@aiworker/web 1.22.0 → 1.23.0

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 (415) hide show
  1. package/README.md +4 -4
  2. package/bin/cli.js +14 -4
  3. package/bin/cli.test.js +165 -73
  4. package/bin/lib/cli-api-target.js +2 -2
  5. package/bin/lib/cli-args.js +119 -119
  6. package/bin/lib/cli-lifecycle.js +9 -9
  7. package/bin/lib/cli-network.js +3 -3
  8. package/bin/lib/cli-paths.js +3 -3
  9. package/bin/lib/cli-ports.js +2 -2
  10. package/bin/lib/cli-process.js +4 -4
  11. package/bin/lib/cli-startup.js +64 -15
  12. package/bin/lib/cli-tunnel-profiles.js +1 -1
  13. package/bin/lib/cli-tunnel-utils.js +2 -2
  14. package/bin/lib/commands-connect-url.js +19 -19
  15. package/bin/lib/commands-lifecycle.js +27 -27
  16. package/bin/lib/commands-logs.js +5 -5
  17. package/bin/lib/commands-models.js +1 -1
  18. package/bin/lib/commands-projects.js +1 -1
  19. package/bin/lib/commands-schedule.js +1 -1
  20. package/bin/lib/commands-serve.js +29 -29
  21. package/bin/lib/commands-session.js +1 -1
  22. package/bin/lib/commands-startup.js +45 -10
  23. package/bin/lib/commands-status.js +1 -1
  24. package/bin/lib/commands-tunnel.js +40 -40
  25. package/bin/lib/commands-update.js +1 -1
  26. package/bin/lib/commands-update.test.js +6 -6
  27. package/dist/assets/{CodeMirrorCommentWidgets-B3u7UIcE.js → CodeMirrorCommentWidgets-B1Gizi3a.js} +1 -1
  28. package/dist/assets/DiffView-DXjVsEOw.js +4 -0
  29. package/dist/assets/DirtyBranchSwitchDialog-aig6zJjg.js +1 -0
  30. package/dist/assets/FilesView-CJdG0-wk.js +17 -0
  31. package/dist/assets/GitView-BXsS3jG6.js +6 -0
  32. package/dist/assets/{JsonTreeView-B0BdZEHG.js → JsonTreeView-D_hpXBnF.js} +1 -1
  33. package/dist/assets/LinearIssuesView-BoUiLQG1.js +1 -0
  34. package/dist/assets/MarkdownImageGallery-B_B_a9KS.js +1 -0
  35. package/dist/assets/MarkdownRendererImpl-xgyyLiBM.js +12 -0
  36. package/dist/assets/OnboardingScreen-DIp84OWt.js +1 -0
  37. package/dist/assets/{PatchDiff-DvfqDql7.js → PatchDiff-8p6nLJaU.js} +1 -1
  38. package/dist/assets/PierreDiffViewer-DjC8nTk9.js +161 -0
  39. package/dist/assets/PlanView-CJTmOF6I.js +5 -0
  40. package/dist/assets/SettingsView-DD-JqIJx.js +28 -0
  41. package/dist/assets/{SettingsWindow-i45U1Cy1.js → SettingsWindow-Cpb4hM6q.js} +1 -1
  42. package/dist/assets/SymbolsNerdFontMono-Regular-aK5vsLov.woff2 +0 -0
  43. package/dist/assets/{ToolOutputDialog-BTwyh5OF.js → ToolOutputDialog-DfaKZXNU.js} +6 -6
  44. package/dist/assets/ToolPartDiffPreview-DtZLzrSK.js +8 -0
  45. package/dist/assets/{VirtualizedFileDiff-DD8lDVej.js → VirtualizedFileDiff-C8i9HpTB.js} +1 -1
  46. package/dist/assets/WalkthroughView-DeKMvZlL.js +4 -0
  47. package/dist/assets/{computeVirtualFileMetrics-BMIRgMHv.js → computeVirtualFileMetrics-BBI7ZwrC.js} +2 -2
  48. package/dist/assets/contextPanelEmbeddedChat-BdA6bdky.js +1 -0
  49. package/dist/assets/de-DCrsQ5zS.js +10 -0
  50. package/dist/assets/es-Dwv4YfH6.js +16 -0
  51. package/dist/assets/fr-BCWg4Cnx.js +14 -0
  52. package/dist/assets/ghostty-vt-DdA0Zryv.wasm +0 -0
  53. package/dist/assets/index-B68h5S5B.css +1 -0
  54. package/dist/assets/index-DVwMarHI.js +39 -0
  55. package/dist/assets/{index-CODwDsU_.js → index-jXSK5RrB.js} +1 -1
  56. package/dist/assets/{isDiffPlainText-BqayB8d3.js → isDiffPlainText-B_x_rVon.js} +1 -1
  57. package/dist/assets/{isFilePlainText-QfoiKJNY.js → isFilePlainText-DW_xMer1.js} +1 -1
  58. package/dist/assets/ja-Bruw3RYC.js +16 -0
  59. package/dist/assets/ko-idhXGF8j.js +16 -0
  60. package/dist/assets/main-BkyaQhJX.js +930 -0
  61. package/dist/assets/{main-C5DVOxc6.js → main-CzdPuL0s.js} +2 -2
  62. package/dist/assets/markdownCore-Cn4Tyejo.js +5 -0
  63. package/dist/assets/{miniChat-DUJ4irZc.js → miniChat-CCkqKOLp.js} +2 -2
  64. package/dist/assets/{mobile-CcaxB0n4.js → mobile-mvxTo055.js} +2 -2
  65. package/dist/assets/patchFileDiff-Csk4iNUi.js +13 -0
  66. package/dist/assets/pl-CGZWUqZJ.js +16 -0
  67. package/dist/assets/pt-BR-B8V7u7tA.js +16 -0
  68. package/dist/assets/renderElectronMiniChatApp-BxoyujA5.js +2 -0
  69. package/dist/assets/renderMobileApp-B48CsP4r.js +25 -0
  70. package/dist/assets/runtimeEndpointReset-Bg5gx18H.js +17 -0
  71. package/dist/assets/scheduledTasksApi-BW0Etzwz.js +1 -0
  72. package/dist/assets/{shikiHighlight-DYOWuY65.js → shikiHighlight-CRl0SUC9.js} +1 -1
  73. package/dist/assets/surface-oMvhsog3.js +1 -0
  74. package/dist/assets/tr-BK_KiO2V.js +7 -0
  75. package/dist/assets/uk-CG74xV8N.js +16 -0
  76. package/dist/assets/useAppFontEffects-CPKeOpUo.js +7284 -0
  77. package/dist/assets/useGitComparison-DH220WmO.js +1 -0
  78. package/dist/assets/useInlineCommentController-BiWz4AVb.js +2 -0
  79. package/dist/assets/useRootScrollLock-BS4-kr7P.js +1 -0
  80. package/dist/assets/{vendor-base-ui-BeMD8X_w.js → vendor-base-ui-DdV8vhHn.js} +1 -1
  81. package/dist/assets/{vendor-codemirror-language-data-DFZik9R2.js → vendor-codemirror-language-data-Bg4AEeCr.js} +2 -2
  82. package/dist/assets/vendor-zod-BPAANqvH.js +39 -0
  83. package/dist/assets/{web-components-Bhg83tjf.js → web-components-z7hfnS8n.js} +1 -1
  84. package/dist/assets/zh-CN-T4AXofZI.js +16 -0
  85. package/dist/assets/zh-TW-Dte40sxp.js +16 -0
  86. package/dist/index.html +21 -59
  87. package/dist/mini-chat.html +7 -7
  88. package/dist/mobile.html +5 -5
  89. package/package.json +3 -4
  90. package/server/index.d.ts +15 -0
  91. package/server/index.js +158 -89
  92. package/server/lib/agent-memory/actions.js +2 -2
  93. package/server/lib/agent-memory/feature-flag.js +1 -1
  94. package/server/lib/agent-memory/feature-flag.test.js +8 -8
  95. package/server/lib/agent-memory/routes.js +2 -2
  96. package/server/lib/agent-tool/runtime.js +37 -54
  97. package/server/lib/agent-tool/runtime.test.js +59 -59
  98. package/server/lib/browser-control/broker.js +3 -3
  99. package/server/lib/browser-control/broker.test.js +1 -1
  100. package/server/lib/changelog/update-notes.js +82 -0
  101. package/server/lib/changelog/update-notes.test.js +59 -0
  102. package/server/lib/client-auth/remote-clients.test.js +5 -5
  103. package/server/lib/context-obligatory/runtime.js +7 -7
  104. package/server/lib/context-obligatory/runtime.test.js +5 -5
  105. package/server/lib/data-dir-migration.js +40 -0
  106. package/server/lib/data-dir-migration.test.js +59 -0
  107. package/server/lib/dev-servers/parse.js +2 -2
  108. package/server/lib/dev-servers/parse.test.js +2 -2
  109. package/server/lib/dev-servers/routes.js +1 -1
  110. package/server/lib/dev-tunnel/DOCUMENTATION.md +13 -4
  111. package/server/lib/dev-tunnel/client.js +1 -1
  112. package/server/lib/dev-tunnel/runtime.js +5 -5
  113. package/server/lib/dev-tunnel/tunnel.test.js +21 -1
  114. package/server/lib/dictation/local/model-catalog.js +1 -1
  115. package/server/lib/dictation/local/worker-process.js +2 -2
  116. package/server/lib/event-stream/directory-ws-bridge.js +1 -1
  117. package/server/lib/event-stream/global-ws-bridge.js +1 -1
  118. package/server/lib/event-stream/protocol.test.js +4 -4
  119. package/server/lib/event-stream/runtime.test.js +18 -18
  120. package/server/lib/fs/DOCUMENTATION.md +5 -0
  121. package/server/lib/fs/routes.js +68 -26
  122. package/server/lib/fs/routes.test.js +208 -22
  123. package/server/lib/git/DOCUMENTATION.md +32 -6
  124. package/server/lib/git/identity-storage.js +1 -1
  125. package/server/lib/git/issue-2746-longpaths.test.js +4 -4
  126. package/server/lib/git/routes.js +41 -5
  127. package/server/lib/git/service.js +300 -224
  128. package/server/lib/git/service.test.js +596 -28
  129. package/server/lib/github/auth.js +8 -8
  130. package/server/lib/github/pr-status.js +1 -1
  131. package/server/lib/github/routes.js +2 -2
  132. package/server/lib/inherited-env.js +17 -10
  133. package/server/lib/inherited-env.test.js +10 -11
  134. package/server/lib/linear/auth.js +8 -8
  135. package/server/lib/linear/auth.test.js +24 -24
  136. package/server/lib/linear/issues.test.js +6 -6
  137. package/server/lib/linear/mapping.test.js +4 -4
  138. package/server/lib/linear/oauth.js +2 -2
  139. package/server/lib/linear/oauth.test.js +14 -14
  140. package/server/lib/linear/routes.js +5 -5
  141. package/server/lib/linear/routes.test.js +16 -16
  142. package/server/lib/linear/status-runtime.test.js +9 -9
  143. package/server/lib/linear/status.js +1 -1
  144. package/server/lib/linear/status.test.js +15 -15
  145. package/server/lib/linear/teams.test.js +4 -4
  146. package/server/lib/magic-prompts/routes.js +2 -2
  147. package/server/lib/mcp-reconnect/DOCUMENTATION.md +55 -0
  148. package/server/lib/mcp-reconnect/runtime.js +122 -0
  149. package/server/lib/mcp-reconnect/runtime.test.js +140 -0
  150. package/server/lib/message-queue/DOCUMENTATION.md +161 -0
  151. package/server/lib/message-queue/runtime.js +870 -0
  152. package/server/lib/message-queue/runtime.test.js +482 -0
  153. package/server/lib/network-defaults.js +23 -0
  154. package/server/lib/network-defaults.test.js +52 -0
  155. package/server/lib/notifications/apns-runtime.js +17 -17
  156. package/server/lib/notifications/apns-runtime.test.js +11 -11
  157. package/server/lib/notifications/emitter-runtime.js +1 -1
  158. package/server/lib/notifications/emitter-runtime.test.js +1 -1
  159. package/server/lib/notifications/push-runtime.js +7 -7
  160. package/server/lib/notifications/routes.js +1 -1
  161. package/server/lib/notifications/runtime.js +1 -1
  162. package/server/lib/openchamber-control/action-resolution.test.js +10 -10
  163. package/server/lib/openchamber-control/actions.js +24 -24
  164. package/server/lib/openchamber-control/error.js +4 -4
  165. package/server/lib/openchamber-control/routes.js +2 -2
  166. package/server/lib/openchamber-control/routes.test.js +5 -5
  167. package/server/lib/openchamber-control/screenshots.js +1 -1
  168. package/server/lib/openchamber-control/screenshots.test.js +1 -1
  169. package/server/lib/openchamber-control/service.js +50 -50
  170. package/server/lib/openchamber-control/service.test.js +5 -5
  171. package/server/lib/openchamber-sessions/routes.js +124 -22
  172. package/server/lib/openchamber-sessions/routes.test.js +99 -11
  173. package/server/lib/opencode/DOCUMENTATION.md +30 -6
  174. package/server/lib/opencode/auth.js +1 -1
  175. package/server/lib/opencode/bootstrap-runtime.js +8 -6
  176. package/server/lib/opencode/cli-options.js +8 -8
  177. package/server/lib/opencode/config-paths.test.js +116 -0
  178. package/server/lib/opencode/core-routes.js +8 -7
  179. package/server/lib/opencode/core-routes.test.js +11 -11
  180. package/server/lib/opencode/env-config.js +5 -5
  181. package/server/lib/opencode/env-config.test.js +7 -7
  182. package/server/lib/opencode/env-runtime.js +10 -10
  183. package/server/lib/opencode/env-runtime.test.js +18 -18
  184. package/server/lib/opencode/feature-routes-runtime.js +19 -12
  185. package/server/lib/opencode/hmr-state-runtime.js +2 -2
  186. package/server/lib/opencode/hmr-state-runtime.test.js +1 -1
  187. package/server/lib/opencode/input-history-scope.js +14 -0
  188. package/server/lib/opencode/lifecycle.js +8 -8
  189. package/server/lib/opencode/lifecycle.test.js +4 -4
  190. package/server/lib/opencode/managed-plugin-config.js +35 -0
  191. package/server/lib/opencode/managed-process-registry.js +3 -3
  192. package/server/lib/opencode/mcp-oauth-callback.test.js +2 -2
  193. package/server/lib/opencode/openchamber-routes.js +79 -19
  194. package/server/lib/opencode/openchamber-routes.test.js +139 -12
  195. package/server/lib/opencode/plugins.js +2 -2
  196. package/server/lib/opencode/plugins.test.js +1 -1
  197. package/server/lib/opencode/project-icon-routes.js +2 -2
  198. package/server/lib/opencode/project-icon-routes.test.js +1 -1
  199. package/server/lib/opencode/providers.js +44 -2
  200. package/server/lib/opencode/providers.test.js +131 -4
  201. package/server/lib/opencode/proxy.js +2 -2
  202. package/server/lib/opencode/pwa-manifest-routes.js +1 -1
  203. package/server/lib/opencode/restart-session-recovery.test.js +1 -1
  204. package/server/lib/opencode/routes-upgrade.test.js +4 -4
  205. package/server/lib/opencode/routes.js +19 -17
  206. package/server/lib/opencode/server-startup-runtime.js +6 -6
  207. package/server/lib/opencode/session-runtime.js +3 -3
  208. package/server/lib/opencode/session-runtime.test.js +6 -6
  209. package/server/lib/opencode/settings-files.js +214 -0
  210. package/server/lib/opencode/settings-helpers.js +116 -44
  211. package/server/lib/opencode/settings-helpers.test.js +354 -12
  212. package/server/lib/opencode/settings-registry.json +747 -0
  213. package/server/lib/opencode/settings-runtime.js +141 -20
  214. package/server/lib/opencode/settings-runtime.test.js +191 -4
  215. package/server/lib/opencode/shared.js +5 -2
  216. package/server/lib/opencode/shared.test.js +7 -7
  217. package/server/lib/opencode/shutdown-runtime.js +2 -0
  218. package/server/lib/opencode/skill-routes.js +2 -1
  219. package/server/lib/opencode/snippets.js +1 -2
  220. package/server/lib/opencode/startup-performance.js +1 -1
  221. package/server/lib/opencode/startup-performance.test.js +6 -6
  222. package/server/lib/opencode/static-routes-runtime.js +8 -8
  223. package/server/lib/opencode/static-routes-runtime.test.js +7 -7
  224. package/server/lib/opencode/upgrade-capability.js +2 -2
  225. package/server/lib/opencode/upgrade-capability.test.js +3 -3
  226. package/server/lib/package-manager.js +17 -42
  227. package/server/lib/package-manager.test.js +19 -19
  228. package/server/lib/permission-auto-accept/runtime.js +1 -1
  229. package/server/lib/project-context/DOCUMENTATION.md +25 -1
  230. package/server/lib/project-context/routes.http.test.js +18 -0
  231. package/server/lib/project-context/routes.js +16 -1
  232. package/server/lib/project-context/runtime.js +248 -23
  233. package/server/lib/project-context/runtime.test.js +106 -3
  234. package/server/lib/projects/DOCUMENTATION.md +76 -0
  235. package/server/lib/projects/project-config.js +144 -11
  236. package/server/lib/projects/project-id.js +17 -0
  237. package/server/lib/projects/project-setup.js +409 -0
  238. package/server/lib/projects/project-setup.test.js +557 -0
  239. package/server/lib/projects/routes.js +59 -0
  240. package/server/lib/quota/DOCUMENTATION.md +40 -2
  241. package/server/lib/quota/credentials/providers.js +4 -0
  242. package/server/lib/quota/credentials/store.js +4 -4
  243. package/server/lib/quota/credentials/store.test.js +8 -8
  244. package/server/lib/quota/index.js +1 -0
  245. package/server/lib/quota/providers/cline-pass.js +125 -0
  246. package/server/lib/quota/providers/cline-pass.test.js +103 -0
  247. package/server/lib/quota/providers/exe-dev.js +75 -0
  248. package/server/lib/quota/providers/exe-dev.test.js +47 -0
  249. package/server/lib/quota/providers/hyper.js +118 -0
  250. package/server/lib/quota/providers/hyper.test.js +126 -0
  251. package/server/lib/quota/providers/index.js +22 -0
  252. package/server/lib/quota/providers/neuralwatt.js +3 -6
  253. package/server/lib/quota/providers/neuralwatt.test.js +7 -7
  254. package/server/lib/quota/providers/ollama-cloud.js +32 -1
  255. package/server/lib/quota/providers/ollama-cloud.test.js +33 -1
  256. package/server/lib/quota/providers/opencode-go.js +3 -2
  257. package/server/lib/quota/providers/opencode-go.test.js +35 -6
  258. package/server/lib/quota/providers/openrouter.js +119 -24
  259. package/server/lib/quota/providers/openrouter.test.js +330 -0
  260. package/server/lib/quota/providers/xai.js +1 -1
  261. package/server/lib/quota/routes.js +2 -0
  262. package/server/lib/quota/utils/auth.js +1 -1
  263. package/server/lib/relay/DOCUMENTATION.md +56 -1
  264. package/server/lib/relay/cross-compat.test.js +26 -0
  265. package/server/lib/relay/downstream-scheduler.js +154 -0
  266. package/server/lib/relay/downstream-scheduler.test.js +162 -0
  267. package/server/lib/relay/e2ee.js +10 -8
  268. package/server/lib/relay/flow-control.test.js +177 -0
  269. package/server/lib/relay/host-client.js +38 -9
  270. package/server/lib/relay/host-client.test.js +9 -1
  271. package/server/lib/relay/host-lock.js +1 -1
  272. package/server/lib/relay/service.js +5 -5
  273. package/server/lib/relay/tunnel-codec.js +9 -0
  274. package/server/lib/relay/tunnel-host.js +69 -18
  275. package/server/lib/relay/tunnel-host.test.js +9 -1
  276. package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +2 -2
  277. package/server/lib/scheduled-tasks/routes.js +5 -5
  278. package/server/lib/scheduled-tasks/service.js +25 -25
  279. package/server/lib/scheduled-tasks/service.test.js +1 -1
  280. package/server/lib/security/bind-host.js +4 -4
  281. package/server/lib/security/bind-host.test.js +1 -1
  282. package/server/lib/security/request-security.js +11 -5
  283. package/server/lib/security/request-security.test.js +14 -14
  284. package/server/lib/session-assist/runtime.js +15 -18
  285. package/server/lib/session-folders/routes.js +2 -2
  286. package/server/lib/session-folders/routes.test.js +8 -8
  287. package/server/lib/session-goal/DOCUMENTATION.md +20 -7
  288. package/server/lib/session-goal/create.js +4 -2
  289. package/server/lib/session-goal/create.test.js +1 -1
  290. package/server/lib/session-goal/objectives.js +4 -4
  291. package/server/lib/session-goal/routes.js +1 -1
  292. package/server/lib/session-goal/runtime.js +91 -30
  293. package/server/lib/session-goal/runtime.test.js +428 -2
  294. package/server/lib/session-knowledge/runtime.js +11 -11
  295. package/server/lib/session-knowledge/runtime.test.js +5 -5
  296. package/server/lib/skills-catalog/DOCUMENTATION.md +1 -1
  297. package/server/lib/skills-catalog/cache.test.js +2 -2
  298. package/server/lib/skills-catalog/disk-cache.js +5 -5
  299. package/server/lib/skills-catalog/github-meta.test.js +2 -2
  300. package/server/lib/skills-catalog/install.js +3 -2
  301. package/server/lib/small-model/DOCUMENTATION.md +7 -2
  302. package/server/lib/small-model/call.js +18 -7
  303. package/server/lib/small-model/call.test.js +58 -6
  304. package/server/lib/small-model/index.js +12 -16
  305. package/server/lib/small-model/index.test.js +1 -1
  306. package/server/lib/small-model/resolve.js +1 -1
  307. package/server/lib/small-model/resolve.test.js +1 -1
  308. package/server/lib/small-model/routes.js +2 -1
  309. package/server/lib/small-model/runtime-providers.js +15 -7
  310. package/server/lib/small-model/runtime-providers.test.js +7 -1
  311. package/server/lib/system-prompt/runtime.js +3 -22
  312. package/server/lib/system-prompt/runtime.test.js +3 -3
  313. package/server/lib/terminal/DOCUMENTATION.md +14 -10
  314. package/server/lib/terminal/runtime.js +190 -31
  315. package/server/lib/terminal/runtime.test.js +572 -38
  316. package/server/lib/terminal/shells.js +20 -3
  317. package/server/lib/terminal/shells.test.js +33 -2
  318. package/server/lib/tts/base-url.js +3 -3
  319. package/server/lib/tts/routes.test.js +20 -20
  320. package/server/lib/ui-auth/ui-auth.js +12 -9
  321. package/server/lib/ui-auth/ui-auth.test.js +19 -3
  322. package/server/lib/ui-auth/ui-passkeys.js +7 -7
  323. package/server/lib/walkthrough/DOCUMENTATION.md +33 -14
  324. package/server/lib/walkthrough/index.js +1 -0
  325. package/server/lib/walkthrough/jobs.test.js +1 -1
  326. package/server/lib/walkthrough/language.test.js +1 -1
  327. package/server/lib/walkthrough/model-settings.js +11 -15
  328. package/server/lib/walkthrough/model-settings.test.js +1 -1
  329. package/server/lib/walkthrough/prompt.js +3 -1
  330. package/server/lib/walkthrough/pull-request.test.js +5 -5
  331. package/server/lib/walkthrough/reproduce-2607.test.js +2 -2
  332. package/server/lib/walkthrough/routes.test.js +26 -5
  333. package/server/lib/walkthrough/sources.js +23 -2
  334. package/server/lib/walkthrough/store.js +3 -3
  335. package/server/lib/walkthrough/store.test.js +1 -1
  336. package/server/opencode-proxy.test.js +2 -2
  337. package/server/proxy-headers.js +1 -1
  338. package/server/sse-routes.test.js +4 -4
  339. package/README.md.bak +0 -250
  340. package/bin/lib/DOCUMENTATION.md.bak +0 -163
  341. package/dist/assets/CommitSection-SGBCAW0w.js +0 -1
  342. package/dist/assets/DiffView-DluiRSla.js +0 -4
  343. package/dist/assets/FilesView-Bdq8ppva.js +0 -17
  344. package/dist/assets/GitView-Znn7VJcP.js +0 -6
  345. package/dist/assets/LinearIssuesView-jP-hXyac.js +0 -1
  346. package/dist/assets/MarkdownImageGallery-ClOvuZxC.js +0 -1
  347. package/dist/assets/MarkdownRendererImpl-Dt9mjTRN.js +0 -12
  348. package/dist/assets/OnboardingScreen-D2DG7K6b.js +0 -1
  349. package/dist/assets/PierreDiffViewer-B7m3f0d7.js +0 -157
  350. package/dist/assets/PlanView-B0F3BtPZ.js +0 -5
  351. package/dist/assets/SettingsView-BBW-S-gh.js +0 -28
  352. package/dist/assets/ToolPartDiffPreview-CUNe28U1.js +0 -8
  353. package/dist/assets/WalkthroughView-egQgxel3.js +0 -4
  354. package/dist/assets/contextPanelEmbeddedChat-C3fjDbdg.js +0 -1
  355. package/dist/assets/de-C1P6X5Rs.js +0 -9
  356. package/dist/assets/es-CDgaF1_t.js +0 -15
  357. package/dist/assets/fr-Bgxqvvz_.js +0 -13
  358. package/dist/assets/index-C57jT0Sa.css +0 -1
  359. package/dist/assets/index-DW_E3rnL.js +0 -7
  360. package/dist/assets/ja-BDRrEcNP.js +0 -15
  361. package/dist/assets/ko-Ba8sQV79.js +0 -15
  362. package/dist/assets/main-Bv5Pkngh.js +0 -928
  363. package/dist/assets/markdownCore-CZwzz5gw.js +0 -3
  364. package/dist/assets/patchFileDiff-yNfWXN4E.js +0 -10
  365. package/dist/assets/pl-Dioz29BI.js +0 -15
  366. package/dist/assets/pt-BR-DIs6ElwV.js +0 -15
  367. package/dist/assets/renderElectronMiniChatApp-BcKLHXKe.js +0 -2
  368. package/dist/assets/renderMobileApp-D9yQJy0L.js +0 -25
  369. package/dist/assets/runtimeEndpointReset-CjhvxLH0.js +0 -16
  370. package/dist/assets/scheduledTasksApi-DLW0mkQK.js +0 -1
  371. package/dist/assets/tr-DFnMlPxY.js +0 -6
  372. package/dist/assets/uk-ZrCNjM7Y.js +0 -15
  373. package/dist/assets/useAppFontEffects-CjrntdL0.js +0 -7310
  374. package/dist/assets/useInlineCommentController-CDEuSlPH.js +0 -2
  375. package/dist/assets/useRootScrollLock-BHYPkrLv.js +0 -1
  376. package/dist/assets/vendor-ghostty-web-CrxinGGH.js +0 -13
  377. package/dist/assets/vendor-zod-BLfBSgBh.js +0 -39
  378. package/dist/assets/zh-CN-iv_AV4EC.js +0 -15
  379. package/dist/assets/zh-TW-CzEUk38j.js +0 -15
  380. package/server/index.d.ts.bak +0 -39
  381. package/server/lib/agent-tool/DOCUMENTATION.md.bak +0 -119
  382. package/server/lib/browser-control/DOCUMENTATION.md.bak +0 -50
  383. package/server/lib/context-obligatory/DOCUMENTATION.md.bak +0 -19
  384. package/server/lib/dev-tunnel/DOCUMENTATION.md.bak +0 -57
  385. package/server/lib/dictation/DOCUMENTATION.md.bak +0 -100
  386. package/server/lib/event-stream/DOCUMENTATION.md.bak +0 -62
  387. package/server/lib/fs/DOCUMENTATION.md.bak +0 -47
  388. package/server/lib/git/DOCUMENTATION.md.bak +0 -193
  389. package/server/lib/github/DOCUMENTATION.md.bak +0 -183
  390. package/server/lib/linear/DOCUMENTATION.md.bak +0 -97
  391. package/server/lib/linear/OAUTH-BROKER-HANDOFF.md.bak +0 -91
  392. package/server/lib/markdown-image-grants/DOCUMENTATION.md.bak +0 -40
  393. package/server/lib/notifications/APNS.md.bak +0 -135
  394. package/server/lib/notifications/DOCUMENTATION.md.bak +0 -138
  395. package/server/lib/openchamber-control/DOCUMENTATION.md.bak +0 -64
  396. package/server/lib/opencode/DOCUMENTATION.md.bak +0 -431
  397. package/server/lib/opencode/managed-process-registry.d.ts.bak +0 -13
  398. package/server/lib/opencode/provider-env-aliases.d.ts.bak +0 -3
  399. package/server/lib/permission-auto-accept/DOCUMENTATION.md.bak +0 -34
  400. package/server/lib/project-context/DOCUMENTATION.md.bak +0 -160
  401. package/server/lib/quota/DOCUMENTATION.md.bak +0 -123
  402. package/server/lib/relay/DOCUMENTATION.md.bak +0 -100
  403. package/server/lib/scheduled-tasks/DOCUMENTATION.md.bak +0 -182
  404. package/server/lib/session-assist/DOCUMENTATION.md.bak +0 -66
  405. package/server/lib/session-goal/DOCUMENTATION.md.bak +0 -213
  406. package/server/lib/session-knowledge/DOCUMENTATION.md.bak +0 -89
  407. package/server/lib/skills-catalog/DOCUMENTATION.md.bak +0 -151
  408. package/server/lib/small-model/DOCUMENTATION.md.bak +0 -212
  409. package/server/lib/system-prompt/DOCUMENTATION.md.bak +0 -36
  410. package/server/lib/terminal/DOCUMENTATION.md.bak +0 -50
  411. package/server/lib/text/DOCUMENTATION.md.bak +0 -35
  412. package/server/lib/tts/DOCUMENTATION.md.bak +0 -147
  413. package/server/lib/tunnels/DOCUMENTATION.md.bak +0 -21
  414. package/server/lib/ui-auth/DOCUMENTATION.md.bak +0 -44
  415. package/server/lib/walkthrough/DOCUMENTATION.md.bak +0 -411
@@ -1,16 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CODwDsU_.js","assets/useAppFontEffects-CjrntdL0.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-DW_E3rnL.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-zod-BLfBSgBh.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-C57jT0Sa.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-BeMD8X_w.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/contextPanelEmbeddedChat-C3fjDbdg.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/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-DFZik9R2.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-gg7YLRW7.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/computeVirtualFileMetrics-BMIRgMHv.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/isFilePlainText-QfoiKJNY.js","assets/isDiffPlainText-BqayB8d3.js","assets/vendor-diff-C3JhlQdm.js","assets/vendor-lru_map-Tstukz9J.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/PlanView-B0F3BtPZ.js","assets/shikiHighlight-DYOWuY65.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useInlineCommentController-CDEuSlPH.js","assets/CodeMirrorCommentWidgets-B3u7UIcE.js","assets/vendor-ghostty-web-CrxinGGH.js","assets/vendor-capacitor-keyboard-CYccoJjr.js","assets/vendor-capacitor-core-B4EWRrHz.js"])))=>i.map(i=>d[i]);
2
- import{_ as Qt}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as Ve,r as de,j as t,R as m}from"./vendor-react-BUCujlKS.js";import{ea as No,c6 as jr,c7 as kr,aS as Io,f as nt,o as Co,bG as Is,bH as Cs,bJ as Ts,I as E,c2 as To,b_ as On,h as ie,B as Ne,bd as Nr,g as Do,t as Se,eb as Po,ec as Ro,ed as Eo,O as Ao,dT as Bo,ee as Lo,ef as Mo,eg as Fo,y as at,eh as Oo,l as kt,ei as $o,dt as Ir,ej as Uo,du as Wo,b$ as Ds,cQ as _o,bI as zs,b8 as Vo,bb as zo,ba as Go,b5 as Gs,ek as Ho,el as Ko,em as qo,en as Yo,eo as Jo,ep as Qo,eq as Xo,er as Zo,b as It,ca as ea,a2 as $n,be as ta,dN as Cr,dC as Tr,dE as sa,es as na,u as Yt,cC as ra,et as hn,S as yt,dk as oa,eu as Un,ev as aa,ew as ia,ex as Wn,ey as la,ez as ca,eA as da,eB as ua,b6 as fa,eC as ma,b4 as zt,b1 as Gt,b3 as Ht,bZ as Hs,bU as Dn,bV as Pn,eD as Dr,bW as Pr,bX as Rn,bY as js,L as Rr,eE as ha,N as pa,eF as ga,eG as _n,eH as xa,T as ba,U as ya,R as wa,eI as Er,eJ as va,e0 as Sa,r as Ar,eK as ja,eL as ka,eM as Na,a0 as pn,a6 as ms,a7 as hs,a8 as ps,cx as gn,cy as xn,cz as bn,cA as yn,cs as Ut,ct as Pt,eN as Us,b0 as At,bD as wn,M as Ss,bK as Ia,bL as En,V as An,at as Ws,c8 as Ca,eO as Br,au as Vn,c0 as Ta,dJ as Da,ag as Bn,eP as Es,m as Lr,cU as Vt,eQ as Pa,eR as Qs,eS as Ra,eT as zn,cS as Gn,eU as Ea,c1 as Aa,eV as Ba,eW as La,dD as Ma,eX as Fa,eY as Oa,cw as $a,_ as Ua,H as Wa,c as _a,d as Va,cN as za,eZ as Mr,Z as Fr,W as Ga,e1 as Dt,e_ as Ha,e$ as Ka,f0 as Or,$ as Ks,f1 as Rt,f2 as vn,f3 as qa,f4 as $r,f5 as As,cf as Ya,f6 as Ja,f7 as Qa,f8 as Xa,f9 as Za,fa as ei,dd as ti,dp as si,Y as Sn,dZ as ni,c_ as ri,ar as oi,ab as ai,bS as ii,fb as Ur,e7 as li,fc as ci,fd as di,fe as ui,ff as fi,bP as mi,cY as hi}from"./useAppFontEffects-CjrntdL0.js";import{al as Hn,am as pi,an as Kn,ao as gi,i as xi,ap as bi,F as Wr,$ as yi,r as Lt,u as He,A as wi,b as vi,v as Si,a as Xs,d as qn,a0 as _r,X as ji,aq as Ot,o as ki,m as gs,z as Vr,a3 as Ni,a4 as Ii,ar as Ci,as as Ti,w as fs,V as Di,H as jn,at as Pi,aa as Ri,au as bs,av as Zs,aw as zr,U as Ei,n as Ai,y as Bi}from"./index-DW_E3rnL.js";import{g as Li,h as Mi,i as Fi,d as Oi,C as $i,c as Ui,M as Wi,S as _i,a as Vi,b as zi}from"./vendor-base-ui-BeMD8X_w.js";import{c as qs,d as Gr,p as Hr,a as Gi}from"./vendor-zustand-BAGL70zf.js";import{i as Kr}from"./contextPanelEmbeddedChat-C3fjDbdg.js";import{f as qr,h as Yr,P as Jr,k as Hi,D as Qr,j as Xr}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as Zr,S as eo,h as Ki,v as qi,a as Yi}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as to}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";const Ji=["typescript","javascript","tsx","jsx","json","markdown"],so={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:"none"},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:"word-alt"}};let Yn=null;const no=()=>(Yn??=Promise.all([Qt(()=>import("./index-CODwDsU_.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])),Qt(()=>import("./workerFactory-tw7cIdmV.js"),[]),Qt(()=>import("./appThemeRegistry-BK0dHKa6.js"),__vite__mapDeps([113,114,100,101,5,85,86,87,88,89,90,91,92,93,94,95,96,97,98]))]).then(([s,e,n])=>({WorkerPoolManager:s.WorkerPoolManager,workerFactory:e.workerFactory,ensurePierreThemeRegistered:n.ensurePierreThemeRegistered})),Yn),ks={},Jn=new Set,kn=new Set;let Os={light:"pierre-light",dark:"pierre-dark"};const Qi=()=>{for(const s of kn)s()},ro=(s,e)=>{e.setRenderOptions({theme:Os,lineDiffType:so[s].lineDiffType})},Nn=s=>{typeof window>"u"||Jn.has(s)||(Jn.add(s),no().then(e=>{if(ks[s])return;const n=so[s],r=new e.WorkerPoolManager({workerFactory:e.workerFactory,poolSize:n.poolSize,totalASTLRUCacheSize:n.totalASTLRUCacheSize},{theme:{light:"pierre-light",dark:"pierre-dark"},langs:Ji,lineDiffType:n.lineDiffType,preferredHighlighter:"shiki-wasm"});r.initialize(),ks[s]=r,ro(s,r),Qi()}))},Xi=s=>(kn.add(s),()=>kn.delete(s)),Zi=s=>{if(!(Os.light===s.light&&Os.dark===s.dark)){Os=s;for(const e of Object.keys(ks)){const n=ks[e];n&&ro(e,n)}}},Tf=s=>{const e=Ve.c(15),{children:n}=s,r=No();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Hn(!1),e[0]=o):o=e[0];const a=o;let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=Hn(!0),e[1]=i):i=e[1];const c=i,l=r?.lightThemeId??a.metadata.id,d=r?.darkThemeId??c.metadata.id;let u;e[2]!==l||e[3]!==r?.availableThemes?(u=r?.availableThemes.find(k=>k.metadata.id===l)??a,e[2]=l,e[3]=r?.availableThemes,e[4]=u):u=e[4];const h=u;let b;e[5]!==d||e[6]!==r?.availableThemes?(b=r?.availableThemes.find(k=>k.metadata.id===d)??c,e[5]=d,e[6]=r?.availableThemes,e[7]=b):b=e[7];const f=b;let x,g;e[8]!==f||e[9]!==h?(x=()=>{let k=!1;return no().then(P=>{k||(P.ensurePierreThemeRegistered(h),P.ensurePierreThemeRegistered(f),Zi({light:h.metadata.id,dark:f.metadata.id}))}),()=>{k=!0}},g=[f,h],e[8]=f,e[9]=h,e[10]=x,e[11]=g):(x=e[10],g=e[11]),de.useEffect(x,g);let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[12]=j):j=e[12],de.useEffect(tl,j);let p;return e[13]!==n?(p=t.jsx(t.Fragment,{children:n}),e[13]=n,e[14]=p):p=e[14],p},Df=s=>{const e=Ve.c(5),n=s===void 0?"unified":s;let r;e[0]!==n?(r=()=>ks[n],e[0]=n,e[1]=r):r=e[1];const o=de.useSyncExternalStore(Xi,r,sl);let a,i;return e[2]!==n?(a=()=>{Nn(n)},i=[n],e[2]=n,e[3]=a,e[4]=i):(a=e[3],i=e[4]),de.useEffect(a,i),o};function el(){Nn("unified"),Nn("split")}function tl(){if(typeof window>"u")return;const s=el;if(typeof window.requestIdleCallback=="function"){const n=window.requestIdleCallback(s,{timeout:5e3});return()=>window.cancelIdleCallback(n)}const e=window.setTimeout(s,2e3);return()=>window.clearTimeout(e)}function sl(){}const en=(s,e)=>jr(kr.getState().dictionary,s,e),nl=s=>{const e=s.message.toLowerCase();return e.includes("code signature")||e.includes("did not pass validation")||e.includes("code requirement")||e.includes("not signed")?"signature":e.includes("command is disabled")?"updater-disabled":"unknown"},rl=s=>{const e=nl(s);return e==="signature"?en("updateDialog.error.signatureRejected"):e==="updater-disabled"?en("updateDialog.error.updaterDisabled"):s.message.trim()||en("updateDialog.error.restartFailed")},Qn="aiworker.update-install-id";function ol(){if(!(typeof window>"u"||typeof crypto.randomUUID!="function"))try{const s=window.localStorage.getItem(Qn)?.trim();if(s)return s;const e=crypto.randomUUID();return window.localStorage.setItem(Qn,e),e}catch{return}}function al(){if(typeof window>"u")return"unknown";try{const{deviceType:s}=Io();return s}catch{return"unknown"}}function il(){const s=typeof window<"u"?window.__AIWORKER_ELECTRON__?.arch?.toLowerCase?.():void 0;if(s==="arm64"||s==="aarch64")return"arm64";if(s==="x64"||s==="amd64"||s==="x86_64")return"x64";const e=typeof window<"u"?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e==="arm64"||e==="aarch64")return"arm64";if(e==="x64"||e==="amd64"||e==="x86_64")return"x64";const r=(typeof navigator<"u"?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(r==="arm"||r==="arm64"||r==="aarch64")return"arm64";if(r==="x86"||r==="x64"||r==="amd64")return"x64";const o=typeof navigator<"u"?navigator.userAgent.toLowerCase():"";return o.includes("aarch64")||o.includes("arm64")||o.includes("armv")?"arm64":o.includes("x86_64")||o.includes("x64")||o.includes("amd64")||o.includes("win64")?"x64":"unknown"}function ll(){const s=vi();if(s==="android"||s==="ios")return s;if(typeof navigator>"u")return"web";const e=(navigator.platform||"").toLowerCase();return e.includes("mac")?"macos":e.includes("win")?"windows":e.includes("linux")?"linux":"web"}function cl(s){const e=He.getState().reportUsage,n=new URLSearchParams({reportUsage:e?"true":"false"});if(n.set("deviceClass",al()),n.set("arch",il()),n.set("platform",ll()),e&&(s==="desktop"||s==="mobile")){const r=ol();r&&n.set("installId",r)}return s==="desktop"?(n.set("appType","desktop-electron"),n.set("instanceMode",wi()?"local":"remote"),n):s==="vscode"?(n.set("appType","vscode"),n.set("instanceMode","local"),n):s==="mobile"?(n.set("appType","mobile-capacitor"),n.set("instanceMode","remote"),n):(n.set("appType","web"),n.set("instanceMode","unknown"),n)}async function Bs(s,e){try{const n=cl(s),r=typeof window<"u"?window.__VSCODE_CONFIG__?.extensionVersion:void 0;e?n.set("currentVersion",e):s==="vscode"&&r&&n.set("currentVersion",r);const o=await Lt(`/api/openchamber/update-check?${n.toString()}`,{method:"GET",headers:{Accept:"application/json"},priority:"low"});if(!o.ok)throw new Error(`Server responded with ${o.status}`);const a=await o.json();return{available:a.available??!1,version:a.version,currentVersion:a.currentVersion??"unknown",body:a.body,releaseUrl:a.releaseUrl,downloadUrl:a.downloadUrl,nextSuggestedCheckInSec:typeof a.nextSuggestedCheckInSec=="number"&&Number.isFinite(a.nextSuggestedCheckInSec)?a.nextSuggestedCheckInSec:void 0,packageManager:a.packageManager,updateCommand:a.updateCommand}}catch(n){return console.warn("Failed to check for updates:",n),null}}function dl(){return xi()?"mobile":bi()?"desktop":Wr()?"vscode":yi()?"web":null}const Xn={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null},ul=qs()((s,e)=>({...Xn,checkForUpdates:async()=>{const n=dl();if(!n)return null;s({checking:!0,error:null,runtimeType:n});try{let r=null,o=null;if(n==="desktop"){const a="1.22.0",[i,c]=await Promise.allSettled([Kn(),Bs("desktop",a)]),l=i.status==="fulfilled"?i.value:null;return o=c.status==="fulfilled"?c.value?.nextSuggestedCheckInSec??null:null,s({checking:!1,available:l?.available??!1,info:l,lastChecked:Date.now(),nextCheckInSec:o}),o}else n==="web"?(r=await Bs("web"),o=r?.nextSuggestedCheckInSec??null):n==="vscode"?o=(await Bs("vscode"))?.nextSuggestedCheckInSec??null:n==="mobile"&&(r=await Bs("mobile","1.22.0"),o=r?.nextSuggestedCheckInSec??null);return s({checking:!1,available:n==="vscode"?!1:r?.available??!1,info:n==="vscode"?null:r,lastChecked:Date.now(),nextCheckInSec:o}),o}catch(r){return s({checking:!1,error:r instanceof Error?r.message:"Failed to check for updates"}),null}},downloadUpdate:async()=>{const{available:n,runtimeType:r}=e();if(!(r!=="desktop"||!n)){s({downloading:!0,error:null,progress:null});try{const o=await Kn();if(!o?.available)throw new Error("Update detected, but desktop package is not ready yet. Retry in a moment.");if(s(i=>({info:i.info?{...i.info,...o,body:i.info.body||o.body,available:i.info.available}:o})),!await gi(i=>{s({progress:i})}))throw new Error("Desktop update only works on Local instance");s({downloading:!1,downloaded:!0})}catch(o){s({downloading:!1,error:o instanceof Error?o.message:"Failed to download update"})}}},restartToUpdate:async()=>{const{downloaded:n,runtimeType:r}=e();if(!(r!=="desktop"||!n)){s({error:null});try{if(!await pi())throw new Error(jr(kr.getState().dictionary,"updateDialog.error.restartUnavailable"))}catch(o){s({error:rl(o instanceof Error?o:new Error(String(o)))})}}},dismiss:()=>{s({available:!1,downloaded:!1,info:null})},reset:()=>{s(Xn)}})),Zn="https://github.com/openchamber/openchamber/releases";function fl(s){const e=new Date(`${s}T00:00:00`);return Number.isNaN(e.getTime())?s:new Intl.DateTimeFormat(Nr(),{year:"numeric",month:"short",day:"numeric"}).format(e)}function ml(s){return s.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,"").trim()}function er(s){return s.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,"$1[@$2](https://github.com/$2)")}function hl(s,e){const n=s.split(".").map(o=>Number.parseInt(o,10)),r=e.split(".").map(o=>Number.parseInt(o,10));for(let o=0;o<3;o+=1){const a=Number.isFinite(n[o])?n[o]:0,i=Number.isFinite(r[o])?r[o]:0;if(a!==i)return i-a}return 0}function pl(s){const e=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[];let r;for(;(r=e.exec(s))!==null;)n.push({version:r[1]??"",date:r[2]??"",start:r.index});return n.length===0?[]:n.map((o,a)=>{const i=n[a+1]?.start??s.length,c=s.slice(o.start,i).trim();return{version:o.version,date:o.date,start:o.start,end:i,raw:c}})}const tr=2e3,gl=600*1e3;async function xl(){try{const s=await Lt("/api/openchamber/update-install",{method:"POST",headers:{"Content-Type":"application/json"}});return s.ok?{success:!0,autoRestart:(await s.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await s.json().catch(()=>({}))).error||`Server error: ${s.status}`}}catch(s){return{success:!1,error:s instanceof Error?s.message:void 0}}}async function bl(){try{return(await Lt("/health",{method:"GET",headers:{Accept:"application/json"}})).ok}catch{return!1}}async function yl(s,e=Math.ceil(gl/tr),n=tr){for(let r=0;r<e;r++){try{const o=await Lt("/api/openchamber/update-check?reportUsage=false",{method:"GET",headers:{Accept:"application/json"}});if(o.ok){const a=await o.json().catch(()=>null);if(a&&a.available===!1||a&&typeof a.currentVersion=="string"&&typeof s=="string"&&a.currentVersion!==s)return!0}else if((o.status===401||o.status===403)&&await bl())return!0}catch{}await new Promise(o=>setTimeout(o,n))}return!1}const Pf=({open:s,onOpenChange:e,info:n,downloading:r,downloaded:o,progress:a,error:i,onDownload:c,onRestart:l,runtimeType:d="desktop"})=>{const{t:u}=nt(),[h,b]=de.useState(!1),[f,x]=de.useState("idle"),[g,j]=de.useState(null),p=n?.version?n.releaseUrl||`${Zn}/tag/v${n.version}`:Zn,k=n?.downloadUrl||p,P=a?.total?Math.round(a.downloaded/a.total*100):0,A=d==="web",N=d==="mobile",C=n?.updateCommand||"aiworker update";de.useEffect(()=>{s||(x("idle"),j(null))},[s]);const w=async()=>{(await Do(C)).ok&&(b(!0),setTimeout(()=>b(!1),2e3))},v=de.useCallback(async K=>{await Co(K)},[]),L=de.useCallback(async()=>{x("updating"),j(null);const K=await xl();if(!K.success){x("error"),j(K.error||u("updateDialog.error.updateFailed"));return}K.autoRestart&&(x("restarting"),await new Promise(Y=>setTimeout(Y,2e3))),x("reconnecting"),await yl(n?.currentVersion)?window.location.reload():(x("error"),j(u("updateDialog.error.takingLonger")))},[n?.currentVersion,u]),$=de.useCallback(()=>{v(k)},[v,k]),M=f!=="idle"&&f!=="error",H=de.useMemo(()=>{if(!n?.body)return null;const K=n.body.trim();if(!K)return null;const ee=pl(K);if(ee.length===0)return{kind:"raw",title:u("updateDialog.changelog.title"),content:er(K)};const Y=[...ee].sort((O,_)=>hl(O.version,_.version));return{kind:"sections",title:u("updateDialog.changelog.title"),sections:Y.map(O=>({version:O.version,dateLabel:fl(O.date),content:er(ml(O.raw)||K)}))}},[n?.body,u]);return t.jsx(Is,{open:s,onOpenChange:M?void 0:e,children:t.jsxs(Cs,{className:"max-w-4xl p-5 bg-background border-[var(--interactive-border)]",showCloseButton:!0,children:[t.jsxs("div",{className:"flex items-center mb-1",children:[t.jsxs(Ts,{className:"flex items-center gap-2.5",children:[t.jsx(E,{name:"download-cloud",className:"h-5 w-5 text-[var(--primary-base)]"}),t.jsx("span",{className:"text-lg font-semibold text-foreground",children:u(f==="restarting"||f==="reconnecting"?"updateDialog.header.updating":"updateDialog.header.updateAvailable")})]}),(n?.currentVersion||n?.version)&&t.jsxs("div",{className:"flex items-center gap-2 font-mono text-sm ml-3",children:[n?.currentVersion&&t.jsx("span",{className:"text-muted-foreground",children:n.currentVersion}),n?.currentVersion&&n?.version&&t.jsx("span",{className:"text-muted-foreground/50",children:"→"}),n?.version&&t.jsx("span",{className:"text-[var(--primary-base)] font-medium",children:n.version})]})]}),t.jsxs("div",{className:"space-y-2",children:[A&&M&&t.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(E,{name:"loader",className:"h-5 w-5 animate-spin text-[var(--primary-base)]"}),t.jsxs("div",{className:"typography-ui-label text-foreground",children:[f==="updating"&&u("updateDialog.status.installingUpdate"),f==="restarting"&&u("updateDialog.status.serverRestarting"),f==="reconnecting"&&u("updateDialog.status.waitingForServer")]})]}),t.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:u("updateDialog.status.autoReloadHint")})]}),H&&!M&&t.jsx("div",{className:"rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 overflow-hidden",children:t.jsx(To,{className:"max-h-[400px] p-0",fillContainer:!1,children:H.kind==="raw"?t.jsx("div",{className:"p-4 typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline",onClickCapture:K=>{const Y=K.target.closest("a");Y&&Y.href&&(K.preventDefault(),K.stopPropagation(),v(Y.href))},children:t.jsx(On,{content:H.content,disableLinkSafety:!0,enableFileReferences:!1})}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:H.sections.map(K=>t.jsxs("div",{className:"p-4",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.jsxs("span",{className:"typography-ui-label font-mono text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-1.5 py-0.5 rounded",children:["v",K.version]}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:K.dateLabel})]}),t.jsx("div",{className:"typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline",onClickCapture:ee=>{const O=ee.target.closest("a");O&&O.href&&(ee.preventDefault(),ee.stopPropagation(),v(O.href))},children:t.jsx(On,{content:K.content,disableLinkSafety:!0,enableFileReferences:!1})})]},K.version))})})}),A&&f==="error"&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(E,{name:"terminal",className:"h-4 w-4"}),t.jsx("span",{children:u("updateDialog.fallback.updateViaTerminal")})]}),t.jsxs("div",{className:"flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]",children:[t.jsx("code",{className:"flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap",children:C}),t.jsx("button",{onClick:w,className:ie("flex items-center justify-center p-2 rounded","text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]","transition-colors",h&&"text-[var(--status-success)]"),title:u(h?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:h?t.jsx(E,{name:"check",className:"h-4 w-4"}):t.jsx(E,{name:"clipboard",className:"h-4 w-4"})})]})]}),!A&&!N&&r&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:u("updateDialog.status.downloadingPayload")}),t.jsxs("span",{className:"font-mono text-foreground",children:[P,"%"]})]}),t.jsx("div",{className:"h-1.5 bg-[var(--surface-subtle)] rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-[var(--primary-base)] transition-all duration-300",style:{width:`${P}%`}})})]}),(i||g)&&t.jsx("div",{className:"p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg",children:t.jsx("p",{className:"text-sm text-[var(--status-error)]",children:i||g})})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4",children:[t.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors shrink-0",children:[t.jsx(E,{name:"external-link",className:"h-4 w-4"}),"GitHub"]}),t.jsxs("div",{className:"flex-1 flex justify-end",children:[!A&&!N&&!o&&!r&&t.jsxs("button",{onClick:c,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(E,{name:"download",className:"h-4 w-4"}),u("updateDialog.actions.downloadUpdate")]}),!A&&!N&&r&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(E,{name:"loader",className:"h-4 w-4 animate-spin"}),u("updateDialog.status.downloading")]}),!A&&!N&&o&&t.jsxs("button",{onClick:l,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--status-success)] text-white hover:opacity-90 transition-opacity",children:[t.jsx(E,{name:"restart",className:"h-4 w-4"}),u("updateDialog.actions.restartToUpdate")]}),N&&t.jsxs(Ne,{onClick:$,size:"default",children:[t.jsx(E,{name:"external-link",className:"h-4 w-4"}),u("updateDialog.actions.openMobileUpdate")]}),A&&!M&&t.jsxs("button",{onClick:L,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(E,{name:"download",className:"h-4 w-4"}),u("updateDialog.actions.updateNow")]}),A&&M&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(E,{name:"loader",className:"h-4 w-4 animate-spin"}),u("updateDialog.status.updating")]})]})]})]})})},Rf=s=>!(s.dismissed==="true"||s.sessionShown==="true"||s.hasActiveToast),wl=s=>!(!s.version||s.seenVersions.has(s.version)||s.dismissedVersion!==null&&s.dismissedVersion===s.version),vl=s=>{if(s===null||typeof s!="object")return"";const e=s.version;return typeof e!="string"?"":e.trim()},Sl=s=>!s||s.upgrade?.supported!==!0||s.available!==!0||typeof s.latestVersion!="string"?"":s.latestVersion.trim(),us="opencode-update-available",Ls="opencode-upgrade-progress",jl=5e3,kl=[1e4,6e4],sr="opencode-update-toast-dismissed-version",Ef=()=>{const{t:s}=nt(),e=He(i=>i.showOpenCodeUpdateNotifications),n=de.useRef(new Set),r=de.useRef(!1);de.useEffect(()=>{e||Se.dismiss(us)},[e]);const o=de.useCallback(()=>{Se.dismiss(Ls),Po({message:s("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]}).catch(()=>{})},[s]),a=de.useCallback(async()=>{if(!r.current){r.current=!0,Se.dismiss(us),Se.message(s("opencodeUpdate.toast.upgrading.title"),{id:Ls,description:s("opencodeUpdate.toast.upgrading.description"),duration:1/0,icon:t.jsx(E,{name:"refresh",className:"h-4 w-4 animate-spin text-muted-foreground"})});try{const i=await Lt("/api/opencode/upgrade",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),c=await i.json().catch(()=>null);if(!i.ok||c?.success===!1)throw new Error(c?.error||i.statusText||s("opencodeUpdate.toast.failed.description"));Se.success(s("opencodeUpdate.toast.updated.title"),{id:Ls,description:c?.version?s("opencodeUpdate.toast.updated.descriptionWithVersion",{version:c.version}):s("opencodeUpdate.toast.updated.description"),duration:1/0,icon:t.jsx(E,{name:"check",className:"h-4 w-4 text-[var(--status-success)]"}),action:{label:s("opencodeUpdate.toast.actions.reload"),onClick:o}})}catch(i){Se.error(s("opencodeUpdate.toast.failed.title"),{id:Ls,description:i instanceof Error?i.message:s("opencodeUpdate.toast.failed.description"),duration:1/0})}finally{r.current=!1}}},[o,s]);return de.useEffect(()=>{const i=b=>{if(!He.getState().showOpenCodeUpdateNotifications){Se.dismiss(us);return}wl({version:b,dismissedVersion:qn().getItem(sr),seenVersions:n.current})&&(n.current.add(b),Se.info(s("opencodeUpdate.toast.available.title"),{id:us,description:s("opencodeUpdate.toast.available.description",{version:b}),duration:1/0,action:{label:s("opencodeUpdate.toast.actions.update"),onClick:a},cancel:{label:s("opencodeUpdate.toast.actions.dismiss"),onClick:()=>{qn().setItem(sr,b),_r({openCodeUpdateToastDismissedVersion:b}),Se.dismiss(us)}}}))};let c=!1;const l=[],d=async(b,f=Xs())=>{try{const x=await Lt("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!x.ok)throw new Error(x.statusText||"OpenCode upgrade status check failed");const g=await x.json().catch(()=>null),j=Sl(g);!c&&f===Xs()&&j&&i(j)}catch{const x=kl[b];!c&&f===Xs()&&x!==void 0&&l.push(setTimeout(()=>{d(b+1,f)},x))}},u=b=>{vl(b.detail)&&d(0)};e&&l.push(setTimeout(()=>{d(0)},jl));const h=Si(({runtimeKey:b})=>{n.current.clear(),Se.dismiss(us),He.getState().showOpenCodeUpdateNotifications&&d(0,b)});return window.addEventListener("aiworker:opencode-update-available",u),()=>{c=!0;for(const b of l)clearTimeout(b);h(),window.removeEventListener("aiworker:opencode-update-available",u)}},[a,e,s]),null},Af=()=>{const s=Ve.c(3),[e,n]=m.useState(Nl),{isUpdating:r}=e;let o,a;if(s[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>Eo(n),a=[],s[0]=o,s[1]=a):(o=s[0],a=s[1]),m.useEffect(o,a),!r)return null;let i;return s[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-background/90",children:t.jsx(Ao,{width:80,height:80,isAnimated:!0})}),s[2]=i):i=s[2],i};function Nl(){return Ro()}class Il extends m.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){this.setState({error:e,errorInfo:n})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?t.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:t.jsxs(Bo,{className:"w-full max-w-md",children:[t.jsx(Lo,{className:"text-center",children:t.jsxs(Mo,{className:"flex items-center justify-center gap-2 text-destructive",children:[t.jsx(E,{name:"chat-3",className:"h-5 w-5"}),this.props.texts.title]})}),t.jsxs(Fo,{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground text-center",children:this.props.texts.description}),this.props.sessionId&&t.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:[this.props.texts.sessionLabel,": ",this.props.sessionId]}),this.state.error&&t.jsxs("details",{className:"text-xs font-mono bg-muted p-3 rounded",children:[t.jsx("summary",{className:"cursor-pointer hover:bg-interactive-hover/80",children:this.props.texts.detailsSummary}),t.jsx("pre",{className:"mt-2 max-h-48 overflow-auto",children:this.state.error.toString()})]}),t.jsx("div",{className:"flex gap-2",children:t.jsxs(Ne,{onClick:this.handleReset,variant:"outline",className:"flex-1",children:[t.jsx(E,{name:"restart",className:"h-4 w-4 mr-2"}),this.props.texts.resetAction]})}),t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:this.props.texts.persistentHint})]})]})}):this.props.children}}function Cl(s){const e=Ve.c(22),{t:n}=nt();let r;e[0]!==n?(r=n("chat.errorBoundary.title"),e[0]=n,e[1]=r):r=e[1];let o;e[2]!==n?(o=n("chat.errorBoundary.description"),e[2]=n,e[3]=o):o=e[3];let a;e[4]!==n?(a=n("chat.errorBoundary.sessionLabel"),e[4]=n,e[5]=a):a=e[5];let i;e[6]!==n?(i=n("chat.errorBoundary.detailsSummary"),e[6]=n,e[7]=i):i=e[7];let c;e[8]!==n?(c=n("chat.errorBoundary.resetAction"),e[8]=n,e[9]=c):c=e[9];let l;e[10]!==n?(l=n("chat.errorBoundary.persistentHint"),e[10]=n,e[11]=l):l=e[11];let d;e[12]!==r||e[13]!==o||e[14]!==a||e[15]!==i||e[16]!==c||e[17]!==l?(d={title:r,description:o,sessionLabel:a,detailsSummary:i,resetAction:c,persistentHint:l},e[12]=r,e[13]=o,e[14]=a,e[15]=i,e[16]=c,e[17]=l,e[18]=d):d=e[18];let u;return e[19]!==s||e[20]!==d?(u=t.jsx(Il,{...s,texts:d}),e[19]=s,e[20]=d,e[21]=u):u=e[21],u}const Bf=s=>{const e=Ve.c(8),{active:n,messagesEnabled:r,readOnly:o,initialAllowPromptingSubagentSessions:a}=s,i=n===void 0?!0:n,c=o===void 0?!1:o,d=at(Tl)||void 0;let u;e[0]!==i||e[1]!==a||e[2]!==r||e[3]!==c?(u=t.jsx(Oo,{active:i,messagesEnabled:r,readOnly:c,initialAllowPromptingSubagentSessions:a}),e[0]=i,e[1]=a,e[2]=r,e[3]=c,e[4]=u):u=e[4];let h;return e[5]!==d||e[6]!==u?(h=t.jsx(Cl,{sessionId:d,children:u}),e[5]=d,e[6]=u,e[7]=h):h=e[7],h};function Tl(s){return s.currentSessionId}const Dl=Li,Pl=s=>{const e=Ve.c(14);let n,r,o,a;e[0]!==s?({className:o,asChild:n,children:r,...a}=s,e[0]=s,e[1]=n,e[2]=r,e[3]=o,e[4]=a):(n=e[1],r=e[2],o=e[3],a=e[4]);let i;e[5]!==n||e[6]!==r?(i=n&&de.isValidElement(r)?{render:r}:{children:r},e[5]=n,e[6]=r,e[7]=i):i=e[7];const c=i;let l;e[8]!==o?(l=ie("flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",o),e[8]=o,e[9]=l):l=e[9];let d;return e[10]!==a||e[11]!==c||e[12]!==l?(d=t.jsx(Mi,{className:l,...a,...c}),e[10]=a,e[11]=c,e[12]=l,e[13]=d):d=e[13],d},Rl=s=>{const e=Ve.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=ie("transition-opacity duration-100 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0","motion-reduce:transition-none",n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(Fi,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a},nr=s=>({providerID:s.providerID,modelID:s.modelID,variant:s.variant,agent:s.agent});function El(s){const e=Ve.c(131),{t:n}=nt(),{open:r,onOpenChange:o,target:a,projectDirectory:i,submitting:c,allowRunAsGoal:l,onConfirm:d}=s,u=c===void 0?!1:c,h=l===void 0?!1:l;let b;e[0]!==h?(b=h&&!Wr(),e[0]=h,e[1]=b):b=e[1];const f=b,x=kt(Vl),g=kt(_l),j=$o(Wl),p=kt(Ul),k=kt($l),P=kt(Ol),A=kt(Fl),N=kt(Ml);let C;e[2]!==N||e[3]!==P||e[4]!==k||e[5]!==A?(C=()=>nr({providerID:k,modelID:P,variant:A,agent:N}),e[2]=N,e[3]=P,e[4]=k,e[5]=A,e[6]=C):C=e[6];const[w,v]=m.useState(C);let L,$;e[7]!==j||e[8]!==g||e[9]!==x||e[10]!==r||e[11]!==i?(L=()=>{r&&(x({directory:i,source:"todoSendDialog"}),g({directory:i}),j())},$=[r,x,g,j,i],e[7]=j,e[8]=g,e[9]=x,e[10]=r,e[11]=i,e[12]=L,e[13]=$):(L=e[12],$=e[13]),m.useEffect(L,$);let M,H;e[14]!==N||e[15]!==P||e[16]!==k||e[17]!==A||e[18]!==r?(M=()=>{r&&v(nr({providerID:k,modelID:P,variant:A,agent:N}))},H=[r,k,P,A,N],e[14]=N,e[15]=P,e[16]=k,e[17]=A,e[18]=r,e[19]=M,e[20]=H):(M=e[19],H=e[20]),m.useEffect(M,H);let K,ee;e[21]!==w.modelID||e[22]!==w.providerID||e[23]!==r||e[24]!==p?(K=()=>{if(!r||p.length===0)return;const Fe=p.find(Qe=>Qe.id===w.providerID)??p[0],$e=Array.isArray(Fe?.models)?Fe.models:[],st=$e.some(Qe=>Qe.id===w.modelID),Re=$e[0]?.id??"";Fe?.id===w.providerID&&st||v(Qe=>({...Qe,providerID:Fe?.id??"",modelID:st?Qe.modelID:Re,variant:""}))},ee=[r,p,w.providerID,w.modelID],e[21]=w.modelID,e[22]=w.providerID,e[23]=r,e[24]=p,e[25]=K,e[26]=ee):(K=e[25],ee=e[26]),m.useEffect(K,ee);const Y=Ll;let O;if(e[27]!==w.modelID||e[28]!==w.providerID||e[29]!==p){let Fe;e[31]!==w.providerID?(Fe=st=>st.id===w.providerID,e[31]=w.providerID,e[32]=Fe):Fe=e[32],O=p.find(Fe)?.models?.find(st=>st.id===w.modelID),e[27]=w.modelID,e[28]=w.providerID,e[29]=p,e[30]=O}else O=e[30];const _=O;let U;e[33]!==_?(U=_?.variants?Object.keys(_.variants):[],e[33]=_,e[34]=U):U=e[34];const J=U,D=J.length>0;let z,F;e[35]!==w.variant||e[36]!==D?(z=()=>{D||!w.variant||v(Bl)},F=[D,w.variant],e[35]=w.variant,e[36]=D,e[37]=z,e[38]=F):(z=e[37],F=e[38]),m.useEffect(z,F);let R;e[39]!==w.modelID||e[40]!==w.providerID?(R=w.providerID.trim().length>0&&w.modelID.trim().length>0,e[39]=w.modelID,e[40]=w.providerID,e[41]=R):R=e[41];const V=R;let ne;e[42]!==V||e[43]!==w||e[44]!==d||e[45]!==u?(ne=()=>{!V||u||d(w)},e[42]=V,e[43]=w,e[44]=d,e[45]=u,e[46]=ne):ne=e[46];const Q=ne;let q,oe;e[47]!==Q||e[48]!==r?(q=()=>{if(!r)return;const Fe=$e=>{($e.metaKey||$e.ctrlKey)&&$e.key==="Enter"&&($e.preventDefault(),Q())};return window.addEventListener("keydown",Fe),()=>window.removeEventListener("keydown",Fe)},oe=[r,Q],e[47]=Q,e[48]=r,e[49]=q,e[50]=oe):(q=e[49],oe=e[50]),m.useEffect(q,oe);let Z;e[51]!==n||e[52]!==a?(Z=n(a==="worktree"?"rightSidebar.contextNotesTodo.sendDialog.title.newWorktree":"rightSidebar.contextNotesTodo.sendDialog.title.newSession"),e[51]=n,e[52]=a,e[53]=Z):Z=e[53];const te=Z;let ye;e[54]!==o||e[55]!==u?(ye=Fe=>{u||o(Fe)},e[54]=o,e[55]=u,e[56]=ye):ye=e[56];let re;e[57]!==te?(re=t.jsx(zs,{children:t.jsx(Ts,{children:te})}),e[57]=te,e[58]=re):re=e[58];let ge;e[59]!==n?(ge=n("chat.modelControls.model"),e[59]=n,e[60]=ge):ge=e[60];let se;e[61]!==ge?(se=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:ge}),e[61]=ge,e[62]=se):se=e[62];let fe;e[63]===Symbol.for("react.memo_cache_sentinel")?(fe=(Fe,$e)=>{v(st=>({...st,providerID:Fe,modelID:$e,variant:""}))},e[63]=fe):fe=e[63];let he;e[64]!==w.modelID||e[65]!==w.providerID?(he=t.jsx(Ir,{providerId:w.providerID,modelId:w.modelID,className:"max-w-[320px] justify-between",dropdownPortalToBody:!0,onChange:fe}),e[64]=w.modelID,e[65]=w.providerID,e[66]=he):he=e[66];let S;e[67]!==se||e[68]!==he?(S=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[se,he]}),e[67]=se,e[68]=he,e[69]=S):S=e[69];let B;e[70]!==n?(B=n("sessions.scheduledTasks.editor.thinkingLevel.label"),e[70]=n,e[71]=B):B=e[71];let W;e[72]!==B?(W=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:B}),e[72]=B,e[73]=W):W=e[73];const le=!D;let pe;e[74]===Symbol.for("react.memo_cache_sentinel")?(pe=Fe=>v($e=>({...$e,variant:Fe})),e[74]=pe):pe=e[74];let Te;e[75]!==w.variant||e[76]!==le||e[77]!==J?(Te=t.jsx(Uo,{value:w.variant,options:J,disabled:le,onChange:pe}),e[75]=w.variant,e[76]=le,e[77]=J,e[78]=Te):Te=e[78];let Ie;e[79]!==W||e[80]!==Te?(Ie=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[W,Te]}),e[79]=W,e[80]=Te,e[81]=Ie):Ie=e[81];let We;e[82]!==n?(We=n("sessions.scheduledTasks.editor.agent.label"),e[82]=n,e[83]=We):We=e[83];let Me;e[84]!==We?(Me=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:We}),e[84]=We,e[85]=Me):Me=e[85];let ve;e[86]===Symbol.for("react.memo_cache_sentinel")?(ve=Fe=>v($e=>({...$e,agent:Fe})),e[86]=ve):ve=e[86];let Be;e[87]!==w.agent?(Be=t.jsx(Wo,{agentName:w.agent,filter:Y,dropdownPortalToBody:!0,onChange:ve}),e[87]=w.agent,e[88]=Be):Be=e[88];let Ee;e[89]!==Me||e[90]!==Be?(Ee=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[Me,Be]}),e[89]=Me,e[90]=Be,e[91]=Ee):Ee=e[91];let Oe;e[92]!==S||e[93]!==Ie||e[94]!==Ee?(Oe=t.jsxs("div",{className:"flex flex-col gap-4",children:[S,Ie,Ee]}),e[92]=S,e[93]=Ie,e[94]=Ee,e[95]=Oe):Oe=e[95];const ze=`flex items-center gap-3 ${f?"justify-between":"justify-end"}`;let qe;e[96]!==w.runAsGoal||e[97]!==f||e[98]!==u||e[99]!==n?(qe=f?t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ds,{checked:w.runAsGoal===!0,onChange:Fe=>v($e=>({...$e,runAsGoal:Fe})),disabled:u,ariaLabel:n("sessions.scheduledTasks.editor.goal.aria")}),t.jsx("button",{type:"button",className:"truncate typography-ui-label text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:u,onClick:()=>v(Al),children:n("sessions.scheduledTasks.editor.goal.label")})]}):null,e[96]=w.runAsGoal,e[97]=f,e[98]=u,e[99]=n,e[100]=qe):qe=e[100];let Ke;e[101]!==o?(Ke=()=>o(!1),e[101]=o,e[102]=Ke):Ke=e[102];let _e;e[103]!==n?(_e=n("rightSidebar.contextNotesTodo.sendDialog.actions.cancel"),e[103]=n,e[104]=_e):_e=e[104];let et;e[105]!==u||e[106]!==Ke||e[107]!==_e?(et=t.jsx(Ne,{variant:"ghost",size:"sm",onClick:Ke,disabled:u,children:_e}),e[105]=u,e[106]=Ke,e[107]=_e,e[108]=et):et=e[108];const dt=!V||u;let je;e[109]!==u||e[110]!==n?(je=n(u?"rightSidebar.contextNotesTodo.sendDialog.actions.sending":"rightSidebar.contextNotesTodo.sendDialog.actions.send"),e[109]=u,e[110]=n,e[111]=je):je=e[111];let Xe;e[112]!==Q||e[113]!==dt||e[114]!==je?(Xe=t.jsx(Ne,{size:"sm",onClick:Q,disabled:dt,children:je}),e[112]=Q,e[113]=dt,e[114]=je,e[115]=Xe):Xe=e[115];let tt;e[116]!==et||e[117]!==Xe?(tt=t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[et,Xe]}),e[116]=et,e[117]=Xe,e[118]=tt):tt=e[118];let Je;e[119]!==ze||e[120]!==qe||e[121]!==tt?(Je=t.jsxs("div",{className:ze,children:[qe,tt]}),e[119]=ze,e[120]=qe,e[121]=tt,e[122]=Je):Je=e[122];let Ce;e[123]!==re||e[124]!==Oe||e[125]!==Je?(Ce=t.jsxs(Cs,{className:"max-w-md overflow-visible",children:[re,Oe,Je]}),e[123]=re,e[124]=Oe,e[125]=Je,e[126]=Ce):Ce=e[126];let it;return e[127]!==r||e[128]!==ye||e[129]!==Ce?(it=t.jsx(Is,{open:r,onOpenChange:ye,children:Ce}),e[127]=r,e[128]=ye,e[129]=Ce,e[130]=it):it=e[130],it}function Al(s){return{...s,runAsGoal:s.runAsGoal!==!0}}function Bl(s){return{...s,variant:""}}function Ll(s){return _o(s.mode)}function Ml(s){return s.currentAgentName||""}function Fl(s){return s.currentVariant||""}function Ol(s){return s.currentModelId}function $l(s){return s.currentProviderId}function Ul(s){return s.providers}function Wl(s){return s.loadAgents}function _l(s){return s.loadAgents}function Vl(s){return s.loadProviders}function zl(s){const e=Ve.c(4);let n;e[0]!==s?({...n}=s,e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=t.jsx(Oi,{...n}),e[2]=n,e[3]=r):r=e[3],r}function Gl(s){const e=Ve.c(4);let n;e[0]!==s?({...n}=s,e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=t.jsx($i,{...n}),e[2]=n,e[3]=r):r=e[3],r}function Hl(s){const e=Ve.c(20);let n,r,o,a,i;e[0]!==s?({className:r,positionerClassName:o,children:n,style:i,...a}=s,e[0]=s,e[1]=n,e[2]=r,e[3]=o,e[4]=a,e[5]=i):(n=e[1],r=e[2],o=e[3],a=e[4],i=e[5]);let c;e[6]!==o?(c=ie("app-region-no-drag z-50",o),e[6]=o,e[7]=c):c=e[7];let l;e[8]!==i?(l={color:"var(--surface-elevated-foreground)",...i},e[8]=i,e[9]=l):l=e[9];let d;e[10]!==r?(d=ie(Vo,r),e[10]=r,e[11]=d):d=e[11];let u;e[12]!==n||e[13]!==a||e[14]!==l||e[15]!==d?(u=t.jsx(Ui,{"data-slot":"dropdown-menu-content",style:l,className:d,...a,children:n}),e[12]=n,e[13]=a,e[14]=l,e[15]=d,e[16]=u):u=e[16];let h;return e[17]!==c||e[18]!==u?(h=t.jsx(Vi,{children:t.jsx(zi,{className:c,children:u})}),e[17]=c,e[18]=u,e[19]=h):h=e[19],h}function Lf(s){const e=Ve.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=ie(zo,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(Wi,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}function Mf(s){const e=Ve.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=ie(Go,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(_i,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}const Kl=280,rr=4,ql=({transform:s})=>({...s,y:0}),Yl=s=>{const e=Ve.c(18),{id:n,children:r,className:o}=s;let a;e[0]!==n?(a={id:n},e[0]=n,e[1]=a):a=e[1];const{attributes:i,listeners:c,setNodeRef:l,transform:d,transition:u,isDragging:h}=Zr(a);let b;e[2]!==d?(b=to.Transform.toString(d),e[2]=d,e[3]=b):b=e[3];let f;e[4]!==b||e[5]!==u?(f={transform:b,transition:u},e[4]=b,e[5]=u,e[6]=f):f=e[6];const x=h&&"opacity-50";let g;e[7]!==o||e[8]!==x?(g=ie("h-full rounded-md",o,x),e[7]=o,e[8]=x,e[9]=g):g=e[9];let j;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==c||e[14]!==l||e[15]!==f||e[16]!==g?(j=t.jsx("div",{ref:l,"data-sortable-tab-id":n,style:f,className:g,...i,...c,children:r}),e[10]=i,e[11]=r,e[12]=n,e[13]=c,e[14]=l,e[15]=f,e[16]=g,e[17]=j):j=e[17],j},Jl=s=>{const e=Ve.c(6),{id:n,children:r,className:o}=s;let a;e[0]!==o?(a=ie("h-full",o),e[0]=o,e[1]=a):a=e[1];let i;return e[2]!==r||e[3]!==n||e[4]!==a?(i=t.jsx("div",{className:a,"data-sortable-tab-id":n,children:r}),e[2]=r,e[3]=n,e[4]=a,e[5]=i):i=e[5],i},Ns=s=>{const e=Ve.c(137),{items:n,activeId:r,onSelect:o,onClose:a,onReorder:i,layoutMode:c,variant:l,activePillInsetClassName:d,activePillButtonClassName:u,inactiveTabsIconOnly:h,animateActivePill:b,activePillLowercase:f,nonCompositedIndicator:x,tabContextMenu:g,className:j}=s,p=c===void 0?"scrollable":c,k=l===void 0?"default":l,P=h===void 0?!1:h,A=f===void 0?!0:f,N=x===void 0?!1:x,{t:C}=nt(),w=He(Ql),{isTablet:v}=Gs(),L=w||v,$=m.useRef(null);let M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M={left:!1,right:!1},e[0]=M):M=e[0];const[H,K]=m.useState(M);let ee;e[1]!==n?(ee=n.map(Xl),e[1]=n,e[2]=ee):ee=e[2];const Y=ee,O=p==="scrollable",_=k==="default",U=k==="active-pill",D=U||k==="animated",z=_,F=D||z,R=U&&O,V=D,ne=b??D,Q=typeof i=="function",q=Q?Yl:Jl;let oe;e[3]===Symbol.for("react.memo_cache_sentinel")?(oe=new Map,e[3]=oe):oe=e[3];const Z=m.useRef(oe),[te,ye]=m.useState(null),[re,ge]=m.useState(!1),[se,fe]=m.useState(null),he=m.useRef(!1),S=m.useRef(0),B=m.useRef(r),W=m.useRef(null);let le;e:{if(!F||!se||!r||se===r){le=0;break e}const Pe=n.findIndex(Ye=>Ye.id===se),ce=n.findIndex(Ye=>Ye.id===r);if(Pe<0||ce<0){le=0;break e}le=Pe>ce?rr:-rr}const pe=le;let Te;e[4]===Symbol.for("react.memo_cache_sentinel")?(Te={activationConstraint:{distance:8}},e[4]=Te):Te=e[4];const Ie=qr(Yr(Jr,Te)),We=Zl;let Me;e[5]===Symbol.for("react.memo_cache_sentinel")?(Me=(Pe,ce)=>{if(ce){Z.current.set(Pe,ce);return}Z.current.delete(Pe)},e[5]=Me):Me=e[5];const ve=Me;let Be;e[6]!==r||e[7]!==F?(Be=()=>{if(!F||!r){ye(ec);return}const Pe=$.current,ce=Z.current.get(r);if(!Pe||!ce){ye(tc);return}let Ye=0,ct=0,pt=ce;for(;pt&&pt!==Pe;)Ye=Ye+pt.offsetLeft,ct=ct+pt.offsetTop,pt=pt.offsetParent;const bt={left:Ye,top:ct,width:ce.offsetWidth,height:ce.offsetHeight};ye(St=>We(St,bt)?St:bt)},e[6]=r,e[7]=F,e[8]=Be):Be=e[8];const Ee=Be;let Oe;e[9]!==O?(Oe=()=>{if(!O){K({left:!1,right:!1});return}const Pe=$.current;if(!Pe){K({left:!1,right:!1});return}K({left:Pe.scrollLeft>2,right:Pe.scrollLeft+Pe.clientWidth<Pe.scrollWidth-2})},e[9]=O,e[10]=Oe):Oe=e[10];const ze=Oe;let qe;e[11]!==O||e[12]!==ze?(qe=()=>{if(!O){K({left:!1,right:!1});return}const Pe=$.current;if(!Pe)return;ze(),Pe.addEventListener("scroll",ze,{passive:!0});const ce=new ResizeObserver(ze);return ce.observe(Pe),()=>{Pe.removeEventListener("scroll",ze),ce.disconnect()}},e[11]=O,e[12]=ze,e[13]=qe):qe=e[13];let Ke;e[14]!==O||e[15]!==n.length||e[16]!==ze?(Ke=[O,n.length,ze],e[14]=O,e[15]=n.length,e[16]=ze,e[17]=Ke):Ke=e[17],m.useEffect(qe,Ke);let _e;e[18]!==r||e[19]!==Ee||e[20]!==F?(_e=()=>{if(!F){ye(null);return}Ee();const Pe=$.current;if(!Pe)return;const ce=new ResizeObserver(()=>{performance.now()-S.current>Kl&&ge(!1),Ee()});if(ce.observe(Pe),r){const Ye=Z.current.get(r);Ye&&ce.observe(Ye)}return()=>{ce.disconnect()}},e[18]=r,e[19]=Ee,e[20]=F,e[21]=_e):_e=e[21];let et;e[22]!==r||e[23]!==n.length||e[24]!==Ee||e[25]!==F?(et=[r,n.length,Ee,F],e[22]=r,e[23]=n.length,e[24]=Ee,e[25]=F,e[26]=et):et=e[26],m.useEffect(_e,et);let dt;e[27]!==Ee?(dt=()=>{Ee()},e[27]=Ee,e[28]=dt):dt=e[28],m.useLayoutEffect(dt);let je;e[29]!==Y?(je=Y.join("\0"),e[29]=Y,e[30]=je):je=e[30];const Xe=je;let tt,Je;e[31]!==r||e[32]!==Xe||e[33]!==F?(tt=()=>{if(!F){he.current=!1,ge(!1);return}const Pe=W.current!==Xe;if(W.current=Xe,!he.current){he.current=!0,B.current=r;return}const ce=B.current!==r;if(B.current=r,!ce||Pe){ge(!1);return}S.current=performance.now(),ge(!0)},Je=[r,Xe,F],e[31]=r,e[32]=Xe,e[33]=F,e[34]=tt,e[35]=Je):(tt=e[34],Je=e[35]),m.useLayoutEffect(tt,Je);let Ce;e[36]!==r||e[37]!==O||e[38]!==ze?(Ce=()=>{if(!O||!r)return;const Pe=$.current;if(!Pe)return;const ce=window.requestAnimationFrame(()=>{const Ye=typeof window.CSS?.escape=="function"?window.CSS.escape(r):r.replace(/"/g,'\\"'),ct=Pe.querySelector(`[data-sortable-tab-id="${Ye}"]`);ct&&(ct.scrollIntoView({block:"nearest",inline:"nearest"}),ze())});return()=>{window.cancelAnimationFrame(ce)}},e[36]=r,e[37]=O,e[38]=ze,e[39]=Ce):Ce=e[39];let it;e[40]!==r||e[41]!==O||e[42]!==n.length||e[43]!==ze?(it=[r,O,n.length,ze],e[40]=r,e[41]=O,e[42]=n.length,e[43]=ze,e[44]=it):it=e[44],m.useEffect(Ce,it);let Fe;e[45]!==i?(Fe=Pe=>{if(!i)return;const{active:ce,over:Ye}=Pe;!Ye||ce.id===Ye.id||i(String(ce.id),String(Ye.id))},e[45]=i,e[46]=Fe):Fe=e[46];const $e=Fe;let st;e[47]!==j?(st=ie("relative flex h-full min-w-0 flex-1",j),e[47]=j,e[48]=st):st=e[48];let Re;e[49]!==O||e[50]!==H||e[51]!==D?(Re=O&&H.left?t.jsx("div",{className:ie("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",D?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[49]=O,e[50]=H,e[51]=D,e[52]=Re):Re=e[52];let Qe;e[53]!==O||e[54]!==H||e[55]!==D?(Qe=O&&H.right?t.jsx("div",{className:ie("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",D?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[53]=O,e[54]=H,e[55]=D,e[56]=Qe):Qe=e[56];const ut=D?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",lt=D&&"@container/pill-tabs",mt=D&&"pill-tabs__track",y=D&&(d??"gap-0.5 py-0.5"),G=z&&"items-center overflow-y-hidden",ke=V&&"rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_4%,transparent)] p-0.5 gap-0.5",Ue=O?"overflow-x-auto scrollbar-none":"overflow-x-hidden";let De;e[57]!==ut||e[58]!==lt||e[59]!==mt||e[60]!==y||e[61]!==G||e[62]!==ke||e[63]!==Ue?(De=ie("relative flex h-full min-w-0 flex-1",ut,lt,mt,y,G,ke,Ue),e[57]=ut,e[58]=lt,e[59]=mt,e[60]=y,e[61]=G,e[62]=ke,e[63]=Ue,e[64]=De):De=e[64];let I;e[65]!==O?(I=O?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,e[65]=O,e[66]=I):I=e[66];let ae;e[67]!==C?(ae=C("sortableTabsStrip.aria.tabs"),e[67]=C,e[68]=ae):ae=e[68];let xe;e[69]!==N||e[70]!==pe||e[71]!==te||e[72]!==re||e[73]!==ne||e[74]!==D?(xe=D&&te?t.jsx("div",{className:ie("pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[var(--surface-elevated)]","border border-[color-mix(in_srgb,var(--foreground)_7%,transparent)]","shadow-[0_1px_2px_color-mix(in_srgb,var(--foreground)_10%,transparent),0_2px_6px_color-mix(in_srgb,var(--foreground)_6%,transparent)]",ne&&re&&(N?"pill-tabs__indicator--is-animated-layout":"pill-tabs__indicator--is-animated")),style:N?{left:`${te.left+pe}px`,top:`${te.top}px`,width:`${te.width}px`,height:`${te.height}px`}:{transform:`translate3d(${te.left+pe}px, ${te.top}px, 0)`,width:`${te.width}px`,height:`${te.height}px`}}):null,e[69]=N,e[70]=pe,e[71]=te,e[72]=re,e[73]=ne,e[74]=D,e[75]=xe):xe=e[75];let ue;e[76]!==pe||e[77]!==te||e[78]!==re||e[79]!==z?(ue=z&&te?t.jsx("div",{className:ie("pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",re&&"underline-tabs__indicator--is-animated"),style:{transform:`translate3d(${te.left+pe}px, 0, 0)`,width:`${te.width}px`},"aria-hidden":!0}):null,e[76]=pe,e[77]=te,e[78]=re,e[79]=z,e[80]=ue):ue=e[80];let Le;if(e[81]!==q||e[82]!==r||e[83]!==u||e[84]!==A||e[85]!==L||e[86]!==P||e[87]!==U||e[88]!==w||e[89]!==O||e[90]!==Y||e[91]!==n||e[92]!==a||e[93]!==o||e[94]!==g||e[95]!==R||e[96]!==D||e[97]!==F){let Pe;e[99]!==q||e[100]!==r||e[101]!==u||e[102]!==A||e[103]!==L||e[104]!==P||e[105]!==U||e[106]!==w||e[107]!==O||e[108]!==Y||e[109]!==a||e[110]!==o||e[111]!==g||e[112]!==R||e[113]!==D||e[114]!==F?(Pe=(ce,Ye)=>{const ct=ce.id===r,pt=P&&D&&!ct&&!!ce.icon,bt=!pt,St=!!ce.icon,Nt=P&&D&&ct&&!O&&!R,wt=ce.closable!==!1&&!!a,jt=wt&&!!ce.icon,Ct=O||R?void 0:D?Nt?"flex-none basis-auto":w?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",Et=wt?ht=>{ht.button===1&&(ht.preventDefault(),ht.stopPropagation(),a?.(ce.id))}:void 0,_t=wt?sc:void 0,Mt=!w&&g?g({id:ce.id,index:Ye,isActive:ct,allIds:Y,close:()=>a?.(ce.id)}):null,Xt=t.jsxs("div",{ref:ht=>ve(ce.id,ht),onAuxClick:Et,onMouseDown:_t,className:ie("group flex h-full min-w-0 flex-nowrap items-center",O||R?"shrink-0":D?"w-full":"w-full min-w-0",D?"relative z-10 bg-transparent":ct?"relative z-10 bg-transparent text-foreground":"relative z-10 bg-transparent text-muted-foreground hover:text-foreground"),children:[t.jsx("button",{type:"button",role:"tab","aria-selected":ct,"aria-label":pt?ce.title??ce.label:void 0,onClick:()=>o(ce.id),onPointerDown:F?()=>{ge(!0),fe(ce.id)}:void 0,onPointerUp:F?()=>fe(null):void 0,onPointerLeave:F?()=>fe(null):void 0,onPointerCancel:F?()=>fe(null):void 0,className:ie(D?"animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0":"flex h-full min-w-0 flex-nowrap items-center typography-micro",D&&A?"lowercase":null,D&&(pt?"gap-0":"gap-1.5"),D?R?"shrink-0 whitespace-nowrap px-3 text-center":O?"max-w-56 shrink-0 px-3 text-center":pt?"px-2 !min-w-0 text-center":Nt?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":O?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",D?u??(U?w?"h-[38px]":"h-[31px]":"h-7"):null,D?ct?"text-foreground":"text-muted-foreground hover:text-foreground":null,D?"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background":null),title:ce.title??ce.label,children:D?t.jsxs(t.Fragment,{children:[St?t.jsxs("span",{className:"relative flex h-4 w-4 shrink-0 items-center justify-center",children:[t.jsx("span",{className:ie("flex items-center justify-center transition-opacity",jt&&(L?"opacity-0":"group-hover:opacity-0")),children:ce.icon}),jt?t.jsx("span",{role:"button",tabIndex:-1,className:ie("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",L?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:nc,onClick:ht=>{ht.stopPropagation(),a?.(ce.id)},"aria-label":ce.closeLabel??`Close ${ce.label} tab`,title:ce.closeLabel??`Close ${ce.label} tab`,children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,bt?t.jsx("span",{className:"animated-tabs__label truncate",children:ce.label}):null]}):t.jsxs("span",{className:ie("flex min-w-0 flex-nowrap items-center gap-1.5",!O&&"justify-center"),children:[St?t.jsxs("span",{className:ie("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",ct?"text-[var(--primary-base)]":"text-muted-foreground"),children:[t.jsx("span",{className:ie("flex items-center justify-center transition-opacity",jt&&(L?"opacity-0":"group-hover:opacity-0")),children:ce.icon}),jt?t.jsx("span",{role:"button",tabIndex:-1,className:ie("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",L?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:rc,onClick:ht=>{ht.stopPropagation(),a?.(ce.id)},"aria-label":ce.closeLabel??`Close ${ce.label} tab`,title:ce.closeLabel??`Close ${ce.label} tab`,children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,t.jsx("span",{className:"truncate leading-[1.2]",children:ce.label})]})}),wt&&!jt?t.jsx("button",{type:"button",onPointerDown:oc,onClick:ht=>{ht.stopPropagation(),a?.(ce.id)},className:ie("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",D?"-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md":"aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1",D?ct?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":ct?"text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100"),"aria-label":ce.closeLabel??`Close ${ce.label} tab`,title:ce.closeLabel??`Close ${ce.label} tab`,children:t.jsx(E,{name:"close",className:"h-3 w-3"})}):null]});return t.jsx(q,{id:ce.id,className:Ct,children:Mt?t.jsxs(zl,{children:[t.jsx(Gl,{render:ht=>t.jsx("div",{...ht,className:ie("flex h-full min-w-0",ht.className),children:Xt})}),t.jsx(Hl,{className:"w-52",children:Mt})]}):Xt},ce.id)},e[99]=q,e[100]=r,e[101]=u,e[102]=A,e[103]=L,e[104]=P,e[105]=U,e[106]=w,e[107]=O,e[108]=Y,e[109]=a,e[110]=o,e[111]=g,e[112]=R,e[113]=D,e[114]=F,e[115]=Pe):Pe=e[115],Le=n.map(Pe),e[81]=q,e[82]=r,e[83]=u,e[84]=A,e[85]=L,e[86]=P,e[87]=U,e[88]=w,e[89]=O,e[90]=Y,e[91]=n,e[92]=a,e[93]=o,e[94]=g,e[95]=R,e[96]=D,e[97]=F,e[98]=Le}else Le=e[98];let T;e[116]!==De||e[117]!==I||e[118]!==ae||e[119]!==xe||e[120]!==ue||e[121]!==Le?(T=t.jsxs("div",{ref:$,className:De,style:I,role:"tablist","aria-label":ae,children:[xe,ue,Le]}),e[116]=De,e[117]=I,e[118]=ae,e[119]=xe,e[120]=ue,e[121]=Le,e[122]=T):T=e[122];let X;e[123]!==st||e[124]!==Re||e[125]!==Qe||e[126]!==T?(X=t.jsxs("div",{className:st,children:[Re,Qe,T]}),e[123]=st,e[124]=Re,e[125]=Qe,e[126]=T,e[127]=X):X=e[127];const me=X;if(!Q)return me;let Ge;e[128]===Symbol.for("react.memo_cache_sentinel")?(Ge=[ql],e[128]=Ge):Ge=e[128];let be;e[129]!==Y||e[130]!==me?(be=t.jsx(eo,{items:Y,strategy:Ki,children:me}),e[129]=Y,e[130]=me,e[131]=be):be=e[131];let Ae;e[132]===Symbol.for("react.memo_cache_sentinel")?(Ae=t.jsx(Hi,{dropAnimation:null}),e[132]=Ae):Ae=e[132];let rt;return e[133]!==$e||e[134]!==Ie||e[135]!==be?(rt=t.jsxs(Qr,{sensors:Ie,collisionDetection:Xr,onDragEnd:$e,modifiers:Ge,children:[be,Ae]}),e[133]=$e,e[134]=Ie,e[135]=be,e[136]=rt):rt=e[136],rt};function Ql(s){return s.isMobile}function Xl(s){return s.id}function Zl(s,e){return!s||!e?s===e:Math.abs(s.left-e.left)<.5&&Math.abs(s.top-e.top)<.5&&Math.abs(s.width-e.width)<.5&&Math.abs(s.height-e.height)<.5}function ec(s){return s===null?s:null}function tc(s){return s===null?s:null}function sc(s){s.button===1&&s.preventDefault()}function nc(s){s.stopPropagation()}function rc(s){s.stopPropagation()}function oc(s){s.stopPropagation()}const qt=qs()(Gr(Hr((s,e)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:n=>{s({selectedProfileId:n})},loadProfiles:async()=>{s({isLoading:!0});const n=e().profiles;try{const r=await Qo();return s({profiles:r,isLoading:!1}),!0}catch(r){return console.error("Failed to load git identity profiles:",r),s({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{const n=await Jo();if(n&&n.userName&&n.userEmail){const r={id:"global",name:"Global Identity",userName:n.userName,userEmail:n.userEmail,authType:n.sshCommand?"ssh":void 0,sshKey:n.sshCommand?n.sshCommand.replace("ssh -i ",""):null,color:"info",icon:"fingerprint"};s({globalIdentity:r})}else s({globalIdentity:null});return!0}catch(n){return console.error("Failed to load global git identity:",n),s({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{const n=await Yo();return s({discoveredCredentials:n}),!0}catch(n){return console.error("Failed to discover git credentials:",n),s({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{const n=r=>{if(typeof r!="string")return null;const o=r.trim();return o.length>0?o:null};try{let r=null;if(r===null){const o=ki()?.settings;if(o)try{const i=(await o.load())?.settings||{};r=n(i.defaultGitIdentityId)}catch{}}if(r===null)try{const o=await Lt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(o.ok){const a=await o.json().catch(()=>null);r=n(a?.defaultGitIdentityId)}}catch{}return s({defaultGitIdentityId:r}),!0}catch(r){return console.error("Failed to load default git identity setting:",r),!1}},setDefaultGitIdentityId:async n=>{try{const r=typeof n=="string"?n.trim():"",o=r.length>0?r:"";return await _r({defaultGitIdentityId:o}),s({defaultGitIdentityId:o.length>0?o:null}),!0}catch(r){return console.error("Failed to save default git identity setting:",r),!1}},createProfile:async n=>{try{const r={...n,id:n.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:n.color||"keyword",icon:n.icon||"branch"};return Ot("saving"),await qo(r),Ot("saved"),await e().loadProfiles(),!0}catch(r){return Ot("error"),console.error("Failed to create git identity profile:",r),!1}},updateProfile:async(n,r)=>{try{const o=e().profiles.find(i=>i.id===n);if(!o)throw new Error("Profile not found");const a={...o,...r};return Ot("saving"),await Ko(n,a),Ot("saved"),await e().loadProfiles(),!0}catch(o){return Ot("error"),console.error("Failed to update git identity profile:",o),!1}},deleteProfile:async n=>{try{return Ot("saving"),await Ho(n),Ot("saved"),e().selectedProfileId===n&&s({selectedProfileId:null}),await e().loadProfiles(),!0}catch(r){return Ot("error"),console.error("Failed to delete git identity profile:",r),!1}},getProfileById:n=>{const{profiles:r,globalIdentity:o}=e();return n==="global"?o||void 0:r.find(a=>a.id===n)},getUnimportedCredentials:()=>{const{profiles:n,discoveredCredentials:r}=e();return r.filter(o=>!n.some(a=>a.authType==="token"&&a.host===o.host))}}),{name:"git-identities-store",storage:ji(),partialize:s=>({selectedProfileId:s.selectedProfileId})}),{name:"git-identities-store"}));typeof window<"u"&&(window.__zustand_git_identities_store__=qt);const _s=Xo,Wt=s=>{const e=Ve.c(11),{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:c,children:l,className:d,contentClassName:u,divider:h}=s,b=h===void 0?!0:h;let f;return e[0]!==l||e[1]!==d||e[2]!==u||e[3]!==r||e[4]!==b||e[5]!==c||e[6]!==o||e[7]!==a||e[8]!==n||e[9]!==i?(f=t.jsx(Zo,{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:c,divider:b,className:d,contentClassName:u,children:l}),e[0]=l,e[1]=d,e[2]=u,e[3]=r,e[4]=b,e[5]=c,e[6]=o,e[7]=a,e[8]=n,e[9]=i,e[10]=f):f=e[10],f},ac=450,ic=({projectRef:s=null,sections:e="all"})=>{const{t:n}=nt(),{isMobile:r,isTablet:o}=Gs(),a=r||o,i=It(R=>R.getActiveProject()),c=s?.path??i?.path??null,l=at(R=>R.getWorktreeMetadata),d=ea(),u=gs(R=>R.homeDirectory),[h,b]=m.useState([]),[f,x]=m.useState(!1),[g,j]=m.useState(!1),[p,k]=m.useState(null),[P,A]=m.useState(null),[N,C]=m.useState([]),[w,v]=m.useState(!1),L=m.useRef(!1),$=m.useMemo(()=>s?.id&&s?.path?{id:s.id,path:s.path}:!i?.id||!c?null:{id:i.id,path:c},[i?.id,c,s?.id,s?.path]),M=m.useCallback(async()=>{if(!(!$||P===!1))try{const R=await $n($);C(R)}catch{}},[$,P]);m.useEffect(()=>{if(!c)return;let R=!1;return A(null),(async()=>{try{const V=await ta(c);if(R)return;A(V)}catch{}})(),()=>{R=!0}},[c]),m.useEffect(()=>{if(!$){C([]),v(!1);return}if(P===!1){C([]),v(!1);return}let R=!1;return v(!0),C([]),(async()=>{try{const V=await $n($);if(R)return;C(V)}catch{}finally{R||v(!1)}})(),()=>{R=!0}},[$,P]),m.useEffect(()=>{if(!$)return;let R=!1;return j(!0),(async()=>{try{const[V,ne]=await Promise.all([Cr($),Tr($)]);if(!R){const Q=V.length>0?V:[""];b(Q),k(JSON.stringify(Q)),x(ne)}}catch{R||(b([""]),k(JSON.stringify([""])),x(!1))}finally{R||j(!1)}})(),()=>{R=!0}},[$]);const H=m.useCallback(async R=>{if(!$)return!1;const V=R.filter(ne=>ne.trim().length>0);try{return await sa($,V)?(k(JSON.stringify(R)),!0):(Se.error(n("settings.aiworker.worktrees.setup.toast.saveFailed")),!1)}catch{return Se.error(n("settings.aiworker.worktrees.setup.toast.saveFailed")),!1}},[$,n]),K=m.useMemo(()=>p===null?!1:p!==JSON.stringify(h),[p,h]);m.useEffect(()=>{if(!K||g||L.current)return;const R=window.setTimeout(()=>{L.current||(L.current=!0,(async()=>{try{await H(h)}finally{L.current=!1}})())},ac);return()=>{window.clearTimeout(R)}},[K,g,H,h]);const ee=m.useCallback((R,V)=>{b(ne=>{const Q=[...ne];return Q[R]=V,Q})},[]),Y=m.useCallback(()=>{b(R=>[...R,""])},[]),O=m.useCallback(R=>{b(V=>{const ne=V.filter((Q,q)=>q!==R);return ne.length>0?ne:[""]})},[]),_=m.useCallback(()=>{!K||L.current||(L.current=!0,(async()=>{try{await H(h)}finally{L.current=!1}})())},[K,H,h]),U=m.useCallback(R=>{x(R),$&&na($,R)},[$]),J=m.useCallback(R=>{const V=ge=>ge.replace(/\\/g,"/").replace(/\/+$/,""),ne=V(R.path),Q=d.filter(ge=>{const se=l(ge.id);if(se?.path&&V(se.path)===ne)return!0;const fe=ge.directory;return!!(fe&&V(fe)===ne)}),q=new Set(Q.map(ge=>ge.id)),oe=[...Yt.getState().activeSessions,...Yt.getState().archivedSessions],Z=ge=>{const se=oe.filter(he=>{const S=he.parentID;return S&&ge.has(S)});if(se.length===0)return[];const fe=new Set(se.map(he=>he.id));return[...se,...Z(fe)]},te=Z(q),ye=new Set,re=[...Q,...te].filter(ge=>ye.has(ge.id)?!1:(ye.add(ge.id),!0));ra.requestDelete({sessions:re,mode:"worktree",worktree:R})},[d,l]),D=m.useMemo(()=>d.map(R=>R.id).join(","),[d]);m.useEffect(()=>{P&&c&&M()},[D,P,c,M]);const z=t.jsxs(hn,{children:[n("settings.aiworker.worktrees.setup.tooltipPrefix")," ",t.jsx("code",{className:"font-mono text-xs bg-sidebar-accent/50 px-1 rounded",children:"$ROOT_PROJECT_PATH"})," ",n("settings.aiworker.worktrees.setup.tooltipSuffix")]}),F=t.jsx(hn,{children:n("settings.aiworker.worktrees.list.tooltip")});return c?P===!1?t.jsx(Wt,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.aiworker.worktrees.state.gitOnly")})}):t.jsxs(t.Fragment,{children:[e==="all"?t.jsx(Wt,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",titleAccessory:z,children:g?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.aiworker.worktrees.setup.loading")}):t.jsxs("div",{className:ie("space-y-2",_s),children:[h.map((R,V)=>t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(yt,{value:R,onChange:ne=>ee(V,ne.target.value),onBlur:_,placeholder:n("settings.aiworker.worktrees.setup.commandPlaceholder"),className:"h-7 min-w-0 flex-1 font-mono text-xs"}),t.jsx(Ne,{type:"button",variant:"ghost",size:"icon",onClick:()=>O(V),className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive","aria-label":n("settings.aiworker.worktrees.setup.removeCommandAria"),children:t.jsx(E,{name:"close",className:"h-4 w-4"})})]},V)),t.jsxs(Ne,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:Y,children:[t.jsx(E,{name:"add",className:"h-3.5 w-3.5"}),n("settings.aiworker.worktrees.setup.addCommand")]}),t.jsxs("label",{"data-settings-item":"projects.worktree.setup.wait",className:"flex cursor-pointer items-center gap-2 py-1",children:[t.jsx(Ds,{checked:f,onChange:U,ariaLabel:n("settings.aiworker.worktrees.setup.waitForCommandsAria")}),t.jsx("span",{className:ie("typography-ui-label font-normal",f?"text-foreground":"text-foreground/60"),children:n("settings.aiworker.worktrees.setup.waitForCommands")})]})]})}):null,t.jsx(Wt,{title:n("settings.aiworker.worktrees.list.title"),titleAccessory:F,children:w?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.aiworker.worktrees.list.loading")}):N.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:n("settings.aiworker.worktrees.list.empty")}):t.jsx("div",{className:ie("space-y-1",e==="all"&&_s),children:N.map(R=>t.jsxs("div",{className:"group flex w-full items-center gap-2 py-1.5",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"flex min-w-0 items-center gap-2",children:t.jsx("p",{className:"typography-meta min-w-0 truncate text-foreground",children:R.label||R.branch||n("settings.aiworker.worktrees.list.detachedHead")})}),t.jsx("p",{className:"typography-micro truncate text-muted-foreground/60",children:oa(R.path,u)})]}),t.jsx("button",{type:"button",onClick:()=>J(R),className:ie("flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",a?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":n("settings.aiworker.worktrees.list.deleteWorktreeAria",{name:R.branch||R.label||R.path}),children:t.jsx(E,{name:"delete-bin",className:"h-4 w-4"})})]},R.path))})})]}):t.jsx(Wt,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.aiworker.worktrees.state.selectProject")})})},or=(s,e)=>e.updatedAtMs-s.updatedAtMs,ar=qs((s,e)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!e().isLoading){s({isLoading:!0,error:null});try{const[n,r]=await Promise.all([ca(),Wn()]),o={};for(const a of r.sort(or))o[a.id]=a;e().listenerReady||await da(a=>{s(i=>({statusesById:{...i.statusesById,[a.id]:a}}))}),s({instances:n.instances,statusesById:o,isLoading:!1,initialized:!0,listenerReady:!0})}catch(n){s({isLoading:!1,error:n instanceof Error?n.message:String(n)})}}},loadImports:async()=>{if(!e().isImportsLoading){s({isImportsLoading:!0,error:null});try{const n=await la();s({importCandidates:n,isImportsLoading:!1})}catch(n){s({isImportsLoading:!1,error:n instanceof Error?n.message:String(n)})}}},refreshStatuses:async()=>{try{const n=await Wn(),r={};for(const o of n.sort(or))r[o.id]=o;s({statusesById:r})}catch(n){s({error:n instanceof Error?n.message:String(n)})}},setInstances:async n=>{s({isSaving:!0,error:null});try{await ia({instances:n}),s({instances:n,isSaving:!1}),await e().refreshStatuses()}catch(r){throw s({isSaving:!1,error:r instanceof Error?r.message:String(r)}),r}},upsertInstance:async n=>{const r=e().instances,o=r.some(a=>a.id===n.id)?r.map(a=>a.id===n.id?n:a):[n,...r];await e().setInstances(o)},createFromCommand:async(n,r,o)=>{const a=ua(n,r);o&&o.trim()&&(a.nickname=o.trim()),await e().upsertInstance(a)},removeInstance:async n=>{await Un(n).catch(()=>{});const r=e().instances.filter(o=>o.id!==n);await e().setInstances(r),s(o=>{const a={...o.statusesById};return delete a[n],{statusesById:a}})},connect:async n=>{s({error:null});try{await aa(n),await e().refreshStatuses()}catch(r){throw s({error:r instanceof Error?r.message:String(r)}),r}},disconnect:async n=>{s({error:null});try{await Un(n),await e().refreshStatuses()}catch(r){throw s({error:r instanceof Error?r.message:String(r)}),r}},retry:async n=>{await e().connect(n)},getStatus:n=>e().statusesById[n]||null,clearError:()=>s({error:null})})),oo=[{key:"play",label:"Play",Icon:"play"},{key:"build",label:"Build",Icon:"hammer"},{key:"lint",label:"Lint",Icon:"checkbox-circle"},{key:"terminal",label:"Terminal",Icon:"terminal-box"},{key:"tools",label:"Tools",Icon:"tools"},{key:"bug",label:"Bug",Icon:"bug"},{key:"flask",label:"Flask",Icon:"flask"},{key:"rocket",label:"Rocket",Icon:"rocket"},{key:"code",label:"Code",Icon:"code"},{key:"server",label:"Server",Icon:"server"},{key:"branch",label:"Branch",Icon:"git-branch"},{key:"search",label:"Search",Icon:"search"},{key:"settings",label:"Settings",Icon:"settings-3"},{key:"brain",label:"Brain",Icon:"brain-ai-3"},{key:"stack",label:"Stack",Icon:"stack"},{key:"robot",label:"Robot",Icon:"robot-2"},{key:"command",label:"Command",Icon:"command"},{key:"file",label:"File",Icon:"file-text"}],ao=Object.fromEntries(oo.map(s=>[s.key,s.Icon])),lc="aiworker:project-actions-updated",cc=s=>{const e=(s||"").trim().replace(/\\/g,"/");return e?e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e:""},Ff=(s,e)=>`${cc(s)}::${e}`,dc=s=>{const e=s.trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},ir=s=>{if(typeof s!="number"||!Number.isFinite(s))return null;const e=Math.round(s);return e<1||e>65535?null:e},uc=(s,e)=>{if(!e.enabled||e.type!=="local")return null;const n=ir(e.localPort),r=ir(e.remotePort);if(!n||!r)return null;const o=dc(e.localHost||s.localForward.bindHost||"127.0.0.1"),a=(e.remoteHost||"127.0.0.1").trim(),i=(s.nickname||s.id||"instance").trim();return{id:`${s.id}::${e.id}`,label:`${i} - ${o}:${n} -> ${a}:${r}`,url:`http://${o}:${n}`}},io=s=>{const e=[];for(const n of s)if(!(!n?.id||!Array.isArray(n.portForwards)))for(const r of n.portForwards){const o=uc(n,r);o&&e.push(o)}return e},Of=(s,e)=>{const n=(s||"").trim();return n&&io(e).find(a=>a.id===n)?.url||null},fc=450,mc=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`action_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,hc=()=>({id:mc(),name:"",command:"",icon:"play"}),pc=({projectRef:s})=>{const{t:e}=nt(),n=m.useMemo(()=>Vr(),[]),r=ar(C=>C.instances),o=ar(C=>C.load),[a,i]=m.useState([]),[c,l]=m.useState(!1),[d,u]=m.useState(null),[h,b]=m.useState({}),f=m.useRef(!1),x=m.useRef(null);m.useEffect(()=>{n&&o().catch(()=>{})},[n,o]),m.useEffect(()=>{let C=!1;return l(!0),(async()=>{try{const w=await fa(s);if(C)return;i(w.actions),u(JSON.stringify({actions:w.actions}))}catch{if(C)return;i([]),u(JSON.stringify({actions:[]}))}finally{C||l(!1)}})(),()=>{C=!0}},[s]);const g=m.useMemo(()=>n?io(r):[],[r,n]),j=m.useMemo(()=>a.some(w=>w.name.trim().length===0||w.command.trim().length===0)?e("settings.projects.actions.validation.fillNameAndCommand"):null,[a,e]),p=m.useMemo(()=>d===null?!1:d!==JSON.stringify({actions:a}),[a,d]),k=m.useCallback(async C=>await ma(s,{actions:C,primaryActionId:null})?(u(JSON.stringify({actions:C})),typeof window<"u"&&window.dispatchEvent(new CustomEvent(lc,{detail:{projectId:s.id}})),!0):(Se.error(e("settings.projects.actions.toast.saveFailed")),!1),[s,e]);m.useEffect(()=>{if(!p||c||j||f.current)return;const C=window.setTimeout(()=>{f.current||(f.current=!0,(async()=>{try{await k(a)}finally{f.current=!1}})())},fc);return()=>{window.clearTimeout(C)}},[a,p,c,k,j]),m.useEffect(()=>{if(!p||!j||c){j||(x.current=null);return}const C=window.setTimeout(()=>{x.current!==j&&(x.current=j,Se.error(j))},1e3);return()=>{window.clearTimeout(C)}},[p,c,j]);const P=m.useCallback(()=>{const C=hc();i(w=>[...w,C]),b(w=>({...w,[C.id]:!0}))},[]),A=m.useCallback(C=>{i(w=>w.filter(v=>v.id!==C)),b(w=>{const v={...w};return delete v[C],v})},[]),N=m.useCallback((C,w)=>{i(v=>v.map(L=>L.id===C?w(L):L))},[]);return t.jsxs(Wt,{title:e("settings.projects.actions.title"),info:e("settings.projects.actions.description"),settingsItem:"projects.actions",headerAction:t.jsxs(Ne,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:P,children:[t.jsx(E,{name:"add",className:"h-3.5 w-3.5"}),e("settings.projects.actions.actions.add")]}),contentClassName:"space-y-0",children:[c?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.loading")}):a.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.empty")}):t.jsx("div",{className:ie("space-y-0",_s),children:a.map(C=>{const w=C.icon||"play",v=ao[w]||"play",L=h[C.id]??!1,$=C.name.trim()||e("settings.projects.actions.state.untitled");return t.jsxs(Dl,{open:L,onOpenChange:M=>{b(H=>({...H,[C.id]:M}))},className:"py-1.5",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs(Pl,{className:"group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",children:[L?t.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):t.jsx(E,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),t.jsx(E,{name:v,className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:$})})]}),t.jsx(Ne,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>A(C.id),children:t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(Rl,{className:"pt-1.5",children:t.jsxs("div",{className:"space-y-2 pb-4 pl-3 pr-1",children:[t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsxs(zt,{children:[t.jsx(Gt,{asChild:!0,children:t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]","aria-label":e("settings.projects.actions.field.selectIconAria"),children:t.jsx(E,{name:v,className:"h-4 w-4"})})}),t.jsx(Ht,{align:"start",className:"w-56 p-2",children:t.jsx("div",{className:"grid grid-cols-6 gap-1",children:oo.map(M=>{const H=M.Icon,K=(C.icon||"play")===M.key;return t.jsx("button",{type:"button",onClick:()=>N(C.id,ee=>({...ee,icon:M.key})),className:ie("inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]",K&&"border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]"),"aria-label":e("settings.projects.actions.field.iconAria",{icon:M.label}),children:t.jsx(E,{name:H,className:"h-4 w-4"})},M.key)})})})]}),t.jsx(yt,{value:C.name,onChange:M=>N(C.id,H=>({...H,name:M.target.value})),placeholder:e("settings.projects.actions.field.actionNamePlaceholder"),className:"h-7 flex-1 min-w-0"})]}),t.jsxs("div",{className:"py-1",children:[t.jsx("p",{className:"typography-meta mb-0.5 text-muted-foreground",children:e("settings.projects.actions.field.command")}),t.jsx(Hs,{value:C.command,onChange:M=>N(C.id,H=>({...H,command:M.target.value})),placeholder:e("settings.projects.actions.field.commandPlaceholder"),className:"min-h-[88px] w-full font-mono text-xs"})]}),t.jsxs("div",{className:"py-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:e("settings.projects.actions.field.autoOpenUrl")}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2",role:"button",tabIndex:0,"aria-pressed":C.autoOpenUrl===!0,onClick:()=>N(C.id,M=>({...M,...M.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:M=>{(M.key===" "||M.key==="Enter")&&(M.preventDefault(),N(C.id,H=>({...H,...H.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[t.jsx(Ds,{checked:C.autoOpenUrl===!0,onChange:M=>N(C.id,H=>({...H,...M?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:e("settings.projects.actions.field.autoOpenUrlForAria",{title:$})}),t.jsx("span",{className:"typography-ui-label font-normal text-foreground/80",children:e("settings.projects.actions.field.autoOpenUrlDescription")})]})]}),C.autoOpenUrl===!0?t.jsxs("div",{className:"mt-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(yt,{value:C.openUrl||"",onChange:M=>N(C.id,H=>({...H,openUrl:M.target.value})),placeholder:e("settings.projects.actions.field.overrideUrlPlaceholder"),className:"h-7 w-full max-w-[24rem]"}),t.jsx(hn,{contentClassName:"max-w-xs",children:e("settings.projects.actions.field.overrideUrlTooltip")})]}),n?t.jsxs("div",{className:"mt-2",children:[t.jsx("p",{className:"typography-meta mb-0.5 text-muted-foreground",children:e("settings.projects.actions.field.desktopSshForward")}),g.length>0?t.jsxs(Dn,{value:C.desktopOpenSshForward&&g.some(M=>M.id===C.desktopOpenSshForward)?C.desktopOpenSshForward:"__none__",onValueChange:M=>{N(C.id,H=>({...H,...M==="__none__"?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:M}}))},children:[t.jsx(Pn,{size:Dr,className:"w-full",children:t.jsx(Pr,{placeholder:e("settings.projects.actions.field.useOutputManualUrl")})}),t.jsxs(Rn,{children:[t.jsx(js,{value:"__none__",children:e("settings.projects.actions.field.useOutputManualUrl")}),g.map(M=>t.jsx(js,{value:M.id,children:M.label},M.id))]})]}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.noDesktopSshForwards")})]}):null]}):null]})]})})]},C.id)})}),j&&a.length>0?t.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:j}):null]})},tn="__default__",lo=s=>s.charAt(0).toUpperCase()+s.slice(1),gc=s=>{const e=Ve.c(138),{form:n}=s,{t:r}=nt(),{currentTheme:o}=Rr(),a=kt(xc),{name:i,setName:c,icon:l,setIcon:d,color:u,setColor:h,iconBackground:b,setIconBackground:f,parsedDefaultModel:x,defaultVariant:g,handleDefaultModelChange:j,handleDefaultVariantChange:p,isUploadingIcon:k,isRemovingCustomIcon:P,isDiscoveringIcon:A,pendingRemoveImageIcon:N,setPendingRemoveImageIcon:C,pendingUploadIconPreviewUrl:w,setPreviewImageFailed:v,hasPendingUploadImageIcon:L,hasCustomIcon:$,effectiveHasImageIcon:M,hasRemovableImageIcon:H,showImagePreview:K,fileInputRef:ee,handleUploadIcon:Y,handleRemoveImageIcon:O,handleDiscoverIcon:_,currentIconImage:U,project:J}=n;let D;e:{const{providerId:Re,modelId:Qe}=x;if(!Re||!Qe){let lt;e[0]===Symbol.for("react.memo_cache_sentinel")?(lt=[],e[0]=lt):lt=e[0],D=lt;break e}let ut;if(e[1]!==Qe||e[2]!==Re||e[3]!==a){const lt=a.find(mt=>mt.id===Re)?.models.find(mt=>mt.id===Qe);ut=ha(lt),e[1]=Qe,e[2]=Re,e[3]=a,e[4]=ut}else ut=e[4];D=ut}const z=D;if(!J)return null;const F=u?pa[u]??null:null;let R;e[5]!==r?(R=r("settings.projects.page.field.projectName"),e[5]=r,e[6]=R):R=e[6];let V;e[7]!==c?(V=Re=>c(Re.target.value),e[7]=c,e[8]=V):V=e[8];let ne;e[9]!==r?(ne=r("settings.projects.page.field.projectNamePlaceholder"),e[9]=r,e[10]=ne):ne=e[10];let Q;e[11]===Symbol.for("react.memo_cache_sentinel")?(Q=ie("h-8 rounded-md px-3",_s),e[11]=Q):Q=e[11];let q;e[12]!==i||e[13]!==V||e[14]!==ne?(q=t.jsx(yt,{value:i,onChange:V,placeholder:ne,className:Q}),e[12]=i,e[13]=V,e[14]=ne,e[15]=q):q=e[15];let oe;e[16]!==R||e[17]!==q?(oe=t.jsx(Wt,{title:R,settingsItem:"projects.name",divider:!1,children:q}),e[16]=R,e[17]=q,e[18]=oe):oe=e[18];let Z;e[19]!==r?(Z=r("settings.projects.page.section.chatDefaults"),e[19]=r,e[20]=Z):Z=e[20];let te;e[21]!==r?(te=r("settings.projects.page.section.chatDefaultsDescription"),e[21]=r,e[22]=te):te=e[22];let ye;e[23]!==r?(ye=r("settings.projects.page.field.projectModel"),e[23]=r,e[24]=ye):ye=e[24];let re;e[25]!==j||e[26]!==x.modelId||e[27]!==x.providerId?(re=t.jsx(Ir,{providerId:x.providerId,modelId:x.modelId,onChange:j,className:ga}),e[25]=j,e[26]=x.modelId,e[27]=x.providerId,e[28]=re):re=e[28];let ge;e[29]!==ye||e[30]!==re?(ge=t.jsx(_n,{settingsItem:"projects.default-model",label:ye,children:re}),e[29]=ye,e[30]=re,e[31]=ge):ge=e[31];let se;e[32]!==z||e[33]!==g||e[34]!==p||e[35]!==r?(se=z.length>0?t.jsx(_n,{settingsItem:"projects.default-thinking",label:r("settings.projects.page.field.projectThinking"),children:t.jsxs(Dn,{value:g??tn,onValueChange:Re=>p(Re===tn?void 0:Re),children:[t.jsx(Pn,{size:Dr,className:xa,"aria-label":r("settings.projects.page.field.projectThinking"),children:t.jsx(Pr,{children:g?lo(g):r("settings.projects.page.option.thinkingDefault")})}),t.jsxs(Rn,{children:[t.jsx(js,{value:tn,children:r("settings.projects.page.option.thinkingDefault")}),z.map(bc)]})]})}):null,e[32]=z,e[33]=g,e[34]=p,e[35]=r,e[36]=se):se=e[36];let fe;e[37]!==ge||e[38]!==se||e[39]!==Z||e[40]!==te?(fe=t.jsxs(Wt,{title:Z,info:te,contentClassName:"space-y-0",children:[ge,se]}),e[37]=ge,e[38]=se,e[39]=Z,e[40]=te,e[41]=fe):fe=e[41];let he;e[42]!==r?(he=r("settings.projects.page.field.accentColor"),e[42]=r,e[43]=he):he=e[43];let S;e[44]!==h?(S=()=>h(null),e[44]=h,e[45]=S):S=e[45];const B=u===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let W;e[46]!==B?(W=ie("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",B),e[46]=B,e[47]=W):W=e[47];let le;e[48]!==r?(le=r("settings.projects.page.field.none"),e[48]=r,e[49]=le):le=e[49];let pe;e[50]===Symbol.for("react.memo_cache_sentinel")?(pe=t.jsx(E,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[50]=pe):pe=e[50];let Te;e[51]!==S||e[52]!==W||e[53]!==le?(Te=t.jsx("button",{type:"button",onClick:S,className:W,title:le,children:pe}),e[51]=S,e[52]=W,e[53]=le,e[54]=Te):Te=e[54];let Ie;e[55]!==u||e[56]!==h?(Ie=ba.map(Re=>t.jsx("button",{type:"button",onClick:()=>h(Re.key),className:ie("h-7 w-7 rounded-md border transition-colors",u===Re.key?"border-2 border-foreground ring-1 ring-[var(--primary-base)]/40":"border-transparent hover:border-border/70"),style:{backgroundColor:Re.cssVar},title:Re.label},Re.key)),e[55]=u,e[56]=h,e[57]=Ie):Ie=e[57];let We;e[58]!==Te||e[59]!==Ie?(We=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Te,Ie]}),e[58]=Te,e[59]=Ie,e[60]=We):We=e[60];let Me;e[61]!==he||e[62]!==We?(Me=t.jsx(Wt,{title:he,settingsItem:"projects.accent-color",children:We}),e[61]=he,e[62]=We,e[63]=Me):Me=e[63];let ve;e[64]!==r?(ve=r("settings.projects.page.field.projectIcon"),e[64]=r,e[65]=ve):ve=e[65];let Be;e[66]!==Y?(Be=Re=>{const Qe=Re.target.files?.[0]??null;Y(Qe),Re.currentTarget.value=""},e[66]=Y,e[67]=Be):Be=e[67];let Ee;e[68]!==ee||e[69]!==Be?(Ee=t.jsx("input",{ref:ee,type:"file",accept:"image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg",className:"hidden",onChange:Be}),e[68]=ee,e[69]=Be,e[70]=Ee):Ee=e[70];let Oe;e[71]!==d?(Oe=()=>d(null),e[71]=d,e[72]=Oe):Oe=e[72];const ze=l===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let qe;e[73]!==ze?(qe=ie("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",ze),e[73]=ze,e[74]=qe):qe=e[74];let Ke;e[75]!==r?(Ke=r("settings.projects.page.field.none"),e[75]=r,e[76]=Ke):Ke=e[76];let _e;e[77]===Symbol.for("react.memo_cache_sentinel")?(_e=t.jsx(E,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[77]=_e):_e=e[77];let et;e[78]!==Oe||e[79]!==qe||e[80]!==Ke?(et=t.jsx("button",{type:"button",onClick:Oe,className:qe,title:Ke,children:_e}),e[78]=Oe,e[79]=qe,e[80]=Ke,e[81]=et):et=e[81];let dt;e[82]!==F||e[83]!==l||e[84]!==d?(dt=ya.map(Re=>{const Qe=Re.Icon;return t.jsx("button",{type:"button",onClick:()=>d(Re.key),className:ie("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",l===Re.key?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-transparent hover:border-border hover:bg-[var(--surface-muted)]"),title:Re.label,children:t.jsx(E,{name:Qe,className:"w-4 h-4",style:F&&l===Re.key?{color:F}:void 0})},Re.key)}),e[82]=F,e[83]=l,e[84]=d,e[85]=dt):dt=e[85];let je;e[86]!==et||e[87]!==dt?(je=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[et,dt]}),e[86]=et,e[87]=dt,e[88]=je):je=e[88];let Xe;e[89]!==U||e[90]!==o||e[91]!==M||e[92]!==L||e[93]!==b||e[94]!==w||e[95]!==J||e[96]!==v||e[97]!==K||e[98]!==r?(Xe=M&&K&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-meta text-muted-foreground",children:r("settings.projects.page.field.preview")}),t.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1",children:t.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:b?{backgroundColor:b}:void 0,children:L&&w?t.jsx("img",{src:w,alt:"",className:"h-full w-full object-contain",draggable:!1,onError:()=>v(!0)}):t.jsx(wa,{project:{...J,iconImage:U??J.iconImage},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"h-full w-full object-contain",onError:()=>v(!0)})})})]}),e[89]=U,e[90]=o,e[91]=M,e[92]=L,e[93]=b,e[94]=w,e[95]=J,e[96]=v,e[97]=K,e[98]=r,e[99]=Xe):Xe=e[99];let tt;e[100]!==M||e[101]!==b||e[102]!==f||e[103]!==r?(tt=M&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("input",{type:"color",value:b??"#000000",onChange:Re=>f(Re.target.value),className:"h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1","aria-label":r("settings.projects.page.field.projectIconBackgroundAria")}),t.jsx(yt,{value:b??"",onChange:Re=>f(Re.target.value),placeholder:"#000000",className:"h-7 w-[8rem]"}),t.jsx(Ne,{type:"button",size:"xs",variant:"outline",onClick:()=>f(null),className:"h-7 w-7 p-0","aria-label":r("settings.projects.page.field.clearIconBackgroundAria"),title:r("settings.projects.page.field.clearBackground"),disabled:!b,children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),e[100]=M,e[101]=b,e[102]=f,e[103]=r,e[104]=tt):tt=e[104];let Je;e[105]!==ee||e[106]!==_||e[107]!==$||e[108]!==A||e[109]!==k||e[110]!==r?(Je=!$&&t.jsxs(t.Fragment,{children:[t.jsx(Ne,{size:"xs",className:"h-6 !font-normal",onClick:()=>ee.current?.click(),disabled:k,children:r(k?"settings.projects.page.actions.uploading":"settings.projects.page.actions.uploadIcon")}),t.jsx(Ne,{size:"xs",className:"h-6 !font-normal",variant:"outline",onClick:()=>{_()},disabled:A,children:r(A?"settings.projects.page.actions.discovering":"settings.projects.page.actions.discoverFavicon")})]}),e[105]=ee,e[106]=_,e[107]=$,e[108]=A,e[109]=k,e[110]=r,e[111]=Je):Je=e[111];let Ce;e[112]!==O||e[113]!==H||e[114]!==P||e[115]!==r?(Ce=H&&t.jsx(Ne,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>{O()},disabled:P,children:r(P?"settings.projects.page.actions.removing":"settings.projects.page.actions.removeProjectIcon")}),e[112]=O,e[113]=H,e[114]=P,e[115]=r,e[116]=Ce):Ce=e[116];let it;e[117]!==P||e[118]!==N||e[119]!==C||e[120]!==r?(it=N&&t.jsx(Ne,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>C(!1),disabled:P,children:r("settings.projects.page.actions.undoRemove")}),e[117]=P,e[118]=N,e[119]=C,e[120]=r,e[121]=it):it=e[121];let Fe;e[122]!==Je||e[123]!==Ce||e[124]!==it?(Fe=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Je,Ce,it]}),e[122]=Je,e[123]=Ce,e[124]=it,e[125]=Fe):Fe=e[125];let $e;e[126]!==ve||e[127]!==Ee||e[128]!==je||e[129]!==Xe||e[130]!==tt||e[131]!==Fe?($e=t.jsxs(Wt,{title:ve,settingsItem:"projects.icon",contentClassName:"space-y-3",children:[Ee,je,Xe,tt,Fe]}),e[126]=ve,e[127]=Ee,e[128]=je,e[129]=Xe,e[130]=tt,e[131]=Fe,e[132]=$e):$e=e[132];let st;return e[133]!==fe||e[134]!==Me||e[135]!==$e||e[136]!==oe?(st=t.jsxs(t.Fragment,{children:[oe,fe,Me,$e]}),e[133]=fe,e[134]=Me,e[135]=$e,e[136]=oe,e[137]=st):st=e[137],st};function xc(s){return s.providers}function bc(s){return t.jsx(js,{value:s,children:lo(s)},s)}const yc=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,wc=s=>{if(!s)return null;const e=s.trim();return e&&yc.test(e)?e.toLowerCase():null},vc=s=>{const{t:e}=nt(),n=It(se=>se.uploadProjectIcon),r=It(se=>se.removeProjectIcon),o=It(se=>se.discoverProjectIcon),a=It(se=>s?se.projects.find(fe=>fe.id===s.id)?.iconImage??null:null),[i,c]=m.useState(""),[l,d]=m.useState(null),[u,h]=m.useState(null),[b,f]=m.useState(null),[x,g]=m.useState(void 0),[j,p]=m.useState(void 0),[k,P]=m.useState(!1),[A,N]=m.useState(!1),[C,w]=m.useState(!1),[v,L]=m.useState(!1),[$,M]=m.useState(null),[H,K]=m.useState(null),[ee,Y]=m.useState(!1),O=m.useRef(null),_=m.useCallback(()=>{M(null),K(se=>(se&&URL.revokeObjectURL(se),null))},[]),U=s?.id??null;m.useEffect(()=>{if(!s){c(""),d(null),h(null),f(null),g(void 0),p(void 0);return}c(s.label??""),d(s.icon??null),h(s.color??null),f(s.iconBackground??null),g(s.defaultModel),p(s.defaultVariant),L(!1),_(),Y(!1)},[s,_]),m.useEffect(()=>()=>{_()},[_]);const J=m.useMemo(()=>Er(x)??{providerId:"",modelId:""},[x]),D=!!s?.iconImage,z=!!($&&H),F=s?.iconImage?.source==="custom",R=D&&!v||z,V=R,ne=!!(s&&D&&!v),Q=!ee&&(z||ne),q=!!s&&(i.trim()!==(s?.label??"").trim()||l!==(s?.icon??null)||u!==(s?.color??null)||b!==(s?.iconBackground??null)||(x??void 0)!==(s?.defaultModel??void 0)||(j??void 0)!==(s?.defaultVariant??void 0)||v||!!$),oe=m.useCallback((se,fe)=>{g(se&&fe?`${se}/${fe}`:void 0),p(void 0)},[]),Z=m.useCallback(se=>{p(se)},[]),te=m.useCallback(se=>{!s||!se||k||(L(!1),Y(!1),M(se),K(fe=>(fe&&URL.revokeObjectURL(fe),URL.createObjectURL(se))))},[k,s]),ye=m.useCallback(()=>{!s||!V||A||(z&&_(),L(!!D),Y(!1))},[_,z,V,D,A,s]),re=m.useCallback(async()=>{if(!(!s||C)){_(),L(!1),Y(!1),w(!0);try{const se=await o(s.id);if(!se.ok){Se.error(se.error||e("settings.projects.page.toast.discoverIconFailed"));return}if(se.skipped){Se.success(e("settings.projects.page.toast.customIconAlreadySet"));return}Se.success(e("settings.projects.page.toast.iconDiscovered"))}finally{w(!1)}}},[_,o,C,s,e]),ge=m.useCallback(async se=>{const fe=se?.silent===!0;if(!s)return null;const he=i.trim();if(!he)return null;if($){P(!0);const B=await n(s.id,$);if(P(!1),!B.ok)return Se.error(B.error||e("settings.projects.page.toast.uploadIconFailed")),null;fe||Se.success(e("settings.projects.page.toast.iconUpdated")),_(),L(!1)}const S=v&&!!s.iconImage;if(S){N(!0);const B=await r(s.id);if(N(!1),!B.ok)return Se.error(B.error||e("settings.projects.page.toast.removeIconFailed")),null;fe||Se.success(e("settings.projects.page.toast.iconRemoved")),L(!1),f(null)}return{label:he,icon:l,color:u,iconBackground:wc(S?null:b),defaultModel:x??null,defaultVariant:x?j??null:null}},[_,u,x,j,l,b,i,v,$,s,r,e,n]);return m.useEffect(()=>{Y(!1)},[U,a?.updatedAt]),{name:i,setName:c,icon:l,setIcon:d,color:u,setColor:h,iconBackground:b,setIconBackground:f,defaultModel:x,defaultVariant:j,parsedDefaultModel:J,handleDefaultModelChange:oe,handleDefaultVariantChange:Z,isUploadingIcon:k,isRemovingCustomIcon:A,isDiscoveringIcon:C,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:L,pendingUploadIconFile:$,pendingUploadIconPreviewUrl:H,previewImageFailed:ee,setPreviewImageFailed:Y,hasStoredImageIcon:D,hasPendingUploadImageIcon:z,hasCustomIcon:F,effectiveHasImageIcon:R,hasRemovableImageIcon:V,showStoredImagePreview:ne,showImagePreview:Q,fileInputRef:O,clearPendingUploadIcon:_,handleUploadIcon:te,handleRemoveImageIcon:ye,handleDiscoverIcon:re,hasChanges:q,prepareSaveData:ge,currentIconImage:a,project:s}},Sc=450,jc=(s,e)=>{const{t:n}=nt(),{hasChanges:r,name:o,icon:a,color:i,iconBackground:c,defaultModel:l,pendingRemoveImageIcon:d,pendingUploadIconFile:u,isUploadingIcon:h,isRemovingCustomIcon:b,prepareSaveData:f}=s,x=m.useRef(!1);m.useEffect(()=>{if(!r||!o.trim()||h||b||x.current)return;const g=window.setTimeout(()=>{x.current||(x.current=!0,(async()=>{try{const j=await f({silent:!0});if(j)try{await e(j)}catch{Se.error(n("settings.projects.page.toast.saveFailed"))}}finally{x.current=!1}})())},Sc);return()=>{window.clearTimeout(g)}},[i,l,r,a,c,b,h,o,e,d,u,f,n])},$f=s=>{const e=Ve.c(16),{project:n,onIdentitySave:r,showWorktrees:o}=s,a=o===void 0?!0:o,i=vc(n);let c;e:{if(!n){c=null;break e}let g;e[0]!==n.id||e[1]!==n.path?(g={id:n.id,path:n.path},e[0]=n.id,e[1]=n.path,e[2]=g):g=e[2],c=g}const l=c;let d;if(e[3]!==r?(d=async g=>{await r(g)},e[3]=r,e[4]=d):d=e[4],jc(i,d),!n||!l)return null;let h;e[5]!==i?(h=t.jsx(gc,{form:i}),e[5]=i,e[6]=h):h=e[6];let b;e[7]!==l?(b=t.jsx(pc,{projectRef:l}),e[7]=l,e[8]=b):b=e[8];let f;e[9]!==l||e[10]!==a?(f=a?t.jsx(ic,{projectRef:l}):null,e[9]=l,e[10]=a,e[11]=f):f=e[11];let x;return e[12]!==h||e[13]!==b||e[14]!==f?(x=t.jsxs("div",{className:"space-y-0",children:[h,b,f]}),e[12]=h,e[13]=b,e[14]=f,e[15]=x):x=e[15],x},co=()=>{const s=va();return{displayMode:s,installed:s!=="browser",browserTab:s==="browser"}},Uf=()=>{const s=Ve.c(2),[e,n]=m.useState(kc);let r,o;return s[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=[window.matchMedia("(display-mode: standalone)"),window.matchMedia("(display-mode: minimal-ui)"),window.matchMedia("(display-mode: fullscreen)"),window.matchMedia("(display-mode: window-controls-overlay)")],i=()=>{n(co())};i();for(const c of a)typeof c.addEventListener=="function"?c.addEventListener("change",i):typeof c.addListener=="function"&&c.addListener(i);return window.addEventListener("appinstalled",i),window.addEventListener("focus",i),()=>{for(const c of a)typeof c.removeEventListener=="function"?c.removeEventListener("change",i):typeof c.removeListener=="function"&&c.removeListener(i);window.removeEventListener("appinstalled",i),window.removeEventListener("focus",i)}},o=[],s[0]=r,s[1]=o):(r=s[0],o=s[1]),m.useEffect(r,o),e};function kc(){return co()}const Nc=[{slug:"home",title:"Settings",group:"general",kind:"single",description:"Search and jump to common pages.",keywords:["search","settings"]},{slug:"general",title:"General",group:"general",kind:"single",keywords:["general","startup","launch at login","autostart","tray","password","passkey","security","privacy","telemetry","transport","network","lan","binary","cli"]},{slug:"projects",title:"Projects",group:"projects",kind:"split",keywords:["project","projects","worktree","worktrees","repo","repository","directory"]},{slug:"remote-instances",title:"Remote Instances",group:"projects",kind:"single",keywords:["ssh","remote","instances","tunnels","forwarding","connection"],isAvailable:s=>!s.isVSCode},{slug:"providers",title:"Providers",group:"opencode",kind:"split",keywords:["provider","providers","models","model","api key","api keys","openai","anthropic","ollama","credentials"]},{slug:"usage",title:"Usage",group:"general",kind:"split",keywords:["quota","billing","tokens","usage","limits"]},{slug:"agents",title:"Agents",group:"opencode",kind:"split",keywords:["agent","agents","prompts","tools","permissions"]},{slug:"behavior",title:"Behavior",group:"opencode",kind:"single",keywords:["behavior","agents.md","system prompt","global rules","instructions","override"]},{slug:"commands",title:"Commands",group:"opencode",kind:"split",keywords:["command","commands","slash","macros","automation"]},{slug:"mcp",title:"MCP",group:"opencode",kind:"split",keywords:["mcp","model context protocol","servers","tools","remote","stdio"]},{slug:"plugins",title:"Plugins",group:"opencode",kind:"split",keywords:["plugin","plugins","extensions","addons","npm","opencode-wakatime"]},{slug:"skills.installed",title:"Skills",group:"content",kind:"split",keywords:["skill","skills","instructions","install","catalog"]},{slug:"skills.catalog",title:"Skills Catalog",group:"content",kind:"single",keywords:["install","catalog","external","repository","skills catalog"]},{slug:"git",title:"Git",group:"projects",kind:"single",keywords:["git","identity","identities","ssh","profiles","credentials","keys","commit","gitmoji"],isAvailable:s=>!s.isVSCode},{slug:"appearance",title:"Appearance",group:"general",kind:"single",keywords:["theme","font","spacing","padding","corner radius","radius","input bar","keyboard","viewport","mobile","terminal","pwa","install name","app shortcuts"]},{slug:"chat",title:"Chat",group:"general",kind:"single",keywords:["tools","diff","reasoning","dotfiles","draft","queue","output","copy","image","split messages","message actions"]},{slug:"shortcuts",title:"Shortcuts",group:"general",kind:"single",keywords:["keyboard","hotkeys","shortcuts","bindings"],isAvailable:s=>!s.isVSCode},{slug:"sessions",title:"Sessions",group:"general",kind:"single",keywords:["defaults","default agent","default model","retention","memory","limits","zen"]},{slug:"magic-prompts",title:"Magic Prompts",group:"content",kind:"split",keywords:["prompts","templates","git","github","review","commit","pull request"],isAvailable:s=>!s.isVSCode},{slug:"snippets",title:"Snippets",group:"content",kind:"split",keywords:["prompt","templates","multi-run","strategy","approach"]},{slug:"notifications",title:"Notifications",group:"general",kind:"single",keywords:["alerts","native","summary","summarization"]},{slug:"voice",title:"Voice",group:"general",kind:"single",keywords:["tts","speech","voice"],isAvailable:s=>!s.isVSCode},{slug:"tunnel",title:"External Tunnel",group:"projects",kind:"single",keywords:["tunnel","external","cloudflare","qr","remote","mobile","share"],isAvailable:s=>!s.isVSCode},{slug:"about",title:"About",group:"general",kind:"single",keywords:["about","version","updates","release","changelog"],isAvailable:s=>s.isMobile&&!s.isVSCode},{slug:"integrations",title:"Integrations",group:"general",kind:"single",keywords:["integration","plugin","provider","oauth","claude","cursor","command code","connect","discord","telegram","messenger","github","linear"]}],Ic={sessions:"sessions",agents:"agents",commands:"commands",mcp:"mcp",skills:"skills.installed",providers:"providers",usage:"usage","git-identities":"git",settings:"home"};function Cc(s){const e=s.trim().toLowerCase();return Nc.find(n=>n.slug===e)??null}function Tc(s){const e=(s??"").trim().toLowerCase();if(!e)return"home";const n=Ic[e];if(n)return n;const r=Cc(e);return r?r.slug:"home"}function Wf(s){switch(s){case"general":return"settings-3";case"projects":return"folders";case"remote-instances":return"computer";case"appearance":return"palette";case"chat":return"chat-ai-3";case"magic-prompts":return"ai-generate-2";case"snippets":return"chat-thread";case"notifications":return"notification-3";case"shortcuts":return"command";case"sessions":return"chat-history";case"providers":return"cloud";case"agents":return"ai-agent";case"behavior":return"brain";case"commands":return"slash-commands-2";case"mcp":return null;case"plugins":return"plug-2";case"skills.installed":return"book-open";case"skills.catalog":return"book";case"git":return"git-branch";case"integrations":return"plug";case"usage":return"bar-chart-2";case"voice":return"mic";case"tunnel":return"home-office";case"about":return"information";case"home":return null;default:return"robot-2"}}const Dc=["chat","git","diff","terminal","files"],Pc=["settings","agents","commands","skills","providers","usage","git-identities"],Bt={SESSION:"session",TAB:"tab",SETTINGS:"settings",FILE:"file"};function lr(s){const e=Rc();return{sessionId:Ec(e),tab:Ac(e),settingsPath:Bc(e),diffFile:Lc(e)}}function Rc(){if(typeof window>"u")return new URLSearchParams;try{return new URLSearchParams(window.location.search)}catch{return new URLSearchParams}}function Ec(s){const e=s.get(Bt.SESSION);return!e||e.trim().length===0?null:e.trim()}function Ac(s){const e=s.get(Bt.TAB);if(!e)return null;const n=e.toLowerCase().trim();return Dc.includes(n)?n:null}function Bc(s){const e=s.get(Bt.SETTINGS);if(!e)return null;const n=e.toLowerCase().trim();return n.length===0?null:n==="aiworker"||n==="general"||n==="preferences"?"home":(Pc.includes(n),n)}function Lc(s){const e=s.get(Bt.FILE);if(!e||e.trim().length===0)return null;try{return decodeURIComponent(e.trim())}catch{return e.trim()}}function cr(){if(typeof window>"u")return!1;try{const s=new URLSearchParams(window.location.search);return s.has(Bt.SESSION)||s.has(Bt.TAB)||s.has(Bt.SETTINGS)||s.has(Bt.FILE)}catch{return!1}}function uo(s){const e=new URLSearchParams;if(s.sessionId&&s.sessionId.trim().length>0&&e.set(Bt.SESSION,s.sessionId),s.isSettingsOpen){const n=s.settingsPath.trim().length>0?s.settingsPath:"home";return e.set(Bt.SETTINGS,n),e}return e}function Mc(s,e){const n=typeof window<"u"?window.location.pathname:"/",r=s.toString();return r?`${n}?${r}`:n}function Fc(s){if(typeof window>"u")return!0;try{const e=new URLSearchParams(window.location.search),n=uo(s),r=[...e.entries()].sort((a,i)=>a[0].localeCompare(i[0])),o=[...n.entries()].sort((a,i)=>a[0].localeCompare(i[0]));if(r.length!==o.length)return!1;for(let a=0;a<r.length;a++)if(r[a][0]!==o[a][0]||r[a][1]!==o[a][1])return!1;return!0}catch{return!0}}function dr(s,e={}){if(!(typeof window>"u")&&!(Oc()||Kr())&&!(!e.force&&Fc(s)))try{const n=uo(s),r=Mc(n);e.replace?window.history.replaceState({...window.history.state,route:s},"",r):window.history.pushState({route:s},"",r)}catch{}}function Oc(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}async function $c(s){const e=s.trim();if(!e)return;const n=at.getState();n.currentSessionId!==e&&n.setCurrentSession(e,n.getDirectoryForSession(e));const r=await Sa().catch(()=>null);if(!r)return;const o=at.getState();if(o.currentSessionId!==e)return;const a=[...r.activeSessions,...r.archivedSessions].find(c=>c.id===e);if(!a)return;const i=Ar(a);!i||i===o.currentSessionDirectory||o.setCurrentSession(e,i)}function Uc(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function _f(){const s=m.useMemo(()=>Uc(),[]),e=m.useMemo(()=>Kr(),[]),n=m.useRef(!1),r=m.useRef(!1),o=He(u=>u.setSettingsDialogOpen),a=He(u=>u.setSettingsPage),i=He(u=>u.navigateToDiff),c=m.useCallback(async u=>{if(!r.current){r.current=!0;try{if(u.sessionId&&await $c(u.sessionId),u.settingsPath){a(Tc(u.settingsPath)),o(!0);return}if(He.getState().isSettingsDialogOpen&&o(!1),u.tab&&u.tab!=="chat"){const h=gs.getState().currentDirectory;if(h){const b=u.tab==="files"?"file":u.tab;He.getState().openContextSurface(h,b)}}u.diffFile&&(u.tab==="diff"||!u.tab)&&i(u.diffFile)}finally{r.current=!1}}},[o,a,i]),l=m.useCallback(()=>{const u=at.getState(),h=He.getState();return{sessionId:u.currentSessionId,isSettingsOpen:h.isSettingsDialogOpen,settingsPath:h.settingsPage}},[]),d=m.useCallback((u={})=>{if(s||e||r.current)return;const h=l();dr(h,u)},[s,e,l]);m.useEffect(()=>{if(n.current||(n.current=!0,!cr()))return;const u=lr();(async()=>(await c(u),!s&&!e&&dr({...l(),sessionId:u.sessionId??at.getState().currentSessionId,settingsPath:u.settingsPath??He.getState().settingsPage},{replace:!0,force:!0})))()},[c,l,s,e]),m.useEffect(()=>{if(s||e)return;let u=at.getState().currentSessionId;return at.subscribe(b=>{const f=b.currentSessionId;f===u||r.current||(u=f,d())})},[s,e,d]),m.useEffect(()=>{if(s||e)return;let u=He.getState().isSettingsDialogOpen,h=He.getState().settingsPage;return He.subscribe(f=>{if(r.current)return;const x=f.isSettingsDialogOpen!==u,g=f.settingsPage!==h;u=f.isSettingsDialogOpen,h=f.settingsPage,(x||g)&&d()})},[s,e,d]),m.useEffect(()=>{if(typeof window>"u"||s||e)return;const u=()=>{const h=lr();cr()?c(h):He.getState().isSettingsDialogOpen&&o(!1)};return window.addEventListener("popstate",u),()=>{window.removeEventListener("popstate",u)}},[c,s,e,o])}function Vf(){const s=Ve.c(5),e=ul(_c),n=m.useRef(e);let r,o;s[0]!==e?(r=()=>{n.current=e},o=[e],s[0]=e,s[1]=r,s[2]=o):(r=s[1],o=s[2]),m.useEffect(r,o);let a,i;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{let c=!1,l=null;const d=Wc,u=h=>{c||(l=window.setTimeout(async()=>{const b=await n.current(),f=typeof b=="number"&&Number.isFinite(b)?d(b):36e5;u(f)},h))};return u(3e3),()=>{c=!0,l!==null&&window.clearTimeout(l)}},i=[],s[3]=a,s[4]=i):(a=s[3],i=s[4]),m.useEffect(a,i)}function Wc(s){const e=Math.round(s*1e3);return Math.max(3e5,Math.min(864e5,e))}function _c(s){return s.checkForUpdates}const In=1e3,ws=60*In,sn=60*ws,Vc=(s,e)=>{const n=Math.max(0,s);return n<ws?e("common.duration.secondsCompact",{seconds:Math.floor(n/In)}):n<sn?e("common.duration.minutesSecondsCompact",{minutes:Math.floor(n/ws),seconds:Math.floor(n%ws/In)}):e("common.duration.hoursMinutesCompact",{hours:Math.floor(n/sn),minutes:Math.floor(n%sn/ws)})},zc=1e3,zf=s=>{const e=Ve.c(12),{sessionId:n,running:r,className:o}=s,{t:a}=nt(),i=ja(n),c=ka(n),l=Na(r,zc),d=r?Math.max(0,l-(i??l)):c;if(d===void 0)return null;let u,h;e[0]!==d||e[1]!==r||e[2]!==a?(u=Vc(d,a),h=r?a("sessions.sidebar.session.status.activeFor",{duration:u}):a("sessions.sidebar.session.status.lastTurnDuration",{duration:u}),e[0]=d,e[1]=r,e[2]=a,e[3]=u,e[4]=h):(u=e[3],h=e[4]);const b=h,f=r?"text-primary":"text-[var(--status-info)]";let x;e[5]!==o||e[6]!==f?(x=ie("shrink-0 tabular-nums",f,o),e[5]=o,e[6]=f,e[7]=x):x=e[7];let g;return e[8]!==b||e[9]!==u||e[10]!==x?(g=t.jsx("span",{className:x,"aria-label":b,title:b,children:u}),e[8]=b,e[9]=u,e[10]=x,e[11]=g):g=e[11],g},Gc=()=>{const s=Ve.c(14),[e,n]=de.useState(!1),[r,o]=de.useState(!1);let a,i;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{n(Vr()),o(Ni())},i=[],s[0]=a,s[1]=i):(a=s[0],i=s[1]),de.useEffect(a,i);let c;s[2]!==e?(c=async x=>e?await Ii(x):{success:!0,path:x},s[2]=e,s[3]=c):c=s[3];const l=c;let d;s[4]!==e?(d=async x=>e?await Ci():{success:!0},s[4]=e,s[5]=d):d=s[5];const u=d;let h;s[6]!==e?(h=async x=>e?await Ti():{success:!0},s[6]=e,s[7]=h):h=s[7];const b=h;let f;return s[8]!==r||s[9]!==e||s[10]!==l||s[11]!==u||s[12]!==b?(f={isDesktop:e,canRequestAccess:r,requestAccess:l,startAccessing:u,stopAccessing:b},s[8]=r,s[9]=e,s[10]=l,s[11]=u,s[12]=b,s[13]=f):f=s[13],f},Hc=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),Kc=({currentBranch:s,localBranches:e,remoteBranches:n,branchInfo:r,onCheckout:o,onCreate:a,remotes:i=[],disabled:c=!1})=>{const{t:l}=nt(),[d,u]=m.useState(!1),[h,b]=m.useState(""),[f,x]=m.useState(!1),[g,j]=m.useState(!1),[p,k]=m.useState(""),[P,A]=m.useState(!1),N=m.useRef(null),C=m.useCallback(_=>{_.stopPropagation()},[]),w=i.length>1,v=m.useMemo(()=>Hc(p),[p]),L=m.useMemo(()=>pn(e,h,_=>[_]),[h,e]),$=m.useMemo(()=>pn(n,h,_=>[_]),[h,n]),M=_=>{if(_===s){u(!1);return}o(_),u(!1),b("")},H=()=>{x(!0),setTimeout(()=>N.current?.focus(),50)},K=async()=>{if(!(!v||P)){if(w){j(!0);return}A(!0);try{await a(v,i[0]),k(""),x(!1),u(!1)}finally{A(!1)}}},ee=async _=>{if(!(!v||P)){A(!0);try{await a(v,_),k(""),x(!1),j(!1),u(!1)}finally{A(!1)}}},Y=()=>{j(!1)},O=()=>{k(""),x(!1),j(!1)};return m.useEffect(()=>{d||(b(""),x(!1),j(!1),k(""))},[d]),t.jsxs(zt,{open:d,onOpenChange:u,children:[t.jsxs(ms,{children:[t.jsx(hs,{asChild:!0,children:t.jsx(Gt,{asChild:!0,children:t.jsxs(Ne,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:c,children:[t.jsx(E,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:s||l("gitView.branch.detachedHead")}),t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),t.jsx(ps,{sideOffset:8,children:l("gitView.branch.currentBranchTooltip")})]}),t.jsx(Ht,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:t.jsxs(gn,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(xn,{placeholder:l("gitView.branch.searchPlaceholder"),value:h,onValueChange:b,onKeyDown:C}),t.jsxs(bn,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(yn,{children:l("gitView.branch.empty")}),t.jsx(Ut,{children:g?t.jsxs("div",{className:"px-2 py-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("button",{type:"button",onClick:Y,disabled:P,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(E,{name:"arrow-left",className:"size-4"})}),t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[l("gitView.branch.pushToPrefix")," ",t.jsx("span",{className:"text-foreground font-medium",children:v})," ",l("gitView.branch.pushToSuffix")]})]}),t.jsx("div",{className:"flex flex-col gap-1",children:i.map(_=>t.jsxs("button",{type:"button",onClick:()=>ee(_),disabled:P,className:"flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50",children:[t.jsxs("span",{className:"typography-ui-label text-foreground",children:[P?t.jsx(E,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,_.name]}),t.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:_.pushUrl})]},_.name))})]}):f?t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[t.jsx("input",{ref:N,placeholder:l("gitView.branch.newBranchPlaceholder"),value:p,onChange:_=>k(_.target.value),onClick:_=>_.stopPropagation(),onKeyDown:_=>{C(_),_.key==="Enter"?(_.preventDefault(),K()):_.key==="Escape"&&(_.preventDefault(),O())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:K,disabled:!v||P,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:P?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"add",className:"size-4"})}),t.jsx("button",{type:"button",onClick:O,disabled:P,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(E,{name:"close",className:"size-4"})})]}):t.jsxs(Pt,{onSelect:H,children:[t.jsx(E,{name:"add",className:"size-4"}),t.jsx("span",{children:l("gitView.branch.create")})]})}),t.jsx(Us,{}),t.jsxs(Ut,{heading:l("gitView.branch.localBranches"),children:[L.map(_=>t.jsxs(Pt,{onSelect:()=>M(_),children:[t.jsxs("span",{className:"flex flex-1 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:_}),(r?.[_]?.ahead||r?.[_]?.behind)&&t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[r[_].ahead||0," ahead ·"," ",r[_].behind||0," behind"]})]}),s===_&&t.jsx("span",{className:"typography-micro text-primary",children:l("gitView.branch.currentBadge")})]},`local-${_}`)),L.length===0&&t.jsx(Pt,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:l("gitView.branch.noLocalBranches")})})]}),t.jsx(Us,{}),t.jsxs(Ut,{heading:l("gitView.branch.remoteBranches"),children:[$.map(_=>t.jsx(Pt,{onSelect:()=>M(_),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:_})},`remote-${_}`)),$.length===0&&t.jsx(Pt,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:l("gitView.branch.noRemoteBranches")})})]})]})]})})]})},qc=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),Yc=({currentBranch:s,onRename:e,showEditButton:n=!0})=>{const{t:r}=nt(),[o,a]=m.useState(!1),[i,c]=m.useState(s||""),[l,d]=m.useState(!1),u=m.useRef(null),h=()=>{!s||!e||(c(s),a(!0),setTimeout(()=>u.current?.focus(),0))},b=async()=>{if(!s||!e||!i.trim())return;const g=qc(i);if(g===s){a(!1);return}d(!0);try{await e(s,g),a(!1),c("")}finally{d(!1)}},f=()=>{a(!1),c("")},x=g=>{g.key==="Enter"?(g.preventDefault(),b()):g.key==="Escape"&&(g.preventDefault(),f())};return o?t.jsx("div",{className:"flex items-center gap-2 rounded-md bg-primary/12 px-2 py-1 h-8",children:t.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:g=>{g.preventDefault(),b()},children:[t.jsx(E,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("input",{ref:u,value:i,onChange:g=>c(g.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",placeholder:r("gitView.branch.namePlaceholder"),onKeyDown:x,autoFocus:!0}),t.jsx("button",{type:"submit",disabled:l,"aria-label":r(l?"gitView.branch.renameSaving":"gitView.branch.renameSave"),title:r(l?"gitView.branch.renameSaving":"gitView.branch.renameSave"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:l?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"check",className:"size-4"})}),t.jsx("button",{type:"button",onClick:f,disabled:l,"aria-label":r("gitView.branch.renameCancel"),title:r("gitView.branch.renameCancel"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(E,{name:"close",className:"size-4"})})]})}):t.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5 px-2 py-1 h-8",children:[t.jsx(E,{name:"git-branch",className:"size-4 text-primary shrink-0"}),t.jsxs("div",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[t.jsx("span",{className:"truncate typography-ui-label font-normal text-foreground",children:s||r("gitView.branch.detachedHead")}),n&&e&&s&&t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:h,title:r("gitView.branch.renameTitle"),children:t.jsx(E,{name:"edit",className:"size-4"})})]})]})},Jc=s=>{const e=Ve.c(44),{syncAction:n,remotes:r,onFetch:o,onSync:a,onRemoveRemote:i,disabled:c,removingRemoteName:l,aheadCount:d,behindCount:u,trackingRemoteName:h,hasUncommittedChanges:b}=s,f=r===void 0?[]:r,x=l===void 0?null:l,g=d===void 0?0:d,j=u===void 0?0:u,p=b===void 0?!1:b,{t:k}=nt(),P=m.useRef(!1),A=!!x,N=f.find(le=>le.name===h)??f[0],C=j>0&&p,w=c||n!==null||A||!N||C,v=c||n!==null||A||f.length===0,L=g>0||j>0;let $;e[0]!==k?($=k("gitView.sync.sync"),e[0]=k,e[1]=$):$=e[1];const M=j>0?`↓${j}`:null,H=g>0?`↑${g}`:null;let K;e[2]!==$||e[3]!==M||e[4]!==H?(K=[$,M,H].filter(Boolean),e[2]=$,e[3]=M,e[4]=H,e[5]=K):K=e[5];const ee=K.join(" "),Y=C?k("gitView.sync.commitOrStashTooltip"):N?L?k("gitView.sync.syncChangesTooltip",{ahead:g,behind:j}):k("gitView.sync.syncChanges"):k("gitView.sync.noRemoteTooltip"),O=()=>{N&&a(N)},_="inline-flex items-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] border border-border/60 bg-[var(--surface-elevated)] overflow-hidden",U=C?0:void 0;let J;e[6]===Symbol.for("react.memo_cache_sentinel")?(J=ie("inline-flex h-7 items-center gap-1.5 px-2 typography-ui-label font-medium text-foreground","transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),e[6]=J):J=e[6];let D;e[7]!==k?(D=k("gitView.sync.syncChanges"),e[7]=k,e[8]=D):D=e[8];let z;e[9]!==n?(z=n==="sync"?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"refresh",className:"size-4"}),e[9]=n,e[10]=z):z=e[10];let F;e[11]!==ee?(F=t.jsx("span",{className:"whitespace-nowrap tabular-nums",children:ee}),e[11]=ee,e[12]=F):F=e[12];let R;e[13]!==O||e[14]!==w||e[15]!==D||e[16]!==z||e[17]!==F?(R=t.jsxs("button",{type:"button",onClick:O,disabled:w,className:J,"aria-label":D,children:[z,F]}),e[13]=O,e[14]=w,e[15]=D,e[16]=z,e[17]=F,e[18]=R):R=e[18];let V;e[19]!==U||e[20]!==R?(V=t.jsx(hs,{asChild:!0,children:t.jsx("span",{className:"inline-flex",tabIndex:U,children:R})}),e[19]=U,e[20]=R,e[21]=V):V=e[21];let ne;e[22]!==Y?(ne=t.jsx(ps,{sideOffset:8,children:Y}),e[22]=Y,e[23]=ne):ne=e[23];let Q;e[24]!==V||e[25]!==ne?(Q=t.jsxs(ms,{children:[V,ne]}),e[24]=V,e[25]=ne,e[26]=Q):Q=e[26];const q=zt;let oe;e[27]===Symbol.for("react.memo_cache_sentinel")?(oe=ie("inline-flex h-7 w-6 items-center justify-center border-l border-[var(--interactive-border)] text-muted-foreground","transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),e[27]=oe):oe=e[27];let Z;e[28]!==k?(Z=k("gitView.sync.moreActionsAria"),e[28]=k,e[29]=Z):Z=e[29];let te;e[30]===Symbol.for("react.memo_cache_sentinel")?(te=t.jsx(E,{name:"arrow-down-s",className:"size-4"}),e[30]=te):te=e[30];let ye;e[31]!==v||e[32]!==Z?(ye=t.jsx(Gt,{asChild:!0,children:t.jsx("button",{type:"button",className:oe,disabled:v,"aria-label":Z,children:te})}),e[31]=v,e[32]=Z,e[33]=ye):ye=e[33];const re=Ht,ge="start",se=-40,fe="w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",he=f.map(le=>t.jsx(At,{onSelect:pe=>{if(P.current){pe.preventDefault(),P.current=!1;return}o(le)},children:t.jsxs("div",{className:"flex w-full items-center gap-2",children:[t.jsx(E,{name:"refresh",className:"size-4 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:k("gitView.sync.fetchFromRemote",{name:le.name})}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:le.fetchUrl})]})}),i&&le.name!==h?t.jsx(Ne,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:n!==null||A,onPointerDown:pe=>{P.current=!0,pe.preventDefault(),pe.stopPropagation()},onClick:pe=>{P.current=!0,pe.preventDefault(),pe.stopPropagation(),i(le)},"aria-label":k("gitView.header.removeRemoteAria",{name:le.name}),title:k("gitView.header.removeRemoteTitle",{name:le.name}),children:x===le.name?t.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(E,{name:"close",className:"size-3.5"})}):null]})},le.name));let S;e[34]!==re||e[35]!==he?(S=t.jsx(re,{align:ge,alignOffset:se,className:fe,children:he}),e[34]=re,e[35]=he,e[36]=S):S=e[36];let B;e[37]!==q||e[38]!==ye||e[39]!==S?(B=t.jsxs(q,{children:[ye,S]}),e[37]=q,e[38]=ye,e[39]=S,e[40]=B):B=e[40];let W;return e[41]!==Q||e[42]!==B?(W=t.jsxs("div",{className:_,children:[Q,B]}),e[41]=Q,e[42]=B,e[43]=W):W=e[43],W},Qc=s=>{const e=Ve.c(27),{repositories:n,selectedRepository:r,onSelectRepository:o,repositoryRoot:a}=s,{t:i}=nt();let c;e[0]!==a?(c=P=>{const A=`${a??""}/`;return P.startsWith(A)?P.slice(A.length):P},e[0]=a,e[1]=c):c=e[1];const l=c,d=r??void 0;let u;e[2]!==o?(u=P=>{P&&o(P)},e[2]=o,e[3]=u):u=e[3];let h;e[4]!==i?(h=i("gitView.empty.selectRepositoryPlaceholder"),e[4]=i,e[5]=h):h=e[5];let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(E,{name:"folder-3",className:"size-4 text-muted-foreground"}),e[6]=b):b=e[6];let f;e[7]!==l||e[8]!==r?(f=r?l(r):"",e[7]=l,e[8]=r,e[9]=f):f=e[9];let x;e[10]!==f?(x=t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:f}),e[10]=f,e[11]=x):x=e[11];let g;e[12]!==h||e[13]!==x?(g=t.jsxs(Pn,{size:"sm",className:"max-w-[13rem] gap-1.5 px-2 py-1","aria-label":h,children:[b,x]}),e[12]=h,e[13]=x,e[14]=g):g=e[14];let j;if(e[15]!==l||e[16]!==n){let P;e[18]!==l?(P=A=>t.jsx(js,{value:A,children:t.jsx("span",{className:"truncate",children:l(A)})},A),e[18]=l,e[19]=P):P=e[19],j=n.map(P),e[15]=l,e[16]=n,e[17]=j}else j=e[17];let p;e[20]!==j?(p=t.jsx(Rn,{align:"start",children:j}),e[20]=j,e[21]=p):p=e[21];let k;return e[22]!==p||e[23]!==d||e[24]!==u||e[25]!==g?(k=t.jsxs(Dn,{value:d,onValueChange:u,children:[g,p]}),e[22]=p,e[23]=d,e[24]=u,e[25]=g,e[26]=k):k=e[26],k},Xc={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",user:"user-3",fingerprint:"fingerprint"},Zc={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)",success:"var(--status-success)",info:"var(--status-info)",warning:"var(--status-warning)"};function fo(s){return s&&Zc[s]||"var(--primary)"}const ur=s=>{const e=Ve.c(8),{icon:n,className:r,colorToken:o}=s,a=Xc[n??"branch"]??"user-3";let i;e[0]!==o?(i=fo(o),e[0]=o,e[1]=i):i=e[1];let c;e[2]!==i?(c={color:i},e[2]=i,e[3]=c):c=e[3];let l;return e[4]!==r||e[5]!==a||e[6]!==c?(l=t.jsx(E,{name:a,className:r,style:c}),e[4]=r,e[5]=a,e[6]=c,e[7]=l):l=e[7],l},mo=s=>{const e=Ve.c(35),{activeProfile:n,identities:r,onSelect:o,isApplying:a,iconOnly:i}=s,c=i===void 0?!1:i,{t:l}=nt(),d=a||r.length===0,u=n?.color;let h;e[0]!==u?(h=fo(u),e[0]=u,e[1]=h):h=e[1];let b;e[2]!==h?(b={color:h},e[2]=h,e[3]=b):b=e[3];let f;e[4]!==n?.color||e[5]!==n?.icon||e[6]!==a?(f=a?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(ur,{icon:n?.icon,colorToken:n?.color,className:"size-4"}),e[4]=n?.color,e[5]=n?.icon,e[6]=a,e[7]=f):f=e[7];let x;e[8]!==n?.name||e[9]!==c||e[10]!==l?(x=!c&&t.jsx("span",{className:"git-identity-label min-w-0 flex-1 truncate text-left",children:n?.name||l("gitView.header.noIdentity")}),e[8]=n?.name,e[9]=c,e[10]=l,e[11]=x):x=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60"}),e[12]=g):g=e[12];let j;e[13]!==d||e[14]!==b||e[15]!==f||e[16]!==x?(j=t.jsx(hs,{asChild:!0,children:t.jsx(Gt,{asChild:!0,children:t.jsxs(Ne,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-[15rem] justify-start gap-1.5 px-2 py-1 typography-ui-label",style:b,disabled:d,children:[f,x,g]})})}),e[13]=d,e[14]=b,e[15]=f,e[16]=x,e[17]=j):j=e[17];let p;e[18]!==l?(p=l("gitView.header.identityTooltip"),e[18]=l,e[19]=p):p=e[19];let k;e[20]!==p?(k=t.jsx(ps,{sideOffset:8,children:p}),e[20]=p,e[21]=k):k=e[21];let P;e[22]!==k||e[23]!==j?(P=t.jsxs(ms,{children:[j,k]}),e[22]=k,e[23]=j,e[24]=P):P=e[24];let A;e[25]!==n?.id||e[26]!==r||e[27]!==o||e[28]!==l?(A=r.length===0?t.jsx("div",{className:"px-2 py-1.5",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:l("gitView.header.noProfiles")})}):r.map(w=>{const v=n?.id===w.id;return t.jsx(At,{onSelect:()=>o(w),children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(ur,{icon:w.icon,colorToken:w.color,className:"size-4"}),t.jsxs("span",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:w.name}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:w.userEmail})]}),v?t.jsx(E,{name:"check",className:"ml-auto size-4 text-foreground"}):null]})},w.id)}),e[25]=n?.id,e[26]=r,e[27]=o,e[28]=l,e[29]=A):A=e[29];let N;e[30]!==A?(N=t.jsx(Ht,{align:"end",className:"w-64",children:A}),e[30]=A,e[31]=N):N=e[31];let C;return e[32]!==P||e[33]!==N?(C=t.jsxs(zt,{children:[P,N]}),e[32]=P,e[33]=N,e[34]=C):C=e[34],C},ed=s=>{const e=Ve.c(21),{comparison:n,trackingBranch:r,tooltipDelayMs:o}=s,a=o===void 0?1e3:o,{t:i}=nt(),c=`${n.remote}/${n.branch}`,l=n.ahead===0&&n.behind===0;let d;e[0]!==i||e[1]!==c||e[2]!==r?(d=r?i("gitView.header.upstreamTooltipTracking",{target:c,tracking:r}):i("gitView.header.upstreamTooltip",{target:c}),e[0]=i,e[1]=c,e[2]=r,e[3]=d):d=e[3];const u=d;let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(E,{name:"git-branch",className:"size-3.5 shrink-0"}),e[4]=h):h=e[4];let b;e[5]!==c?(b=t.jsx("span",{className:"min-w-0 truncate text-foreground/80",children:c}),e[5]=c,e[6]=b):b=e[6];let f;e[7]!==n.ahead||e[8]!==n.behind||e[9]!==l||e[10]!==i?(f=l?t.jsx("span",{className:"tabular-nums text-muted-foreground",children:i("gitView.header.upstreamSynced")}):t.jsxs("span",{className:"inline-flex items-center gap-1 tabular-nums",children:[n.ahead>0?t.jsxs("span",{className:"text-[var(--status-info)]",children:["↑",n.ahead]}):null,n.behind>0?t.jsxs("span",{className:"text-[var(--status-warning)]",children:["↓",n.behind]}):null]}),e[7]=n.ahead,e[8]=n.behind,e[9]=l,e[10]=i,e[11]=f):f=e[11];let x;e[12]!==b||e[13]!==f?(x=t.jsx(hs,{asChild:!0,children:t.jsxs("div",{className:"inline-flex h-8 max-w-full items-center gap-1.5 rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 typography-micro text-muted-foreground",children:[h,b,f]})}),e[12]=b,e[13]=f,e[14]=x):x=e[14];let g;e[15]!==u?(g=t.jsx(ps,{sideOffset:8,children:u}),e[15]=u,e[16]=g):g=e[16];let j;return e[17]!==x||e[18]!==g||e[19]!==a?(j=t.jsxs(ms,{delayDuration:a,children:[x,g]}),e[17]=x,e[18]=g,e[19]=a,e[20]=j):j=e[20],j},Gf=s=>{const e=Ve.c(79),{status:n,localBranches:r,remoteBranches:o,branchInfo:a,syncAction:i,remotes:c,onFetch:l,onSync:d,onRemoveRemote:u,removingRemoteName:h,onCheckoutBranch:b,onCreateBranch:f,onRenameBranch:x,activeIdentityProfile:g,availableIdentities:j,onSelectIdentity:p,isApplyingIdentity:k,isWorktreeMode:P,onOpenHistory:A,onOpenGraph:N,onOpenStashes:C,onOpenUpdateBranch:w,onOpenReintegrateCommits:v,pullRequest:L,prChecks:$,onOpenPullRequest:M,repositoryOptions:H,selectedRepository:K,onSelectRepository:ee,repositoryRoot:Y}=s,{t:O}=nt();if(!n)return null;let _;e[0]!==H?(_=H??[],e[0]=H,e[1]=_):_=e[1];let U;e[2]!==_?(U=_.filter(Boolean),e[2]=_,e[3]=U):U=e[3];const J=U;let D;e[4]!==N||e[5]!==A||e[6]!==v||e[7]!==C||e[8]!==w||e[9]!==O?(D=A||N||C||w?t.jsxs(zt,{children:[t.jsxs(ms,{children:[t.jsx(hs,{asChild:!0,children:t.jsx(Gt,{asChild:!0,children:t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":O("gitView.header.repositoryViews"),children:t.jsx(E,{name:"more-fill",className:"size-4"})})})}),t.jsx(ps,{sideOffset:8,children:O("gitView.header.repositoryViews")})]}),t.jsxs(Ht,{align:"end",children:[A?t.jsxs(At,{onSelect:A,children:[t.jsx(E,{name:"history",className:"size-4"}),O("gitView.history.title")]}):null,N?t.jsxs(At,{onSelect:N,children:[t.jsx(E,{name:"git-branch",className:"size-4"}),O("gitView.graph.title")]}):null,C?t.jsxs(At,{onSelect:C,children:[t.jsx(E,{name:"archive-stack",className:"size-4"}),O("gitView.stashes.title")]}):null,w?t.jsxs(At,{onSelect:w,children:[t.jsx(E,{name:"git-merge",className:"size-4"}),O("gitView.header.updateBranch")]}):null,v?t.jsxs(At,{onSelect:v,children:[t.jsx(E,{name:"split-cells-horizontal",className:"size-4"}),O("gitView.integrate.title")]}):null]})]}):null,e[4]=N,e[5]=A,e[6]=v,e[7]=C,e[8]=w,e[9]=O,e[10]=D):D=e[10];let z;e[11]!==D?(z=t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:D}),e[11]=D,e[12]=z):z=e[12];const F=z,R=$?$.state==="success"?"var(--status-success)":$.state==="failure"?"var(--status-error)":"var(--status-warning)":null,V=L?L.state==="merged"?"merged":L.state==="closed"?"closed":L.draft?"draft":$?.state==="failure"||L.mergeable===!1||L.mergeableState==="blocked"||L.mergeableState==="dirty"?"blocked":"open":null;let ne;e[13]!==M||e[14]!==R||e[15]!==V||e[16]!==L||e[17]!==O?(ne=L&&M?t.jsxs(ms,{children:[t.jsx(hs,{asChild:!0,children:t.jsxs(Ne,{variant:"ghost",size:"sm",onClick:M,className:"h-8 gap-1.5 px-2 typography-micro",children:[t.jsx(E,{name:"git-pull-request",className:"size-3.5",style:{color:`var(--pr-${V})`}}),t.jsx("span",{className:"tabular-nums text-foreground/80",children:O("gitView.pr.numberLabel",{number:L.number})}),R?t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:R}}):null]})}),t.jsx(ps,{sideOffset:8,children:O("gitView.header.openPullRequest")})]}):null,e[13]=M,e[14]=R,e[15]=V,e[16]=L,e[17]=O,e[18]=ne):ne=e[18];const Q=ne,q=!n;let oe;e[19]!==n.tracking?(oe=n.tracking?.split("/")[0],e[19]=n.tracking,e[20]=oe):oe=e[20];const Z=(n.files?.length??0)>0;let te;e[21]!==l||e[22]!==u||e[23]!==d||e[24]!==c||e[25]!==h||e[26]!==n.ahead||e[27]!==n.behind||e[28]!==i||e[29]!==q||e[30]!==oe||e[31]!==Z?(te=t.jsx(Jc,{syncAction:i,remotes:c,onFetch:l,onSync:d,onRemoveRemote:u,removingRemoteName:h,disabled:q,iconOnly:!0,aheadCount:n.ahead,behindCount:n.behind,trackingRemoteName:oe,hasUncommittedChanges:Z}),e[21]=l,e[22]=u,e[23]=d,e[24]=c,e[25]=h,e[26]=n.ahead,e[27]=n.behind,e[28]=i,e[29]=q,e[30]=oe,e[31]=Z,e[32]=te):te=e[32];const ye=te;let re;e[33]!==n.tracking||e[34]!==n.upstreamComparison?(re=n.upstreamComparison?t.jsx(ed,{comparison:n.upstreamComparison,trackingBranch:n.tracking,tooltipDelayMs:1e3}):null,e[33]=n.tracking,e[34]=n.upstreamComparison,e[35]=re):re=e[35];const ge=re;let se;e[36]!==g||e[37]!==j||e[38]!==k||e[39]!==p?(se=t.jsx(mo,{activeProfile:g,identities:j,onSelect:p,isApplying:k,iconOnly:!0}),e[36]=g,e[37]=j,e[38]=k,e[39]=p,e[40]=se):se=e[40];const fe=se;let he;e[41]!==a||e[42]!==P||e[43]!==r||e[44]!==b||e[45]!==f||e[46]!==x||e[47]!==o||e[48]!==c||e[49]!==n.current?(he=P?t.jsx(Yc,{currentBranch:n.current,onRename:x}):t.jsx(Kc,{currentBranch:n.current,localBranches:r,remoteBranches:o,branchInfo:a,onCheckout:b,onCreate:f,remotes:c}),e[41]=a,e[42]=P,e[43]=r,e[44]=b,e[45]=f,e[46]=x,e[47]=o,e[48]=c,e[49]=n.current,e[50]=he):he=e[50];let S;e[51]!==ee||e[52]!==J||e[53]!==Y||e[54]!==K?(S=J.length>0&&ee?t.jsx(Qc,{repositories:J,selectedRepository:K??null,onSelectRepository:ee,repositoryRoot:Y}):null,e[51]=ee,e[52]=J,e[53]=Y,e[54]=K,e[55]=S):S=e[55];let B;e[56]!==he||e[57]!==S?(B=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[he,S]}),e[56]=he,e[57]=S,e[58]=B):B=e[58];let W;e[59]!==fe?(W=t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:fe}),e[59]=fe,e[60]=W):W=e[60];let le;e[61]!==B||e[62]!==W?(le=t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[B,W]}),e[61]=B,e[62]=W,e[63]=le):le=e[63];let pe;e[64]!==Q?(pe=Q?t.jsx("div",{className:"shrink-0",children:Q}):null,e[64]=Q,e[65]=pe):pe=e[65];let Te;e[66]===Symbol.for("react.memo_cache_sentinel")?(Te=t.jsx("div",{className:"min-w-0 flex-1"}),e[66]=Te):Te=e[66];let Ie;e[67]!==ge?(Ie=ge?t.jsx("div",{className:"min-w-0 shrink",children:ge}):null,e[67]=ge,e[68]=Ie):Ie=e[68];let We;e[69]!==ye?(We=t.jsx("div",{className:"shrink-0",children:ye}),e[69]=ye,e[70]=We):We=e[70];let Me;e[71]!==F||e[72]!==pe||e[73]!==Ie||e[74]!==We?(Me=t.jsxs("div",{className:"mt-3 flex h-8 min-w-0 items-center gap-2",children:[pe,Te,Ie,F,We]}),e[71]=F,e[72]=pe,e[73]=Ie,e[74]=We,e[75]=Me):Me=e[75];let ve;return e[76]!==le||e[77]!==Me?(ve=t.jsxs("header",{className:"@container/git-header px-3 py-2 bg-transparent",children:[le,Me]}),e[76]=le,e[77]=Me,e[78]=ve):ve=e[78],ve},td=s=>s==="/",Vs=s=>s.replace(/\\/g,"/"),Ln=s=>{if(!s||td(s))return s;let e=s;for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e},Jt=s=>s.endsWith("/"),sd=s=>{const e=s.trim();return!e||Jt(e)?e:`${e}/`},Mn=s=>s.lastIndexOf("/"),ho=s=>{if(Jt(s))return s;const e=Mn(s);return e<0?s:s.slice(0,e+1)},nd=s=>{const e=Mn(s);return s.slice(e+1)},po=s=>{const e=Ln(s.trim());if(!e||e==="~"||e==="~/"||e==="/")return null;const n=Mn(e);return n<0?null:e.startsWith("~/")&&n<=1?"~/":n===0?"/":`${e.slice(0,n)}/`},rd=s=>Jt(s)&&po(s)!==null,od=(s,e)=>`${ho(s)}${e}/`,$t=s=>{if(!s)return null;const e=Ln(Vs(s.trim()));return e?e.toLowerCase():null},fr=(s,e)=>{const n=s.trim();return n==="~"?e:n.startsWith("~/")?`${e}${n.slice(1)}`:n},ad=s=>typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?s.metaKey&&!s.ctrlKey:s.ctrlKey&&!s.metaKey,nn=s=>{if(!s)return;s.focus({preventScroll:!0});const e=s.value.length;s.setSelectionRange(e,e),s.scrollLeft=s.scrollWidth},id=async()=>{try{const s=await Lt("/api/fs/home",{method:"GET",headers:{Accept:"application/json"}});if(s.ok){const e=await s.json();if(typeof e.home=="string"&&e.home.trim().length>0)return Vs(e.home.trim())}}catch{}return fs.getFilesystemHome().catch(()=>null)},Hf=({open:s,onOpenChange:e})=>{const{t:n}=nt(),r=gs(I=>I.homeDirectory),o=It(I=>I.projects),a=It(I=>I.addProject),i=He(I=>I.setSessionSwitcherOpen),c=at(I=>I.openNewSessionDraft),l=It(I=>I.addProjects),d=qt(I=>I.profiles),u=qt(I=>I.globalIdentity),h=qt(I=>I.defaultGitIdentityId),b=qt(I=>I.loadProfiles),f=qt(I=>I.loadGlobalIdentity),x=qt(I=>I.loadDefaultGitIdentityId),{canRequestAccess:g,requestAccess:j,startAccessing:p}=Gc(),{isMobile:k}=Gs(),P=m.useRef(null),A=m.useRef(null),N=m.useRef(new Map),[C,w]=m.useState(""),[v,L]=m.useState("~/"),[$,M]=m.useState([]),[H,K]=m.useState(!1),[ee,Y]=m.useState(!1),[O,_]=m.useState(null),[U,J]=m.useState(0),[D,z]=m.useState(0),[F,R]=m.useState(!1),[V,ne]=m.useState(!1),[Q,q]=m.useState(0),[oe,Z]=m.useState(!1),[te,ye]=m.useState(""),[re,ge]=m.useState(null),[se,fe]=m.useState(!1),[he,S]=m.useState([]),B=C||r,W=m.useMemo(()=>new Set(o.map(I=>$t(I.path)).filter(I=>!!I)),[o]);m.useEffect(()=>{if(!s)return;L("~/"),M([]),z(0),R(!1),ne(!1),Z(!1),ye(""),ge(null),fe(!1),S([]),requestAnimationFrame(()=>nn(P.current));let I=!1;return(async()=>{const xe=await id();I||(w(xe||r||""),requestAnimationFrame(()=>nn(P.current)))})(),()=>{I=!0}},[r,s]),m.useEffect(()=>{s&&(b(),f(),x())},[x,b,f,s]);const le=m.useMemo(()=>{const I=new Map;u&&I.set(u.id,u);for(const ae of d)I.set(ae.id,ae);return Array.from(I.values())},[d,u]);m.useEffect(()=>{if(!s||!oe||re!==null)return;const I=typeof h=="string"?h.trim():"";if(I&&le.some(xe=>xe.id===I)){ge(I);return}const ae=le.find(xe=>xe.authType==="ssh"||xe.sshKey);ae&&ge(ae.id)},[le,h,oe,s,re]);const pe=m.useMemo(()=>le.find(I=>I.id===re)??null,[le,re]),Te=m.useMemo(()=>ho(v),[v]),Ie=m.useMemo(()=>Jt(v)?"":nd(v),[v]),We=m.useMemo(()=>B?fr(Te,B):"",[Te,B]);m.useEffect(()=>{if(!s||!We){M([]),_(null);return}let I=!1;return K(!0),Y(!1),_(null),fs.listLocalDirectory(We).then(ae=>{if(I)return;Y(!1),_(null);const xe=ae.filter(ue=>ue.isDirectory).map(ue=>({name:ue.name,path:Vs(ue.path)})).sort((ue,Le)=>ue.name.localeCompare(Le.name));M(xe)}).catch(ae=>{if(!I){M([]);const xe=Di(ae)?ae.reason:"unknown";_(xe),Y(xe==="not-found")}}).finally(()=>{I||K(!1)}),()=>{I=!0}},[We,U,s]);const Me=m.useMemo(()=>{const I=Ie.toLowerCase(),ae=se||Ie.startsWith(".");return $.filter(xe=>xe.name.toLowerCase().startsWith(I)&&(ae||!xe.name.startsWith(".")))},[Ie,$,se]),ve=m.useMemo(()=>{const I=[];rd(v)&&I.push({type:"up",value:"browse:up",name:"..",path:po(v)});for(const ae of Me){const xe=$t(ae.path);I.push({type:"directory",value:`browse:${ae.path}`,name:ae.name,path:ae.path,disabled:!!(xe&&W.has(xe))})}return I},[W,Me,v]);m.useEffect(()=>{z(0)},[v,ve.length]),m.useEffect(()=>{S([])},[We]);const Be=m.useMemo(()=>he.filter(I=>{const ae=$t(I);return!!(ae&&!W.has(ae))}),[W,he]),Ee=m.useCallback(I=>{S(ae=>ae.includes(I)?ae.filter(xe=>xe!==I):[...ae,I])},[]),Oe=m.useMemo(()=>B?Ln(fr(v,B)):"",[B,v]),ze=$t(Oe),qe=!!(ze&&W.has(ze)),Ke=m.useMemo(()=>Ie?Me.find(I=>I.name===Ie)??null:null,[Ie,Me]),_e=!!(Oe&&!qe&&(O===null||O==="not-found")&&(Jt(v)&&ee||!Jt(v)&&Ie.trim().length>0&&Ke===null)),et=!F&&!V&&O!=="os-permission"&&O!=="invalid-response"&&O!=="unknown"&&(!oe&&Be.length>0||!qe&&!!Oe),dt=et&&te.trim().length>0,je=ve[D]??null,Xe=!!(je&&(je.type==="up"||je.type==="directory")),tt=wn("mod"),Je=!oe&&Be.length>0?n("directoryExplorerDialog.actions.addSelected"):n(qe?"directoryExplorerDialog.actions.alreadyAdded":oe?F?"directoryExplorerDialog.actions.cloning":"directoryExplorerDialog.actions.cloneAndAdd":F?"directoryExplorerDialog.actions.adding":_e?"directoryExplorerDialog.actions.createAndAdd":"directoryExplorerDialog.actions.addProject");m.useLayoutEffect(()=>{const I=A.current;if(!I)return;const ae=()=>q(Math.ceil(I.getBoundingClientRect().width));if(ae(),typeof ResizeObserver>"u")return;const xe=new ResizeObserver(ae);return xe.observe(I),()=>xe.disconnect()},[Je]),m.useLayoutEffect(()=>{const I=P.current;I&&(I.scrollLeft=I.scrollWidth)},[Q,v]),m.useLayoutEffect(()=>{s&&nn(P.current)},[s]),m.useLayoutEffect(()=>{const I=ve[D];I&&N.current.get(I.value)?.scrollIntoView({block:"nearest"})},[D,ve]);const Ce=m.useCallback(()=>{e(!1)},[e]),it=m.useCallback((I,ae)=>{k&&i(!1),c({selectedProjectId:I,directoryOverride:ae}),Ce()},[Ce,k,c,i]),Fe=m.useCallback(async(I,ae)=>{I.stopPropagation();const xe=$t(ae);if(xe&&W.has(xe))return;const ue=await a(ae);if(!ue){Se.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}it(ue.id,ue.path)},[a,W,it,n]),$e=m.useCallback(async I=>{if(F)return;const ae=$t(I),xe=oe?[]:he.filter(Le=>{const T=$t(Le);return!!(T&&!W.has(T))});if(xe.length===0&&(!I||ae&&W.has(ae)))return;let ue=I;R(!0);try{const Le=!oe&&_e&&$t(I)===$t(Oe);if(oe){const X=te.trim();if(!X){Se.error(n("directoryExplorerDialog.toast.cloneUrlRequired"));return}ue=(await fs.cloneRepository({remoteUrl:X,destinationPath:I,gitIdentityId:pe?.id??null})).path}else if(xe.length>0){const X=await l(xe);if(X.length===0){Se.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}Se.success(n("directoryExplorerDialog.toast.addedProjects",{count:X.length})),S([]),Ce();return}else Le&&await fs.createDirectory(I,{asProject:!0});const T=await a(ue);if(!T){Se.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}it(T.id,T.path)}catch(Le){Se.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:Le instanceof Error?Le.message:n("directoryExplorerDialog.toast.unknownError")})}finally{R(!1)}},[a,l,W,te,Ce,oe,F,it,pe?.id,he,_e,Oe,n]),st=m.useCallback(I=>{L(sd(I))},[]),Re=m.useCallback(I=>{L(od(v,I.name))},[v]),Qe=m.useCallback(I=>{if(I){if(I.type==="up"){I.path&&st(I.path);return}Re(I)}},[st,Re]),ut=m.useCallback(async()=>{if(!(!g||V)){ne(!0);try{const I=await j(Oe);if(!I.success||!I.path){I.error&&I.error!=="Directory selection cancelled"&&Se.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:I.error});return}const ae=await p(I.path);if(!ae.success){Se.error(n("directoryExplorerDialog.toast.failedToOpenDirectory"),{description:ae.error||n("directoryExplorerDialog.toast.desktopCouldNotGrantAccess")});return}S([]),await $e(I.path)}catch(I){Se.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:I instanceof Error?I.message:n("directoryExplorerDialog.toast.unknownError")})}finally{ne(!1)}}},[g,$e,V,j,p,n,Oe]),lt=m.useCallback(I=>{if(I.key==="ArrowDown"){I.preventDefault(),z(ae=>Math.min(ve.length-1,ae+1));return}if(I.key==="ArrowUp"){I.preventDefault(),z(ae=>Math.max(0,ae-1));return}if(I.key===" "){if(Jt(v)){I.preventDefault(),je&&je.type==="directory"&&!je.disabled&&Ee(je.path);return}return}if(I.key==="Enter"){if(I.preventDefault(),ad(I)){$e(Oe);return}Xe&&Qe(je);return}I.key==="Backspace"&&v===""&&(I.preventDefault(),Ce())},[Qe,$e,Ce,Xe,je,v,ve.length,Oe,Ee]),mt=t.jsxs("button",{type:"button",onClick:()=>fe(I=>!I),className:"flex flex-shrink-0 items-center gap-2 rounded-lg px-2 py-1 typography-meta text-muted-foreground transition-colors hover:bg-interactive-hover/40",children:[se?t.jsx(E,{name:"checkbox",className:"h-4 w-4 text-primary"}):t.jsx(E,{name:"checkbox-blank",className:"h-4 w-4"}),n("directoryExplorerDialog.toggle.showHidden")]}),y=t.jsxs("div",{className:"px-2.5 py-1.5",children:[oe?t.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[t.jsx(yt,{value:te,onChange:I=>ye(I.target.value),placeholder:n("directoryExplorerDialog.clone.remoteUrlPlaceholder"),className:"min-w-0 flex-1 border-border/60 bg-[var(--surface-elevated)] font-mono typography-ui-label shadow-none",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),t.jsx(mo,{activeProfile:pe,identities:le,onSelect:I=>ge(I.id),isApplying:F,iconOnly:!0})]}):null,t.jsxs("div",{className:"relative",children:[t.jsx(E,{name:"folder-add",className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/80"}),t.jsx(yt,{ref:P,value:v,onChange:I=>L(Vs(I.target.value)),onKeyDown:lt,placeholder:n("directoryExplorerDialog.pathInput.placeholder"),className:"border-transparent bg-transparent pl-9 font-mono typography-ui-label shadow-none focus-visible:ring-0",style:!k&&Q>0?{paddingRight:`${Q+24}px`}:void 0,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),k?null:t.jsx(Ne,{ref:A,variant:"outline",size:"xs",tabIndex:-1,className:"absolute right-1.5 top-1/2 h-7 -translate-y-1/2 gap-1 px-2 typography-meta",disabled:oe?!dt:!et,onMouseDown:I=>I.preventDefault(),onClick:()=>{$e(Oe)},title:Je,children:Je})]})]}),G=t.jsx("div",{className:"relative min-h-0 flex-1 overflow-hidden rounded-xl border border-border/60 bg-[var(--surface-elevated)] shadow-sm",children:t.jsxs("div",{className:"max-h-[min(28rem,58vh)] overflow-y-auto p-2",children:[t.jsx("div",{className:"px-2 pb-1 pt-0.5 typography-meta font-medium uppercase tracking-wide text-muted-foreground/80",children:n("directoryExplorerDialog.browse.directories")}),H?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.loading")}):O&&O!=="not-found"?t.jsxs("div",{className:"flex flex-col items-center gap-3 px-4 py-10 text-center",children:[t.jsx("div",{className:"typography-ui-label text-status-error",children:n(O==="os-permission"?"directoryExplorerDialog.browse.permissionDenied":"directoryExplorerDialog.browse.loadFailed")}),t.jsxs("div",{className:"flex items-center gap-2",children:[O==="os-permission"&&g?t.jsx(Ne,{size:"xs",onClick:()=>{ut()},disabled:V,children:n("directoryExplorerDialog.browse.grantAccess")}):null,t.jsx(Ne,{variant:"outline",size:"xs",onClick:()=>J(I=>I+1),children:n("directoryExplorerDialog.browse.retry")})]})]}):ve.length===0?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.empty")}):t.jsx("div",{className:"space-y-0.5",children:ve.map((I,ae)=>{const xe=ae===D;return t.jsxs("button",{ref:ue=>{ue?N.current.set(I.value,ue):N.current.delete(I.value)},type:"button",onMouseEnter:()=>z(ae),onMouseDown:ue=>ue.preventDefault(),onClick:()=>Qe(I),className:ie("flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",xe&&"bg-interactive-selection text-interactive-selection-foreground",!xe&&"hover:bg-interactive-hover/50",I.type==="directory"&&I.disabled&&"opacity-45"),children:[I.type==="up"?t.jsx(E,{name:"arrow-left-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}):t.jsx(E,{name:"folder-6",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}),t.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:t.jsx("span",{className:"truncate typography-ui-label text-foreground",children:I.name})}),I.type==="directory"&&I.disabled?t.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 typography-meta text-muted-foreground",children:n("directoryExplorerDialog.browse.addedBadge")}):I.type==="directory"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onMouseDown:ue=>ue.stopPropagation(),onClick:ue=>{ue.stopPropagation(),Ee(I.path)},title:n("directoryExplorerDialog.browse.selectForAdd"),"aria-label":n("directoryExplorerDialog.browse.selectForAdd"),"aria-pressed":he.includes(I.path),className:"flex-shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",children:t.jsx(E,{name:he.includes(I.path)?"checkbox":"checkbox-blank",className:"h-4 w-4"})}),t.jsx("button",{type:"button",onMouseDown:ue=>ue.stopPropagation(),onClick:ue=>Fe(ue,I.path),className:"flex-shrink-0 rounded-full p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",title:n("directoryExplorerDialog.browse.quickAdd"),children:t.jsx(E,{name:"add",className:"h-3.5 w-3.5"})})]}):null]},I.value)})})]})}),ke=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[y,G]}),Ue=t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-micro text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(E,{name:"arrow-up-s",className:"h-3.5 w-3.5"}),t.jsx(E,{name:"arrow-down-s",className:"-ml-1 h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.navigate")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(E,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.select")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{children:tt}),t.jsx(E,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.add")]})]}),De=()=>t.jsxs(t.Fragment,{children:[k?null:Ue,t.jsxs("div",{className:ie("flex w-full flex-row justify-end gap-2 sm:w-auto",k&&"justify-stretch"),children:[g?t.jsx(Ne,{variant:"ghost",size:"xs",onClick:ut,disabled:F||V||oe,children:n(V?"directoryExplorerDialog.actions.openingFinder":"directoryExplorerDialog.actions.openInFinder")}):null,t.jsx(Ne,{variant:"ghost",size:"xs",onClick:()=>{Z(I=>!I),S([])},disabled:F||V,className:ie(k&&"flex-1"),children:n(oe?"directoryExplorerDialog.actions.addLocalProject":"directoryExplorerDialog.actions.cloneRepository")}),k?t.jsx(Ne,{size:"xs",onClick:()=>{$e(Oe)},disabled:oe?!dt:!et,className:"flex-1",children:Je}):null]})]});return k?t.jsx(Ss,{open:s,onClose:Ce,title:n("directoryExplorerDialog.title"),className:"h-[88dvh] max-h-[720px]",contentMaxHeightClassName:"flex-1",footer:t.jsx("div",{className:"flex flex-col gap-2",children:De()}),children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[t.jsx("div",{className:"flex justify-end",children:mt}),ke]})}):t.jsx(Is,{open:s,onOpenChange:e,children:t.jsxs(Cs,{className:"flex w-full max-w-xl flex-col gap-0 overflow-hidden p-0 sm:max-h-[80vh]",initialFocus:!1,children:[t.jsx(zs,{className:"px-5 pb-2 pt-5",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx(Ts,{children:n("directoryExplorerDialog.title")}),t.jsx(Ia,{className:"mt-2",children:n("directoryExplorerDialog.description")})]}),mt]})}),t.jsx("div",{className:"min-h-0 flex-1 px-2 pb-0",children:ke}),t.jsx(En,{className:"flex w-full flex-col gap-3 px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:De()})]})})};function mr(s){const{localBranches:e,remoteBranches:n,query:r}=s,o=r.trim();if(!o)return{matching:[],otherLocal:e,otherRemote:n};const a=[...e.map(l=>({label:l,value:l,source:"local"})),...n.map(l=>({label:l,value:`remotes/${l}`,source:"remote"}))],i=pn(a,o,l=>[l.label]),c=new Set(i);return{matching:i,otherLocal:a.filter(l=>l.source==="local"&&!c.has(l)).map(l=>l.label),otherRemote:a.filter(l=>l.source==="remote"&&!c.has(l)).map(l=>l.label)}}const rn="oc:lastWorktreeSourceBranch",ld=({mode:s,sourceBranch:e,linkedPr:n,selectedBranch:r})=>s==="existing-branch"?r||null:n?null:e||null,cd=({branches:s,savedSourceBranch:e,rootBranch:n})=>!!(e&&s.includes(e))&&e?{sourceBranch:e,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&s.includes(n)?n:s.includes("main")?"main":s.includes("master")?"master":s[0]??"",shouldClearSavedSourceBranch:!!e};function dd({open:s,onOpenChange:e,onSelect:n}){const{t:r}=nt(),o=He(S=>S.isMobile),{github:a}=An(),i=Ws(S=>S.status),c=Ws(S=>S.hasChecked),l=He(S=>S.setSettingsDialogOpen),d=He(S=>S.setSettingsPage),u=It(S=>S.getActiveProject()),h=u?.path??null,b=de.useMemo(()=>h&&u?{id:u.id,path:h}:null,[u,h]),[f,x]=de.useState("issues"),[g,j]=de.useState(""),[p,k]=de.useState([]),[P,A]=de.useState([]),[N,C]=de.useState(!1),[w,v]=de.useState(!1),[L,$]=de.useState(null),[M,H]=de.useState(null),[K,ee]=de.useState(null),[Y,O]=de.useState(!1),[_,U]=de.useState(new Map),[J,D]=de.useState(1),[z,F]=de.useState(!1),R=Ca(g,350),V=de.useCallback(async S=>{if(!(!h||!a)&&!(c&&i?.connected===!1)){C(!0),$(null),D(1),F(!1);try{if(f==="issues"&&a.issuesList){const B=await a.issuesList(h,{page:1,query:S});B.connected===!1?($(r("session.githubIntegration.error.notConnected")),k([])):(k(B.issues??[]),D(B.page??1),F(!!B.hasMore))}else if(f==="prs"&&a.prsList){const B=await a.prsList(h,{page:1,query:S});B.connected===!1?($(r("session.githubIntegration.error.notConnected")),A([])):(A(B.prs??[]),D(B.page??1),F(!!B.hasMore))}}catch(B){$(B instanceof Error?B.message:r("session.githubIntegration.error.loadDataFailed"))}finally{C(!1)}}},[h,a,c,i,f,r]);de.useEffect(()=>{if(!s||!h||c&&i?.connected===!1||!a)return;if(!R.trim()){V();return}const S=new AbortController;C(!0),$(null),D(1),F(!1);const B=f==="issues"&&a.issuesList?a.issuesList(h,{page:1,query:R.trim()}):f==="prs"&&a.prsList?a.prsList(h,{page:1,query:R.trim()}):null;if(!B){C(!1);return}return B.then(W=>{S.signal.aborted||("issues"in W?W.connected===!1?($(r("session.githubIntegration.error.notConnected")),k([])):(k(W.issues??[]),D(W.page??1),F(!!W.hasMore)):"prs"in W&&(W.connected===!1?($(r("session.githubIntegration.error.notConnected")),A([])):(A(W.prs??[]),D(W.page??1),F(!!W.hasMore))))}).catch(W=>{S.signal.aborted||$(W instanceof Error?W.message:r("session.githubIntegration.error.loadDataFailed"))}).finally(()=>{S.signal.aborted||C(!1)}),()=>S.abort()},[s,h,a,c,i,f,R,V,r]);const ne=de.useCallback(async()=>{if(!(!h||!a)&&!(N||w)&&z){v(!0);try{const S=J+1;if(f==="issues"&&a.issuesList){const B=R.trim()?await a.issuesList(h,{page:S,query:R.trim()}):await a.issuesList(h,{page:S});B.connected!==!1&&(k(W=>[...W,...B.issues??[]]),D(B.page??S),F(!!B.hasMore))}else if(f==="prs"&&a.prsList){const B=R.trim()?await a.prsList(h,{page:S,query:R.trim()}):await a.prsList(h,{page:S});B.connected!==!1&&(A(W=>[...W,...B.prs??[]]),D(B.page??S),F(!!B.hasMore))}}catch{}finally{v(!1)}}},[h,a,f,J,z,N,w,R]);de.useEffect(()=>{if(!s){x("issues"),j(""),k([]),A([]),H(null),ee(null),O(!1),$(null),U(new Map),D(1),F(!1);return}V()},[s,V]);const Q=de.useCallback(async S=>{if(!(!b||!S)&&!_.has(S))try{const W=(await Br(b,{mode:"new",branchName:S,worktreeName:S})).errors.find(le=>le.code==="branch_in_use");U(le=>new Map(le).set(S,{isValid:!W,error:W?r(W.code==="branch_exists"?"session.githubIntegration.validation.branchAlreadyExists":"session.githubIntegration.validation.branchAlreadyCheckedOut"):null}))}catch{U(B=>new Map(B).set(S,{isValid:!1,error:r("session.githubIntegration.validation.failed")}))}},[b,_,r]);de.useEffect(()=>{!s||f!=="prs"||P.forEach(S=>{S.head&&Q(S.head)})},[s,f,P,Q]);const q=c&&i?.connected===!0,oe=()=>{d("integrations"),l(!0)},Z=S=>{H(S),ee(null)},te=S=>{ee(S),H(null)},ye=()=>{M?n({type:"issue",item:M}):K&&n({type:"pr",item:K,includeDiff:Y}),e(!1)},re=()=>{H(null),ee(null),O(!1)},ge=M||K&&_.get(K.head??"")?.isValid!==!1,se=S=>S.head?_.get(S.head)?.isValid===!1:!0,fe=t.jsx(t.Fragment,{children:q?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative mt-2",children:[t.jsx(E,{name:"search",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(yt,{value:g,onChange:S=>j(S.target.value),placeholder:r(f==="issues"?"session.githubIntegration.search.issuesPlaceholder":"session.githubIntegration.search.prsPlaceholder"),className:"h-8 pl-9"})]}),t.jsx("div",{className:"mt-2 h-[300px] overflow-hidden",children:t.jsxs("div",{className:"h-full overflow-y-auto",children:[N&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(E,{name:"loader-4",className:"h-5 w-5 animate-spin text-muted-foreground"})}),L&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-destructive/10 text-destructive",children:[t.jsx(E,{name:"error-warning",className:"h-4 w-4"}),t.jsx("span",{className:"typography-small",children:L})]})}),!N&&!L&&f==="issues"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[p.length>0?p.map(S=>t.jsx("button",{onClick:()=>Z(S),className:ie("w-full text-left px-2 py-1.5 rounded transition-colors",M?.number===S.number?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"text-muted-foreground shrink-0 typography-micro",children:["#",S.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-2",children:S.title}),S.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info mt-0.5 inline-block",children:[S.sourceRepo.owner,"/",S.sourceRepo.repo]}):null]})]})},`${S.sourceRepo?.owner??""}-${S.sourceRepo?.repo??""}-${S.number}`)):t.jsx("div",{className:"flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground",children:r("session.githubIntegration.empty.noIssuesFound")}),z&&!w&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{ne()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),w&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]}),!N&&!L&&f==="prs"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[P.length>0?P.map(S=>{const B=se(S),W=S.head?_.get(S.head):void 0;return t.jsx("button",{onClick:()=>!B&&te(S),disabled:B,className:ie("w-full text-left px-2 py-1.5 rounded transition-colors",K?.number===S.number?"bg-interactive-selection text-interactive-selection-foreground":B?"opacity-50 cursor-not-allowed":"hover:bg-interactive-hover"),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"text-muted-foreground shrink-0 typography-micro",children:["#",S.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-1",children:S.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[S.head," → ",S.base]}),S.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info",children:[S.sourceRepo.owner,"/",S.sourceRepo.repo]}):null,B&&W?.error&&t.jsx("span",{className:"typography-micro text-destructive",children:W.error})]})]})]})},`${S.sourceRepo?.owner??""}-${S.sourceRepo?.repo??""}-${S.number}`)}):t.jsx("div",{className:"flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground",children:r("session.githubIntegration.empty.noPullRequestsFound")}),z&&!w&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{ne()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),w&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]})]})})]}):t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 gap-4",children:[t.jsx(E,{name:"github",className:"h-12 w-12 text-muted-foreground"}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:r("session.githubIntegration.connect.title")}),t.jsx("p",{className:"typography-small text-muted-foreground mt-1",children:r("session.githubIntegration.connect.description")})]}),t.jsx(Ne,{onClick:oe,size:"sm",children:r("session.githubIntegration.connect.action")})]})}),he=t.jsxs("div",{className:ie("w-full",o?"flex flex-col gap-2":"flex flex-row items-center"),children:[t.jsxs("div",{className:ie("flex items-center gap-4",o?"w-full justify-center order-1":"flex-1"),children:[!o&&(M||K)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 h-8 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate max-w-[150px]",children:M?r("session.githubIntegration.selected.issueNumber",{number:M.number}):r("session.githubIntegration.selected.prNumber",{number:K?.number??""})}),t.jsx("button",{onClick:re,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),f==="prs"&&K&&t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer h-8",children:[t.jsx(Ds,{checked:Y,onChange:S=>O(S),ariaLabel:r("session.githubIntegration.includeDiffAria")}),t.jsx("span",{className:"typography-small text-foreground",children:r("session.githubIntegration.includeDiff")})]})]}),t.jsxs("div",{className:ie("flex gap-2",o?"w-full order-2":"justify-end"),children:[t.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>e(!1),className:ie(o&&"flex-1"),children:r("session.githubIntegration.actions.cancel")}),t.jsx(Ne,{size:"sm",onClick:ye,disabled:!ge,className:ie(o&&"flex-1"),children:r("session.githubIntegration.actions.select")})]})]});return t.jsx(t.Fragment,{children:o?t.jsx(Ss,{open:s,title:r("session.githubIntegration.title"),onClose:()=>e(!1),footer:q?he:void 0,renderHeader:S=>t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2 border-b border-border/40",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:r("session.githubIntegration.title")}),S]}),t.jsx("div",{className:"w-full",children:t.jsx(Ns,{items:[{id:"issues",label:r("session.githubIntegration.tabs.issues"),icon:t.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(E,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:f,onSelect:B=>{x(B),j("")},variant:"active-pill",layoutMode:"fit"})}),(M||K)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate flex-1",children:M?r("session.githubIntegration.selected.issueNumber",{number:M.number}):r("session.githubIntegration.selected.prNumber",{number:K?.number??""})}),t.jsx("button",{onClick:re,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]})]}),children:fe}):t.jsx(Is,{open:s,onOpenChange:e,children:t.jsxs(Cs,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsx(zs,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Ts,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(E,{name:"github",className:"h-5 w-5"}),r("session.githubIntegration.title")]}),t.jsx("div",{className:"w-[220px]",children:t.jsx(Ns,{items:[{id:"issues",label:r("session.githubIntegration.tabs.issues"),icon:t.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(E,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:f,onSelect:S=>{x(S),j("")},variant:"active-pill",layoutMode:"fit"})})]})}),fe,t.jsx(En,{className:"mt-1",children:he})]})})})}const vs=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,""),ud=s=>String(s).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"pr-head",hr=(s,e,n)=>{const r=vs(s.head||"");if(!r)throw new Error("PR head branch is missing");if(e.includes(r))return{existingBranch:r,setUpstream:void 0,upstreamRemote:void 0,upstreamBranch:void 0,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:r};const o=n.find(d=>{const u=d.indexOf("/");return u<=0||u>=d.length-1?!1:d.slice(u+1)===r});if(o){const d=o.indexOf("/"),u=o.slice(0,d);return{existingBranch:`remotes/${o}`,setUpstream:!0,upstreamRemote:u,upstreamBranch:r,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${u}/${r}`}}const a=String(s.headLabel||"").split(":")[0]?.trim(),i=s.headRepo?.owner||a||"pr-head",c=`pr-${ud(i)}`,l=s.headRepo?.cloneUrl||s.headRepo?.sshUrl||"";if(!l)throw new Error("PR head repository URL is unavailable. The fork may have been deleted; push the branch to a reachable repository and try again.");return{existingBranch:`remotes/${c}/${r}`,setUpstream:!0,upstreamRemote:c,upstreamBranch:r,ensureRemoteName:c,ensureRemoteUrl:l,sourceLabel:`${c}/${r}`}},gt=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,"").split("/").join("-").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"").slice(0,80),fd=s=>{const e={repo:s.repo??null,issue:s.issue,comments:s.comments};return`GitHub issue context (JSON)
3
- ${JSON.stringify(e,null,2)}`},md=s=>`GitHub pull request context (JSON)
4
- ${JSON.stringify(s,null,2)}`,hd=s=>{const e={issue:s.issue,comments:s.comments};return`Linear issue context (JSON)
5
- ${JSON.stringify(e,null,2)}`};function Kf({open:s,onOpenChange:e,onWorktreeCreated:n}){const{t:r}=nt(),{github:o,git:a,linear:i}=An(),c=He(y=>y.isMobile),l=Ws(y=>y.status),d=Ws(y=>y.hasChecked),u=Vn(y=>y.status),h=Vn(y=>y.hasChecked),b=It(y=>y.getActiveProject()),f=b?.path??null,x=de.useMemo(()=>f&&b?{id:b.id,path:f}:null,[b,f]),[g,j]=de.useState("new-branch"),[p,k]=de.useState({branchName:"",worktreeName:"",isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1}),[P,A]=de.useState({selectedBranch:"",worktreeName:""}),N=Ta(f),C=Da(f),w=Bn(y=>y.fetchBranches),v=de.useMemo(()=>N?.all?N.all.filter(y=>!y.startsWith("remotes/")).sort():[],[N]),L=de.useMemo(()=>N?.all?N.all.filter(y=>y.startsWith("remotes/")).map(y=>y.replace(/^remotes\//,"")).sort():[],[N]),$=at(y=>y.availableWorktreesByProject),M=de.useMemo(()=>{if(!f)return new Set;const y=$.get(f)??[];return new Set(y.map(G=>G.name))},[$,f]),H=de.useCallback((y=10)=>{for(let G=0;G<y;G++){const ke=Es();if(!M.has(ke))return ke}return`${Es()}-${Date.now().toString(36).slice(-4)}`},[M]),[K,ee]=de.useState(!1),[Y,O]=de.useState(!1),[_,U]=de.useState(!1),[J,D]=de.useState(!1),[z,F]=de.useState(!1),[R,V]=de.useState(!1),[ne,Q]=de.useState(""),[q,oe]=de.useState(""),Z=de.useRef(null),te=de.useRef(null),ye=de.useRef(null),re=de.useRef(null),ge=de.useCallback(y=>{y.stopPropagation()},[]),se=de.useCallback(y=>{let G=y;for(;G&&G!==document.body;){const{overflowY:ke}=window.getComputedStyle(G);if((ke==="auto"||ke==="scroll")&&G.scrollHeight>G.clientHeight)return G;G=G.parentElement}return null},[]),fe=de.useCallback(y=>{y&&(y.scrollTop=0)},[]),he=de.useCallback(y=>{const G=y.current?.querySelector('[data-slot="command-list"]')??null;fe(G)},[fe]),S=de.useCallback(y=>{const G=se(y.current);fe(G)},[se,fe]),B=de.useMemo(()=>mr({localBranches:v,remoteBranches:L,query:ne}),[v,L,ne]),W=de.useMemo(()=>mr({localBranches:v,remoteBranches:L,query:q}),[v,L,q]),le=ne.trim().length>0,pe=q.trim().length>0,Te=B.matching.length>0,Ie=W.matching.length>0,We=!!(f&&a),Me=de.useCallback(()=>{!f||!a||w(f,a)},[f,a,w]);de.useEffect(()=>{!s||!f||!a||N?.all||w(f,a)},[s,f,a,N?.all,w]),de.useEffect(()=>{!_&&!z&&Q("")},[_,z]),de.useEffect(()=>{!J&&!R&&oe("")},[J,R]),de.useEffect(()=>{_&&he(Z),z&&S(ye)},[_,z,ne,he,S]),de.useEffect(()=>{J&&he(te),R&&S(re)},[J,R,q,he,S]);const[ve,Be]=de.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[Ee,Oe]=de.useState(!1),[ze,qe]=de.useState(null),Ke=de.useCallback(()=>{const y=kt.getState(),G=y.getVisibleAgents();if(y.settingsDefaultAgent){const ke=G.find(Ue=>Ue.name===y.settingsDefaultAgent);if(ke)return ke.name}return G.find(ke=>ke.name==="build")?.name||G[0]?.name},[]),_e=de.useCallback(()=>{const y=kt.getState(),G=y.settingsDefaultModel;if(!G)return null;const ke=Er(G);if(!ke)return null;const{providerId:Ue,modelId:De}=ke;return y.getModelMetadata(Ue,De)?{providerID:Ue,modelID:De}:null},[]),et=de.useCallback((y,G)=>{const ke=kt.getState(),Ue=ke.settingsDefaultVariant,De=ke.currentProviderId===y&&ke.currentModelId===G?ke.currentVariant:void 0,xe=ke.providers.find(ue=>ue.id===y)?.models.find(ue=>ue.id===G)?.variants;if(!xe)return Ue||De||void 0;if(Ue&&Object.prototype.hasOwnProperty.call(xe,Ue))return Ue;if(De&&Object.prototype.hasOwnProperty.call(xe,De))return De},[]),dt=de.useCallback(async y=>{const G=kt.getState(),ke=Lr.getState().lastUsedProvider,Ue=_e(),De=Ue?.providerID||G.currentProviderId||ke?.providerID,I=Ue?.modelID||G.currentModelId||ke?.modelID,ae=Ke()||G.currentAgentName||void 0;if(!De||!I){Se.error(r("session.newWorktree.error.noModelSelected"));return}const xe=et(De,I);if(y.linearIssue){if(!i?.issueGet)return;const ue=await i.issueGet(y.linearIssue.identifier);if(ue.connected===!1||!ue.issue)throw new Error("Failed to load issue context");const Le=ue.issue,T=Le.comments??[],X=Le.assignee?.displayName||Le.assignee?.name,me=await Vt("linear.issue.review.visible",{identifier:Le.identifier}),Ge=await Vt("linear.issue.review.instructions"),be=hd({issue:Le,comments:T});Pa(i,{sessionId:y.sessionId,issueIdentifier:Le.identifier}),await at.getState().sendMessage(me,De,I,ae,void 0,void 0,[{text:Ge,synthetic:!0},{text:be,synthetic:!0}],xe,void 0,{sessionId:y.sessionId,directory:y.directory}),Qs(y.sessionId,y.directory,Ra({identifier:Le.identifier,title:Le.title,url:Le.url,author:X?{login:X,avatarUrl:Le.assignee?.avatarUrl||void 0}:y.linearIssue.author,linkedAt:Date.now()}),!0).catch(()=>{}),Se.success(r("session.newWorktree.toast.sessionFromIssue"));return}if(!(!f||!o)){if(y.issue){if(!o.issueGet||!o.issueComments)return;const ue=await o.issueGet(f,y.issue.number,{sourceRepo:y.issue.sourceRepo??null});if(ue.connected===!1||!ue.repo||!ue.issue)throw new Error("Failed to load issue context");const Le=await o.issueComments(f,y.issue.number,{sourceRepo:y.issue.sourceRepo??null});if(Le.connected===!1)throw new Error("Failed to load issue comments");const T=await Vt("github.issue.review.visible",{issue_number:String(y.issue.number)}),X=await Vt("github.issue.review.instructions"),me=fd({repo:ue.repo,issue:ue.issue,comments:Le.comments??[]});await at.getState().sendMessage(T,De,I,ae,void 0,void 0,[{text:X,synthetic:!0},{text:me,synthetic:!0}],xe,void 0,{sessionId:y.sessionId}),Qs(y.sessionId,y.directory,zn({url:ue.issue.url,number:ue.issue.number,title:ue.issue.title,kind:"issue",author:ue.issue.author,linkedAt:Date.now()}),!0).catch(()=>{}),Se.success(r("session.newWorktree.toast.sessionFromIssue"));return}if(y.pr){if(!o.prContext)return;const ue=await o.prContext(f,y.pr.number,{sourceRepo:y.pr.sourceRepo??null,includeDiff:y.includeDiff,includeCheckDetails:!1});if(ue.connected===!1||!ue.repo||!ue.pr)throw new Error("Failed to load PR context");const Le=await Vt("github.pr.review.visible",{pr_number:String(y.pr.number)}),T=await Vt("github.pr.review.instructions"),X=md(ue);await at.getState().sendMessage(Le,De,I,ae,void 0,void 0,[{text:T,synthetic:!0},{text:X,synthetic:!0}],xe,void 0,{sessionId:y.sessionId}),Qs(y.sessionId,y.directory,zn({url:ue.pr.url,number:ue.pr.number,title:ue.pr.title,kind:"pull",author:ue.pr.author,linkedAt:Date.now()}),!0).catch(()=>{}),Se.success(r("session.newWorktree.toast.sessionFromPr"))}}},[o,i,f,Ke,_e,et,r]),je=g==="new-branch"?p:P;de.useEffect(()=>{if(!s||!N?.all||!f||p.sourceBranch)return;const y=p.sourceBranch;let G=!1;return(async()=>{try{const Ue=await Aa(f).catch(()=>null);if(G)return;const De=localStorage.getItem(rn),{sourceBranch:I,shouldClearSavedSourceBranch:ae}=cd({branches:N.all,savedSourceBranch:De,rootBranch:Ue});if(ae&&localStorage.removeItem(rn),G||y)return;I&&k(xe=>({...xe,sourceBranch:I}))}catch{}})(),()=>{G=!0}},[s,N?.all,f,p.sourceBranch]),de.useLayoutEffect(()=>{if(!s)return;j("new-branch"),A({selectedBranch:"",worktreeName:""}),U(!1),D(!1),F(!1),V(!1),Q(""),oe(""),Be({isValidating:!1,branchError:null,worktreeError:null,touched:!1});const y=H();k({branchName:y,worktreeName:y,isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1})},[s,H]),de.useEffect(()=>{if(g!=="new-branch"||!p.isSyncingWorktreeName)return;const y=vs(p.branchName),G=gt(y);k(ke=>({...ke,worktreeName:G}))},[g,p.branchName,p.isSyncingWorktreeName]);const Xe=de.useCallback(async()=>{if(!x||!ve.touched||Ee)return;ze&&ze.abort();const y=new AbortController;qe(y),Be(G=>({...G,isValidating:!0}));try{const G=g==="new-branch"?p.branchName:P.selectedBranch,ke=je.worktreeName,Ue=vs(G),De=gt(ke);let I=null,ae=null;if(Ue||(I=r("session.newWorktree.error.branchNameRequired")),De||(ae=r("session.newWorktree.error.worktreeDirectoryRequired")),Ue&&De){const xe=g==="new-branch"?p.linkedPr:null,ue=xe?hr(xe,v,L):null,Le=await Br(x,{mode:g==="existing-branch"||ue?"existing":"new",branchName:Ue,worktreeName:De,existingBranch:ue?.existingBranch??(g==="existing-branch"?Ue:void 0),...ue?.ensureRemoteName?{ensureRemoteName:ue.ensureRemoteName}:{},...ue?.ensureRemoteUrl?{ensureRemoteUrl:ue.ensureRemoteUrl}:{}});if(y.signal.aborted)return;Le.ok||Le.errors.forEach(T=>{if(T.code==="worktree_exists"){ae=ae??T.message;return}T.code.startsWith("branch_")&&(I=I??T.message)})}y.signal.aborted||Be(xe=>({...xe,isValidating:!1,branchError:I,worktreeError:ae}))}catch{y.signal.aborted||Be(G=>({...G,isValidating:!1}))}},[x,g,p.branchName,p.linkedPr,P.selectedBranch,je.worktreeName,v,L,ve.touched,ze,Ee,r]),tt=g==="new-branch"?p.branchName:P.selectedBranch;de.useEffect(()=>{if(!s||!x||!ve.touched||Ee)return;const y=setTimeout(()=>{Xe()},300);return()=>clearTimeout(y)},[je.worktreeName,tt,s,x,Xe,ve.touched,Ee]);const Je=async()=>{if(!x||!f){Se.error(r("session.newWorktree.error.noActiveProject"));return}Be(De=>({...De,touched:!0}));const y=g==="new-branch"?p.branchName:P.selectedBranch,G=je.worktreeName,ke=vs(y),Ue=gt(G);if(!ke){Se.error(r("session.newWorktree.error.branchNameRequired"));return}if(!Ue){Se.error(r("session.newWorktree.error.worktreeDirectoryRequired"));return}ze&&(ze.abort(),qe(null)),Be(De=>({...De,isValidating:!1,branchError:null,worktreeError:null})),Oe(!0);try{const De=g==="new-branch"?p.linkedPr:null,I=g==="new-branch"?p.linkedIssue:null,ae=g==="new-branch"?p.linkedLinearIssue:null,xe=g==="new-branch"?p.linkedPr:null,ue=g==="new-branch"?p.includePrDiff:!1,Le=!!(I||xe||ae),T=await Cr(x),X=p.sourceBranch;let me="";const Ge=(()=>{if(De){const ce=hr(De,v,L);return me=ce.sourceLabel,{preferredName:ke||Ue,mode:"existing",branchName:ke,worktreeName:Ue,existingBranch:ce.existingBranch,setupCommands:T,setUpstream:ce.setUpstream,upstreamRemote:ce.upstreamRemote,upstreamBranch:ce.upstreamBranch,returnAfterDirectoryCreated:!0,...ce.ensureRemoteName?{ensureRemoteName:ce.ensureRemoteName}:{},...ce.ensureRemoteUrl?{ensureRemoteUrl:ce.ensureRemoteUrl}:{}}}return me=g==="new-branch"?X:"",{preferredName:ke||Ue,mode:g==="existing-branch"?"existing":"new",branchName:g==="existing-branch"?void 0:ke,worktreeName:Ue,existingBranch:g==="existing-branch"?ke:void 0,setupCommands:T,returnAfterDirectoryCreated:!0,...X&&g==="new-branch"?{startRef:X}:{}}})(),be=await Ba(f,Ge),Ae=await La(x,be);let rt=null;if(Le){await Tr(x)&&await Ma(Ae.path);const ce=ae?`${ae.identifier} ${ae.title}`.trim():I?`#${I.number} ${I.title}`.trim():xe?`#${xe.number} ${xe.title}`.trim():r("session.newWorktree.newSessionTitle"),Ye=await Fa(ce,Ae.path,null);if(!Ye?.id)throw new Error("Failed to create session");rt=Ye.id,n?.(Ae.path,{sessionId:rt}),e(!1),Oe(!1),Oa(Ye.id,ce).catch(()=>{});try{at.getState().initializeNewAiWorkerSession(Ye.id,kt.getState().agents)}catch{}}else e(!1),Oe(!1);const Pe=ld({mode:g,sourceBranch:p.sourceBranch,linkedPr:!!p.linkedPr,selectedBranch:P.selectedBranch});Pe&&localStorage.setItem(rn,Pe),Se.success(r("session.newWorktree.toast.worktreeCreated"),{description:r("session.newWorktree.toast.worktreeCreatedDescription",{target:`${Ae.branch||Ae.name}${me?` ${r("session.newWorktree.fromSource",{source:me})}`:""}`})}),rt?dt({sessionId:rt,directory:Ae.path,issue:I,pr:xe,linearIssue:ae,includeDiff:ue}).catch(ce=>{const Ye=r(ae?"session.newWorktree.error.sendLinearContextFailed":"session.newWorktree.error.sendGitHubContextFailed"),ct=ce instanceof Error?ce.message:Ye;Se.error(Ye,{description:ct})}):n?.(Ae.path)}catch(De){const I=De instanceof Error?De.message:r("session.newWorktree.error.createWorktreeFailed");Se.error(r("session.newWorktree.error.createWorktreeFailed"),{description:I})}finally{Oe(!1)}},Ce=y=>{j(y),Be(G=>({...G,touched:!1,branchError:null,worktreeError:null}))},it=y=>{if(!y){k(G=>({...G,linkedIssue:null,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1,branchName:""}));return}if(y.type==="issue"){const G=y.item,ke=`issue-${G.number}-${Es()}`;k(Ue=>({...Ue,linkedIssue:G,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1,branchName:ke,worktreeName:gt(ke),isSyncingWorktreeName:!0}))}else if(y.type==="pr"){const G=y.item;k(ke=>({...ke,linkedPr:G,linkedIssue:null,linkedLinearIssue:null,includePrDiff:y.includeDiff??!1,branchName:G.head,worktreeName:gt(G.head),isSyncingWorktreeName:!0}))}},Fe=y=>{const G=`issue-${y.identifier}-${Es()}`;k(ke=>({...ke,linkedLinearIssue:{identifier:y.identifier,title:y.title,url:y.url,author:y.author},linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:G,worktreeName:gt(G),isSyncingWorktreeName:!0}))},$e=d&&l?.connected===!0,st=!!i&&h&&u?.connected===!0,Qe=(g==="existing-branch"?!!P.selectedBranch&&!!P.worktreeName&&!ve.branchError&&!ve.worktreeError:!!vs(p.branchName)&&!!p.worktreeName&&!ve.branchError&&!ve.worktreeError)&&!Ee,ut=()=>{k(y=>({...y,linkedIssue:null,linkedPr:null,linkedLinearIssue:null,branchName:"",includePrDiff:!1,isSyncingWorktreeName:!0}))},lt=g==="new-branch"&&($e||st)?t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[$e&&t.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>ee(!0),className:"h-8 w-8 px-0",title:r("session.newWorktree.actions.startFromGitHubIssuePr"),"aria-label":r("session.newWorktree.actions.startFromGitHubIssuePr"),children:t.jsx(E,{name:"github",className:"size-4 text-status-success"})}),st&&t.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>O(!0),className:"h-8 w-8 px-0",title:r("session.newWorktree.actions.startFromLinearIssue"),"aria-label":r("session.newWorktree.actions.startFromLinearIssue"),children:t.jsx(E,{name:"linear",className:"size-4"})})]}):null,mt=t.jsxs("div",{className:ie("flex gap-2",c?"flex-col w-full":"flex-row items-center"),children:[t.jsx("div",{className:ie("flex items-center gap-1.5 text-destructive",c?"w-full justify-center order-first":"mr-auto"),children:ve.touched&&(ve.branchError||ve.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(E,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:ve.branchError||ve.worktreeError})]})}),t.jsxs("div",{className:ie("flex gap-2",c&&"w-full"),children:[t.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Ee,className:ie(c&&"flex-1"),children:r("session.newWorktree.actions.cancel")}),t.jsxs(Ne,{size:"sm",onClick:Je,disabled:!Qe||Ee,className:ie("gap-1.5",c&&"flex-1"),children:[Ee&&t.jsx(E,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(Ee?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]});return t.jsxs(t.Fragment,{children:[c?t.jsxs(Ss,{open:s,title:r("session.newWorktree.title"),onClose:()=>e(!1),footer:mt,children:[t.jsx("div",{className:"w-full mb-4",children:t.jsx(Ns,{items:[{id:"new-branch",label:r("session.newWorktree.mode.newBranch"),icon:t.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(E,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:g,onSelect:y=>Ce(y),variant:"active-pill",layoutMode:"fit",className:"w-full"})}),t.jsxs("div",{className:"space-y-6",children:[g==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>F(!0),className:"flex-1 justify-between h-9",children:[t.jsx("span",{className:P.selectedBranch?"text-foreground":"text-muted-foreground",children:P.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(E,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:Me,disabled:!We||C,title:r("session.newWorktree.fetchBranches"),children:C?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"refresh",className:"size-4"})})]}),t.jsx(Ss,{open:z,title:r("session.newWorktree.selectBranch"),onClose:()=>F(!1),children:t.jsxs("div",{className:"space-y-4",ref:ye,children:[t.jsx(yt,{value:ne,onChange:y=>Q(y.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),C?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):v.length===0&&L.length===0?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noBranchesFound")}):t.jsxs("div",{className:"space-y-4",children:[le&&Te&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:B.matching.map(y=>t.jsx("button",{onClick:()=>{A(G=>({...G,selectedBranch:y.value,worktreeName:gt(y.label)})),Be(G=>({...G,touched:!0})),F(!1)},className:ie("w-full text-left px-3 py-2.5 rounded-md transition-colors",P.selectedBranch===y.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y.label})},`${y.source}-${y.value}`))})]}),le&&!Te&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!le&&B.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:B.otherLocal.map(y=>t.jsx("button",{onClick:()=>{A(G=>({...G,selectedBranch:y,worktreeName:gt(y)})),Be(G=>({...G,touched:!0})),F(!1)},className:ie("w-full text-left px-3 py-2.5 rounded-md transition-colors",P.selectedBranch===y?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y})},y))})]}),!le&&B.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:B.otherRemote.map(y=>t.jsx("button",{onClick:()=>{A(G=>({...G,selectedBranch:`remotes/${y}`,worktreeName:gt(y)})),Be(G=>({...G,touched:!0})),F(!1)},className:ie("w-full text-left px-3 py-2.5 rounded-md transition-colors",P.selectedBranch===`remotes/${y}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y})},`remotes/${y}`))})]})]})]})})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold shrink-0",children:r("session.newWorktree.branchName")}),lt]}),t.jsx(yt,{value:p.branchName,onChange:y=>{k(G=>({...G,branchName:y.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null,linkedLinearIssue:null}))},onBlur:()=>Be(y=>({...y,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!p.linkedPr,className:ie("h-8",ve.touched&&ve.branchError&&"border-destructive",p.linkedPr&&"bg-muted text-muted-foreground")}),p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:p.linkedPr.head})})]}),p.linkedIssue&&!p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:p.linkedIssue.number,title:p.linkedIssue.title})})]}),p.linkedLinearIssue&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromLinearIssue",{identifier:p.linkedLinearIssue.identifier,title:p.linkedLinearIssue.title})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold",children:r("session.newWorktree.worktreeDirectory")}),g!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const y=gt(g==="new-branch"?p.branchName:"");k(G=>({...G,worktreeName:y,isSyncingWorktreeName:!0}))},disabled:!p.branchName||p.worktreeName===gt(p.branchName),className:ie("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",p.worktreeName===gt(p.branchName)||!p.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:r("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(E,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:r("session.newWorktree.actions.reset")})]})]}),t.jsx(yt,{value:je.worktreeName,onChange:y=>{g==="new-branch"?k(G=>({...G,worktreeName:y.target.value,isSyncingWorktreeName:!1})):A(G=>({...G,worktreeName:y.target.value}))},onBlur:()=>Be(y=>({...y,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:ie("h-8",ve.touched&&ve.worktreeError&&"border-destructive")})]}),g==="new-branch"&&!p.linkedPr&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.sourceBranch")}),t.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>V(!0),className:"w-full justify-between h-9",children:[t.jsx("span",{className:p.sourceBranch?"text-foreground":"text-muted-foreground",children:p.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(E,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),p.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:p.sourceBranch})}),t.jsx(Ss,{open:R,title:r("session.newWorktree.selectSourceBranch"),onClose:()=>V(!1),children:t.jsxs("div",{className:"space-y-4",ref:re,children:[t.jsx(yt,{value:q,onChange:y=>oe(y.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),C?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):v.length===0&&L.length===0?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noBranchesFound")}):t.jsxs("div",{className:"space-y-4",children:[pe&&Ie&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:W.matching.map(y=>t.jsx("button",{onClick:()=>{k(G=>({...G,sourceBranch:y.value})),V(!1)},className:ie("w-full text-left px-3 py-2.5 rounded-md transition-colors",p.sourceBranch===y.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y.label})},`${y.source}-${y.value}`))})]}),pe&&!Ie&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!pe&&W.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:W.otherLocal.map(y=>t.jsx("button",{onClick:()=>{k(G=>({...G,sourceBranch:y})),V(!1)},className:ie("w-full text-left px-3 py-2.5 rounded-md transition-colors",p.sourceBranch===y?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y})},y))})]}),!pe&&W.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:W.otherRemote.map(y=>t.jsx("button",{onClick:()=>{k(G=>({...G,sourceBranch:`remotes/${y}`})),V(!1)},className:ie("w-full text-left px-3 py-2.5 rounded-md transition-colors",p.sourceBranch===`remotes/${y}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y})},`remotes/${y}`))})]})]})]})})]}),(p.linkedIssue||p.linkedPr||p.linkedLinearIssue)&&g==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(E,{name:p.linkedLinearIssue?"linear":"github",className:ie("h-3.5 w-3.5 shrink-0",p.linkedLinearIssue?"text-foreground":"text-status-success")}),p.linkedLinearIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:p.linkedLinearIssue.identifier}),p.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:p.linkedIssue.number})}),p.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:p.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:p.linkedLinearIssue?.title||p.linkedIssue?.title||p.linkedPr?.title}),t.jsx("a",{href:p.linkedLinearIssue?.url||p.linkedIssue?.url||p.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:y=>y.stopPropagation(),children:t.jsx(E,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:ut,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 pl-5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[p.linkedPr.head," → ",p.linkedPr.base]}),p.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:r("session.newWorktree.includeDiffBadge")})]})]})]})]}):t.jsx(Is,{open:s,onOpenChange:e,children:t.jsxs(Cs,{className:"max-w-lg max-h-[80vh] flex flex-col",children:[t.jsx(zs,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Ts,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(E,{name:"git-branch",className:"h-5 w-5"}),r("session.newWorktree.title")]}),t.jsx("div",{className:"w-[280px] shrink-0",children:t.jsx(Ns,{items:[{id:"new-branch",label:r("session.newWorktree.mode.newBranch"),icon:t.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(E,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:g,onSelect:y=>Ce(y),variant:"active-pill",layoutMode:"fit",className:"w-full"})})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto mt-2 space-y-6",children:[g==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(zt,{open:_,onOpenChange:U,children:[t.jsx(Gt,{asChild:!0,children:t.jsxs("button",{type:"button",className:ie(Gn({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:ie("truncate",P.selectedBranch?"text-foreground":"text-muted-foreground"),children:P.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(Ht,{align:"start",sideOffset:6,portalToBody:!0,className:"w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",ref:Z,children:t.jsxs(gn,{shouldFilter:!1,children:[t.jsx(xn,{placeholder:r("session.newWorktree.searchBranches"),value:ne,onValueChange:Q,onKeyDown:ge}),t.jsx(bn,{disableHorizontal:!0,children:C?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):v.length===0&&L.length===0?t.jsx(yn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[le&&Te&&t.jsx(Ut,{heading:r("session.newWorktree.matchingBranches"),children:B.matching.map(y=>t.jsx(Pt,{value:y.value,onSelect:()=>{A(G=>({...G,selectedBranch:y.value,worktreeName:gt(y.label)})),Be(G=>({...G,touched:!0})),U(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y.label})},`${y.source}-${y.value}`))}),le&&!Te&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!le&&B.otherLocal.length>0&&t.jsx(t.Fragment,{children:t.jsx(Ut,{heading:r("session.newWorktree.localBranches"),children:B.otherLocal.map(y=>t.jsx(Pt,{value:y,onSelect:()=>{A(G=>({...G,selectedBranch:y,worktreeName:gt(y)})),Be(G=>({...G,touched:!0})),U(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y})},`local-${y}`))})}),!le&&B.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[B.otherLocal.length>0&&t.jsx(Us,{}),t.jsx(Ut,{heading:r("session.newWorktree.remoteBranches"),children:B.otherRemote.map(y=>t.jsx(Pt,{value:`remotes/${y}`,onSelect:()=>{A(G=>({...G,selectedBranch:`remotes/${y}`,worktreeName:gt(y)})),Be(G=>({...G,touched:!0})),U(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y})},`remote-${y}`))})]})]})})]})})]}),t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:Me,disabled:!We||C,title:r("session.newWorktree.fetchBranches"),children:C?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"refresh",className:"size-4"})})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold shrink-0",children:r("session.newWorktree.branchName")}),lt]}),t.jsx(yt,{value:p.branchName,onChange:y=>{k(G=>({...G,branchName:y.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null,linkedLinearIssue:null}))},onBlur:()=>Be(y=>({...y,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!p.linkedPr,className:ie("h-8",ve.touched&&ve.branchError&&"border-destructive",p.linkedPr&&"bg-muted text-muted-foreground")}),p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:p.linkedPr.head})})]}),p.linkedIssue&&!p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:p.linkedIssue.number,title:p.linkedIssue.title})})]}),p.linkedLinearIssue&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromLinearIssue",{identifier:p.linkedLinearIssue.identifier,title:p.linkedLinearIssue.title})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold",children:r("session.newWorktree.worktreeDirectory")}),g!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const y=gt(g==="new-branch"?p.branchName:"");k(G=>({...G,worktreeName:y,isSyncingWorktreeName:!0}))},disabled:!p.branchName||p.worktreeName===gt(p.branchName),className:ie("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",p.worktreeName===gt(p.branchName)||!p.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:r("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(E,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:r("session.newWorktree.actions.reset")})]})]}),t.jsx(yt,{value:je.worktreeName,onChange:y=>{g==="new-branch"?k(G=>({...G,worktreeName:y.target.value,isSyncingWorktreeName:!1})):A(G=>({...G,worktreeName:y.target.value}))},onBlur:()=>Be(y=>({...y,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:ie("h-8",ve.touched&&ve.worktreeError&&"border-destructive")})]}),g==="new-branch"&&!p.linkedPr&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.sourceBranch")}),t.jsxs(zt,{open:J,onOpenChange:D,children:[t.jsx(Gt,{asChild:!0,children:t.jsxs("button",{type:"button",className:ie(Gn({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:ie("truncate",p.sourceBranch?"text-foreground":"text-muted-foreground"),children:p.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(Ht,{align:"start",portalToBody:!0,className:"w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",ref:te,children:t.jsxs(gn,{shouldFilter:!1,children:[t.jsx(xn,{placeholder:r("session.newWorktree.searchBranches"),value:q,onValueChange:oe,onKeyDown:ge}),t.jsx(bn,{disableHorizontal:!0,children:C?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):v.length===0&&L.length===0?t.jsx(yn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[pe&&Ie&&t.jsx(Ut,{heading:r("session.newWorktree.matchingBranches"),children:W.matching.map(y=>t.jsx(Pt,{value:y.value,onSelect:()=>{k(G=>({...G,sourceBranch:y.value})),D(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y.label})},`${y.source}-${y.value}`))}),pe&&!Ie&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!pe&&W.otherLocal.length>0&&t.jsx(t.Fragment,{children:t.jsx(Ut,{heading:r("session.newWorktree.localBranches"),children:W.otherLocal.map(y=>t.jsx(Pt,{value:y,onSelect:()=>{k(G=>({...G,sourceBranch:y})),D(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y})},`local-${y}`))})}),!pe&&W.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[W.otherLocal.length>0&&t.jsx(Us,{}),t.jsx(Ut,{heading:r("session.newWorktree.remoteBranches"),children:W.otherRemote.map(y=>t.jsx(Pt,{value:`remotes/${y}`,onSelect:()=>{k(G=>({...G,sourceBranch:`remotes/${y}`})),D(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y})},`remote-${y}`))})]})]})})]})})]}),p.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:p.sourceBranch})})]}),(p.linkedIssue||p.linkedPr||p.linkedLinearIssue)&&g==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(E,{name:p.linkedLinearIssue?"linear":"github",className:ie("h-3.5 w-3.5 shrink-0",p.linkedLinearIssue?"text-foreground":"text-status-success")}),p.linkedLinearIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:p.linkedLinearIssue.identifier}),p.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:p.linkedIssue.number})}),p.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:p.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:p.linkedLinearIssue?.title||p.linkedIssue?.title||p.linkedPr?.title}),t.jsx("a",{href:p.linkedLinearIssue?.url||p.linkedIssue?.url||p.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:y=>y.stopPropagation(),children:t.jsx(E,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:ut,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 pl-5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[p.linkedPr.head," → ",p.linkedPr.base]}),p.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:r("session.newWorktree.includeDiffBadge")})]})]})]}),t.jsxs(En,{className:"mt-1 flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center gap-1.5 text-destructive",children:ve.touched&&(ve.branchError||ve.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(E,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:ve.branchError||ve.worktreeError})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Ee,children:r("session.newWorktree.actions.cancel")}),t.jsxs(Ne,{size:"sm",onClick:Je,disabled:!Qe||Ee,className:"gap-1.5",children:[Ee&&t.jsx(E,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(Ee?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]})]})}),t.jsx(dd,{open:K,onOpenChange:ee,onSelect:it}),t.jsx(Ea,{open:Y,onOpenChange:O,mode:"select",onSelect:Fe})]})}const pd=2880*60*1e3,gd=s=>!!s.parentID,xd=s=>!!s.time?.archived,bd=s=>{const e=s.time?.updated,n=s.time?.created;return typeof e=="number"&&Number.isFinite(e)?e:typeof n=="number"&&Number.isFinite(n)?n:0},yd=(s,e,n=Date.now())=>{const r=n-pd;return s.filter(o=>xd(o)||gd(o)?!1:e.has(o.id)||bd(o)>=r)},qf=({sessions:s,getSessionLocation:e,getSessionNode:n,query:r})=>[{key:"active-now",items:s.flatMap(o=>{const a=typeof o.title=="string"?o.title.toLowerCase():"";if(r&&!a.includes(r))return[];const i=e(o.id);return[{node:n?.(o)??{session:o,children:[],worktree:null},projectId:i?.projectId??null,groupDirectory:i?.groupDirectory??o.directory??null,secondaryMeta:i?{projectLabel:i.projectLabel,branchLabel:i.branchLabel}:null}]})}],go=s=>s.parentID??null,wd=(s,e)=>{const n=[],r=[];for(const o of s)if(!$a(o)){if(Ua(o.directory)){if(e)continue;r.push(o);continue}n.push(o)}return{projectSessions:n,chatSessions:r}},vd=new Set,Sd=(s,e,n)=>{if(s.time?.archived)return!0;const r=jn(Ar(s))?.toLowerCase();return!r||e.size===0?!n:e.has(r)},jd=(s,e)=>{const n=[...s],r=new Set(s.map(o=>o.id));for(const o of e)r.has(o.id)||(r.add(o.id),n.push(o));return n},kd=(s,e)=>{const n=[],r=new Set([e]),o=a=>{for(const i of s.get(a)??[])r.has(i.id)||(r.add(i.id),n.push(i.id),o(i.id))};return o(e),n},Nd=({globalActiveSessions:s,liveSessions:e,knownDirectories:n,isVSCode:r,globalStructure:o})=>{Mr("sidebarStructureBuilds");const i=jd(s??[],e),c=wd(i,r),l=c.projectSessions.filter(g=>Sd(g,n,r)),d=[...l,...c.chatSessions],u=new Map(d.map(g=>[g.id,g])),h=new Set(l.map(g=>g.id)),b=o?.activeRootIds??[],f=new Set(b),x=[...b.flatMap(g=>{if(!h.has(g))return[];const j=u.get(g);return j?[j]:[]}),...l.filter(g=>!f.has(g.id)&&!go(g))];return{chatSessionIds:new Set(c.chatSessions.map(g=>g.id)),projectSessions:l,rootSessions:x,sessionById:u,sessions:d,hierarchy:o?{rootIds:o.activeRootIds,childrenByParentId:o.activeChildrenByParentId}:void 0}},Id=(s,e,n)=>{const r=Fr(s.sessions,e,n,s.hierarchy),o=new Map;for(const a of r){const i=go(a);if(!i)continue;const c=o.get(i)??[];c.push(a),o.set(i,c)}return{chatSessions:r.filter(a=>s.chatSessionIds.has(a.id)),childrenMap:o,orderedSessions:r}},Yf=s=>{const e=Ve.c(33),{knownDirectories:n,isVSCode:r,isVisible:o}=s,a=Yt(Cd),i=Yt(Td),c=Yt(Dd),l=Yt(Pd),d=Wa(),u=_a(Rd);let h;e[0]!==o?(h=M=>o?M.rankById:Ga,e[0]=o,e[1]=h):h=e[1];const b=Va(h);let f;e[2]!==a||e[3]!==i||e[4]!==r||e[5]!==n||e[6]!==d?(f=Nd({globalActiveSessions:a,globalStructure:i,liveSessions:d,knownDirectories:n,isVSCode:r}),e[2]=a,e[3]=i,e[4]=r,e[5]=n,e[6]=d,e[7]=f):f=e[7];const x=f;let g;e[8]!==u||e[9]!==b||e[10]!==x?(g=Id(x,u,b),e[8]=u,e[9]=b,e[10]=x,e[11]=g):g=e[11];const j=g,{chatSessions:p,orderedSessions:k}=j,P=x.projectSessions;let A;e[12]!==c||e[13]!==x.sessions?(A=new Map([...x.sessions,...c].map(Ed)),e[12]=c,e[13]=x.sessions,e[14]=A):A=e[14];const N=A;let C;if(e[15]!==c||e[16]!==j.childrenMap){C=new Map(j.childrenMap);for(const M of c){const H=M.parentID;if(!H)continue;const K=C.get(H)??[];K.push(M),C.set(H,K)}e[15]=c,e[16]=j.childrenMap,e[17]=C}else C=e[17];const w=C;let v;e[18]!==w||e[19]!==N?(v=(M,H)=>kd(w,M).filter(K=>H.includeArchived||!N.get(K)?.time?.archived),e[18]=w,e[19]=N,e[20]=v):v=e[20];const L=v;let $;return e[21]!==c||e[22]!==p||e[23]!==w||e[24]!==L||e[25]!==l||e[26]!==d||e[27]!==k||e[28]!==u||e[29]!==b||e[30]!==P||e[31]!==x.rootSessions?($={archivedSessions:c,childrenMap:w,chatSessions:p,getDescendantIds:L,hasAuthoritativeGlobalSessions:l,liveSessions:d,orderedSessions:k,pinnedSessionIds:u,sessionOrderRanks:b,sessions:P,rootSessions:x.rootSessions},e[21]=c,e[22]=p,e[23]=w,e[24]=L,e[25]=l,e[26]=d,e[27]=k,e[28]=u,e[29]=b,e[30]=P,e[31]=x.rootSessions,e[32]=$):$=e[32],$},Jf=s=>{const e=Ve.c(9),{enabled:n,isVSCode:r,pinnedSessionIds:o,sessionOrderRanks:a,sessions:i}=s;let c;e[0]!==n||e[1]!==r?(c=u=>n&&!r?u.activeSessionIds:vd,e[0]=n,e[1]=r,e[2]=c):c=e[2];const l=za(c);let d;e:{if(!n||r){let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=[],e[3]=h):h=e[3],d=h;break e}Mr("recentCandidatesVisited",i.length);let u;e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==i?(u=Fr(yd(i,l),o,a),e[4]=l,e[5]=o,e[6]=a,e[7]=i,e[8]=u):u=e[8],d=u}return d};function Cd(s){return s.activeSessions}function Td(s){return s.structure}function Dd(s){return s.archivedSessions}function Pd(s){return s.status==="ready"}function Rd(s){return s.ids}function Ed(s){return[s.id,s]}const Fn=(s,e)=>s==="global"?"global":`project:${e??""}`,xo=(s,e)=>s.createdAt>e?"new":s.updatedAt>e?"changed":null,pr=(s,e)=>s.reduce((n,r)=>xo(r,e)?n+1:n,0),bo=s=>{const e=Ve.c(29),{expanded:n,onToggleExpanded:r,header:o,children:a,actions:i,footer:c,expandLabel:l}=s,{t:d}=nt(),u=!n&&"cursor-pointer hover:border-[var(--interactive-border)] hover:bg-interactive-hover/30";let h;e[0]!==u?(h=ie("flex flex-col gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 py-1.5",u),e[0]=u,e[1]=h):h=e[1];const b=n?void 0:r;let f;e[2]!==n||e[3]!==r?(f=n?void 0:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),r())},e[2]=n,e[3]=r,e[4]=f):f=e[4];const x=n?void 0:"button",g=n?void 0:0,j=n?void 0:l;let p;e[5]!==a||e[6]!==o?(p=t.jsxs("div",{className:"min-w-0 flex-1",children:[o,a]}),e[5]=a,e[6]=o,e[7]=p):p=e[7];let k;e[8]!==n||e[9]!==r||e[10]!==d?(k=n?t.jsx("button",{type:"button",onClick:r,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":d("rightSidebar.contextNotesTodo.notes.actions.collapse"),title:d("rightSidebar.contextNotesTodo.notes.actions.collapse"),children:t.jsx(E,{name:"arrow-up-s",className:"h-3.5 w-3.5"})}):null,e[8]=n,e[9]=r,e[10]=d,e[11]=k):k=e[11];let P;e[12]!==i||e[13]!==k?(P=t.jsxs("div",{className:"flex flex-shrink-0 flex-col items-center gap-0.5",onClick:Ad,onKeyDown:Bd,children:[k,i]}),e[12]=i,e[13]=k,e[14]=P):P=e[14];let A;e[15]!==P||e[16]!==p?(A=t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[p,P]}),e[15]=P,e[16]=p,e[17]=A):A=e[17];let N;e[18]!==c?(N=c?t.jsx("div",{className:"min-w-0",children:c}):null,e[18]=c,e[19]=N):N=e[19];let C;return e[20]!==A||e[21]!==N||e[22]!==h||e[23]!==b||e[24]!==f||e[25]!==x||e[26]!==g||e[27]!==j?(C=t.jsxs("li",{className:h,onClick:b,onKeyDown:f,role:x,tabIndex:g,"aria-label":j,children:[A,N]}),e[20]=A,e[21]=N,e[22]=h,e[23]=b,e[24]=f,e[25]=x,e[26]=g,e[27]=j,e[28]=C):C=e[28],C};function Ad(s){return s.stopPropagation()}function Bd(s){return s.stopPropagation()}const Ld=s=>{const e=Ve.c(52),{entry:n,badge:r,expanded:o,onToggleExpanded:a,onSave:i,onDelete:c}=s,{t:l}=nt(),[d,u]=m.useState(n.title),[h,b]=m.useState(n.body);let f,x;e[0]!==n.body||e[1]!==n.title||e[2]!==o?(f=()=>{o||(u(n.title),b(n.body))},x=[n.body,n.title,o],e[0]=n.body,e[1]=n.title,e[2]=o,e[3]=f,e[4]=x):(f=e[3],x=e[4]),m.useEffect(f,x);let g;e[5]!==h||e[6]!==n.body||e[7]!==n.title||e[8]!==i||e[9]!==d?(g=()=>{const Y=d.trim(),O=h.trim();if(!Y||!O){u(n.title),b(n.body);return}Y===n.title&&O===n.body||i({title:Y,body:O})},e[5]=h,e[6]=n.body,e[7]=n.title,e[8]=i,e[9]=d,e[10]=g):g=e[10];const j=g,p=`rightSidebar.contextNotesTodo.memory.type.${n.type}`;let k;e[11]!==l||e[12]!==p?(k=l(p),e[11]=l,e[12]=p,e[13]=k):k=e[13];const P=k;let A;e[14]!==j||e[15]!==o||e[16]!==a?(A=()=>{o&&j(),a()},e[14]=j,e[15]=o,e[16]=a,e[17]=A):A=e[17];const N=n.title;let C;e[18]!==n.flagged||e[19]!==l?(C=n.flagged?t.jsxs("span",{className:"flex items-center gap-1 text-[var(--status-error)]",children:[t.jsx(E,{name:"error-warning",className:"h-3 w-3 flex-shrink-0"}),l("rightSidebar.contextNotesTodo.memory.flagged")]}):null,e[18]=n.flagged,e[19]=l,e[20]=C):C=e[20];let w;e[21]!==C||e[22]!==P?(w=t.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 typography-micro text-muted-foreground",children:[P,C]}),e[21]=C,e[22]=P,e[23]=w):w=e[23];let v;e[24]!==r||e[25]!==l?(v=r?t.jsx("span",{className:ie("mb-0.5 mr-1.5 inline-block rounded-full px-1.5 py-px typography-micro font-medium",r==="new"?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--status-warning)]/15 text-[var(--status-warning)]"),children:l(r==="new"?"rightSidebar.contextNotesTodo.memory.badge.new":"rightSidebar.contextNotesTodo.memory.badge.changed")}):null,e[24]=r,e[25]=l,e[26]=v):v=e[26];let L;e[27]!==l?(L=l("rightSidebar.contextNotesTodo.memory.actions.delete"),e[27]=l,e[28]=L):L=e[28];let $;e[29]!==l?($=l("rightSidebar.contextNotesTodo.memory.actions.delete"),e[29]=l,e[30]=$):$=e[30];let M;e[31]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[31]=M):M=e[31];let H;e[32]!==c||e[33]!==L||e[34]!==$?(H=t.jsx("button",{type:"button",onClick:c,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":L,title:$,children:M}),e[32]=c,e[33]=L,e[34]=$,e[35]=H):H=e[35];let K;e[36]!==h||e[37]!==j||e[38]!==n.body||e[39]!==n.title||e[40]!==o||e[41]!==l||e[42]!==d?(K=o?t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(yt,{value:d,onChange:Y=>u(Y.target.value.slice(0,Ha)),onBlur:j,"aria-label":l("rightSidebar.contextNotesTodo.memory.actions.editTitle"),className:"h-7 typography-ui-label"}),t.jsx(Hs,{simple:!0,rows:Math.min(20,Math.max(3,h.split(`
6
- `).length+1)),value:h,onChange:Y=>b(Y.target.value.slice(0,Ka)),onBlur:j,"aria-label":l("rightSidebar.contextNotesTodo.memory.actions.editBody"),className:"min-h-0 w-full resize-none bg-transparent p-0 typography-meta leading-normal text-muted-foreground focus-visible:outline-none focus-visible:ring-0"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:n.title}),t.jsx("p",{className:"line-clamp-2 whitespace-pre-wrap break-words typography-meta text-muted-foreground",children:n.body})]}),e[36]=h,e[37]=j,e[38]=n.body,e[39]=n.title,e[40]=o,e[41]=l,e[42]=d,e[43]=K):K=e[43];let ee;return e[44]!==n.title||e[45]!==o||e[46]!==v||e[47]!==H||e[48]!==K||e[49]!==A||e[50]!==w?(ee=t.jsx(bo,{expanded:o,onToggleExpanded:A,expandLabel:N,footer:w,header:v,actions:H,children:K}),e[44]=n.title,e[45]=o,e[46]=v,e[47]=H,e[48]=K,e[49]=A,e[50]=w,e[51]=ee):ee=e[51],ee},Md=s=>{const e=Ve.c(59),{projectPath:n,query:r}=s,{t:o}=nt(),[a,i]=m.useState("project"),[c,l]=m.useState(null),d=Dt(Fd);let u;e[0]!==n?(u=Z=>Or(Z,n),e[0]=n,e[1]=u):u=e[1];const h=Dt(u),b=Dt(Od),f=Dt($d),x=Dt(Ud),g=Dt(Wd),j=He(_d),p=a==="global"?d:h,k=a==="global"?b:f;let P;e[2]!==n||e[3]!==a?(P=Fn(a,n),e[2]=n,e[3]=a,e[4]=P):P=e[4];const A=P;let N;e[5]!==A?(N=Z=>Z.agentMemoryViewedAt[A]??0,e[5]=A,e[6]=N):N=e[6];const C=He(N),w=m.useRef(C),[v,L]=m.useState(C);let $,M;e[7]!==j||e[8]!==A?($=()=>(w.current=He.getState().agentMemoryViewedAt[A]??0,L(w.current),()=>{j(A,Date.now())}),M=[j,A],e[7]=j,e[8]=A,e[9]=$,e[10]=M):($=e[9],M=e[10]),m.useEffect($,M);let H;if(e[11]!==p||e[12]!==r){let Z;e[14]!==r?(Z=te=>Ks([te.title,te.body],r),e[14]=r,e[15]=Z):Z=e[15],H=p.filter(Z),e[11]=p,e[12]=r,e[13]=H}else H=e[13];const K=H;let ee;e[16]!==x||e[17]!==a||e[18]!==o?(ee=async Z=>{if(!await x(a,Z)){const te=Dt.getState().error;Se.error(o("rightSidebar.contextNotesTodo.memory.toast.deleteFailed"),te?{description:te}:void 0)}},e[16]=x,e[17]=a,e[18]=o,e[19]=ee):ee=e[19];const Y=ee;let O;e[20]!==g||e[21]!==a||e[22]!==o?(O=async(Z,te)=>{if(!await g(a,Z,te)){const ye=Dt.getState().error;Se.error(o("rightSidebar.contextNotesTodo.memory.toast.saveFailed"),ye?{description:ye}:void 0)}},e[20]=g,e[21]=a,e[22]=o,e[23]=O):O=e[23];const _=O;let U;e[24]!==o?(U=o("rightSidebar.contextNotesTodo.memory.scope.project"),e[24]=o,e[25]=U):U=e[25];let J;e[26]!==h.length||e[27]!==U?(J={id:"project",label:U,count:h.length},e[26]=h.length,e[27]=U,e[28]=J):J=e[28];let D;e[29]!==o?(D=o("rightSidebar.contextNotesTodo.memory.scope.global"),e[29]=o,e[30]=D):D=e[30];let z;e[31]!==d.length||e[32]!==D?(z={id:"global",label:D,count:d.length},e[31]=d.length,e[32]=D,e[33]=z):z=e[33];let F;e[34]!==J||e[35]!==z?(F=[J,z],e[34]=J,e[35]=z,e[36]=F):F=e[36];const R=F;let V;e[37]!==o?(V=o("rightSidebar.contextNotesTodo.memory.scope.label"),e[37]=o,e[38]=V):V=e[38];let ne;e[39]!==a||e[40]!==R?(ne=R.map(Z=>t.jsx(Ne,{type:"button",variant:"chip",size:"xs","aria-pressed":a===Z.id,className:"!font-normal",onClick:()=>i(Z.id),children:`${Z.label} ${Z.count}`},Z.id)),e[39]=a,e[40]=R,e[41]=ne):ne=e[41];let Q;e[42]!==V||e[43]!==ne?(Q=t.jsx("div",{role:"group","aria-label":V,className:"flex items-center gap-1",children:ne}),e[42]=V,e[43]=ne,e[44]=Q):Q=e[44];let q;e[45]!==v||e[46]!==c||e[47]!==Y||e[48]!==_||e[49]!==n||e[50]!==r||e[51]!==a||e[52]!==k||e[53]!==o||e[54]!==K?(q=a==="project"&&!n?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.memory.empty.noProject")}):k?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.memory.empty.unavailable")}):K.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r.trim()?o("rightSidebar.contextNotesTodo.memory.empty.noMatches"):o("rightSidebar.contextNotesTodo.memory.empty.nothing")}):t.jsx("ul",{className:"flex flex-col gap-1.5",children:K.map(Z=>t.jsx(Ld,{entry:Z,badge:xo(Z,v),expanded:c===Z.id,onToggleExpanded:()=>l(c===Z.id?null:Z.id),onSave:te=>{_(Z.id,te)},onDelete:()=>{Y(Z.id)}},Z.id))}),e[45]=v,e[46]=c,e[47]=Y,e[48]=_,e[49]=n,e[50]=r,e[51]=a,e[52]=k,e[53]=o,e[54]=K,e[55]=q):q=e[55];let oe;return e[56]!==Q||e[57]!==q?(oe=t.jsxs("div",{className:"flex flex-col gap-2",children:[Q,q]}),e[56]=Q,e[57]=q,e[58]=oe):oe=e[58],oe};function Fd(s){return s.global}function Od(s){return s.globalFailed}function $d(s){return s.projectFailed}function Ud(s){return s.deleteEntry}function Wd(s){return s.saveEntry}function _d(s){return s.markAgentMemoryViewed}const Vd=400,zd=s=>{const e=Ve.c(61),{note:n,pinned:r,expanded:o,onToggleExpanded:a,onSaveBody:i,onTogglePinned:c,onDelete:l}=s,{t:d}=nt(),[u,h]=m.useState(n.body),b=m.useRef(n.body),f=m.useRef(null);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{f.current!==null&&(window.clearTimeout(f.current),f.current=null)},e[0]=x):x=e[0];const g=x;let j,p;e[1]!==u||e[2]!==n.body?(j=()=>{n.body!==b.current&&u===b.current&&(b.current=n.body,h(n.body))},p=[u,n.body],e[1]=u,e[2]=n.body,e[3]=j,e[4]=p):(j=e[3],p=e[4]),m.useEffect(j,p);let k,P;e[5]!==u||e[6]!==i?(k=()=>{if(u!==b.current)return f.current=window.setTimeout(()=>{f.current=null,u.trim()&&(b.current=u,i(u))},Vd),g},P=[g,u,i],e[5]=u,e[6]=i,e[7]=k,e[8]=P):(k=e[7],P=e[8]),m.useEffect(k,P);let A,N;e[9]===Symbol.for("react.memo_cache_sentinel")?(A=()=>g,N=[g],e[9]=A,e[10]=N):(A=e[9],N=e[10]),m.useEffect(A,N);let C;e[11]!==u||e[12]!==i?(C=()=>{if(g(),u!==b.current){if(!u.trim()){h(b.current);return}b.current=u,i(u)}},e[11]=u,e[12]=i,e[13]=C):C=e[13];const w=C;let v;e[14]!==n.source||e[15]!==d?(v=n.source==="selection"?d("rightSidebar.contextNotesTodo.notes.source.selection"):n.source==="agent"?d("rightSidebar.contextNotesTodo.notes.source.agent"):null,e[14]=n.source,e[15]=d,e[16]=v):v=e[16];const L=v;let $;e[17]!==d?($=d("rightSidebar.contextNotesTodo.notes.actions.expand"),e[17]=d,e[18]=$):$=e[18];let M;e[19]!==L?(M=L?t.jsx("span",{className:"typography-micro text-muted-foreground",children:L}):null,e[19]=L,e[20]=M):M=e[20];const H=r?"text-primary":"text-muted-foreground hover:text-foreground";let K;e[21]!==H?(K=ie("inline-flex h-6 w-6 items-center justify-center rounded-md hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",H),e[21]=H,e[22]=K):K=e[22];let ee;e[23]!==r||e[24]!==d?(ee=d(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[23]=r,e[24]=d,e[25]=ee):ee=e[25];let Y;e[26]!==r||e[27]!==d?(Y=d(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[26]=r,e[27]=d,e[28]=Y):Y=e[28];const O=r?"pushpin-2-fill":"pushpin";let _;e[29]!==O?(_=t.jsx(E,{name:O,className:"h-3.5 w-3.5"}),e[29]=O,e[30]=_):_=e[30];let U;e[31]!==c||e[32]!==r||e[33]!==K||e[34]!==ee||e[35]!==Y||e[36]!==_?(U=t.jsx("button",{type:"button",onClick:c,className:K,"aria-pressed":r,"aria-label":ee,title:Y,children:_}),e[31]=c,e[32]=r,e[33]=K,e[34]=ee,e[35]=Y,e[36]=_,e[37]=U):U=e[37];let J;e[38]!==d?(J=d("rightSidebar.contextNotesTodo.notes.actions.delete"),e[38]=d,e[39]=J):J=e[39];let D;e[40]!==d?(D=d("rightSidebar.contextNotesTodo.notes.actions.delete"),e[40]=d,e[41]=D):D=e[41];let z;e[42]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[42]=z):z=e[42];let F;e[43]!==l||e[44]!==J||e[45]!==D?(F=t.jsx("button",{type:"button",onClick:l,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":J,title:D,children:z}),e[43]=l,e[44]=J,e[45]=D,e[46]=F):F=e[46];let R;e[47]!==U||e[48]!==F?(R=t.jsxs(t.Fragment,{children:[U,F]}),e[47]=U,e[48]=F,e[49]=R):R=e[49];let V;e[50]!==u||e[51]!==o||e[52]!==w?(V=o?t.jsx(Hs,{simple:!0,autoFocus:!0,rows:Math.min(20,Math.max(3,u.split(`
7
- `).length+1)),value:u,onChange:Q=>h(Q.target.value.slice(0,vn)),onBlur:w,className:"min-h-0 w-full resize-none bg-transparent p-0 typography-ui-label leading-normal text-foreground focus-visible:outline-none focus-visible:ring-0"}):t.jsx("p",{className:"line-clamp-3 whitespace-pre-wrap break-words typography-ui-label leading-normal text-foreground",title:u,children:u}),e[50]=u,e[51]=o,e[52]=w,e[53]=V):V=e[53];let ne;return e[54]!==o||e[55]!==a||e[56]!==$||e[57]!==M||e[58]!==R||e[59]!==V?(ne=t.jsx(bo,{expanded:o,onToggleExpanded:a,expandLabel:$,footer:M,actions:R,children:V}),e[54]=o,e[55]=a,e[56]=$,e[57]=M,e[58]=R,e[59]=V,e[60]=ne):ne=e[60],ne},Gd=s=>{const e=Ve.c(69),{projectRef:n,notes:r,disabled:o,query:a,pinnedNoteIds:i,onTogglePinned:c}=s,{t:l}=nt(),[d,u]=m.useState(""),[h,b]=m.useState(null),f=He(Hd),x=He(Kd),g=Rt(qd),j=Rt(Yd),p=Rt(Jd);let k;if(e[0]!==r||e[1]!==a){let q;e[3]!==a?(q=oe=>Ks([oe.body],a),e[3]=a,e[4]=q):q=e[4],k=r.filter(q),e[0]=r,e[1]=a,e[2]=k}else k=e[2];const P=k;let A;e[5]!==n?(A=q=>{const oe=Rt.getState().getEntry(n).error;Se.error(q,oe?{description:oe}:void 0)},e[5]=n,e[6]=A):A=e[6];const N=A;let C;e[7]!==d||e[8]!==g||e[9]!==n||e[10]!==N||e[11]!==l?(C=async()=>{const q=d.trim();if(!q)return;if(!await g(n,{body:q})){N(l("rightSidebar.contextNotesTodo.toast.createNoteFailed"));return}u("")},e[7]=d,e[8]=g,e[9]=n,e[10]=N,e[11]=l,e[12]=C):C=e[12];const w=C;let v;e[13]!==p||e[14]!==n||e[15]!==N||e[16]!==l?(v=async q=>{await p(n,q)||N(l("rightSidebar.contextNotesTodo.toast.deleteNoteFailed"))},e[13]=p,e[14]=n,e[15]=N,e[16]=l,e[17]=v):v=e[17];const L=v;let $;e[18]!==c||e[19]!==N||e[20]!==l?($=async(q,oe)=>{await c(q,oe)||N(l("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))},e[18]=c,e[19]=N,e[20]=l,e[21]=$):$=e[21];const M=$;let H;e[22]!==n||e[23]!==N||e[24]!==j||e[25]!==l?(H=(q,oe)=>{j(n,q,oe).then(Z=>{Z||N(l("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[22]=n,e[23]=N,e[24]=j,e[25]=l,e[26]=H):H=e[26];const K=H;let ee;e[27]===Symbol.for("react.memo_cache_sentinel")?(ee=q=>u(q.target.value.slice(0,vn)),e[27]=ee):ee=e[27];let Y;e[28]!==l?(Y=l("rightSidebar.contextNotesTodo.notes.placeholder"),e[28]=l,e[29]=Y):Y=e[29];let O;e[30]!==d.length?(O=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[d.length,"/",vn]}),e[30]=d.length,e[31]=O):O=e[31];let _;e[32]!==w?(_=()=>{w()},e[32]=w,e[33]=_):_=e[33];let U;e[34]!==d||e[35]!==o?(U=o||d.trim().length===0,e[34]=d,e[35]=o,e[36]=U):U=e[36];let J;e[37]!==l?(J=l("rightSidebar.contextNotesTodo.notes.addAria"),e[37]=l,e[38]=J):J=e[38];let D;e[39]!==l?(D=l("rightSidebar.contextNotesTodo.notes.addAria"),e[39]=l,e[40]=D):D=e[40];let z;e[41]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx(E,{name:"add",className:"h-4 w-4"}),e[41]=z):z=e[41];let F;e[42]!==_||e[43]!==U||e[44]!==J||e[45]!==D?(F=t.jsx("button",{type:"button",onClick:_,disabled:U,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-40","aria-label":J,title:D,children:z}),e[42]=_,e[43]=U,e[44]=J,e[45]=D,e[46]=F):F=e[46];let R;e[47]!==F||e[48]!==O?(R=t.jsxs(t.Fragment,{children:[O,F]}),e[47]=F,e[48]=O,e[49]=R):R=e[49];let V;e[50]!==d||e[51]!==o||e[52]!==f||e[53]!==x||e[54]!==R||e[55]!==Y?(V=t.jsx(Hs,{value:d,onChange:ee,placeholder:Y,resizedHeight:f,onResizeHeightChange:x,useScrollShadow:!0,scrollShadowSize:56,disabled:o,endSlot:R}),e[50]=d,e[51]=o,e[52]=f,e[53]=x,e[54]=R,e[55]=Y,e[56]=V):V=e[56];let ne;e[57]!==h||e[58]!==L||e[59]!==K||e[60]!==M||e[61]!==i||e[62]!==a||e[63]!==l||e[64]!==P?(ne=t.jsx("div",{children:P.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:a.trim()?l("rightSidebar.contextNotesTodo.search.noResults",{query:a.trim()}):l("rightSidebar.contextNotesTodo.notes.empty")}):t.jsx("ul",{className:"flex flex-col gap-1.5",children:P.map(q=>t.jsx(zd,{note:q,pinned:i.has(q.id),expanded:h===q.id,onToggleExpanded:()=>b(oe=>oe===q.id?null:q.id),onSaveBody:oe=>K(q.id,oe),onTogglePinned:()=>{M(q.id,!i.has(q.id))},onDelete:()=>{L(q.id)}},q.id))})}),e[57]=h,e[58]=L,e[59]=K,e[60]=M,e[61]=i,e[62]=a,e[63]=l,e[64]=P,e[65]=ne):ne=e[65];let Q;return e[66]!==V||e[67]!==ne?(Q=t.jsxs("div",{className:"space-y-2",children:[V,ne]}),e[66]=V,e[67]=ne,e[68]=Q):Q=e[68],Q};function Hd(s){return s.notesPanelHeight}function Kd(s){return s.setNotesPanelHeight}function qd(s){return s.createNote}function Yd(s){return s.saveNoteBody}function Jd(s){return s.deleteNote}const Qd=({projectRef:s,plans:e,query:n,onOpenPlan:r,pinnedPlanIds:o,onTogglePinned:a})=>{const{t:i}=nt(),c=m.useRef(null),[l,d]=m.useState(!1),[u,h]=m.useState(null),b=Rt(w=>w.createPlan),f=Rt(w=>w.deletePlan),x=gs(w=>w.currentDirectory),g=He(w=>w.openContextPanelTab),j=m.useCallback(async w=>{if(!u){h(w);try{await f(s,w)||Se.error(i("rightSidebar.contextNotesTodo.toast.deletePlanFailed"))}finally{h(null)}}},[u,s,f,i]),p=m.useCallback(async(w,v)=>{if(!w.trim()){Se.error(i("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const L=qa(w,v||i("rightSidebar.contextNotesTodo.plan.defaultTitle"));if(!await b(s,{title:L.title,body:L.body})){Se.error(i("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}Se.success(i("rightSidebar.contextNotesTodo.toast.planImported"))},[b,s,i]),k=m.useCallback(async()=>{if(l)return;const w=await Pi({defaultPath:s.path,filters:[{name:"Plan files",extensions:["md","markdown","txt"]},{name:"All files",extensions:["*"]}]});if(w.success&&w.path){d(!0);try{const v=new URLSearchParams({path:w.path,allowOutsideWorkspace:"true"});w.outsideFileGrant&&v.set("outsideFileGrant",w.outsideFileGrant);const L=await Lt(`/api/fs/read?${v.toString()}`,{cache:"no-store"});if(!L.ok){Se.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"));return}const $=await L.text(),M=w.path.split("/").pop()?.replace(/\.(md|markdown|txt)$/i,"").trim()||"";await p($,M)}catch(v){const L=v instanceof Error?v.message:void 0;Se.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),L?{description:L}:void 0)}finally{d(!1)}return}w.error==="Native file picker not available"&&c.current?.click()},[p,l,s.path,i]),P=m.useCallback(async w=>{if(w){d(!0);try{const v=await w.text(),L=w.name.replace(/\.(md|markdown|txt)$/i,"").trim();await p(v,L)}catch(v){const L=v instanceof Error?v.message:void 0;Se.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),L?{description:L}:void 0)}finally{d(!1)}}},[p,i]),A=m.useCallback(async(w,v)=>{if(!await a(w,v)){const $=Rt.getState().getEntry(s).error;Se.error(i("rightSidebar.contextNotesTodo.toast.updatePlanFailed"),$?{description:$}:void 0)}},[a,s,i]),N=m.useMemo(()=>e.filter(w=>Ks([w.title],n)),[e,n]),C=m.useCallback(w=>{if(r){r({id:w.id,title:w.title,projectRef:s});return}const v=x?.trim()||s.path.trim();v&&g(v,{mode:"plan",projectPlanId:w.id,projectPlanRef:s,dedupeKey:`plan:${$r(s)}:${w.id}`,label:w.title})},[x,r,g,s]);return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsx("input",{ref:c,type:"file",accept:".md,.markdown,.txt,text/markdown,text/plain",className:"hidden",onChange:w=>{const v=w.target.files?.[0]??null;P(v),w.currentTarget.value=""}}),t.jsx("button",{type:"button",onClick:k,disabled:l,className:"inline-flex h-6 w-6 items-center justify-center rounded-md border border-border/70 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":i("rightSidebar.contextNotesTodo.plans.importFromFile"),title:i("rightSidebar.contextNotesTodo.plans.importFromFile"),children:t.jsx(E,{name:"add",className:"h-3.5 w-3.5"})})]}),t.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:N.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:n.trim()?i("rightSidebar.contextNotesTodo.search.noResults",{query:n.trim()}):i("rightSidebar.contextNotesTodo.plans.empty")}):t.jsx("ul",{className:"divide-y divide-border/50",children:N.map(w=>t.jsxs("li",{className:"flex items-center gap-1.5 px-2.5 py-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>C(w),className:"flex min-w-0 flex-1 items-center justify-between gap-3 rounded-md px-1.5 py-1 text-left hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",children:w.title}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:new Date(w.createdAt).toLocaleDateString(Nr())})]}),t.jsx("button",{type:"button",onClick:()=>{A(w.id,!o.has(w.id))},className:ie("inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",o.has(w.id)?"text-primary":"text-muted-foreground hover:text-foreground"),"aria-pressed":o.has(w.id),"aria-label":o.has(w.id)?i("rightSidebar.contextNotesTodo.notes.actions.unpin"):i("rightSidebar.contextNotesTodo.notes.actions.pin"),title:o.has(w.id)?i("rightSidebar.contextNotesTodo.notes.actions.unpin"):i("rightSidebar.contextNotesTodo.notes.actions.pin"),children:t.jsx(E,{name:"pushpin",className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button",onClick:()=>{j(w.id)},disabled:u===w.id,className:"inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",title:i("rightSidebar.contextNotesTodo.plans.deletePlan"),"aria-label":i("rightSidebar.contextNotesTodo.plans.deletePlanWithTitle",{title:w.title}),children:t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},w.id))})})]})},Xd=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`todo_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,Zd=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],gr=(s,e)=>{const n=s.findIndex(r=>r.completed);return n===-1?[...s,e]:[...s.slice(0,n),e,...s.slice(n)]},eu=s=>{const e=Ve.c(20),{id:n,children:r}=s;let o;e[0]!==n?(o={id:n},e[0]=n,e[1]=o):o=e[1];const{attributes:a,listeners:i,setNodeRef:c,setActivatorNodeRef:l,transform:d,transition:u,isDragging:h}=Zr(o);let b;e[2]!==d?(b=to.Transform.toString(d),e[2]=d,e[3]=b):b=e[3];let f;e[4]!==b||e[5]!==u?(f={transform:b,transition:u},e[4]=b,e[5]=u,e[6]=f):f=e[6];const x=h&&"opacity-60";let g;e[7]!==x?(g=ie(x),e[7]=x,e[8]=g):g=e[8];let j;e[9]!==a||e[10]!==r||e[11]!==h||e[12]!==i||e[13]!==l?(j=r({attributes:a,listeners:i,setActivatorNodeRef:l,isDragging:h}),e[9]=a,e[10]=r,e[11]=h,e[12]=i,e[13]=l,e[14]=j):j=e[14];let p;return e[15]!==c||e[16]!==f||e[17]!==g||e[18]!==j?(p=t.jsx("li",{ref:c,style:f,className:g,children:j}),e[15]=c,e[16]=f,e[17]=g,e[18]=j,e[19]=p):p=e[19],p},tu=s=>{const e=Ve.c(82),{todos:n,query:r,disabled:o,canCreateWorktree:a,sendingTodoId:i,onPersistTodos:c,onSendToCurrentSession:l,onSendToNewSession:d,onSendToNewWorktreeSession:u}=s,{t:h}=nt(),[b,f]=m.useState(""),[x,g]=m.useState(su);let j;e[0]!==b||e[1]!==c||e[2]!==n?(j=()=>{const S=b.trim();S&&(c(gr(n,{id:Xd(),text:S.slice(0,As),completed:!1,createdAt:Date.now()})),f(""))},e[0]=b,e[1]=c,e[2]=n,e[3]=j):j=e[3];const p=j;let k;e[4]===Symbol.for("react.memo_cache_sentinel")?(k=S=>{g(B=>{const W=new Set(B);return W.has(S)?W.delete(S):W.add(S),W})},e[4]=k):k=e[4];const P=k;let A;e[5]!==c||e[6]!==n?(A=(S,B)=>{const W=n.find(Te=>Te.id===S);if(!W||W.completed===B)return;const le=n.filter(Te=>Te.id!==S),pe={...W,completed:B};c(B?[...le,pe]:gr(le,pe))},e[5]=c,e[6]=n,e[7]=A):A=e[7];const N=A;let C;e[8]!==c||e[9]!==n?(C=S=>{c(n.filter(B=>B.id!==S))},e[8]=c,e[9]=n,e[10]=C):C=e[10];const w=C;let v;e[11]!==c||e[12]!==n?(v=()=>{const S=n.filter(nu);S.length!==n.length&&c(S)},e[11]=c,e[12]=n,e[13]=v):v=e[13];const L=v;let $;e[14]!==c||e[15]!==n?($=S=>{const{active:B,over:W}=S;if(!W||B.id===W.id)return;const le=n.findIndex(Te=>Te.id===B.id),pe=n.findIndex(Te=>Te.id===W.id);le===-1||pe===-1||c(Zd(Yi(n,le,pe)))},e[14]=c,e[15]=n,e[16]=$):$=e[16];const M=$;let H;e[17]===Symbol.for("react.memo_cache_sentinel")?(H={activationConstraint:{distance:8}},e[17]=H):H=e[17];const K=qr(Yr(Jr,H));let ee;e[18]!==b?(ee=b.slice(0,As),e[18]=b,e[19]=ee):ee=e[19];const Y=ee;let O;e[20]!==n?(O=n.reduce(ru,0),e[20]=n,e[21]=O):O=e[21];const _=O;let U;if(e[22]!==r||e[23]!==n){let S;e[25]!==r?(S=B=>Ks([B.text],r),e[25]=r,e[26]=S):S=e[26],U=n.filter(S),e[22]=r,e[23]=n,e[24]=U}else U=e[24];const J=U,D=o||_===0;let z;e[27]!==h?(z=h("rightSidebar.contextNotesTodo.todo.clearCompleted"),e[27]=h,e[28]=z):z=e[28];let F;e[29]!==L||e[30]!==D||e[31]!==z?(F=t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{type:"button",onClick:L,disabled:D,className:"typography-meta rounded-md px-1.5 py-0.5 text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",children:z})}),e[29]=L,e[30]=D,e[31]=z,e[32]=F):F=e[32];let R;e[33]!==Y.length?(R=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[Y.length,"/",As]}),e[33]=Y.length,e[34]=R):R=e[34];let V;e[35]!==F||e[36]!==R?(V=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[F,R]}),e[35]=F,e[36]=R,e[37]=V):V=e[37];let ne;e[38]===Symbol.for("react.memo_cache_sentinel")?(ne=S=>f(S.target.value.slice(0,As)),e[38]=ne):ne=e[38];let Q;e[39]!==p?(Q=S=>{S.key==="Enter"&&(S.preventDefault(),p())},e[39]=p,e[40]=Q):Q=e[40];let q;e[41]!==h?(q=h("rightSidebar.contextNotesTodo.todo.inputPlaceholder"),e[41]=h,e[42]=q):q=e[42];let oe;e[43]!==o||e[44]!==Q||e[45]!==q||e[46]!==Y?(oe=t.jsx(yt,{value:Y,onChange:ne,onKeyDown:Q,placeholder:q,disabled:o,className:"h-8"}),e[43]=o,e[44]=Q,e[45]=q,e[46]=Y,e[47]=oe):oe=e[47];let Z;e[48]!==o||e[49]!==Y?(Z=o||Y.trim().length===0,e[48]=o,e[49]=Y,e[50]=Z):Z=e[50];let te;e[51]!==h?(te=h("rightSidebar.contextNotesTodo.todo.addAria"),e[51]=h,e[52]=te):te=e[52];let ye;e[53]!==h?(ye=h("rightSidebar.contextNotesTodo.todo.addAria"),e[53]=h,e[54]=ye):ye=e[54];let re;e[55]===Symbol.for("react.memo_cache_sentinel")?(re=t.jsx(E,{name:"add",className:"h-4 w-4"}),e[55]=re):re=e[55];let ge;e[56]!==p||e[57]!==Z||e[58]!==te||e[59]!==ye?(ge=t.jsx("button",{type:"button",onClick:p,disabled:Z,className:"inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border border-border/70 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":te,title:ye,children:re}),e[56]=p,e[57]=Z,e[58]=te,e[59]=ye,e[60]=ge):ge=e[60];let se;e[61]!==oe||e[62]!==ge?(se=t.jsxs("div",{className:"flex items-center gap-1.5",children:[oe,ge]}),e[61]=oe,e[62]=ge,e[63]=se):se=e[63];let fe;e[64]!==a||e[65]!==x||e[66]!==w||e[67]!==M||e[68]!==N||e[69]!==l||e[70]!==d||e[71]!==u||e[72]!==r||e[73]!==i||e[74]!==h||e[75]!==K||e[76]!==J?(fe=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:J.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:r.trim()?h("rightSidebar.contextNotesTodo.search.noResults",{query:r.trim()}):h("rightSidebar.contextNotesTodo.todo.empty")}):t.jsx(Qr,{sensors:K,collisionDetection:Xr,onDragEnd:M,children:t.jsx(eo,{items:J.map(ou),strategy:qi,children:t.jsx("ul",{className:"divide-y divide-border/50",children:J.map(S=>{const B=x.has(S.id);return t.jsx(eu,{id:S.id,children:W=>t.jsxs("div",{className:ie("flex gap-1.5 px-2.5 py-1.5",B?"items-start":"items-center"),children:[t.jsx("button",{type:"button",ref:W.setActivatorNodeRef,...W.attributes,...W.listeners,onClick:au,className:"flex h-6 w-4 flex-shrink-0 touch-none items-center justify-center text-muted-foreground hover:text-foreground","aria-label":h("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:S.text}),title:h("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:S.text}),children:t.jsx(E,{name:"draggable",className:"h-3.5 w-3.5"})}),t.jsx("div",{className:"flex h-6 items-center",children:t.jsx(Ds,{checked:S.completed,onChange:le=>N(S.id,le),ariaLabel:h("rightSidebar.contextNotesTodo.todo.actions.markComplete",{text:S.text})})}),t.jsx("button",{type:"button",onClick:()=>P(S.id),className:ie("block min-h-6 min-w-0 flex-1 bg-transparent p-0 text-left typography-ui-label leading-normal text-foreground",B?"whitespace-normal break-words":"overflow-hidden text-ellipsis whitespace-nowrap","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",S.completed&&"text-muted-foreground line-through"),title:B?void 0:S.text,"aria-label":B?h("rightSidebar.contextNotesTodo.todo.actions.collapse",{text:S.text}):h("rightSidebar.contextNotesTodo.todo.actions.expand",{text:S.text}),children:S.text}),t.jsxs("div",{className:"flex h-6 items-center gap-0.5",children:[t.jsx("button",{type:"button",onClick:()=>w(S.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":h("rightSidebar.contextNotesTodo.todo.actions.delete",{text:S.text}),title:h("rightSidebar.contextNotesTodo.todo.actions.delete",{text:S.text}),children:t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})}),t.jsxs(zt,{children:[t.jsx(Gt,{asChild:!0,children:t.jsx("button",{type:"button",disabled:i===S.id,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":h("rightSidebar.contextNotesTodo.todo.actions.send",{text:S.text}),title:h("rightSidebar.contextNotesTodo.todo.actions.send",{text:S.text}),children:t.jsx(E,{name:"send-plane",className:"h-3.5 w-3.5"})})}),t.jsxs(Ht,{align:"end",className:"w-56",children:[t.jsx(At,{onClick:()=>l(S.text),children:h("rightSidebar.contextNotesTodo.todo.sendMenu.currentSession")}),t.jsx(At,{onClick:()=>d(S.id,S.text),children:h("rightSidebar.contextNotesTodo.todo.sendMenu.newSession")}),t.jsx(At,{onClick:()=>u(S.id,S.text),disabled:!a,children:h("rightSidebar.contextNotesTodo.todo.sendMenu.newWorktreeSession")})]})]})]})]})},S.id)})})})})}),e[64]=a,e[65]=x,e[66]=w,e[67]=M,e[68]=N,e[69]=l,e[70]=d,e[71]=u,e[72]=r,e[73]=i,e[74]=h,e[75]=K,e[76]=J,e[77]=fe):fe=e[77];let he;return e[78]!==V||e[79]!==se||e[80]!==fe?(he=t.jsxs("div",{className:"space-y-2",children:[V,se,fe]}),e[78]=V,e[79]=se,e[80]=fe,e[81]=he):he=e[81],he};function su(){return new Set}function nu(s){return!s.completed}function ru(s,e){return s+(e.completed?1:0)}function ou(s){return s.id}function au(s){s.preventDefault(),s.stopPropagation()}const iu=s=>{const{projectRef:e,canCreateWorktree:n,onActionComplete:r}=s,{t:o}=nt(),[a,i]=m.useState(null),[c,l]=m.useState(!1),[d,u]=m.useState(null),h=at(v=>v.currentSessionId),b=at(v=>v.createSession),f=at(v=>v.initializeNewAiWorkerSession),x=at(v=>v.sendMessage),g=at(v=>v.setCurrentSession),j=Ya(v=>v.setPendingInputText),p=He(v=>v.setSessionSwitcherOpen),k=m.useCallback(()=>{p(!1)},[p]),P=m.useCallback(v=>{if(!h){Se.error(o("rightSidebar.contextNotesTodo.toast.noActiveSession"));return}k();const L=`\`\`\`md
8
- ${v}
9
- \`\`\``;j(L,"append"),Se.success(o("rightSidebar.contextNotesTodo.toast.sentToCurrentSession")),r?.()},[h,r,k,j,o]),A=m.useCallback((v,L)=>{!e||d||i({kind:"session",todoId:v,todoText:L})},[e,d]),N=m.useCallback((v,L)=>{if(!(!e||d)){if(!n){Se.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}i({kind:"worktree",todoId:v,todoText:L})}},[n,e,d,o]),C=m.useCallback(async v=>{if(!e||!a)return;const L=await Vt("plan.todo.visible",{todo_text:a.todoText}),M=[{synthetic:!0,text:await Vt("plan.todo.instructions",{todo_text:a.todoText})}];l(!0),u(a.todoId);try{k();let H=null,K=e.path;if(a.kind==="worktree"){if(!n){Se.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}const Y=await Ja(e.path,Qa());if(!Y?.id)return;H=Y.id,K=Y.path}else{const Y=await b(void 0,e.path,null);if(!Y?.id){Se.error(o("rightSidebar.contextNotesTodo.toast.createSessionFailed"));return}H=Y.id,K=Y.directory??e.path,f(Y.id,kt.getState().agents??[])}if(!H)return;const ee=Lr.getState();ee.saveSessionModelSelection(H,v.providerID,v.modelID),v.agent.trim()&&(ee.saveSessionAgentSelection(H,v.agent),ee.saveAgentModelForSession(H,v.agent,v.providerID,v.modelID),ee.saveAgentModelVariantForSession(H,v.agent,v.providerID,v.modelID,v.variant||void 0)),g(H,K),await x(L,v.providerID,v.modelID,v.agent.trim()||void 0,void 0,void 0,M,v.variant||void 0),Se.success(a.kind==="worktree"?o("rightSidebar.contextNotesTodo.toast.sentToNewWorktreeSession"):o("rightSidebar.contextNotesTodo.toast.sentToNewSession")),i(null),r?.()}catch(H){const K=H instanceof Error?H.message:void 0;Se.error(o("rightSidebar.contextNotesTodo.toast.sendTodoFailed"),K?{description:K}:void 0)}finally{l(!1),u(null)}},[n,b,f,r,a,e,k,x,g,o]),w=m.useCallback(()=>{c||i(null)},[c]);return{pendingSendTarget:a,isSubmitting:c,sendingTodoId:d,sendToCurrentSession:P,sendToNewSession:A,sendToNewWorktreeSession:N,confirmSend:C,closeDialog:w}},lu=m.lazy(()=>Qt(()=>import("./PlanView-B0F3BtPZ.js"),__vite__mapDeps([115,2,3,4,5,6,7,8,9,116,57,58,59,60,61,62,79,55,56,63,117,118,119,1,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,120,121,113,114,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98])).then(s=>({default:s.PlanView}))),xr=["notes","todos","plans","memory"],cu=120,du=320,on=s=>Math.min(du,Math.max(cu,Math.round(s))),uu=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],ys=(s,e)=>s.toLowerCase().includes(e),fu=s=>{const e=Ve.c(242),{projectRef:n,projectLabel:r,canCreateWorktree:o,onActionComplete:a,onOpenPlan:i,className:c}=s,l=o===void 0?!1:o,{t:d}=nt();let u;e[0]!==n?(u=$r(n),e[0]=n,e[1]=u):u=e[1];const h=u;let b;e[2]!==h?(b=we=>(h?we.entries[h]:void 0)??Xa,e[2]=h,e[3]=b):b=e[3];const f=Rt(b),x=Rt(mu),g=Rt(hu),j=at(pu),p=at(gu),k=at(xu),P=at(bu);let A;e[4]===Symbol.for("react.memo_cache_sentinel")?(A={notes:[],plans:[]},e[4]=A):A=e[4];const[N,C]=m.useState(A);let w,v;e[5]!==p||e[6]!==j||e[7]!==k.open||e[8]!==k.projectContextPins?(w=()=>{if(k.open){C(k.projectContextPins??{notes:[],plans:[]});return}let we=!1;return Za(p,j).then(Ze=>{we||C({notes:Ze.notes.map(yu),plans:Ze.plans.map(wu)})}),()=>{we=!0}},v=[p,j,k.open,k.projectContextPins],e[5]=p,e[6]=j,e[7]=k.open,e[8]=k.projectContextPins,e[9]=w,e[10]=v):(w=e[9],v=e[10]),m.useEffect(w,v);let L;e[11]!==p||e[12]!==j||e[13]!==k.open||e[14]!==P?(L=async(we,Ze,vt)=>{if(k.open)return P(we,Ze,vt),!0;if(!j||!p)return!1;const Ft=await ei(p,j,we,Ze,vt);return Ft?(C(Ft),!0):!1},e[11]=p,e[12]=j,e[13]=k.open,e[14]=P,e[15]=L):L=e[15];const $=L;let M;e[16]!==N.notes?(M=new Set(N.notes),e[16]=N.notes,e[17]=M):M=e[17];const H=M;let K;e[18]!==N.plans?(K=new Set(N.plans),e[18]=N.plans,e[19]=K):K=e[19];const ee=K,Y=He(vu),O=Dt(Su),_=Y&&!O,U=Dt(ju);let J;e[20]!==n?.path?(J=we=>Or(we,n?.path??null),e[20]=n?.path,e[21]=J):J=e[21];const D=Dt(J),z=He(ku),F=He(Nu),R=He(Iu);let V;e[22]!==F?(V=xr.includes(F)?F:"notes",e[22]=F,e[23]=V):V=e[23];const ne=V,Q=ne==="memory"&&!_?"notes":ne,[q,oe]=m.useState(""),[Z,te]=m.useState(null);let ye;e[24]!==q?(ye=q.trim().toLowerCase(),e[24]=q,e[25]=ye):ye=e[25];const re=ye;let ge;e[26]!==f.todos?(ge=uu(f.todos),e[26]=f.todos,e[27]=ge):ge=e[27];const se=ge,fe=f.loading&&!f.loaded;let he;e[28]!==U||e[29]!==D?(he=[...U,...D],e[28]=U,e[29]=D,e[30]=he):he=e[30];const S=he;let B;e:{if(!re){let ft;e[31]!==f.notes.length||e[32]!==f.plans.length||e[33]!==S.length||e[34]!==se.length?(ft={notes:f.notes.length,todos:se.length,plans:f.plans.length,memory:S.length},e[31]=f.notes.length,e[32]=f.plans.length,e[33]=S.length,e[34]=se.length,e[35]=ft):ft=e[35],B=ft;break e}let we;if(e[36]!==f.notes||e[37]!==re){let ft;e[39]!==re?(ft=xs=>ys(xs.body,re),e[39]=re,e[40]=ft):ft=e[40],we=f.notes.filter(ft),e[36]=f.notes,e[37]=re,e[38]=we}else we=e[38];const Ze=we.length;let vt;if(e[41]!==se||e[42]!==re){let ft;e[44]!==re?(ft=xs=>ys(xs.text,re),e[44]=re,e[45]=ft):ft=e[45],vt=se.filter(ft),e[41]=se,e[42]=re,e[43]=vt}else vt=e[43];const Ft=vt.length;let cs;if(e[46]!==f.plans||e[47]!==re){let ft;e[49]!==re?(ft=xs=>ys(xs.title,re),e[49]=re,e[50]=ft):ft=e[50],cs=f.plans.filter(ft),e[46]=f.plans,e[47]=re,e[48]=cs}else cs=e[48];const ko=cs.length;let ds;e[51]!==S||e[52]!==re?(ds=S.filter(ft=>ys(ft.title,re)||ys(ft.body,re)),e[51]=S,e[52]=re,e[53]=ds):ds=e[53];let Rs;e[54]!==we.length||e[55]!==vt.length||e[56]!==cs.length||e[57]!==ds.length?(Rs={notes:Ze,todos:Ft,plans:ko,memory:ds.length},e[54]=we.length,e[55]=vt.length,e[56]=cs.length,e[57]=ds.length,e[58]=Rs):Rs=e[58],B=Rs}const W=B,le=He(Cu);let pe;e[59]!==n?.path?(pe=we=>we.agentMemoryViewedAt[Fn("project",n?.path??null)]??0,e[59]=n?.path,e[60]=pe):pe=e[60];const Te=He(pe),Ie=pr(U,le)+pr(D,Te),We=He(Tu),Me=He(Du),[ve,Be]=m.useState(!1),[Ee,Oe]=m.useState(null),ze=Ee??We;let qe;e[61]!==ze?(qe=on(ze),e[61]=ze,e[62]=qe):qe=e[62];const Ke=qe;let _e;e[63]!==Ke?(_e=we=>{we.currentTarget.setPointerCapture(we.pointerId),Be(!0),Oe(Ke)},e[63]=Ke,e[64]=_e):_e=e[64];const et=_e;let dt;e[65]===Symbol.for("react.memo_cache_sentinel")?(dt=we=>{if(!we.currentTarget.hasPointerCapture(we.pointerId))return;const Ze=we.currentTarget.closest("nav")?.getBoundingClientRect().right??0;Oe(on(Ze-we.clientX))},e[65]=dt):dt=e[65];const je=dt;let Xe;e[66]!==Me?(Xe=we=>{we.currentTarget.hasPointerCapture(we.pointerId)&&we.currentTarget.releasePointerCapture(we.pointerId),Be(!1),Oe(Ze=>(Ze!==null&&Me(on(Ze)),null))},e[66]=Me,e[67]=Xe):Xe=e[67];const tt=Xe;let Je;e[68]!==l||e[69]!==a||e[70]!==n?(Je={projectRef:n,canCreateWorktree:l,onActionComplete:a},e[68]=l,e[69]=a,e[70]=n,e[71]=Je):Je=e[71];const Ce=iu(Je);let it,Fe;e[72]!==x||e[73]!==n?(it=()=>{n&&x(n)},Fe=[x,n],e[72]=x,e[73]=n,e[74]=it,e[75]=Fe):(it=e[74],Fe=e[75]),m.useEffect(it,Fe);const $e=m.useRef(null);let st,Re;e[76]!==f.error||e[77]!==f.loaded||e[78]!==d?(st=()=>{if(!f.error){$e.current=null;return}$e.current!==f.error&&($e.current=f.error,f.loaded||Se.error(d("rightSidebar.contextNotesTodo.toast.loadNotesFailed")))},Re=[f.error,f.loaded,d],e[76]=f.error,e[77]=f.loaded,e[78]=d,e[79]=st,e[80]=Re):(st=e[79],Re=e[80]),m.useEffect(st,Re);let Qe;e[81]===Symbol.for("react.memo_cache_sentinel")?(Qe=()=>{te(null)},e[81]=Qe):Qe=e[81];let ut;e[82]!==h?(ut=[h],e[82]=h,e[83]=ut):ut=e[83],m.useEffect(Qe,ut);let lt,mt;e[84]!==Q?(lt=()=>{Q!=="plans"&&te(null)},mt=[Q],e[84]=Q,e[85]=lt,e[86]=mt):(lt=e[85],mt=e[86]),m.useEffect(lt,mt);let y;e[87]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{oe("")},e[87]=y):y=e[87];let G;e[88]!==h?(G=[h],e[88]=h,e[89]=G):G=e[89],m.useEffect(y,G);let ke,Ue;e[90]!==Q||e[91]!==W||e[92]!==R||e[93]!==re?(ke=()=>{if(!re||W[Q]>0)return;const we=xr.find(Ze=>W[Ze]>0);we&&R(we)},Ue=[Q,W,R,re],e[90]=Q,e[91]=W,e[92]=R,e[93]=re,e[94]=ke,e[95]=Ue):(ke=e[94],Ue=e[95]),m.useEffect(ke,Ue);let De;e[96]!==n||e[97]!==g||e[98]!==d?(De=we=>{n&&g(n,we).then(Ze=>{Ze||Se.error(d("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[96]=n,e[97]=g,e[98]=d,e[99]=De):De=e[99];const I=De;let ae;e[100]!==d?(ae=d("rightSidebar.contextNotesTodo.tabs.notes"),e[100]=d,e[101]=ae):ae=e[101];const xe=String(W.notes);let ue;e[102]!==ae||e[103]!==xe?(ue={id:"notes",icon:"sticky-note",label:ae,count:xe},e[102]=ae,e[103]=xe,e[104]=ue):ue=e[104];let Le;e[105]!==d?(Le=d("rightSidebar.contextNotesTodo.tabs.todos"),e[105]=d,e[106]=Le):Le=e[106];const T=String(W.todos);let X;e[107]!==Le||e[108]!==T?(X={id:"todos",icon:"checkbox-circle",label:Le,count:T},e[107]=Le,e[108]=T,e[109]=X):X=e[109];let me;e[110]!==d?(me=d("rightSidebar.contextNotesTodo.tabs.plans"),e[110]=d,e[111]=me):me=e[111];const Ge=String(W.plans);let be;e[112]!==me||e[113]!==Ge?(be={id:"plans",icon:"file-text",label:me,count:Ge},e[112]=me,e[113]=Ge,e[114]=be):be=e[114];let Ae;e[115]!==W.memory||e[116]!==Ie||e[117]!==_||e[118]!==d?(Ae=_?[{id:"memory",icon:"brain-4",label:d("rightSidebar.contextNotesTodo.tabs.memory"),count:Ie>0?`${Ie}/${W.memory}`:String(W.memory)}]:[],e[115]=W.memory,e[116]=Ie,e[117]=_,e[118]=d,e[119]=Ae):Ae=e[119];let rt;e[120]!==ue||e[121]!==X||e[122]!==be||e[123]!==Ae?(rt=[ue,X,be,...Ae],e[120]=ue,e[121]=X,e[122]=be,e[123]=Ae,e[124]=rt):rt=e[124];const Pe=rt;if(!n){let we;e[125]!==c?(we=ie("w-full min-w-0 p-3",c),e[125]=c,e[126]=we):we=e[126];let Ze;e[127]!==d?(Ze=d("rightSidebar.contextNotesTodo.empty.selectProject"),e[127]=d,e[128]=Ze):Ze=e[128];let vt;e[129]!==Ze?(vt=t.jsx("p",{className:"typography-meta text-muted-foreground",children:Ze}),e[129]=Ze,e[130]=vt):vt=e[130];let Ft;return e[131]!==we||e[132]!==vt?(Ft=t.jsx("div",{className:we,children:vt}),e[131]=we,e[132]=vt,e[133]=Ft):Ft=e[133],Ft}let ce;e[134]!==r||e[135]!==n.path?(ce=r?.trim()||n.path.split("/").filter(Boolean).pop()||n.path,e[134]=r,e[135]=n.path,e[136]=ce):ce=e[136];const Ye=ce;let ct;e[137]!==c?(ct=ie("flex h-full min-h-0 w-full min-w-0 flex-col",c),e[137]=c,e[138]=ct):ct=e[138];let pt;e[139]!==Z||e[140]!==d?(pt=Z?t.jsx("button",{type:"button",onClick:()=>te(null),className:"inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":d("rightSidebar.contextNotesTodo.plans.actions.back"),title:d("rightSidebar.contextNotesTodo.plans.actions.back"),children:t.jsx(E,{name:"arrow-left-s",className:"h-4 w-4"})}):null,e[139]=Z,e[140]=d,e[141]=pt):pt=e[141];let bt;e[142]!==n.path||e[143]!==Ye?(bt=t.jsx("h3",{className:"min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",title:n.path,children:Ye}),e[142]=n.path,e[143]=Ye,e[144]=bt):bt=e[144];let St;e[145]===Symbol.for("react.memo_cache_sentinel")?(St=t.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e[145]=St):St=e[145];let Nt;e[146]===Symbol.for("react.memo_cache_sentinel")?(Nt=we=>oe(we.target.value),e[146]=Nt):Nt=e[146];let wt;e[147]!==d?(wt=d("rightSidebar.contextNotesTodo.search.placeholder"),e[147]=d,e[148]=wt):wt=e[148];let jt;e[149]!==q||e[150]!==wt?(jt=t.jsx(yt,{value:q,onChange:Nt,placeholder:wt,className:"h-8 pl-7 pr-7"}),e[149]=q,e[150]=wt,e[151]=jt):jt=e[151];let Ct;e[152]!==q||e[153]!==d?(Ct=q?t.jsx("button",{type:"button",onClick:()=>oe(""),className:"absolute right-1.5 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":d("rightSidebar.contextNotesTodo.search.clear"),title:d("rightSidebar.contextNotesTodo.search.clear"),children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null,e[152]=q,e[153]=d,e[154]=Ct):Ct=e[154];let Et;e[155]!==jt||e[156]!==Ct?(Et=t.jsxs("div",{className:"relative w-40 flex-shrink-0",children:[St,jt,Ct]}),e[155]=jt,e[156]=Ct,e[157]=Et):Et=e[157];let _t;e[158]!==pt||e[159]!==bt||e[160]!==Et?(_t=t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2 p-3 pb-2",children:[pt,bt,Et]}),e[158]=pt,e[159]=bt,e[160]=Et,e[161]=_t):_t=e[161];let Mt;e[162]!==Q||e[163]!==z||e[164]!==Pe||e[165]!==R||e[166]!==d?(Mt=z?t.jsx("nav",{className:"flex flex-shrink-0 items-center gap-1.5 overflow-x-auto px-3 pb-2","aria-label":d("rightSidebar.contextNotesTodo.sections.label"),children:Pe.map(we=>{const Ze=Q===we.id;return t.jsxs("button",{type:"button",onClick:()=>R(we.id),"aria-current":Ze?"page":void 0,className:ie("flex flex-shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Ze?"border-transparent bg-interactive-active text-foreground":"border-[var(--interactive-border)] text-muted-foreground"),children:[t.jsx(E,{name:we.icon,className:"h-4 w-4 flex-shrink-0"}),Ze?t.jsx("span",{className:"whitespace-nowrap typography-meta",children:we.label}):null,t.jsx("span",{className:"typography-micro text-muted-foreground",children:we.count})]},we.id)})}):null,e[162]=Q,e[163]=z,e[164]=Pe,e[165]=R,e[166]=d,e[167]=Mt):Mt=e[167];const Xt=Z?"overflow-hidden":"overflow-y-auto";let ht;e[168]!==Xt?(ht=ie("min-h-0 min-w-0 flex-1 p-3",Xt),e[168]=Xt,e[169]=ht):ht=e[169];let Zt;e[170]!==Q||e[171]!==f.notes||e[172]!==fe||e[173]!==H||e[174]!==n||e[175]!==q||e[176]!==$?(Zt=Q==="notes"?t.jsx(Gd,{projectRef:n,notes:f.notes,disabled:fe,query:q,pinnedNoteIds:H,onTogglePinned:(we,Ze)=>$("note",we,Ze)}):null,e[170]=Q,e[171]=f.notes,e[172]=fe,e[173]=H,e[174]=n,e[175]=q,e[176]=$,e[177]=Zt):Zt=e[177];let es;e[178]!==Q||e[179]!==l||e[180]!==I||e[181]!==fe||e[182]!==q||e[183]!==Ce.sendToCurrentSession||e[184]!==Ce.sendToNewSession||e[185]!==Ce.sendToNewWorktreeSession||e[186]!==Ce.sendingTodoId||e[187]!==se?(es=Q==="todos"?t.jsx(tu,{todos:se,query:q,disabled:fe,canCreateWorktree:l,sendingTodoId:Ce.sendingTodoId,onPersistTodos:I,onSendToCurrentSession:Ce.sendToCurrentSession,onSendToNewSession:Ce.sendToNewSession,onSendToNewWorktreeSession:Ce.sendToNewWorktreeSession}):null,e[178]=Q,e[179]=l,e[180]=I,e[181]=fe,e[182]=q,e[183]=Ce.sendToCurrentSession,e[184]=Ce.sendToNewSession,e[185]=Ce.sendToNewWorktreeSession,e[186]=Ce.sendingTodoId,e[187]=se,e[188]=es):es=e[188];let ts;e[189]!==Q||e[190]!==_||e[191]!==n.path||e[192]!==q?(ts=Q==="memory"&&_?t.jsx(Md,{projectPath:n.path,query:q}):null,e[189]=Q,e[190]=_,e[191]=n.path,e[192]=q,e[193]=ts):ts=e[193];let ss;e[194]!==Q||e[195]!==f.plans||e[196]!==i||e[197]!==Z||e[198]!==ee||e[199]!==n||e[200]!==q||e[201]!==$?(ss=Q==="plans"&&!Z?t.jsx(Qd,{projectRef:n,plans:f.plans,query:q,pinnedPlanIds:ee,onTogglePinned:(we,Ze)=>$("plan",we,Ze),onOpenPlan:i??te}):null,e[194]=Q,e[195]=f.plans,e[196]=i,e[197]=Z,e[198]=ee,e[199]=n,e[200]=q,e[201]=$,e[202]=ss):ss=e[202];let ns;e[203]!==Q||e[204]!==Z||e[205]!==n?(ns=Q==="plans"&&Z&&n?t.jsx(m.Suspense,{fallback:null,children:t.jsx(lu,{savedProjectPlan:{projectRef:n,planId:Z.id},onNavigatedToChat:()=>te(null)})}):null,e[203]=Q,e[204]=Z,e[205]=n,e[206]=ns):ns=e[206];let rs;e[207]!==ht||e[208]!==Zt||e[209]!==es||e[210]!==ts||e[211]!==ss||e[212]!==ns?(rs=t.jsxs("div",{className:ht,children:[Zt,es,ts,ss,ns]}),e[207]=ht,e[208]=Zt,e[209]=es,e[210]=ts,e[211]=ss,e[212]=ns,e[213]=rs):rs=e[213];let os;e[214]!==Q||e[215]!==tt||e[216]!==et||e[217]!==z||e[218]!==ve||e[219]!==Pe||e[220]!==R||e[221]!==Ke||e[222]!==d?(os=z?null:t.jsxs("nav",{className:"relative flex flex-shrink-0 flex-col gap-0.5 overflow-y-auto border-l border-[var(--interactive-border)] p-2",style:{width:`${Ke}px`},"aria-label":d("rightSidebar.contextNotesTodo.sections.label"),children:[t.jsx("div",{className:ie("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",ve&&"bg-[var(--interactive-border)]"),onPointerDown:et,onPointerMove:je,onPointerUp:tt,onPointerCancel:tt,role:"separator","aria-orientation":"vertical","aria-label":d("rightSidebar.contextNotesTodo.sections.resize")}),Pe.map(we=>{const Ze=Q===we.id;return t.jsxs("button",{type:"button",onClick:()=>R(we.id),"aria-current":Ze?"page":void 0,className:ie("flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Ze?"bg-interactive-active text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),style:{minHeight:0},children:[t.jsx(E,{name:we.icon,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:we.label}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:we.count})]},we.id)})]}),e[214]=Q,e[215]=tt,e[216]=et,e[217]=z,e[218]=ve,e[219]=Pe,e[220]=R,e[221]=Ke,e[222]=d,e[223]=os):os=e[223];let as;e[224]!==rs||e[225]!==os?(as=t.jsxs("div",{className:"flex min-h-0 flex-1",children:[rs,os]}),e[224]=rs,e[225]=os,e[226]=as):as=e[226];const Ys=Ce.pendingSendTarget!==null;let is;e[227]!==Ce?(is=we=>{we||Ce.closeDialog()},e[227]=Ce,e[228]=is):is=e[228];const Js=Ce.pendingSendTarget?.kind??"session";let ls;e[229]!==n.path||e[230]!==Ce.confirmSend||e[231]!==Ce.isSubmitting||e[232]!==Ys||e[233]!==is||e[234]!==Js?(ls=t.jsx(El,{open:Ys,onOpenChange:is,target:Js,projectDirectory:n.path,submitting:Ce.isSubmitting,onConfirm:Ce.confirmSend}),e[229]=n.path,e[230]=Ce.confirmSend,e[231]=Ce.isSubmitting,e[232]=Ys,e[233]=is,e[234]=Js,e[235]=ls):ls=e[235];let Ps;return e[236]!==ct||e[237]!==_t||e[238]!==Mt||e[239]!==as||e[240]!==ls?(Ps=t.jsxs("div",{className:ct,children:[_t,Mt,as,ls]}),e[236]=ct,e[237]=_t,e[238]=Mt,e[239]=as,e[240]=ls,e[241]=Ps):Ps=e[241],Ps};function mu(s){return s.load}function hu(s){return s.saveTodos}function pu(s){return s.currentSessionId}function gu(s){return s.currentSessionDirectory}function xu(s){return s.newSessionDraft}function bu(s){return s.setDraftProjectContextPin}function yu(s){return s.id}function wu(s){return s.id}function vu(s){return s.agentMemoryFeatureAvailable&&s.agentMemoryToolEnabled}function Su(s){return s.disabled}function ju(s){return s.global}function ku(s){return s.isMobile}function Nu(s){return s.projectContextTab}function Iu(s){return s.setProjectContextTab}function Cu(s){return s.agentMemoryViewedAt[Fn("global",null)]??0}function Tu(s){return s.projectContextSidebarWidth}function Du(s){return s.setProjectContextSidebarWidth}const Pu=({projects:s,worktreesByProject:e,directory:n,activeProjectId:r,chatDraftOpen:o,chatDraftTarget:a,homeDirectory:i})=>{const c=ti(n)??si(i),l=jn(n),d=jn(c);if((o?a==="chat":!!(l&&d&&(l===d||l.startsWith(`${d}/`))))&&c)return{id:Sn,path:c};const h=ni(s,e,n);if(h)return{id:h.id,path:h.path};if(l)return null;const b=s.find(f=>f.id===r)??null;return b?{id:b.id,path:b.path}:null},Ru=s=>{const e=Ve.c(8),n=It(Eu),r=It(Au),o=gs(Bu),a=at(Lu),i=at(Mu),c=at(Fu);let l;return e[0]!==r||e[1]!==i||e[2]!==c||e[3]!==s||e[4]!==o||e[5]!==n||e[6]!==a?(l=Pu({projects:n,worktreesByProject:a,directory:s,activeProjectId:r,chatDraftOpen:i,chatDraftTarget:c,homeDirectory:o}),e[0]=r,e[1]=i,e[2]=c,e[3]=s,e[4]=o,e[5]=n,e[6]=a,e[7]=l):l=e[7],l};function Eu(s){return s.projects}function Au(s){return s.activeProjectId}function Bu(s){return s.homeDirectory}function Lu(s){return s.availableWorktreesByProject}function Mu(s){return s.newSessionDraft.open}function Fu(s){return s.newSessionDraft.target}const Qf=s=>{const e=Ve.c(18),{onActionComplete:n,onOpenPlan:r}=s,o=gs(Ou),{t:a}=nt(),i=Bn($u),c=at(Uu),l=Ru(c),d=It(Wu);let u;e[0]!==l||e[1]!==d?(u=l?d.find(p=>p.id===l.id)??null:null,e[0]=l,e[1]=d,e[2]=u):u=e[2];const h=u;let b;e:{if(!l){b=null;break e}if(l.id===Sn){let k;e[3]!==a?(k=a("sessions.sidebar.activity.chatsTitle"),e[3]=a,e[4]=k):k=e[4],b=k;break e}let p;e[5]!==o||e[6]!==h?.label||e[7]!==l.path?(p=h?.label?.trim()||ri(l.path,o)||l.path,e[5]=o,e[6]=h?.label,e[7]=l.path,e[8]=p):p=e[8],b=p}const f=b;let x;e:{if(!l||l.id===Sn){x=!1;break e}let p;e[9]!==i||e[10]!==l.path?(p=i.get(l.path)?.isGitRepo,e[9]=i,e[10]=l.path,e[11]=p):p=e[11],x=p===!0}const g=x;let j;return e[12]!==g||e[13]!==n||e[14]!==r||e[15]!==f||e[16]!==l?(j=t.jsx("div",{className:"h-full min-h-0 overflow-hidden bg-background",children:t.jsx(fu,{projectRef:l,projectLabel:f,canCreateWorktree:g,onActionComplete:n,onOpenPlan:r})}),e[12]=g,e[13]=n,e[14]=r,e[15]=f,e[16]=l,e[17]=j):j=e[17],j};function Ou(s){return s.homeDirectory}function $u(s){return s.directories}function Uu(s){return s.currentSessionDirectory}function Wu(s){return s.projects}const $s=Object.freeze({chunks:Object.freeze([]),byteLength:0,lastSequence:-1}),Cn=512*1024,_u=new TextEncoder,Vu=new TextDecoder,an=s=>{const e=_u.encode(s);if(e.byteLength<=Cn)return{text:s,byteLength:e.byteLength};let n=e.byteLength-Cn;for(;n<e.byteLength&&(e[n]&192)===128;)n+=1;const r=e.subarray(n);return{text:Vu.decode(r),byteLength:r.byteLength}},Kt=(s,e)=>`${s}\0${e}`,ln=(s,e)=>{let n=null;for(const r of s.keys())e(r)&&(n??=new Map(s),n.delete(r));return n},zu="terminal-store";let br=!1,yr=0;const Ms=()=>typeof globalThis.crypto?.randomUUID=="function"?`tab-${globalThis.crypto.randomUUID()}`:(yr+=1,`tab-${Date.now().toString(36)}-${yr.toString(36)}`),cn=s=>typeof s=="object"&&s!==null,Gu=s=>{const e=/^tab-(\d+)$/.exec(s);if(!e)return null;const n=Number(e[1]);return Number.isFinite(n)?n:null};function xt(s){let e=s.trim();for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e}const Hu=/^Terminal(?: (\d+))?$/,wr=s=>{let e=0;for(const n of s){const r=Hu.exec(n.label);if(!r)continue;const o=r[1]?Number.parseInt(r[1],10):1;Number.isSafeInteger(o)&&(e=Math.max(e,o))}return e===0?"Terminal":`Terminal ${e+1}`},Fs=(s,e)=>({id:s,terminalSessionId:null,lifecycle:"idle",label:e,iconKey:null,isConnecting:!1,createdAt:Date.now(),previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1}),dn=s=>({tabs:[s],activeTabId:s.id}),Tt=(s,e)=>s.tabs.findIndex(n=>n.id===e);let un=null,fn=null;const Ku=s=>{if(fn&&un?.sessions===s.sessions&&un.nextTabId===s.nextTabId)return fn;const e={sessions:Array.from(s.sessions.entries()).map(([n,r])=>[n,{activeTabId:r.activeTabId,tabs:r.tabs.map(o=>({id:o.id,label:o.label,iconKey:o.iconKey,createdAt:o.createdAt}))}]),nextTabId:s.nextTabId};return un={sessions:s.sessions,nextTabId:s.nextTabId},fn=e,e},qu=()=>{const s=Gi(()=>Ri());if(!s)return;let e=null;return{getItem:n=>s.getItem(n),setItem:(n,r)=>{if(r.state!==e)return e=r.state,s.setItem(n,r)},removeItem:n=>(e=null,s.removeItem(n))}},ot=qs()(Gr(Hr((s,e)=>({sessions:new Map,buffers:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1,hasHydrated:typeof window>"u",ensureDirectory:n=>{const r=xt(n);r&&s(o=>{if(o.sessions.has(r))return o;const a=new Map(o.sessions),i=Ms(),c=Fs(i,"Terminal");return a.set(r,dn(c)),{sessions:a,nextTabId:o.nextTabId+1}})},getDirectoryState:n=>{const r=xt(n);return e().sessions.get(r)},getActiveTab:n=>{const r=xt(n),o=e().sessions.get(r);if(!o)return;const a=o.activeTabId;return a?o.tabs.find(i=>i.id===a)??o.tabs[0]:o.tabs[0]},getBuffer:(n,r)=>e().buffers.get(Kt(xt(n),r))??$s,createTab:n=>{const r=xt(n);if(!r)return"tab-invalid";const o=Ms();return s(a=>{const i=new Map(a.sessions),c=i.get(r),l=a.nextTabId+1,d=wr(c?.tabs??[]),u=Fs(o,d);return c?i.set(r,{...c,tabs:[...c.tabs,u]}):i.set(r,dn(u)),{sessions:i,nextTabId:l}}),o},adoptServerSessions:(n,r)=>{const o=xt(n);!o||r.length===0||s(a=>{const i=a.sessions.get(o),c=new Set;for(const x of i?.tabs??[])c.add(x.id),x.terminalSessionId&&c.add(x.terminalSessionId);const l=r.filter(x=>!c.has(x.sessionId));if(l.length===0)return a;const d=[...i?.tabs??[]],u=d.length===1&&d[0].terminalSessionId===null&&d[0].lifecycle==="idle"&&!a.buffers.has(Kt(o,d[0].id))?d[0]:null;u&&(d.length=0);for(const x of l){const g={...Fs(x.sessionId,u&&d.length===0?u.label:wr(d)),terminalSessionId:x.sessionId,lifecycle:x.status,createdAt:x.createdAt??Date.now()};d.push(g)}const h=i?.activeTabId??null,b=h&&d.some(x=>x.id===h)?h:d[0]?.id??null,f=new Map(a.sessions);return f.set(o,{tabs:d,activeTabId:b}),{sessions:f}})},setActiveTab:(n,r)=>{const o=xt(n);s(a=>{const i=new Map(a.sessions),c=i.get(o);return!c||c.activeTabId===r||Tt(c,r)<0?a:(i.set(o,{...c,activeTabId:r}),{sessions:i})})},setTabLabel:(n,r,o)=>{const a=xt(n),i=o.trim();i&&s(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=Tt(d,r);if(u<0||d.tabs[u]?.label===i)return c;const h=[...d.tabs];return h[u]={...h[u],label:i},l.set(a,{...d,tabs:h}),{sessions:l}})},setTabIconKey:(n,r,o)=>{const a=xt(n);s(i=>{const c=new Map(i.sessions),l=c.get(a);if(!l)return i;const d=Tt(l,r);if(d<0)return i;const u=o?.trim()||null;if(l.tabs[d]?.iconKey===u)return i;const h=[...l.tabs];return h[d]={...h[d],iconKey:u},c.set(a,{...l,tabs:h}),{sessions:c}})},closeTab:(n,r)=>{const o=xt(n);s(a=>{const i=new Map(a.sessions),c=i.get(o);if(!c)return a;const l=Tt(c,r);if(l<0)return a;const d=c.tabs.filter(g=>g.id!==r),u=Object.fromEntries(Object.entries(a.projectActionRuns).filter(([,g])=>!(g.directory===o&&g.tabId===r))),h=Object.keys(u).length!==Object.keys(a.projectActionRuns).length,b=Kt(o,r),f=a.buffers.has(b)?ln(a.buffers,g=>g===b):null;if(d.length===0){const g=Ms(),j=Fs(g,"Terminal");return i.set(o,dn(j)),{sessions:i,nextTabId:a.nextTabId+1,...f?{buffers:f}:{},...h?{projectActionRuns:u}:{}}}let x=c.activeTabId;return c.activeTabId===r&&(x=d[Math.min(l,d.length-1)]?.id??d[0]?.id??null),i.set(o,{...c,tabs:d,activeTabId:x}),{sessions:i,...f?{buffers:f}:{},...h?{projectActionRuns:u}:{}}})},setTabSessionId:(n,r,o)=>{const a=xt(n);s(i=>{const c=new Map(i.sessions),l=c.get(a);if(!l)return i;const d=Tt(l,r);if(d<0)return i;const u=l.tabs[d],h=o!==null&&u.terminalSessionId!==o,b=o?"running":u.terminalSessionId?"exited":u.lifecycle,f={...u,terminalSessionId:o,lifecycle:b,isConnecting:!1},x=Kt(a,r),g=h&&i.buffers.has(x)?ln(i.buffers,p=>p===x):null,j=[...l.tabs];return j[d]=f,c.set(a,{...l,tabs:j}),{sessions:c,...g?{buffers:g}:{}}})},setTabLifecycle:(n,r,o)=>{const a=xt(n);s(i=>{const c=new Map(i.sessions),l=c.get(a);if(!l)return i;const d=Tt(l,r);if(d<0)return i;const u=[...l.tabs];return u[d]={...u[d],lifecycle:o,isConnecting:!1},c.set(a,{...l,tabs:u}),{sessions:c}})},setConnecting:(n,r,o)=>{const a=xt(n);s(i=>{const c=new Map(i.sessions),l=c.get(a);if(!l)return i;const d=Tt(l,r);if(d<0)return i;const u=[...l.tabs];return u[d]={...u[d],isConnecting:o},c.set(a,{...l,tabs:u}),{sessions:c}})},replaceBuffer:(n,r,o,a)=>{const i=xt(n);s(c=>{const l=c.sessions.get(i);if(!l||Tt(l,r)<0)return c;const d=Kt(i,r),u=c.buffers.get(d)??$s;if(u.lastSequence>a)return c;const h=an(o);if(u.lastSequence===a&&u.byteLength===h.byteLength&&u.chunks.map(x=>x.data).join("")===h.text)return c;const b=c.nextChunkId,f=new Map(c.buffers);return f.set(d,{chunks:h.text?[{id:b,data:h.text,byteLength:h.byteLength}]:[],byteLength:h.byteLength,lastSequence:a}),{buffers:f,nextChunkId:h.text?b+1:b}})},appendToBuffer:(n,r,o,a,i)=>{if(!o)return;const c=xt(n);s(l=>{const d=l.sessions.get(c);if(!d||Tt(d,r)<0)return l;const u=Kt(c,r),h=l.buffers.get(u)??$s;if(a!==void 0&&a<=h.lastSequence)return l;const b=l.nextChunkId,f=an(o),x=i!==void 0&&i!==o?an(i).text:void 0,g={id:b,data:f.text,...x!==void 0?{replayData:x}:{},byteLength:f.byteLength},j=[...h.chunks,g];let p=h.byteLength+g.byteLength;for(;p>Cn&&j.length>1;){const P=j.shift();if(!P)break;p-=P.byteLength}const k=new Map(l.buffers);return k.set(u,{chunks:j,byteLength:p,lastSequence:a??h.lastSequence}),{buffers:k,nextChunkId:b+1}})},setTabPreviewUrl:(n,r,o,a={})=>{const i=xt(n);s(c=>{const l=new Map(c.sessions),d=l.get(i);if(!d)return c;const u=Tt(d,r);if(u<0)return c;const h=d.tabs[u],b=a.autoOpened??h.previewAutoOpened,f=a.locked??h.previewUrlLocked;if(h.previewUrl===o&&h.previewAutoOpened===b&&h.previewUrlLocked===f)return c;const x=[...d.tabs];return x[u]={...h,previewUrl:o,previewAutoOpened:b,previewUrlLocked:f},l.set(i,{...d,tabs:x}),{sessions:l}})},markPreviewAutoOpened:(n,r)=>{const o=xt(n);s(a=>{const i=new Map(a.sessions),c=i.get(o);if(!c)return a;const l=Tt(c,r);if(l<0)return a;const d=c.tabs[l];if(!d.previewUrl||d.previewAutoOpened)return a;const u=[...c.tabs];return u[l]={...d,previewAutoOpened:!0},i.set(o,{...c,tabs:u}),{sessions:i}})},setProjectActionRun:n=>{s(r=>{const o=r.projectActionRuns[n.key];return o&&o.directory===n.directory&&o.actionId===n.actionId&&o.tabId===n.tabId&&o.sessionId===n.sessionId&&o.status===n.status?r:{projectActionRuns:{...r.projectActionRuns,[n.key]:n}}})},updateProjectActionRunStatus:(n,r)=>{s(o=>{const a=o.projectActionRuns[n];return!a||a.status===r?o:{projectActionRuns:{...o.projectActionRuns,[n]:{...a,status:r}}}})},removeProjectActionRun:n=>{s(r=>{if(!r.projectActionRuns[n])return r;const o={...r.projectActionRuns};return delete o[n],{projectActionRuns:o}})},removeDirectory:n=>{const r=xt(n);s(o=>{const a=new Map(o.sessions);a.delete(r);const i=Kt(r,""),c=ln(o.buffers,d=>d.startsWith(i)),l=Object.fromEntries(Object.entries(o.projectActionRuns).filter(([,d])=>d.directory!==r));return{sessions:a,...c?{buffers:c}:{},projectActionRuns:l}})},clearAll:()=>{s({sessions:new Map,buffers:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1})}}),{name:zu,storage:qu(),partialize:Ku,merge:(s,e)=>{if(!cn(s))return e;const n=Array.isArray(s.sessions)?s.sessions:[],r=new Map;let o=0;for(const c of n){if(!Array.isArray(c)||c.length!==2)continue;const[l,d]=c;if(typeof l!="string"||!cn(d))continue;const u=Array.isArray(d.tabs)?d.tabs:[],h=[],b=new Map;for(const j of u){if(!cn(j))continue;const p=typeof j.id=="string"?j.id:null;if(!p)continue;const k=Gu(p);k!==null&&(o=Math.max(o,k));const P=k===null?p:Ms();b.set(p,P),h.push({id:P,label:typeof j.label=="string"?j.label:"Terminal",iconKey:typeof j.iconKey=="string"?j.iconKey:null,terminalSessionId:null,lifecycle:"idle",createdAt:typeof j.createdAt=="number"?j.createdAt:Date.now(),isConnecting:!1,previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1})}if(h.length===0)continue;const f=typeof d.activeTabId=="string"?d.activeTabId:null,x=f?b.get(f)??f:null,g=x?h.some(j=>j.id===x):!1;r.set(l,{tabs:h,activeTabId:g?x:h[0].id})}const a=typeof s.nextTabId=="number"&&Number.isFinite(s.nextTabId)?s.nextTabId:1,i=Math.max(e.nextTabId,a,o+1);return{...e,sessions:r,buffers:new Map,nextChunkId:1,nextTabId:i,hasHydrated:!0}}})));if(typeof window<"u"&&!br){br=!0;const s=ot.persist,e=()=>{ot.getState().hasHydrated||ot.setState({hasHydrated:!0})};s?.hasHydrated?.()?e():s?.onFinishHydration?s.onFinishHydration(e):e()}function Yu(s){const{colors:e}=s,n=e.syntax.base;return{background:e.surface.background,foreground:n.foreground,cursor:e.interactive.cursor,cursorAccent:e.surface.background,selectionBackground:e.interactive.selection,selectionForeground:e.interactive.selectionForeground,selectionInactiveBackground:e.interactive.selection+"50",black:e.surface.muted,red:e.status.error,green:e.status.success,yellow:e.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:e.status.error,brightGreen:e.status.success,brightYellow:e.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:e.surface.elevatedForeground}}function Ju(s,e,n,r,o=!1){const i=`${s}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`;return{cursorBlink:!1,cursorStyle:"bar",fontSize:e,fontFamily:i,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:o}}const mn=["\x1B[0m","\x1B[m"],Qu=s=>{const e=s.trim(),n=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e)?.[1];if(n){const a=n.length<=4?n.slice(0,3).split("").map(i=>i+i).join(""):n.slice(0,6);return[Number.parseInt(a.slice(0,2),16),Number.parseInt(a.slice(2,4),16),Number.parseInt(a.slice(4,6),16)]}const r=/^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})(?:\s*[,/]\s*[\d.]+)?\s*\)$/i.exec(e);if(!r)return null;const o=r.slice(1,4).map(Number);return o.some(a=>a<0||a>255)?null:o},vr=s=>{const e=Qu(s);return e?`\x1B[0;48;2;${e[0]};${e[1]};${e[2]}m`:null},Xu=(s,e,n)=>{const r=e+s;if(!n)return{data:r,carry:""};let o=0;const a=Math.max(...mn.map(l=>l.length))-1;for(let l=1;l<=Math.min(a,r.length);l+=1){const d=r.slice(-l);mn.some(u=>u.length>d.length&&u.startsWith(d))&&(o=l)}const i=o>0?r.slice(-o):"";let c=o>0?r.slice(0,-o):r;for(const l of mn)c=c.replaceAll(l,n);return{data:c,carry:i}},Zu=(s,e,n,r,o)=>{if(n.width<=0||n.height<=0||r<=0||o<=0)return null;const a=Math.floor((s-n.left)/n.width*r),i=Math.floor((e-n.top)/n.height*o);return{column:Math.max(0,Math.min(r-1,a)),row:Math.max(0,Math.min(o-1,i))}},ef=(s,e)=>{const n=Math.max(0,Math.min(s.length-1,e)),r=i=>!!(i&&!/^\s+$/u.test(i));if(!r(s[n]))return{startColumn:n,endColumn:n};let o=n,a=n;for(;o>0&&r(s[o-1]);)o-=1;for(;a<s.length-1&&r(s[a+1]);)a+=1;return{startColumn:o,endColumn:a}};let tf=null;const sf=()=>tf??=Qt(()=>import("./vendor-ghostty-web-CrxinGGH.js"),__vite__mapDeps([122,5])).then(async s=>({module:s,ghostty:await s.Ghostty.load()})),nf=2e3,rf=()=>{if(typeof window>"u")return Promise.resolve();const s=window.__aiworkerEnsureNerdFonts;return typeof s!="function"?Promise.resolve():Promise.race([Promise.resolve(s()).catch(()=>{}),new Promise(e=>setTimeout(e,nf))]).then(()=>{})},of=(s,e,n)=>{if(typeof window>"u"||typeof document>"u")return null;const r=document.createElement("canvas").getContext("2d");if(!r||s.clientWidth<24||s.clientHeight<24)return null;r.font=`${n}px ${e}`;const o=r.measureText("M"),a=Math.ceil(o.width),i=Math.ceil((o.actualBoundingBoxAscent||n*.8)+(o.actualBoundingBoxDescent||n*.2))+2;if(a<1||i<1)return null;const c=window.getComputedStyle(s),l=(Number.parseInt(c.paddingLeft,10)||0)+(Number.parseInt(c.paddingRight,10)||0),d=(Number.parseInt(c.paddingTop,10)||0)+(Number.parseInt(c.paddingBottom,10)||0);return{cols:Math.max(2,Math.floor((s.clientWidth-l-15)/a)),rows:Math.max(1,Math.floor((s.clientHeight-d)/i))}},yo=m.forwardRef(({sessionKey:s,chunks:e,onInput:n,onResize:r,theme:o,fontFamily:a,fontSize:i,className:c,enableTouchScroll:l=!1,autoFocus:d=!0,isVisible:u=!0},h)=>{const b=m.useRef(null),f=m.useRef(null),x=m.useRef(null),g=m.useRef(n),j=m.useRef(r),p=m.useRef(null),k=m.useRef(null),P=m.useRef(null),A=m.useRef(""),N=m.useRef(""),C=m.useRef(vr(o.background)),w=m.useRef(!1),v=m.useRef(0),L=m.useRef(u),$=m.useRef(!1),[M,H]=m.useState(0),[K,ee]=m.useState(0);g.current=n,j.current=r,L.current=u,C.current=vr(o.background),m.useLayoutEffect(()=>{const U=b.current;if(!U)return;const J=of(U,a,i);k.current=J,J&&j.current(J.cols,J.rows)},[a,i]);const Y=m.useCallback(()=>{const U=b.current,J=f.current;if(!U||!J||!x.current||!L.current)return;const D=U.getBoundingClientRect();if(!(D.width<24||D.height<24))try{x.current.fit();const z={cols:J.cols,rows:J.rows};(!p.current||p.current.cols!==z.cols||p.current.rows!==z.rows)&&(p.current=z,j.current(z.cols,z.rows)),$.current||($.current=!0,H(F=>F+1))}catch{}},[]),O=m.useCallback(()=>{if(w.current||!A.current||!f.current)return;const U=f.current,J=A.current;A.current="";const D=Xu(J,N.current,C.current);if(N.current=D.carry,!D.data){A.current&&O();return}w.current=!0;const z=v.current;U.write(D.data,()=>{f.current!==U||v.current!==z||(w.current=!1,A.current&&O())})},[]),_=m.useCallback(()=>{P.current=null,A.current="",N.current="",w.current=!1,v.current+=1;const U=f.current;if(!U){ee(J=>J+1);return}try{U.reset();const J=C.current;J&&U.write(`${J}\x1B[2J\x1B[H`)}catch{ee(J=>J+1)}},[]);return m.useEffect(()=>{const U=b.current;if(!U)return;let J=!1,D=null,z=null,F=null,R=null,V=[];const ne=()=>{D&&L.current&&(D.options.cursorBlink=!0)},Q=Z=>{Z.relatedTarget instanceof Node&&U.contains(Z.relatedTarget)||D&&(D.options.cursorBlink=!1)},q=()=>{D&&L.current&&U.contains(document.activeElement)&&(D.options.cursorBlink=!0)},oe=()=>{D&&(D.options.cursorBlink=!1)};return U.addEventListener("focusin",ne),U.addEventListener("focusout",Q),window.addEventListener("focus",q),window.addEventListener("blur",oe),Promise.all([sf(),rf()]).then(([{module:Z,ghostty:te}])=>{if(J)return;D=new Z.Terminal({...Ju(a,i,o,te,!1),...k.current??{}});const ye=new Z.FitAddon;D.loadAddon(ye),D.open(U),U.setAttribute("autocapitalize","off"),U.setAttribute("autocorrect","off"),U.setAttribute("spellcheck","false"),f.current=D,x.current=ye,V=[D.onData(ge=>g.current(ge))],z=new ResizeObserver(()=>{F&&clearTimeout(F),F=setTimeout(Y,80)}),z.observe(U),Y();const re=C.current;re&&D.write(`${re}\x1B[2J\x1B[H`),R=requestAnimationFrame(Y)}),()=>{J=!0;const Z=document.activeElement;Z instanceof HTMLElement&&U.contains(Z)&&(Z.blur(),window.Capacitor?.getPlatform?.()==="android"&&Qt(async()=>{const{Keyboard:ye}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:ye}},__vite__mapDeps([123,124])).then(({Keyboard:ye})=>ye.hide()).catch(()=>{})),z?.disconnect(),F&&clearTimeout(F),R!==null&&cancelAnimationFrame(R),U.removeEventListener("focusin",ne),U.removeEventListener("focusout",Q),window.removeEventListener("focus",q),window.removeEventListener("blur",oe),V.forEach(te=>te.dispose()),D?.dispose(),f.current=null,x.current=null,p.current=null,P.current=null,A.current="",N.current="",w.current=!1,v.current+=1,$.current=!1}},[Y,a,i,K,o]),m.useEffect(()=>{const U=f.current,J=b.current;!U||!J||(U.options.cursorBlink=u&&document.hasFocus()&&J.contains(document.activeElement))},[u,M]),m.useEffect(()=>{if(!f.current)return;if(e.length===0){P.current!==null&&_();return}const J=P.current;let D=-1;if(J!==null){for(let R=e.length-1;R>=0;R-=1){const V=e[R].id;if(V===J){D=R;break}if(V<J)break}if(D<0){_();return}}const z=D<0,F=D>=0?e.slice(D+1):e;A.current+=F.map(R=>z?R.replayData??R.data:R.data).join(""),P.current=e.at(-1)?.id??null,O()},[e,O,M,_]),m.useEffect(()=>{if(!d||!u)return;const U=requestAnimationFrame(()=>f.current?.focus());return()=>cancelAnimationFrame(U)},[d,u,M,s]),m.useEffect(()=>{const U=b.current;if(!l||!U)return;const J=D=>{const z=D;if(!z.isComposing)switch(z.inputType){case"insertText":z.data&&g.current(z.data);break;case"insertLineBreak":case"insertParagraph":g.current("\r");break;case"deleteContentBackward":g.current("");break}};return U.addEventListener("beforeinput",J),()=>U.removeEventListener("beforeinput",J)},[l,M]),m.useEffect(()=>{const U=b.current,J=f.current;if(!l||!U||!J)return;let D=null,z=null,F="idle",R=0,V=0,ne=0,Q=0,q=null;const oe=Math.max(12,i+2),Z=()=>{window.Capacitor?.getPlatform?.()==="android"&&Qt(async()=>{const{Keyboard:W}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:W}},__vite__mapDeps([123,124])).then(({Keyboard:W})=>W.show()).catch(()=>{})},te=()=>{z&&(clearTimeout(z),z=null)},ye=(B,W)=>{const le=U.querySelector("canvas");return le?Zu(B,W,le.getBoundingClientRect(),J.cols,J.rows):null},re=(B,W)=>{const le=U.querySelector("canvas");if(!le)return;const pe=le.getBoundingClientRect(),Te=pe.left+(W.column+.5)/J.cols*pe.width,Ie=pe.top+(W.row+.5)/J.rows*pe.height;le.dispatchEvent(new MouseEvent(B,{bubbles:!0,cancelable:!0,button:0,buttons:1,clientX:Te,clientY:Ie}))},ge=()=>{document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0,buttons:0}))},se=B=>{B.pointerType!=="touch"||D!==null||(D=B.pointerId,F="pending",R=B.clientX,V=B.clientY,ne=B.clientY,Q=0,q=null,U.setPointerCapture(B.pointerId),z=setTimeout(()=>{if(z=null,D!==B.pointerId||F!=="pending")return;const W=ye(R,V);if(!W)return;const le=J.buffer.active,pe=Math.max(0,le.length-J.rows-le.viewportY+W.row),Te=le.getLine(pe),Ie=Array.from({length:J.cols},(ve,Be)=>Te?.getCell(Be)?.getChars()??""),We=ef(Ie,W.column),Me={column:We.startColumn,row:W.row};q={column:We.endColumn,row:W.row},F="selecting",re("mousedown",Me),re("mousemove",q)},350))},fe=B=>{if(D!==B.pointerId)return;if(F==="selecting"){const pe=ye(B.clientX,B.clientY);pe&&(!q||pe.column!==q.column||pe.row!==q.row)&&(q=pe,re("mousemove",pe)),B.cancelable&&B.preventDefault();return}if(F==="pending"){if(Math.hypot(B.clientX-R,B.clientY-V)<8)return;te(),F="scrolling"}if(F!=="scrolling")return;const W=ne-B.clientY;ne=B.clientY,Q+=W;const le=Math.trunc(Q/oe);le&&(J.scrollLines(le),Q-=le*oe),B.cancelable&&B.preventDefault()},he=B=>{if(D!==B.pointerId)return;const W=F==="pending",le=F==="selecting";te(),U.hasPointerCapture(B.pointerId)&&U.releasePointerCapture(B.pointerId),D=null,F="idle",le&&ge(),W&&(J.focus(),Z())},S=B=>{if(D!==B.pointerId)return;const W=F==="selecting";te(),U.hasPointerCapture(B.pointerId)&&U.releasePointerCapture(B.pointerId),D=null,F="idle",W&&ge()};return U.addEventListener("pointerdown",se),U.addEventListener("pointermove",fe,{passive:!1}),U.addEventListener("pointerup",he),U.addEventListener("pointercancel",S),()=>{te(),U.removeEventListener("pointerdown",se),U.removeEventListener("pointermove",fe),U.removeEventListener("pointerup",he),U.removeEventListener("pointercancel",S)}},[l,i,M]),m.useImperativeHandle(h,()=>({focus:()=>f.current?.focus(),fit:Y,getSelection:()=>{const U=f.current,J=U?.getSelectionPosition(),D=U?.getSelection()??"";return!J||!D.trim()?null:{text:D,startLine:J.start.y+1,endLine:J.end.y+1}}}),[Y]),t.jsx("div",{ref:b,"data-terminal-owner":"main",className:ie("terminal-viewport-container h-full w-full overflow-hidden touch-none",c)})});yo.displayName="TerminalViewport";const af="\x1B",wo=new RegExp(`${af}\\[[0-9;?]*[ -/]*[@-~]`,"g"),lf=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,cf=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,df=/Serving HTTP on .*? port (\d{2,5})/i,uf=new Set([".",",",";",":","!","?"]),vo=s=>{let e=s;for(;e.length>0;){const n=e[e.length-1];if(n===")"||n==="]"||n==="}"||n===">"){const r=n===")"?"(":n==="]"?"[":n==="}"?"{":"<",o=e.slice(0,-1),a=(o.match(new RegExp(`\\${r}`,"g"))||[]).length,i=(o.match(new RegExp(`\\${n}`,"g"))||[]).length;if(a>i)break;e=o;continue}if(uf.has(n)){e=e.slice(0,-1);continue}break}return e},Tn=s=>{let e=vo(s);return e=e.replace("0.0.0.0","127.0.0.1"),e=e.replace("[::1]","127.0.0.1"),e=e.replace("[::]","127.0.0.1"),e},ff=s=>{if(!s)return[];const e=s.replace(wo,""),n=[],r=new Set,o=i=>{r.has(i)||(r.add(i),n.push(i))},a=e.match(df);if(a?.[1]){const i=Number.parseInt(a[1],10);Number.isFinite(i)&&i>0&&i<=65535&&o(`http://127.0.0.1:${i}/`)}for(const i of e.split(`
10
- `)){if(!cf.test(i))continue;const c=Array.from(i.matchAll(lf));if(c.length===0)continue;const l=c.find(d=>{try{return!!new URL(Tn(d[1])).port}catch{return!1}});o(Tn((l??c[0])[1]))}return n},So=s=>ff(s)[0]??null,mf=async(s,e=1500)=>{if(!s||typeof window>"u")return!1;let n;try{n=new URL(s)}catch{return!1}if(n.protocol!=="http:"&&n.protocol!=="https:")return!1;const r=n.hostname.toLowerCase();if(r!=="localhost"&&r!=="127.0.0.1"&&r!=="0.0.0.0"&&r!=="::1"&&r!=="::")return!1;const o=new AbortController,a=window.setTimeout(()=>o.abort(),e);try{const i=await Lt("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:n.toString()}),cache:"no-store",signal:o.signal});return i.ok?(await i.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(a)}},hf=/https?:\/\/[^\s<>'"`]+/gi,Xf=(s,{requireAnnounced:e=!1}={})=>{const n=So(s);if(n)return n;if(e)return null;const r=String(s||"").replace(wo,""),o=[];for(const c of r.match(hf)??[])try{const l=new URL(vo(c));l.port&&o.push(l)}catch{}if(o.length===0)return null;const a=c=>{const l=c.hostname.toLowerCase();return(l==="localhost"||l==="127.0.0.1"||l==="0.0.0.0"||l==="::1"?50:0)-(c.search||c.hash?10:0)};let i=o[0];for(const c of o.slice(1))a(c)>a(i)&&(i=c);return Tn(i.toString())},pf={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},gf=(s,e)=>{if(e&&s.startsWith("arrow-")){const n=e==="ctrl"?"5":"3",r={"arrow-up":"A","arrow-down":"B","arrow-right":"C","arrow-left":"D"}[s];return`\x1B[1;${n}${r}`}return pf[s]},jo=s=>{const e=s[0]?.toUpperCase();return!e||e<"A"||e>"Z"?null:String.fromCharCode(e.charCodeAt(0)&31)},xf=(s,e)=>s&&(e==="ctrl"?jo(s)??s:s.length===1&&s!=="\x1B"?`\x1B${s}`:s),Sr={cols:80,rows:24},Zf=({visible:s})=>{const{t:e}=nt(),{terminal:n,runtime:r}=An(),{currentTheme:o}=Rr(),a=m.useRef({themeMode:"dark",terminalBackground:"",terminalForeground:""});a.current={themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground};const{monoFont:i}=oi(),c=He(T=>T.terminalFontSize),l=He(T=>T.terminalShell),d=He(T=>T.terminalLoginShells.includes(T.terminalShell)),{isMobile:u,isTablet:h,hasTouchOnlyPointer:b}=Gs(),f=u||h,x=(f||b)&&r.platform==="web",g=r.platform!=="vscode",j=He(T=>T.showTerminalQuickKeysOnDesktop),p=f||j,k=at(T=>T.currentSessionId),P=at(T=>T.newSessionDraft),A=k!==null||P?.open===!0,N=ai()??null,C=ot(T=>N?T.sessions.get(N):void 0),w=ot(T=>T.hasHydrated),v=ot(T=>T.ensureDirectory),L=ot(T=>T.createTab),$=ot(T=>T.setActiveTab),M=ot(T=>T.closeTab),H=ot(T=>T.setTabSessionId),K=ot(T=>T.adoptServerSessions),ee=ot(T=>T.setTabLifecycle),Y=ot(T=>T.setConnecting),O=ot(T=>T.appendToBuffer),_=ot(T=>T.replaceBuffer),U=ot(T=>T.setTabPreviewUrl),J=ii(T=>T.addDraft),D=He(T=>T.openContextPreview),z=m.useMemo(()=>C?g?C.activeTabId??C.tabs[0]?.id??null:C.tabs[0]?.id??null:null,[C,g]),F=m.useMemo(()=>{if(C)return z?C.tabs.find(T=>T.id===z)??C.tabs[0]:C.tabs[0]},[C,z]),R=m.useMemo(()=>(C?.tabs??[]).map(T=>({icon:(()=>{const X=T.iconKey?ao[T.iconKey]??"terminal":"terminal";return t.jsx(E,{name:X,className:"h-4 w-4"})})(),id:T.id,label:T.label,title:T.label,closeLabel:e("terminalView.tabs.closeTabTitle")})),[C?.tabs,e]),V=F?.terminalSessionId??null,ne=F?.lifecycle??"idle",Q=ot(T=>N&&z?T.getBuffer(N,z).chunks:$s.chunks),q=F?.isConnecting??!1,oe=F?.previewUrl??null,[Z,te]=m.useState(null),[ye,re]=m.useState(!1),[ge,se]=m.useState(!1),[fe,he]=m.useState(null),[S,B]=m.useState(!1),W=m.useRef(null),le=m.useRef(null),pe=m.useRef(z),Te=m.useRef(V),Ie=m.useRef(N),We=m.useRef(null),Me=m.useRef(null),ve=m.useRef(new Set),Be=m.useRef(""),Ee=m.useRef(new Set),Oe=m.useRef(0),ze=m.useCallback(()=>{Be.current="",Ee.current.clear(),Oe.current+=1},[]),qe=m.useCallback(()=>{x||typeof document<"u"&&!document.hasFocus()||We.current?.focus()},[x]),Ke=m.useCallback(()=>{x||We.current?.focus()},[x]),_e=s??!1,[et,dt]=m.useState(_e);m.useEffect(()=>{_e&&dt(!0)},[_e]),m.useEffect(()=>{Te.current=V},[V]),m.useEffect(()=>{!V||!n.updateAppearance||n.updateAppearance(V,a.current).catch(()=>{})},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,n,V]),m.useEffect(()=>{pe.current=z,ze()},[z,ze]),m.useEffect(()=>{Ie.current=N},[N]),m.useEffect(()=>{if(!w||!N||!n.listSessions)return;let T=!1;const X=N;return n.listSessions(X).then(me=>{T||Ie.current!==X||K(X,me)}).catch(()=>{}),()=>{T=!0}},[w,N,n,K]),m.useEffect(()=>{if(!n.touchSessions)return;const T=()=>{if(typeof navigator<"u"&&!navigator.onLine)return;const me=[];for(const Ge of ot.getState().sessions.values())for(const be of Ge.tabs)be.terminalSessionId&&me.push(be.terminalSessionId);me.length>0&&n.touchSessions?.(me).catch(()=>{})};T();const X=setInterval(T,600*1e3);return()=>clearInterval(X)},[n]),m.useEffect(()=>{!p&&fe!==null&&he(null)},[p,fe,he]),m.useEffect(()=>{!V&&fe!==null&&he(null)},[V,fe,he]);const je=m.useCallback(()=>{W.current?.(),W.current=null,le.current=null,se(!1)},[]);m.useEffect(()=>()=>{je(),Te.current=null},[je]);const Xe=m.useCallback((T,X,me)=>{if(!me)return;const Ge=`${Be.current}${me}`.replace(/\r\n|\r/g,`
11
- `),be=Ge.split(`
12
- `),Ae=Ge.endsWith(`
13
- `)?be.join(`
14
- `):be.slice(0,-1).join(`
15
- `);if(Be.current=Ge.endsWith(`
16
- `)?"":(be[be.length-1]??"").slice(-1024),!Ae)return;const rt=So(Ae);if(!rt||Ee.current.has(rt))return;const Pe=Oe.current;Ee.current.add(rt),mf(rt).then(ce=>{if(Ee.current.delete(rt),!ce||Oe.current!==Pe)return;const Ye=ot.getState().getDirectoryState(T)?.tabs.find(ct=>ct.id===X);!Ye||Ye.previewUrlLocked||Ye.previewUrl===rt||U(T,X,rt,{locked:!1,autoOpened:!1})})},[U]),tt=m.useCallback((T,X,me)=>{if(le.current===me)return;je(),le.current=me;const Ge=n.connect(me,{onEvent:be=>{if(le.current===me)switch(be.type){case"snapshot":{Y(T,X,!1),te(null),re(!1),se(!1),qe(),_(T,X,be.data??"",be.sequence??0),Xe(T,X,be.data??""),be.status==="exited"&&ee(T,X,"exited");break}case"reconnecting":{te(null),re(!1),se(!0);break}case"data":{be.data&&(O(T,X,be.data,be.sequence,be.replayData),Xe(T,X,be.data));break}case"exit":{const Ae=typeof be.exitCode=="number"?be.exitCode:null,rt=typeof be.signal=="number"?be.signal:null,ce=!!ot.getState().getDirectoryState(T)?.tabs.find(Ye=>Ye.id===X)?.label?.startsWith("Action:");O(T,X,e("terminalView.stream.processExitedMessage",{exitCodeSegment:Ae!==null?e("terminalView.stream.processExitedWithCode",{exitCode:Ae}):"",signalSegment:rt!==null?e("terminalView.stream.processExitedWithSignal",{signal:rt}):""})),ee(T,X,"exited"),Y(T,X,!1),te(ce?null:e("terminalView.error.sessionEnded")),re(!1),se(!1),je();break}}},onError:(be,Ae)=>{if(le.current===me){if(!Ae){te(null),re(!1);return}if(se(!1),be.code==="SESSION_NOT_FOUND"&&!ot.getState().getDirectoryState(T)?.tabs.find(Pe=>Pe.id===X)?.label?.startsWith("Action:")){te(null),re(!1),Y(T,X,!1),H(T,X,null),ee(T,X,"idle"),je();return}te(e("terminalView.error.connectionFailed",{message:be.message})),re(!0),Y(T,X,!1),ee(T,X,"exited"),H(T,X,null),je()}}});W.current=()=>{Ge.close(),le.current=null}},[O,_,je,qe,Xe,Y,ee,H,e,n]);m.useEffect(()=>{let T=!1;if(!w||!et)return;if(!N){te(e(A?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),je();return}return(async()=>{const me=N;if(!Ie.current||Ie.current!==me)return;if(!ot.getState().getDirectoryState(me)){v(me);return}const be=ot.getState().getDirectoryState(me);if(!be||be.tabs.length===0)return;const Ae=g?be.activeTabId??be.tabs[0]?.id??null:be.tabs[0]?.id??null;if(!Ae)return;const rt=be.tabs.find(bt=>bt.id===Ae)??be.tabs[0],Pe=rt?.terminalSessionId??null,ce=rt?.lifecycle??"idle",Ye=!!rt?.label?.startsWith("Action:"),ct=ot.getState().getBuffer(me,Ae),pt=ct.byteLength>0||ct.chunks.length>0;if(!Pe){if(ce==="exited"){Y(me,Ae,!1);return}if(Ye&&pt){Y(me,Ae,!1);return}const bt=`${me}\0${Ae}`;if(ve.current.has(bt))return;const St=Me.current??Sr;ve.current.add(bt),te(null),re(!1),se(!1),Y(me,Ae,!0);try{const Nt=await n.createSession({cwd:me,sessionId:Ae,cols:St.cols,rows:St.rows,shell:l,loginShell:d,...a.current}),wt=!T&&Ie.current===me&&pe.current===Ae;if(!ot.getState().getDirectoryState(me)?.tabs.find(Et=>Et.id===Ae)){try{await n.close(Nt.sessionId)}catch{}return}if(H(me,Ae,Nt.sessionId),!wt)return;const Ct=Me.current;Ct&&(Ct.cols!==St.cols||Ct.rows!==St.rows)&&n.resize({sessionId:Nt.sessionId,...Ct}).catch(()=>{});return}catch(Nt){const wt=ot.getState().getDirectoryState(me)?.tabs.find(jt=>jt.id===Ae);if(!wt||wt.terminalSessionId||(Y(me,Ae,!1),Ie.current!==me||pe.current!==Ae))return;te(Nt instanceof Error?Nt.message:e("terminalView.error.startSessionFailed")),re(!0),se(!1);return}finally{ve.current.delete(bt)}}!Pe||T||(Te.current=Pe,tt(me,Ae,Pe))})(),()=>{T=!0,Te.current=null,je()}},[A,N,V,ne,z,et,g,w,v,Y,ee,H,tt,je,e,n,d,l]),m.useEffect(()=>{if(!_e||x)return;if(typeof window>"u"){qe();return}const T=window.requestAnimationFrame(()=>{qe()});return()=>{window.cancelAnimationFrame(T)}},[z,qe,_e,x]);const Je=m.useCallback(async()=>{if(!N||S)return;const T=ot.getState().getDirectoryState(N),X=g?z??T?.activeTabId??T?.tabs[0]?.id??null:T?.tabs[0]?.id??null;if(!X)return;const me=T?.tabs.find(Ge=>Ge.id===X)?.terminalSessionId??null;if(!(!me||!n.restartSession)){B(!0),te(null),re(!1),se(!1),je(),ze();try{const Ge=Me.current??Sr,be=await n.restartSession(me,{cwd:N,shell:l,loginShell:d,...Ge,...a.current});if(ot.getState().getDirectoryState(N)?.tabs.find(rt=>rt.id===X)?.terminalSessionId!==me||(H(N,X,be.sessionId),ee(N,X,"running"),Ie.current!==N||pe.current!==X))return;Te.current=be.sessionId,tt(N,X,be.sessionId)}catch(Ge){if(ot.getState().getDirectoryState(N)?.tabs.find(Ae=>Ae.id===X)?.terminalSessionId!==me||Ie.current!==N||pe.current!==X)return;te(Ge instanceof Error?Ge.message:e("terminalView.error.restartFailed")),re(!1),se(!1),Te.current=me,tt(N,X,me)}finally{B(!1)}}},[z,je,N,g,S,ze,ee,H,tt,e,n,d,l]),Ce=m.useCallback(async()=>{await Je()},[Je]),it=m.useCallback(()=>{if(!N)return;const T=L(N);$(N,T),te(null),re(!1),se(!1),je()},[L,je,N,$]),Fe=m.useCallback(()=>{const T=We.current?.getSelection(),X=k??(P?.open?"draft":null);!T||!X||!F||!N||J({directory:N,sessionKey:X},{source:"terminal",fileLabel:F.label,startLine:T.startLine,endLine:T.endLine,code:T.text,language:"",terminalId:F.terminalSessionId??F.id,text:""})},[F,J,k,N,P?.open]),$e=m.useCallback(T=>{N&&($(N,T),te(null),re(!1),se(!1),je())},[je,N,$]),st=m.useCallback(T=>{if(!N)return;T===z&&je(),te(null),re(!1),se(!1);const X=ot.getState().getDirectoryState(N)?.tabs.find(me=>me.id===T)?.terminalSessionId;(async()=>{X&&await n.close(X),M(N,T)})().catch(me=>te(me instanceof Error?me.message:e("terminalView.error.sessionEnded")))},[z,M,je,N,e,n]),Re=m.useCallback(T=>{if(!T||ge)return;let X=T,me=!1;fe&&T.length>0&&(X=xf(T,fe),me=!0);const Ge=Te.current;Ge&&(n.sendInput(Ge,X).catch(be=>{ge||te(be instanceof Error?be.message:e("terminalView.error.sendInputFailed"))}),me&&(he(null),Ke()))},[fe,Ke,ge,he,e,n]),Qe=m.useCallback((T,X)=>{const me=Me.current;if((!me||me.cols!==T||me.rows!==X)&&(Me.current={cols:T,rows:X}),!_e)return;const Ge=Te.current;Ge&&n.resize({sessionId:Ge,cols:T,rows:X}).catch(()=>{})},[_e,n]),ut=m.useCallback(T=>{he(X=>X===T?null:T),Ke()},[Ke,he]),lt=m.useCallback(T=>{const X=gf(T,fe);X&&(Re(X),he(null),Ke())},[fe,Ke,Re,he]),mt=m.useMemo(()=>({Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc"}),[]),y=m.useCallback(T=>{if(T.repeat)return;const X=T.key;if(!X||X==="Control"||X==="Meta"||X==="Alt"||X==="Shift")return;const me=X.length===1?X.toLowerCase():X;if(me in mt){T.preventDefault(),T.stopPropagation(),lt(mt[me]);return}if(fe!=="ctrl")return;const Ge=T.code??"",be=X.length===1&&/[a-zA-Z]/.test(X)?X.toUpperCase():Ge.startsWith("Key")&&Ge.length===4?Ge.slice(3).toUpperCase():null;if(be&&be.length===1&&be>="A"&&be<="Z"){const Ae=jo(be);if(!Ae)return;T.preventDefault(),T.stopPropagation(),Re(Ae),he(null),Ke()}},[fe,Ke,lt,Re,mt,he]);m.useEffect(()=>{if(!(!p||!fe||!V))return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[fe,y,p,V]);const G=m.useMemo(()=>{const T=bs[Zs].stack;if(typeof window>"u")return(bs[i]??bs[Zs]).stack;const me=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return me&&me.trim().length>0?me.trim():(bs[i]??bs[Zs]).stack??T},[i]),ke=m.useMemo(()=>Yu(o),[o]),Ue=`${N??"no-dir"}::${z??"no-tab"}`;if(m.useEffect(()=>{if(!_e||x)return;const T=We.current;if(!T)return;const X=()=>{T.fit()};if(typeof window<"u"){const me=window.requestAnimationFrame(()=>{X(),qe()}),Ge=[220,400].map(be=>window.setTimeout(X,be));return()=>{window.cancelAnimationFrame(me),Ge.forEach(be=>window.clearTimeout(be))}}X()},[qe,_e,x,Ue,V]),m.useEffect(()=>{if(!_e||!x)return;let T=null;const X=()=>{T!==null&&window.cancelAnimationFrame(T),T=window.requestAnimationFrame(()=>{T=null,We.current?.fit()})};return window.addEventListener("oc:keyboard-settled",X),()=>{window.removeEventListener("oc:keyboard-settled",X),T!==null&&window.cancelAnimationFrame(T)}},[_e,Ue,x]),!A)return t.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:e("terminalView.empty.selectSession")});if(!N)return t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[t.jsx("p",{children:e("terminalView.empty.noWorkingDirectoryForSession")}),t.jsx("button",{onClick:Je,className:"rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:e("terminalView.actions.retry")})]});const De=!V||q||S||ge,I=et,ae=f?"lg":"xs",xe=f?"w-10 p-0":"w-9 p-0",ue=T=>{f&&T.preventDefault()},Le=t.jsxs(t.Fragment,{children:[t.jsx(Ne,{type:"button",size:ae,variant:"outline",onPointerDown:ue,onClick:()=>lt("esc"),disabled:De,children:e("terminalView.quickKeys.escape")}),t.jsxs(Ne,{type:"button",size:ae,variant:"outline",className:xe,onPointerDown:ue,onClick:()=>lt("tab"),disabled:De,children:[t.jsx(E,{name:"arrow-right",className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.tabAria")})]}),t.jsxs(Ne,{type:"button",size:ae,variant:"chip","aria-pressed":fe==="ctrl",className:f?"px-3":"px-2",onPointerDown:ue,onClick:()=>ut("ctrl"),disabled:De,children:[t.jsx("span",{className:"text-xs font-medium",children:wn("ctrl")}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.controlModifierAria")})]}),t.jsxs(Ne,{type:"button",size:ae,variant:"chip","aria-pressed":fe==="alt",className:f?"px-3":"px-2",onPointerDown:ue,onClick:()=>ut("alt"),disabled:De,children:[t.jsx("span",{className:"text-xs font-medium",children:wn("alt")}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.altModifierAria")})]}),t.jsxs(Ne,{type:"button",size:ae,variant:"outline",className:xe,onPointerDown:ue,onClick:()=>lt("arrow-up"),disabled:De,children:[t.jsx(E,{name:"arrow-up"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowUpAria")})]}),t.jsxs(Ne,{type:"button",size:ae,variant:"outline",className:xe,onPointerDown:ue,onClick:()=>lt("arrow-left"),disabled:De,children:[t.jsx(E,{name:"arrow-left"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowLeftAria")})]}),t.jsxs(Ne,{type:"button",size:ae,variant:"outline",className:xe,onPointerDown:ue,onClick:()=>lt("arrow-down"),disabled:De,children:[t.jsx(E,{name:"arrow-down"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowDownAria")})]}),t.jsxs(Ne,{type:"button",size:ae,variant:"outline",className:xe,onPointerDown:ue,onClick:()=>lt("arrow-right"),disabled:De,children:[t.jsx(E,{name:"arrow-right"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowRightAria")})]}),t.jsxs(Ne,{type:"button",size:ae,variant:"outline",className:xe,onPointerDown:ue,onClick:()=>lt("enter"),disabled:De,children:[t.jsx(E,{name:"arrow-go-back"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.enterAria")})]})]});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[t.jsxs("div",{className:ie("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",f?"px-3 py-1.5":"pl-3 pr-1.5 py-1"),children:[g&&C?t.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1",children:[t.jsx("div",{className:ie("min-w-0 flex-1",f?"h-8":"h-7"),children:t.jsx(Ns,{items:R,activeId:z,onSelect:$e,onClose:st,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),t.jsx(Ne,{type:"button",size:"xs",variant:"ghost",className:ie("shrink-0",f?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:it,title:e("terminalView.tabs.newTabTitle"),children:t.jsx(E,{name:"add",className:`${f?"h-[18px] w-[18px]":"h-4 w-4"}`})}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-visible",children:[t.jsx(Ne,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{Je()},disabled:S,title:e("terminalView.actions.restart"),"aria-label":e("terminalView.actions.restart"),children:t.jsx(E,{name:"restart",className:"h-4 w-4"})}),t.jsx(Ne,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:Fe,title:e("terminalView.actions.attachSelection"),"aria-label":e("terminalView.actions.attachSelection"),children:t.jsx(E,{name:"attachment-2",className:"h-4 w-4"})}),oe?t.jsxs(Ne,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{N&&D(N,oe)},title:e("terminalView.preview.openTitle"),children:[t.jsx(E,{name:"global",className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"whitespace-nowrap",children:e("terminalView.preview.open")})]}):null]})]}):null,!f&&p&&g&&C?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:Le}):null,!f&&p&&(!g||!C)?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:Le}):null]}),t.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:ke.background},children:[t.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:I?t.jsx(yo,{ref:T=>{We.current=T},sessionKey:Ue,chunks:Q,onInput:Re,onResize:Qe,theme:ke,fontFamily:G,fontSize:c,enableTouchScroll:x,autoFocus:_e,isVisible:_e},Ue):null}),!ge&&Z&&t.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2",children:[t.jsx("span",{children:Z}),ye&&f&&t.jsx(Ne,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:Ce,disabled:S,title:e("terminalView.actions.hardRestartTitle"),type:"button",children:e("terminalView.actions.hardRestart")})]})]}),f&&p?t.jsx("div",{className:"shrink-0 overflow-x-auto border-t border-border/40 bg-[var(--surface-background)] px-2 pt-1.5 pb-[max(0.375rem,calc(var(--oc-app-bottom-safe,0px)-var(--oc-keyboard-inset,0px)))] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:t.jsx("div",{className:"flex min-w-max items-center gap-1.5",children:Le})}):null]})},em=s=>{const e=Ve.c(31),{rootIsGitRepo:n,resolvedIsGitRepo:r,nestedRepos:o,onRetryDiscovery:a,emptyStateFooter:i}=s,{t:c}=nt();if(n!==!1||r===!0)return null;if(o==null){let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(E,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),e[0]=h):h=e[0];let b;e[1]!==o||e[2]!==c?(b=c(o===null?"gitView.empty.discoverFailed":"gitView.empty.discoveringRepositories"),e[1]=o,e[2]=c,e[3]=b):b=e[3];let f;e[4]!==b?(f=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:b}),e[4]=b,e[5]=f):f=e[5];let x;e[6]!==o||e[7]!==a||e[8]!==c?(x=o===null?t.jsxs(Ne,{type:"button",variant:"outline",size:"sm",className:"mt-3 gap-1.5",onClick:a,children:[t.jsx(E,{name:"refresh",className:"size-4"}),c("gitView.empty.retryDiscovery")]}):null,e[6]=o,e[7]=a,e[8]=c,e[9]=x):x=e[9];let g;return e[10]!==f||e[11]!==x?(g=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[h,f,x]}),e[10]=f,e[11]=x,e[12]=g):g=e[12],g}if(o==="unsupported"||o.length===0){let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(E,{name:"git-branch",className:"mb-3 size-6 text-muted-foreground"}),e[13]=h):h=e[13];let b;e[14]!==c?(b=c("gitView.empty.notGitRepository"),e[14]=c,e[15]=b):b=e[15];let f;e[16]!==b?(f=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:b}),e[16]=b,e[17]=f):f=e[17];let x;e[18]!==c?(x=c("gitView.empty.notGitRepositoryDescription"),e[18]=c,e[19]=x):x=e[19];let g;e[20]!==x?(g=t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:x}),e[20]=x,e[21]=g):g=e[21];let j;return e[22]!==i||e[23]!==f||e[24]!==g?(j=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[h,f,g,i]}),e[22]=i,e[23]=f,e[24]=g,e[25]=j):j=e[25],j}let l;e[26]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(E,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),e[26]=l):l=e[26];let d;e[27]!==c?(d=c("gitView.loading.checkingRepository"),e[27]=c,e[28]=d):d=e[28];let u;return e[29]!==d?(u=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[l,t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:d})]}),e[29]=d,e[30]=u):u=e[30],u},tm=()=>{zr(),fs.reconnectToRuntimeBaseUrl(),Ur()},sm=s=>{at.getState().prepareForRuntimeSwitch(s.previousRuntimeKey),s.previousRuntimeKey&&li.getState().stopRunningRunsForRuntime(s.previousRuntimeKey),zr(),ot.getState().clearAll(),fs.reconnectToRuntimeBaseUrl(),kt.setState({providers:[],agents:[],isConnected:!1,isInitialized:!1,connectionPhase:"connecting",lastDisconnectReason:null}),It.getState().resetForRuntimeSwitch(),Rt.getState().reset(),Yt.getState().resetForRuntimeSwitch(),ci(new Map),di(),ui(),fi.getState().reset(),Ei.getState().resetForRuntimeSwitch(),Bn.getState().resetForRuntimeSwitch(s.runtimeKey),mi.getState().resetForRuntimeSwitch(),hi.getState().resetForRuntimeSwitch(s.runtimeKey),Ai.getState().resetForRuntimeSwitch(s.runtimeKey),at.getState().restoreForRuntimeSwitch(s.runtimeKey),Ur(),queueMicrotask(()=>{Bi()})};export{Df as $,Lf as A,Gl as B,Af as C,Hf as D,zl as E,Nc as F,Wf as G,$f as H,qf as I,Yf as J,Jf as K,rn as L,cd as M,Kf as N,Ef as O,Qf as P,Ru as Q,Uf as R,zf as S,Zf as T,Pf as U,Rf as V,ic as W,qt as X,Cc as Y,Tc as Z,El as _,Jc as a,Gf as a0,Qc as b,em as c,Ns as d,sm as e,Vf as f,_f as g,Bf as h,Tf as i,ar as j,ot as k,lc as l,Of as m,cc as n,ao as o,wd as p,ff as q,tm as r,Xf as s,Ff as t,ul as u,Dl as v,Rl as w,Pl as x,Hl as y,Mf as z};