@jingyi0605/codingns 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (425) hide show
  1. package/dist/public/assets/{AdaptiveButlerPage-BsgVNRAa.js → AdaptiveButlerPage-b7s6F_sd.js} +1 -1
  2. package/dist/public/assets/{App-tPcbyRdS.js → App-B0q8uDA-.js} +3 -3
  3. package/dist/public/assets/{BootstrapPage--MDOigQi.js → BootstrapPage-jFfl7KNK.js} +1 -1
  4. package/dist/public/assets/{ConversationPage-BBss5ED8.js → ConversationPage-sj_rn4q0.js} +1 -1
  5. package/dist/public/assets/{DesktopDetachPreviewPage-CB8DoqwU.js → DesktopDetachPreviewPage-C5c88SOX.js} +1 -1
  6. package/dist/public/assets/{DesktopWindowPage-GtIx5m8K.js → DesktopWindowPage-BdKUZrKG.js} +1 -1
  7. package/dist/public/assets/{FileContextPanel-BcM7AIT4.js → FileContextPanel-lM5mBcfn.js} +1 -1
  8. package/dist/public/assets/{GitSidebar-CMtkaxuI.js → GitSidebar-CmXAhyjo.js} +1 -1
  9. package/dist/public/assets/{MobileCreateSessionSheet-CrFY41_8.js → MobileCreateSessionSheet-CceV0-AH.js} +1 -1
  10. package/dist/public/assets/{MobileTopHeaderFrame-DGVOzXyg.js → MobileTopHeaderFrame-_I0t7cC_.js} +1 -1
  11. package/dist/public/assets/{MobileWorkspaceSwitcherHeader-DLkACTnQ.js → MobileWorkspaceSwitcherHeader-DhaM9fgx.js} +1 -1
  12. package/dist/public/assets/{RelayConnectEntryPage-0MPPjxtQ.js → RelayConnectEntryPage-CMtDWyGS.js} +1 -1
  13. package/dist/public/assets/{ServerSettingsModal-vgOhwus4.js → ServerSettingsModal-Rkgn3jft.js} +1 -1
  14. package/dist/public/assets/{SessionIndexPage-KK626Ra9.js → SessionIndexPage-BOumP3ij.js} +1 -1
  15. package/dist/public/assets/{SettingsPage-B3edBJIo.js → SettingsPage-vx_c-00-.js} +1 -1
  16. package/dist/public/assets/{TerminalManagerPanel-BxlhZp8c.js → TerminalManagerPanel-D9JHCS6d.js} +1 -1
  17. package/dist/public/assets/{TerminalPage-B6Rdhylx.js → TerminalPage-CBIKHI33.js} +1 -1
  18. package/dist/public/assets/{TerminalRuntimeFallbackModal-BVLfrpSa.js → TerminalRuntimeFallbackModal-W5NjqFEz.js} +1 -1
  19. package/dist/public/assets/{ToolFilesPage-N_gwwUjD.js → ToolFilesPage-DWtpaN_7.js} +1 -1
  20. package/dist/public/assets/{ToolGitPage-DOcuuWM1.js → ToolGitPage-MpGXsw4_.js} +1 -1
  21. package/dist/public/assets/{ToolProcessesPage-D-FfJ7Re.js → ToolProcessesPage-B1jHQKhZ.js} +1 -1
  22. package/dist/public/assets/{ToolsHomePage-CHfPxd20.js → ToolsHomePage-CJrn8ZFl.js} +1 -1
  23. package/dist/public/assets/{WorkbenchLandingPage-CTTnfovY.js → WorkbenchLandingPage-CJQ1V5U-.js} +1 -1
  24. package/dist/public/assets/{WorkbenchLayout-CbpJg0g1.js → WorkbenchLayout-D48i71PU.js} +3 -3
  25. package/dist/public/assets/{WorkbenchModal-Bt_1fYmM.js → WorkbenchModal-BYNuMIoV.js} +1 -1
  26. package/dist/public/assets/WorkbenchShellRoute-CGKjy4J-.js +1 -0
  27. package/dist/public/assets/{WorkspaceDebugDetailPage-s7yuDIxR.js → WorkspaceDebugDetailPage-DCAYgays.js} +1 -1
  28. package/dist/public/assets/{WorkspaceDetailPage-Cf-gVpqK.js → WorkspaceDetailPage-D5v-nUIi.js} +1 -1
  29. package/dist/public/assets/{WorkspaceHomePage-COf6I8sT.js → WorkspaceHomePage-I5G1p5SR.js} +1 -1
  30. package/dist/public/assets/{client-runtime-manager-DGdKvYzx.js → client-runtime-manager-CdJP7nUp.js} +1 -1
  31. package/dist/public/assets/{file-tree-icon-BeHqeru9.js → file-tree-icon-BFwaPxKs.js} +6 -6
  32. package/dist/public/assets/{index-CuzMc7q2.js → index-CjewzOUG.js} +3 -3
  33. package/dist/public/assets/{index-CcaQt50x.css → index-VVxfF0s5.css} +1 -1
  34. package/dist/public/assets/{login-direct-candidate-resolver-DEP_xCmR.js → login-direct-candidate-resolver-C-mo698r.js} +1 -1
  35. package/dist/public/assets/{model-switch-api-c6kcbBGm.js → model-switch-api-Br0ivfe5.js} +1 -1
  36. package/dist/public/assets/{preferences-service-CV6Ih0BG.js → preferences-service-CnaTvZq2.js} +1 -1
  37. package/dist/public/assets/{realtime-client-CRCx5xBt.js → realtime-client-BlQRqVmm.js} +1 -1
  38. package/dist/public/assets/{relay-entry-C751A-Sm.js → relay-entry-D7OgZZN-.js} +1 -1
  39. package/dist/public/assets/{terminal-runtime-meta-CRAVR-8G.js → terminal-runtime-meta-BCtAYB0E.js} +1 -1
  40. package/dist/public/assets/{useRegisteredDebugTemplates-D6YtNS0r.js → useRegisteredDebugTemplates-CXmxu69X.js} +1 -1
  41. package/dist/public/index.html +2 -2
  42. package/dist/server/main.js +2 -0
  43. package/dist/server/main.js.map +1 -1
  44. package/dist/server/modules/assistant-capability/assistant-capability-controller.d.ts +1 -0
  45. package/dist/server/modules/assistant-capability/assistant-capability-controller.js +1 -0
  46. package/dist/server/modules/assistant-capability/assistant-capability-controller.js.map +1 -1
  47. package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +1 -0
  48. package/dist/server/modules/assistant-capability/assistant-capability-service.js +1 -0
  49. package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
  50. package/dist/server/modules/browser-runtime/browser-runtime-controller.d.ts +2 -1
  51. package/dist/server/modules/browser-runtime/browser-runtime-controller.js +1 -0
  52. package/dist/server/modules/browser-runtime/browser-runtime-controller.js.map +1 -1
  53. package/dist/server/modules/browser-runtime/browser-runtime-service.d.ts +4 -1
  54. package/dist/server/modules/browser-runtime/browser-runtime-service.js +40 -0
  55. package/dist/server/modules/browser-runtime/browser-runtime-service.js.map +1 -1
  56. package/dist/server/modules/browser-runtime/browser-task-payload.d.ts +2 -0
  57. package/dist/server/modules/browser-runtime/browser-task-payload.js.map +1 -1
  58. package/dist/server/modules/git/git-command-helper-process.js +0 -18
  59. package/dist/server/modules/git/git-command-helper-process.js.map +1 -1
  60. package/dist/server/modules/git/git-command-runner.js +0 -18
  61. package/dist/server/modules/git/git-command-runner.js.map +1 -1
  62. package/dist/server/modules/sessions/session-live-runtime-service.js +46 -3
  63. package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
  64. package/dist/server/modules/sessions/workspace-session-runtime-context-service.d.ts +1 -0
  65. package/dist/server/modules/sessions/workspace-session-runtime-context-service.js +11 -2
  66. package/dist/server/modules/sessions/workspace-session-runtime-context-service.js.map +1 -1
  67. package/dist/server/modules/skills/builtin-skills/codingns-workspace-session/SKILL.md +2 -2
  68. package/dist/server/shared/http/error-handler.js +53 -19
  69. package/dist/server/shared/http/error-handler.js.map +1 -1
  70. package/dist/server/shared/utils/install-console-timestamp-prefix.d.ts +1 -0
  71. package/dist/server/shared/utils/install-console-timestamp-prefix.js +28 -0
  72. package/dist/server/shared/utils/install-console-timestamp-prefix.js.map +1 -0
  73. package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.d.ts +42 -0
  74. package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js +346 -0
  75. package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js.map +1 -0
  76. package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.d.ts +1 -0
  77. package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.js +80 -0
  78. package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.js.map +1 -0
  79. package/node_modules/@codingns/session-sync-core/dist/index.d.ts +18 -0
  80. package/node_modules/@codingns/session-sync-core/dist/index.js +19 -0
  81. package/node_modules/@codingns/session-sync-core/dist/index.js.map +1 -0
  82. package/node_modules/@codingns/session-sync-core/dist/kimi-message-normalizer.d.ts +18 -0
  83. package/node_modules/@codingns/session-sync-core/dist/kimi-message-normalizer.js +659 -0
  84. package/node_modules/@codingns/session-sync-core/dist/kimi-message-normalizer.js.map +1 -0
  85. package/node_modules/@codingns/session-sync-core/dist/kimi-shared.d.ts +11 -0
  86. package/node_modules/@codingns/session-sync-core/dist/kimi-shared.js +72 -0
  87. package/node_modules/@codingns/session-sync-core/dist/kimi-shared.js.map +1 -0
  88. package/node_modules/@codingns/session-sync-core/dist/patch-builder.d.ts +67 -0
  89. package/node_modules/@codingns/session-sync-core/dist/patch-builder.js +752 -0
  90. package/node_modules/@codingns/session-sync-core/dist/patch-builder.js.map +1 -0
  91. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.d.ts +48 -0
  92. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js +1184 -0
  93. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js.map +1 -0
  94. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.d.ts +11 -0
  95. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js +105 -0
  96. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js.map +1 -0
  97. package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +84 -0
  98. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +2436 -0
  99. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -0
  100. package/node_modules/@codingns/session-sync-core/dist/providers/gemini.d.ts +47 -0
  101. package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js +1480 -0
  102. package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js.map +1 -0
  103. package/node_modules/@codingns/session-sync-core/dist/providers/kimi.d.ts +33 -0
  104. package/node_modules/@codingns/session-sync-core/dist/providers/kimi.js +684 -0
  105. package/node_modules/@codingns/session-sync-core/dist/providers/kimi.js.map +1 -0
  106. package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.d.ts +9 -0
  107. package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js +17 -0
  108. package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js.map +1 -0
  109. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-permissions.d.ts +1 -0
  110. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-permissions.js +8 -0
  111. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-permissions.js.map +1 -0
  112. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.d.ts +48 -0
  113. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js +373 -0
  114. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js.map +1 -0
  115. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.d.ts +61 -0
  116. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js +1191 -0
  117. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js.map +1 -0
  118. package/node_modules/@codingns/session-sync-core/dist/providers/utils.d.ts +27 -0
  119. package/node_modules/@codingns/session-sync-core/dist/providers/utils.js +415 -0
  120. package/node_modules/@codingns/session-sync-core/dist/providers/utils.js.map +1 -0
  121. package/node_modules/@codingns/session-sync-core/dist/registry.d.ts +7 -0
  122. package/node_modules/@codingns/session-sync-core/dist/registry.js +22 -0
  123. package/node_modules/@codingns/session-sync-core/dist/registry.js.map +1 -0
  124. package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.d.ts +24 -0
  125. package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js +329 -0
  126. package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js.map +1 -0
  127. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.d.ts +30 -0
  128. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js +939 -0
  129. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js.map +1 -0
  130. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.d.ts +1 -0
  131. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js +16 -0
  132. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js.map +1 -0
  133. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.d.ts +70 -0
  134. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +2571 -0
  135. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -0
  136. package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.d.ts +21 -0
  137. package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js +561 -0
  138. package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js.map +1 -0
  139. package/node_modules/@codingns/session-sync-core/dist/runtime/kimi-runtime.d.ts +38 -0
  140. package/node_modules/@codingns/session-sync-core/dist/runtime/kimi-runtime.js +911 -0
  141. package/node_modules/@codingns/session-sync-core/dist/runtime/kimi-runtime.js.map +1 -0
  142. package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.d.ts +15 -0
  143. package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js +16 -0
  144. package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js.map +1 -0
  145. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.d.ts +38 -0
  146. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js +970 -0
  147. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js.map +1 -0
  148. package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.d.ts +21 -0
  149. package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js +168 -0
  150. package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js.map +1 -0
  151. package/node_modules/@codingns/session-sync-core/dist/runtime/types.d.ts +152 -0
  152. package/node_modules/@codingns/session-sync-core/dist/runtime/types.js +2 -0
  153. package/node_modules/@codingns/session-sync-core/dist/runtime/types.js.map +1 -0
  154. package/node_modules/@codingns/session-sync-core/dist/services.d.ts +28 -0
  155. package/node_modules/@codingns/session-sync-core/dist/services.js +148 -0
  156. package/node_modules/@codingns/session-sync-core/dist/services.js.map +1 -0
  157. package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.d.ts +6 -0
  158. package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.js +9 -0
  159. package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.js.map +1 -0
  160. package/node_modules/@codingns/session-sync-core/dist/types.d.ts +198 -0
  161. package/node_modules/@codingns/session-sync-core/dist/types.js +2 -0
  162. package/node_modules/@codingns/session-sync-core/dist/types.js.map +1 -0
  163. package/node_modules/@codingns/session-sync-core/package.json +33 -0
  164. package/package.json +6 -4
  165. package/vendor/node-pty-fork/LICENSE +69 -0
  166. package/vendor/node-pty-fork/README.md +91 -0
  167. package/vendor/node-pty-fork/binding.gyp +117 -0
  168. package/vendor/node-pty-fork/deps/.editorconfig +2 -0
  169. package/vendor/node-pty-fork/deps/winpty/.drone.yml +17 -0
  170. package/vendor/node-pty-fork/deps/winpty/.gitattributes +19 -0
  171. package/vendor/node-pty-fork/deps/winpty/LICENSE +21 -0
  172. package/vendor/node-pty-fork/deps/winpty/Makefile +166 -0
  173. package/vendor/node-pty-fork/deps/winpty/README.md +151 -0
  174. package/vendor/node-pty-fork/deps/winpty/RELEASES.md +280 -0
  175. package/vendor/node-pty-fork/deps/winpty/VERSION.txt +1 -0
  176. package/vendor/node-pty-fork/deps/winpty/configure +167 -0
  177. package/vendor/node-pty-fork/deps/winpty/misc/BufferResizeTests.cc +90 -0
  178. package/vendor/node-pty-fork/deps/winpty/misc/ChangeScreenBuffer.cc +53 -0
  179. package/vendor/node-pty-fork/deps/winpty/misc/ClearConsole.cc +72 -0
  180. package/vendor/node-pty-fork/deps/winpty/misc/ConinMode.cc +117 -0
  181. package/vendor/node-pty-fork/deps/winpty/misc/ConinMode.ps1 +116 -0
  182. package/vendor/node-pty-fork/deps/winpty/misc/ConoutMode.cc +113 -0
  183. package/vendor/node-pty-fork/deps/winpty/misc/DebugClient.py +42 -0
  184. package/vendor/node-pty-fork/deps/winpty/misc/DebugServer.py +63 -0
  185. package/vendor/node-pty-fork/deps/winpty/misc/DumpLines.py +5 -0
  186. package/vendor/node-pty-fork/deps/winpty/misc/EnableExtendedFlags.txt +46 -0
  187. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP437-Consolas.txt +528 -0
  188. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP437-Lucida.txt +633 -0
  189. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP932.txt +630 -0
  190. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP936.txt +630 -0
  191. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP949.txt +630 -0
  192. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP950.txt +630 -0
  193. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/MinimumWindowWidths.txt +16 -0
  194. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/Results.txt +4 -0
  195. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/Windows10SetFontBugginess.txt +144 -0
  196. package/vendor/node-pty-fork/deps/winpty/misc/FontSurvey.cc +100 -0
  197. package/vendor/node-pty-fork/deps/winpty/misc/FormatChar.h +21 -0
  198. package/vendor/node-pty-fork/deps/winpty/misc/FreezePerfTest.cc +62 -0
  199. package/vendor/node-pty-fork/deps/winpty/misc/GetCh.cc +20 -0
  200. package/vendor/node-pty-fork/deps/winpty/misc/GetConsolePos.cc +41 -0
  201. package/vendor/node-pty-fork/deps/winpty/misc/GetFont.cc +261 -0
  202. package/vendor/node-pty-fork/deps/winpty/misc/IdentifyConsoleWindow.ps1 +51 -0
  203. package/vendor/node-pty-fork/deps/winpty/misc/IsNewConsole.cc +87 -0
  204. package/vendor/node-pty-fork/deps/winpty/misc/MouseInputNotes.txt +90 -0
  205. package/vendor/node-pty-fork/deps/winpty/misc/MoveConsoleWindow.cc +34 -0
  206. package/vendor/node-pty-fork/deps/winpty/misc/Notes.txt +219 -0
  207. package/vendor/node-pty-fork/deps/winpty/misc/OSVersion.cc +27 -0
  208. package/vendor/node-pty-fork/deps/winpty/misc/ScreenBufferFreezeInactive.cc +101 -0
  209. package/vendor/node-pty-fork/deps/winpty/misc/ScreenBufferTest.cc +671 -0
  210. package/vendor/node-pty-fork/deps/winpty/misc/ScreenBufferTest2.cc +151 -0
  211. package/vendor/node-pty-fork/deps/winpty/misc/SelectAllTest.cc +45 -0
  212. package/vendor/node-pty-fork/deps/winpty/misc/SetBufferSize.cc +32 -0
  213. package/vendor/node-pty-fork/deps/winpty/misc/SetCursorPos.cc +10 -0
  214. package/vendor/node-pty-fork/deps/winpty/misc/SetFont.cc +145 -0
  215. package/vendor/node-pty-fork/deps/winpty/misc/SetWindowRect.cc +36 -0
  216. package/vendor/node-pty-fork/deps/winpty/misc/ShowArgv.cc +12 -0
  217. package/vendor/node-pty-fork/deps/winpty/misc/ShowConsoleInput.cc +40 -0
  218. package/vendor/node-pty-fork/deps/winpty/misc/Spew.py +5 -0
  219. package/vendor/node-pty-fork/deps/winpty/misc/TestUtil.cc +172 -0
  220. package/vendor/node-pty-fork/deps/winpty/misc/UnicodeDoubleWidthTest.cc +102 -0
  221. package/vendor/node-pty-fork/deps/winpty/misc/UnicodeWideTest1.cc +246 -0
  222. package/vendor/node-pty-fork/deps/winpty/misc/UnicodeWideTest2.cc +130 -0
  223. package/vendor/node-pty-fork/deps/winpty/misc/UnixEcho.cc +89 -0
  224. package/vendor/node-pty-fork/deps/winpty/misc/Utf16Echo.cc +46 -0
  225. package/vendor/node-pty-fork/deps/winpty/misc/VeryLargeRead.cc +122 -0
  226. package/vendor/node-pty-fork/deps/winpty/misc/VkEscapeTest.cc +56 -0
  227. package/vendor/node-pty-fork/deps/winpty/misc/Win10ResizeWhileFrozen.cc +52 -0
  228. package/vendor/node-pty-fork/deps/winpty/misc/Win10WrapTest1.cc +57 -0
  229. package/vendor/node-pty-fork/deps/winpty/misc/Win10WrapTest2.cc +30 -0
  230. package/vendor/node-pty-fork/deps/winpty/misc/Win32Echo1.cc +26 -0
  231. package/vendor/node-pty-fork/deps/winpty/misc/Win32Echo2.cc +19 -0
  232. package/vendor/node-pty-fork/deps/winpty/misc/Win32Test1.cc +46 -0
  233. package/vendor/node-pty-fork/deps/winpty/misc/Win32Test2.cc +70 -0
  234. package/vendor/node-pty-fork/deps/winpty/misc/Win32Test3.cc +78 -0
  235. package/vendor/node-pty-fork/deps/winpty/misc/Win32Write1.cc +44 -0
  236. package/vendor/node-pty-fork/deps/winpty/misc/WindowsBugCrashReader.cc +27 -0
  237. package/vendor/node-pty-fork/deps/winpty/misc/WriteConsole.cc +106 -0
  238. package/vendor/node-pty-fork/deps/winpty/misc/build32.sh +9 -0
  239. package/vendor/node-pty-fork/deps/winpty/misc/build64.sh +9 -0
  240. package/vendor/node-pty-fork/deps/winpty/misc/color-test.sh +212 -0
  241. package/vendor/node-pty-fork/deps/winpty/misc/font-notes.txt +300 -0
  242. package/vendor/node-pty-fork/deps/winpty/misc/winbug-15048.cc +201 -0
  243. package/vendor/node-pty-fork/deps/winpty/ship/build-pty4j-libpty.bat +36 -0
  244. package/vendor/node-pty-fork/deps/winpty/ship/common_ship.py +53 -0
  245. package/vendor/node-pty-fork/deps/winpty/ship/make_msvc_package.py +165 -0
  246. package/vendor/node-pty-fork/deps/winpty/ship/ship.py +108 -0
  247. package/vendor/node-pty-fork/deps/winpty/src/agent/Agent.cc +605 -0
  248. package/vendor/node-pty-fork/deps/winpty/src/agent/Agent.h +103 -0
  249. package/vendor/node-pty-fork/deps/winpty/src/agent/AgentCreateDesktop.cc +84 -0
  250. package/vendor/node-pty-fork/deps/winpty/src/agent/AgentCreateDesktop.h +28 -0
  251. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleFont.cc +632 -0
  252. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleFont.h +28 -0
  253. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInput.cc +852 -0
  254. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInput.h +109 -0
  255. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInputReencoding.cc +121 -0
  256. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInputReencoding.h +36 -0
  257. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleLine.cc +152 -0
  258. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleLine.h +41 -0
  259. package/vendor/node-pty-fork/deps/winpty/src/agent/Coord.h +87 -0
  260. package/vendor/node-pty-fork/deps/winpty/src/agent/DebugShowInput.cc +239 -0
  261. package/vendor/node-pty-fork/deps/winpty/src/agent/DebugShowInput.h +32 -0
  262. package/vendor/node-pty-fork/deps/winpty/src/agent/DefaultInputMap.cc +422 -0
  263. package/vendor/node-pty-fork/deps/winpty/src/agent/DefaultInputMap.h +28 -0
  264. package/vendor/node-pty-fork/deps/winpty/src/agent/DsrSender.h +30 -0
  265. package/vendor/node-pty-fork/deps/winpty/src/agent/EventLoop.cc +99 -0
  266. package/vendor/node-pty-fork/deps/winpty/src/agent/EventLoop.h +47 -0
  267. package/vendor/node-pty-fork/deps/winpty/src/agent/InputMap.cc +246 -0
  268. package/vendor/node-pty-fork/deps/winpty/src/agent/InputMap.h +114 -0
  269. package/vendor/node-pty-fork/deps/winpty/src/agent/LargeConsoleRead.cc +71 -0
  270. package/vendor/node-pty-fork/deps/winpty/src/agent/LargeConsoleRead.h +68 -0
  271. package/vendor/node-pty-fork/deps/winpty/src/agent/NamedPipe.cc +378 -0
  272. package/vendor/node-pty-fork/deps/winpty/src/agent/NamedPipe.h +125 -0
  273. package/vendor/node-pty-fork/deps/winpty/src/agent/Scraper.cc +699 -0
  274. package/vendor/node-pty-fork/deps/winpty/src/agent/Scraper.h +103 -0
  275. package/vendor/node-pty-fork/deps/winpty/src/agent/SimplePool.h +75 -0
  276. package/vendor/node-pty-fork/deps/winpty/src/agent/SmallRect.h +143 -0
  277. package/vendor/node-pty-fork/deps/winpty/src/agent/Terminal.cc +535 -0
  278. package/vendor/node-pty-fork/deps/winpty/src/agent/Terminal.h +69 -0
  279. package/vendor/node-pty-fork/deps/winpty/src/agent/UnicodeEncoding.h +157 -0
  280. package/vendor/node-pty-fork/deps/winpty/src/agent/UnicodeEncodingTest.cc +189 -0
  281. package/vendor/node-pty-fork/deps/winpty/src/agent/Win32Console.cc +107 -0
  282. package/vendor/node-pty-fork/deps/winpty/src/agent/Win32Console.h +67 -0
  283. package/vendor/node-pty-fork/deps/winpty/src/agent/Win32ConsoleBuffer.cc +193 -0
  284. package/vendor/node-pty-fork/deps/winpty/src/agent/Win32ConsoleBuffer.h +99 -0
  285. package/vendor/node-pty-fork/deps/winpty/src/agent/main.cc +114 -0
  286. package/vendor/node-pty-fork/deps/winpty/src/agent/subdir.mk +61 -0
  287. package/vendor/node-pty-fork/deps/winpty/src/configurations.gypi +60 -0
  288. package/vendor/node-pty-fork/deps/winpty/src/debugserver/DebugServer.cc +117 -0
  289. package/vendor/node-pty-fork/deps/winpty/src/debugserver/subdir.mk +41 -0
  290. package/vendor/node-pty-fork/deps/winpty/src/include/winpty.h +242 -0
  291. package/vendor/node-pty-fork/deps/winpty/src/include/winpty_constants.h +131 -0
  292. package/vendor/node-pty-fork/deps/winpty/src/libwinpty/AgentLocation.cc +75 -0
  293. package/vendor/node-pty-fork/deps/winpty/src/libwinpty/AgentLocation.h +28 -0
  294. package/vendor/node-pty-fork/deps/winpty/src/libwinpty/LibWinptyException.h +54 -0
  295. package/vendor/node-pty-fork/deps/winpty/src/libwinpty/WinptyInternal.h +72 -0
  296. package/vendor/node-pty-fork/deps/winpty/src/libwinpty/subdir.mk +46 -0
  297. package/vendor/node-pty-fork/deps/winpty/src/libwinpty/winpty.cc +970 -0
  298. package/vendor/node-pty-fork/deps/winpty/src/shared/AgentMsg.h +38 -0
  299. package/vendor/node-pty-fork/deps/winpty/src/shared/BackgroundDesktop.cc +122 -0
  300. package/vendor/node-pty-fork/deps/winpty/src/shared/BackgroundDesktop.h +73 -0
  301. package/vendor/node-pty-fork/deps/winpty/src/shared/Buffer.cc +103 -0
  302. package/vendor/node-pty-fork/deps/winpty/src/shared/Buffer.h +102 -0
  303. package/vendor/node-pty-fork/deps/winpty/src/shared/DebugClient.cc +187 -0
  304. package/vendor/node-pty-fork/deps/winpty/src/shared/DebugClient.h +38 -0
  305. package/vendor/node-pty-fork/deps/winpty/src/shared/GenRandom.cc +138 -0
  306. package/vendor/node-pty-fork/deps/winpty/src/shared/GenRandom.h +55 -0
  307. package/vendor/node-pty-fork/deps/winpty/src/shared/GetCommitHash.bat +13 -0
  308. package/vendor/node-pty-fork/deps/winpty/src/shared/Mutex.h +54 -0
  309. package/vendor/node-pty-fork/deps/winpty/src/shared/OsModule.h +63 -0
  310. package/vendor/node-pty-fork/deps/winpty/src/shared/OwnedHandle.cc +36 -0
  311. package/vendor/node-pty-fork/deps/winpty/src/shared/OwnedHandle.h +45 -0
  312. package/vendor/node-pty-fork/deps/winpty/src/shared/PrecompiledHeader.h +43 -0
  313. package/vendor/node-pty-fork/deps/winpty/src/shared/StringBuilder.h +227 -0
  314. package/vendor/node-pty-fork/deps/winpty/src/shared/StringBuilderTest.cc +114 -0
  315. package/vendor/node-pty-fork/deps/winpty/src/shared/StringUtil.cc +55 -0
  316. package/vendor/node-pty-fork/deps/winpty/src/shared/StringUtil.h +80 -0
  317. package/vendor/node-pty-fork/deps/winpty/src/shared/TimeMeasurement.h +63 -0
  318. package/vendor/node-pty-fork/deps/winpty/src/shared/UnixCtrlChars.h +45 -0
  319. package/vendor/node-pty-fork/deps/winpty/src/shared/UpdateGenVersion.bat +20 -0
  320. package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsSecurity.cc +460 -0
  321. package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsSecurity.h +104 -0
  322. package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsVersion.cc +252 -0
  323. package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsVersion.h +29 -0
  324. package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyAssert.cc +55 -0
  325. package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyAssert.h +64 -0
  326. package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyException.cc +57 -0
  327. package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyException.h +43 -0
  328. package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyVersion.cc +42 -0
  329. package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyVersion.h +27 -0
  330. package/vendor/node-pty-fork/deps/winpty/src/shared/winpty_snprintf.h +99 -0
  331. package/vendor/node-pty-fork/deps/winpty/src/subdir.mk +5 -0
  332. package/vendor/node-pty-fork/deps/winpty/src/tests/subdir.mk +28 -0
  333. package/vendor/node-pty-fork/deps/winpty/src/tests/trivial_test.cc +158 -0
  334. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/InputHandler.cc +114 -0
  335. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/InputHandler.h +56 -0
  336. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/OutputHandler.cc +80 -0
  337. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/OutputHandler.h +53 -0
  338. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/Util.cc +86 -0
  339. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/Util.h +31 -0
  340. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/WakeupFd.cc +70 -0
  341. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/WakeupFd.h +42 -0
  342. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/main.cc +729 -0
  343. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/subdir.mk +41 -0
  344. package/vendor/node-pty-fork/deps/winpty/src/winpty.gyp +206 -0
  345. package/vendor/node-pty-fork/deps/winpty/vcbuild.bat +83 -0
  346. package/vendor/node-pty-fork/lib/conpty_console_list_agent.js +20 -0
  347. package/vendor/node-pty-fork/lib/conpty_console_list_agent.js.map +1 -0
  348. package/vendor/node-pty-fork/lib/eventEmitter2.js +47 -0
  349. package/vendor/node-pty-fork/lib/eventEmitter2.js.map +1 -0
  350. package/vendor/node-pty-fork/lib/eventEmitter2.test.js +30 -0
  351. package/vendor/node-pty-fork/lib/eventEmitter2.test.js.map +1 -0
  352. package/vendor/node-pty-fork/lib/index.js +51 -0
  353. package/vendor/node-pty-fork/lib/index.js.map +1 -0
  354. package/vendor/node-pty-fork/lib/interfaces.js +7 -0
  355. package/vendor/node-pty-fork/lib/interfaces.js.map +1 -0
  356. package/vendor/node-pty-fork/lib/shared/conout.js +11 -0
  357. package/vendor/node-pty-fork/lib/shared/conout.js.map +1 -0
  358. package/vendor/node-pty-fork/lib/terminal.js +190 -0
  359. package/vendor/node-pty-fork/lib/terminal.js.map +1 -0
  360. package/vendor/node-pty-fork/lib/terminal.test.js +139 -0
  361. package/vendor/node-pty-fork/lib/terminal.test.js.map +1 -0
  362. package/vendor/node-pty-fork/lib/testUtils.test.js +28 -0
  363. package/vendor/node-pty-fork/lib/testUtils.test.js.map +1 -0
  364. package/vendor/node-pty-fork/lib/types.js +7 -0
  365. package/vendor/node-pty-fork/lib/types.js.map +1 -0
  366. package/vendor/node-pty-fork/lib/unixTerminal.js +304 -0
  367. package/vendor/node-pty-fork/lib/unixTerminal.js.map +1 -0
  368. package/vendor/node-pty-fork/lib/unixTerminal.test.js +330 -0
  369. package/vendor/node-pty-fork/lib/unixTerminal.test.js.map +1 -0
  370. package/vendor/node-pty-fork/lib/utils.js +17 -0
  371. package/vendor/node-pty-fork/lib/utils.js.map +1 -0
  372. package/vendor/node-pty-fork/lib/windowsConoutConnection.js +122 -0
  373. package/vendor/node-pty-fork/lib/windowsConoutConnection.js.map +1 -0
  374. package/vendor/node-pty-fork/lib/windowsPtyAgent.js +324 -0
  375. package/vendor/node-pty-fork/lib/windowsPtyAgent.js.map +1 -0
  376. package/vendor/node-pty-fork/lib/windowsPtyAgent.test.js +90 -0
  377. package/vendor/node-pty-fork/lib/windowsPtyAgent.test.js.map +1 -0
  378. package/vendor/node-pty-fork/lib/windowsTerminal.js +201 -0
  379. package/vendor/node-pty-fork/lib/windowsTerminal.js.map +1 -0
  380. package/vendor/node-pty-fork/lib/windowsTerminal.test.js +203 -0
  381. package/vendor/node-pty-fork/lib/windowsTerminal.test.js.map +1 -0
  382. package/vendor/node-pty-fork/lib/worker/conoutSocketWorker.js +22 -0
  383. package/vendor/node-pty-fork/lib/worker/conoutSocketWorker.js.map +1 -0
  384. package/vendor/node-pty-fork/package.json +35 -0
  385. package/vendor/node-pty-fork/scripts/apply-patches.mjs +341 -0
  386. package/vendor/node-pty-fork/scripts/fetch-upstream.mjs +41 -0
  387. package/vendor/node-pty-fork/scripts/install-smoke.cjs +59 -0
  388. package/vendor/node-pty-fork/scripts/smoke-load.cjs +10 -0
  389. package/vendor/node-pty-fork/scripts/sync-upstream.mjs +29 -0
  390. package/vendor/node-pty-fork/scripts/verify-runtime.cjs +54 -0
  391. package/vendor/node-pty-fork/scripts/verify-runtime.test.cjs +22 -0
  392. package/vendor/node-pty-fork/scripts/verify-tarball.cjs +80 -0
  393. package/vendor/node-pty-fork/src/conpty_console_list_agent.ts +19 -0
  394. package/vendor/node-pty-fork/src/eventEmitter2.test.ts +30 -0
  395. package/vendor/node-pty-fork/src/eventEmitter2.ts +48 -0
  396. package/vendor/node-pty-fork/src/index.ts +51 -0
  397. package/vendor/node-pty-fork/src/interfaces.ts +129 -0
  398. package/vendor/node-pty-fork/src/native.d.ts +56 -0
  399. package/vendor/node-pty-fork/src/shared/conout.ts +15 -0
  400. package/vendor/node-pty-fork/src/terminal.test.ts +119 -0
  401. package/vendor/node-pty-fork/src/terminal.ts +211 -0
  402. package/vendor/node-pty-fork/src/testUtils.test.ts +23 -0
  403. package/vendor/node-pty-fork/src/tsconfig.json +22 -0
  404. package/vendor/node-pty-fork/src/types.ts +15 -0
  405. package/vendor/node-pty-fork/src/unix/pty.cc +826 -0
  406. package/vendor/node-pty-fork/src/unix/spawn-helper.cc +23 -0
  407. package/vendor/node-pty-fork/src/unixTerminal.test.ts +335 -0
  408. package/vendor/node-pty-fork/src/unixTerminal.ts +320 -0
  409. package/vendor/node-pty-fork/src/utils.ts +9 -0
  410. package/vendor/node-pty-fork/src/win/conpty.cc +500 -0
  411. package/vendor/node-pty-fork/src/win/conpty_console_list.cc +43 -0
  412. package/vendor/node-pty-fork/src/win/path_util.cc +73 -0
  413. package/vendor/node-pty-fork/src/win/path_util.h +22 -0
  414. package/vendor/node-pty-fork/src/win/winpty.cc +322 -0
  415. package/vendor/node-pty-fork/src/windowsConoutConnection.ts +79 -0
  416. package/vendor/node-pty-fork/src/windowsPtyAgent.test.ts +94 -0
  417. package/vendor/node-pty-fork/src/windowsPtyAgent.ts +323 -0
  418. package/vendor/node-pty-fork/src/windowsTerminal.test.ts +214 -0
  419. package/vendor/node-pty-fork/src/windowsTerminal.ts +208 -0
  420. package/vendor/node-pty-fork/src/worker/conoutSocketWorker.ts +22 -0
  421. package/vendor/node-pty-fork/typings/node-pty.d.ts +203 -0
  422. package/dist/public/assets/WorkbenchShellRoute-DyaMnPfS.js +0 -1
  423. package/dist/server/modules/channels/wechat-claw-client.d.ts +0 -51
  424. package/dist/server/modules/channels/wechat-claw-client.js +0 -245
  425. package/dist/server/modules/channels/wechat-claw-client.js.map +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileContextPanel-BcM7AIT4.js","assets/index-CuzMc7q2.js","assets/index-CcaQt50x.css","assets/App-tPcbyRdS.js","assets/App-CcDXqFl1.css","assets/model-switch-api-c6kcbBGm.js","assets/WorkbenchModal-Bt_1fYmM.js","assets/file-tree-icon-BeHqeru9.js","assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js","assets/relay-entry-C751A-Sm.js","assets/GitSidebar-CMtkaxuI.js","assets/TerminalManagerPanel-BxlhZp8c.js","assets/terminal-runtime-meta-CRAVR-8G.js","assets/TerminalRuntimeFallbackModal-BVLfrpSa.js"])))=>i.map(i=>d[i]);
2
- var qk=Object.defineProperty;var Gk=(e,t,n)=>t in e?qk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var at=(e,t,n)=>Gk(e,typeof t!="symbol"?t+"":t,n);import{C as pe,t as l,b as f,j as s,e as ar,m as ca,H as pu,J as Of,F as Vk,K as Kk,w as fu,A as mu,g as Wf,D as Yk,p as Zo,L as Xk,M as Jk,N as Ff,i as $f,O as Tc,f as gu,h as Ic,P as Qk,l as zf,y as Zk,n as ey,z as ty,d as ny,_ as bu}from"./index-CuzMc7q2.js";import{m as vt,e as $n,h as el,u as xa,f as lr,g as Fr,i as ry,j as sy,O as gd}from"./App-tPcbyRdS.js";import{e as ku,f as Mn,i as mi,j as Jt,k as $a,V as Ro,A as iy,h as Lt,v as Ss,a2 as bd,a3 as ay,a4 as oy,H as Hf,l as ly,m as cy,a5 as Uf,a6 as uy,M as dy,a7 as hy,a8 as py,n as fy,o as my,t as gy,q as by,s as qf,a as Ec,p as yu,a9 as ky,aa as yy,ab as xy,u as za,g as wy,ac as vy,ad as Sy,ae as Cy,af as Gf,ag as Ny,ah as Vf,ai as jy,aj as Ty,ak as Kf,K as Iy,S as Ey,R as kd,r as My,al as Ry}from"./model-switch-api-c6kcbBGm.js";import{t as ui,P as Po,g as Yf}from"./window-BVUB8gMK.js";import{R as Py,_ as yd,a as xd,C as Xf,i as ze}from"./event-DvH9tcej.js";import{W as St,M as Ay,D as xu}from"./WorkbenchModal-Bt_1fYmM.js";import{r as Ly,b as _y}from"./relay-entry-C751A-Sm.js";const di=new Map,Jf=48;function As(){return typeof window<"u"&&typeof window.sessionStorage<"u"}function wd(e,t){return!Number.isFinite(e)||Date.now()-e>t}function Dy(e){return!e||typeof e!="object"||!("savedAt"in e)||!("value"in e)?!1:Number.isFinite(e.savedAt)}function Qf(e){try{const t=JSON.parse(e);return Dy(t)?t:null}catch{return null}}function By(){if(!As())return[];try{return Array.from({length:window.sessionStorage.length},(e,t)=>window.sessionStorage.key(t)).filter(e=>typeof e=="string"&&e.length>0)}catch{return[]}}function Zf(){if(!As())return[];const e=[];for(const t of By()){let n=null;try{n=window.sessionStorage.getItem(t)}catch{continue}if(!n)continue;const r=Qf(n);r&&e.push({key:t,savedAt:r.savedAt})}return e.sort((t,n)=>t.savedAt-n.savedAt)}function ua(e){if(As())try{window.sessionStorage.removeItem(e)}catch{}}function Ha(e){const t=new Set((e==null?void 0:e.preserveKeys)??[]),n=(e==null?void 0:e.maxCount)??Jf,r=Zf().filter(a=>!t.has(a.key)),i=Math.max(0,t.size+r.length-n);for(let a=0;a<i;a+=1){const o=r[a];if(!o)break;ua(o.key)}}function Oy(e){return e instanceof DOMException&&(e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED"||e.code===22||e.code===1014)}function Ll(e,t){if(!As())return"failed";try{return window.sessionStorage.setItem(e,t),"success"}catch(n){return Oy(n)?"quota_exceeded":"failed"}}function Wy(e,t){const n=Ll(e,t);if(n==="success"){Ha({preserveKeys:[e]});return}if(n==="quota_exceeded"){if(ua(e),Ha({maxCount:Math.max(0,Jf-1)}),Ll(e,t)==="success"){Ha({preserveKeys:[e]});return}for(const r of Zf())if(r.key!==e&&(ua(r.key),Ll(e,t)==="success")){Ha({preserveKeys:[e]});return}}}function Ao(e,t){const n=di.get(e);if(n){if(!wd(n.savedAt,t))return n.value;di.delete(e)}if(!As())return null;let r=null;try{r=window.sessionStorage.getItem(e)}catch{return null}if(!r)return null;const i=Qf(r);return!i||wd(i.savedAt,t)?(ua(e),di.delete(e),null):(di.set(e,i),i.value)}function ra(e,t){const n={savedAt:Date.now(),value:t};if(di.set(e,n),!!As())try{Wy(e,JSON.stringify(n))}catch{}}function XA(e){di.delete(e),As()&&ua(e)}const Fy="codingns.debug.perf",$y="codingns.debug.sessionMessageDedup",zy="codingns.debug.timelineScroll",Hy="codingns.debug.conversationTimeline";function Uy(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Fy)==="1"}catch{return!1}}function un(e,t){if(!Uy()||typeof performance>"u")return;const n=Math.round(performance.now());if(t&&Object.keys(t).length>0){console.info(`[perf-ui] ${e} ${n}ms`,t);return}console.info(`[perf-ui] ${e} ${n}ms`)}function qy(){if(typeof window>"u")return!1;try{return window.localStorage.getItem($y)==="1"}catch{return!1}}function os(e,t){if(!qy()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,a=i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__??[];a.push(r),a.length>300&&a.splice(0,a.length-300),i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__=a}catch{}if(t&&Object.keys(t).length>0){console.info(`[session-dedup] ${e} ${n}ms`,t);return}console.info(`[session-dedup] ${e} ${n}ms`)}function Gy(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Hy)==="1"}catch{return!1}}function Vy(e,t){if(!Gy()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window;i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG_CLEARED__!==!0&&(i.__CODINGNS_OPENCODE_ORDER_DEBUG__=[],i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__=[],i.__CODINGNS_TIMELINE_SCROLL_DEBUG__=[],i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG__=[],i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG_CLEARED__=!0);const a=i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG__??[];a.push(r),a.length>400&&a.splice(0,a.length-400),i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG__=a}catch{}if(t&&Object.keys(t).length>0){console.info(`[conversation-timeline] ${e} ${n}ms`,t);return}console.info(`[conversation-timeline] ${e} ${n}ms`)}function Mc(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(zy)==="1"}catch{return!1}}function Ky(e,t){if(!Mc()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,a=i.__CODINGNS_TIMELINE_SCROLL_DEBUG__??[];a.push(r),a.length>300&&a.splice(0,a.length-300),i.__CODINGNS_TIMELINE_SCROLL_DEBUG__=a}catch{}if(t&&Object.keys(t).length>0){console.info(`[timeline-scroll] ${e} ${n}ms`,t);return}console.info(`[timeline-scroll] ${e} ${n}ms`)}function em(e){return pe.request(`/api/office/artifacts/${encodeURIComponent(e)}/preview-link`)}function tm(e,t){return pe.request(`/api/office/tasks/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}/preview-link`)}function JA(e,t){const n=new URLSearchParams({workspaceId:e});return t&&n.set("path",t),pe.request(`/api/files/tree?${n.toString()}`)}function QA(e,t,n,r){return pe.request("/api/files/content",{method:"PUT",body:JSON.stringify({workspaceId:e,path:t,content:n,expectedVersion:r??void 0})})}function ZA(e){return pe.request("/api/files/ops",{method:"POST",body:JSON.stringify(e)})}function eL(e){return pe.request("/api/files/upload",{method:"POST",body:JSON.stringify(e)})}function tL(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return pe.request(`/api/files/download?${n.toString()}`)}function Yy(e,t,n=1,r=20){const i=new URLSearchParams({workspaceId:e,keyword:t,page:String(n),pageSize:String(r)});return pe.request(`/api/files/search?${i.toString()}`)}function nL(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return pe.request(`/api/files/preview?${n.toString()}`)}function nm(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return pe.request(`/api/files/preview-link?${n.toString()}`)}function rL(e){return pe.request(`/api/git/status?workspaceId=${encodeURIComponent(e)}`)}function sL(e){return pe.request("/api/git/init",{method:"POST",body:JSON.stringify({workspaceId:e})})}function iL(e,t,n){const r=new URLSearchParams({workspaceId:e,path:t,staged:String(n)});return pe.request(`/api/git/diff?${r.toString()}`)}function aL(e,t){return pe.request("/api/git/stage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function oL(e,t){return pe.request("/api/git/unstage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function lL(e,t){return pe.request("/api/git/discard",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function cL(e,t){return pe.request("/api/git/commit/draft",{method:"POST",body:JSON.stringify({workspaceId:e,mode:t})})}function uL(e,t){return pe.request("/api/git/commit",{method:"POST",body:JSON.stringify({workspaceId:e,draft:t})})}function dL(e){return pe.request("/api/git/commit/undo",{method:"POST",body:JSON.stringify({workspaceId:e})})}function hL(e,t=5,n=null){const r=new URLSearchParams({workspaceId:e,limit:String(t)});return n&&r.set("cursor",n),pe.request(`/api/git/history?${r.toString()}`)}function pL(e,t){const n=new URLSearchParams({workspaceId:e,commitHash:t});return pe.request(`/api/git/commit-detail?${n.toString()}`)}function Xy(e){return pe.request(`/api/git/branches?workspaceId=${encodeURIComponent(e)}`)}function Jy(e){return pe.request(`/api/git/tags?workspaceId=${encodeURIComponent(e)}`)}function fL(e,t,n){return pe.request("/api/git/branches/switch",{method:"POST",body:JSON.stringify({workspaceId:e,branchName:t,create:n})})}function mL(e,t,n,r,i){return pe.request("/api/git/remote/sync",{method:"POST",body:JSON.stringify({workspaceId:e,action:t,...n?{remote:n}:{},...r?{auth:r}:{},...i?{remember:i}:{}})})}function gL(e){return pe.request(`/api/git/remotes?workspaceId=${encodeURIComponent(e)}`)}var Co,No;function rm(e){var t;if("items"in e)e.items=(t=e.items)===null||t===void 0?void 0:t.map(n=>"rid"in n?n:rm(n));else if("action"in e&&e.action){const n=new Xf;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function Si(e,t){const n=new Xf;if(t&&typeof t=="object"&&("action"in t&&t.action&&(n.onmessage=t.action,delete t.action),"item"in t&&t.item&&typeof t.item=="object"&&"About"in t.item&&t.item.About&&typeof t.item.About=="object"&&"icon"in t.item.About&&t.item.About.icon&&(t.item.About.icon=ui(t.item.About.icon)),"icon"in t&&t.icon&&(t.icon=ui(t.icon)),"items"in t&&t.items)){let r=function(i){var a;return"rid"in i?[i.rid,i.kind]:("item"in i&&typeof i.item=="object"&&(!((a=i.item.About)===null||a===void 0)&&a.icon)&&(i.item.About.icon=ui(i.item.About.icon)),"icon"in i&&i.icon&&(i.icon=ui(i.icon)),"items"in i&&i.items&&(i.items=i.items.map(r)),rm(i))};t.items=t.items.map(r)}return ze("plugin:menu|new",{kind:e,options:t,handler:n})}class Ci extends Py{get id(){return yd(this,Co,"f")}get kind(){return yd(this,No,"f")}constructor(t,n,r){super(t),Co.set(this,void 0),No.set(this,void 0),xd(this,Co,n),xd(this,No,r)}}Co=new WeakMap,No=new WeakMap;class wu extends Ci{constructor(t,n){super(t,n,"MenuItem")}static async new(t){return Si("MenuItem",t).then(([n,r])=>new wu(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ze("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ze("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return ze("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}}class vu extends Ci{constructor(t,n){super(t,n,"Check")}static async new(t){return Si("Check",t).then(([n,r])=>new vu(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ze("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ze("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return ze("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async isChecked(){return ze("plugin:menu|is_checked",{rid:this.rid})}async setChecked(t){return ze("plugin:menu|set_checked",{rid:this.rid,checked:t})}}var vd;(function(e){e.Add="Add",e.Advanced="Advanced",e.Bluetooth="Bluetooth",e.Bookmarks="Bookmarks",e.Caution="Caution",e.ColorPanel="ColorPanel",e.ColumnView="ColumnView",e.Computer="Computer",e.EnterFullScreen="EnterFullScreen",e.Everyone="Everyone",e.ExitFullScreen="ExitFullScreen",e.FlowView="FlowView",e.Folder="Folder",e.FolderBurnable="FolderBurnable",e.FolderSmart="FolderSmart",e.FollowLinkFreestanding="FollowLinkFreestanding",e.FontPanel="FontPanel",e.GoLeft="GoLeft",e.GoRight="GoRight",e.Home="Home",e.IChatTheater="IChatTheater",e.IconView="IconView",e.Info="Info",e.InvalidDataFreestanding="InvalidDataFreestanding",e.LeftFacingTriangle="LeftFacingTriangle",e.ListView="ListView",e.LockLocked="LockLocked",e.LockUnlocked="LockUnlocked",e.MenuMixedState="MenuMixedState",e.MenuOnState="MenuOnState",e.MobileMe="MobileMe",e.MultipleDocuments="MultipleDocuments",e.Network="Network",e.Path="Path",e.PreferencesGeneral="PreferencesGeneral",e.QuickLook="QuickLook",e.RefreshFreestanding="RefreshFreestanding",e.Refresh="Refresh",e.Remove="Remove",e.RevealFreestanding="RevealFreestanding",e.RightFacingTriangle="RightFacingTriangle",e.Share="Share",e.Slideshow="Slideshow",e.SmartBadge="SmartBadge",e.StatusAvailable="StatusAvailable",e.StatusNone="StatusNone",e.StatusPartiallyAvailable="StatusPartiallyAvailable",e.StatusUnavailable="StatusUnavailable",e.StopProgressFreestanding="StopProgressFreestanding",e.StopProgress="StopProgress",e.TrashEmpty="TrashEmpty",e.TrashFull="TrashFull",e.User="User",e.UserAccounts="UserAccounts",e.UserGroup="UserGroup",e.UserGuest="UserGuest"})(vd||(vd={}));class Su extends Ci{constructor(t,n){super(t,n,"Icon")}static async new(t){return Si("Icon",t).then(([n,r])=>new Su(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ze("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ze("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return ze("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async setIcon(t){return ze("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:ui(t)})}}class Cu extends Ci{constructor(t,n){super(t,n,"Predefined")}static async new(t){return Si("Predefined",t).then(([n,r])=>new Cu(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}}function gi([e,t,n]){switch(n){case"Submenu":return new tl(e,t);case"Predefined":return new Cu(e,t);case"Check":return new vu(e,t);case"Icon":return new Su(e,t);case"MenuItem":default:return new wu(e,t)}}class tl extends Ci{constructor(t,n){super(t,n,"Submenu")}static async new(t){return Si("Submenu",t).then(([n,r])=>new tl(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ze("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ze("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async append(t){return ze("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async prepend(t){return ze("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async insert(t,n){return ze("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r),position:n})}async remove(t){return ze("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return ze("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(gi)}async items(){return ze("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(gi))}async get(t){return ze("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?gi(n):null)}async popup(t,n){var r;return ze("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(r=n==null?void 0:n.label)!==null&&r!==void 0?r:null,at:t instanceof Po?t:t?new Po(t):null})}async setAsWindowsMenuForNSApp(){return ze("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return ze("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(t){return ze("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:ui(t)})}}class hi extends Ci{constructor(t,n){super(t,n,"Menu")}static async new(t){return Si("Menu",t).then(([n,r])=>new hi(n,r))}static async default(){return ze("plugin:menu|create_default").then(([t,n])=>new hi(t,n))}async append(t){return ze("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async prepend(t){return ze("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async insert(t,n){return ze("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r),position:n})}async remove(t){return ze("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return ze("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(gi)}async items(){return ze("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(gi))}async get(t){return ze("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?gi(n):null)}async popup(t,n){var r;return ze("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(r=n==null?void 0:n.label)!==null&&r!==void 0?r:null,at:t instanceof Po?t:t?new Po(t):null})}async setAsAppMenu(){return ze("plugin:menu|set_as_app_menu",{rid:this.rid}).then(t=>t?new hi(t[0],t[1]):null)}async setAsWindowMenu(t){var n;return ze("plugin:menu|set_as_window_menu",{rid:this.rid,window:(n=t==null?void 0:t.label)!==null&&n!==void 0?n:null}).then(r=>r?new hi(r[0],r[1]):null)}}async function Qy(e){if(e.length===0)return;await(await hi.new({items:await Promise.all(e.map(n=>sm(n)))})).popup(void 0,Yf())}async function sm(e){return"items"in e?tl.new({id:e.id,text:e.label,enabled:!e.disabled,items:await Promise.all(e.items.map(t=>sm(t)))}):{id:e.id,text:e.label,enabled:!e.disabled,accelerator:e.accelerator,action:()=>{e.onSelect()}}}const Sd={"parallel-group-1":{accent:"#0ea5e9",soft:"rgba(14, 165, 233, 0.16)",surface:"rgba(14, 165, 233, 0.08)"},"parallel-group-2":{accent:"#10b981",soft:"rgba(16, 185, 129, 0.16)",surface:"rgba(16, 185, 129, 0.08)"},"parallel-group-3":{accent:"#f59e0b",soft:"rgba(245, 158, 11, 0.16)",surface:"rgba(245, 158, 11, 0.08)"},"parallel-group-4":{accent:"#ec4899",soft:"rgba(236, 72, 153, 0.16)",surface:"rgba(236, 72, 153, 0.08)"},"parallel-group-5":{accent:"#8b5cf6",soft:"rgba(139, 92, 246, 0.16)",surface:"rgba(139, 92, 246, 0.08)"},"parallel-group-6":{accent:"#f97316",soft:"rgba(249, 115, 22, 0.16)",surface:"rgba(249, 115, 22, 0.08)"}},Zy=2600,im="workbench.parallel.pane.palette";let ii=null;const Cd=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"];function ex(e="create"){return e==="append"?{totalDurationMs:1200,sidebarCollapseDurationMs:0,paneEnterDelayMs:0,paneEnterDurationMs:1e3,gridRevealDelayMs:0,gridRevealDurationMs:920,shellExpandDurationMs:0,paneStaggerMs:80}:{totalDurationMs:2e3,sidebarCollapseDurationMs:720,paneEnterDelayMs:520,paneEnterDurationMs:1480,gridRevealDelayMs:420,gridRevealDurationMs:1360,shellExpandDurationMs:720,paneStaggerMs:96}}function am(e){var n,r;const t=(n=e.displayParentSessionId)==null?void 0:n.trim();return t||((r=e.parentSessionId)==null?void 0:r.trim())||null}function tx(e){var r;const t=(r=e==null?void 0:e.colorToken)==null?void 0:r.trim();if(!t)return;const n=Sd[t]??Sd["parallel-group-1"];return{"--parallel-group-accent":n.accent,"--parallel-group-soft":n.soft,"--parallel-group-surface":n.surface}}function bL(e){const t=Lo(e.overrideColor)??nx(e.groupId,e.ordinal);return{"--parallel-group-accent":t,"--parallel-group-soft":Nd(t,.08),"--parallel-group-surface":Nd(t,.03)}}function kL(e){if(typeof window>"u")return null;const t=e.trim();if(!t)return null;const n=om();return Lo(n[t]??null)}function yL(e,t){if(typeof window>"u")return Lo(t);const n=e.trim();if(!n)return null;const r=om(),i=Lo(t);return i?r[n]=i:delete r[n],window.localStorage.setItem(im,JSON.stringify(r)),i}function nx(e,t){const n=Cd.length,r=Math.abs(lx(e))%n;return Cd[(r+t*5)%n]}function xL(e){return e?e.role==="anchor"?l("shell.parallelGroupAnchorBadge"):l("shell.parallelGroupMemberBadge"):null}function rx(e){return e?l("shell.parallelGroupBadge",{count:e.memberCount}):null}function wL(e){var n;return((n=e==null?void 0:e.branchName)==null?void 0:n.trim())||null}function vL(e){var n,r,i;return((r=(n=e==null?void 0:e.parallelGroup)==null?void 0:n.groupId)==null?void 0:r.trim())?((i=e==null?void 0:e.sessionIsolatedWorkspace)==null?void 0:i.lifecycleStatus)!=="promoted":!1}function sx(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="removing")?t.sourceWorkspaceId:e.workspaceId}function ix(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="promoted")?t.workspaceId:e.workspaceId}function ax(e,t="create"){ii={groupId:e,createdAt:Date.now(),...ex(t)}}function ox(e){return!ii||ii.groupId!==e?null:Date.now()-ii.createdAt>Zy?(ii=null,null):ii}function om(){if(typeof window>"u")return{};const e=window.localStorage.getItem(im);if(!e)return{};try{const t=JSON.parse(e);return!t||typeof t!="object"?{}:t}catch{return{}}}function lx(e){let t=0;for(const n of e)t=t*31+n.charCodeAt(0)|0;return t}function Lo(e){const t=(e==null?void 0:e.trim().toUpperCase())??"";return/^#[0-9A-F]{6}$/.test(t)?t:null}function Nd(e,t){const n=Math.max(0,Math.min(t,1)),r=Number.parseInt(e.slice(1,3),16),i=Number.parseInt(e.slice(3,5),16),a=Number.parseInt(e.slice(5,7),16);return`rgba(${r}, ${i}, ${a}, ${n})`}function Nu(e,t){const n=new Map(e.map(a=>[t.getId(a),a])),r=new Map,i=[];for(const a of e){const o=cx(a,n,t);if(!o){i.push(a);continue}const c=r.get(o)??[];r.set(o,[...c,a])}return[...i].sort(t.compare).map(a=>um(a,0,r,t,new Set))}function Ni(e){return Array.isArray(e==null?void 0:e.children)?e.children:[]}function lm(e){return e.flatMap(t=>[t.item,...lm(Ni(t))])}function Ns(e){return e.flatMap(t=>[t,...Ns(Ni(t))])}function ju(e,t){return e.some(n=>t(n.item)||ju(Ni(n),t))}function cm(e,t,n){return e?n(e.item)===t?!0:Ni(e).some(r=>cm(r,t,n)):!1}function ai(e,t,n){for(const r of e){const i=n(r.item);if(i===t)return[];const a=ai(Ni(r),t,n);if(cm(r,t,n)&&a.length>=0)return[i,...a]}return[]}function um(e,t,n,r,i){const a=r.getId(e),o=new Set(i);o.add(a);const c=[...n.get(a)??[]].filter(u=>!o.has(r.getId(u))).sort(r.compare).map(u=>um(u,t+1,n,r,o));return{item:e,depth:t,children:c}}function cx(e,t,n){const r=jd(n.getParentId(e));if(!r)return null;const i=t.get(r);if(!i)return null;const a=new Set([n.getId(e)]);let o=i;for(;o;){const c=n.getId(o);if(a.has(c))return null;a.add(c);const u=jd(n.getParentId(o));if(!u||(o=t.get(u),!o))return r}return r}function jd(e){const t=e==null?void 0:e.trim();return t||null}function xn(){return"/workspaces"}function Ir(e){return`/workspaces/${encodeURIComponent(e)}`}function dm(e){return`${Ir(e)}/debug`}function xi(e){return`${Ir(e)}/sessions`}function ir(e,t){return`${xi(e)}/${encodeURIComponent(t)}`}function hm(e,t){const n=`${Ir(e)}/tools`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function pm(e){return`${Ir(e)}/tools/files`}function fm(e){return`${Ir(e)}/tools/git`}function mm(e){return`${Ir(e)}/tools/processes`}function js(e){return`${Ir(e)}/terminals`}function Ms(e,t){const n=`${Ir(e)}/butler`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function ux(e){return km(e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),...bm(t.childWorktrees??[])])).sort((t,n)=>(n.session.lastMessageAt??n.session.updatedAt).localeCompare(t.session.lastMessageAt??t.session.updatedAt))}function SL(e,t){return Nu(km(e),{getId:n=>n.session.sessionId,getParentId:n=>dx(n.session,t),compare:px})}function dx(e,t){var n;return(t==null?void 0:t.mode)==="mobile"?((n=e.parentSessionId)==null?void 0:n.trim())||null:am(e)}function gm(e,t){const n=hx(),r=new URLSearchParams({provider:t});return`${ir(e,n)}?${r.toString()}`}function hx(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`draft-${e.randomUUID()}`:`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`}function px(e,t){return(t.session.lastMessageAt??t.session.updatedAt).localeCompare(e.session.lastMessageAt??e.session.updatedAt)}function bm(e){return e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),...bm(t.children)])}function km(e){const t=[],n=new Set;for(const r of e){const i=r.session.sessionId.trim();!i||n.has(i)||(n.add(i),t.push(r))}return t}const fx="mobile.tools.last-primary-tool";function ym(){if(typeof window>"u")return"files";try{return window.localStorage.getItem(fx)==="git"?"git":"files"}catch{return"files"}}function Tu(e){var r;const t=[{pattern:"/workspaces/:workspaceId/tools/processes",routeKind:"processes"},{pattern:"/workspaces/:workspaceId/tools/files",routeKind:"files"},{pattern:"/workspaces/:workspaceId/tools/git",routeKind:"git"},{pattern:"/workspaces/:workspaceId/tools",routeKind:"home"}];for(const i of t){const a=vt(i.pattern,e),o=((r=a==null?void 0:a.params.workspaceId)==null?void 0:r.trim())??null;if(o)return{workspaceId:o,routeKind:i.routeKind,legacy:!1}}const n=[{pattern:"/tools/processes",routeKind:"processes"},{pattern:"/tools/files",routeKind:"files"},{pattern:"/tools/git",routeKind:"git"},{pattern:"/tools",routeKind:"home"}];for(const i of n)if(vt(i.pattern,e))return{workspaceId:null,routeKind:i.routeKind,legacy:!0};return null}function mx(e,t){const n=Tu(e);if((n==null?void 0:n.routeKind)==="git")return"git";if((n==null?void 0:n.routeKind)==="files")return"files";const r=new URLSearchParams(t).get("tab");return r==="git"?"git":r==="files"?"files":ym()}function Iu(e,t){const n=Tu(e);return(n==null?void 0:n.routeKind)==="processes"&&n.workspaceId?js(n.workspaceId):n!=null&&n.workspaceId?hm(n.workspaceId,mx(e,t)):n!=null&&n.legacy?ym()==="git"?"/tools?tab=git":"/tools?tab=files":null}function Eu({activeEntry:e,presentation:t,pathname:n,search:r,moreButtonLabel:i}){if(t==="conversation-focus"||e!=="butler")return null;const a=Tu(n);return a?a.routeKind==="processes"?{title:l("shell.terminalManagerEntry"),showBackButton:!0,showMoreButton:!1,moreButtonLabel:i}:(a.routeKind==="home"||a.routeKind==="files"||a.routeKind==="git",null):null}const xm=f.createContext({composerPortalTarget:null});function Mu({composerPortalTarget:e,children:t}){return s.jsx(xm.Provider,{value:{composerPortalTarget:e},children:t})}function CL(){return f.useContext(xm)}function Ru(e,t,n){const[r,i]=f.useState(void 0);return f.useEffect(()=>{const a=e.current,o=t.current;if(!n||!a||!o){i(void 0),a&&a.style.removeProperty("--mobile-conversation-tabbar-height");return}const c=a,u=o;function d(){if(!e.current||!u.isConnected)return;const p=`${Math.round(u.getBoundingClientRect().height)}px`;c.style.setProperty("--mobile-conversation-tabbar-height",p),i(p)}d();const h=typeof ResizeObserver<"u"?new ResizeObserver(d):null;return h==null||h.observe(u),window.addEventListener("resize",d),()=>{h==null||h.disconnect(),window.removeEventListener("resize",d),c.style.removeProperty("--mobile-conversation-tabbar-height")}},[n,e,t]),r}const gx=3e3,Ua=10,Td=84,Id=.36;function Pu({enabled:e,rootRef:t,suspended:n=!1,resetKey:r}){const i=f.useRef(null),a=f.useRef(null),o=f.useRef("visible"),c=f.useRef(1),[u,d]=f.useState("visible"),[h,p]=f.useState(1);f.useEffect(()=>{o.current=u},[u]),f.useEffect(()=>{c.current=h},[h]);function g(){xs(i),i.current=window.setTimeout(()=>{m()},gx)}function m(){d("hidden"),p(0)}function y(){d("visible"),p(1),g()}f.useEffect(()=>{if(xs(i),!e){xs(i),d("visible"),p(1);return}if(n){d("hidden"),p(0);return}return y(),()=>{xs(i)}},[e,r,n]),f.useEffect(()=>()=>{xs(i)},[]),f.useEffect(()=>{if(!e||n){a.current=null;return}const j=t.current;if(!j)return;function x(z){if(z.touches.length!==1){a.current=null;return}const L=z.touches[0],E=Rd(z.target);if(!L||!E){a.current=null;return}a.current={surface:E,startX:L.clientX,startY:L.clientY,pointerType:"touch",initialState:o.current==="visible"?"visible":"hidden",touchId:L.identifier,dragging:!1,latestProgress:c.current},o.current==="visible"&&xs(i)}function A(z){const L=a.current;if(!L||L.pointerType!=="touch")return;const E=_l(z.touches,L.touchId);if(!E)return;const H=E.clientX-L.startX,B=E.clientY-L.startY;if(L.surface==="conversation"){if(Math.abs(B)<=Ua||Math.abs(B)<=Math.abs(H))return;a.current=null,L.initialState==="visible"&&m();return}const oe=L.initialState==="hidden"?-B:B;oe<=Ua&&!L.dragging||(Ad(z),L.dragging=!0,L.latestProgress=Ed(L.initialState,oe),d("dragging"),p(L.latestProgress))}function T(z){const L=a.current;if(!(!L||L.pointerType!=="touch"||!_l(z.changedTouches,L.touchId))){if(a.current=null,!L.dragging){L.initialState==="visible"&&g();return}Md(L.initialState,L.latestProgress,y,d,p)}}function F(z){const L=a.current;if(!(!L||L.pointerType!=="touch"||!_l(z.changedTouches,L.touchId))){if(a.current=null,!L.dragging){L.initialState==="visible"&&g();return}if(L.initialState==="visible"){y();return}d("hidden"),p(0)}}function R(z){if(z.pointerType!=="touch")return;const L=Rd(z.target);if(!L){a.current=null;return}if(a.current={surface:L,startX:z.clientX,startY:z.clientY,pointerType:"pointer",initialState:o.current==="visible"?"visible":"hidden",pointerId:z.pointerId,captureTarget:z.target instanceof Element?z.target:null,dragging:!1,latestProgress:c.current},z.target instanceof Element)try{z.target.setPointerCapture(z.pointerId)}catch{}o.current==="visible"&&xs(i)}function I(z){const L=a.current;if(!L||L.pointerType!=="pointer")return;const E=z.clientX-L.startX,H=z.clientY-L.startY;if(L.surface==="conversation"){if(Math.abs(H)<=Ua||Math.abs(H)<=Math.abs(E))return;a.current=null,L.initialState==="visible"&&m();return}const B=L.initialState==="hidden"?-H:H;B<=Ua&&!L.dragging||(Ad(z),L.dragging=!0,L.latestProgress=Ed(L.initialState,B),d("dragging"),p(L.latestProgress))}function G(z){const L=a.current;if(!(!L||L.pointerType!=="pointer"||L.pointerId!==z.pointerId)){if(a.current=null,bx(L),!L.dragging){L.initialState==="visible"&&g();return}Md(L.initialState,L.latestProgress,y,d,p)}}return j.addEventListener("touchstart",x,{passive:!0}),j.addEventListener("pointerdown",R,{passive:!0}),window.addEventListener("touchmove",A,{passive:!1}),window.addEventListener("touchend",T),window.addEventListener("touchcancel",F),window.addEventListener("pointermove",I,{passive:!1}),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G),()=>{j.removeEventListener("touchstart",x),j.removeEventListener("pointerdown",R),window.removeEventListener("touchmove",A),window.removeEventListener("touchend",T),window.removeEventListener("touchcancel",F),window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G)}},[e,t,n]);const S=e&&!n?h:e?0:1;return{state:n&&e?"hidden":u,progress:S,isOpen:S>.01}}function xs(e){e.current!==null&&(window.clearTimeout(e.current),e.current=null)}function Ed(e,t){return Pd(e==="hidden"?t/Td:1-t/Td,0,1)}function Md(e,t,n,r,i){if(e==="hidden"){if(t>=Id){n();return}r("hidden"),i(0);return}if(t<=1-Id){r("hidden"),i(0);return}n()}function bx(e){if(!(e.pointerType!=="pointer"||typeof e.pointerId!="number"||!(e.captureTarget instanceof Element)))try{e.captureTarget.hasPointerCapture(e.pointerId)&&e.captureTarget.releasePointerCapture(e.pointerId)}catch{}}function _l(e,t){if(typeof t!="number")return e[0]??null;for(let n=0;n<e.length;n+=1){const r=e[n];if((r==null?void 0:r.identifier)===t)return r}return null}function Rd(e){return e instanceof Element?e.closest(".composer-panel")?"composer":e.closest(".message-list, .message-timeline, .mobile-conversation-main, .conversation-page-shell, .mobile-butler-main-stage, .mobile-butler-chat-body, .mobile-butler-page-shell")?"conversation":null:null}function Pd(e,t,n){return Math.min(Math.max(e,t),n)}function Ad(e){e.cancelable&&e.preventDefault()}function wa({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i=!1}){return i||e==="compact"?"compact":e==="expanded"&&n&&r?"expanded":t==="butler"&&r?"medium-auxiliary":n?"medium-navigation":r?"medium-auxiliary":"compact"}function nl(e){return!e.isNativeMobile||e.viewportClass==="expanded"||typeof window>"u"?!1:window.innerHeight>window.innerWidth}function wm(e){return e==="medium-navigation"||e==="expanded"}function vm(e){return e==="medium-auxiliary"||e==="expanded"}function Au({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i=!1,children:a,navigationPanel:o,auxiliaryPanel:c}){const u=wa({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i}),d=wm(u)&&o,h=vm(u)&&c;return s.jsxs("div",{className:"mobile-adaptive-pane-layout","data-pane-layout":u,children:[d?s.jsx("aside",{className:"workbench-nav surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-navigation",children:o}):null,s.jsx("div",{className:"mobile-adaptive-pane-main",children:a}),h?s.jsx("aside",{className:"workbench-auxiliary surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-auxiliary",children:c}):null]})}function kx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:a,onNavigateTerminals:o,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=$n(),g=ku(),m=el(),y=xa(),S=f.useRef(null),j=f.useRef(null),[x,A]=f.useState(null),T=t==="conversation-focus",F=nl({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),R=Pu({enabled:T,rootRef:S,resetKey:`${m.pathname}${m.search}`}),I=wa({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:F}),G=Eu({activeEntry:e,presentation:t,pathname:m.pathname,search:m.search,moreButtonLabel:l("shell.androidMoreAction")}),z=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(wx,{}),onClick:a},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(vx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Cx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(Sx,{}),onClick:o},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Nx,{}),onClick:h}],L=T?{"--mobile-conversation-tabbar-progress":R.progress.toFixed(4)}:void 0;Ru(S,j,T);function E(){const B=Iu(m.pathname,m.search);if(!B){o();return}y(B,{replace:!0})}const H=s.jsx("nav",{ref:j,className:"android-workbench-bottom-nav","aria-label":l("shell.title"),children:z.map(B=>s.jsxs("button",{type:"button",className:"android-workbench-bottom-nav-item","data-active":B.key===e,"aria-current":B.key===e?"page":void 0,onClick:()=>{B.key!==e&&g.trigger("selection"),B.onClick()},children:[s.jsx("span",{className:"android-workbench-bottom-nav-icon","aria-hidden":"true",children:B.icon}),s.jsx("span",{className:"android-workbench-bottom-nav-label",children:B.label})]},B.key))});return s.jsx(Mu,{composerPortalTarget:T?x:null,children:s.jsxs("div",{ref:S,className:"android-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":I,"data-tabbar-open":T?R.isOpen:!0,"data-conversation-tabbar-state":T?R.state:"default",style:L,children:[G?s.jsxs("header",{className:"android-workbench-topbar","data-header-kind":"tools",children:[s.jsxs("div",{className:"android-workbench-topbar-leading",children:[G.showBackButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":l("common.back"),onClick:E,children:s.jsx(yx,{})}):null,s.jsx("div",{className:"android-workbench-topbar-copy",children:s.jsx("h1",{children:G.title})})]}),s.jsx("div",{className:"android-workbench-topbar-actions",children:G.showMoreButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":G.moreButtonLabel,onClick:d,children:s.jsx(xx,{})}):null})]}):null,s.jsx("div",{className:"android-workbench-content",children:s.jsx(Au,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:F,navigationPanel:r,auxiliaryPanel:i,children:n})}),T?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:H})]}):H]})})}function yx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"m15 18-6-6 6-6"}),s.jsx("path",{d:"M21 12H9"})]})}function xx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function wx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function vx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Sx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function Cx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Nx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}const jx=120,Xi={viewportHeight:null,keyboardInset:0,keyboardOpen:!1};function Rc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Tx(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable||e.closest("[contenteditable='true']"))return!0;if(e instanceof HTMLTextAreaElement)return!e.readOnly&&!e.disabled;if(e instanceof HTMLInputElement){if(e.readOnly||e.disabled)return!1;const t=(e.type||"text").toLowerCase();return!["button","checkbox","color","file","hidden","image","radio","range","reset","submit"].includes(t)}return!1}function Ix(){var t;if(typeof window>"u")return 0;const e=[window.innerHeight,typeof document<"u"?(t=document.documentElement)==null?void 0:t.clientHeight:0].filter(Rc);return e.length>0?Math.max(...e):0}function Ld(){if(typeof window>"u")return Xi;const e=window.visualViewport,t=Ix(),n=(e==null?void 0:e.height)??t,r=Rc(n)?Math.round(n):null,i=Rc(e==null?void 0:e.offsetTop)?(e==null?void 0:e.offsetTop)??0:0,a=r===null?0:Math.max(0,Math.round(t-r-i));return{viewportHeight:r,keyboardInset:a,keyboardOpen:Tx(typeof document<"u"?document.activeElement:null)&&a>=jx}}function Dl(e,t){if(typeof document>"u")return;[document.documentElement,document.body].filter(r=>r instanceof HTMLElement).forEach(r=>{if(!e){delete r.dataset.mobileKeyboardOpen,delete r.dataset.mobileViewportBound,r.style.removeProperty("--mobile-shell-viewport-height"),r.style.removeProperty("--mobile-shell-keyboard-inset");return}r.dataset.mobileKeyboardOpen=String(t.keyboardOpen),r.dataset.mobileViewportBound="true",t.viewportHeight===null?r.style.removeProperty("--mobile-shell-viewport-height"):r.style.setProperty("--mobile-shell-viewport-height",`${t.viewportHeight}px`),r.style.setProperty("--mobile-shell-keyboard-inset",`${t.keyboardInset}px`)})}function Ex(e){const[t,n]=f.useState(()=>e?Ld():Xi),r=f.useRef(null);return f.useEffect(()=>{if(!e){n(Xi),Dl(!1,Xi);return}function i(){n(Ld())}function a(){r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,i()},0)}i();const o=window.visualViewport;return window.addEventListener("resize",i),window.addEventListener("orientationchange",i),o==null||o.addEventListener("resize",i),o==null||o.addEventListener("scroll",i),document.addEventListener("focusin",i),document.addEventListener("focusout",a),()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null),window.removeEventListener("resize",i),window.removeEventListener("orientationchange",i),o==null||o.removeEventListener("resize",i),o==null||o.removeEventListener("scroll",i),document.removeEventListener("focusin",i),document.removeEventListener("focusout",a),Dl(!1,Xi)}},[e]),f.useEffect(()=>{Dl(e,t)},[e,t]),t}function Mx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:a,onNavigateTerminals:o,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=$n(),g=ku(),m=el(),y=xa(),S=f.useRef(null),j=f.useRef(null),[x,A]=f.useState(null),T=t==="conversation-focus",F=nl({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),R=Pu({enabled:T,rootRef:S,resetKey:`${m.pathname}${m.search}`}),I=wa({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:F}),G=Eu({activeEntry:e,presentation:t,pathname:m.pathname,search:m.search,moreButtonLabel:l("shell.iosMoreAction")}),z=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(Ax,{}),onClick:a},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Lx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Dx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(_x,{}),onClick:o},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Bx,{}),onClick:h}],L=T?{"--mobile-conversation-tabbar-progress":R.progress.toFixed(4)}:void 0;Ru(S,j,T);function E(){const B=Iu(m.pathname,m.search);if(!B){o();return}y(B,{replace:!0})}const H=s.jsx("nav",{ref:j,className:"ios-workbench-tabbar","aria-label":l("shell.title"),children:z.map(B=>s.jsxs("button",{type:"button",className:"ios-workbench-tabbar-item","data-active":B.key===e,"aria-current":B.key===e?"page":void 0,onClick:()=>{B.key!==e&&g.trigger("selection"),B.onClick()},children:[s.jsx("span",{className:"ios-workbench-tabbar-icon","aria-hidden":"true",children:B.icon}),s.jsx("span",{className:"ios-workbench-tabbar-label",children:B.label})]},B.key))});return s.jsx(Mu,{composerPortalTarget:T?x:null,children:s.jsxs("div",{ref:S,className:"ios-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":I,"data-tabbar-open":T?R.isOpen:!0,"data-conversation-tabbar-state":T?R.state:"default",style:L,children:[G?s.jsxs("header",{className:"ios-workbench-nav","data-header-kind":"tools",children:[s.jsx("div",{className:"ios-workbench-nav-leading",children:G.showBackButton?s.jsxs("button",{type:"button",className:"ios-workbench-back-button","aria-label":l("common.back"),onClick:E,children:[s.jsx(Rx,{}),s.jsx("span",{children:l("common.back")})]}):null}),s.jsx("div",{className:"ios-workbench-nav-copy",children:s.jsx("h1",{children:G.title})}),s.jsx("div",{className:"ios-workbench-nav-actions",children:G.showMoreButton?s.jsx("button",{type:"button",className:"ios-workbench-icon-button","aria-label":G.moreButtonLabel,onClick:d,children:s.jsx(Px,{})}):null})]}):null,s.jsx("div",{className:"ios-workbench-content",children:s.jsx(Au,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:F,navigationPanel:r,auxiliaryPanel:i,children:n})}),T?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:H})]}):H]})})}function Rx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:s.jsx("path",{d:"m15 18-6-6 6-6"})})}function Px(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function Ax(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function Lx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function _x(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function Dx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Bx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function Ox(e){const t=$n();return t.platform==="ios"?s.jsx(Mx,{...e}):t.platform==="android"?s.jsx(kx,{...e}):s.jsx(Wx,{...e})}function Wx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:a,onNavigateTerminals:o,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=$n(),g=ku(),m=el(),y=xa(),S=f.useRef(null),j=f.useRef(null),[x,A]=f.useState(null),T=Ex(p.platform==="web"),F=p.platform==="web"&&T.keyboardOpen,R=t==="conversation-focus",I=nl({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),G=Pu({enabled:R,rootRef:S,suspended:F,resetKey:`${m.pathname}${m.search}`}),z=wa({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:I}),L=Eu({activeEntry:e,presentation:t,pathname:m.pathname,search:m.search,moreButtonLabel:l("shell.iosMoreAction")}),E=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(zx,{}),onClick:a},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Hx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(qx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(Ux,{}),onClick:o},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Gx,{}),onClick:h}],H=R?{"--mobile-conversation-tabbar-progress":G.progress.toFixed(4)}:void 0;Ru(S,j,R);function B(){const K=Iu(m.pathname,m.search);if(!K){o();return}y(K,{replace:!0})}const oe=s.jsx("nav",{ref:j,className:"mobile-workbench-tabbar","aria-label":l("shell.title"),hidden:F,children:E.map(K=>s.jsxs("button",{type:"button",className:"mobile-workbench-tabbar-item","data-active":K.key===e,"aria-current":K.key===e?"page":void 0,onClick:()=>{K.key!==e&&g.trigger("selection"),K.onClick()},children:[s.jsx("span",{className:"mobile-workbench-tabbar-icon","aria-hidden":"true",children:K.icon}),s.jsx("span",{className:"mobile-workbench-tabbar-label",children:K.label})]},K.key))});return s.jsx(Mu,{composerPortalTarget:R?x:null,children:s.jsxs("div",{ref:S,className:"mobile-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-mobile-runtime":p.platform,"data-mobile-keyboard-open":F,"data-pane-layout":z,"data-tabbar-open":F?!1:R?G.isOpen:!0,"data-conversation-tabbar-state":R?G.state:"default",style:H,children:[L?s.jsxs("header",{className:"mobile-workbench-header","data-header-kind":"tools",children:[s.jsxs("div",{className:"mobile-workbench-header-leading",children:[L.showBackButton?s.jsx("button",{type:"button",className:"mobile-workbench-header-button","aria-label":l("common.back"),onClick:B,children:s.jsx(Fx,{})}):null,s.jsx("div",{className:"mobile-workbench-header-copy",children:s.jsx("h1",{children:L.title})})]}),s.jsx("div",{className:"mobile-workbench-header-actions",children:L.showMoreButton?s.jsx("button",{type:"button",className:"mobile-workbench-header-button mobile-tools-more-button","aria-label":L.moreButtonLabel,onClick:d,children:s.jsx($x,{})}):null})]}):null,s.jsx("div",{className:"mobile-workbench-content",children:s.jsx(Au,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:I,navigationPanel:r,auxiliaryPanel:i,children:n})}),R?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:oe})]}):oe]})})}function Fx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"m15 18-6-6 6-6"}),s.jsx("path",{d:"M21 12H9"})]})}function $x(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function zx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function Hx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Ux(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function qx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Gx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}class Vx{constructor(t){at(this,"maxAttempts");at(this,"baseDelayMs");at(this,"reconnectAttempts",0);at(this,"reconnectTimer",null);at(this,"disposed",!1);this.options=t,this.maxAttempts=t.maxAttempts??4,this.baseDelayMs=t.baseDelayMs??300}start(){this.options.onReconnect(!1)}markConnected(){this.reconnectAttempts=0,this.options.onStateChange("connected")}markTransientFailure(){this.disposed||this.reconnectAttempts>0||this.options.onStateChange("reconnecting")}markDisconnected(){if(this.disposed)return;if(!ar.getState().autoReconnect){this.options.onStateChange("reconnect_failed");return}if(this.reconnectAttempts+=1,this.reconnectAttempts>this.maxAttempts){this.options.onStateChange("reconnect_failed");return}this.options.onStateChange("reconnecting");const t=this.baseDelayMs*this.reconnectAttempts;this.reconnectTimer=window.setTimeout(()=>{this.options.onReconnect(!0)},t)}reconnectNow(){this.reconnectAttempts=0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onReconnect(!0)}close(){this.disposed=!0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onStateChange("closed")}}class Kx{constructor(t){at(this,"socket",null);at(this,"disposed",!1);at(this,"authRecoveryInFlight",!1);at(this,"pendingRefresh",!1);at(this,"workbenchKnownRevision");at(this,"lastWorkbenchSnapshot",null);at(this,"fileTreeSubscription",null);at(this,"gitSubscription",null);at(this,"terminalManagerSubscription",null);at(this,"workspaceManagementSubscription",null);at(this,"pendingFileTreeRefresh",null);at(this,"pendingGitRefresh",null);at(this,"pendingTerminalManagerRefresh",null);at(this,"pendingWorkspaceManagementRefresh",null);at(this,"fileTreeRevisionByPath",new Map);at(this,"gitRevisionByWorkspaceId",new Map);at(this,"terminalManagerRevisionByWorkspaceId",new Map);at(this,"workspaceManagementRevisionByWorkspaceId",new Map);at(this,"fileTreeListeners",new Set);at(this,"gitListeners",new Set);at(this,"terminalManagerListeners",new Set);at(this,"workspaceManagementListeners",new Set);at(this,"workbenchSubscribeStartedAtMs",null);at(this,"workbenchRefreshStartedAtMs",null);at(this,"connectionManager");this.options=t,this.workbenchKnownRevision=null,this.connectionManager=new Vx({onReconnect:n=>{this.connect(n)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}requestRefresh(){const t=this.socket;if(!_d(t)){this.pendingRefresh=!0;return}this.workbenchRefreshStartedAtMs=performance.now(),t.send(JSON.stringify({type:"workbench.refresh",knownRevision:this.workbenchKnownRevision??void 0})),un("workbench.refresh.sent",{knownRevision:this.workbenchKnownRevision}),this.pendingRefresh=!1}setWorkbenchKnownRevision(t){this.workbenchKnownRevision=Vn(t)}primeWorkbenchSnapshot(t){if(!t||!Array.isArray(t.items)){this.lastWorkbenchSnapshot=null,this.workbenchKnownRevision=null;return}this.lastWorkbenchSnapshot=t,this.workbenchKnownRevision=Vn(t.revision)??null}subscribeFileTree(t,n,r){this.fileTreeSubscription={workspaceId:t,paths:Dd(n),knownRevisionByPath:Bl(r==null?void 0:r.knownRevisionByPath)},this.sendWhenReady({type:"fileTree.subscribe",workspaceId:t,paths:this.fileTreeSubscription.paths,knownRevisions:Ol(t,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})}requestFileTreeRefresh(t,n,r){const i=Dd(n),a={type:"fileTree.refresh",workspaceId:t,paths:i,knownRevisions:Ol(t,i,Bl(r==null?void 0:r.knownRevisionByPath),this.fileTreeRevisionByPath)};this.sendWhenReady(a)?this.pendingFileTreeRefresh=null:this.pendingFileTreeRefresh={workspaceId:t,paths:i,knownRevisionByPath:Bl(r==null?void 0:r.knownRevisionByPath)}}subscribeGit(t,n){this.gitSubscription={workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"git.subscribe",workspaceId:t,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(t)})}requestGitRefresh(t,n){const r={type:"git.refresh",workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)??this.gitRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingGitRefresh=null:this.pendingGitRefresh={workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)}}subscribeTerminalManager(t,n){this.terminalManagerSubscription={workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"terminalManager.subscribe",workspaceId:t,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(t)})}requestTerminalManagerRefresh(t,n){const r={type:"terminalManager.refresh",workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)??this.terminalManagerRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingTerminalManagerRefresh=null:this.pendingTerminalManagerRefresh={workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)}}subscribeWorkspaceManagement(t,n){this.workspaceManagementSubscription={workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"workspaceManagement.subscribe",workspaceId:t,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(t)})}requestWorkspaceManagementRefresh(t,n){const r={type:"workspaceManagement.refresh",workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)??this.workspaceManagementRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingWorkspaceManagementRefresh=null:this.pendingWorkspaceManagementRefresh={workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)}}addFileTreeSnapshotListener(t){return this.fileTreeListeners.add(t),()=>{this.fileTreeListeners.delete(t)}}addGitSnapshotListener(t){return this.gitListeners.add(t),()=>{this.gitListeners.delete(t)}}addTerminalManagerSnapshotListener(t){return this.terminalManagerListeners.add(t),()=>{this.terminalManagerListeners.delete(t)}}addWorkspaceManagementSnapshotListener(t){return this.workspaceManagementListeners.add(t),()=>{this.workspaceManagementListeners.delete(t)}}close(){var t;this.disposed=!0,this.connectionManager.close(),(t=this.socket)==null||t.close(),this.socket=null}connect(t){var u;if(this.disposed)return;t&&this.socket&&(this.socket.close(),this.socket=null);const n=(u=ca.getState().session)==null?void 0:u.accessToken;if(!n){this.options.onUnauthorized();return}const r=pu(),i=Of(r),a=i.baseUrl,o=`${Vk("/ws",a)}?access_token=${encodeURIComponent(n)}`,c=i.transport.createWebSocket({path:"/ws",baseUrl:a,url:o});this.socket=c,c.addEventListener("open",()=>{this.workbenchSubscribeStartedAtMs=performance.now(),c.send(JSON.stringify({type:"workbench.subscribe",knownRevision:this.workbenchKnownRevision??void 0})),un("workbench.subscribe.sent",{knownRevision:this.workbenchKnownRevision,baseUrl:a}),this.pendingRefresh&&this.requestRefresh(),this.fileTreeSubscription&&c.send(JSON.stringify({type:"fileTree.subscribe",workspaceId:this.fileTreeSubscription.workspaceId,paths:this.fileTreeSubscription.paths,knownRevisions:Ol(this.fileTreeSubscription.workspaceId,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})),this.pendingFileTreeRefresh&&this.requestFileTreeRefresh(this.pendingFileTreeRefresh.workspaceId,this.pendingFileTreeRefresh.paths,{knownRevisionByPath:this.pendingFileTreeRefresh.knownRevisionByPath}),this.gitSubscription&&c.send(JSON.stringify({type:"git.subscribe",workspaceId:this.gitSubscription.workspaceId,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(this.gitSubscription.workspaceId)})),this.pendingGitRefresh&&this.requestGitRefresh(this.pendingGitRefresh.workspaceId,{knownRevision:this.pendingGitRefresh.knownRevision}),this.terminalManagerSubscription&&c.send(JSON.stringify({type:"terminalManager.subscribe",workspaceId:this.terminalManagerSubscription.workspaceId,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(this.terminalManagerSubscription.workspaceId)})),this.pendingTerminalManagerRefresh&&this.requestTerminalManagerRefresh(this.pendingTerminalManagerRefresh.workspaceId,{knownRevision:this.pendingTerminalManagerRefresh.knownRevision}),this.workspaceManagementSubscription&&c.send(JSON.stringify({type:"workspaceManagement.subscribe",workspaceId:this.workspaceManagementSubscription.workspaceId,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(this.workspaceManagementSubscription.workspaceId)})),this.pendingWorkspaceManagementRefresh&&this.requestWorkspaceManagementRefresh(this.pendingWorkspaceManagementRefresh.workspaceId,{knownRevision:this.pendingWorkspaceManagementRefresh.knownRevision})}),c.addEventListener("message",d=>{var p,g,m,y,S,j,x,A,T,F;if(!(d instanceof MessageEvent)||typeof d.data!="string")return;const h=JSON.parse(d.data);if(h.type==="system.connected"){this.connectionManager.markConnected();return}if(h.type==="session.error"){h.error_code==="UNAUTHORIZED"&&this.handleUnauthorized();return}if(h.type==="workbench.snapshot"&&(un("workbench.snapshot.received",{unchanged:h.unchanged,revision:h.revision,workspaceCount:((p=h.snapshot)==null?void 0:p.items.length)??0,sessionCount:h.snapshot?Jx(h.snapshot):0,subscribeDurationMs:qa(this.workbenchSubscribeStartedAtMs),refreshDurationMs:qa(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null),h.type==="workbench.delta"){un("workbench.delta.received",{baseRevision:h.baseRevision,revision:h.revision,changedWorkspaceCount:h.changedItems.length,removedWorkspaceCount:h.removedWorkspaceIds.length,subscribeDurationMs:qa(this.workbenchSubscribeStartedAtMs),refreshDurationMs:qa(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null;const R=Xx(this.lastWorkbenchSnapshot,h);if(!R){un("workbench.delta.mismatch",{currentRevision:((g=this.lastWorkbenchSnapshot)==null?void 0:g.revision)??null,baseRevision:h.baseRevision,revision:h.revision}),this.workbenchKnownRevision=null,this.lastWorkbenchSnapshot=null,this.connectionManager.reconnectNow();return}this.lastWorkbenchSnapshot=R,this.workbenchKnownRevision=h.revision,this.options.onSnapshot(R);return}if(h.type==="fileTree.snapshot"){const R=h.snapshot;if(R)R.revision=h.revision,this.fileTreeRevisionByPath.set(Pc(R.workspaceId,R.path),h.revision);else if(h.unchanged&&this.fileTreeSubscription)for(const I of this.fileTreeSubscription.paths)this.fileTreeRevisionByPath.set(Pc(this.fileTreeSubscription.workspaceId,I),h.revision);if(!R)return;(y=(m=this.options).onFileTreeSnapshot)==null||y.call(m,R),this.fileTreeListeners.forEach(I=>I(R));return}if(h.type==="git.snapshot"){const R=h.snapshot;if(R?(R.revision=h.revision,this.gitRevisionByWorkspaceId.set(R.workspaceId,h.revision)):h.unchanged&&this.gitSubscription&&this.gitRevisionByWorkspaceId.set(this.gitSubscription.workspaceId,h.revision),!R)return;(j=(S=this.options).onGitSnapshot)==null||j.call(S,R),this.gitListeners.forEach(I=>I(R));return}if(h.type==="terminalManager.snapshot"){const R=h.snapshot;if(R?(R.revision=h.revision,this.terminalManagerRevisionByWorkspaceId.set(R.workspaceId,h.revision)):h.unchanged&&this.terminalManagerSubscription&&this.terminalManagerRevisionByWorkspaceId.set(this.terminalManagerSubscription.workspaceId,h.revision),!R)return;(A=(x=this.options).onTerminalManagerSnapshot)==null||A.call(x,R),this.terminalManagerListeners.forEach(I=>I(R));return}if(h.type==="workspaceManagement.snapshot"){const R=h.snapshot;if(R?(R.revision=h.revision,this.workspaceManagementRevisionByWorkspaceId.set(R.workspaceId,h.revision)):h.unchanged&&this.workspaceManagementSubscription&&this.workspaceManagementRevisionByWorkspaceId.set(this.workspaceManagementSubscription.workspaceId,h.revision),!R)return;(F=(T=this.options).onWorkspaceManagementSnapshot)==null||F.call(T,R),this.workspaceManagementListeners.forEach(I=>I(R));return}h.type==="workbench.snapshot"&&h.snapshot&&Yx(h.snapshot)?(h.snapshot.revision=h.revision,this.lastWorkbenchSnapshot=h.snapshot,this.workbenchKnownRevision=h.revision,this.options.onSnapshot(h.snapshot)):h.type==="workbench.snapshot"&&h.unchanged&&(this.workbenchKnownRevision=h.revision,this.lastWorkbenchSnapshot&&(this.lastWorkbenchSnapshot={...this.lastWorkbenchSnapshot,revision:h.revision}))}),c.addEventListener("close",()=>{this.disposed||this.socket!==c||this.connectionManager.markDisconnected()}),c.addEventListener("error",()=>{this.disposed||this.socket!==c||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const t=this.socket;this.socket=null,t==null||t.close(),ca.refresh().then(n=>{if(this.authRecoveryInFlight=!1,!this.disposed){if(n.status==="refreshed"){this.connectionManager.reconnectNow();return}if(n.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendWhenReady(t){const n=this.socket;return _d(n)?(n.send(JSON.stringify(t)),!0):!1}}function _d(e){return e!==null&&e.readyState===1}function Yx(e){return typeof e!="object"||e===null?!1:Array.isArray(e.items)}function Dd(e){const t=new Set;for(const n of e??[""])t.add(n.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""));return[...t]}function Vn(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function Xx(e,t){if(!e||e.revision!==t.baseRevision)return null;const n=new Map(e.items.map(i=>[i.workspace.id,i]));for(const i of t.removedWorkspaceIds)n.delete(i);for(const i of t.changedItems)n.set(i.workspace.id,i);const r=[];for(const i of t.orderedWorkspaceIds){const a=n.get(i);if(!a)return null;r.push(a)}return{revision:t.revision,items:r}}function Bl(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),Vn(n)]).filter(t=>t[1]!==null)):{}}function Ol(e,t,n,r){const i=t.map(a=>{const o=a.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return[o,n[o]??r.get(Pc(e,o))??null]}).filter(a=>!!a[1]);if(i.length!==0)return Object.fromEntries(i)}function Pc(e,t){return`${e}::${t}`}function Jx(e){return e.items.reduce((t,n)=>t+n.sessions.length+Sm(n.childWorktrees??[]),0)}function Sm(e){return e.reduce((t,n)=>{if(typeof n!="object"||n===null)return t;const r=n,i=Array.isArray(r.sessions)?r.sessions.length:0,a=Array.isArray(r.children)?Sm(r.children):0;return t+i+a},0)}function qa(e){return e===null||typeof performance>"u"?null:Math.round(performance.now()-e)}const Bd=6,Qx=["button","a","input","textarea","select","summary","[role='button']","[role='link']","[role='tab']","[role='menuitem']","[contenteditable='true']","[data-window-drag='ignore']"].join(", ");function Zx(e){return e instanceof HTMLElement?!e.closest(Qx):!0}function Ac(e,t,n){return e.isDesktop&&e.ui.osFamily==="macos"&&t===0&&Zx(n)}function Cm(e){return e.isDesktop&&e.ui.osFamily==="macos"&&e.ui.prefersOverlayTitlebar}function Nm(e){return Cm(e)?"":void 0}function ew(e){if(!Ac(e.platform,e.button,e.target)||typeof window>"u")return;const t=e.clientX,n=e.clientY;let r=!0;const i=()=>{r&&(r=!1,window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",o),window.removeEventListener("blur",c))},a=u=>{Math.abs(u.clientX-t)<Bd&&Math.abs(u.clientY-n)<Bd||(i(),tw())},o=()=>{i()},c=()=>{i()};window.addEventListener("mousemove",a),window.addEventListener("mouseup",o),window.addEventListener("blur",c)}async function tw(){typeof window>"u"||typeof window.__TAURI_INTERNALS__>"u"||await Yf().startDragging()}const _o=.78,nw=1;function rw(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function jm(e,t,n,r){const i=Math.hypot(n-e,r-t),a=Math.min(1,i/120);return _o+(nw-_o)*a}function is(e){return Math.round(Number.isFinite(e)?e:0)}function sw(e){if(!rw())return null;const t=is(e.x),n=is(e.y);let r=!1,i=Promise.resolve();const a=(c,u)=>(i=i.then(async()=>{await window.__TAURI_INTERNALS__.invoke(c,u)}).catch(()=>{}),i),o=async()=>{r||(r=!0,await a("close_detach_preview"))};return a("show_detach_preview",{title:e.title,x:t,y:n,scale:_o}),{updatePosition(c,u){if(r)return;const d=is(c),h=is(u);a("update_detach_preview_position",{x:d,y:h,scale:jm(t,n,d,h)})},complete(){return o()},cancel(){return o()}}}function iw(e){if(typeof document>"u")return null;const t=is(e.x),n=is(e.y),r=document.createElement("div");r.className="desktop-window-detach-animation",r.setAttribute("aria-hidden","true"),r.dataset.state="preview",r.style.left=`${t}px`,r.style.top=`${n}px`,r.style.setProperty("--detach-preview-scale",_o.toFixed(3));const i=document.createElement("div");i.className="desktop-window-detach-animation-bar";const a=document.createElement("strong");a.className="desktop-window-detach-animation-title",a.textContent=e.title;const o=document.createElement("div");o.className="desktop-window-detach-animation-body",i.append(a),r.append(i,o),document.body.append(r);let c=!1;const u=()=>{c||(c=!0,r.remove())};return{updatePosition(d,h){if(c)return;const p=is(d),g=is(h),m=jm(t,n,p,g);r.style.left=`${p}px`,r.style.top=`${g}px`,r.style.setProperty("--detach-preview-scale",m.toFixed(3))},async complete(){u()},async cancel(){u()}}}function Od(e){return sw(e)??iw(e)}const aw={files:{kind:"files",label:"文件",defaultFocusOwner:"file-context-panel"},git:{kind:"git",label:"Git",defaultFocusOwner:"git-sidebar"},processes:{kind:"processes",label:"调试",defaultFocusOwner:"terminal-manager-panel"},terminals:{kind:"terminals",label:"终端",defaultFocusOwner:"terminal-page"}};function ow(e){return{...e,bounds:{...e.bounds}}}function lw(e,t,n){t&&(e.windows.registerDescriptor(t),n?e.windows.markWindowOpen(t.windowId):e.windows.markWindowClosed(t.windowId))}function cw(e){return aw[e]}function Tm(e,t){return`${e}-${t}`}async function rl(e,t,n){const r=n.workspaceId.trim(),i=cw(t);if(!e.isDesktop||!e.bridge.supported)return{ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前运行环境不支持桌面外部窗口。"};if(!r)return{ok:!1,errorCode:"WINDOW_WORKSPACE_REQUIRED",detail:`${i.label}外部窗口必须绑定工作区。`};const a=Tm(t,r),o=e.windows.getDescriptor(a),c=o?ow(o):null,u=e.windows.isWindowOpen(a),d=Kk({windowId:a,kind:t,workspaceId:r,workspaceName:n.workspaceName??(c==null?void 0:c.workspaceName)??null,sessionId:n.sessionId??(c==null?void 0:c.sessionId)??null,mode:"external",bounds:c==null?void 0:c.bounds,focusOwner:n.focusOwner??i.defaultFocusOwner});e.windows.registerDescriptor(d);const h=await e.bridge.createWindow(d);return h.ok?(e.windows.markWindowOpen(a),{ok:!0,value:d}):(c?lw(e,c,u):e.windows.removeWindow(a),{ok:!1,errorCode:h.errorCode,detail:h.detail})}function NL(e){return Tm("terminals",e)}function uw(e,t){return rl(e,"files",t)}function dw(e,t){return rl(e,"git",t)}function hw(e,t){return rl(e,"processes",t)}function jL(e,t){return rl(e,"terminals",t)}async function Wd(){return await pe.request("/api/skills/overview")}async function pw(e){var n;const t=new URLSearchParams;return t.set("workspaceId",e.workspaceId),(n=e.sessionId)!=null&&n.trim()&&t.set("sessionId",e.sessionId.trim()),await pe.request(`/api/skills/workspace-session-mcp-status?${t.toString()}`)}async function fw(e){await pe.request("/api/skills",{method:"POST",body:JSON.stringify(e)})}async function mw(e){await pe.request("/api/skills/import",{method:"POST",body:JSON.stringify(e)})}async function gw(e){await pe.request("/api/skills/sync",{method:"POST",body:JSON.stringify(e)})}function Fd(e){if(e.executionBackend==="opencli_bridge"||e.executionBackend==="playwright")return e.executionBackend;try{return JSON.parse(e.inputJson).executionBackend==="opencli_bridge"?"opencli_bridge":"playwright"}catch{return"playwright"}}async function $d(e="active"){const t=new URLSearchParams({status:e});return(await pe.request(`/api/office/document-templates?${t.toString()}`)).items}async function zd(e={}){var i;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim());const n=t.size>0?`?${t.toString()}`:"";return(await pe.request(`/api/office/browser/profiles${n}`)).items}async function bw(e){return await pe.request("/api/office/browser/profiles",{method:"POST",body:JSON.stringify(e)})}async function kw(e,t){return await pe.request(`/api/office/browser/profiles/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}async function yw(e){return await pe.request(`/api/office/browser/profiles/${encodeURIComponent(e)}`,{method:"DELETE"})}async function xw(e){return await pe.request("/api/office/document-templates/import-file",{method:"POST",body:JSON.stringify(e)})}async function Ga(e){var i;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),e.taskType&&t.set("taskType",e.taskType),e.status&&t.set("status",e.status),e.riskLevel&&t.set("riskLevel",e.riskLevel),typeof e.limit=="number"&&Number.isFinite(e.limit)&&t.set("limit",String(Math.trunc(e.limit)));const n=t.size>0?`?${t.toString()}`:"";return(await pe.request(`/api/office/tasks${n}`)).items}async function Wl(e){return await pe.request(`/api/office/tasks/${encodeURIComponent(e)}`)}async function ww(e){return await pe.request(`/api/office/browser/tasks/${encodeURIComponent(e)}/execute`,{method:"POST"})}async function Lc(e){return(await pe.request(`/api/office/browser/tasks/${encodeURIComponent(e)}/execution`)).task}async function Hd(){return await pe.request("/api/office/browser/bridge-status")}async function vw(e){return await pe.request(`/api/office/browser/tasks/${encodeURIComponent(e)}/execution/cancel`,{method:"POST"})}async function Sw(e,t){await pe.request(`/api/office/approvals/${encodeURIComponent(e)}/reply`,{method:"POST",body:JSON.stringify(t)})}async function Ud(e){var i;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),e.kind&&t.set("kind",e.kind),e.status&&t.set("status",e.status);const n=t.size>0?`?${t.toString()}`:"";return(await pe.request(`/api/office/ops/targets${n}`)).items}async function Cw(e){return await pe.request("/api/office/ops/targets",{method:"POST",body:JSON.stringify(e)})}async function Nw(e,t){return await pe.request(`/api/office/ops/targets/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}async function jw(){return await pe.request("/api/opencli/catalog")}async function qd(){return await pe.request("/api/opencli/check",{method:"POST"})}async function Tw(e){return await pe.request("/api/opencli/config",{method:"POST",body:JSON.stringify(e)})}const Fl="all",$l="status";function Iw({toolbarMode:e="internal",onToolbarStateChange:t}={}){var He,Ue,je,Te;const n=fu(O=>{var q;return((q=O.session)==null?void 0:q.accessToken)??null}),[r,i]=f.useState(null),[a,o]=f.useState(!1),[c,u]=f.useState(!1),[d,h]=f.useState(!1),[p,g]=f.useState(!1),[m,y]=f.useState([]),[S,j]=f.useState(null),[x,A]=f.useState(null),[T,F]=f.useState(Fl),[R,I]=f.useState(null),[G,z]=f.useState(!1),[L,E]=f.useState(""),[H,B]=f.useState($l);f.useEffect(()=>{let O=!0;if(!n){i(null),g(!1),y([]),A(null),j(null),o(!1),F(Fl),I(null),z(!1),E(""),B($l);return}return(async()=>{o(!0),A(null),j(null);try{const J=await qd();if(!O)return;N(J)}catch(J){if(!O)return;const Ce=Ka(J);try{const Ee=await jw();if(!O)return;N(Ee),A(Ce)}catch(Ee){if(!O)return;A(Ka(Ee))}}finally{O&&o(!1)}})(),()=>{O=!1}},[n]);const oe=f.useMemo(()=>new Set(m),[m]),K=f.useMemo(()=>Rw((r==null?void 0:r.entries)??[]),[r==null?void 0:r.entries]),X=f.useMemo(()=>_w(),[]);f.useEffect(()=>{K.some(O=>O.id===T)||F(Fl)},[T,K]);const Y=f.useMemo(()=>((r==null?void 0:r.siteGroups)??[]).filter(O=>O.commands.some(q=>Gd(q,T,oe))),[T,r==null?void 0:r.siteGroups,oe]),D=f.useMemo(()=>R?Y.find(O=>O.site===R)??null:null,[R,Y]);f.useEffect(()=>{R&&!D&&I(null)},[R,D]),f.useEffect(()=>{E(""),B($l)},[R]);const V=f.useMemo(()=>{if(!D)return[];const O=L.trim().toLowerCase();return D.commands.filter(q=>Gd(q,T,oe)&&Aw(q,O)).sort((q,J)=>Lw(q,J,{sortId:H,selectedCommandIdSet:oe}))},[T,D,L,H,oe]),le=!!(r&&(r.provider.enabled!==p||r.entries.some(O=>O.enabled!==oe.has(O.commandId)))),C=f.useMemo(()=>({draftEnabled:p,enableDisabled:a||c||d,refreshDisabled:!n||a||c||d,detailDisabled:!r||a,saveDisabled:!n||a||c||d||!r||!le,refreshing:c,saving:d,onEnabledChange:be,onRefresh:()=>{_e()},onShowDetails:()=>z(!0),onSave:()=>{Z()}}),[n,r,m,p,le,a,c,d]);f.useEffect(()=>{t==null||t(C)},[t,C]),f.useEffect(()=>()=>{t==null||t(null)},[t]);async function _e(){if(n){u(!0),A(null),j(null);try{const O=await qd();N(O),j(Hw(O.refreshState,O.runtimeAvailability))}catch(O){A(Ka(O))}finally{u(!1)}}}async function Z(){if(n){h(!0),A(null),j(null);try{const O=await Tw({enabled:p,enabledCommandIds:m});N(O),j(Uw(O))}catch(O){A(Ka(O))}finally{h(!1)}}}function N(O){i(O),g(O.provider.enabled),y(O.entries.filter(q=>q.enabled).map(q=>q.commandId).sort((q,J)=>q.localeCompare(J))),A(null)}function be(O){g(O)}function ne(O,q){const J=O.commands.map(Ce=>Ce.commandId);y(Ce=>{const Ee=new Set(Ce);for(const ve of J)q?Ee.add(ve):Ee.delete(ve);return[...Ee].sort((ve,Tt)=>ve.localeCompare(Tt))})}function fe(O,q){y(J=>{const Ce=new Set(J);return q?Ce.add(O):Ce.delete(O),[...Ce].sort((Ee,ve)=>Ee.localeCompare(ve))})}const ue=(r==null?void 0:r.summary)??{catalogCount:0,browserDependentCount:0,installState:"not_installed"};return s.jsxs("section",{className:"settings-opencli-panel settings-skill-section",children:[e==="internal"?s.jsx(Ew,{state:C,className:"settings-opencli-inline-toolbar"}):null,s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(Va,{label:l("settings.opencliSummaryInstallState"),value:Yd(ue.installState)}),s.jsx(Va,{label:l("settings.opencliSummaryCatalogCount"),value:String(ue.catalogCount)}),s.jsx(Va,{label:l("settings.opencliSummaryEnabledCount"),value:String(m.length)}),s.jsx(Va,{label:l("settings.opencliSummaryBrowserCount"),value:String(ue.browserDependentCount)})]}),S?s.jsx("p",{className:"settings-release-status",children:S}):null,x?s.jsx("p",{className:"settings-release-status",children:x}):null,a?s.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliLoading")}):r!=null&&r.siteGroups.length?s.jsxs("section",{className:"settings-opencli-catalog-section settings-skill-section",children:[s.jsx("div",{className:"settings-model-tabs settings-opencli-filter-tabs",role:"tablist","aria-label":l("settings.opencliFilterTabsLabel"),children:K.map(O=>{const q=T===O.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":q,"data-active":q?"true":"false",onClick:()=>F(O.id),children:O.label},O.id)})}),Y.length>0?s.jsx("div",{className:"settings-opencli-site-grid",children:Y.map(O=>{const q=Pw(O,oe),J=Dw(O.commands),Ce=Kd(O,{maxDescriptions:2}),Ee=Kd(O),ve=Em(O.site),Tt=R===O.site;return s.jsxs("div",{className:"settings-opencli-site-card","data-selected":Tt?"true":"false",children:[s.jsxs("div",{className:"settings-opencli-site-card-head",children:[s.jsx("div",{className:"settings-opencli-site-card-visual",style:ve.style,children:s.jsx("span",{children:ve.label})}),s.jsxs("div",{className:"settings-opencli-site-card-body",children:[s.jsxs("div",{className:"settings-opencli-site-card-topline",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:O.site}),s.jsxs("div",{className:"settings-opencli-site-card-actions",children:[s.jsx("button",{className:"ghost-button settings-opencli-site-detail-button",type:"button",onClick:()=>I(O.site),children:l("settings.opencliSiteViewAction")}),s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-site-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliSiteToggleLabel",{site:O.site}),type:"checkbox",checked:q.allSelected,disabled:c||d,ref:nt=>{nt&&(nt.indeterminate=q.partialSelected)},onChange:nt=>ne(O,nt.target.checked)}),s.jsx("span",{children:l("settings.opencliSiteEnableAction")})]})]})]}),s.jsx("p",{className:"settings-opencli-site-card-description",title:Ee,children:Ce})]})]}),s.jsx("div",{className:"settings-opencli-site-card-summary",children:s.jsx("div",{className:"settings-opencli-site-card-tag-rows",children:s.jsx("div",{className:"settings-skill-tags settings-opencli-site-card-tag-row settings-opencli-site-card-type-row",children:(J.length>0?J:["unknown"]).slice(0,2).map(nt=>s.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":Pm(nt),children:Mm(nt)},`${O.site}:${nt}`))})})})]},O.site)})}):s.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliFilteredEmpty")})]}):s.jsx("div",{className:"settings-skill-empty",children:qw(r)}),s.jsx(St,{open:G,title:l("settings.opencliDetailTitle"),className:"settings-opencli-detail-modal",onClose:()=>z(!1),children:r?s.jsxs(s.Fragment,{children:[s.jsx(Mn,{heading:l("settings.opencliDetailStatusHeading"),actions:s.jsxs("div",{className:"settings-opencli-detail-tags",children:[s.jsx($a,{children:Yd(r.provider.installState)}),s.jsx($a,{children:Ww(r.provider.healthState)}),s.jsx($a,{children:$w(((He=r.activeRuntimeProfile)==null?void 0:He.status)??null)})]}),children:s.jsxs(mi,{compact:!0,className:"settings-opencli-detail-list",children:[s.jsx(Jt,{label:l("settings.opencliEnabledStateLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:p?l("settings.opencliEnabledStateOn"):l("settings.opencliEnabledStateOff")})}),s.jsx(Jt,{label:l("settings.opencliSummaryCatalogCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(ue.catalogCount)})}),s.jsx(Jt,{label:l("settings.opencliSummaryEnabledCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(m.length)})}),s.jsx(Jt,{label:l("settings.opencliSummaryBrowserCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(ue.browserDependentCount)})}),s.jsx(Jt,{label:l("settings.opencliVersionLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:r.provider.version??"-"})}),s.jsx(Jt,{label:l("settings.opencliCatalogSourceLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Fw(r.effectiveCatalogSource??null)})}),s.jsx(Jt,{label:l("settings.opencliLastCheckedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Xd(r.provider.lastCheckedAt)})}),s.jsx(Jt,{label:l("settings.opencliCatalogRefreshedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Xd(r.provider.catalogRefreshedAt)})}),s.jsx(Jt,{label:l("settings.opencliInstallPathLabel"),description:r.provider.installPath??"-"}),s.jsx(Jt,{label:l("settings.opencliDetailRuntimeIdLabel"),description:r.provider.activeRuntimeId??"-"}),s.jsx(Jt,{label:l("settings.opencliDetailRuntimeRootLabel"),description:((Ue=r.activeRuntimeProfile)==null?void 0:Ue.runtimeRootPath)??"-"})]})}),r.provider.lastErrorDetail||(je=r.activeRuntimeProfile)!=null&&je.lastErrorDetail?s.jsx(Mn,{tone:"danger",heading:l("settings.opencliDetailErrorHeading"),children:s.jsxs("div",{className:"settings-opencli-detail-errors",children:[r.provider.lastErrorDetail?s.jsx("p",{className:"settings-skill-entry-meta",children:r.provider.lastErrorDetail}):null,(Te=r.activeRuntimeProfile)!=null&&Te.lastErrorDetail?s.jsx("p",{className:"settings-skill-entry-meta",children:r.activeRuntimeProfile.lastErrorDetail}):null]})}):null]}):null}),s.jsx(St,{open:D!==null,title:D?l("settings.opencliSiteDetailTitle",{site:D.site}):l("settings.opencliCommandModalFallbackTitle"),description:D?l("settings.opencliSiteDetailDescription",{count:V.length,total:D.totalCount}):void 0,className:"settings-opencli-command-modal",onClose:()=>I(null),children:D?s.jsxs("section",{className:"settings-skill-section",children:[s.jsx(Mn,{heading:l("settings.opencliSiteDescriptionHeading"),children:s.jsx("div",{className:"settings-opencli-site-detail-copy",children:Im(D.commands).map(O=>s.jsx("p",{className:"settings-opencli-site-detail-description",children:O},O))})}),s.jsx(Mn,{heading:l("settings.opencliCommandSearchLabel"),actions:s.jsx($a,{children:l("settings.opencliCommandResultCount",{count:V.length})}),children:s.jsxs("div",{className:"settings-opencli-command-tools",children:[s.jsxs("label",{className:"settings-opencli-command-search",htmlFor:"opencli-command-search",children:[s.jsx("span",{className:"settings-opencli-command-search-label",children:l("settings.opencliCommandSearchLabel")}),s.jsx("input",{id:"opencli-command-search",className:"settings-text-input",type:"search",value:L,placeholder:l("settings.opencliCommandSearchPlaceholder"),onChange:O=>E(O.target.value)})]}),s.jsxs("div",{className:"settings-opencli-command-sort",children:[s.jsx("span",{className:"settings-opencli-command-search-label",children:l("settings.opencliCommandSortLabel")}),s.jsx("div",{className:"settings-opencli-command-sort-tabs",role:"tablist","aria-label":l("settings.opencliCommandSortLabel"),children:X.map(O=>{const q=H===O.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab settings-opencli-command-sort-button","aria-selected":q,"data-active":q?"true":"false",onClick:()=>B(O.id),children:O.label},O.id)})})]})]})}),V.length>0?s.jsx("div",{className:"settings-opencli-command-grid",children:V.map(O=>s.jsx(Mw,{command:O,checked:oe.has(O.commandId),disabled:c||d,onToggle:fe},O.commandId))}):s.jsx(Ro,{compact:!0,title:l("settings.opencliCommandModalEmpty")})]}):null})]})}function Ew({state:e,className:t}){return s.jsxs("div",{className:`settings-opencli-toolbar${t?` ${t}`:""}`,children:[s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-toolbar-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliProviderToggleLabel"),type:"checkbox",checked:e.draftEnabled,disabled:e.enableDisabled,onChange:n=>e.onEnabledChange(n.target.checked)}),s.jsx("span",{children:l("settings.opencliEnableAction")})]}),s.jsx("button",{className:"secondary-button",type:"button",disabled:e.refreshDisabled,onClick:e.onRefresh,children:e.refreshing?l("common.loading"):l("settings.opencliRefreshAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:e.detailDisabled,onClick:e.onShowDetails,children:l("settings.opencliDetailAction")}),s.jsx("button",{className:"primary-button",type:"button",disabled:e.saveDisabled,onClick:e.onSave,children:e.saving?l("common.loading"):l("settings.opencliSaveAction")})]})}function Mw({command:e,checked:t,disabled:n,onToggle:r}){const i=Em(e.commandId);return s.jsxs("div",{className:"settings-opencli-command-card",children:[s.jsxs("div",{className:"settings-opencli-command-card-head",children:[s.jsx("div",{className:"settings-opencli-command-badge",style:i.style,children:s.jsx("span",{children:e.name.slice(0,1).toUpperCase()})}),s.jsxs("div",{className:"settings-opencli-command-card-main",children:[s.jsxs("label",{className:"settings-opencli-checkbox",children:[s.jsx("input",{"aria-label":l("settings.opencliCommandToggleLabel",{commandId:e.commandId}),type:"checkbox",checked:t,disabled:n,onChange:a=>r(e.commandId,a.target.checked)}),s.jsx("span",{children:e.commandId})]}),s.jsx("p",{className:"settings-skill-entry-meta",children:e.description||l("settings.opencliCommandDescriptionEmpty")})]})]}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":Pm(e.strategy),children:zw(e.strategy)}),e.browser?s.jsx("span",{className:"settings-skill-tag","data-status":"failed",children:l("settings.opencliBrowserTag")}):s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:l("settings.opencliHttpTag")})]})]})}function Va({label:e,value:t}){return s.jsxs("div",{className:"settings-skill-summary-card",children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t})]})}function Rw(e){const t=Array.from(new Set(e.map(n=>n.strategy.trim()).filter(n=>n.length>0&&n!=="unknown"))).sort((n,r)=>n.localeCompare(r));return[{id:"all",label:l("settings.opencliFilterAll")},{id:"enabled",label:l("settings.opencliFilterEnabled")},{id:"browser",label:l("settings.opencliFilterBrowser")},{id:"direct",label:l("settings.opencliFilterDirect")},...t.map(n=>({id:`strategy:${n}`,label:l("settings.opencliFilterStrategy",{strategy:Mm(n)})}))]}function Gd(e,t,n){switch(t){case"all":return!0;case"enabled":return n.has(e.commandId);case"browser":return e.browser;case"direct":return!e.browser;default:return t.startsWith("strategy:")?e.strategy===t.slice(9):!0}}function Pw(e,t){const n=e.commands.filter(r=>t.has(r.commandId)).length;return{selectedCount:n,allSelected:n>0&&n===e.commands.length,partialSelected:n>0&&n<e.commands.length}}function Aw(e,t){return t?[e.commandId,e.name,e.description,e.strategy].join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileContextPanel-lM5mBcfn.js","assets/index-CjewzOUG.js","assets/index-VVxfF0s5.css","assets/App-B0q8uDA-.js","assets/App-CcDXqFl1.css","assets/model-switch-api-Br0ivfe5.js","assets/WorkbenchModal-BYNuMIoV.js","assets/file-tree-icon-BFwaPxKs.js","assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js","assets/relay-entry-D7OgZZN-.js","assets/GitSidebar-CmXAhyjo.js","assets/TerminalManagerPanel-D9JHCS6d.js","assets/terminal-runtime-meta-BCtAYB0E.js","assets/TerminalRuntimeFallbackModal-W5NjqFEz.js"])))=>i.map(i=>d[i]);
2
+ var qk=Object.defineProperty;var Gk=(e,t,n)=>t in e?qk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var at=(e,t,n)=>Gk(e,typeof t!="symbol"?t+"":t,n);import{C as pe,t as l,b as f,j as s,e as ar,m as ca,H as pu,J as Of,F as Vk,K as Kk,w as fu,A as mu,g as Wf,D as Yk,p as Zo,L as Xk,M as Jk,N as Ff,i as $f,O as Tc,f as gu,h as Ic,P as Qk,l as zf,y as Zk,n as ey,z as ty,d as ny,_ as bu}from"./index-CjewzOUG.js";import{m as vt,e as $n,h as el,u as xa,f as lr,g as Fr,i as ry,j as sy,O as gd}from"./App-B0q8uDA-.js";import{e as ku,f as Mn,i as mi,j as Jt,k as $a,V as Ro,A as iy,h as Lt,v as Ss,a2 as bd,a3 as ay,a4 as oy,H as Hf,l as ly,m as cy,a5 as Uf,a6 as uy,M as dy,a7 as hy,a8 as py,n as fy,o as my,t as gy,q as by,s as qf,a as Ec,p as yu,a9 as ky,aa as yy,ab as xy,u as za,g as wy,ac as vy,ad as Sy,ae as Cy,af as Gf,ag as Ny,ah as Vf,ai as jy,aj as Ty,ak as Kf,K as Iy,S as Ey,R as kd,r as My,al as Ry}from"./model-switch-api-Br0ivfe5.js";import{t as ui,P as Po,g as Yf}from"./window-BVUB8gMK.js";import{R as Py,_ as yd,a as xd,C as Xf,i as ze}from"./event-DvH9tcej.js";import{W as St,M as Ay,D as xu}from"./WorkbenchModal-BYNuMIoV.js";import{r as Ly,b as _y}from"./relay-entry-D7OgZZN-.js";const di=new Map,Jf=48;function As(){return typeof window<"u"&&typeof window.sessionStorage<"u"}function wd(e,t){return!Number.isFinite(e)||Date.now()-e>t}function Dy(e){return!e||typeof e!="object"||!("savedAt"in e)||!("value"in e)?!1:Number.isFinite(e.savedAt)}function Qf(e){try{const t=JSON.parse(e);return Dy(t)?t:null}catch{return null}}function By(){if(!As())return[];try{return Array.from({length:window.sessionStorage.length},(e,t)=>window.sessionStorage.key(t)).filter(e=>typeof e=="string"&&e.length>0)}catch{return[]}}function Zf(){if(!As())return[];const e=[];for(const t of By()){let n=null;try{n=window.sessionStorage.getItem(t)}catch{continue}if(!n)continue;const r=Qf(n);r&&e.push({key:t,savedAt:r.savedAt})}return e.sort((t,n)=>t.savedAt-n.savedAt)}function ua(e){if(As())try{window.sessionStorage.removeItem(e)}catch{}}function Ha(e){const t=new Set((e==null?void 0:e.preserveKeys)??[]),n=(e==null?void 0:e.maxCount)??Jf,r=Zf().filter(a=>!t.has(a.key)),i=Math.max(0,t.size+r.length-n);for(let a=0;a<i;a+=1){const o=r[a];if(!o)break;ua(o.key)}}function Oy(e){return e instanceof DOMException&&(e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED"||e.code===22||e.code===1014)}function Ll(e,t){if(!As())return"failed";try{return window.sessionStorage.setItem(e,t),"success"}catch(n){return Oy(n)?"quota_exceeded":"failed"}}function Wy(e,t){const n=Ll(e,t);if(n==="success"){Ha({preserveKeys:[e]});return}if(n==="quota_exceeded"){if(ua(e),Ha({maxCount:Math.max(0,Jf-1)}),Ll(e,t)==="success"){Ha({preserveKeys:[e]});return}for(const r of Zf())if(r.key!==e&&(ua(r.key),Ll(e,t)==="success")){Ha({preserveKeys:[e]});return}}}function Ao(e,t){const n=di.get(e);if(n){if(!wd(n.savedAt,t))return n.value;di.delete(e)}if(!As())return null;let r=null;try{r=window.sessionStorage.getItem(e)}catch{return null}if(!r)return null;const i=Qf(r);return!i||wd(i.savedAt,t)?(ua(e),di.delete(e),null):(di.set(e,i),i.value)}function ra(e,t){const n={savedAt:Date.now(),value:t};if(di.set(e,n),!!As())try{Wy(e,JSON.stringify(n))}catch{}}function XA(e){di.delete(e),As()&&ua(e)}const Fy="codingns.debug.perf",$y="codingns.debug.sessionMessageDedup",zy="codingns.debug.timelineScroll",Hy="codingns.debug.conversationTimeline";function Uy(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Fy)==="1"}catch{return!1}}function un(e,t){if(!Uy()||typeof performance>"u")return;const n=Math.round(performance.now());if(t&&Object.keys(t).length>0){console.info(`[perf-ui] ${e} ${n}ms`,t);return}console.info(`[perf-ui] ${e} ${n}ms`)}function qy(){if(typeof window>"u")return!1;try{return window.localStorage.getItem($y)==="1"}catch{return!1}}function os(e,t){if(!qy()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,a=i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__??[];a.push(r),a.length>300&&a.splice(0,a.length-300),i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__=a}catch{}if(t&&Object.keys(t).length>0){console.info(`[session-dedup] ${e} ${n}ms`,t);return}console.info(`[session-dedup] ${e} ${n}ms`)}function Gy(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Hy)==="1"}catch{return!1}}function Vy(e,t){if(!Gy()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window;i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG_CLEARED__!==!0&&(i.__CODINGNS_OPENCODE_ORDER_DEBUG__=[],i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__=[],i.__CODINGNS_TIMELINE_SCROLL_DEBUG__=[],i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG__=[],i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG_CLEARED__=!0);const a=i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG__??[];a.push(r),a.length>400&&a.splice(0,a.length-400),i.__CODINGNS_CONVERSATION_TIMELINE_DEBUG__=a}catch{}if(t&&Object.keys(t).length>0){console.info(`[conversation-timeline] ${e} ${n}ms`,t);return}console.info(`[conversation-timeline] ${e} ${n}ms`)}function Mc(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(zy)==="1"}catch{return!1}}function Ky(e,t){if(!Mc()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,a=i.__CODINGNS_TIMELINE_SCROLL_DEBUG__??[];a.push(r),a.length>300&&a.splice(0,a.length-300),i.__CODINGNS_TIMELINE_SCROLL_DEBUG__=a}catch{}if(t&&Object.keys(t).length>0){console.info(`[timeline-scroll] ${e} ${n}ms`,t);return}console.info(`[timeline-scroll] ${e} ${n}ms`)}function em(e){return pe.request(`/api/office/artifacts/${encodeURIComponent(e)}/preview-link`)}function tm(e,t){return pe.request(`/api/office/tasks/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}/preview-link`)}function JA(e,t){const n=new URLSearchParams({workspaceId:e});return t&&n.set("path",t),pe.request(`/api/files/tree?${n.toString()}`)}function QA(e,t,n,r){return pe.request("/api/files/content",{method:"PUT",body:JSON.stringify({workspaceId:e,path:t,content:n,expectedVersion:r??void 0})})}function ZA(e){return pe.request("/api/files/ops",{method:"POST",body:JSON.stringify(e)})}function eL(e){return pe.request("/api/files/upload",{method:"POST",body:JSON.stringify(e)})}function tL(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return pe.request(`/api/files/download?${n.toString()}`)}function Yy(e,t,n=1,r=20){const i=new URLSearchParams({workspaceId:e,keyword:t,page:String(n),pageSize:String(r)});return pe.request(`/api/files/search?${i.toString()}`)}function nL(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return pe.request(`/api/files/preview?${n.toString()}`)}function nm(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return pe.request(`/api/files/preview-link?${n.toString()}`)}function rL(e){return pe.request(`/api/git/status?workspaceId=${encodeURIComponent(e)}`)}function sL(e){return pe.request("/api/git/init",{method:"POST",body:JSON.stringify({workspaceId:e})})}function iL(e,t,n){const r=new URLSearchParams({workspaceId:e,path:t,staged:String(n)});return pe.request(`/api/git/diff?${r.toString()}`)}function aL(e,t){return pe.request("/api/git/stage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function oL(e,t){return pe.request("/api/git/unstage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function lL(e,t){return pe.request("/api/git/discard",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function cL(e,t){return pe.request("/api/git/commit/draft",{method:"POST",body:JSON.stringify({workspaceId:e,mode:t})})}function uL(e,t){return pe.request("/api/git/commit",{method:"POST",body:JSON.stringify({workspaceId:e,draft:t})})}function dL(e){return pe.request("/api/git/commit/undo",{method:"POST",body:JSON.stringify({workspaceId:e})})}function hL(e,t=5,n=null){const r=new URLSearchParams({workspaceId:e,limit:String(t)});return n&&r.set("cursor",n),pe.request(`/api/git/history?${r.toString()}`)}function pL(e,t){const n=new URLSearchParams({workspaceId:e,commitHash:t});return pe.request(`/api/git/commit-detail?${n.toString()}`)}function Xy(e){return pe.request(`/api/git/branches?workspaceId=${encodeURIComponent(e)}`)}function Jy(e){return pe.request(`/api/git/tags?workspaceId=${encodeURIComponent(e)}`)}function fL(e,t,n){return pe.request("/api/git/branches/switch",{method:"POST",body:JSON.stringify({workspaceId:e,branchName:t,create:n})})}function mL(e,t,n,r,i){return pe.request("/api/git/remote/sync",{method:"POST",body:JSON.stringify({workspaceId:e,action:t,...n?{remote:n}:{},...r?{auth:r}:{},...i?{remember:i}:{}})})}function gL(e){return pe.request(`/api/git/remotes?workspaceId=${encodeURIComponent(e)}`)}var Co,No;function rm(e){var t;if("items"in e)e.items=(t=e.items)===null||t===void 0?void 0:t.map(n=>"rid"in n?n:rm(n));else if("action"in e&&e.action){const n=new Xf;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function Si(e,t){const n=new Xf;if(t&&typeof t=="object"&&("action"in t&&t.action&&(n.onmessage=t.action,delete t.action),"item"in t&&t.item&&typeof t.item=="object"&&"About"in t.item&&t.item.About&&typeof t.item.About=="object"&&"icon"in t.item.About&&t.item.About.icon&&(t.item.About.icon=ui(t.item.About.icon)),"icon"in t&&t.icon&&(t.icon=ui(t.icon)),"items"in t&&t.items)){let r=function(i){var a;return"rid"in i?[i.rid,i.kind]:("item"in i&&typeof i.item=="object"&&(!((a=i.item.About)===null||a===void 0)&&a.icon)&&(i.item.About.icon=ui(i.item.About.icon)),"icon"in i&&i.icon&&(i.icon=ui(i.icon)),"items"in i&&i.items&&(i.items=i.items.map(r)),rm(i))};t.items=t.items.map(r)}return ze("plugin:menu|new",{kind:e,options:t,handler:n})}class Ci extends Py{get id(){return yd(this,Co,"f")}get kind(){return yd(this,No,"f")}constructor(t,n,r){super(t),Co.set(this,void 0),No.set(this,void 0),xd(this,Co,n),xd(this,No,r)}}Co=new WeakMap,No=new WeakMap;class wu extends Ci{constructor(t,n){super(t,n,"MenuItem")}static async new(t){return Si("MenuItem",t).then(([n,r])=>new wu(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ze("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ze("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return ze("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}}class vu extends Ci{constructor(t,n){super(t,n,"Check")}static async new(t){return Si("Check",t).then(([n,r])=>new vu(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ze("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ze("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return ze("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async isChecked(){return ze("plugin:menu|is_checked",{rid:this.rid})}async setChecked(t){return ze("plugin:menu|set_checked",{rid:this.rid,checked:t})}}var vd;(function(e){e.Add="Add",e.Advanced="Advanced",e.Bluetooth="Bluetooth",e.Bookmarks="Bookmarks",e.Caution="Caution",e.ColorPanel="ColorPanel",e.ColumnView="ColumnView",e.Computer="Computer",e.EnterFullScreen="EnterFullScreen",e.Everyone="Everyone",e.ExitFullScreen="ExitFullScreen",e.FlowView="FlowView",e.Folder="Folder",e.FolderBurnable="FolderBurnable",e.FolderSmart="FolderSmart",e.FollowLinkFreestanding="FollowLinkFreestanding",e.FontPanel="FontPanel",e.GoLeft="GoLeft",e.GoRight="GoRight",e.Home="Home",e.IChatTheater="IChatTheater",e.IconView="IconView",e.Info="Info",e.InvalidDataFreestanding="InvalidDataFreestanding",e.LeftFacingTriangle="LeftFacingTriangle",e.ListView="ListView",e.LockLocked="LockLocked",e.LockUnlocked="LockUnlocked",e.MenuMixedState="MenuMixedState",e.MenuOnState="MenuOnState",e.MobileMe="MobileMe",e.MultipleDocuments="MultipleDocuments",e.Network="Network",e.Path="Path",e.PreferencesGeneral="PreferencesGeneral",e.QuickLook="QuickLook",e.RefreshFreestanding="RefreshFreestanding",e.Refresh="Refresh",e.Remove="Remove",e.RevealFreestanding="RevealFreestanding",e.RightFacingTriangle="RightFacingTriangle",e.Share="Share",e.Slideshow="Slideshow",e.SmartBadge="SmartBadge",e.StatusAvailable="StatusAvailable",e.StatusNone="StatusNone",e.StatusPartiallyAvailable="StatusPartiallyAvailable",e.StatusUnavailable="StatusUnavailable",e.StopProgressFreestanding="StopProgressFreestanding",e.StopProgress="StopProgress",e.TrashEmpty="TrashEmpty",e.TrashFull="TrashFull",e.User="User",e.UserAccounts="UserAccounts",e.UserGroup="UserGroup",e.UserGuest="UserGuest"})(vd||(vd={}));class Su extends Ci{constructor(t,n){super(t,n,"Icon")}static async new(t){return Si("Icon",t).then(([n,r])=>new Su(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ze("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ze("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return ze("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async setIcon(t){return ze("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:ui(t)})}}class Cu extends Ci{constructor(t,n){super(t,n,"Predefined")}static async new(t){return Si("Predefined",t).then(([n,r])=>new Cu(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}}function gi([e,t,n]){switch(n){case"Submenu":return new tl(e,t);case"Predefined":return new Cu(e,t);case"Check":return new vu(e,t);case"Icon":return new Su(e,t);case"MenuItem":default:return new wu(e,t)}}class tl extends Ci{constructor(t,n){super(t,n,"Submenu")}static async new(t){return Si("Submenu",t).then(([n,r])=>new tl(n,r))}async text(){return ze("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ze("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ze("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ze("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async append(t){return ze("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async prepend(t){return ze("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async insert(t,n){return ze("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r),position:n})}async remove(t){return ze("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return ze("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(gi)}async items(){return ze("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(gi))}async get(t){return ze("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?gi(n):null)}async popup(t,n){var r;return ze("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(r=n==null?void 0:n.label)!==null&&r!==void 0?r:null,at:t instanceof Po?t:t?new Po(t):null})}async setAsWindowsMenuForNSApp(){return ze("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return ze("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(t){return ze("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:ui(t)})}}class hi extends Ci{constructor(t,n){super(t,n,"Menu")}static async new(t){return Si("Menu",t).then(([n,r])=>new hi(n,r))}static async default(){return ze("plugin:menu|create_default").then(([t,n])=>new hi(t,n))}async append(t){return ze("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async prepend(t){return ze("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async insert(t,n){return ze("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r),position:n})}async remove(t){return ze("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return ze("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(gi)}async items(){return ze("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(gi))}async get(t){return ze("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?gi(n):null)}async popup(t,n){var r;return ze("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(r=n==null?void 0:n.label)!==null&&r!==void 0?r:null,at:t instanceof Po?t:t?new Po(t):null})}async setAsAppMenu(){return ze("plugin:menu|set_as_app_menu",{rid:this.rid}).then(t=>t?new hi(t[0],t[1]):null)}async setAsWindowMenu(t){var n;return ze("plugin:menu|set_as_window_menu",{rid:this.rid,window:(n=t==null?void 0:t.label)!==null&&n!==void 0?n:null}).then(r=>r?new hi(r[0],r[1]):null)}}async function Qy(e){if(e.length===0)return;await(await hi.new({items:await Promise.all(e.map(n=>sm(n)))})).popup(void 0,Yf())}async function sm(e){return"items"in e?tl.new({id:e.id,text:e.label,enabled:!e.disabled,items:await Promise.all(e.items.map(t=>sm(t)))}):{id:e.id,text:e.label,enabled:!e.disabled,accelerator:e.accelerator,action:()=>{e.onSelect()}}}const Sd={"parallel-group-1":{accent:"#0ea5e9",soft:"rgba(14, 165, 233, 0.16)",surface:"rgba(14, 165, 233, 0.08)"},"parallel-group-2":{accent:"#10b981",soft:"rgba(16, 185, 129, 0.16)",surface:"rgba(16, 185, 129, 0.08)"},"parallel-group-3":{accent:"#f59e0b",soft:"rgba(245, 158, 11, 0.16)",surface:"rgba(245, 158, 11, 0.08)"},"parallel-group-4":{accent:"#ec4899",soft:"rgba(236, 72, 153, 0.16)",surface:"rgba(236, 72, 153, 0.08)"},"parallel-group-5":{accent:"#8b5cf6",soft:"rgba(139, 92, 246, 0.16)",surface:"rgba(139, 92, 246, 0.08)"},"parallel-group-6":{accent:"#f97316",soft:"rgba(249, 115, 22, 0.16)",surface:"rgba(249, 115, 22, 0.08)"}},Zy=2600,im="workbench.parallel.pane.palette";let ii=null;const Cd=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"];function ex(e="create"){return e==="append"?{totalDurationMs:1200,sidebarCollapseDurationMs:0,paneEnterDelayMs:0,paneEnterDurationMs:1e3,gridRevealDelayMs:0,gridRevealDurationMs:920,shellExpandDurationMs:0,paneStaggerMs:80}:{totalDurationMs:2e3,sidebarCollapseDurationMs:720,paneEnterDelayMs:520,paneEnterDurationMs:1480,gridRevealDelayMs:420,gridRevealDurationMs:1360,shellExpandDurationMs:720,paneStaggerMs:96}}function am(e){var n,r;const t=(n=e.displayParentSessionId)==null?void 0:n.trim();return t||((r=e.parentSessionId)==null?void 0:r.trim())||null}function tx(e){var r;const t=(r=e==null?void 0:e.colorToken)==null?void 0:r.trim();if(!t)return;const n=Sd[t]??Sd["parallel-group-1"];return{"--parallel-group-accent":n.accent,"--parallel-group-soft":n.soft,"--parallel-group-surface":n.surface}}function bL(e){const t=Lo(e.overrideColor)??nx(e.groupId,e.ordinal);return{"--parallel-group-accent":t,"--parallel-group-soft":Nd(t,.08),"--parallel-group-surface":Nd(t,.03)}}function kL(e){if(typeof window>"u")return null;const t=e.trim();if(!t)return null;const n=om();return Lo(n[t]??null)}function yL(e,t){if(typeof window>"u")return Lo(t);const n=e.trim();if(!n)return null;const r=om(),i=Lo(t);return i?r[n]=i:delete r[n],window.localStorage.setItem(im,JSON.stringify(r)),i}function nx(e,t){const n=Cd.length,r=Math.abs(lx(e))%n;return Cd[(r+t*5)%n]}function xL(e){return e?e.role==="anchor"?l("shell.parallelGroupAnchorBadge"):l("shell.parallelGroupMemberBadge"):null}function rx(e){return e?l("shell.parallelGroupBadge",{count:e.memberCount}):null}function wL(e){var n;return((n=e==null?void 0:e.branchName)==null?void 0:n.trim())||null}function vL(e){var n,r,i;return((r=(n=e==null?void 0:e.parallelGroup)==null?void 0:n.groupId)==null?void 0:r.trim())?((i=e==null?void 0:e.sessionIsolatedWorkspace)==null?void 0:i.lifecycleStatus)!=="promoted":!1}function sx(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="removing")?t.sourceWorkspaceId:e.workspaceId}function ix(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="promoted")?t.workspaceId:e.workspaceId}function ax(e,t="create"){ii={groupId:e,createdAt:Date.now(),...ex(t)}}function ox(e){return!ii||ii.groupId!==e?null:Date.now()-ii.createdAt>Zy?(ii=null,null):ii}function om(){if(typeof window>"u")return{};const e=window.localStorage.getItem(im);if(!e)return{};try{const t=JSON.parse(e);return!t||typeof t!="object"?{}:t}catch{return{}}}function lx(e){let t=0;for(const n of e)t=t*31+n.charCodeAt(0)|0;return t}function Lo(e){const t=(e==null?void 0:e.trim().toUpperCase())??"";return/^#[0-9A-F]{6}$/.test(t)?t:null}function Nd(e,t){const n=Math.max(0,Math.min(t,1)),r=Number.parseInt(e.slice(1,3),16),i=Number.parseInt(e.slice(3,5),16),a=Number.parseInt(e.slice(5,7),16);return`rgba(${r}, ${i}, ${a}, ${n})`}function Nu(e,t){const n=new Map(e.map(a=>[t.getId(a),a])),r=new Map,i=[];for(const a of e){const o=cx(a,n,t);if(!o){i.push(a);continue}const c=r.get(o)??[];r.set(o,[...c,a])}return[...i].sort(t.compare).map(a=>um(a,0,r,t,new Set))}function Ni(e){return Array.isArray(e==null?void 0:e.children)?e.children:[]}function lm(e){return e.flatMap(t=>[t.item,...lm(Ni(t))])}function Ns(e){return e.flatMap(t=>[t,...Ns(Ni(t))])}function ju(e,t){return e.some(n=>t(n.item)||ju(Ni(n),t))}function cm(e,t,n){return e?n(e.item)===t?!0:Ni(e).some(r=>cm(r,t,n)):!1}function ai(e,t,n){for(const r of e){const i=n(r.item);if(i===t)return[];const a=ai(Ni(r),t,n);if(cm(r,t,n)&&a.length>=0)return[i,...a]}return[]}function um(e,t,n,r,i){const a=r.getId(e),o=new Set(i);o.add(a);const c=[...n.get(a)??[]].filter(u=>!o.has(r.getId(u))).sort(r.compare).map(u=>um(u,t+1,n,r,o));return{item:e,depth:t,children:c}}function cx(e,t,n){const r=jd(n.getParentId(e));if(!r)return null;const i=t.get(r);if(!i)return null;const a=new Set([n.getId(e)]);let o=i;for(;o;){const c=n.getId(o);if(a.has(c))return null;a.add(c);const u=jd(n.getParentId(o));if(!u||(o=t.get(u),!o))return r}return r}function jd(e){const t=e==null?void 0:e.trim();return t||null}function xn(){return"/workspaces"}function Ir(e){return`/workspaces/${encodeURIComponent(e)}`}function dm(e){return`${Ir(e)}/debug`}function xi(e){return`${Ir(e)}/sessions`}function ir(e,t){return`${xi(e)}/${encodeURIComponent(t)}`}function hm(e,t){const n=`${Ir(e)}/tools`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function pm(e){return`${Ir(e)}/tools/files`}function fm(e){return`${Ir(e)}/tools/git`}function mm(e){return`${Ir(e)}/tools/processes`}function js(e){return`${Ir(e)}/terminals`}function Ms(e,t){const n=`${Ir(e)}/butler`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function ux(e){return km(e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),...bm(t.childWorktrees??[])])).sort((t,n)=>(n.session.lastMessageAt??n.session.updatedAt).localeCompare(t.session.lastMessageAt??t.session.updatedAt))}function SL(e,t){return Nu(km(e),{getId:n=>n.session.sessionId,getParentId:n=>dx(n.session,t),compare:px})}function dx(e,t){var n;return(t==null?void 0:t.mode)==="mobile"?((n=e.parentSessionId)==null?void 0:n.trim())||null:am(e)}function gm(e,t){const n=hx(),r=new URLSearchParams({provider:t});return`${ir(e,n)}?${r.toString()}`}function hx(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`draft-${e.randomUUID()}`:`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`}function px(e,t){return(t.session.lastMessageAt??t.session.updatedAt).localeCompare(e.session.lastMessageAt??e.session.updatedAt)}function bm(e){return e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),...bm(t.children)])}function km(e){const t=[],n=new Set;for(const r of e){const i=r.session.sessionId.trim();!i||n.has(i)||(n.add(i),t.push(r))}return t}const fx="mobile.tools.last-primary-tool";function ym(){if(typeof window>"u")return"files";try{return window.localStorage.getItem(fx)==="git"?"git":"files"}catch{return"files"}}function Tu(e){var r;const t=[{pattern:"/workspaces/:workspaceId/tools/processes",routeKind:"processes"},{pattern:"/workspaces/:workspaceId/tools/files",routeKind:"files"},{pattern:"/workspaces/:workspaceId/tools/git",routeKind:"git"},{pattern:"/workspaces/:workspaceId/tools",routeKind:"home"}];for(const i of t){const a=vt(i.pattern,e),o=((r=a==null?void 0:a.params.workspaceId)==null?void 0:r.trim())??null;if(o)return{workspaceId:o,routeKind:i.routeKind,legacy:!1}}const n=[{pattern:"/tools/processes",routeKind:"processes"},{pattern:"/tools/files",routeKind:"files"},{pattern:"/tools/git",routeKind:"git"},{pattern:"/tools",routeKind:"home"}];for(const i of n)if(vt(i.pattern,e))return{workspaceId:null,routeKind:i.routeKind,legacy:!0};return null}function mx(e,t){const n=Tu(e);if((n==null?void 0:n.routeKind)==="git")return"git";if((n==null?void 0:n.routeKind)==="files")return"files";const r=new URLSearchParams(t).get("tab");return r==="git"?"git":r==="files"?"files":ym()}function Iu(e,t){const n=Tu(e);return(n==null?void 0:n.routeKind)==="processes"&&n.workspaceId?js(n.workspaceId):n!=null&&n.workspaceId?hm(n.workspaceId,mx(e,t)):n!=null&&n.legacy?ym()==="git"?"/tools?tab=git":"/tools?tab=files":null}function Eu({activeEntry:e,presentation:t,pathname:n,search:r,moreButtonLabel:i}){if(t==="conversation-focus"||e!=="butler")return null;const a=Tu(n);return a?a.routeKind==="processes"?{title:l("shell.terminalManagerEntry"),showBackButton:!0,showMoreButton:!1,moreButtonLabel:i}:(a.routeKind==="home"||a.routeKind==="files"||a.routeKind==="git",null):null}const xm=f.createContext({composerPortalTarget:null});function Mu({composerPortalTarget:e,children:t}){return s.jsx(xm.Provider,{value:{composerPortalTarget:e},children:t})}function CL(){return f.useContext(xm)}function Ru(e,t,n){const[r,i]=f.useState(void 0);return f.useEffect(()=>{const a=e.current,o=t.current;if(!n||!a||!o){i(void 0),a&&a.style.removeProperty("--mobile-conversation-tabbar-height");return}const c=a,u=o;function d(){if(!e.current||!u.isConnected)return;const p=`${Math.round(u.getBoundingClientRect().height)}px`;c.style.setProperty("--mobile-conversation-tabbar-height",p),i(p)}d();const h=typeof ResizeObserver<"u"?new ResizeObserver(d):null;return h==null||h.observe(u),window.addEventListener("resize",d),()=>{h==null||h.disconnect(),window.removeEventListener("resize",d),c.style.removeProperty("--mobile-conversation-tabbar-height")}},[n,e,t]),r}const gx=3e3,Ua=10,Td=84,Id=.36;function Pu({enabled:e,rootRef:t,suspended:n=!1,resetKey:r}){const i=f.useRef(null),a=f.useRef(null),o=f.useRef("visible"),c=f.useRef(1),[u,d]=f.useState("visible"),[h,p]=f.useState(1);f.useEffect(()=>{o.current=u},[u]),f.useEffect(()=>{c.current=h},[h]);function g(){xs(i),i.current=window.setTimeout(()=>{m()},gx)}function m(){d("hidden"),p(0)}function y(){d("visible"),p(1),g()}f.useEffect(()=>{if(xs(i),!e){xs(i),d("visible"),p(1);return}if(n){d("hidden"),p(0);return}return y(),()=>{xs(i)}},[e,r,n]),f.useEffect(()=>()=>{xs(i)},[]),f.useEffect(()=>{if(!e||n){a.current=null;return}const j=t.current;if(!j)return;function x(z){if(z.touches.length!==1){a.current=null;return}const L=z.touches[0],E=Rd(z.target);if(!L||!E){a.current=null;return}a.current={surface:E,startX:L.clientX,startY:L.clientY,pointerType:"touch",initialState:o.current==="visible"?"visible":"hidden",touchId:L.identifier,dragging:!1,latestProgress:c.current},o.current==="visible"&&xs(i)}function A(z){const L=a.current;if(!L||L.pointerType!=="touch")return;const E=_l(z.touches,L.touchId);if(!E)return;const H=E.clientX-L.startX,B=E.clientY-L.startY;if(L.surface==="conversation"){if(Math.abs(B)<=Ua||Math.abs(B)<=Math.abs(H))return;a.current=null,L.initialState==="visible"&&m();return}const oe=L.initialState==="hidden"?-B:B;oe<=Ua&&!L.dragging||(Ad(z),L.dragging=!0,L.latestProgress=Ed(L.initialState,oe),d("dragging"),p(L.latestProgress))}function T(z){const L=a.current;if(!(!L||L.pointerType!=="touch"||!_l(z.changedTouches,L.touchId))){if(a.current=null,!L.dragging){L.initialState==="visible"&&g();return}Md(L.initialState,L.latestProgress,y,d,p)}}function F(z){const L=a.current;if(!(!L||L.pointerType!=="touch"||!_l(z.changedTouches,L.touchId))){if(a.current=null,!L.dragging){L.initialState==="visible"&&g();return}if(L.initialState==="visible"){y();return}d("hidden"),p(0)}}function R(z){if(z.pointerType!=="touch")return;const L=Rd(z.target);if(!L){a.current=null;return}if(a.current={surface:L,startX:z.clientX,startY:z.clientY,pointerType:"pointer",initialState:o.current==="visible"?"visible":"hidden",pointerId:z.pointerId,captureTarget:z.target instanceof Element?z.target:null,dragging:!1,latestProgress:c.current},z.target instanceof Element)try{z.target.setPointerCapture(z.pointerId)}catch{}o.current==="visible"&&xs(i)}function I(z){const L=a.current;if(!L||L.pointerType!=="pointer")return;const E=z.clientX-L.startX,H=z.clientY-L.startY;if(L.surface==="conversation"){if(Math.abs(H)<=Ua||Math.abs(H)<=Math.abs(E))return;a.current=null,L.initialState==="visible"&&m();return}const B=L.initialState==="hidden"?-H:H;B<=Ua&&!L.dragging||(Ad(z),L.dragging=!0,L.latestProgress=Ed(L.initialState,B),d("dragging"),p(L.latestProgress))}function G(z){const L=a.current;if(!(!L||L.pointerType!=="pointer"||L.pointerId!==z.pointerId)){if(a.current=null,bx(L),!L.dragging){L.initialState==="visible"&&g();return}Md(L.initialState,L.latestProgress,y,d,p)}}return j.addEventListener("touchstart",x,{passive:!0}),j.addEventListener("pointerdown",R,{passive:!0}),window.addEventListener("touchmove",A,{passive:!1}),window.addEventListener("touchend",T),window.addEventListener("touchcancel",F),window.addEventListener("pointermove",I,{passive:!1}),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G),()=>{j.removeEventListener("touchstart",x),j.removeEventListener("pointerdown",R),window.removeEventListener("touchmove",A),window.removeEventListener("touchend",T),window.removeEventListener("touchcancel",F),window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G)}},[e,t,n]);const S=e&&!n?h:e?0:1;return{state:n&&e?"hidden":u,progress:S,isOpen:S>.01}}function xs(e){e.current!==null&&(window.clearTimeout(e.current),e.current=null)}function Ed(e,t){return Pd(e==="hidden"?t/Td:1-t/Td,0,1)}function Md(e,t,n,r,i){if(e==="hidden"){if(t>=Id){n();return}r("hidden"),i(0);return}if(t<=1-Id){r("hidden"),i(0);return}n()}function bx(e){if(!(e.pointerType!=="pointer"||typeof e.pointerId!="number"||!(e.captureTarget instanceof Element)))try{e.captureTarget.hasPointerCapture(e.pointerId)&&e.captureTarget.releasePointerCapture(e.pointerId)}catch{}}function _l(e,t){if(typeof t!="number")return e[0]??null;for(let n=0;n<e.length;n+=1){const r=e[n];if((r==null?void 0:r.identifier)===t)return r}return null}function Rd(e){return e instanceof Element?e.closest(".composer-panel")?"composer":e.closest(".message-list, .message-timeline, .mobile-conversation-main, .conversation-page-shell, .mobile-butler-main-stage, .mobile-butler-chat-body, .mobile-butler-page-shell")?"conversation":null:null}function Pd(e,t,n){return Math.min(Math.max(e,t),n)}function Ad(e){e.cancelable&&e.preventDefault()}function wa({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i=!1}){return i||e==="compact"?"compact":e==="expanded"&&n&&r?"expanded":t==="butler"&&r?"medium-auxiliary":n?"medium-navigation":r?"medium-auxiliary":"compact"}function nl(e){return!e.isNativeMobile||e.viewportClass==="expanded"||typeof window>"u"?!1:window.innerHeight>window.innerWidth}function wm(e){return e==="medium-navigation"||e==="expanded"}function vm(e){return e==="medium-auxiliary"||e==="expanded"}function Au({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i=!1,children:a,navigationPanel:o,auxiliaryPanel:c}){const u=wa({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i}),d=wm(u)&&o,h=vm(u)&&c;return s.jsxs("div",{className:"mobile-adaptive-pane-layout","data-pane-layout":u,children:[d?s.jsx("aside",{className:"workbench-nav surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-navigation",children:o}):null,s.jsx("div",{className:"mobile-adaptive-pane-main",children:a}),h?s.jsx("aside",{className:"workbench-auxiliary surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-auxiliary",children:c}):null]})}function kx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:a,onNavigateTerminals:o,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=$n(),g=ku(),m=el(),y=xa(),S=f.useRef(null),j=f.useRef(null),[x,A]=f.useState(null),T=t==="conversation-focus",F=nl({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),R=Pu({enabled:T,rootRef:S,resetKey:`${m.pathname}${m.search}`}),I=wa({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:F}),G=Eu({activeEntry:e,presentation:t,pathname:m.pathname,search:m.search,moreButtonLabel:l("shell.androidMoreAction")}),z=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(wx,{}),onClick:a},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(vx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Cx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(Sx,{}),onClick:o},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Nx,{}),onClick:h}],L=T?{"--mobile-conversation-tabbar-progress":R.progress.toFixed(4)}:void 0;Ru(S,j,T);function E(){const B=Iu(m.pathname,m.search);if(!B){o();return}y(B,{replace:!0})}const H=s.jsx("nav",{ref:j,className:"android-workbench-bottom-nav","aria-label":l("shell.title"),children:z.map(B=>s.jsxs("button",{type:"button",className:"android-workbench-bottom-nav-item","data-active":B.key===e,"aria-current":B.key===e?"page":void 0,onClick:()=>{B.key!==e&&g.trigger("selection"),B.onClick()},children:[s.jsx("span",{className:"android-workbench-bottom-nav-icon","aria-hidden":"true",children:B.icon}),s.jsx("span",{className:"android-workbench-bottom-nav-label",children:B.label})]},B.key))});return s.jsx(Mu,{composerPortalTarget:T?x:null,children:s.jsxs("div",{ref:S,className:"android-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":I,"data-tabbar-open":T?R.isOpen:!0,"data-conversation-tabbar-state":T?R.state:"default",style:L,children:[G?s.jsxs("header",{className:"android-workbench-topbar","data-header-kind":"tools",children:[s.jsxs("div",{className:"android-workbench-topbar-leading",children:[G.showBackButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":l("common.back"),onClick:E,children:s.jsx(yx,{})}):null,s.jsx("div",{className:"android-workbench-topbar-copy",children:s.jsx("h1",{children:G.title})})]}),s.jsx("div",{className:"android-workbench-topbar-actions",children:G.showMoreButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":G.moreButtonLabel,onClick:d,children:s.jsx(xx,{})}):null})]}):null,s.jsx("div",{className:"android-workbench-content",children:s.jsx(Au,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:F,navigationPanel:r,auxiliaryPanel:i,children:n})}),T?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:H})]}):H]})})}function yx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"m15 18-6-6 6-6"}),s.jsx("path",{d:"M21 12H9"})]})}function xx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function wx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function vx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Sx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function Cx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Nx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}const jx=120,Xi={viewportHeight:null,keyboardInset:0,keyboardOpen:!1};function Rc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Tx(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable||e.closest("[contenteditable='true']"))return!0;if(e instanceof HTMLTextAreaElement)return!e.readOnly&&!e.disabled;if(e instanceof HTMLInputElement){if(e.readOnly||e.disabled)return!1;const t=(e.type||"text").toLowerCase();return!["button","checkbox","color","file","hidden","image","radio","range","reset","submit"].includes(t)}return!1}function Ix(){var t;if(typeof window>"u")return 0;const e=[window.innerHeight,typeof document<"u"?(t=document.documentElement)==null?void 0:t.clientHeight:0].filter(Rc);return e.length>0?Math.max(...e):0}function Ld(){if(typeof window>"u")return Xi;const e=window.visualViewport,t=Ix(),n=(e==null?void 0:e.height)??t,r=Rc(n)?Math.round(n):null,i=Rc(e==null?void 0:e.offsetTop)?(e==null?void 0:e.offsetTop)??0:0,a=r===null?0:Math.max(0,Math.round(t-r-i));return{viewportHeight:r,keyboardInset:a,keyboardOpen:Tx(typeof document<"u"?document.activeElement:null)&&a>=jx}}function Dl(e,t){if(typeof document>"u")return;[document.documentElement,document.body].filter(r=>r instanceof HTMLElement).forEach(r=>{if(!e){delete r.dataset.mobileKeyboardOpen,delete r.dataset.mobileViewportBound,r.style.removeProperty("--mobile-shell-viewport-height"),r.style.removeProperty("--mobile-shell-keyboard-inset");return}r.dataset.mobileKeyboardOpen=String(t.keyboardOpen),r.dataset.mobileViewportBound="true",t.viewportHeight===null?r.style.removeProperty("--mobile-shell-viewport-height"):r.style.setProperty("--mobile-shell-viewport-height",`${t.viewportHeight}px`),r.style.setProperty("--mobile-shell-keyboard-inset",`${t.keyboardInset}px`)})}function Ex(e){const[t,n]=f.useState(()=>e?Ld():Xi),r=f.useRef(null);return f.useEffect(()=>{if(!e){n(Xi),Dl(!1,Xi);return}function i(){n(Ld())}function a(){r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,i()},0)}i();const o=window.visualViewport;return window.addEventListener("resize",i),window.addEventListener("orientationchange",i),o==null||o.addEventListener("resize",i),o==null||o.addEventListener("scroll",i),document.addEventListener("focusin",i),document.addEventListener("focusout",a),()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null),window.removeEventListener("resize",i),window.removeEventListener("orientationchange",i),o==null||o.removeEventListener("resize",i),o==null||o.removeEventListener("scroll",i),document.removeEventListener("focusin",i),document.removeEventListener("focusout",a),Dl(!1,Xi)}},[e]),f.useEffect(()=>{Dl(e,t)},[e,t]),t}function Mx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:a,onNavigateTerminals:o,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=$n(),g=ku(),m=el(),y=xa(),S=f.useRef(null),j=f.useRef(null),[x,A]=f.useState(null),T=t==="conversation-focus",F=nl({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),R=Pu({enabled:T,rootRef:S,resetKey:`${m.pathname}${m.search}`}),I=wa({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:F}),G=Eu({activeEntry:e,presentation:t,pathname:m.pathname,search:m.search,moreButtonLabel:l("shell.iosMoreAction")}),z=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(Ax,{}),onClick:a},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Lx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Dx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(_x,{}),onClick:o},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Bx,{}),onClick:h}],L=T?{"--mobile-conversation-tabbar-progress":R.progress.toFixed(4)}:void 0;Ru(S,j,T);function E(){const B=Iu(m.pathname,m.search);if(!B){o();return}y(B,{replace:!0})}const H=s.jsx("nav",{ref:j,className:"ios-workbench-tabbar","aria-label":l("shell.title"),children:z.map(B=>s.jsxs("button",{type:"button",className:"ios-workbench-tabbar-item","data-active":B.key===e,"aria-current":B.key===e?"page":void 0,onClick:()=>{B.key!==e&&g.trigger("selection"),B.onClick()},children:[s.jsx("span",{className:"ios-workbench-tabbar-icon","aria-hidden":"true",children:B.icon}),s.jsx("span",{className:"ios-workbench-tabbar-label",children:B.label})]},B.key))});return s.jsx(Mu,{composerPortalTarget:T?x:null,children:s.jsxs("div",{ref:S,className:"ios-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":I,"data-tabbar-open":T?R.isOpen:!0,"data-conversation-tabbar-state":T?R.state:"default",style:L,children:[G?s.jsxs("header",{className:"ios-workbench-nav","data-header-kind":"tools",children:[s.jsx("div",{className:"ios-workbench-nav-leading",children:G.showBackButton?s.jsxs("button",{type:"button",className:"ios-workbench-back-button","aria-label":l("common.back"),onClick:E,children:[s.jsx(Rx,{}),s.jsx("span",{children:l("common.back")})]}):null}),s.jsx("div",{className:"ios-workbench-nav-copy",children:s.jsx("h1",{children:G.title})}),s.jsx("div",{className:"ios-workbench-nav-actions",children:G.showMoreButton?s.jsx("button",{type:"button",className:"ios-workbench-icon-button","aria-label":G.moreButtonLabel,onClick:d,children:s.jsx(Px,{})}):null})]}):null,s.jsx("div",{className:"ios-workbench-content",children:s.jsx(Au,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:F,navigationPanel:r,auxiliaryPanel:i,children:n})}),T?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:H})]}):H]})})}function Rx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:s.jsx("path",{d:"m15 18-6-6 6-6"})})}function Px(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function Ax(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function Lx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function _x(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function Dx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Bx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function Ox(e){const t=$n();return t.platform==="ios"?s.jsx(Mx,{...e}):t.platform==="android"?s.jsx(kx,{...e}):s.jsx(Wx,{...e})}function Wx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:a,onNavigateTerminals:o,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=$n(),g=ku(),m=el(),y=xa(),S=f.useRef(null),j=f.useRef(null),[x,A]=f.useState(null),T=Ex(p.platform==="web"),F=p.platform==="web"&&T.keyboardOpen,R=t==="conversation-focus",I=nl({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),G=Pu({enabled:R,rootRef:S,suspended:F,resetKey:`${m.pathname}${m.search}`}),z=wa({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:I}),L=Eu({activeEntry:e,presentation:t,pathname:m.pathname,search:m.search,moreButtonLabel:l("shell.iosMoreAction")}),E=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(zx,{}),onClick:a},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Hx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(qx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(Ux,{}),onClick:o},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Gx,{}),onClick:h}],H=R?{"--mobile-conversation-tabbar-progress":G.progress.toFixed(4)}:void 0;Ru(S,j,R);function B(){const K=Iu(m.pathname,m.search);if(!K){o();return}y(K,{replace:!0})}const oe=s.jsx("nav",{ref:j,className:"mobile-workbench-tabbar","aria-label":l("shell.title"),hidden:F,children:E.map(K=>s.jsxs("button",{type:"button",className:"mobile-workbench-tabbar-item","data-active":K.key===e,"aria-current":K.key===e?"page":void 0,onClick:()=>{K.key!==e&&g.trigger("selection"),K.onClick()},children:[s.jsx("span",{className:"mobile-workbench-tabbar-icon","aria-hidden":"true",children:K.icon}),s.jsx("span",{className:"mobile-workbench-tabbar-label",children:K.label})]},K.key))});return s.jsx(Mu,{composerPortalTarget:R?x:null,children:s.jsxs("div",{ref:S,className:"mobile-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-mobile-runtime":p.platform,"data-mobile-keyboard-open":F,"data-pane-layout":z,"data-tabbar-open":F?!1:R?G.isOpen:!0,"data-conversation-tabbar-state":R?G.state:"default",style:H,children:[L?s.jsxs("header",{className:"mobile-workbench-header","data-header-kind":"tools",children:[s.jsxs("div",{className:"mobile-workbench-header-leading",children:[L.showBackButton?s.jsx("button",{type:"button",className:"mobile-workbench-header-button","aria-label":l("common.back"),onClick:B,children:s.jsx(Fx,{})}):null,s.jsx("div",{className:"mobile-workbench-header-copy",children:s.jsx("h1",{children:L.title})})]}),s.jsx("div",{className:"mobile-workbench-header-actions",children:L.showMoreButton?s.jsx("button",{type:"button",className:"mobile-workbench-header-button mobile-tools-more-button","aria-label":L.moreButtonLabel,onClick:d,children:s.jsx($x,{})}):null})]}):null,s.jsx("div",{className:"mobile-workbench-content",children:s.jsx(Au,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:I,navigationPanel:r,auxiliaryPanel:i,children:n})}),R?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:oe})]}):oe]})})}function Fx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"m15 18-6-6 6-6"}),s.jsx("path",{d:"M21 12H9"})]})}function $x(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function zx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function Hx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Ux(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function qx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Gx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}class Vx{constructor(t){at(this,"maxAttempts");at(this,"baseDelayMs");at(this,"reconnectAttempts",0);at(this,"reconnectTimer",null);at(this,"disposed",!1);this.options=t,this.maxAttempts=t.maxAttempts??4,this.baseDelayMs=t.baseDelayMs??300}start(){this.options.onReconnect(!1)}markConnected(){this.reconnectAttempts=0,this.options.onStateChange("connected")}markTransientFailure(){this.disposed||this.reconnectAttempts>0||this.options.onStateChange("reconnecting")}markDisconnected(){if(this.disposed)return;if(!ar.getState().autoReconnect){this.options.onStateChange("reconnect_failed");return}if(this.reconnectAttempts+=1,this.reconnectAttempts>this.maxAttempts){this.options.onStateChange("reconnect_failed");return}this.options.onStateChange("reconnecting");const t=this.baseDelayMs*this.reconnectAttempts;this.reconnectTimer=window.setTimeout(()=>{this.options.onReconnect(!0)},t)}reconnectNow(){this.reconnectAttempts=0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onReconnect(!0)}close(){this.disposed=!0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onStateChange("closed")}}class Kx{constructor(t){at(this,"socket",null);at(this,"disposed",!1);at(this,"authRecoveryInFlight",!1);at(this,"pendingRefresh",!1);at(this,"workbenchKnownRevision");at(this,"lastWorkbenchSnapshot",null);at(this,"fileTreeSubscription",null);at(this,"gitSubscription",null);at(this,"terminalManagerSubscription",null);at(this,"workspaceManagementSubscription",null);at(this,"pendingFileTreeRefresh",null);at(this,"pendingGitRefresh",null);at(this,"pendingTerminalManagerRefresh",null);at(this,"pendingWorkspaceManagementRefresh",null);at(this,"fileTreeRevisionByPath",new Map);at(this,"gitRevisionByWorkspaceId",new Map);at(this,"terminalManagerRevisionByWorkspaceId",new Map);at(this,"workspaceManagementRevisionByWorkspaceId",new Map);at(this,"fileTreeListeners",new Set);at(this,"gitListeners",new Set);at(this,"terminalManagerListeners",new Set);at(this,"workspaceManagementListeners",new Set);at(this,"workbenchSubscribeStartedAtMs",null);at(this,"workbenchRefreshStartedAtMs",null);at(this,"connectionManager");this.options=t,this.workbenchKnownRevision=null,this.connectionManager=new Vx({onReconnect:n=>{this.connect(n)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}requestRefresh(){const t=this.socket;if(!_d(t)){this.pendingRefresh=!0;return}this.workbenchRefreshStartedAtMs=performance.now(),t.send(JSON.stringify({type:"workbench.refresh",knownRevision:this.workbenchKnownRevision??void 0})),un("workbench.refresh.sent",{knownRevision:this.workbenchKnownRevision}),this.pendingRefresh=!1}setWorkbenchKnownRevision(t){this.workbenchKnownRevision=Vn(t)}primeWorkbenchSnapshot(t){if(!t||!Array.isArray(t.items)){this.lastWorkbenchSnapshot=null,this.workbenchKnownRevision=null;return}this.lastWorkbenchSnapshot=t,this.workbenchKnownRevision=Vn(t.revision)??null}subscribeFileTree(t,n,r){this.fileTreeSubscription={workspaceId:t,paths:Dd(n),knownRevisionByPath:Bl(r==null?void 0:r.knownRevisionByPath)},this.sendWhenReady({type:"fileTree.subscribe",workspaceId:t,paths:this.fileTreeSubscription.paths,knownRevisions:Ol(t,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})}requestFileTreeRefresh(t,n,r){const i=Dd(n),a={type:"fileTree.refresh",workspaceId:t,paths:i,knownRevisions:Ol(t,i,Bl(r==null?void 0:r.knownRevisionByPath),this.fileTreeRevisionByPath)};this.sendWhenReady(a)?this.pendingFileTreeRefresh=null:this.pendingFileTreeRefresh={workspaceId:t,paths:i,knownRevisionByPath:Bl(r==null?void 0:r.knownRevisionByPath)}}subscribeGit(t,n){this.gitSubscription={workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"git.subscribe",workspaceId:t,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(t)})}requestGitRefresh(t,n){const r={type:"git.refresh",workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)??this.gitRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingGitRefresh=null:this.pendingGitRefresh={workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)}}subscribeTerminalManager(t,n){this.terminalManagerSubscription={workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"terminalManager.subscribe",workspaceId:t,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(t)})}requestTerminalManagerRefresh(t,n){const r={type:"terminalManager.refresh",workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)??this.terminalManagerRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingTerminalManagerRefresh=null:this.pendingTerminalManagerRefresh={workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)}}subscribeWorkspaceManagement(t,n){this.workspaceManagementSubscription={workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"workspaceManagement.subscribe",workspaceId:t,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(t)})}requestWorkspaceManagementRefresh(t,n){const r={type:"workspaceManagement.refresh",workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)??this.workspaceManagementRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingWorkspaceManagementRefresh=null:this.pendingWorkspaceManagementRefresh={workspaceId:t,knownRevision:Vn(n==null?void 0:n.knownRevision)}}addFileTreeSnapshotListener(t){return this.fileTreeListeners.add(t),()=>{this.fileTreeListeners.delete(t)}}addGitSnapshotListener(t){return this.gitListeners.add(t),()=>{this.gitListeners.delete(t)}}addTerminalManagerSnapshotListener(t){return this.terminalManagerListeners.add(t),()=>{this.terminalManagerListeners.delete(t)}}addWorkspaceManagementSnapshotListener(t){return this.workspaceManagementListeners.add(t),()=>{this.workspaceManagementListeners.delete(t)}}close(){var t;this.disposed=!0,this.connectionManager.close(),(t=this.socket)==null||t.close(),this.socket=null}connect(t){var u;if(this.disposed)return;t&&this.socket&&(this.socket.close(),this.socket=null);const n=(u=ca.getState().session)==null?void 0:u.accessToken;if(!n){this.options.onUnauthorized();return}const r=pu(),i=Of(r),a=i.baseUrl,o=`${Vk("/ws",a)}?access_token=${encodeURIComponent(n)}`,c=i.transport.createWebSocket({path:"/ws",baseUrl:a,url:o});this.socket=c,c.addEventListener("open",()=>{this.workbenchSubscribeStartedAtMs=performance.now(),c.send(JSON.stringify({type:"workbench.subscribe",knownRevision:this.workbenchKnownRevision??void 0})),un("workbench.subscribe.sent",{knownRevision:this.workbenchKnownRevision,baseUrl:a}),this.pendingRefresh&&this.requestRefresh(),this.fileTreeSubscription&&c.send(JSON.stringify({type:"fileTree.subscribe",workspaceId:this.fileTreeSubscription.workspaceId,paths:this.fileTreeSubscription.paths,knownRevisions:Ol(this.fileTreeSubscription.workspaceId,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})),this.pendingFileTreeRefresh&&this.requestFileTreeRefresh(this.pendingFileTreeRefresh.workspaceId,this.pendingFileTreeRefresh.paths,{knownRevisionByPath:this.pendingFileTreeRefresh.knownRevisionByPath}),this.gitSubscription&&c.send(JSON.stringify({type:"git.subscribe",workspaceId:this.gitSubscription.workspaceId,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(this.gitSubscription.workspaceId)})),this.pendingGitRefresh&&this.requestGitRefresh(this.pendingGitRefresh.workspaceId,{knownRevision:this.pendingGitRefresh.knownRevision}),this.terminalManagerSubscription&&c.send(JSON.stringify({type:"terminalManager.subscribe",workspaceId:this.terminalManagerSubscription.workspaceId,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(this.terminalManagerSubscription.workspaceId)})),this.pendingTerminalManagerRefresh&&this.requestTerminalManagerRefresh(this.pendingTerminalManagerRefresh.workspaceId,{knownRevision:this.pendingTerminalManagerRefresh.knownRevision}),this.workspaceManagementSubscription&&c.send(JSON.stringify({type:"workspaceManagement.subscribe",workspaceId:this.workspaceManagementSubscription.workspaceId,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(this.workspaceManagementSubscription.workspaceId)})),this.pendingWorkspaceManagementRefresh&&this.requestWorkspaceManagementRefresh(this.pendingWorkspaceManagementRefresh.workspaceId,{knownRevision:this.pendingWorkspaceManagementRefresh.knownRevision})}),c.addEventListener("message",d=>{var p,g,m,y,S,j,x,A,T,F;if(!(d instanceof MessageEvent)||typeof d.data!="string")return;const h=JSON.parse(d.data);if(h.type==="system.connected"){this.connectionManager.markConnected();return}if(h.type==="session.error"){h.error_code==="UNAUTHORIZED"&&this.handleUnauthorized();return}if(h.type==="workbench.snapshot"&&(un("workbench.snapshot.received",{unchanged:h.unchanged,revision:h.revision,workspaceCount:((p=h.snapshot)==null?void 0:p.items.length)??0,sessionCount:h.snapshot?Jx(h.snapshot):0,subscribeDurationMs:qa(this.workbenchSubscribeStartedAtMs),refreshDurationMs:qa(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null),h.type==="workbench.delta"){un("workbench.delta.received",{baseRevision:h.baseRevision,revision:h.revision,changedWorkspaceCount:h.changedItems.length,removedWorkspaceCount:h.removedWorkspaceIds.length,subscribeDurationMs:qa(this.workbenchSubscribeStartedAtMs),refreshDurationMs:qa(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null;const R=Xx(this.lastWorkbenchSnapshot,h);if(!R){un("workbench.delta.mismatch",{currentRevision:((g=this.lastWorkbenchSnapshot)==null?void 0:g.revision)??null,baseRevision:h.baseRevision,revision:h.revision}),this.workbenchKnownRevision=null,this.lastWorkbenchSnapshot=null,this.connectionManager.reconnectNow();return}this.lastWorkbenchSnapshot=R,this.workbenchKnownRevision=h.revision,this.options.onSnapshot(R);return}if(h.type==="fileTree.snapshot"){const R=h.snapshot;if(R)R.revision=h.revision,this.fileTreeRevisionByPath.set(Pc(R.workspaceId,R.path),h.revision);else if(h.unchanged&&this.fileTreeSubscription)for(const I of this.fileTreeSubscription.paths)this.fileTreeRevisionByPath.set(Pc(this.fileTreeSubscription.workspaceId,I),h.revision);if(!R)return;(y=(m=this.options).onFileTreeSnapshot)==null||y.call(m,R),this.fileTreeListeners.forEach(I=>I(R));return}if(h.type==="git.snapshot"){const R=h.snapshot;if(R?(R.revision=h.revision,this.gitRevisionByWorkspaceId.set(R.workspaceId,h.revision)):h.unchanged&&this.gitSubscription&&this.gitRevisionByWorkspaceId.set(this.gitSubscription.workspaceId,h.revision),!R)return;(j=(S=this.options).onGitSnapshot)==null||j.call(S,R),this.gitListeners.forEach(I=>I(R));return}if(h.type==="terminalManager.snapshot"){const R=h.snapshot;if(R?(R.revision=h.revision,this.terminalManagerRevisionByWorkspaceId.set(R.workspaceId,h.revision)):h.unchanged&&this.terminalManagerSubscription&&this.terminalManagerRevisionByWorkspaceId.set(this.terminalManagerSubscription.workspaceId,h.revision),!R)return;(A=(x=this.options).onTerminalManagerSnapshot)==null||A.call(x,R),this.terminalManagerListeners.forEach(I=>I(R));return}if(h.type==="workspaceManagement.snapshot"){const R=h.snapshot;if(R?(R.revision=h.revision,this.workspaceManagementRevisionByWorkspaceId.set(R.workspaceId,h.revision)):h.unchanged&&this.workspaceManagementSubscription&&this.workspaceManagementRevisionByWorkspaceId.set(this.workspaceManagementSubscription.workspaceId,h.revision),!R)return;(F=(T=this.options).onWorkspaceManagementSnapshot)==null||F.call(T,R),this.workspaceManagementListeners.forEach(I=>I(R));return}h.type==="workbench.snapshot"&&h.snapshot&&Yx(h.snapshot)?(h.snapshot.revision=h.revision,this.lastWorkbenchSnapshot=h.snapshot,this.workbenchKnownRevision=h.revision,this.options.onSnapshot(h.snapshot)):h.type==="workbench.snapshot"&&h.unchanged&&(this.workbenchKnownRevision=h.revision,this.lastWorkbenchSnapshot&&(this.lastWorkbenchSnapshot={...this.lastWorkbenchSnapshot,revision:h.revision}))}),c.addEventListener("close",()=>{this.disposed||this.socket!==c||this.connectionManager.markDisconnected()}),c.addEventListener("error",()=>{this.disposed||this.socket!==c||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const t=this.socket;this.socket=null,t==null||t.close(),ca.refresh().then(n=>{if(this.authRecoveryInFlight=!1,!this.disposed){if(n.status==="refreshed"){this.connectionManager.reconnectNow();return}if(n.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendWhenReady(t){const n=this.socket;return _d(n)?(n.send(JSON.stringify(t)),!0):!1}}function _d(e){return e!==null&&e.readyState===1}function Yx(e){return typeof e!="object"||e===null?!1:Array.isArray(e.items)}function Dd(e){const t=new Set;for(const n of e??[""])t.add(n.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""));return[...t]}function Vn(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function Xx(e,t){if(!e||e.revision!==t.baseRevision)return null;const n=new Map(e.items.map(i=>[i.workspace.id,i]));for(const i of t.removedWorkspaceIds)n.delete(i);for(const i of t.changedItems)n.set(i.workspace.id,i);const r=[];for(const i of t.orderedWorkspaceIds){const a=n.get(i);if(!a)return null;r.push(a)}return{revision:t.revision,items:r}}function Bl(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),Vn(n)]).filter(t=>t[1]!==null)):{}}function Ol(e,t,n,r){const i=t.map(a=>{const o=a.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return[o,n[o]??r.get(Pc(e,o))??null]}).filter(a=>!!a[1]);if(i.length!==0)return Object.fromEntries(i)}function Pc(e,t){return`${e}::${t}`}function Jx(e){return e.items.reduce((t,n)=>t+n.sessions.length+Sm(n.childWorktrees??[]),0)}function Sm(e){return e.reduce((t,n)=>{if(typeof n!="object"||n===null)return t;const r=n,i=Array.isArray(r.sessions)?r.sessions.length:0,a=Array.isArray(r.children)?Sm(r.children):0;return t+i+a},0)}function qa(e){return e===null||typeof performance>"u"?null:Math.round(performance.now()-e)}const Bd=6,Qx=["button","a","input","textarea","select","summary","[role='button']","[role='link']","[role='tab']","[role='menuitem']","[contenteditable='true']","[data-window-drag='ignore']"].join(", ");function Zx(e){return e instanceof HTMLElement?!e.closest(Qx):!0}function Ac(e,t,n){return e.isDesktop&&e.ui.osFamily==="macos"&&t===0&&Zx(n)}function Cm(e){return e.isDesktop&&e.ui.osFamily==="macos"&&e.ui.prefersOverlayTitlebar}function Nm(e){return Cm(e)?"":void 0}function ew(e){if(!Ac(e.platform,e.button,e.target)||typeof window>"u")return;const t=e.clientX,n=e.clientY;let r=!0;const i=()=>{r&&(r=!1,window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",o),window.removeEventListener("blur",c))},a=u=>{Math.abs(u.clientX-t)<Bd&&Math.abs(u.clientY-n)<Bd||(i(),tw())},o=()=>{i()},c=()=>{i()};window.addEventListener("mousemove",a),window.addEventListener("mouseup",o),window.addEventListener("blur",c)}async function tw(){typeof window>"u"||typeof window.__TAURI_INTERNALS__>"u"||await Yf().startDragging()}const _o=.78,nw=1;function rw(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function jm(e,t,n,r){const i=Math.hypot(n-e,r-t),a=Math.min(1,i/120);return _o+(nw-_o)*a}function is(e){return Math.round(Number.isFinite(e)?e:0)}function sw(e){if(!rw())return null;const t=is(e.x),n=is(e.y);let r=!1,i=Promise.resolve();const a=(c,u)=>(i=i.then(async()=>{await window.__TAURI_INTERNALS__.invoke(c,u)}).catch(()=>{}),i),o=async()=>{r||(r=!0,await a("close_detach_preview"))};return a("show_detach_preview",{title:e.title,x:t,y:n,scale:_o}),{updatePosition(c,u){if(r)return;const d=is(c),h=is(u);a("update_detach_preview_position",{x:d,y:h,scale:jm(t,n,d,h)})},complete(){return o()},cancel(){return o()}}}function iw(e){if(typeof document>"u")return null;const t=is(e.x),n=is(e.y),r=document.createElement("div");r.className="desktop-window-detach-animation",r.setAttribute("aria-hidden","true"),r.dataset.state="preview",r.style.left=`${t}px`,r.style.top=`${n}px`,r.style.setProperty("--detach-preview-scale",_o.toFixed(3));const i=document.createElement("div");i.className="desktop-window-detach-animation-bar";const a=document.createElement("strong");a.className="desktop-window-detach-animation-title",a.textContent=e.title;const o=document.createElement("div");o.className="desktop-window-detach-animation-body",i.append(a),r.append(i,o),document.body.append(r);let c=!1;const u=()=>{c||(c=!0,r.remove())};return{updatePosition(d,h){if(c)return;const p=is(d),g=is(h),m=jm(t,n,p,g);r.style.left=`${p}px`,r.style.top=`${g}px`,r.style.setProperty("--detach-preview-scale",m.toFixed(3))},async complete(){u()},async cancel(){u()}}}function Od(e){return sw(e)??iw(e)}const aw={files:{kind:"files",label:"文件",defaultFocusOwner:"file-context-panel"},git:{kind:"git",label:"Git",defaultFocusOwner:"git-sidebar"},processes:{kind:"processes",label:"调试",defaultFocusOwner:"terminal-manager-panel"},terminals:{kind:"terminals",label:"终端",defaultFocusOwner:"terminal-page"}};function ow(e){return{...e,bounds:{...e.bounds}}}function lw(e,t,n){t&&(e.windows.registerDescriptor(t),n?e.windows.markWindowOpen(t.windowId):e.windows.markWindowClosed(t.windowId))}function cw(e){return aw[e]}function Tm(e,t){return`${e}-${t}`}async function rl(e,t,n){const r=n.workspaceId.trim(),i=cw(t);if(!e.isDesktop||!e.bridge.supported)return{ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前运行环境不支持桌面外部窗口。"};if(!r)return{ok:!1,errorCode:"WINDOW_WORKSPACE_REQUIRED",detail:`${i.label}外部窗口必须绑定工作区。`};const a=Tm(t,r),o=e.windows.getDescriptor(a),c=o?ow(o):null,u=e.windows.isWindowOpen(a),d=Kk({windowId:a,kind:t,workspaceId:r,workspaceName:n.workspaceName??(c==null?void 0:c.workspaceName)??null,sessionId:n.sessionId??(c==null?void 0:c.sessionId)??null,mode:"external",bounds:c==null?void 0:c.bounds,focusOwner:n.focusOwner??i.defaultFocusOwner});e.windows.registerDescriptor(d);const h=await e.bridge.createWindow(d);return h.ok?(e.windows.markWindowOpen(a),{ok:!0,value:d}):(c?lw(e,c,u):e.windows.removeWindow(a),{ok:!1,errorCode:h.errorCode,detail:h.detail})}function NL(e){return Tm("terminals",e)}function uw(e,t){return rl(e,"files",t)}function dw(e,t){return rl(e,"git",t)}function hw(e,t){return rl(e,"processes",t)}function jL(e,t){return rl(e,"terminals",t)}async function Wd(){return await pe.request("/api/skills/overview")}async function pw(e){var n;const t=new URLSearchParams;return t.set("workspaceId",e.workspaceId),(n=e.sessionId)!=null&&n.trim()&&t.set("sessionId",e.sessionId.trim()),await pe.request(`/api/skills/workspace-session-mcp-status?${t.toString()}`)}async function fw(e){await pe.request("/api/skills",{method:"POST",body:JSON.stringify(e)})}async function mw(e){await pe.request("/api/skills/import",{method:"POST",body:JSON.stringify(e)})}async function gw(e){await pe.request("/api/skills/sync",{method:"POST",body:JSON.stringify(e)})}function Fd(e){if(e.executionBackend==="opencli_bridge"||e.executionBackend==="playwright")return e.executionBackend;try{return JSON.parse(e.inputJson).executionBackend==="opencli_bridge"?"opencli_bridge":"playwright"}catch{return"playwright"}}async function $d(e="active"){const t=new URLSearchParams({status:e});return(await pe.request(`/api/office/document-templates?${t.toString()}`)).items}async function zd(e={}){var i;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim());const n=t.size>0?`?${t.toString()}`:"";return(await pe.request(`/api/office/browser/profiles${n}`)).items}async function bw(e){return await pe.request("/api/office/browser/profiles",{method:"POST",body:JSON.stringify(e)})}async function kw(e,t){return await pe.request(`/api/office/browser/profiles/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}async function yw(e){return await pe.request(`/api/office/browser/profiles/${encodeURIComponent(e)}`,{method:"DELETE"})}async function xw(e){return await pe.request("/api/office/document-templates/import-file",{method:"POST",body:JSON.stringify(e)})}async function Ga(e){var i;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),e.taskType&&t.set("taskType",e.taskType),e.status&&t.set("status",e.status),e.riskLevel&&t.set("riskLevel",e.riskLevel),typeof e.limit=="number"&&Number.isFinite(e.limit)&&t.set("limit",String(Math.trunc(e.limit)));const n=t.size>0?`?${t.toString()}`:"";return(await pe.request(`/api/office/tasks${n}`)).items}async function Wl(e){return await pe.request(`/api/office/tasks/${encodeURIComponent(e)}`)}async function ww(e){return await pe.request(`/api/office/browser/tasks/${encodeURIComponent(e)}/execute`,{method:"POST"})}async function Lc(e){return(await pe.request(`/api/office/browser/tasks/${encodeURIComponent(e)}/execution`)).task}async function Hd(){return await pe.request("/api/office/browser/bridge-status")}async function vw(e){return await pe.request(`/api/office/browser/tasks/${encodeURIComponent(e)}/execution/cancel`,{method:"POST"})}async function Sw(e,t){await pe.request(`/api/office/approvals/${encodeURIComponent(e)}/reply`,{method:"POST",body:JSON.stringify(t)})}async function Ud(e){var i;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),e.kind&&t.set("kind",e.kind),e.status&&t.set("status",e.status);const n=t.size>0?`?${t.toString()}`:"";return(await pe.request(`/api/office/ops/targets${n}`)).items}async function Cw(e){return await pe.request("/api/office/ops/targets",{method:"POST",body:JSON.stringify(e)})}async function Nw(e,t){return await pe.request(`/api/office/ops/targets/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}async function jw(){return await pe.request("/api/opencli/catalog")}async function qd(){return await pe.request("/api/opencli/check",{method:"POST"})}async function Tw(e){return await pe.request("/api/opencli/config",{method:"POST",body:JSON.stringify(e)})}const Fl="all",$l="status";function Iw({toolbarMode:e="internal",onToolbarStateChange:t}={}){var He,Ue,je,Te;const n=fu(O=>{var q;return((q=O.session)==null?void 0:q.accessToken)??null}),[r,i]=f.useState(null),[a,o]=f.useState(!1),[c,u]=f.useState(!1),[d,h]=f.useState(!1),[p,g]=f.useState(!1),[m,y]=f.useState([]),[S,j]=f.useState(null),[x,A]=f.useState(null),[T,F]=f.useState(Fl),[R,I]=f.useState(null),[G,z]=f.useState(!1),[L,E]=f.useState(""),[H,B]=f.useState($l);f.useEffect(()=>{let O=!0;if(!n){i(null),g(!1),y([]),A(null),j(null),o(!1),F(Fl),I(null),z(!1),E(""),B($l);return}return(async()=>{o(!0),A(null),j(null);try{const J=await qd();if(!O)return;N(J)}catch(J){if(!O)return;const Ce=Ka(J);try{const Ee=await jw();if(!O)return;N(Ee),A(Ce)}catch(Ee){if(!O)return;A(Ka(Ee))}}finally{O&&o(!1)}})(),()=>{O=!1}},[n]);const oe=f.useMemo(()=>new Set(m),[m]),K=f.useMemo(()=>Rw((r==null?void 0:r.entries)??[]),[r==null?void 0:r.entries]),X=f.useMemo(()=>_w(),[]);f.useEffect(()=>{K.some(O=>O.id===T)||F(Fl)},[T,K]);const Y=f.useMemo(()=>((r==null?void 0:r.siteGroups)??[]).filter(O=>O.commands.some(q=>Gd(q,T,oe))),[T,r==null?void 0:r.siteGroups,oe]),D=f.useMemo(()=>R?Y.find(O=>O.site===R)??null:null,[R,Y]);f.useEffect(()=>{R&&!D&&I(null)},[R,D]),f.useEffect(()=>{E(""),B($l)},[R]);const V=f.useMemo(()=>{if(!D)return[];const O=L.trim().toLowerCase();return D.commands.filter(q=>Gd(q,T,oe)&&Aw(q,O)).sort((q,J)=>Lw(q,J,{sortId:H,selectedCommandIdSet:oe}))},[T,D,L,H,oe]),le=!!(r&&(r.provider.enabled!==p||r.entries.some(O=>O.enabled!==oe.has(O.commandId)))),C=f.useMemo(()=>({draftEnabled:p,enableDisabled:a||c||d,refreshDisabled:!n||a||c||d,detailDisabled:!r||a,saveDisabled:!n||a||c||d||!r||!le,refreshing:c,saving:d,onEnabledChange:be,onRefresh:()=>{_e()},onShowDetails:()=>z(!0),onSave:()=>{Z()}}),[n,r,m,p,le,a,c,d]);f.useEffect(()=>{t==null||t(C)},[t,C]),f.useEffect(()=>()=>{t==null||t(null)},[t]);async function _e(){if(n){u(!0),A(null),j(null);try{const O=await qd();N(O),j(Hw(O.refreshState,O.runtimeAvailability))}catch(O){A(Ka(O))}finally{u(!1)}}}async function Z(){if(n){h(!0),A(null),j(null);try{const O=await Tw({enabled:p,enabledCommandIds:m});N(O),j(Uw(O))}catch(O){A(Ka(O))}finally{h(!1)}}}function N(O){i(O),g(O.provider.enabled),y(O.entries.filter(q=>q.enabled).map(q=>q.commandId).sort((q,J)=>q.localeCompare(J))),A(null)}function be(O){g(O)}function ne(O,q){const J=O.commands.map(Ce=>Ce.commandId);y(Ce=>{const Ee=new Set(Ce);for(const ve of J)q?Ee.add(ve):Ee.delete(ve);return[...Ee].sort((ve,Tt)=>ve.localeCompare(Tt))})}function fe(O,q){y(J=>{const Ce=new Set(J);return q?Ce.add(O):Ce.delete(O),[...Ce].sort((Ee,ve)=>Ee.localeCompare(ve))})}const ue=(r==null?void 0:r.summary)??{catalogCount:0,browserDependentCount:0,installState:"not_installed"};return s.jsxs("section",{className:"settings-opencli-panel settings-skill-section",children:[e==="internal"?s.jsx(Ew,{state:C,className:"settings-opencli-inline-toolbar"}):null,s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(Va,{label:l("settings.opencliSummaryInstallState"),value:Yd(ue.installState)}),s.jsx(Va,{label:l("settings.opencliSummaryCatalogCount"),value:String(ue.catalogCount)}),s.jsx(Va,{label:l("settings.opencliSummaryEnabledCount"),value:String(m.length)}),s.jsx(Va,{label:l("settings.opencliSummaryBrowserCount"),value:String(ue.browserDependentCount)})]}),S?s.jsx("p",{className:"settings-release-status",children:S}):null,x?s.jsx("p",{className:"settings-release-status",children:x}):null,a?s.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliLoading")}):r!=null&&r.siteGroups.length?s.jsxs("section",{className:"settings-opencli-catalog-section settings-skill-section",children:[s.jsx("div",{className:"settings-model-tabs settings-opencli-filter-tabs",role:"tablist","aria-label":l("settings.opencliFilterTabsLabel"),children:K.map(O=>{const q=T===O.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":q,"data-active":q?"true":"false",onClick:()=>F(O.id),children:O.label},O.id)})}),Y.length>0?s.jsx("div",{className:"settings-opencli-site-grid",children:Y.map(O=>{const q=Pw(O,oe),J=Dw(O.commands),Ce=Kd(O,{maxDescriptions:2}),Ee=Kd(O),ve=Em(O.site),Tt=R===O.site;return s.jsxs("div",{className:"settings-opencli-site-card","data-selected":Tt?"true":"false",children:[s.jsxs("div",{className:"settings-opencli-site-card-head",children:[s.jsx("div",{className:"settings-opencli-site-card-visual",style:ve.style,children:s.jsx("span",{children:ve.label})}),s.jsxs("div",{className:"settings-opencli-site-card-body",children:[s.jsxs("div",{className:"settings-opencli-site-card-topline",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:O.site}),s.jsxs("div",{className:"settings-opencli-site-card-actions",children:[s.jsx("button",{className:"ghost-button settings-opencli-site-detail-button",type:"button",onClick:()=>I(O.site),children:l("settings.opencliSiteViewAction")}),s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-site-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliSiteToggleLabel",{site:O.site}),type:"checkbox",checked:q.allSelected,disabled:c||d,ref:nt=>{nt&&(nt.indeterminate=q.partialSelected)},onChange:nt=>ne(O,nt.target.checked)}),s.jsx("span",{children:l("settings.opencliSiteEnableAction")})]})]})]}),s.jsx("p",{className:"settings-opencli-site-card-description",title:Ee,children:Ce})]})]}),s.jsx("div",{className:"settings-opencli-site-card-summary",children:s.jsx("div",{className:"settings-opencli-site-card-tag-rows",children:s.jsx("div",{className:"settings-skill-tags settings-opencli-site-card-tag-row settings-opencli-site-card-type-row",children:(J.length>0?J:["unknown"]).slice(0,2).map(nt=>s.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":Pm(nt),children:Mm(nt)},`${O.site}:${nt}`))})})})]},O.site)})}):s.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliFilteredEmpty")})]}):s.jsx("div",{className:"settings-skill-empty",children:qw(r)}),s.jsx(St,{open:G,title:l("settings.opencliDetailTitle"),className:"settings-opencli-detail-modal",onClose:()=>z(!1),children:r?s.jsxs(s.Fragment,{children:[s.jsx(Mn,{heading:l("settings.opencliDetailStatusHeading"),actions:s.jsxs("div",{className:"settings-opencli-detail-tags",children:[s.jsx($a,{children:Yd(r.provider.installState)}),s.jsx($a,{children:Ww(r.provider.healthState)}),s.jsx($a,{children:$w(((He=r.activeRuntimeProfile)==null?void 0:He.status)??null)})]}),children:s.jsxs(mi,{compact:!0,className:"settings-opencli-detail-list",children:[s.jsx(Jt,{label:l("settings.opencliEnabledStateLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:p?l("settings.opencliEnabledStateOn"):l("settings.opencliEnabledStateOff")})}),s.jsx(Jt,{label:l("settings.opencliSummaryCatalogCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(ue.catalogCount)})}),s.jsx(Jt,{label:l("settings.opencliSummaryEnabledCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(m.length)})}),s.jsx(Jt,{label:l("settings.opencliSummaryBrowserCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(ue.browserDependentCount)})}),s.jsx(Jt,{label:l("settings.opencliVersionLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:r.provider.version??"-"})}),s.jsx(Jt,{label:l("settings.opencliCatalogSourceLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Fw(r.effectiveCatalogSource??null)})}),s.jsx(Jt,{label:l("settings.opencliLastCheckedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Xd(r.provider.lastCheckedAt)})}),s.jsx(Jt,{label:l("settings.opencliCatalogRefreshedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Xd(r.provider.catalogRefreshedAt)})}),s.jsx(Jt,{label:l("settings.opencliInstallPathLabel"),description:r.provider.installPath??"-"}),s.jsx(Jt,{label:l("settings.opencliDetailRuntimeIdLabel"),description:r.provider.activeRuntimeId??"-"}),s.jsx(Jt,{label:l("settings.opencliDetailRuntimeRootLabel"),description:((Ue=r.activeRuntimeProfile)==null?void 0:Ue.runtimeRootPath)??"-"})]})}),r.provider.lastErrorDetail||(je=r.activeRuntimeProfile)!=null&&je.lastErrorDetail?s.jsx(Mn,{tone:"danger",heading:l("settings.opencliDetailErrorHeading"),children:s.jsxs("div",{className:"settings-opencli-detail-errors",children:[r.provider.lastErrorDetail?s.jsx("p",{className:"settings-skill-entry-meta",children:r.provider.lastErrorDetail}):null,(Te=r.activeRuntimeProfile)!=null&&Te.lastErrorDetail?s.jsx("p",{className:"settings-skill-entry-meta",children:r.activeRuntimeProfile.lastErrorDetail}):null]})}):null]}):null}),s.jsx(St,{open:D!==null,title:D?l("settings.opencliSiteDetailTitle",{site:D.site}):l("settings.opencliCommandModalFallbackTitle"),description:D?l("settings.opencliSiteDetailDescription",{count:V.length,total:D.totalCount}):void 0,className:"settings-opencli-command-modal",onClose:()=>I(null),children:D?s.jsxs("section",{className:"settings-skill-section",children:[s.jsx(Mn,{heading:l("settings.opencliSiteDescriptionHeading"),children:s.jsx("div",{className:"settings-opencli-site-detail-copy",children:Im(D.commands).map(O=>s.jsx("p",{className:"settings-opencli-site-detail-description",children:O},O))})}),s.jsx(Mn,{heading:l("settings.opencliCommandSearchLabel"),actions:s.jsx($a,{children:l("settings.opencliCommandResultCount",{count:V.length})}),children:s.jsxs("div",{className:"settings-opencli-command-tools",children:[s.jsxs("label",{className:"settings-opencli-command-search",htmlFor:"opencli-command-search",children:[s.jsx("span",{className:"settings-opencli-command-search-label",children:l("settings.opencliCommandSearchLabel")}),s.jsx("input",{id:"opencli-command-search",className:"settings-text-input",type:"search",value:L,placeholder:l("settings.opencliCommandSearchPlaceholder"),onChange:O=>E(O.target.value)})]}),s.jsxs("div",{className:"settings-opencli-command-sort",children:[s.jsx("span",{className:"settings-opencli-command-search-label",children:l("settings.opencliCommandSortLabel")}),s.jsx("div",{className:"settings-opencli-command-sort-tabs",role:"tablist","aria-label":l("settings.opencliCommandSortLabel"),children:X.map(O=>{const q=H===O.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab settings-opencli-command-sort-button","aria-selected":q,"data-active":q?"true":"false",onClick:()=>B(O.id),children:O.label},O.id)})})]})]})}),V.length>0?s.jsx("div",{className:"settings-opencli-command-grid",children:V.map(O=>s.jsx(Mw,{command:O,checked:oe.has(O.commandId),disabled:c||d,onToggle:fe},O.commandId))}):s.jsx(Ro,{compact:!0,title:l("settings.opencliCommandModalEmpty")})]}):null})]})}function Ew({state:e,className:t}){return s.jsxs("div",{className:`settings-opencli-toolbar${t?` ${t}`:""}`,children:[s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-toolbar-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliProviderToggleLabel"),type:"checkbox",checked:e.draftEnabled,disabled:e.enableDisabled,onChange:n=>e.onEnabledChange(n.target.checked)}),s.jsx("span",{children:l("settings.opencliEnableAction")})]}),s.jsx("button",{className:"secondary-button",type:"button",disabled:e.refreshDisabled,onClick:e.onRefresh,children:e.refreshing?l("common.loading"):l("settings.opencliRefreshAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:e.detailDisabled,onClick:e.onShowDetails,children:l("settings.opencliDetailAction")}),s.jsx("button",{className:"primary-button",type:"button",disabled:e.saveDisabled,onClick:e.onSave,children:e.saving?l("common.loading"):l("settings.opencliSaveAction")})]})}function Mw({command:e,checked:t,disabled:n,onToggle:r}){const i=Em(e.commandId);return s.jsxs("div",{className:"settings-opencli-command-card",children:[s.jsxs("div",{className:"settings-opencli-command-card-head",children:[s.jsx("div",{className:"settings-opencli-command-badge",style:i.style,children:s.jsx("span",{children:e.name.slice(0,1).toUpperCase()})}),s.jsxs("div",{className:"settings-opencli-command-card-main",children:[s.jsxs("label",{className:"settings-opencli-checkbox",children:[s.jsx("input",{"aria-label":l("settings.opencliCommandToggleLabel",{commandId:e.commandId}),type:"checkbox",checked:t,disabled:n,onChange:a=>r(e.commandId,a.target.checked)}),s.jsx("span",{children:e.commandId})]}),s.jsx("p",{className:"settings-skill-entry-meta",children:e.description||l("settings.opencliCommandDescriptionEmpty")})]})]}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":Pm(e.strategy),children:zw(e.strategy)}),e.browser?s.jsx("span",{className:"settings-skill-tag","data-status":"failed",children:l("settings.opencliBrowserTag")}):s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:l("settings.opencliHttpTag")})]})]})}function Va({label:e,value:t}){return s.jsxs("div",{className:"settings-skill-summary-card",children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t})]})}function Rw(e){const t=Array.from(new Set(e.map(n=>n.strategy.trim()).filter(n=>n.length>0&&n!=="unknown"))).sort((n,r)=>n.localeCompare(r));return[{id:"all",label:l("settings.opencliFilterAll")},{id:"enabled",label:l("settings.opencliFilterEnabled")},{id:"browser",label:l("settings.opencliFilterBrowser")},{id:"direct",label:l("settings.opencliFilterDirect")},...t.map(n=>({id:`strategy:${n}`,label:l("settings.opencliFilterStrategy",{strategy:Mm(n)})}))]}function Gd(e,t,n){switch(t){case"all":return!0;case"enabled":return n.has(e.commandId);case"browser":return e.browser;case"direct":return!e.browser;default:return t.startsWith("strategy:")?e.strategy===t.slice(9):!0}}function Pw(e,t){const n=e.commands.filter(r=>t.has(r.commandId)).length;return{selectedCount:n,allSelected:n>0&&n===e.commands.length,partialSelected:n>0&&n<e.commands.length}}function Aw(e,t){return t?[e.commandId,e.name,e.description,e.strategy].join(`
3
3
  `).toLowerCase().includes(t):!0}function Lw(e,t,n){const r=Vd(e,n)-Vd(t,n);if(r!==0)return r;const i=e.name.localeCompare(t.name);return i!==0?i:e.commandId.localeCompare(t.commandId)}function Vd(e,t){const n=t.selectedCommandIdSet.has(e.commandId)?0:1,r=e.browser?1:0;switch(t.sortId){case"browser":return(e.browser?0:2)+n;case"name":return 0;case"status":default:return n*2+r}}function _w(){return[{id:"status",label:l("settings.opencliCommandSortStatus")},{id:"browser",label:l("settings.opencliCommandSortBrowser")},{id:"name",label:l("settings.opencliCommandSortName")}]}function Im(e){return Array.from(new Set(e.map(t=>t.description.trim()).filter(t=>t.length>0)))}function Kd(e,t={}){const n=Im(e.commands);if(n.length===0)return l("settings.opencliSiteDescriptionEmpty");const r=t.maxDescriptions??n.length;return n.slice(0,r).join(" · ")}function Dw(e){return Array.from(new Set(e.map(t=>t.strategy.trim()).filter(t=>t.length>0&&t!=="unknown"))).sort((t,n)=>t.localeCompare(n))}function Em(e){const t=Gw[e.toLowerCase()];if(t)return{label:t.label,style:{background:t.background}};const n=Jd[Math.abs(Ow(e))%Jd.length];return{label:Bw(e),style:{background:`linear-gradient(135deg, ${n[0]} 0%, ${n[1]} 100%)`}}}function Bw(e){const t=e.split(/[^a-z0-9]+/i).map(r=>r.trim()).filter(r=>r.length>0);if(t.length>=2)return`${t[0][0]??""}${t[1][0]??""}`.toUpperCase();const n=t[0]??e;return n.slice(0,Math.min(2,n.length)).toUpperCase()}function Ow(e){let t=0;for(const n of e)t=(t<<5)-t+n.charCodeAt(0),t|=0;return t}function Ka(e){return e instanceof mu?e.message||l("settings.opencliLoadFailed"):e instanceof Error?e.message:l("settings.opencliLoadFailed")}function Yd(e){switch(e){case"installed":return l("settings.opencliInstallInstalled");case"broken":return l("settings.opencliInstallBroken");default:return l("settings.opencliInstallMissing")}}function Ww(e){switch(e){case"ready":return l("settings.opencliHealthReady");case"bridge_missing":return l("settings.opencliHealthBridgeMissing");case"binary_ready":return l("settings.opencliHealthBinaryReady");case"runtime_build_failed":return l("settings.opencliHealthRuntimeBuildFailed");default:return l("settings.opencliHealthUnknown")}}function Fw(e){switch(e){case"manifest":return l("settings.opencliCatalogSourceManifest");case"cli_list":return l("settings.opencliCatalogSourceCliList");case"local_manifest":return l("settings.opencliCatalogSourceLocalManifest");case"cache":return l("settings.opencliCatalogSourceCache");default:return"-"}}function $w(e){switch(e){case"ready":return l("settings.opencliRuntimeReady");case"failed":return l("settings.opencliRuntimeFailed");case"pending":return l("settings.opencliRuntimePending");case"stale":return l("settings.opencliRuntimeStale");default:return l("settings.opencliRuntimeIdle")}}function zw(e){return l("settings.opencliStrategyLabel",{strategy:Rm(e)})}function Mm(e){return l("settings.opencliStrategyShortLabel",{strategy:Rm(e)})}function Rm(e){switch(Am(e)){case"cookie":return l("settings.opencliStrategyCookie");case"header":return l("settings.opencliStrategyHeader");case"intercept":return l("settings.opencliStrategyIntercept");case"local":return l("settings.opencliStrategyLocal");case"public":return l("settings.opencliStrategyPublic");case"ui":return l("settings.opencliStrategyUi");default:return l("settings.opencliStrategyUnknown")}}function Pm(e){return Am(e)}function Am(e){const t=e.trim().toLowerCase();return t.length>0?t:"unknown"}function Hw(e,t){return e==="cache_retained"?l("settings.opencliRefreshCacheRetained"):e==="unavailable"?l("settings.opencliRefreshUnavailable"):t==="ready"?l("settings.opencliRefreshReady"):l("settings.opencliRefreshDone")}function Uw(e){return e.runtimeAvailability==="ready"?l("settings.opencliSaveReady"):e.provider.enabled?l("settings.opencliSaveEnabled"):l("settings.opencliSaveDisabled")}function qw(e){return e?e.provider.installState!=="installed"?l("settings.opencliEmptyNotInstalled"):l("settings.opencliEmpty"):l("settings.opencliEmpty")}function Xd(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}const Jd=[["#2563eb","#0ea5e9"],["#0f766e","#14b8a6"],["#7c3aed","#6366f1"],["#ea580c","#f59e0b"],["#be123c","#f43f5e"],["#1d4ed8","#38bdf8"]],Gw={github:{label:"GH",background:"linear-gradient(135deg, #111827 0%, #374151 100%)"},hackernews:{label:"HN",background:"linear-gradient(135deg, #f97316 0%, #fb923c 100%)"},twitter:{label:"TW",background:"linear-gradient(135deg, #2563eb 0%, #38bdf8 100%)"},x:{label:"X",background:"linear-gradient(135deg, #111827 0%, #6b7280 100%)"},reddit:{label:"RD",background:"linear-gradient(135deg, #f97316 0%, #ef4444 100%)"}},Vw=[{id:"skills"},{id:"office"},{id:"ops"},{id:"opencli"}];function Kw({triggerClassName:e="secondary-button",triggerLabel:t,triggerLeading:n,workspaceId:r=null,sessionId:i=null}){const a=fu(w=>{var U;return((U=w.session)==null?void 0:U.accessToken)??null}),o=f.useRef(null),c=f.useRef(null),[u,d]=f.useState(null),[h,p]=f.useState([]),[g,m]=f.useState([]),[y,S]=f.useState([]),[j,x]=f.useState({}),[A,T]=f.useState(null),[F,R]=f.useState([]),[I,G]=f.useState([]),[z,L]=f.useState([]),[E,H]=f.useState(null),[B,oe]=f.useState(null),[K,X]=f.useState(null),[Y,D]=f.useState(null),[V,le]=f.useState(null),[C,_e]=f.useState(!1),[Z,N]=f.useState(null),[be,ne]=f.useState(null),[fe,ue]=f.useState(null),[He,Ue]=f.useState(!1),[je,Te]=f.useState(!1),[O,q]=f.useState(!1),[J,Ce]=f.useState(!1),[Ee,ve]=f.useState(!1),[Tt,nt]=f.useState(!1),[mt,ae]=f.useState(!1),[se,ke]=f.useState(!1),[ye,Me]=f.useState(!1),[$,Q]=f.useState(!1),[ge,Ne]=f.useState(null),[Be,Ke]=f.useState(!1),Ie=(ge==null?void 0:ge.simplified)??null,[ut,Qe]=f.useState(null),[rt,st]=f.useState("file"),[qe,gt]=f.useState("workspace"),[Ht,Ye]=f.useState(""),[dt,De]=f.useState(()=>zi("workspace")),[bt,Ze]=f.useState("skills"),[_t,_]=f.useState(null),[de,Re]=f.useState("all"),[xe,Se]=f.useState("ssh_host"),[ht,Bt]=f.useState({fileName:"",fileContentBase64:""}),[ft,Ot]=f.useState({displayName:"",engine:"chrome",mode:"persistent",ownershipScope:r!=null&&r.trim()?"workspace":"user",cdpEndpoint:""}),[et,ct]=f.useState({targetId:null,displayName:"",environment:"",host:"",port:"22",username:"",privateKeyPath:"",knownHostsPath:"",jumpHost:"",workspacePath:"",credentialRef:"",strictHostKeyChecking:"accept-new",status:"active"}),Ut=f.useId(),Ur=iy(He&&!!a).items??[],kt=f.useMemo(()=>bv(Ur),[Ur]),us=f.useMemo(()=>new Map(F.map(w=>[w.id,w])),[F]),gn=f.useMemo(()=>!ye||!(r!=null&&r.trim())?g:g.filter(w=>w.workspaceId===r),[g,ye,r]),cr=f.useMemo(()=>K?y.filter(w=>w.targetRefId===K.id):[],[y,K]);f.useEffect(()=>{let w=!0;if(!He)return;if(!a){d(null),ne(null),ue(null),_e(!1);return}return(async()=>{_e(!0);try{const[Pe,Xe,Cn,Lr,Yr,Nn,kn]=await Promise.all([Wd(),$d("active"),zd(),Ga({taskType:"browser",limit:100}),bd(),Ga({workspaceId:r,taskType:"ops",limit:20}),Ud({workspaceId:r,kind:"ssh_host"})]);if(!w)return;const kr=await oh(Lr),Je=await Hd().catch(()=>null);d(Pe),p(Xe),m(Cn),S(Lr),T(Je),x(kr),R(Yr.items),G(Nn),L(kn),X(null),D(null),le(null),ne(null)}catch(Pe){if(!w)return;ne(Xt(Pe))}finally{w&&_e(!1)}})(),()=>{w=!1}},[a,He,r]);async function Qt(){const[w,U,Pe,Xe,Cn,Lr,Yr]=await Promise.all([Wd(),$d("active"),zd(),Ga({taskType:"browser",limit:100}),bd(),Ga({workspaceId:r,taskType:"ops",status:de==="all"?void 0:de,limit:20}),Ud({workspaceId:r,kind:xe==="all"?void 0:xe})]),Nn=await oh(Xe),kn=await Hd().catch(()=>null);d(w),p(U),m(Pe),S(Xe),T(kn),x(Nn),R(Cn.items),G(Lr),L(Yr),ne(null)}async function Yn(){if(a){N("refresh"),ne(null),ue(null);try{await Qt(),ue(l("settings.skillRefreshSuccess"))}catch(w){ne(Xt(w))}finally{N(null)}}}async function Zt(){if(a){N("office-template-submit"),ne(null),ue(null);try{await xw({fileName:ht.fileName,fileContentBase64:ht.fileContentBase64}),Bt(Ja()),q(!1),ue(l("settings.skillOfficeTemplateImported")),await Qt()}catch(w){ne(Xt(w))}finally{N(null)}}}async function en(){if(a){N("browser-profile-submit"),ne(null),ue(null);try{await bw({workspaceId:r,displayName:ft.displayName.trim()||null,engine:ft.engine,mode:ft.mode,ownershipScope:ft.ownershipScope,cdpEndpoint:ft.mode==="cdp_attached"&&ft.cdpEndpoint.trim()||null}),Ot(Xa(r)),Ce(!1),ue(l("settings.skillOfficeBrowserProfileCreated")),await Qt()}catch(w){ne(Xt(w))}finally{N(null)}}}async function vn(w){var Pe;if(!a)return;const U=w.ownershipScope==="user"?"workspace":"user";if(U==="workspace"&&!((Pe=w.workspaceId)!=null&&Pe.trim())){ne(l("settings.skillOfficeBrowserProfileWorkspaceRequired"));return}N(`browser-profile-scope:${w.id}`),ne(null),ue(null);try{await kw(w.id,{ownershipScope:U}),await Qt(),ue(U==="user"?l("settings.skillOfficeBrowserProfileCrossWorkspaceEnabled"):l("settings.skillOfficeBrowserProfileWorkspaceOnlyEnabled"))}catch(Xe){ne(Xt(Xe))}finally{N(null)}}function Bs(w){H(w),ve(!0),ne(null)}function Vt(w){oe(w),nt(!0),ne(null)}async function Sn(){if(!a)return;const w=B;if(w){N(`browser-profile-delete:${w.id}`),ne(null),ue(null);try{await yw(w.id),(K==null?void 0:K.id)===w.id&&(ke(!1),X(null),D(null)),(E==null?void 0:E.id)===w.id&&(ve(!1),H(null)),nt(!1),oe(null),await Qt(),ue(l("settings.skillOfficeBrowserProfileDeleted"))}catch(U){ne(Xt(U))}finally{N(null)}}}async function yt(w){if(a){N(`browser-profile-tasks:${w.id}`),ne(null);try{X(w),D(null),ke(!0)}catch(U){ne(Xt(U))}finally{N(null)}}}async function Mr(w){if(a){N(`browser-task-detail:${w}`),ne(null);try{const[U,Pe]=await Promise.all([Wl(w),Lc(w)]);D(U),x(Xe=>({...Xe,[w]:Pe}))}catch(U){ne(Xt(U))}finally{N(null)}}}async function ur(w){if(a){N(`browser-task-execute:${w}`),ne(null),ue(null);try{await ww(w),await An(w),ue(l("settings.skillOfficeBrowserInstanceStarted"))}catch(U){ne(Xt(U))}finally{N(null)}}}async function dr(w){if(a){N(`browser-task-cancel:${w}`),ne(null),ue(null);try{await vw(w),await An(w),ue(l("settings.skillOfficeBrowserInstanceCancelled"))}catch(U){ne(Xt(U))}finally{N(null)}}}async function bn(w){if(a){N(`ops-task-detail:${w}`),ne(null);try{const U=await Wl(w);le(U)}catch(U){ne(Xt(U))}finally{N(null)}}}async function qr(w,U){if(a){N(`ops-approval:${w}:${U}`),ne(null);try{if(await Sw(w,{status:U,decisionNote:U==="approved"?l("settings.skillOpsApprovalApproveNote"):l("settings.skillOpsApprovalRejectNote")}),V){const Pe=await Wl(V.task.id);le(Pe)}await Qt(),ue(U==="approved"?l("settings.skillOpsApprovalApproved"):l("settings.skillOpsApprovalRejected"))}catch(Pe){ne(Xt(Pe))}finally{N(null)}}}async function Rr(){if(a){N("ops-target-submit"),ne(null),ue(null);try{const w={workspaceId:r,kind:"ssh_host",displayName:et.displayName.trim(),environment:et.environment.trim()||null,credentialRef:et.credentialRef.trim()||null,status:et.status,config:{host:et.host.trim(),port:Number.parseInt(et.port,10)||22,username:et.username.trim(),privateKeyPath:et.privateKeyPath.trim()||void 0,knownHostsPath:et.knownHostsPath.trim()||void 0,jumpHost:et.jumpHost.trim()||void 0,workspacePath:et.workspacePath.trim()||void 0,strictHostKeyChecking:et.strictHostKeyChecking}};et.targetId?(await Nw(et.targetId,w),ue(l("settings.skillOpsTargetUpdated"))):(await Cw(w),ue(l("settings.skillOpsTargetCreated"))),ct(Ya()),ae(!1),await Qt()}catch(w){ne(Xt(w))}finally{N(null)}}}async function hr(){if(!(!a||!(r!=null&&r.trim()))){Q(!0),Ke(!0),ne(null);try{const w=await pw({workspaceId:r,sessionId:i});Ne(w)}catch(w){ne(Xt(w)),Ne(null)}finally{Ke(!1)}}}function pr(w){const U=Lm(w.configJson);ct({targetId:w.id,displayName:w.displayName,environment:w.environment??"",host:rs(U.host),port:_m(U.port,22),username:rs(U.username),privateKeyPath:rs(U.privateKeyPath),knownHostsPath:rs(U.knownHostsPath),jumpHost:rs(U.jumpHost),workspacePath:rs(U.workspacePath),credentialRef:w.credentialRef??"",strictHostKeyChecking:nv(U.strictHostKeyChecking),status:w.status}),ae(!0)}function zn(){ct(Ya())}async function ds(w){var Pe;const U=((Pe=w.target.files)==null?void 0:Pe[0])??null;if(w.target.value="",!!U){ne(null),ue(null);try{Bt({fileName:U.name,fileContentBase64:await Lv(U)})}catch(Xe){ne(Xt(Xe))}}}function Gr(){Bt(Ja()),q(!0),ne(null)}function Ii(){Ot(Xa(r)),Ce(!0),ne(null)}function Os(){ct(Ya()),ae(!0),ne(null)}async function An(w){const U=await Lc(w);x(Pe=>({...Pe,[w]:U}))}async function hs(w){if(a){N(Qd(w)),ne(null),ue(null);try{await mw({targetCli:w.targetCli,directoryPath:w.directoryPath,expectedContentHash:w.contentHash}),await Qt(),ue(l("settings.skillImportSuccess",{name:w.name,target:Wn(w.targetCli)}))}catch(U){ne(Xt(U))}finally{N(null)}}}async function rn(w){if(!a)return;const U=w.bindings.filter(Pe=>Pe.enabled).map(Pe=>Pe.targetCli).filter(Pe=>pn(Pe,kt));if(U.length===0){ne(Nv(w.bindings));return}N(Zd(w.skill.id)),ne(null),ue(null);try{await gw({skillId:w.skill.id,targetCli:U}),await Qt(),ue(l("settings.skillSyncSuccess",{name:w.skill.name}))}catch(Pe){ne(Xt(Pe))}finally{N(null)}}async function fr(w){var Pe;const U=((Pe=w.target.files)==null?void 0:Pe[0])??null;if(w.target.value="",!!U){ne(null),ue(null);try{const Xe=await Av(U),Cn=Wm(U.name,Xe);Qe(Cn),De(zi(qe,kt))}catch(Xe){ne(Xt(Xe))}}}async function Pr(){const w=ih({sourceMode:rt,fileDraft:ut,pastedMarkdown:Ht});if(!a)return;if(!w){ne(rt==="paste"?l("settings.skillPasteEmpty"):l("settings.skillUploadEmpty"));return}const U=w.directoryName;if(!U){ne(l("settings.skillUploadDirectoryInvalid"));return}const Pe=Do(qe).filter(Xe=>dt[Xe]).filter(Xe=>pn(Xe,kt)).map(Xe=>Xe);if(Pe.length===0){ne(jv(qe,kt));return}N("upload"),ne(null),ue(null);try{await fw({markdownContent:w.rawContent,scope:qe,fileName:w.fileName,directoryName:U,targetCli:Pe}),await Qt(),ue(l("settings.skillUploadSuccess",{name:U})),Wt(qe),Te(!1)}catch(Xe){ne(Xt(Xe))}finally{N(null)}}function mr(w){gt(w),De(zi(w,kt))}function Ar(w){st(w),Qe(null),Ye(""),De(zi(qe,kt)),ne(null)}function sn(w){pn(w,kt)&&De(U=>({...U,[w]:!U[w]}))}function Mt(){Te(!0),ne(null),Wt(qe)}function an(){Te(!1),ne(null),Wt(qe)}function Wt(w){Qe(null),Ye(""),st("file"),De(zi(w,kt))}const on=(u==null?void 0:u.summary)??{managedSkillCount:0,managedEntryCount:0},gr=Ev((u==null?void 0:u.assistantRuntimeSkills)??[],(u==null?void 0:u.conflictedEntries)??[],(u==null?void 0:u.diagnostics)??[]),Vr=((u==null?void 0:u.conflictedEntries)??[]).filter(w=>!Om(w,(u==null?void 0:u.diagnostics)??[])),br=((u==null?void 0:u.diagnostics)??[]).filter(w=>!va(w)),Kt=ih({sourceMode:rt,fileDraft:ut,pastedMarkdown:Ht}),Kr=t??l("settings.skillManageAction"),Xn=bt==="skills",Ln=bt==="office",Jn=bt==="ops",Qn=bt==="opencli";return s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:e,type:"button","data-open":He?"true":"false","aria-haspopup":"dialog","aria-expanded":He,onClick:()=>{Ze("skills"),Ue(!0)},children:[n,s.jsx("span",{children:Kr})]}),s.jsxs(St,{open:He,title:l("settings.skillConfigModalTitle"),hideHeader:!0,className:"settings-skill-modal",onClose:()=>{Ze("skills"),Ue(!1)},children:[s.jsxs("div",{className:"settings-skill-modal-topbar",children:[s.jsxs("div",{className:"settings-skill-modal-topbar-main",children:[s.jsx("div",{className:"settings-model-tabs settings-skill-tabs",role:"tablist","aria-label":l("settings.skillConfigTabsLabel"),children:Vw.map(w=>{const U=bt===w.id,Pe=`${Ut}-${w.id}-tab`,Xe=`${Ut}-${w.id}-panel`;return s.jsx("button",{id:Pe,type:"button",role:"tab",className:"settings-model-tab","aria-selected":U,"aria-controls":Xe,"data-active":U?"true":"false",onClick:()=>Ze(w.id),children:tv(w.id)},w.id)})}),Xn?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar",children:[s.jsx("button",{className:"secondary-button",type:"button",disabled:!a||C||Z!==null,onClick:Mt,children:l("settings.skillCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!a||C||Z!==null,onClick:()=>{Yn()},children:Z==="refresh"?l("common.loading"):l("settings.skillRefresh")})]}):null,Ln?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar",children:[s.jsxs("div",{className:"settings-skill-toolbar-status",role:"status",title:A?l("settings.skillOfficeBrowserBridgeSummaryDetail",{provider:A.provider,status:rh(A),detail:A.detail??l("settings.skillOfficeBrowserBridgeDetailReady")}):l("settings.skillOfficeBrowserBridgeAvailabilityUnknown"),children:[s.jsx("span",{className:"settings-skill-toolbar-status-dot","data-status":uv(A),"aria-hidden":"true"}),s.jsx("span",{className:"settings-skill-toolbar-status-label",children:l("settings.skillOfficeBrowserBridgeSummaryLabel")}),s.jsx("strong",{className:"settings-skill-toolbar-status-value",children:rh(A)})]}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!a||C||Z!==null,onClick:Gr,children:l("settings.skillOfficeTemplateOpenCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!a||C||Z!==null,onClick:Ii,children:l("settings.skillOfficeBrowserProfileOpenCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!a||C||Z!==null,onClick:()=>{Yn()},children:Z==="refresh"?l("common.loading"):l("settings.skillRefresh")})]}):null,Jn?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar",children:[s.jsx("button",{className:"secondary-button",type:"button",disabled:!a||C||Z!==null,onClick:Os,children:l("settings.skillOpsTargetOpenCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!a||C||Z!==null,onClick:()=>{Yn()},children:Z==="refresh"?l("common.loading"):l("settings.skillRefresh")})]}):null,Qn&&_t?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar settings-opencli-toolbar",children:[s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-toolbar-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliProviderToggleLabel"),type:"checkbox",checked:_t.draftEnabled,disabled:_t.enableDisabled,onChange:w=>_t.onEnabledChange(w.target.checked)}),s.jsx("span",{children:l("settings.opencliEnableAction")})]}),s.jsx("button",{className:"secondary-button",type:"button",disabled:_t.refreshDisabled,onClick:_t.onRefresh,children:_t.refreshing?l("common.loading"):l("settings.opencliRefreshAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:_t.detailDisabled,onClick:_t.onShowDetails,children:l("settings.opencliDetailAction")}),s.jsx("button",{className:"primary-button",type:"button",disabled:_t.saveDisabled,onClick:_t.onSave,children:_t.saving?l("common.loading"):l("settings.opencliSaveAction")})]}):null]}),s.jsx(Ay,{onClick:()=>{Ze("skills"),Ue(!1)}})]}),Xn?s.jsxs("div",{id:`${Ut}-skills-panel`,role:"tabpanel","aria-labelledby":`${Ut}-skills-tab`,className:"settings-skill-panel",children:[s.jsxs("section",{className:"settings-skill-summary-block",children:[s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(In,{label:l("settings.skillSummaryManagedSkills"),value:String(on.managedSkillCount)}),s.jsx(In,{label:l("settings.skillSummaryManagedEntries"),value:String(on.managedEntryCount)}),s.jsx(In,{label:l("settings.skillSummaryConflictedEntries"),value:String(Vr.length)}),s.jsx(In,{label:l("settings.skillSummaryDiagnostics"),value:String(br.length)})]}),s.jsx("div",{className:"settings-release-meta",children:s.jsxs("span",{children:[l("settings.skillScannedAt"),": ",C?l("common.loading"):Iv(u==null?void 0:u.scannedAt)]})}),fe?s.jsx("p",{className:"settings-release-status",children:fe}):null,be?s.jsx("p",{className:"settings-release-status",children:be}):null]}),s.jsx(Or,{title:l("settings.skillManagedListTitle"),emptyText:l("settings.skillManagedEmpty"),items:(u==null?void 0:u.managedSkills)??[],renderItem:w=>{const U=Zd(w.skill.id);return s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:w.skill.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:vv(w.bindings)}),s.jsx("div",{className:"settings-skill-tags",children:w.bindings.map(Pe=>s.jsx("span",{className:"settings-skill-tag","data-status":xv(Pe,kt),children:wv(Pe,kt)},`${w.skill.id}-${Pe.targetCli}`))})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null||!yv(w.bindings,kt),onClick:()=>{rn(w)},children:Z===U?l("common.loading"):l("settings.skillSyncAction")})})]},w.skill.id)}}),s.jsx(Or,{title:l("settings.skillUnmanagedListTitle"),emptyText:l("settings.skillUnmanagedEmpty"),items:(u==null?void 0:u.unmanagedEntries)??[],renderItem:w=>{const U=Qd(w);return s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:w.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:Sv(w,kt)}),pn(w.targetCli,kt)?null:s.jsx("div",{className:"settings-skill-tags",children:s.jsx("span",{className:"settings-skill-tag","data-status":"failed",children:l("settings.skillTargetDisabledTag")})})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null||!pn(w.targetCli,kt),onClick:()=>{hs(w)},children:Z===U?l("common.loading"):l("settings.skillImportAction")})})]},`${w.targetCli}:${w.directoryPath}`)}}),s.jsx(Or,{title:l("settings.skillAssistantRuntimeListTitle"),description:l("settings.skillAssistantRuntimeListDescription"),emptyText:l("settings.skillAssistantRuntimeEmpty"),items:gr,renderItem:w=>s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:w.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillAssistantRuntimeItemDescription")}),s.jsxs("p",{className:"settings-skill-entry-meta",children:[l("settings.skillAssistantRuntimeUsedBy"),": ",Bm(w.usedByTargetCli)]}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"assistant-runtime",children:Mv(w.usageTag)}),w.usedByTargetCli.map(U=>s.jsx("span",{className:"settings-skill-tag","data-status":pn(U,kt)?"synced":"failed",children:pn(U,kt)?Wn(U):`${Wn(U)} · ${l("settings.skillTargetDisabledTag")}`},`${w.directoryName}:${U}`))]})]}),w.directoryName==="codingns-workspace-session"?s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null||!(r!=null&&r.trim()),onClick:()=>{hr()},children:l("settings.skillWorkspaceSessionMcpStatusAction")})}):null]},`${w.directoryName}:${w.sourcePath}`)}),s.jsx(Or,{title:l("settings.skillConflictedListTitle"),emptyText:l("settings.skillConflictedEmpty"),items:Vr,renderItem:w=>{const U=Rv(w,(u==null?void 0:u.diagnostics)??[]);return s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:w.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:Cv(w,kt)}),U.length>0?s.jsx("div",{className:"settings-skill-tags",children:U.map(Pe=>s.jsx("span",{className:"settings-skill-tag","data-status":Pe.status,children:Pe.label},Pe.key))}):null]})},`${w.targetCli}:${w.directoryPath}`)}}),s.jsx(Or,{title:l("settings.skillDiagnosticsTitle"),emptyText:l("settings.skillDiagnosticsEmpty"),items:br,renderItem:w=>{const U=Pv(w),Pe=Tv(w);return s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:Pe.title}),s.jsx("p",{className:"settings-skill-entry-meta",children:Pe.detail}),U.length>0?s.jsx("div",{className:"settings-skill-tags",children:U.map(Xe=>s.jsx("span",{className:"settings-skill-tag","data-status":Xe.status,children:Xe.label},Xe.key))}):null]})},`${w.targetCli}:${w.code}:${w.directoryPath??w.rootDir}`)}})]}):null,Ln?s.jsxs("div",{id:`${Ut}-office-panel`,role:"tabpanel","aria-labelledby":`${Ut}-office-tab`,className:"settings-skill-panel",children:[s.jsxs("section",{className:"settings-skill-summary-block",children:[s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(In,{label:l("settings.skillOfficeTemplateCount"),value:String(h.length)}),s.jsx(In,{label:l("settings.skillOfficeBrowserProfileCount"),value:String(gn.length)}),s.jsx(In,{label:l("settings.skillOfficeBrowserTaskCount"),value:String(y.length)}),s.jsx(In,{label:l("settings.skillOfficeWorkspaceScope"),value:r!=null&&r.trim()?l("settings.skillOfficeScoped"):l("settings.skillOfficeGlobal")})]}),fe?s.jsx("p",{className:"settings-release-status",children:fe}):null,be?s.jsx("p",{className:"settings-release-status",children:be}):null]}),s.jsx(Or,{title:l("settings.skillOfficeTemplateListTitle"),description:l("settings.skillOfficeTemplateListDescription"),emptyText:l("settings.skillOfficeTemplateEmpty"),items:h,renderItem:w=>s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:w.displayName}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOfficeTemplateListMeta",{key:w.templateKey,version:w.templateVersion})}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:w.engine}),s.jsx("span",{className:"settings-skill-tag","data-status":w.status==="active"?"synced":"failed",children:w.status})]})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("span",{className:"settings-skill-entry-meta",children:w.templateSourcePath??"-"})})]},w.id)}),s.jsx(Or,{title:l("settings.skillOfficeBrowserProfileListTitle"),description:l("settings.skillOfficeBrowserProfileListDescription"),emptyText:l("settings.skillOfficeBrowserProfileEmpty"),headerExtra:s.jsxs("label",{className:"settings-skill-inline-toggle",children:[s.jsx("input",{type:"checkbox",checked:ye,disabled:!(r!=null&&r.trim()),onChange:w=>Me(w.target.checked)}),s.jsx("span",{children:l("settings.skillOfficeBrowserProfileOnlyCurrentWorkspace")})]}),items:gn,renderItem:w=>s.jsxs("div",{className:"settings-skill-entry settings-browser-profile-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:w.displayName}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOfficeBrowserProfileListMeta",{engine:eh(w.engine),mode:rv(w.mode),scope:sv(w.ownershipScope)})}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:eh(w.engine)}),s.jsx("span",{className:"settings-skill-tag","data-status":av(w.status),children:iv(w.status)}),s.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:l("settings.skillOfficeBrowserProfileWorkspaceTag",{workspaceName:th(w.workspaceId,us)})}),w.ownershipScope==="user"?s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:l("settings.skillOfficeBrowserProfileCrossWorkspaceTag")}):null,w.cdpEndpoint?s.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:l("settings.skillOfficeBrowserProfileCdpEndpointTag")}):null]}),s.jsx("p",{className:"settings-skill-entry-meta settings-skill-path",children:w.userDataDir??w.cdpEndpoint??l("settings.skillOfficeBrowserProfileUserDataDirLabel")})]}),s.jsxs("div",{className:"settings-skill-entry-actions settings-browser-profile-entry-actions",children:[s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null,onClick:()=>{Bs(w)},children:l("settings.skillOfficeBrowserProfileOptionAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null,onClick:()=>{yt(w)},children:Z===`browser-profile-tasks:${w.id}`?l("common.loading"):l("settings.skillOfficeBrowserProfileTaskAction")}),s.jsx("button",{className:"settings-button-danger",type:"button",disabled:C||Z!==null,onClick:()=>{Vt(w)},children:l("settings.skillOfficeBrowserProfileDeleteAction")})]})]},w.id)})]}):null,Jn?s.jsxs("div",{id:`${Ut}-ops-panel`,role:"tabpanel","aria-labelledby":`${Ut}-ops-tab`,className:"settings-skill-panel",children:[s.jsxs("section",{className:"settings-skill-summary-block",children:[s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(In,{label:l("settings.skillOpsTaskCount"),value:String(I.length)}),s.jsx(In,{label:l("settings.skillOpsTargetCount"),value:String(z.length)}),s.jsx(In,{label:l("settings.skillOpsWorkspaceScope"),value:r!=null&&r.trim()?l("settings.skillOfficeScoped"):l("settings.skillOfficeGlobal")})]}),fe?s.jsx("p",{className:"settings-release-status",children:fe}):null,be?s.jsx("p",{className:"settings-release-status",children:be}):null]}),s.jsx(Or,{title:l("settings.skillOpsTaskListTitle"),description:l("settings.skillOpsTaskListDescription"),emptyText:l("settings.skillOpsTaskEmpty"),items:I,renderItem:w=>s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:w.title}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOpsTaskListMeta",{status:w.status,risk:w.riskLevel})}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:w.connectorId}),s.jsx("span",{className:"settings-skill-tag","data-status":sh(w.status),children:w.status})]}),(V==null?void 0:V.task.id)===w.id?s.jsx("div",{className:"settings-skill-tags",children:V.approvals.map(U=>s.jsx("span",{className:"settings-skill-tag","data-status":U.status==="pending"?"pending":U.status==="approved"?"synced":"failed",children:U.status},U.id))}):null]}),s.jsxs("div",{className:"settings-skill-entry-actions",children:[s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null,onClick:()=>{bn(w.id)},children:Z===`ops-task-detail:${w.id}`?l("common.loading"):l("settings.skillOpsTaskDetailAction")}),(V==null?void 0:V.task.id)===w.id?V.approvals.filter(U=>U.status==="pending").map(U=>s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null,onClick:()=>{qr(U.id,"approved")},children:Z===`ops-approval:${U.id}:approved`?l("common.loading"):l("settings.skillOpsApprovalApproveAction")},U.id)):null]})]},w.id)}),s.jsx(Or,{title:l("settings.skillOpsTargetListTitle"),description:l("settings.skillOpsTargetListDescription"),emptyText:l("settings.skillOpsTargetEmpty"),items:z,renderItem:w=>s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:w.displayName}),s.jsx("p",{className:"settings-skill-entry-meta",children:mv(w)}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:w.kind}),s.jsx("span",{className:"settings-skill-tag","data-status":w.status==="active"?"synced":"failed",children:w.status})]})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null,onClick:()=>pr(w),children:l("settings.skillOpsTargetEditAction")})})]},w.id)})]}):null,Qn?s.jsx("div",{id:`${Ut}-opencli-panel`,role:"tabpanel","aria-labelledby":`${Ut}-opencli-tab`,className:"settings-skill-panel",children:s.jsx(Iw,{toolbarMode:"external",onToolbarStateChange:_})}):null]}),s.jsx(St,{open:O,title:l("settings.skillOfficeTemplateModalTitle"),description:l("settings.skillOfficeTemplateModalDescription"),className:"settings-skill-create-modal",onClose:()=>{q(!1),Bt(Ja())},children:s.jsxs(Mn,{heading:l("settings.skillOfficeTemplateFormTitle"),children:[s.jsx("input",{ref:c,type:"file",accept:".domt,.doct,application/octet-stream",className:"settings-skill-upload-input",onChange:w=>{ds(w)}}),s.jsx(Lt,{label:l("settings.skillOfficeTemplateUploadLabel"),description:l("settings.skillOfficeTemplateUploadDescription"),children:s.jsx("div",{className:"settings-skill-create-toolbar",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null,onClick:()=>{var w;return(w=c.current)==null?void 0:w.click()},children:l("settings.skillOfficeTemplatePickAction")})})}),ht.fileName?s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:ht.fileName}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOfficeTemplateAutoDetectHint")})]})}):null,s.jsxs(Ss,{children:[s.jsx("button",{className:"secondary-button",type:"button",onClick:()=>{q(!1),Bt(Ja())},children:l("common.cancel")}),s.jsx("button",{className:"primary-button",type:"button",disabled:!ht.fileName||C||Z!==null,onClick:()=>{Zt()},children:Z==="office-template-submit"?l("common.loading"):l("settings.skillOfficeTemplateSaveAction")})]})]})}),s.jsx(St,{open:J,title:l("settings.skillOfficeBrowserProfileModalTitle"),description:l("settings.skillOfficeBrowserProfileModalDescription"),className:"settings-skill-create-modal",onClose:()=>{Ce(!1),Ot(Xa(r))},children:s.jsxs(Mn,{heading:l("settings.skillOfficeBrowserProfileFormTitle"),children:[s.jsx(Lt,{label:l("settings.skillOfficeBrowserProfileNameLabel"),htmlFor:"browser-profile-name",children:s.jsx("input",{id:"browser-profile-name",className:"settings-text-input",value:ft.displayName,onChange:w=>Ot(U=>({...U,displayName:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOfficeBrowserProfileEngineLabel"),htmlFor:"browser-profile-engine",children:s.jsxs("select",{id:"browser-profile-engine",className:"settings-select",value:ft.engine,onChange:w=>Ot(U=>({...U,engine:w.target.value})),children:[s.jsx("option",{value:"chrome",children:l("settings.skillOfficeBrowserProfileEngineChrome")}),s.jsx("option",{value:"edge",children:l("settings.skillOfficeBrowserProfileEngineEdge")})]})}),s.jsx(Lt,{label:l("settings.skillOfficeBrowserProfileModeLabel"),htmlFor:"browser-profile-mode",children:s.jsxs("select",{id:"browser-profile-mode",className:"settings-select",value:ft.mode,onChange:w=>Ot(U=>({...U,mode:w.target.value})),children:[s.jsx("option",{value:"persistent",children:l("settings.skillOfficeBrowserProfileModePersistent")}),s.jsx("option",{value:"cdp_attached",children:l("settings.skillOfficeBrowserProfileModeCdpAttached")})]})}),s.jsx(Lt,{label:l("settings.skillOfficeBrowserProfileScopeLabel"),htmlFor:"browser-profile-scope",children:s.jsxs("select",{id:"browser-profile-scope",className:"settings-select",value:ft.ownershipScope,onChange:w=>Ot(U=>({...U,ownershipScope:w.target.value})),children:[s.jsx("option",{value:"user",children:l("settings.skillOfficeBrowserProfileScopeUser")}),s.jsx("option",{value:"workspace",children:l("settings.skillOfficeBrowserProfileScopeWorkspace")}),s.jsx("option",{value:"target",children:l("settings.skillOfficeBrowserProfileScopeTarget")})]})}),ft.mode==="cdp_attached"?s.jsx(Lt,{label:l("settings.skillOfficeBrowserProfileCdpEndpointLabel"),description:l("settings.skillOfficeBrowserProfileCdpEndpointDescription"),htmlFor:"browser-profile-cdp-endpoint",children:s.jsx("input",{id:"browser-profile-cdp-endpoint",className:"settings-text-input",value:ft.cdpEndpoint,onChange:w=>Ot(U=>({...U,cdpEndpoint:w.target.value}))})}):null,s.jsxs(Ss,{children:[s.jsx("button",{className:"secondary-button",type:"button",onClick:()=>{Ce(!1),Ot(Xa(r))},children:l("common.cancel")}),s.jsx("button",{className:"primary-button",type:"button",disabled:C||Z!==null,onClick:()=>{en()},children:Z==="browser-profile-submit"?l("common.loading"):l("settings.skillOfficeBrowserProfileSaveAction")})]})]})}),s.jsx(St,{open:se,title:l("settings.skillOfficeBrowserProfileTaskModalTitle",{profileName:(K==null?void 0:K.displayName)??"-"}),description:l("settings.skillOfficeBrowserProfileTaskModalDescription"),className:"settings-skill-detail-modal",onClose:()=>{ke(!1),X(null),D(null)},children:s.jsx(Mn,{heading:l("settings.skillOfficeBrowserProfileTaskListTitle"),description:K?l("settings.skillOfficeBrowserProfileTaskListDescription",{workspaceName:th(K.workspaceId,us)}):void 0,children:cr.length===0?s.jsx(Ro,{title:l("settings.skillOfficeBrowserProfileTaskEmpty"),compact:!0}):s.jsx(mi,{children:cr.map(w=>{const U=j[w.id]??null,Pe=(Y==null?void 0:Y.task.id)===w.id;return s.jsxs(Jt,{className:"settings-browser-task-list-item",label:w.title,description:l("settings.skillOfficeBrowserInstanceListMeta",{profileName:(K==null?void 0:K.displayName)??"-",status:nh(U,w.status),risk:w.riskLevel}),trailing:s.jsxs("div",{className:"settings-skill-entry-actions settings-browser-task-list-item-actions",children:[s.jsx("span",{className:"settings-skill-entry-meta",children:fv(w.createdAt)}),s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null,onClick:()=>{Mr(w.id)},children:Z===`browser-task-detail:${w.id}`?l("common.loading"):l("settings.skillOfficeBrowserInstanceDetailAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null||!hv(w.status),onClick:()=>{ur(w.id)},children:Z===`browser-task-execute:${w.id}`?l("common.loading"):l("settings.skillOfficeBrowserInstanceExecuteAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null||!pv(U),onClick:()=>{dr(w.id)},children:Z===`browser-task-cancel:${w.id}`?l("common.loading"):l("settings.skillOfficeBrowserInstanceCancelAction")})]}),children:[s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":sh(w.status),children:w.status}),s.jsx("span",{className:"settings-skill-tag","data-status":cv(Fd(w)),children:lv(Fd(w))}),s.jsx("span",{className:"settings-skill-tag","data-status":dv(U),children:nh(U,w.status)})]}),Pe?s.jsxs("div",{className:"settings-skill-entry-meta",children:[s.jsx("p",{children:U?l("settings.skillOfficeBrowserInstanceSnapshotMeta",{status:Dm(U.status),attempt:U.attempt,startedAt:ah(U.startedAt),finishedAt:ah(U.finishedAt)}):l("settings.skillOfficeBrowserInstanceSnapshotPending")}),Y.steps.map(Xe=>s.jsxs("p",{children:[Xe.title," · ",Xe.status]},Xe.id))]}):null]},w.id)})})})}),s.jsx(St,{open:Ee,title:l("settings.skillOfficeBrowserProfileOptionsModalTitle",{profileName:(E==null?void 0:E.displayName)??"-"}),description:l("settings.skillOfficeBrowserProfileOptionsModalDescription"),className:"settings-skill-create-modal",onClose:()=>{ve(!1),H(null)},children:s.jsxs(Mn,{heading:l("settings.skillOfficeBrowserProfileOptionsSectionTitle"),children:[s.jsx(Lt,{label:l("settings.skillOfficeBrowserProfileCrossWorkspaceFieldLabel"),description:l("settings.skillOfficeBrowserProfileCrossWorkspaceFieldDescription"),children:s.jsx("div",{className:"settings-skill-entry-actions settings-browser-profile-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:!E||C||Z!==null||!ov(E),onClick:()=>{E&&vn(E)},children:E&&Z===`browser-profile-scope:${E.id}`?l("common.loading"):(E==null?void 0:E.ownershipScope)==="user"?l("settings.skillOfficeBrowserProfileSetWorkspaceOnlyAction"):l("settings.skillOfficeBrowserProfileAllowCrossWorkspaceAction")})})}),s.jsx(Ss,{children:s.jsx("button",{className:"secondary-button",type:"button",onClick:()=>{ve(!1),H(null)},children:l("common.close")})})]})}),s.jsx(St,{open:Tt,title:l("settings.skillOfficeBrowserProfileDeleteModalTitle"),description:l("settings.skillOfficeBrowserProfileDeleteModalDescription"),className:"settings-skill-create-modal",onClose:()=>{nt(!1),oe(null)},children:s.jsxs(Mn,{heading:(B==null?void 0:B.displayName)??"-",children:[s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOfficeBrowserProfileDeleteModalWarning")}),s.jsxs(Ss,{children:[s.jsx("button",{className:"secondary-button",type:"button",onClick:()=>{nt(!1),oe(null)},children:l("common.cancel")}),s.jsx("button",{className:"settings-button-danger",type:"button",disabled:!B||C||Z!==null,onClick:()=>{Sn()},children:B&&Z===`browser-profile-delete:${B.id}`?l("common.loading"):l("settings.skillOfficeBrowserProfileDeleteConfirmAction")})]})]})}),s.jsx(St,{open:mt,title:l("settings.skillOpsTargetModalTitle"),description:l("settings.skillOpsTargetModalDescription"),className:"settings-skill-create-modal",onClose:()=>{ae(!1),ct(Ya())},children:s.jsxs(Mn,{heading:l("settings.skillOpsTargetFormTitle"),description:l("settings.skillOpsTargetFormDescription"),children:[s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillOpsPasswordNotice")}),s.jsx(Lt,{label:l("settings.skillOpsTargetNameLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.displayName,onChange:w=>ct(U=>({...U,displayName:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetEnvironmentLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.environment,onChange:w=>ct(U=>({...U,environment:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetHostLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.host,onChange:w=>ct(U=>({...U,host:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetPortLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.port,onChange:w=>ct(U=>({...U,port:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetUsernameLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.username,onChange:w=>ct(U=>({...U,username:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetPrivateKeyPathLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.privateKeyPath,onChange:w=>ct(U=>({...U,privateKeyPath:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetKnownHostsPathLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.knownHostsPath,onChange:w=>ct(U=>({...U,knownHostsPath:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetJumpHostLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.jumpHost,onChange:w=>ct(U=>({...U,jumpHost:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetWorkspacePathLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.workspacePath,onChange:w=>ct(U=>({...U,workspacePath:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetCredentialRefLabel"),children:s.jsx("input",{className:"settings-text-input",value:et.credentialRef,onChange:w=>ct(U=>({...U,credentialRef:w.target.value}))})}),s.jsx(Lt,{label:l("settings.skillOpsTargetHostKeyPolicyLabel"),children:s.jsxs("select",{className:"settings-select",value:et.strictHostKeyChecking,onChange:w=>ct(U=>({...U,strictHostKeyChecking:w.target.value})),children:[s.jsx("option",{value:"accept-new",children:"accept-new"}),s.jsx("option",{value:"yes",children:"yes"}),s.jsx("option",{value:"no",children:"no"})]})}),s.jsxs(Ss,{children:[s.jsx("button",{className:"secondary-button",type:"button",onClick:zn,children:l("settings.skillOpsTargetResetAction")}),s.jsx("button",{className:"primary-button",type:"button",disabled:C||Z!==null,onClick:()=>{Rr()},children:Z==="ops-target-submit"?l("common.loading"):l("settings.skillOpsTargetSaveAction")})]})]})}),s.jsxs(St,{open:$,title:l("settings.skillWorkspaceSessionMcpModalTitle"),description:l("settings.skillWorkspaceSessionMcpModalDescription"),className:"settings-skill-create-modal",onClose:()=>{Q(!1),Ne(null)},children:[s.jsx(Mn,{heading:l("settings.skillWorkspaceSessionMcpRuntimeTitle"),description:l("settings.skillWorkspaceSessionMcpRuntimeDescription"),children:Be?s.jsx("div",{className:"settings-skill-empty",children:l("settings.skillWorkspaceSessionMcpLoading")}):ge?s.jsxs("div",{className:"settings-skill-entry-list",children:[s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(In,{label:l("settings.skillWorkspaceSessionMcpOverallLabel"),value:(Ie==null?void 0:Ie.overallState)==="ready"?l("settings.skillWorkspaceSessionMcpStateReady"):(Ie==null?void 0:Ie.overallState)==="partial"?l("settings.skillWorkspaceSessionMcpStatePartial"):l("settings.skillWorkspaceSessionMcpStateMissing")}),s.jsx(In,{label:l("settings.skillWorkspaceSessionMcpCurrentSessionLabel"),value:Ie!=null&&Ie.currentSessionReady?l("settings.skillWorkspaceSessionMcpStateReady"):l("settings.skillWorkspaceSessionMcpStateMissing")}),s.jsx(In,{label:l("settings.skillWorkspaceSessionMcpCodexLabel"),value:(Ie==null?void 0:Ie.codexState)==="ready"?l("settings.skillWorkspaceSessionMcpStateReady"):(Ie==null?void 0:Ie.codexState)==="partial"?l("settings.skillWorkspaceSessionMcpStatePartial"):l("settings.skillWorkspaceSessionMcpStateMissing")})]}),s.jsxs(mi,{children:[s.jsx(Jt,{label:l("settings.skillWorkspaceSessionMcpRuntimeTitle"),description:(Ie==null?void 0:Ie.currentSessionDetail)??l("settings.skillWorkspaceSessionMcpValueMissing"),trailing:Hi(Ie!=null&&Ie.currentSessionReady?"ready":"missing")}),s.jsx(Jt,{label:"Codex",description:(Ie==null?void 0:Ie.codexDetail)??l("settings.skillWorkspaceSessionMcpValueMissing"),trailing:Hi((Ie==null?void 0:Ie.codexState)??"missing")}),s.jsx(Jt,{label:l("settings.skillWorkspaceSessionMcpGlobalCodingnsLabel"),description:(Ie==null?void 0:Ie.globalCodingnsDetail)??l("settings.skillWorkspaceSessionMcpValueMissing"),trailing:Hi((Ie==null?void 0:Ie.globalCodingnsState)??"missing")})]})]}):s.jsx(Ro,{title:l("settings.skillWorkspaceSessionMcpEmptyTitle"),description:be??l("settings.skillWorkspaceSessionMcpEmptyDescription"),compact:!0})}),s.jsx(Mn,{heading:l("settings.skillWorkspaceSessionMcpCommandTitle"),description:l("settings.skillWorkspaceSessionMcpCommandDescription"),children:ge?s.jsxs(mi,{children:[s.jsx(Jt,{label:l("settings.skillWorkspaceSessionMcpBrowserBridgeLabel"),description:l("settings.skillWorkspaceSessionMcpBrowserBridgeDetail"),trailing:Hi("ready")}),s.jsx(Jt,{label:l("settings.skillWorkspaceSessionMcpRecommendedPathLabel"),description:(Ie==null?void 0:Ie.recommendedPath)??l("settings.skillWorkspaceSessionMcpValueMissing"),trailing:Hi("ready")})]}):null}),s.jsx(Ss,{children:s.jsx("button",{className:"secondary-button",type:"button",disabled:!(r!=null&&r.trim())||Be,onClick:()=>{hr()},children:Be?l("common.loading"):l("settings.skillWorkspaceSessionMcpRefreshAction")})})]}),s.jsx(St,{open:je,title:l("settings.skillCreateModalTitle"),description:l("settings.skillCreateModalDescription"),className:"settings-skill-create-modal",onClose:an,children:s.jsxs("section",{className:"settings-skill-section",children:[s.jsx("h3",{className:"settings-skill-section-title",children:l("settings.skillUploadSectionTitle")}),s.jsx("p",{className:"settings-skill-section-description",children:l("settings.skillUploadSectionDescription")}),s.jsxs("div",{className:"settings-skill-create-panel",children:[s.jsx("input",{ref:o,type:"file",accept:".md,text/markdown,text/plain",className:"settings-skill-upload-input",onChange:w=>{fr(w)}}),s.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":l("settings.skillCreateSourceTabsLabel"),children:Qw.map(w=>{const U=rt===w;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":U,"data-active":U?"true":"false",onClick:()=>Ar(w),children:ev(w)},w)})}),s.jsx("div",{className:"settings-skill-upload-targets",role:"radiogroup","aria-label":l("settings.skillUploadScopeLabel"),children:Jw.map(w=>s.jsxs("label",{className:"settings-skill-upload-target","data-selected":qe===w?"true":"false",children:[s.jsx("input",{type:"radio",name:"skill-upload-scope",checked:qe===w,onChange:()=>mr(w)}),s.jsx("span",{children:Zw(w)})]},w))}),rt==="file"?s.jsx("div",{className:"settings-skill-create-toolbar",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:C||Z!==null,onClick:()=>{var w;(w=o.current)==null||w.click()},children:l("settings.skillUploadPickAction")})}):s.jsxs("label",{className:"settings-skill-upload-field",children:[s.jsx("span",{children:l("settings.skillPasteLabel")}),s.jsx("textarea",{className:"settings-skill-create-textarea",value:Ht,onChange:w=>Ye(w.target.value),placeholder:l("settings.skillPastePlaceholder")})]}),Kt?s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:Kt.previewTitle}),s.jsxs("p",{className:"settings-skill-entry-meta",children:[l("settings.skillUploadPickedFile"),": ",Kt.fileName]})]})}):s.jsx("div",{className:"settings-skill-empty",children:rt==="paste"?l("settings.skillPasteEmpty"):l("settings.skillUploadEmpty")}),s.jsxs("div",{className:"settings-skill-upload-field",children:[s.jsx("span",{children:l("settings.skillUploadTargetsLabel")}),s.jsx("div",{className:"settings-skill-upload-targets",children:Do(qe).map(w=>s.jsxs("label",{className:"settings-skill-upload-target","data-selected":dt[w]?"true":"false",children:[s.jsx("input",{type:"checkbox",checked:dt[w],disabled:!pn(w,kt),onChange:()=>sn(w)}),s.jsx("span",{children:pn(w,kt)?Wn(w):`${Wn(w)} · ${l("settings.skillTargetDisabledTag")}`})]},w))})]}),Kt!=null&&Kt.notes.length?s.jsx("div",{className:"settings-skill-tags",children:Kt.notes.map((w,U)=>s.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:w},`${Kt.fileName}:${U}`))}):null,be?s.jsx("p",{className:"settings-release-status",children:be}):null,s.jsx("div",{className:"settings-skill-create-actions",children:s.jsx("button",{className:"primary-button",type:"button",disabled:C||Z!==null,onClick:()=>{Pr()},children:Z==="upload"?l("common.loading"):l("settings.skillCreateSubmitAction")})})]})]})})]})}function Or({title:e,description:t,headerExtra:n,emptyText:r,items:i,renderItem:a}){return s.jsxs("section",{className:"settings-skill-section",children:[s.jsxs("div",{className:"settings-skill-section-header",children:[s.jsx("h3",{className:"settings-skill-section-title",children:e}),n?s.jsx("div",{className:"settings-skill-section-extra",children:n}):null]}),t?s.jsx("p",{className:"settings-skill-section-description",children:t}):null,i.length>0?s.jsx("div",{className:"settings-skill-entry-list",children:i.map((o,c)=>s.jsx(f.Fragment,{children:a(o)},c))}):s.jsx("div",{className:"settings-skill-empty",children:r})]})}function In({label:e,value:t}){return s.jsxs("div",{className:"settings-skill-summary-card",children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t})]})}function Qd(e){return`import:${e.targetCli}:${e.directoryPath}`}function Zd(e){return`sync:${e}`}const Yw=["codex","claude-code","gemini","opencode"],Xw=["codex","claude-code"],Jw=["workspace","assistant"],Qw=["file","paste"];function Xt(e){return e instanceof mu?e.message||l("settings.skillLoadFailed"):e instanceof Error?e.message:l("settings.skillLoadFailed")}function Wn(e){switch(e){case"claude-code":return l("settings.skillTargetClaudeCode");case"gemini":return l("settings.skillTargetGemini");case"opencode":return l("settings.skillTargetOpenCode");default:return l("settings.skillTargetCodex")}}function Zw(e){return e==="assistant"?l("settings.skillUploadScopeAssistant"):l("settings.skillUploadScopeWorkspace")}function ev(e){return e==="paste"?l("settings.skillCreateSourcePaste"):l("settings.skillCreateSourceFile")}function tv(e){switch(e){case"office":return l("settings.skillConfigTabOffice");case"ops":return l("settings.skillConfigTabOps");case"opencli":return l("settings.skillConfigTabOpenCli");default:return l("settings.skillConfigTabSkills")}}function zi(e,t={}){const r=Do(e).filter(i=>pn(i,t))[0]??null;return{codex:r==="codex","claude-code":r==="claude-code",gemini:r==="gemini",opencode:r==="opencode"}}function Do(e){return e==="assistant"?Xw:Yw}function Ya(){return{targetId:null,displayName:"",environment:"",host:"",port:"22",username:"",privateKeyPath:"",knownHostsPath:"",jumpHost:"",workspacePath:"",credentialRef:"",strictHostKeyChecking:"accept-new",status:"active"}}function Xa(e){return{displayName:"",engine:"chrome",mode:"persistent",ownershipScope:e!=null&&e.trim()?"workspace":"user",cdpEndpoint:""}}function Ja(){return{fileName:"",fileContentBase64:""}}function Lm(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function rs(e){return typeof e=="string"?e:""}function _m(e,t){return typeof e=="number"&&Number.isFinite(e)?String(e):String(t)}function nv(e){return e==="yes"||e==="no"||e==="accept-new"?e:"accept-new"}function eh(e){return e==="edge"?l("settings.skillOfficeBrowserProfileEngineEdge"):l("settings.skillOfficeBrowserProfileEngineChrome")}function rv(e){return e==="cdp_attached"?l("settings.skillOfficeBrowserProfileModeCdpAttached"):l("settings.skillOfficeBrowserProfileModePersistent")}function sv(e){switch(e){case"workspace":return l("settings.skillOfficeBrowserProfileScopeWorkspace");case"target":return l("settings.skillOfficeBrowserProfileScopeTarget");default:return l("settings.skillOfficeBrowserProfileScopeUser")}}function iv(e){switch(e){case"locked":return l("settings.skillOfficeBrowserProfileStatusLocked");case"archived":return l("settings.skillOfficeBrowserProfileStatusArchived");case"error":return l("settings.skillOfficeBrowserProfileStatusError");default:return l("settings.skillOfficeBrowserProfileStatusActive")}}function av(e){switch(e){case"locked":return"pending";case"archived":case"error":return"failed";default:return"synced"}}function th(e,t){var n;return e!=null&&e.trim()?((n=t.get(e))==null?void 0:n.name)??l("settings.skillOfficeBrowserProfileWorkspaceUnknown"):l("settings.skillOfficeBrowserProfileWorkspaceUnbound")}function ov(e){var t;return e.ownershipScope==="user"?!!((t=e.workspaceId)!=null&&t.trim()):!0}function nh(e,t){return e?Dm(e.status):t==="succeeded"?l("settings.skillOfficeBrowserInstanceExecutionSucceeded"):t==="failed"?l("settings.skillOfficeBrowserInstanceExecutionFailed"):t==="cancelled"?l("settings.skillOfficeBrowserInstanceExecutionCancelled"):l("settings.skillOfficeBrowserInstanceExecutionIdle")}function Dm(e){switch(e){case"queued":return l("settings.skillOfficeBrowserInstanceExecutionQueued");case"running":return l("settings.skillOfficeBrowserInstanceExecutionRunning");case"succeeded":return l("settings.skillOfficeBrowserInstanceExecutionSucceeded");case"failed":return l("settings.skillOfficeBrowserInstanceExecutionFailed");case"cancelled":return l("settings.skillOfficeBrowserInstanceExecutionCancelled");default:return l("settings.skillOfficeBrowserInstanceExecutionTimeout")}}function lv(e){return e==="opencli_bridge"?l("settings.skillOfficeBrowserExecutionBackendOpenCliBridge"):l("settings.skillOfficeBrowserExecutionBackendPlaywright")}function cv(e){return e==="opencli_bridge"?"pending":"synced"}function rh(e){if(!e)return l("settings.skillOfficeBrowserBridgeAvailabilityUnknown");switch(e.availability){case"ready":return l("settings.skillOfficeBrowserBridgeAvailabilityReady");case"daemon_missing":return l("settings.skillOfficeBrowserBridgeAvailabilityDaemonMissing");case"extension_missing":return l("settings.skillOfficeBrowserBridgeAvailabilityExtensionMissing");default:return l("settings.skillOfficeBrowserBridgeAvailabilityUnavailable")}}function uv(e){if(!e)return"conflicted";switch(e.availability){case"ready":return"synced";case"daemon_missing":case"extension_missing":return"pending";default:return"failed"}}function dv(e){if(!e)return"conflicted";switch(e.status){case"queued":case"running":return"pending";case"succeeded":return"synced";case"failed":case"cancelled":case"timeout":return"failed";default:return"conflicted"}}function hv(e){return e==="ready"||e==="failed"}function pv(e){return(e==null?void 0:e.status)==="queued"||(e==null?void 0:e.status)==="running"}function fv(e){return new Date(e).toLocaleString("zh-CN",{hour12:!1})}function sh(e){return e==="ready"||e==="running"||e==="succeeded"?"synced":e==="pending_approval"||e==="waiting_external"||e==="paused"?"pending":e==="failed"||e==="cancelled"||e==="rolled_back"?"failed":"conflicted"}function mv(e){var o;const t=Lm(e.configJson),n=rs(t.host),r=rs(t.username),i=_m(t.port,22);return[(o=e.environment)==null?void 0:o.trim(),`${r}@${n}:${i}`].filter(c=>c&&c.trim().length>0).join(" · ")}function Hi(e){const t=e==="ready"?"synced":e==="partial"?"pending":"failed",n=e==="ready"?l("settings.skillWorkspaceSessionMcpStateReady"):e==="partial"?l("settings.skillWorkspaceSessionMcpStatePartial"):l("settings.skillWorkspaceSessionMcpStateMissing");return s.jsx("span",{className:"settings-skill-tag","data-status":t,children:n})}function ih({sourceMode:e,fileDraft:t,pastedMarkdown:n}){return e==="file"?t:n.trim()?Wm(_v(n),n):null}function gv(e){switch(e){case"conflicted":return l("settings.skillBindingConflicted");case"failed":return l("settings.skillBindingFailed");case"pending":return l("settings.skillBindingPending");default:return l("settings.skillBindingSynced")}}function bv(e){const t={};for(const n of e){const r=kv(n.provider);r&&(t[r]=n)}return t}function kv(e){switch(e){case"claude-code":return"claude-code";case"codex":return"codex";case"gemini":return"gemini";case"opencode":return"opencode";default:return null}}function pn(e,t){var n;return((n=t[e])==null?void 0:n.enabled)!==!1}function yv(e,t){return e.some(n=>n.enabled&&pn(n.targetCli,t))}function xv(e,t){return pn(e.targetCli,t)?e.syncStatus:"failed"}function wv(e,t){return pn(e.targetCli,t)?`${Wn(e.targetCli)} · ${gv(e.syncStatus)}`:`${Wn(e.targetCli)} · ${l("settings.skillTargetDisabledTag")}`}function Bm(e){return e.map(Wn).join(" / ")}function vv(e){const t=e.filter(n=>n.enabled);return t.length===0?l("settings.skillManagedItemNoTarget"):l("settings.skillManagedItemDescription",{targets:Bm(t.map(n=>n.targetCli))})}function Sv(e,t){return pn(e.targetCli,t)?l("settings.skillUnmanagedItemDescription",{target:Wn(e.targetCli)}):l("settings.skillUnmanagedItemDisabledDescription",{target:Wn(e.targetCli)})}function Cv(e,t){return pn(e.targetCli,t)?l("settings.skillConflictedItemDescription",{target:Wn(e.targetCli)}):l("settings.skillConflictedItemDisabledDescription",{target:Wn(e.targetCli)})}function Nv(e,t){return e.some(r=>r.enabled)?l("settings.skillSyncTargetDisabled"):l("settings.skillSyncTargetMissing")}function jv(e,t){return Do(e).some(r=>pn(r,t))?l("settings.skillUploadTargetRequired"):l("settings.skillUploadTargetDisabled")}function Tv(e){const t=Wn(e.targetCli);switch(e.code){case"SKILL_TARGET_ROOT_MISSING":return{title:l("settings.skillDiagnosticTargetMissingTitle",{target:t}),detail:l("settings.skillDiagnosticTargetMissingDetail",{target:t})};case"SKILL_TARGET_ROOT_INVALID":case"SKILL_TARGET_STAT_FAILED":case"SKILL_TARGET_READ_FAILED":return{title:l("settings.skillDiagnosticReadFailedTitle",{target:t}),detail:l("settings.skillDiagnosticReadFailedDetail",{target:t})};case"SKILL_TARGET_SKILL_MISSING":return{title:l("settings.skillDiagnosticSyncMissingTitle",{target:t}),detail:l("settings.skillDiagnosticSyncMissingDetail",{target:t})};default:return{title:l("settings.skillDiagnosticGenericTitle",{target:t}),detail:l("settings.skillDiagnosticGenericDetail",{target:t})}}}function Iv(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function ah(e){return e===null?"-":new Date(e).toLocaleString()}async function oh(e){const t=await Promise.all(e.map(async n=>[n.id,await Lc(n.id)]));return Object.fromEntries(t)}function Ev(e,t,n){if(e.length>0)return e.map(i=>({name:i.name,directoryName:i.directoryName,sourcePath:i.sourcePath,usedByTargetCli:i.usedByTargetCli,usageTag:zl(i.directoryName)}));const r=new Map;for(const i of t)Om(i,n)&&r.set(lh(i.targetCli,i.directoryPath),{name:i.name,directoryName:i.directoryName,sourcePath:i.directoryPath,usedByTargetCli:[i.targetCli],usageTag:zl(i.directoryName)});for(const i of n){if(!va(i))continue;const a=i.directoryPath??i.rootDir,o=lh(i.targetCli,a);r.has(o)||r.set(o,{name:i.directoryName??"codingns-assistant",directoryName:i.directoryName??"codingns-assistant",sourcePath:a,usedByTargetCli:[i.targetCli],usageTag:zl(i.directoryName??"codingns-assistant")})}return[...r.values()]}function lh(e,t){return`${e}:${t}`}function Om(e,t){return t.some(n=>va(n)&&n.targetCli===e.targetCli&&n.directoryPath===e.directoryPath&&n.directoryName===e.directoryName)}function va(e){return e.code==="SKILL_RESERVED_FOR_ASSISTANT_RUNTIME"}function zl(e){return e==="codingns-workspace-session"?"workspace-session":"assistant-only"}function Mv(e){return e==="workspace-session"?l("settings.skillTagWorkspaceSessionOnly"):l("settings.skillTagAssistantOnly")}function Rv(e,t){return t.find(r=>va(r)&&r.targetCli===e.targetCli&&r.directoryName===e.directoryName&&r.directoryPath===e.directoryPath)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath}`,label:l("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function Pv(e){return va(e)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath??e.rootDir}`,label:l("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function Wm(e,t){const n=[],r=t.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
4
4
  `).trim();if(!r)throw new Error(l("settings.skillUploadContentEmpty"));r!==t.trim()&&n.push(l("settings.skillUploadNormalizedNote"));const i=Fm(r),a=_c(e)??_c(i)??"";return a||n.push(l("settings.skillUploadDirectoryRequiredNote")),i||n.push(l("settings.skillUploadHeadingNote")),{fileName:e,rawContent:r,directoryName:a,previewTitle:i||Dv(a||"skill"),notes:n}}async function Av(e){if(typeof e.text=="function")return await e.text();if(typeof FileReader>"u")throw new Error(l("settings.skillUploadReadFailed"));return await new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>{n(r.error??new Error(l("settings.skillUploadReadFailed")))},r.onload=()=>{if(typeof r.result=="string"){t(r.result);return}n(new Error(l("settings.skillUploadReadFailed")))},r.readAsText(e)})}async function Lv(e){if(typeof e.arrayBuffer=="function"){const t=await e.arrayBuffer();return ch(new Uint8Array(t))}if(typeof FileReader>"u")throw new Error(l("settings.skillUploadReadFailed"));return await new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>{n(r.error??new Error(l("settings.skillUploadReadFailed")))},r.onload=()=>{if(r.result instanceof ArrayBuffer){t(ch(new Uint8Array(r.result)));return}n(new Error(l("settings.skillUploadReadFailed")))},r.readAsArrayBuffer(e)})}function ch(e){let t="";return e.forEach(n=>{t+=String.fromCharCode(n)}),btoa(t)}function _c(e){const r=(e.replace(/\\/g,"/").split("/").pop()??e).replace(/\.[A-Za-z0-9]+$/,"").trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-._]+|[-._]+$/g,"").toLowerCase();return r.length>0?r:null}function _v(e){const t=_c(Fm(e));return t?`${t}.md`:"pasted-skill.md"}function Fm(e){var t,n;return((n=(t=e.match(/^#\s+(.+)$/m))==null?void 0:t[1])==null?void 0:n.trim())??""}function Dv(e){return e.split(/[._-]+/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||e}function Bv(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Ov=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Wv=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Fv={};function uh(e,t){return(Fv.jsx?Wv:Ov).test(e)}const $v=/[ \t\n\f\r]/g;function zv(e){return typeof e=="object"?e.type==="text"?dh(e.value):!1:dh(e)}function dh(e){return e.replace($v,"")===""}class Sa{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Sa.prototype.normal={};Sa.prototype.property={};Sa.prototype.space=void 0;function $m(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Sa(n,r,t)}function Dc(e){return e.toLowerCase()}class Pn{constructor(t,n){this.attribute=n,this.property=t}}Pn.prototype.attribute="";Pn.prototype.booleanish=!1;Pn.prototype.boolean=!1;Pn.prototype.commaOrSpaceSeparated=!1;Pn.prototype.commaSeparated=!1;Pn.prototype.defined=!1;Pn.prototype.mustUseProperty=!1;Pn.prototype.number=!1;Pn.prototype.overloadedBoolean=!1;Pn.prototype.property="";Pn.prototype.spaceSeparated=!1;Pn.prototype.space=void 0;let Hv=0;const Ge=Ls(),Gt=Ls(),Bc=Ls(),ce=Ls(),Et=Ls(),bi=Ls(),Bn=Ls();function Ls(){return 2**++Hv}const Oc=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ge,booleanish:Gt,commaOrSpaceSeparated:Bn,commaSeparated:bi,number:ce,overloadedBoolean:Bc,spaceSeparated:Et},Symbol.toStringTag,{value:"Module"})),Hl=Object.keys(Oc);class Lu extends Pn{constructor(t,n,r,i){let a=-1;if(super(t,n),hh(this,"space",i),typeof r=="number")for(;++a<Hl.length;){const o=Hl[a];hh(this,Hl[a],(r&Oc[o])===Oc[o])}}}Lu.prototype.defined=!0;function hh(e,t,n){n&&(e[t]=n)}function ji(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const a=new Lu(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Dc(r)]=r,n[Dc(a.attribute)]=r}return new Sa(t,n,e.space)}const zm=ji({properties:{ariaActiveDescendant:null,ariaAtomic:Gt,ariaAutoComplete:null,ariaBusy:Gt,ariaChecked:Gt,ariaColCount:ce,ariaColIndex:ce,ariaColSpan:ce,ariaControls:Et,ariaCurrent:null,ariaDescribedBy:Et,ariaDetails:null,ariaDisabled:Gt,ariaDropEffect:Et,ariaErrorMessage:null,ariaExpanded:Gt,ariaFlowTo:Et,ariaGrabbed:Gt,ariaHasPopup:null,ariaHidden:Gt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Et,ariaLevel:ce,ariaLive:null,ariaModal:Gt,ariaMultiLine:Gt,ariaMultiSelectable:Gt,ariaOrientation:null,ariaOwns:Et,ariaPlaceholder:null,ariaPosInSet:ce,ariaPressed:Gt,ariaReadOnly:Gt,ariaRelevant:null,ariaRequired:Gt,ariaRoleDescription:Et,ariaRowCount:ce,ariaRowIndex:ce,ariaRowSpan:ce,ariaSelected:Gt,ariaSetSize:ce,ariaSort:null,ariaValueMax:ce,ariaValueMin:ce,ariaValueNow:ce,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Hm(e,t){return t in e?e[t]:t}function Um(e,t){return Hm(e,t.toLowerCase())}const Uv=ji({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:bi,acceptCharset:Et,accessKey:Et,action:null,allow:null,allowFullScreen:Ge,allowPaymentRequest:Ge,allowUserMedia:Ge,alt:null,as:null,async:Ge,autoCapitalize:null,autoComplete:Et,autoFocus:Ge,autoPlay:Ge,blocking:Et,capture:null,charSet:null,checked:Ge,cite:null,className:Et,cols:ce,colSpan:null,content:null,contentEditable:Gt,controls:Ge,controlsList:Et,coords:ce|bi,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ge,defer:Ge,dir:null,dirName:null,disabled:Ge,download:Bc,draggable:Gt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ge,formTarget:null,headers:Et,height:ce,hidden:Bc,high:ce,href:null,hrefLang:null,htmlFor:Et,httpEquiv:Et,id:null,imageSizes:null,imageSrcSet:null,inert:Ge,inputMode:null,integrity:null,is:null,isMap:Ge,itemId:null,itemProp:Et,itemRef:Et,itemScope:Ge,itemType:Et,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ge,low:ce,manifest:null,max:null,maxLength:ce,media:null,method:null,min:null,minLength:ce,multiple:Ge,muted:Ge,name:null,nonce:null,noModule:Ge,noValidate:Ge,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ge,optimum:ce,pattern:null,ping:Et,placeholder:null,playsInline:Ge,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ge,referrerPolicy:null,rel:Et,required:Ge,reversed:Ge,rows:ce,rowSpan:ce,sandbox:Et,scope:null,scoped:Ge,seamless:Ge,selected:Ge,shadowRootClonable:Ge,shadowRootDelegatesFocus:Ge,shadowRootMode:null,shape:null,size:ce,sizes:null,slot:null,span:ce,spellCheck:Gt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ce,step:null,style:null,tabIndex:ce,target:null,title:null,translate:null,type:null,typeMustMatch:Ge,useMap:null,value:Gt,width:ce,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Et,axis:null,background:null,bgColor:null,border:ce,borderColor:null,bottomMargin:ce,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ge,declare:Ge,event:null,face:null,frame:null,frameBorder:null,hSpace:ce,leftMargin:ce,link:null,longDesc:null,lowSrc:null,marginHeight:ce,marginWidth:ce,noResize:Ge,noHref:Ge,noShade:Ge,noWrap:Ge,object:null,profile:null,prompt:null,rev:null,rightMargin:ce,rules:null,scheme:null,scrolling:Gt,standby:null,summary:null,text:null,topMargin:ce,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ce,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ge,disableRemotePlayback:Ge,prefix:null,property:null,results:ce,security:null,unselectable:null},space:"html",transform:Um}),qv=ji({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Bn,accentHeight:ce,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ce,amplitude:ce,arabicForm:null,ascent:ce,attributeName:null,attributeType:null,azimuth:ce,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ce,by:null,calcMode:null,capHeight:ce,className:Et,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ce,diffuseConstant:ce,direction:null,display:null,dur:null,divisor:ce,dominantBaseline:null,download:Ge,dx:null,dy:null,edgeMode:null,editable:null,elevation:ce,enableBackground:null,end:null,event:null,exponent:ce,externalResourcesRequired:null,fill:null,fillOpacity:ce,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:bi,g2:bi,glyphName:bi,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ce,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ce,horizOriginX:ce,horizOriginY:ce,id:null,ideographic:ce,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ce,k:ce,k1:ce,k2:ce,k3:ce,k4:ce,kernelMatrix:Bn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ce,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ce,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ce,overlineThickness:ce,paintOrder:null,panose1:null,path:null,pathLength:ce,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Et,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ce,pointsAtY:ce,pointsAtZ:ce,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Bn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Bn,rev:Bn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Bn,requiredFeatures:Bn,requiredFonts:Bn,requiredFormats:Bn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ce,specularExponent:ce,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ce,strikethroughThickness:ce,string:null,stroke:null,strokeDashArray:Bn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ce,strokeOpacity:ce,strokeWidth:null,style:null,surfaceScale:ce,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Bn,tabIndex:ce,tableValues:null,target:null,targetX:ce,targetY:ce,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Bn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ce,underlineThickness:ce,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ce,values:null,vAlphabetic:ce,vMathematical:ce,vectorEffect:null,vHanging:ce,vIdeographic:ce,version:null,vertAdvY:ce,vertOriginX:ce,vertOriginY:ce,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ce,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Hm}),qm=ji({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Gm=ji({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Um}),Vm=ji({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Gv={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Vv=/[A-Z]/g,ph=/-[a-z]/g,Kv=/^data[-\w.:]+$/i;function Yv(e,t){const n=Dc(t);let r=t,i=Pn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Kv.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(ph,Jv);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!ph.test(a)){let o=a.replace(Vv,Xv);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Lu}return new i(r,t)}function Xv(e){return"-"+e.toLowerCase()}function Jv(e){return e.charAt(1).toUpperCase()}const Qv=$m([zm,Uv,qm,Gm,Vm],"html"),_u=$m([zm,qv,qm,Gm,Vm],"svg");function Zv(e){return e.join(" ").trim()}var Qs={},Ul,fh;function eS(){if(fh)return Ul;fh=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,c=/^\s+|\s+$/g,u=`
5
5
  `,d="/",h="*",p="",g="comment",m="declaration";function y(j,x){if(typeof j!="string")throw new TypeError("First argument must be a string");if(!j)return[];x=x||{};var A=1,T=1;function F(K){var X=K.match(t);X&&(A+=X.length);var Y=K.lastIndexOf(u);T=~Y?K.length-Y:T+K.length}function R(){var K={line:A,column:T};return function(X){return X.position=new I(K),L(),X}}function I(K){this.start=K,this.end={line:A,column:T},this.source=x.source}I.prototype.content=j;function G(K){var X=new Error(x.source+":"+A+":"+T+": "+K);if(X.reason=K,X.filename=x.source,X.line=A,X.column=T,X.source=j,!x.silent)throw X}function z(K){var X=K.exec(j);if(X){var Y=X[0];return F(Y),j=j.slice(Y.length),X}}function L(){z(n)}function E(K){var X;for(K=K||[];X=H();)X!==!1&&K.push(X);return K}function H(){var K=R();if(!(d!=j.charAt(0)||h!=j.charAt(1))){for(var X=2;p!=j.charAt(X)&&(h!=j.charAt(X)||d!=j.charAt(X+1));)++X;if(X+=2,p===j.charAt(X-1))return G("End of comment missing");var Y=j.slice(2,X-2);return T+=2,F(Y),j=j.slice(X),T+=2,K({type:g,comment:Y})}}function B(){var K=R(),X=z(r);if(X){if(H(),!z(i))return G("property missing ':'");var Y=z(a),D=K({type:m,property:S(X[0].replace(e,p)),value:Y?S(Y[0].replace(e,p)):p});return z(o),D}}function oe(){var K=[];E(K);for(var X;X=B();)X!==!1&&(K.push(X),E(K));return K}return L(),oe()}function S(j){return j?j.replace(c,p):p}return Ul=y,Ul}var mh;function tS(){if(mh)return Qs;mh=1;var e=Qs&&Qs.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.default=n;const t=e(eS());function n(r,i){let a=null;if(!r||typeof r!="string")return a;const o=(0,t.default)(r),c=typeof i=="function";return o.forEach(u=>{if(u.type!=="declaration")return;const{property:d,value:h}=u;c?i(d,h,u):h&&(a=a||{},a[d]=h)}),a}return Qs}var Ui={},gh;function nS(){if(gh)return Ui;gh=1,Object.defineProperty(Ui,"__esModule",{value:!0}),Ui.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,a=function(d){return!d||n.test(d)||e.test(d)},o=function(d,h){return h.toUpperCase()},c=function(d,h){return"".concat(h,"-")},u=function(d,h){return h===void 0&&(h={}),a(d)?d:(d=d.toLowerCase(),h.reactCompat?d=d.replace(i,c):d=d.replace(r,c),d.replace(t,o))};return Ui.camelCase=u,Ui}var qi,bh;function rS(){if(bh)return qi;bh=1;var e=qi&&qi.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(tS()),n=nS();function r(i,a){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(c,u){c&&u&&(o[(0,n.camelCase)(c,a)]=u)}),o}return r.default=r,qi=r,qi}var sS=rS();const iS=Wf(sS),Km=Ym("end"),Du=Ym("start");function Ym(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function aS(e){const t=Du(e),n=Km(e);if(t&&n)return{start:t,end:n}}function sa(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?kh(e.position):"start"in e||"end"in e?kh(e):"line"in e||"column"in e?Wc(e):""}function Wc(e){return yh(e&&e.line)+":"+yh(e&&e.column)}function kh(e){return Wc(e&&e.start)+"-"+Wc(e&&e.end)}function yh(e){return e&&typeof e=="number"?e:1}class mn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",a={},o=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?i=t:!a.cause&&t&&(o=!0,i=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?a.ruleId=r:(a.source=r.slice(0,u),a.ruleId=r.slice(u+1))}if(!a.place&&a.ancestors&&a.ancestors){const u=a.ancestors[a.ancestors.length-1];u&&(a.place=u.position)}const c=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=c?c.line:void 0,this.name=sa(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=o&&a.cause&&typeof a.cause.stack=="string"?a.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}mn.prototype.file="";mn.prototype.name="";mn.prototype.reason="";mn.prototype.message="";mn.prototype.stack="";mn.prototype.column=void 0;mn.prototype.line=void 0;mn.prototype.ancestors=void 0;mn.prototype.cause=void 0;mn.prototype.fatal=void 0;mn.prototype.place=void 0;mn.prototype.ruleId=void 0;mn.prototype.source=void 0;const Bu={}.hasOwnProperty,oS=new Map,lS=/[A-Z]/g,cS=new Set(["table","tbody","thead","tfoot","tr"]),uS=new Set(["td","th"]),Xm="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function dS(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=yS(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=kS(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?_u:Qv,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Jm(i,e,void 0);return a&&typeof a!="string"?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Jm(e,t,n){if(t.type==="element")return hS(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return pS(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return mS(e,t,n);if(t.type==="mdxjsEsm")return fS(e,t);if(t.type==="root")return gS(e,t,n);if(t.type==="text")return bS(e,t)}function hS(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=_u,e.schema=i),e.ancestors.push(t);const a=Zm(e,t.tagName,!1),o=xS(e,t);let c=Wu(e,t);return cS.has(t.tagName)&&(c=c.filter(function(u){return typeof u=="string"?!zv(u):!0})),Qm(e,o,a,t),Ou(o,c),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function pS(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}da(e,t.position)}function fS(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);da(e,t.position)}function mS(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=_u,e.schema=i),e.ancestors.push(t);const a=t.name===null?e.Fragment:Zm(e,t.name,!0),o=wS(e,t),c=Wu(e,t);return Qm(e,o,a,t),Ou(o,c),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function gS(e,t,n){const r={};return Ou(r,Wu(e,t)),e.create(t,e.Fragment,r,n)}function bS(e,t){return t.value}function Qm(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Ou(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function kS(e,t,n){return r;function r(i,a,o,c){const d=Array.isArray(o.children)?n:t;return c?d(a,o,c):d(a,o)}}function yS(e,t){return n;function n(r,i,a,o){const c=Array.isArray(a.children),u=Du(r);return t(i,a,o,c,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function xS(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Bu.call(t.properties,i)){const a=vS(e,i,t.properties[i]);if(a){const[o,c]=a;e.tableCellAlignToStyle&&o==="align"&&typeof c=="string"&&uS.has(t.tagName)?r=c:n[o]=c}}if(r){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function wS(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const o=a.expression;o.type;const c=o.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else da(e,t.position);else{const i=r.name;let a;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const c=r.value.data.estree.body[0];c.type,a=e.evaluater.evaluateExpression(c.expression)}else da(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function Wu(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:oS;for(;++r<t.children.length;){const a=t.children[r];let o;if(e.passKeys){const u=a.type==="element"?a.tagName:a.type==="mdxJsxFlowElement"||a.type==="mdxJsxTextElement"?a.name:void 0;if(u){const d=i.get(u)||0;o=u+"-"+d,i.set(u,d+1)}}const c=Jm(e,a,o);c!==void 0&&n.push(c)}return n}function vS(e,t,n){const r=Yv(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Bv(n):Zv(n)),r.property==="style"){let i=typeof n=="object"?n:SS(e,String(n));return e.stylePropertyNameCase==="css"&&(i=CS(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Gv[r.property]||r.property:r.attribute,n]}}function SS(e,t){try{return iS(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new mn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Xm+"#cannot-parse-style-attribute",i}}function Zm(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let a=-1,o;for(;++a<i.length;){const c=uh(i[a])?{type:"Identifier",name:i[a]}:{type:"Literal",value:i[a]};o=o?{type:"MemberExpression",object:o,property:c,computed:!!(a&&c.type==="Literal"),optional:!1}:c}r=o}else r=uh(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Bu.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);da(e)}function da(e,t){const n=new mn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Xm+"#cannot-handle-mdx-estrees-without-createevaluater",n}function CS(e){const t={};let n;for(n in e)Bu.call(e,n)&&(t[NS(n)]=e[n]);return t}function NS(e){let t=e.replace(lS,jS);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function jS(e){return"-"+e.toLowerCase()}const ql={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},TS={};function Fu(e,t){const n=TS,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return eg(e,r,i)}function eg(e,t,n){if(IS(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return xh(e.children,t,n)}return Array.isArray(e)?xh(e,t,n):""}function xh(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=eg(e[i],t,n);return r.join("")}function IS(e){return!!(e&&typeof e=="object")}const wh=document.createElement("i");function $u(e){const t="&"+e+";";wh.innerHTML=t;const n=wh.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Fn(e,t,n,r){const i=e.length;let a=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Kn(e,t){return e.length>0?(Fn(e,e.length,0,t),e):t}const vh={}.hasOwnProperty;function tg(e){const t={};let n=-1;for(;++n<e.length;)ES(t,e[n]);return t}function ES(e,t){let n;for(n in t){const i=(vh.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){vh.call(i,o)||(i[o]=[]);const c=a[o];MS(i[o],Array.isArray(c)?c:c?[c]:[])}}}function MS(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Fn(e,0,0,r)}function ng(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function or(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const wn=cs(/[A-Za-z]/),fn=cs(/[\dA-Za-z]/),RS=cs(/[#-'*+\--9=?A-Z^-~]/);function Bo(e){return e!==null&&(e<32||e===127)}const Fc=cs(/\d/),PS=cs(/[\dA-Fa-f]/),AS=cs(/[!-/:-@[-`{-~]/);function Le(e){return e!==null&&e<-2}function jt(e){return e!==null&&(e<0||e===32)}function tt(e){return e===-2||e===-1||e===32}const sl=cs(new RegExp("\\p{P}|\\p{S}","u")),Rs=cs(/\s/);function cs(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Ti(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o="";if(a===37&&fn(e.charCodeAt(n+1))&&fn(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){const c=e.charCodeAt(n+1);a<56320&&c>56319&&c<57344?(o=String.fromCharCode(a,c),i=1):o="�"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ot(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(u){return tt(u)?(e.enter(n),c(u)):t(u)}function c(u){return tt(u)&&a++<i?(e.consume(u),c):(e.exit(n),t(u))}}const LS={tokenize:_S};function _S(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),ot(e,t,"linePrefix")}function i(c){return e.enter("paragraph"),a(c)}function a(c){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,o(c)}function o(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return Le(c)?(e.consume(c),e.exit("chunkText"),a):(e.consume(c),o)}}const DS={tokenize:BS},Sh={tokenize:OS};function BS(e){const t=this,n=[];let r=0,i,a,o;return c;function c(T){if(r<n.length){const F=n[r];return t.containerState=F[1],e.attempt(F[0].continuation,u,d)(T)}return d(T)}function u(T){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&A();const F=t.events.length;let R=F,I;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){I=t.events[R][1].end;break}x(r);let G=F;for(;G<t.events.length;)t.events[G][1].end={...I},G++;return Fn(t.events,R+1,0,t.events.slice(F)),t.events.length=G,d(T)}return c(T)}function d(T){if(r===n.length){if(!i)return g(T);if(i.currentConstruct&&i.currentConstruct.concrete)return y(T);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Sh,h,p)(T)}function h(T){return i&&A(),x(r),g(T)}function p(T){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,y(T)}function g(T){return t.containerState={},e.attempt(Sh,m,y)(T)}function m(T){return r++,n.push([t.currentConstruct,t.containerState]),g(T)}function y(T){if(T===null){i&&A(),x(0),e.consume(T);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:a}),S(T)}function S(T){if(T===null){j(e.exit("chunkFlow"),!0),x(0),e.consume(T);return}return Le(T)?(e.consume(T),j(e.exit("chunkFlow")),r=0,t.interrupt=void 0,c):(e.consume(T),S)}function j(T,F){const R=t.sliceStream(T);if(F&&R.push(null),T.previous=a,a&&(a.next=T),a=T,i.defineSkip(T.start),i.write(R),t.parser.lazy[T.start.line]){let I=i.events.length;for(;I--;)if(i.events[I][1].start.offset<o&&(!i.events[I][1].end||i.events[I][1].end.offset>o))return;const G=t.events.length;let z=G,L,E;for(;z--;)if(t.events[z][0]==="exit"&&t.events[z][1].type==="chunkFlow"){if(L){E=t.events[z][1].end;break}L=!0}for(x(r),I=G;I<t.events.length;)t.events[I][1].end={...E},I++;Fn(t.events,z+1,0,t.events.slice(G)),t.events.length=I}}function x(T){let F=n.length;for(;F-- >T;){const R=n[F];t.containerState=R[1],R[0].exit.call(t,e)}n.length=T}function A(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function OS(e,t,n){return ot(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function wi(e){if(e===null||jt(e)||Rs(e))return 1;if(sl(e))return 2}function il(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const $c={name:"attention",resolveAll:WS,tokenize:FS};function WS(e,t){let n=-1,r,i,a,o,c,u,d,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[r][1].end},g={...e[n][1].start};Ch(p,-u),Ch(g,u),o={type:u>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},c={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},a={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?"strong":"emphasis",start:{...o.start},end:{...c.end}},e[r][1].end={...o.start},e[n][1].start={...c.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=Kn(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=Kn(d,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",a,t]]),d=Kn(d,il(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=Kn(d,[["exit",a,t],["enter",c,t],["exit",c,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,d=Kn(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,Fn(e,r-1,n-r+3,d),n=r+d.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function FS(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=wi(r);let a;return o;function o(u){return a=u,e.enter("attentionSequence"),c(u)}function c(u){if(u===a)return e.consume(u),c;const d=e.exit("attentionSequence"),h=wi(u),p=!h||h===2&&i||n.includes(u),g=!i||i===2&&h||n.includes(r);return d._open=!!(a===42?p:p&&(i||!g)),d._close=!!(a===42?g:g&&(h||!p)),t(u)}}function Ch(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const $S={name:"autolink",tokenize:zS};function zS(e,t,n){let r=0;return i;function i(m){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),a}function a(m){return wn(m)?(e.consume(m),o):m===64?n(m):d(m)}function o(m){return m===43||m===45||m===46||fn(m)?(r=1,c(m)):d(m)}function c(m){return m===58?(e.consume(m),r=0,u):(m===43||m===45||m===46||fn(m))&&r++<32?(e.consume(m),c):(r=0,d(m))}function u(m){return m===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):m===null||m===32||m===60||Bo(m)?n(m):(e.consume(m),u)}function d(m){return m===64?(e.consume(m),h):RS(m)?(e.consume(m),d):n(m)}function h(m){return fn(m)?p(m):n(m)}function p(m){return m===46?(e.consume(m),r=0,h):m===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):g(m)}function g(m){if((m===45||fn(m))&&r++<63){const y=m===45?g:p;return e.consume(m),y}return n(m)}}const Ca={partial:!0,tokenize:HS};function HS(e,t,n){return r;function r(a){return tt(a)?ot(e,i,"linePrefix")(a):i(a)}function i(a){return a===null||Le(a)?t(a):n(a)}}const rg={continuation:{tokenize:qS},exit:GS,name:"blockQuote",tokenize:US};function US(e,t,n){const r=this;return i;function i(o){if(o===62){const c=r.containerState;return c.open||(e.enter("blockQuote",{_container:!0}),c.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),a}return n(o)}function a(o){return tt(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function qS(e,t,n){const r=this;return i;function i(o){return tt(o)?ot(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):a(o)}function a(o){return e.attempt(rg,t,n)(o)}}function GS(e){e.exit("blockQuote")}const sg={name:"characterEscape",tokenize:VS};function VS(e,t,n){return r;function r(a){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(a),e.exit("escapeMarker"),i}function i(a){return AS(a)?(e.enter("characterEscapeValue"),e.consume(a),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(a)}}const ig={name:"characterReference",tokenize:KS};function KS(e,t,n){const r=this;let i=0,a,o;return c;function c(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),u}function u(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),a=31,o=fn,h(p))}function d(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,o=PS,h):(e.enter("characterReferenceValue"),a=7,o=Fc,h(p))}function h(p){if(p===59&&i){const g=e.exit("characterReferenceValue");return o===fn&&!$u(r.sliceSerialize(g))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(p)&&i++<a?(e.consume(p),h):n(p)}}const Nh={partial:!0,tokenize:XS},jh={concrete:!0,name:"codeFenced",tokenize:YS};function YS(e,t,n){const r=this,i={partial:!0,tokenize:R};let a=0,o=0,c;return u;function u(I){return d(I)}function d(I){const G=r.events[r.events.length-1];return a=G&&G[1].type==="linePrefix"?G[2].sliceSerialize(G[1],!0).length:0,c=I,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(I)}function h(I){return I===c?(o++,e.consume(I),h):o<3?n(I):(e.exit("codeFencedFenceSequence"),tt(I)?ot(e,p,"whitespace")(I):p(I))}function p(I){return I===null||Le(I)?(e.exit("codeFencedFence"),r.interrupt?t(I):e.check(Nh,S,F)(I)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(I))}function g(I){return I===null||Le(I)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(I)):tt(I)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ot(e,m,"whitespace")(I)):I===96&&I===c?n(I):(e.consume(I),g)}function m(I){return I===null||Le(I)?p(I):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(I))}function y(I){return I===null||Le(I)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(I)):I===96&&I===c?n(I):(e.consume(I),y)}function S(I){return e.attempt(i,F,j)(I)}function j(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),x}function x(I){return a>0&&tt(I)?ot(e,A,"linePrefix",a+1)(I):A(I)}function A(I){return I===null||Le(I)?e.check(Nh,S,F)(I):(e.enter("codeFlowValue"),T(I))}function T(I){return I===null||Le(I)?(e.exit("codeFlowValue"),A(I)):(e.consume(I),T)}function F(I){return e.exit("codeFenced"),t(I)}function R(I,G,z){let L=0;return E;function E(X){return I.enter("lineEnding"),I.consume(X),I.exit("lineEnding"),H}function H(X){return I.enter("codeFencedFence"),tt(X)?ot(I,B,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(X):B(X)}function B(X){return X===c?(I.enter("codeFencedFenceSequence"),oe(X)):z(X)}function oe(X){return X===c?(L++,I.consume(X),oe):L>=o?(I.exit("codeFencedFenceSequence"),tt(X)?ot(I,K,"whitespace")(X):K(X)):z(X)}function K(X){return X===null||Le(X)?(I.exit("codeFencedFence"),G(X)):z(X)}}}function XS(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Gl={name:"codeIndented",tokenize:QS},JS={partial:!0,tokenize:ZS};function QS(e,t,n){const r=this;return i;function i(d){return e.enter("codeIndented"),ot(e,a,"linePrefix",5)(d)}function a(d){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?o(d):n(d)}function o(d){return d===null?u(d):Le(d)?e.attempt(JS,o,u)(d):(e.enter("codeFlowValue"),c(d))}function c(d){return d===null||Le(d)?(e.exit("codeFlowValue"),o(d)):(e.consume(d),c)}function u(d){return e.exit("codeIndented"),t(d)}}function ZS(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):Le(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):ot(e,a,"linePrefix",5)(o)}function a(o){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(o):Le(o)?i(o):n(o)}}const eC={name:"codeText",previous:nC,resolve:tC,tokenize:rC};function tC(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function nC(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function rC(e,t,n){let r=0,i,a;return o;function o(p){return e.enter("codeText"),e.enter("codeTextSequence"),c(p)}function c(p){return p===96?(e.consume(p),r++,c):(e.exit("codeTextSequence"),u(p))}function u(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),u):p===96?(a=e.enter("codeTextSequence"),i=0,h(p)):Le(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("codeTextData"),d(p))}function d(p){return p===null||p===32||p===96||Le(p)?(e.exit("codeTextData"),u(p)):(e.consume(p),d)}function h(p){return p===96?(e.consume(p),i++,h):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(a.type="codeTextData",d(p))}}class sC{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Gi(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Gi(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Gi(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Gi(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Gi(this.left,n.reverse())}}}function Gi(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function ag(e){const t={};let n=-1,r,i,a,o,c,u,d;const h=new sC(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,a=0,a<u.length&&u[a][1].type==="lineEndingBlank"&&(a+=2),a<u.length&&u[a][1].type==="content"))for(;++a<u.length&&u[a][1].type!=="content";)u[a][1].type==="chunkText"&&(u[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,iC(h,n)),n=t[n],d=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=h.get(a),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(h.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=a);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...h.get(i)[1].start},c=h.slice(i,n),c.unshift(r),h.splice(i,n-i+1,c))}}return Fn(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!d}function iC(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const c=o.events,u=[],d={};let h,p,g=-1,m=n,y=0,S=0;const j=[S];for(;m;){for(;e.get(++i)[1]!==m;);a.push(i),m._tokenizer||(h=r.sliceStream(m),m.next||h.push(null),p&&o.defineSkip(m.start),m._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(h),m._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),p=m,m=m.next}for(m=n;++g<c.length;)c[g][0]==="exit"&&c[g-1][0]==="enter"&&c[g][1].type===c[g-1][1].type&&c[g][1].start.line!==c[g][1].end.line&&(S=g+1,j.push(S),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(o.events=[],m?(m._tokenizer=void 0,m.previous=void 0):j.pop(),g=j.length;g--;){const x=c.slice(j[g],j[g+1]),A=a.pop();u.push([A,A+x.length-1]),e.splice(A,2,x)}for(u.reverse(),g=-1;++g<u.length;)d[y+u[g][0]]=y+u[g][1],y+=u[g][1]-u[g][0]-1;return d}const aC={resolve:lC,tokenize:cC},oC={partial:!0,tokenize:uC};function lC(e){return ag(e),e}function cC(e,t){let n;return r;function r(c){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(c)}function i(c){return c===null?a(c):Le(c)?e.check(oC,o,a)(c):(e.consume(c),i)}function a(c){return e.exit("chunkContent"),e.exit("content"),t(c)}function o(c){return e.consume(c),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function uC(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),ot(e,a,"linePrefix")}function a(o){if(o===null||Le(o))return n(o);const c=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function og(e,t,n,r,i,a,o,c,u){const d=u||Number.POSITIVE_INFINITY;let h=0;return p;function p(x){return x===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(x),e.exit(a),g):x===null||x===32||x===41||Bo(x)?n(x):(e.enter(r),e.enter(o),e.enter(c),e.enter("chunkString",{contentType:"string"}),S(x))}function g(x){return x===62?(e.enter(a),e.consume(x),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),m(x))}function m(x){return x===62?(e.exit("chunkString"),e.exit(c),g(x)):x===null||x===60||Le(x)?n(x):(e.consume(x),x===92?y:m)}function y(x){return x===60||x===62||x===92?(e.consume(x),m):m(x)}function S(x){return!h&&(x===null||x===41||jt(x))?(e.exit("chunkString"),e.exit(c),e.exit(o),e.exit(r),t(x)):h<d&&x===40?(e.consume(x),h++,S):x===41?(e.consume(x),h--,S):x===null||x===32||x===40||Bo(x)?n(x):(e.consume(x),x===92?j:S)}function j(x){return x===40||x===41||x===92?(e.consume(x),S):S(x)}}function lg(e,t,n,r,i,a){const o=this;let c=0,u;return d;function d(m){return e.enter(r),e.enter(i),e.consume(m),e.exit(i),e.enter(a),h}function h(m){return c>999||m===null||m===91||m===93&&!u||m===94&&!c&&"_hiddenFootnoteSupport"in o.parser.constructs?n(m):m===93?(e.exit(a),e.enter(i),e.consume(m),e.exit(i),e.exit(r),t):Le(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),p(m))}function p(m){return m===null||m===91||m===93||Le(m)||c++>999?(e.exit("chunkString"),h(m)):(e.consume(m),u||(u=!tt(m)),m===92?g:p)}function g(m){return m===91||m===92||m===93?(e.consume(m),c++,p):p(m)}}function cg(e,t,n,r,i,a){let o;return c;function c(g){return g===34||g===39||g===40?(e.enter(r),e.enter(i),e.consume(g),e.exit(i),o=g===40?41:g,u):n(g)}function u(g){return g===o?(e.enter(i),e.consume(g),e.exit(i),e.exit(r),t):(e.enter(a),d(g))}function d(g){return g===o?(e.exit(a),u(o)):g===null?n(g):Le(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),ot(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(g))}function h(g){return g===o||g===null||Le(g)?(e.exit("chunkString"),d(g)):(e.consume(g),g===92?p:h)}function p(g){return g===o||g===92?(e.consume(g),h):h(g)}}function ia(e,t){let n;return r;function r(i){return Le(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):tt(i)?ot(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const dC={name:"definition",tokenize:pC},hC={partial:!0,tokenize:fC};function pC(e,t,n){const r=this;let i;return a;function a(m){return e.enter("definition"),o(m)}function o(m){return lg.call(r,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function c(m){return i=or(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),u):n(m)}function u(m){return jt(m)?ia(e,d)(m):d(m)}function d(m){return og(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function h(m){return e.attempt(hC,p,p)(m)}function p(m){return tt(m)?ot(e,g,"whitespace")(m):g(m)}function g(m){return m===null||Le(m)?(e.exit("definition"),r.parser.defined.push(i),t(m)):n(m)}}function fC(e,t,n){return r;function r(c){return jt(c)?ia(e,i)(c):n(c)}function i(c){return cg(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function a(c){return tt(c)?ot(e,o,"whitespace")(c):o(c)}function o(c){return c===null||Le(c)?t(c):n(c)}}const mC={name:"hardBreakEscape",tokenize:gC};function gC(e,t,n){return r;function r(a){return e.enter("hardBreakEscape"),e.consume(a),i}function i(a){return Le(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const bC={name:"headingAtx",resolve:kC,tokenize:yC};function kC(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},a={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Fn(e,r,n-r+1,[["enter",i,t],["enter",a,t],["exit",a,t],["exit",i,t]])),e}function yC(e,t,n){let r=0;return i;function i(h){return e.enter("atxHeading"),a(h)}function a(h){return e.enter("atxHeadingSequence"),o(h)}function o(h){return h===35&&r++<6?(e.consume(h),o):h===null||jt(h)?(e.exit("atxHeadingSequence"),c(h)):n(h)}function c(h){return h===35?(e.enter("atxHeadingSequence"),u(h)):h===null||Le(h)?(e.exit("atxHeading"),t(h)):tt(h)?ot(e,c,"whitespace")(h):(e.enter("atxHeadingText"),d(h))}function u(h){return h===35?(e.consume(h),u):(e.exit("atxHeadingSequence"),c(h))}function d(h){return h===null||h===35||jt(h)?(e.exit("atxHeadingText"),c(h)):(e.consume(h),d)}}const xC=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Th=["pre","script","style","textarea"],wC={concrete:!0,name:"htmlFlow",resolveTo:CC,tokenize:NC},vC={partial:!0,tokenize:TC},SC={partial:!0,tokenize:jC};function CC(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function NC(e,t,n){const r=this;let i,a,o,c,u;return d;function d(N){return h(N)}function h(N){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(N),p}function p(N){return N===33?(e.consume(N),g):N===47?(e.consume(N),a=!0,S):N===63?(e.consume(N),i=3,r.interrupt?t:C):wn(N)?(e.consume(N),o=String.fromCharCode(N),j):n(N)}function g(N){return N===45?(e.consume(N),i=2,m):N===91?(e.consume(N),i=5,c=0,y):wn(N)?(e.consume(N),i=4,r.interrupt?t:C):n(N)}function m(N){return N===45?(e.consume(N),r.interrupt?t:C):n(N)}function y(N){const be="CDATA[";return N===be.charCodeAt(c++)?(e.consume(N),c===be.length?r.interrupt?t:B:y):n(N)}function S(N){return wn(N)?(e.consume(N),o=String.fromCharCode(N),j):n(N)}function j(N){if(N===null||N===47||N===62||jt(N)){const be=N===47,ne=o.toLowerCase();return!be&&!a&&Th.includes(ne)?(i=1,r.interrupt?t(N):B(N)):xC.includes(o.toLowerCase())?(i=6,be?(e.consume(N),x):r.interrupt?t(N):B(N)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(N):a?A(N):T(N))}return N===45||fn(N)?(e.consume(N),o+=String.fromCharCode(N),j):n(N)}function x(N){return N===62?(e.consume(N),r.interrupt?t:B):n(N)}function A(N){return tt(N)?(e.consume(N),A):E(N)}function T(N){return N===47?(e.consume(N),E):N===58||N===95||wn(N)?(e.consume(N),F):tt(N)?(e.consume(N),T):E(N)}function F(N){return N===45||N===46||N===58||N===95||fn(N)?(e.consume(N),F):R(N)}function R(N){return N===61?(e.consume(N),I):tt(N)?(e.consume(N),R):T(N)}function I(N){return N===null||N===60||N===61||N===62||N===96?n(N):N===34||N===39?(e.consume(N),u=N,G):tt(N)?(e.consume(N),I):z(N)}function G(N){return N===u?(e.consume(N),u=null,L):N===null||Le(N)?n(N):(e.consume(N),G)}function z(N){return N===null||N===34||N===39||N===47||N===60||N===61||N===62||N===96||jt(N)?R(N):(e.consume(N),z)}function L(N){return N===47||N===62||tt(N)?T(N):n(N)}function E(N){return N===62?(e.consume(N),H):n(N)}function H(N){return N===null||Le(N)?B(N):tt(N)?(e.consume(N),H):n(N)}function B(N){return N===45&&i===2?(e.consume(N),Y):N===60&&i===1?(e.consume(N),D):N===62&&i===4?(e.consume(N),_e):N===63&&i===3?(e.consume(N),C):N===93&&i===5?(e.consume(N),le):Le(N)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(vC,Z,oe)(N)):N===null||Le(N)?(e.exit("htmlFlowData"),oe(N)):(e.consume(N),B)}function oe(N){return e.check(SC,K,Z)(N)}function K(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),X}function X(N){return N===null||Le(N)?oe(N):(e.enter("htmlFlowData"),B(N))}function Y(N){return N===45?(e.consume(N),C):B(N)}function D(N){return N===47?(e.consume(N),o="",V):B(N)}function V(N){if(N===62){const be=o.toLowerCase();return Th.includes(be)?(e.consume(N),_e):B(N)}return wn(N)&&o.length<8?(e.consume(N),o+=String.fromCharCode(N),V):B(N)}function le(N){return N===93?(e.consume(N),C):B(N)}function C(N){return N===62?(e.consume(N),_e):N===45&&i===2?(e.consume(N),C):B(N)}function _e(N){return N===null||Le(N)?(e.exit("htmlFlowData"),Z(N)):(e.consume(N),_e)}function Z(N){return e.exit("htmlFlow"),t(N)}}function jC(e,t,n){const r=this;return i;function i(o){return Le(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function TC(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Ca,t,n)}}const IC={name:"htmlText",tokenize:EC};function EC(e,t,n){const r=this;let i,a,o;return c;function c(C){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(C),u}function u(C){return C===33?(e.consume(C),d):C===47?(e.consume(C),R):C===63?(e.consume(C),T):wn(C)?(e.consume(C),z):n(C)}function d(C){return C===45?(e.consume(C),h):C===91?(e.consume(C),a=0,y):wn(C)?(e.consume(C),A):n(C)}function h(C){return C===45?(e.consume(C),m):n(C)}function p(C){return C===null?n(C):C===45?(e.consume(C),g):Le(C)?(o=p,D(C)):(e.consume(C),p)}function g(C){return C===45?(e.consume(C),m):p(C)}function m(C){return C===62?Y(C):C===45?g(C):p(C)}function y(C){const _e="CDATA[";return C===_e.charCodeAt(a++)?(e.consume(C),a===_e.length?S:y):n(C)}function S(C){return C===null?n(C):C===93?(e.consume(C),j):Le(C)?(o=S,D(C)):(e.consume(C),S)}function j(C){return C===93?(e.consume(C),x):S(C)}function x(C){return C===62?Y(C):C===93?(e.consume(C),x):S(C)}function A(C){return C===null||C===62?Y(C):Le(C)?(o=A,D(C)):(e.consume(C),A)}function T(C){return C===null?n(C):C===63?(e.consume(C),F):Le(C)?(o=T,D(C)):(e.consume(C),T)}function F(C){return C===62?Y(C):T(C)}function R(C){return wn(C)?(e.consume(C),I):n(C)}function I(C){return C===45||fn(C)?(e.consume(C),I):G(C)}function G(C){return Le(C)?(o=G,D(C)):tt(C)?(e.consume(C),G):Y(C)}function z(C){return C===45||fn(C)?(e.consume(C),z):C===47||C===62||jt(C)?L(C):n(C)}function L(C){return C===47?(e.consume(C),Y):C===58||C===95||wn(C)?(e.consume(C),E):Le(C)?(o=L,D(C)):tt(C)?(e.consume(C),L):Y(C)}function E(C){return C===45||C===46||C===58||C===95||fn(C)?(e.consume(C),E):H(C)}function H(C){return C===61?(e.consume(C),B):Le(C)?(o=H,D(C)):tt(C)?(e.consume(C),H):L(C)}function B(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),i=C,oe):Le(C)?(o=B,D(C)):tt(C)?(e.consume(C),B):(e.consume(C),K)}function oe(C){return C===i?(e.consume(C),i=void 0,X):C===null?n(C):Le(C)?(o=oe,D(C)):(e.consume(C),oe)}function K(C){return C===null||C===34||C===39||C===60||C===61||C===96?n(C):C===47||C===62||jt(C)?L(C):(e.consume(C),K)}function X(C){return C===47||C===62||jt(C)?L(C):n(C)}function Y(C){return C===62?(e.consume(C),e.exit("htmlTextData"),e.exit("htmlText"),t):n(C)}function D(C){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),V}function V(C){return tt(C)?ot(e,le,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):le(C)}function le(C){return e.enter("htmlTextData"),o(C)}}const zu={name:"labelEnd",resolveAll:AC,resolveTo:LC,tokenize:_C},MC={tokenize:DC},RC={tokenize:BC},PC={tokenize:OC};function AC(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&Fn(e,0,e.length,n),e}function LC(e,t){let n=e.length,r=0,i,a,o,c;for(;n--;)if(i=e[n][1],a){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(a=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const u={type:e[a][1].type==="labelLink"?"link":"image",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[a][1].start},end:{...e[o][1].end}},h={type:"labelText",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return c=[["enter",u,t],["enter",d,t]],c=Kn(c,e.slice(a+1,a+r+3)),c=Kn(c,[["enter",h,t]]),c=Kn(c,il(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),c=Kn(c,[["exit",h,t],e[o-2],e[o-1],["exit",d,t]]),c=Kn(c,e.slice(o+1)),c=Kn(c,[["exit",u,t]]),Fn(e,a,e.length,c),e}function _C(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return c;function c(g){return a?a._inactive?p(g):(o=r.parser.defined.includes(or(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),u):n(g)}function u(g){return g===40?e.attempt(MC,h,o?h:p)(g):g===91?e.attempt(RC,h,o?d:p)(g):o?h(g):p(g)}function d(g){return e.attempt(PC,h,p)(g)}function h(g){return t(g)}function p(g){return a._balanced=!0,n(g)}}function DC(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),i}function i(p){return jt(p)?ia(e,a)(p):a(p)}function a(p){return p===41?h(p):og(e,o,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function o(p){return jt(p)?ia(e,u)(p):h(p)}function c(p){return n(p)}function u(p){return p===34||p===39||p===40?cg(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):h(p)}function d(p){return jt(p)?ia(e,h)(p):h(p)}function h(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function BC(e,t,n){const r=this;return i;function i(c){return lg.call(r,e,a,o,"reference","referenceMarker","referenceString")(c)}function a(c){return r.parser.defined.includes(or(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function o(c){return n(c)}}function OC(e,t,n){return r;function r(a){return e.enter("reference"),e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),i}function i(a){return a===93?(e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),e.exit("reference"),t):n(a)}}const WC={name:"labelStartImage",resolveAll:zu.resolveAll,tokenize:FC};function FC(e,t,n){const r=this;return i;function i(c){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(c),e.exit("labelImageMarker"),a}function a(c){return c===91?(e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelImage"),o):n(c)}function o(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):t(c)}}const $C={name:"labelStartLink",resolveAll:zu.resolveAll,tokenize:zC};function zC(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),a}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Vl={name:"lineEnding",tokenize:HC};function HC(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ot(e,t,"linePrefix")}}const jo={name:"thematicBreak",tokenize:UC};function UC(e,t,n){let r=0,i;return a;function a(d){return e.enter("thematicBreak"),o(d)}function o(d){return i=d,c(d)}function c(d){return d===i?(e.enter("thematicBreakSequence"),u(d)):r>=3&&(d===null||Le(d))?(e.exit("thematicBreak"),t(d)):n(d)}function u(d){return d===i?(e.consume(d),r++,u):(e.exit("thematicBreakSequence"),tt(d)?ot(e,c,"whitespace")(d):c(d))}}const En={continuation:{tokenize:KC},exit:XC,name:"list",tokenize:VC},qC={partial:!0,tokenize:JC},GC={partial:!0,tokenize:YC};function VC(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return c;function c(m){const y=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:Fc(m)){if(r.containerState.type||(r.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),m===42||m===45?e.check(jo,n,d)(m):d(m);if(!r.interrupt||m===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(m)}return n(m)}function u(m){return Fc(m)&&++o<10?(e.consume(m),u):(!r.interrupt||o<2)&&(r.containerState.marker?m===r.containerState.marker:m===41||m===46)?(e.exit("listItemValue"),d(m)):n(m)}function d(m){return e.enter("listItemMarker"),e.consume(m),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||m,e.check(Ca,r.interrupt?n:h,e.attempt(qC,g,p))}function h(m){return r.containerState.initialBlankLine=!0,a++,g(m)}function p(m){return tt(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),g):n(m)}function g(m){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function KC(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Ca,i,a);function i(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ot(e,t,"listItemIndent",r.containerState.size+1)(c)}function a(c){return r.containerState.furtherBlankLines||!tt(c)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(c)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(GC,t,o)(c))}function o(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,ot(e,e.attempt(En,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function YC(e,t,n){const r=this;return ot(e,i,"listItemIndent",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function XC(e){e.exit(this.containerState.type)}function JC(e,t,n){const r=this;return ot(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!tt(a)&&o&&o[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const Ih={name:"setextUnderline",resolveTo:QC,tokenize:ZC};function QC(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!a&&e[n][1].type==="definition"&&(a=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",a?(e.splice(i,0,["enter",o,t]),e.splice(a+1,0,["exit",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function ZC(e,t,n){const r=this;let i;return a;function a(d){let h=r.events.length,p;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){p=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(e.enter("setextHeadingLine"),i=d,o(d)):n(d)}function o(d){return e.enter("setextHeadingLineSequence"),c(d)}function c(d){return d===i?(e.consume(d),c):(e.exit("setextHeadingLineSequence"),tt(d)?ot(e,u,"lineSuffix")(d):u(d))}function u(d){return d===null||Le(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const e0={tokenize:t0};function t0(e){const t=this,n=e.attempt(Ca,r,e.attempt(this.parser.constructs.flowInitial,i,ot(e,e.attempt(this.parser.constructs.flow,i,e.attempt(aC,i)),"linePrefix")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const n0={resolveAll:dg()},r0=ug("string"),s0=ug("text");function ug(e){return{resolveAll:dg(e==="text"?i0:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,c);return o;function o(h){return d(h)?a(h):c(h)}function c(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),u}function u(h){return d(h)?(n.exit("data"),a(h)):(n.consume(h),u)}function d(h){if(h===null)return!0;const p=i[h];let g=-1;if(p)for(;++g<p.length;){const m=p[g];if(!m.previous||m.previous.call(r,r.previous))return!0}return!1}}}function dg(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type==="data"&&(a=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function i0(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,c=0,u;for(;a--;){const d=i[a];if(typeof d=="string"){for(o=d.length;d.charCodeAt(o-1)===32;)c++,o--;if(o)break;o=-1}else if(d===-2)u=!0,c++;else if(d!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const d={type:n===e.length||u||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-c,offset:r.end.offset-c},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const a0={42:En,43:En,45:En,48:En,49:En,50:En,51:En,52:En,53:En,54:En,55:En,56:En,57:En,62:rg},o0={91:dC},l0={[-2]:Gl,[-1]:Gl,32:Gl},c0={35:bC,42:jo,45:[Ih,jo],60:wC,61:Ih,95:jo,96:jh,126:jh},u0={38:ig,92:sg},d0={[-5]:Vl,[-4]:Vl,[-3]:Vl,33:WC,38:ig,42:$c,60:[$S,IC],91:$C,92:[mC,sg],93:zu,95:$c,96:eC},h0={null:[$c,n0]},p0={null:[42,95]},f0={null:[]},m0=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:p0,contentInitial:o0,disable:f0,document:a0,flow:c0,flowInitial:l0,insideSpan:h0,string:u0,text:d0},Symbol.toStringTag,{value:"Module"}));function g0(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],c=[];const u={attempt:G(R),check:G(I),consume:A,enter:T,exit:F,interrupt:G(I,{interrupt:!0})},d={code:null,containerState:{},defineSkip:S,events:[],now:y,parser:e,previous:null,sliceSerialize:g,sliceStream:m,write:p};let h=t.tokenize.call(d,u);return t.resolveAll&&a.push(t),d;function p(H){return o=Kn(o,H),j(),o[o.length-1]!==null?[]:(z(t,0),d.events=il(a,d.events,d),d.events)}function g(H,B){return k0(m(H),B)}function m(H){return b0(o,H)}function y(){const{_bufferIndex:H,_index:B,line:oe,column:K,offset:X}=r;return{_bufferIndex:H,_index:B,line:oe,column:K,offset:X}}function S(H){i[H.line]=H.column,E()}function j(){let H;for(;r._index<o.length;){const B=o[r._index];if(typeof B=="string")for(H=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===H&&r._bufferIndex<B.length;)x(B.charCodeAt(r._bufferIndex));else x(B)}}function x(H){h=h(H)}function A(H){Le(H)?(r.line++,r.column=1,r.offset+=H===-3?2:1,E()):H!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=H}function T(H,B){const oe=B||{};return oe.type=H,oe.start=y(),d.events.push(["enter",oe,d]),c.push(oe),oe}function F(H){const B=c.pop();return B.end=y(),d.events.push(["exit",B,d]),B}function R(H,B){z(H,B.from)}function I(H,B){B.restore()}function G(H,B){return oe;function oe(K,X,Y){let D,V,le,C;return Array.isArray(K)?Z(K):"tokenize"in K?Z([K]):_e(K);function _e(fe){return ue;function ue(He){const Ue=He!==null&&fe[He],je=He!==null&&fe.null,Te=[...Array.isArray(Ue)?Ue:Ue?[Ue]:[],...Array.isArray(je)?je:je?[je]:[]];return Z(Te)(He)}}function Z(fe){return D=fe,V=0,fe.length===0?Y:N(fe[V])}function N(fe){return ue;function ue(He){return C=L(),le=fe,fe.partial||(d.currentConstruct=fe),fe.name&&d.parser.constructs.disable.null.includes(fe.name)?ne():fe.tokenize.call(B?Object.assign(Object.create(d),B):d,u,be,ne)(He)}}function be(fe){return H(le,C),X}function ne(fe){return C.restore(),++V<D.length?N(D[V]):Y}}}function z(H,B){H.resolveAll&&!a.includes(H)&&a.push(H),H.resolve&&Fn(d.events,B,d.events.length-B,H.resolve(d.events.slice(B),d)),H.resolveTo&&(d.events=H.resolveTo(d.events,d))}function L(){const H=y(),B=d.previous,oe=d.currentConstruct,K=d.events.length,X=Array.from(c);return{from:K,restore:Y};function Y(){r=H,d.previous=B,d.currentConstruct=oe,d.events.length=K,c=X,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function b0(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){const c=o[0];typeof c=="string"?o[0]=c.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function k0(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let o;if(typeof a=="string")o=a;else switch(a){case-5:{o="\r";break}case-4:{o=`
@@ -68,7 +68,7 @@ endobj
68
68
  `;d.push(j),p+=new TextEncoder().encode(j).length}const g=p,m=["xref",`0 ${u+1}`,"0000000000 65535 f "];for(let y=1;y<h.length;y+=1){const S=h[y];typeof S=="number"&&m.push(`${String(S).padStart(10,"0")} 00000 n `)}return d.push(`${m.join(`
69
69
  `)}
70
70
  `),d.push(["trailer",`<< /Size ${u+1} /Root 1 0 R >>`,"startxref",String(g),"%%EOF"].join(`
71
- `)),new TextEncoder().encode(d.join(""))}const _p=48;function tR(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function ld(e,t){const n=tR(e)||t,r=n.length>_p?n.slice(0,_p).trimEnd():n;return{fullTitle:n,displayTitle:r}}function co(e,t){return(t??"").localeCompare(e??"")}function Dp(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function uo(e){return(e==null?void 0:e.trim())??""}function ya(e,t,n){if(n==="updatedAt"){const o=co(e.updatedAt,t.updatedAt);if(o!==0)return o}if(n==="title"){const o=Dp(uo(e.title),uo(t.title));if(o!==0)return o}else{const o=co(e.createdAt,t.createdAt);if(o!==0)return o}const r=co(e.updatedAt,t.updatedAt);if(r!==0)return r;const i=co(e.createdAt,t.createdAt);if(i!==0)return i;const a=Dp(uo(e.title),uo(t.title));return a!==0?a:e.sessionId.localeCompare(t.sessionId)}function Ta(e,t){return[...e].sort((n,r)=>ya(n,r,t))}function cd(e,t){return Array.isArray(e)?e.map(n=>({...n,sessions:Ta(n.sessions,t),children:cd(n.children,t)})):[]}const mc=5,gc=["#2563eb","#0891b2","#16a34a","#d97706","#dc2626","#64748b"];function nR(e){const t=Math.round(e.ratio*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}function rR(e,t){const n=e.reduce((c,u)=>c+u.count,0);if(n<=0)return[];const i=e.slice(0,mc).map((c,u)=>({...c,key:c.type,ratio:c.count/n,color:gc[u]??gc[0]})),a=e.slice(mc);if(a.length===0)return i;const o=a.reduce((c,u)=>c+u.count,0);return i.push({key:"other",type:t,count:o,ratio:o/n,color:gc[mc]}),i}function sR(e){if(e.length===0)return"conic-gradient(color-mix(in srgb, var(--border-primary) 78%, transparent) 0% 100%)";let t=0;return`conic-gradient(${e.map((r,i)=>{const a=t,o=i===e.length-1?1:Math.min(1,t+r.ratio);return t=o,`${r.color} ${Bp(a)} ${Bp(o)}`}).join(", ")})`}function iR(e){return{"--workbench-manage-chart-background":sR(e)}}function Bp(e){const t=Math.round(e*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}const aR=8,oR=12,lR=160,Op=96;function cR(e,t,n,r={}){const i=r.gapPx??aR,a=r.viewportMarginPx??oR,o=r.defaultWidthPx??lR,c=r.estimatedHeightPx??Op,u=r.minHeightPx??Op,d=Math.max(0,n.width),h=Math.max(0,n.height),p=Math.max(0,h-a*2),g=Math.max(0,d-a*2),m=ho(Math.max(t.width||o,o),0,g),y=Math.max(t.height||c,c),S=Math.max(0,d-e.x-a),j=Math.max(0,e.x-a),x=S<m&&j>S,A=Math.max(0,h-e.y-i-a),T=Math.max(0,e.y-i-a),F=A<y&&T>A,I=ho(Math.max(F?T:A,u),0,p),G=Math.min(y,I),z=x?e.x-m:e.x,L=Math.max(a,d-a-m),E=F?e.y-i-G:e.y+i,H=Math.max(a,h-a-G),B=ho(z,a,L),oe=ho(E,a,H),K=x||B<e.x?"right":"left";return{top:oe,left:B,width:m,maxHeight:Math.max(0,I),transformOrigin:`${F?"bottom":"top"} ${K}`}}function ho(e,t,n){return!Number.isFinite(e)||n<t?t:Math.min(Math.max(e,t),n)}const Vb="workbench.navigation.snapshot",Kb=1800*1e3,uR="workbench.navigation.snapshot.host.";function Yb(e){return`${uR}${e}`}function dR(e=Kb,t=Zo(ar.getState())){if(t){const n=Ao(Yb(t),e);if(n)return n}return Ao(Vb,e)}function po(e,t=Zo(ar.getState())){ra(Vb,e),t&&ra(Yb(t),e)}function Wp(e,t="createdAt"){return!e||!Array.isArray(e.items)?[]:e.items.map(n=>({workspace:n.workspace,sessions:Ta(n.sessions,t),childWorktrees:hR(n.childWorktrees,t)}))}function hR(e,t){return cd(e,t)}function Jo(e){return{workspaceId:e.id,tone:"root",backgroundColor:e.backgroundColor??null,displayName:e.name,workspaceName:e.name,branchName:null,depth:0,rootWorkspaceId:e.id,rootDisplayName:e.name,parentWorkspaceId:null,parentDisplayName:null}}function pR(e){const t=new Map;for(const n of e)t.set(n.workspace.id,Jo(n.workspace)),Xb(t,n.childWorktrees??[],n.workspace,n.workspace);return Object.fromEntries(t)}function Wr(e){if(e!=null&&e.backgroundColor)return{"--workspace-tone-color":e.backgroundColor}}function Xb(e,t,n,r,i=r.name){var a;for(const o of t){const c=((a=o.meta.displayName)==null?void 0:a.trim())||o.workspace.name;e.set(o.workspace.id,{workspaceId:o.workspace.id,tone:"worktree",backgroundColor:o.workspace.backgroundColor??null,displayName:c,workspaceName:o.workspace.name,branchName:o.meta.branchName||null,depth:o.meta.depth,rootWorkspaceId:n.id,rootDisplayName:n.name,parentWorkspaceId:o.meta.parentWorkspaceId||r.id,parentDisplayName:i}),Xb(e,o.children,n,o.workspace,c)}}class au extends Error{constructor(t,n){super(n),this.code=t,this.name="HostSwitchError"}}class fR{constructor(){at(this,"inFlight",null)}async switchHost(t){this.inFlight&&await this.inFlight;const n=this.performSwitch(t).finally(()=>{this.inFlight===n&&(this.inFlight=null)});this.inFlight=n,await n}async performSwitch(t){const n=ar.getState();if(Zo(n)===t)return;const r=Xk(n,t);if(!r)throw new au("HOST_NOT_FOUND",`找不到 HOST:${t}`);if(!(await Jk(r.baseUrl)).reachable)throw new au("HOST_UNREACHABLE",`目标 HOST 不可达:${r.baseUrl}`);const a=Ff(r.id);if(a)try{await ca.loginForHost(r,{username:a.username,password:a.password})}catch{}const o=ar.getState(),c=new Date().toISOString();if($f(r)){ar.updateRuntime({discoveredHosts:o.discoveredHosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeDiscoveredHostId:t});return}Tc.setActiveDiscoveredHost(null),await ar.update({hosts:o.hosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeHostId:t})}}const mR=new fR,gR=1700;function bR({open:e,id:t,role:n="dialog",labelledBy:r,className:i,anchorRef:a,popoverRef:o,children:c,maxWidth:u=360,gap:d=10,viewportPadding:h=16}){const[p,g]=f.useState(null);if(f.useEffect(()=>{if(!e||typeof window>"u"||typeof document>"u"){g(null);return}let y=0;const S=()=>{const x=a.current;if(!x)return;const A=x.getBoundingClientRect(),T=Math.max(180,Math.min(u,window.innerWidth-h*2)),F=Math.min(Math.max(h,A.right-T),Math.max(h,window.innerWidth-h-T)),R=A.top>=Math.min(240,window.innerHeight*.42),I=Math.round(R?A.top-d:A.bottom+d);g({top:I,left:Math.round(F),width:T,placeAbove:R})},j=()=>{window.cancelAnimationFrame(y),y=window.requestAnimationFrame(S)};return S(),window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.cancelAnimationFrame(y),window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[a,d,u,e,h]),!e||!p||typeof document>"u")return null;const m={position:"fixed",top:p.top,left:p.left,width:p.width,maxWidth:`calc(100vw - ${h*2}px)`,zIndex:gR,transform:p.placeAbove?"translateY(-100%)":void 0};return Fr.createPortal(s.jsx("div",{id:t,ref:o,role:n,"aria-labelledby":r,className:i,"data-placement":p.placeAbove?"top":"bottom",style:m,children:c}),document.body)}const bc={status:"idle",latencyMs:null};function Jb({collapsed:e=!1}){const[t,n]=f.useState(!1),[r,i]=f.useState(!1),[a,o]=f.useState(""),[c,u]=f.useState(""),[d,h]=f.useState(""),[p,g]=f.useState(""),[m,y]=f.useState(null),[S,j]=f.useState(null),[x,A]=f.useState(null),[T,F]=f.useState(!1),[R,I]=f.useState(!1),[G,z]=f.useState(bc),[L,E]=f.useState(null),H=f.useRef(null),B=f.useRef(null),oe=f.useRef(null),K=f.useRef(null),X=gu(O=>O),Y=fu(O=>O.session),{showToast:D}=lr(),V=Ic(X),le=Zo(X),C=ly(),_e=Qk(le),Z=f.useMemo(()=>Fp(X.hosts,le),[le,X.hosts]),N=f.useMemo(()=>Fp(zf(X),le),[le,X]),be=f.useCallback(()=>{if(typeof window>"u")return;const O=H.current;if(!O)return;const q=O.getBoundingClientRect(),J=window.innerWidth,Ce=window.innerHeight,Ee=16,ve=8,nt=Math.min(320,Math.max(240,J-Ee*2)),mt=Math.min(e?Math.max(Ee,q.right+ve):Math.max(Ee,q.left),Math.max(Ee,J-nt-Ee)),ae=r?440:240,se=e?q.top:q.bottom+ve,ke=Math.min(Math.max(Ee,se),Math.max(Ee,Ce-ae-Ee));E({position:"fixed",top:ke,left:mt,width:nt,maxWidth:J-Ee*2})},[e,r]);f.useEffect(()=>{if(!t){E(null),F(!1),z(bc);return}Tc.refresh();function O(J){var Ce,Ee,ve;J.target instanceof Node&&!((Ce=H.current)!=null&&Ce.contains(J.target))&&!((Ee=B.current)!=null&&Ee.contains(J.target))&&!((ve=K.current)!=null&&ve.contains(J.target))&&(n(!1),i(!1),F(!1),A(null))}function q(J){J.key==="Escape"&&(n(!1),i(!1),F(!1),A(null))}return window.addEventListener("pointerdown",O),window.addEventListener("keydown",q),window.addEventListener("resize",be),window.addEventListener("scroll",be,!0),be(),()=>{window.removeEventListener("pointerdown",O),window.removeEventListener("keydown",q),window.removeEventListener("resize",be),window.removeEventListener("scroll",be,!0)}},[t,be]),f.useEffect(()=>{if(!T||!t||(C==null?void 0:C.kind)!=="relay"){z(bc);return}let O=!1;const q=performance.now();return z({status:"probing",latencyMs:null}),pe.request("/api/client/runtime-config").then(()=>{O||z({status:"ready",latencyMs:performance.now()-q})}).catch(()=>{O||z({status:"error",latencyMs:null})}),()=>{O=!0}},[C==null?void 0:C.kind,T,t]);async function ne(O){if(m||S||O.id===le){n(!1);return}y(O.id);try{await mR.switchHost(O.id),n(!1),i(!1),F(!1),A(null)}catch(q){D({title:vR(q,O.name),tone:"error"})}finally{y(null)}}async function fe(O){if(!(O.id===le||m||S)){if(x!==O.id){A(O.id);return}j(O.id);try{await ar.update({hosts:X.hosts.filter(q=>q.id!==O.id)}),Zk(O.id),ca.clearHostSession(O.id),A(null),D({title:l("shell.hostDeleteSuccess",{name:O.name})})}catch{D({title:l("shell.hostDeleteFailed",{name:O.name}),tone:"error"})}finally{j(null)}}}async function ue(){if(R)return;const O=a.trim(),q=d.trim();if((q.length>0||p.length>0)&&(!q||!p)){D({title:l("shell.hostAddIncompleteCredentials"),tone:"error"});return}let Ce;try{Ce=ey(c)}catch{D({title:l("shell.hostAddInvalidUrl"),tone:"error"});return}I(!0);try{const Ee=await Ly(Ce),ve=ar.getState(),Tt=Ic(ve);if(Ee?ve.hosts.find(ke=>{var ye;return ke.baseUrl===Ce||!!Ee.bindingId&&((ye=ke.relayTunnel)==null?void 0:ye.bindingId)===Ee.bindingId}):ve.hosts.find(ke=>ke.baseUrl===Ce)){D({title:l("shell.hostAddDuplicate"),tone:"error"});return}const mt=$f(Tt)&&Tt.baseUrl===Ce;mt&&Tc.setActiveDiscoveredHost(null);let ae,se;if(Ee){const ye=(await ar.update(_y(ve,Ee,{activate:mt,displayName:O}))).hosts.find(Me=>xR(Me,Ce,Ee.bindingId??null));if(!ye)throw new Error("relay entry host missing after save");ae=ye.id,se=ye.name}else{const ke=new Date().toISOString(),ye={id:wR(),name:O||kR(Ce),baseUrl:Ce,kind:yR(Ce),createdAt:ke,updatedAt:ke,lastConnectedAt:null,lastUserId:null,lastUsername:null};await ar.update({hosts:[...ve.hosts,ye],activeHostId:mt?ye.id:ve.activeHostId}),ae=ye.id,se=ye.name}q&&p&&ty({hostId:ae,username:q,password:p}),He(),i(!1),A(null),D({title:l("shell.hostAddSuccess",{name:se})})}catch{D({title:l("shell.hostAddFailed"),tone:"error"})}finally{I(!1)}}function He(){o(""),u(""),h(""),g("")}if(!V)return null;const Ue=Y!=null&&Y.user.username?`${V.baseUrl} · ${Y.user.username}`:V.baseUrl,je=(C==null?void 0:C.kind)==="relay"?l("shell.hostSwitcherDetailStatusRelay"):l("shell.hostSwitcherDetailStatusDirect"),Te=C?l(cy(C.kind)):l("common.unknown");return s.jsxs("div",{ref:H,className:"workbench-host-switcher-anchor","data-collapsed":e,children:[s.jsx("button",{type:"button",className:e?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":l("shell.hostSwitcherAriaLabel"),title:Ue,"aria-expanded":t,onClick:()=>{n(O=>!O),i(!1)},children:s.jsx(NR,{})}),t&&L&&typeof document<"u"?Fr.createPortal(s.jsxs("div",{ref:B,className:"workbench-host-switcher-menu",style:L,role:"menu","aria-label":l("shell.hostSwitcherTitle"),children:[s.jsx("div",{className:"workbench-host-switcher-menu-header",children:s.jsx("strong",{children:l("shell.hostSwitcherTitle")})}),s.jsxs("div",{className:"workbench-host-switcher-list",children:[s.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherSavedSection")}),Z.map(O=>{const q=O.id===le,J=q?(Y==null?void 0:Y.user.username)??O.lastUsername??O.baseUrl:O.lastUsername??O.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":q,children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:m!==null||S!==null,onClick:()=>{ne(O)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[O.name,q?s.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),s.jsx("span",{className:"workbench-host-switcher-item-meta",children:J})]}),s.jsx("span",{className:"workbench-host-switcher-item-trailing",children:m===O.id?l("shell.hostSwitcherSwitching"):q?s.jsx(zp,{}):s.jsx($p,{})})]}),q?s.jsx("button",{ref:oe,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:O.name}),"aria-expanded":T,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{F(Ce=>!Ce),A(null)},children:l("shell.hostSwitcherDetailAction")}):s.jsx("button",{type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostDeleteAriaLabel",{name:O.name}),title:x===O.id?l("shell.hostDeleteConfirmAction"):l("shell.hostDeleteAction"),"data-confirming":x===O.id,disabled:m!==null||S!==null,onClick:()=>{fe(O)},children:S===O.id?l("shell.hostDeleteBusy"):x===O.id?l("shell.hostDeleteConfirmAction"):s.jsx(TR,{})})]},O.id)}),N.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherDiscoveredSection")}),N.map(O=>{const q=O.id===le,J=Ff(O.id),Ce=q?(Y==null?void 0:Y.user.username)??(J==null?void 0:J.username)??O.baseUrl:(J==null?void 0:J.username)??O.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":q,"data-discovered":"true",children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:m!==null||S!==null,onClick:()=>{ne(O)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[O.name,s.jsx("span",{className:"workbench-host-switcher-item-badge","data-tone":"discovered",children:l("shell.hostSwitcherDiscoveredBadge")}),q?s.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),s.jsx("span",{className:"workbench-host-switcher-item-meta",children:Ce})]}),s.jsx("span",{className:"workbench-host-switcher-item-trailing",children:m===O.id?l("shell.hostSwitcherSwitching"):q?s.jsx(zp,{}):s.jsx($p,{})})]}),q?s.jsx("button",{ref:oe,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:O.name}),"aria-expanded":T,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{F(Ee=>!Ee),A(null)},children:l("shell.hostSwitcherDetailAction")}):null]},O.id)})]}):null,X.localHostDiscovery.status==="refreshing"?s.jsx("div",{className:"workbench-host-switcher-state-row",children:l("shell.hostDiscoveryRefreshing")}):null,X.localHostDiscovery.status==="failed"?s.jsx("div",{className:"workbench-host-switcher-state-row","data-tone":"error",children:l("shell.hostDiscoveryFailed")}):null]}),r?s.jsxs("div",{className:"workbench-host-switcher-form",children:[s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("shell.hostSwitcherNameLabel")}),s.jsx("input",{value:a,disabled:R,onChange:O=>o(O.target.value),placeholder:l("shell.hostSwitcherNamePlaceholder")})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("shell.hostSwitcherUrlLabel")}),s.jsx("input",{value:c,disabled:R,onChange:O=>u(O.target.value),placeholder:l("shell.hostSwitcherUrlPlaceholder")})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("auth.username")}),s.jsx("input",{value:d,disabled:R,onChange:O=>h(O.target.value),autoComplete:"username"})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("auth.password")}),s.jsx("input",{type:"password",value:p,disabled:R,onChange:O=>g(O.target.value),autoComplete:"current-password"})]}),s.jsxs("div",{className:"workbench-host-switcher-form-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:R,onClick:()=>{i(!1),He()},children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:R,onClick:()=>{ue()},children:R?l("common.loading"):l("shell.hostSwitcherSaveAction")})]})]}):s.jsxs("button",{type:"button",className:"workbench-host-switcher-add",onClick:()=>{i(!0),A(null)},children:[s.jsx(jR,{}),l("shell.hostSwitcherAddAction")]}),s.jsxs(bR,{open:T&&C!==null&&oe.current!==null,className:"workbench-host-switcher-detail-popover",anchorRef:oe,popoverRef:K,labelledBy:"workbench-host-switcher-detail-title",children:[s.jsx("div",{className:"workbench-host-switcher-detail-header",children:s.jsx("strong",{id:"workbench-host-switcher-detail-title",children:l("shell.hostSwitcherDetailTitle")})}),s.jsxs("div",{className:"workbench-host-switcher-detail-grid",children:[s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailStatusLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:je})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailRouteLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:Te})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailAddressLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value","data-multiline":"true",children:(C==null?void 0:C.url)??V.baseUrl})]}),(C==null?void 0:C.kind)==="relay"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailLatencyLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:SR(G)})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailTrafficLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:CR(_e.totalBytes)})]})]}):null]})]})]}),document.body):null]})}function Fp(e,t){return[...e].sort((n,r)=>{if(n.id===t)return-1;if(r.id===t)return 1;const i=n.lastConnectedAt??n.updatedAt??n.createdAt;return(r.lastConnectedAt??r.updatedAt??r.createdAt).localeCompare(i)})}function kR(e){try{const t=new URL(e),n=t.pathname==="/"?"":t.pathname.replace(/\/+$/,"");return`${t.host}${n}`}catch{return e}}function yR(e){try{const t=new URL(e).hostname.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="[::1]"?"local":/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[0-1])\./.test(t)?"lan":"remote"}catch{return"custom"}}function xR(e,t,n){var r;return!!(e.baseUrl===t||n&&((r=e.relayTunnel)==null?void 0:r.bindingId)===n)}function wR(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`host-${crypto.randomUUID()}`:`host-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function vR(e,t){return e instanceof au?e.code==="HOST_UNREACHABLE"?l("shell.hostSwitchUnreachable",{name:t}):l("shell.hostSwitchMissing"):l("shell.hostSwitchFailed")}function SR(e){return e.status==="probing"?l("shell.hostSwitcherDetailLatencyLoading"):e.status==="error"?l("shell.hostSwitcherDetailUnavailable"):e.status==="ready"?`${Math.max(1,Math.round(e.latencyMs))} ms`:l("shell.hostSwitcherDetailUnavailable")}function CR(e){return!Number.isFinite(e)||e<1024?`${Math.max(0,Math.round(e))} B`:e<1024**2?`${(e/1024).toFixed(1)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}function NR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"4",y:"4.5",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("rect",{x:"4",y:"13",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("path",{d:"M11 7.75h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),s.jsx("path",{d:"M11 16.25h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),s.jsx("circle",{cx:"7.5",cy:"7.75",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"7.5",cy:"16.25",r:"1",fill:"currentColor",stroke:"none"})]})}function $p(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function zp(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function jR(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M8 3.5v9M3.5 8h9",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function TR(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 4.5h9M6.5 2.75h3M5 4.5v7.25a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1V4.5M6.75 6.5v4M9.25 6.5v4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.35"})})}const fo={repositoryUrl:"",parentPath:"",directoryName:"",name:"",authMode:"none",username:"",password:"",token:""};function IR({open:e,onClose:t,onCloned:n}){const{showToast:r}=lr(),[i,a]=f.useState(!1),[o,c]=f.useState(fo),[u,d]=f.useState(!1),[h,p]=f.useState(!1),[g,m]=f.useState(null),[y,S]=f.useState(""),[j,x]=f.useState(""),[A,T]=f.useState(null),[F,R]=f.useState([]),[I,G]=f.useState([]),z=i||h;f.useEffect(()=>{!e&&!i&&(c(fo),d(!1),m(null))},[i,e]);const L=f.useCallback(async Y=>{p(!0),m(null);try{const D=await Uf(Y);S(D.currentPath),x(D.currentPath),T(D.parentPath),R(D.roots),G(D.items),c(V=>({...V,parentPath:D.currentPath}))}catch(D){S(""),T(null),G([]),m(D instanceof Error?D.message:l("shell.importBrowserBrowseFailed"))}finally{p(!1)}},[]);function E(){i||(d(!1),m(null),c(fo),t())}function H(){d(!0),L(o.parentPath||void 0)}function B(){i||(d(!1),m(null))}async function oe(Y){Y.preventDefault(),await L(j)}function K(){c(Y=>({...Y,parentPath:y})),d(!1),m(null)}async function X(Y){Y.preventDefault();const D=o.repositoryUrl.trim(),V=o.parentPath.trim();if(!D){r({title:l("shell.cloneRepoRequired"),tone:"error"});return}if(!V){r({title:l("shell.clonePathRequired"),tone:"error"});return}a(!0);try{const le=await uy({repositoryUrl:D,parentPath:V,directoryName:o.directoryName.trim()||void 0,name:o.name.trim()||void 0,auth:o.authMode==="none"?{mode:"none"}:o.authMode==="basic"?{mode:"basic",username:o.username.trim(),password:o.password}:{mode:"token",username:o.username.trim()||void 0,token:o.token}});await(n==null?void 0:n(le)),c(fo),d(!1),r({title:l("shell.cloneSuccess"),description:le.path,tone:"success"}),t()}catch(le){r({title:le instanceof Error?le.message:l("shell.cloneFailed"),tone:"error"})}finally{a(!1)}}return s.jsxs(s.Fragment,{children:[s.jsx(St,{open:e,title:l("shell.cloneWorkspaceTitle"),description:l("shell.cloneWorkspaceHint"),onClose:E,children:s.jsxs("form",{className:"workbench-clone-form",onSubmit:Y=>void X(Y),children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneRepositoryLabel")}),s.jsx("input",{type:"text",value:o.repositoryUrl,placeholder:l("shell.cloneRepositoryPlaceholder"),onChange:Y=>c(D=>({...D,repositoryUrl:Y.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneParentPathLabel")}),s.jsxs("div",{className:"workbench-modal-inline-field",children:[s.jsx("input",{type:"text",value:o.parentPath,placeholder:l("shell.cloneParentPathPlaceholder"),onChange:Y=>c(D=>({...D,parentPath:Y.target.value}))}),s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:H,children:l("shell.clonePickDirectory")})]})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneDirectoryNameLabel")}),s.jsx("input",{type:"text",value:o.directoryName,placeholder:l("shell.cloneDirectoryNamePlaceholder"),onChange:Y=>c(D=>({...D,directoryName:Y.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importNameLabel")}),s.jsx("input",{type:"text",value:o.name,placeholder:l("shell.importNamePlaceholder"),onChange:Y=>c(D=>({...D,name:Y.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneAuthModeLabel")}),s.jsxs("select",{value:o.authMode,onChange:Y=>c(D=>({...D,authMode:Y.target.value})),children:[s.jsx("option",{value:"none",children:l("shell.cloneAuthModeNone")}),s.jsx("option",{value:"basic",children:l("shell.cloneAuthModeBasic")}),s.jsx("option",{value:"token",children:l("shell.cloneAuthModeToken")})]})]}),o.authMode==="basic"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneUsernameLabel")}),s.jsx("input",{type:"text",value:o.username,placeholder:l("shell.cloneUsernamePlaceholder"),autoComplete:"username",onChange:Y=>c(D=>({...D,username:Y.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.clonePasswordLabel")}),s.jsx("input",{type:"password",value:o.password,placeholder:l("shell.clonePasswordPlaceholder"),autoComplete:"current-password",onChange:Y=>c(D=>({...D,password:Y.target.value}))})]})]}):null,o.authMode==="token"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneUsernameLabel")}),s.jsx("input",{type:"text",value:o.username,placeholder:l("shell.cloneTokenUsernamePlaceholder"),onChange:Y=>c(D=>({...D,username:Y.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneTokenLabel")}),s.jsx("input",{type:"password",value:o.token,placeholder:l("shell.cloneTokenPlaceholder"),onChange:Y=>c(D=>({...D,token:Y.target.value}))})]})]}):null,s.jsx("p",{className:"workbench-import-hint",children:l("shell.cloneHint")}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:E,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:i,children:i?l("shell.cloneSubmitting"):l("shell.cloneSubmit")})]})]})}),s.jsxs(St,{open:e&&u,title:l("shell.cloneBrowserTitle"),description:l("shell.cloneBrowserDescription"),onClose:B,children:[s.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:oe,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCurrentPath")}),s.jsx("input",{type:"text",value:j,placeholder:l("shell.importPathPlaceholder"),onChange:Y=>x(Y.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:z||!A,onClick:()=>{A&&L(A)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:z,children:l("shell.importBrowserOpenPath")})]})]}),s.jsxs("section",{className:"workbench-directory-browser-panel",children:[s.jsxs("div",{className:"workbench-directory-browser-section",children:[s.jsx("span",{className:"workbench-directory-browser-section-title",children:l("shell.importBrowserRoots")}),s.jsx("div",{className:"workbench-directory-browser-root-list",children:F.map(Y=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:z,onClick:()=>{L(Y.path)},children:Y.name},Y.path))})]}),s.jsx("div",{className:"workbench-directory-browser-current-path",children:y}),g?s.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:g}):null,h?s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("common.loading")}):I.length>0?s.jsx("div",{className:"workbench-directory-browser-list",children:I.map(Y=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:z,onClick:()=>{L(Y.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:Y.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:Y.path})]},Y.path))}):s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("shell.importBrowserEmpty")})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:B,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:z||!y,onClick:K,children:l("shell.cloneBrowserSubmit")})]})]})]})}const ER="butler:inbox-updated";function kc(){typeof window>"u"||window.dispatchEvent(new Event(ER))}const Hp={projectId:"",itemType:"task",title:"",content:"",status:"pending"};function Qb({active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,compactComposer:a=!1,composerOpen:o=!0,onComposerOpenChange:c}){const{showToast:u}=lr(),[d,h]=f.useState(!1),[p,g]=f.useState(!1),[m,y]=f.useState([]),[S,j]=f.useState([]),[x,A]=f.useState(null),[T,F]=f.useState(null),[R,I]=f.useState(Hp),[G,z]=f.useState(!1),L=f.useMemo(()=>qp(m,t,T),[T,t,m]),E=f.useMemo(()=>G?S:S.filter(D=>D.status!=="closed"),[S,G]);f.useEffect(()=>{e&&H()},[e,n]),f.useEffect(()=>{!e||x||I(D=>{const V=Vp({projects:L,currentProjectId:D.projectId,preferredProjectId:T,preferredWorkspaceId:t});return V===D.projectId?D:{...D,projectId:V}})},[e,x,T,t,L]),f.useEffect(()=>{!e||r<=0||(B(void 0,t,i,T),c==null||c(!0))},[e,r,i,c,T,t]);async function H(){h(!0);try{const[D,V,le]=await Promise.all([pT(),qg(),n?xT(n).catch(()=>null):Promise.resolve(null)]),C=(le==null?void 0:le.target.project.id)??null;F(C),y(D.items),j(V.items),x||B(D.items,t,r>0?i:null,C)}catch(D){u({title:l("shell.butlerInboxLoadFailed"),description:D instanceof Error?D.message:void 0,tone:"error"})}finally{h(!1)}}function B(D=m,V=t,le=i,C=T){var Z,N;const _e=qp(D,V,C);A(null),I({...Hp,projectId:Vp({projects:_e,preferredProjectId:C,preferredWorkspaceId:V}),title:((Z=le==null?void 0:le.title)==null?void 0:Z.trim())??"",content:((N=le==null?void 0:le.content)==null?void 0:N.trim())??""})}function oe(D){A(D.id),I({projectId:D.projectId,itemType:D.itemType,title:D.title,content:D.content,status:D.status}),a&&(c==null||c(!0))}async function K(D){D.preventDefault(),g(!0);try{x?(await tp(x,{projectId:R.projectId,itemType:R.itemType,title:R.title,content:R.content,status:R.status,priority:"medium"}),u({title:l("shell.butlerInboxUpdated"),tone:"success"})):(await fT({projectId:R.projectId,itemType:R.itemType,title:R.title,content:R.content,status:R.status,priority:"medium"}),u({title:l("shell.butlerInboxCreated"),tone:"success"})),kc(),await H(),B(),a&&(c==null||c(!1))}catch(V){u({title:l("shell.butlerInboxSaveFailed"),description:V instanceof Error?V.message:void 0,tone:"error"})}finally{g(!1)}}async function X(D){g(!0);try{await bT(D),u({title:l("shell.butlerInboxDeleted"),tone:"success"}),kc(),await H(),x===D&&B()}catch(V){u({title:l("shell.butlerInboxDeleteFailed"),description:V instanceof Error?V.message:void 0,tone:"error"})}finally{g(!1)}}async function Y(D,V){if(D.status!==V){g(!0);try{await tp(D.id,{status:V}),u({title:l("shell.butlerInboxUpdated"),tone:"success"}),kc(),await H(),x===D.id&&I(le=>({...le,status:V}))}catch(le){u({title:l("shell.butlerInboxSaveFailed"),description:le instanceof Error?le.message:void 0,tone:"error"})}finally{g(!1)}}}return s.jsxs("div",{className:"workspace-inbox-modal",children:[a?null:s.jsx("section",{className:"workspace-inbox-panel",children:s.jsx(Up,{selectableProjects:L,formState:R,saving:p,editingItemId:x,useMobilePicker:!1,onProjectChange:D=>{I(V=>({...V,projectId:D}))},onItemTypeChange:D=>{I(V=>({...V,itemType:D}))},onStatusChange:D=>{I(V=>({...V,status:D}))},onTitleChange:D=>{I(V=>({...V,title:D}))},onContentChange:D=>{I(V=>({...V,content:D}))},onCancel:()=>B(),onSubmit:K})}),s.jsxs("section",{className:"workspace-inbox-panel",children:[s.jsxs("header",{className:"workspace-inbox-panel-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:l("shell.butlerInboxListTitle")}),s.jsx("p",{children:l("shell.butlerInboxListDescription")})]}),s.jsxs("label",{className:"workspace-inbox-closed-toggle",children:[s.jsx("input",{type:"checkbox",checked:G,onChange:D=>z(D.target.checked)}),s.jsx("span",{children:l("shell.butlerInboxShowClosedAction")})]})]}),d?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxLoading")}):null,!d&&E.length===0?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxEmpty")}):null,!d&&E.length>0?s.jsx("div",{className:"workspace-inbox-list",children:E.map(D=>s.jsxs("article",{className:"workspace-inbox-item",children:[s.jsxs("div",{className:"workspace-inbox-item-header",children:[s.jsxs("div",{children:[s.jsx("strong",{children:D.title}),s.jsx("p",{children:D.projectName})]}),s.jsxs("div",{className:"workspace-inbox-item-badges",children:[s.jsx("span",{className:"workspace-inbox-badge",children:Kp(D.status)}),s.jsx("span",{className:"workspace-inbox-badge",children:LR(D.itemType)})]})]}),s.jsx("p",{className:"workspace-inbox-item-content",children:D.content}),s.jsxs("div",{className:"workspace-inbox-item-footer",children:[s.jsx("span",{children:_R(D.updatedAt)}),s.jsxs("div",{className:"workspace-inbox-item-actions",children:[s.jsx("div",{className:"workspace-inbox-status-quick-actions",role:"group","aria-label":l("shell.butlerInboxQuickStatusLabel"),children:["pending","in_progress","closed"].map(V=>{const le=D.status===V;return s.jsx("button",{type:"button",className:"secondary-button","data-active":le,disabled:p,onClick:()=>{Y(D,V)},children:Kp(V)},`${D.id}:${V}`)})}),s.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>oe(D),children:l("shell.butlerInboxEditAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{X(D.id)},children:l("shell.butlerInboxDeleteAction")})]})]})]},D.id))}):null]}),a?s.jsx(St,{open:e&&o,title:x?l("shell.butlerInboxEditingTitle"):l("shell.butlerInboxCreateTitle"),description:l("shell.butlerInboxFormDescription"),className:"workspace-inbox-modal-card workspace-inbox-composer-modal-card",onClose:()=>{c==null||c(!1),B()},children:s.jsx("div",{className:"workspace-inbox-composer-modal-body",children:s.jsx(Up,{selectableProjects:L,formState:R,saving:p,editingItemId:x,useMobilePicker:!0,onProjectChange:D=>{I(V=>({...V,projectId:D}))},onItemTypeChange:D=>{I(V=>({...V,itemType:D}))},onStatusChange:D=>{I(V=>({...V,status:D}))},onTitleChange:D=>{I(V=>({...V,title:D}))},onContentChange:D=>{I(V=>({...V,content:D}))},onCancel:()=>{c==null||c(!1),B()},onSubmit:K})})}):null]})}function Up(e){const t=e.selectableProjects.map(i=>({value:i.id,label:i.name})),n=[{value:"task",label:l("shell.butlerInboxTypeTask")},{value:"bug",label:l("shell.butlerInboxTypeBug")},{value:"feature",label:l("shell.butlerInboxTypeFeature")},{value:"change",label:l("shell.butlerInboxTypeChange")}],r=[{value:"pending",label:l("shell.butlerInboxStatusPending")},{value:"in_progress",label:l("shell.butlerInboxStatusInProgress")},{value:"closed",label:l("shell.butlerInboxStatusClosed")}];return s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"workspace-inbox-panel-header",children:[s.jsx("h3",{children:e.editingItemId?l("shell.butlerInboxEditingTitle"):l("shell.butlerInboxCreateTitle")}),s.jsx("p",{children:l("shell.butlerInboxFormDescription")})]}),e.selectableProjects.length===0?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxProjectsEmpty")}):s.jsxs("form",{className:"workspace-inbox-form",onSubmit:e.onSubmit,children:[s.jsx("div",{className:"workspace-inbox-form-grid",children:e.useMobilePicker?s.jsxs(s.Fragment,{children:[s.jsx(yc,{label:l("shell.butlerInboxProjectLabel"),value:e.formState.projectId,options:t,disabled:e.saving,onChange:e.onProjectChange}),s.jsx(yc,{label:l("shell.butlerInboxTypeLabel"),value:e.formState.itemType,options:n,disabled:e.saving,onChange:e.onItemTypeChange}),s.jsx(yc,{label:l("shell.butlerInboxStatusLabel"),value:e.formState.status,options:r,disabled:e.saving,onChange:e.onStatusChange})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxProjectLabel")}),s.jsx("select",{value:e.formState.projectId,disabled:e.saving,onChange:i=>e.onProjectChange(i.target.value),children:e.selectableProjects.map(i=>s.jsx("option",{value:i.id,children:i.name},i.id))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxTypeLabel")}),s.jsxs("select",{value:e.formState.itemType,disabled:e.saving,onChange:i=>e.onItemTypeChange(i.target.value),children:[s.jsx("option",{value:"task",children:l("shell.butlerInboxTypeTask")}),s.jsx("option",{value:"bug",children:l("shell.butlerInboxTypeBug")}),s.jsx("option",{value:"feature",children:l("shell.butlerInboxTypeFeature")}),s.jsx("option",{value:"change",children:l("shell.butlerInboxTypeChange")})]})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxStatusLabel")}),s.jsxs("select",{value:e.formState.status,disabled:e.saving,onChange:i=>e.onStatusChange(i.target.value),children:[s.jsx("option",{value:"pending",children:l("shell.butlerInboxStatusPending")}),s.jsx("option",{value:"in_progress",children:l("shell.butlerInboxStatusInProgress")}),s.jsx("option",{value:"closed",children:l("shell.butlerInboxStatusClosed")})]})]})]})}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxTitleLabel")}),s.jsx("input",{value:e.formState.title,placeholder:l("shell.butlerInboxTitlePlaceholder"),disabled:e.saving,onChange:i=>e.onTitleChange(i.target.value)})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxContentLabel")}),s.jsx("textarea",{rows:4,value:e.formState.content,placeholder:l("shell.butlerInboxContentPlaceholder"),disabled:e.saving,onChange:i=>e.onContentChange(i.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:e.saving,onClick:e.onCancel,children:e.editingItemId?l("shell.butlerInboxCancelEditAction"):l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:e.saving||!e.formState.projectId,children:e.editingItemId?l("shell.butlerInboxUpdateAction"):l("shell.butlerInboxCreateAction")})]})]})]})}function yc({label:e,value:t,options:n,disabled:r,onChange:i}){const[a,o]=f.useState(!1),c=n.find(u=>u.value===t)??n[0]??null;return f.useEffect(()=>{if(!a)return;function u(d){d.key==="Escape"&&o(!1)}return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},[a]),s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-modal-field workspace-inbox-mobile-picker",children:[s.jsx("span",{children:e}),s.jsxs("button",{type:"button",className:"workspace-inbox-mobile-picker-trigger","aria-label":e,"aria-haspopup":"dialog","aria-expanded":a,disabled:r||n.length===0,onClick:()=>o(!0),children:[s.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-value",children:(c==null?void 0:c.label)??""}),s.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-icon",children:s.jsx(PR,{expanded:a})})]})]}),s.jsx(MR,{open:a,title:e,options:n,selectedValue:t,onClose:()=>o(!1),onSelect:u=>{i(u),o(!1)}})]})}function MR({open:e,title:t,options:n,selectedValue:r,onClose:i,onSelect:a}){return e?s.jsx(dy,{open:e,title:t,kind:"picker",height:"half",className:"workspace-inbox-picker-sheet",cardClassName:"workspace-inbox-picker-sheet-card",bodyClassName:"workspace-inbox-picker-sheet-body",showHandle:!0,onClose:i,children:s.jsx(mi,{className:"workspace-inbox-picker-sheet-options",role:"listbox","aria-label":t,children:n.map(o=>{const c=o.value===r;return s.jsx(Jt,{as:"button",className:"workspace-inbox-picker-option",role:"option","aria-selected":c,selected:c,trailing:s.jsx("span",{className:"workspace-inbox-picker-option-indicator","aria-hidden":"true",children:c?s.jsx(AR,{}):null}),onClick:()=>a(o.value),children:s.jsxs("span",{className:"workspace-inbox-picker-option-copy",children:[s.jsx("strong",{children:o.label}),o.description?s.jsx("span",{children:o.description}):null]})},o.value)})})}):null}function b2({open:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,onClose:a,compactComposer:o=!1}){const[c,u]=f.useState(0),[d,h]=f.useState(!o);return f.useEffect(()=>{e||h(!o)},[o,e]),s.jsx(St,{open:e,title:l("shell.butlerInboxModalTitle"),description:l("shell.butlerInboxModalDescription"),className:"workspace-inbox-modal-card",showCloseButton:!o,headerActions:o?s.jsx("button",{type:"button",className:"workspace-inbox-modal-create-button","aria-label":l("shell.butlerInboxCreateAction"),title:l("shell.butlerInboxCreateAction"),onClick:()=>{u(p=>p+1),h(!0)},children:s.jsx(RR,{})}):void 0,onClose:a,children:s.jsx(Qb,{active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:Math.max(r,c),initialDraft:i,compactComposer:o,composerOpen:d,onComposerOpenChange:h})})}function qp(e,t,n){return[...e].filter(r=>r.lifecycleStatus!=="archived").sort((r,i)=>{const a=Gp(r,t,n),o=Gp(i,t,n);return a!==o?o-a:r.name.localeCompare(i.name,"zh-Hans-CN")})}function Gp(e,t,n){return n&&e.id===n?2:t&&e.workspaceId===t?1:0}function Vp({projects:e,currentProjectId:t,preferredProjectId:n,preferredWorkspaceId:r}){var a;if(t&&e.some(o=>o.id===t))return t;if(n&&e.some(o=>o.id===n))return n;const i=r?e.find(o=>o.workspaceId===r):null;return(i==null?void 0:i.id)||((a=e[0])==null?void 0:a.id)||""}function RR(){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("path",{d:"M12 5v14"}),s.jsx("path",{d:"M5 12h14"})]})}function PR({expanded:e}){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true","data-expanded":e?"true":void 0,children:s.jsx("path",{d:"M3.5 6 8 10l4.5-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function AR(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 8.4 6.6 11.5 12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function LR(e){switch(e){case"bug":return l("shell.butlerInboxTypeBug");case"feature":return l("shell.butlerInboxTypeFeature");case"change":return l("shell.butlerInboxTypeChange");case"task":default:return l("shell.butlerInboxTypeTask")}}function Kp(e){switch(e){case"in_progress":return l("shell.butlerInboxStatusInProgress");case"closed":return l("shell.butlerInboxStatusClosed");case"pending":default:return l("shell.butlerInboxStatusPending")}}function _R(e){return new Date(e).toLocaleString()}function DR({open:e,onClose:t,onImported:n}){const{showToast:r}=lr(),[i,a]=f.useState(!1),[o,c]=f.useState(!1),[u,d]=f.useState(!1),[h,p]=f.useState(null),[g,m]=f.useState(""),[y,S]=f.useState(""),[j,x]=f.useState(null),[A,T]=f.useState([]),[F,R]=f.useState([]),[I,G]=f.useState(!1),[z,L]=f.useState(""),E=i||o||u,H=f.useCallback(async V=>{a(!0),p(null);try{const le=await Uf(V);m(le.currentPath),S(le.currentPath),x(le.parentPath),T(le.roots),R(le.items)}catch(le){m(""),x(null),R([]),p(le instanceof Error?le.message:l("shell.importBrowserBrowseFailed"))}finally{a(!1)}},[]);f.useEffect(()=>{if(!e){G(!1),L(""),p(null);return}H(g||void 0)},[H,e]);function B(){E||(G(!1),L(""),t())}async function oe(V){V.preventDefault(),await H(y)}function K(){!g||E||(L(""),G(!0))}function X(){o||(G(!1),L(""))}async function Y(V){V==null||V.preventDefault();const le=z.trim();if(!(!g||!le||E)){c(!0),p(null);try{const C=await py({parentPath:g,directoryName:le});r({title:l("shell.importBrowserCreateDirectorySuccess"),description:C.path,tone:"success"}),G(!1),L(""),await H(C.path)}catch(C){const _e=C instanceof Error?C.message:l("shell.importBrowserCreateDirectoryFailed");p(_e),r({title:_e,tone:"error"})}finally{c(!1)}}}async function D(){const V=g.trim();if(!(!V||E)){d(!0),p(null);try{const le=await hy({path:V});r({title:l("shell.importSuccess"),description:le.path,tone:"success"}),t(),Promise.resolve().then(()=>n==null?void 0:n(le)).catch(C=>{r({title:C instanceof Error?C.message:l("shell.navigationLoadFailed"),tone:"error"})})}catch(le){r({title:le instanceof Error?le.message:l("shell.importFailed"),tone:"error"})}finally{d(!1)}}}return s.jsxs(s.Fragment,{children:[s.jsxs(St,{open:e,title:l("shell.importBrowserTitle"),description:l("shell.importBrowserDescription"),onClose:B,children:[s.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:oe,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCurrentPath")}),s.jsx("input",{type:"text",value:y,placeholder:l("shell.importPathPlaceholder"),onChange:V=>S(V.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:E||!j,onClick:()=>{j&&H(j)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:E,children:l("shell.importBrowserOpenPath")}),s.jsx("button",{type:"button",className:"secondary-button",disabled:E||!g,onClick:K,children:l("shell.importBrowserCreateDirectory")})]})]}),s.jsxs("section",{className:"workbench-directory-browser-panel",children:[s.jsxs("div",{className:"workbench-directory-browser-section",children:[s.jsx("span",{className:"workbench-directory-browser-section-title",children:l("shell.importBrowserRoots")}),s.jsx("div",{className:"workbench-directory-browser-root-list",children:A.map(V=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:E,onClick:()=>{H(V.path)},children:V.name},V.path))})]}),s.jsx("div",{className:"workbench-directory-browser-current-path",children:g}),h?s.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:h}):null,i?s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("common.loading")}):F.length>0?s.jsx("div",{className:"workbench-directory-browser-list",children:F.map(V=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:E,onClick:()=>{H(V.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:V.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:V.path})]},V.path))}):s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("shell.importBrowserEmpty")})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:E,onClick:B,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:E||!g,onClick:()=>{D()},children:u?l("shell.importSubmitting"):l("shell.importBrowserSubmit")})]})]}),s.jsx(St,{open:e&&I,title:l("shell.importBrowserCreateDirectoryTitle"),description:l("shell.importBrowserCreateDirectoryDescription"),onClose:X,children:s.jsxs("form",{className:"workbench-rename-form",onSubmit:V=>void Y(V),children:[s.jsx("div",{className:"workbench-directory-browser-current-path",children:g}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCreateDirectoryLabel")}),s.jsx("input",{type:"text",value:z,placeholder:l("shell.importBrowserCreateDirectoryPlaceholder"),autoFocus:!0,onChange:V=>L(V.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:o,onClick:X,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:o||!z.trim(),children:o?l("shell.importBrowserCreatingDirectory"):l("shell.importBrowserCreateDirectorySubmit")})]})]})})]})}function BR({onOpenSoftwareUpdate:e}){var r;const t=gu(i=>i.platform),n=ry(i=>i.latestState);return t!=="desktop"||!(n!=null&&n.hasUpdate)?null:s.jsx("button",{className:"workbench-nav-update-badge",type:"button",title:((r=n.manifest)==null?void 0:r.version)??l("settings.releaseUpdateReady"),onClick:e,children:s.jsx("span",{className:"workbench-nav-update-badge-label",children:l("settings.releaseUpdateBadge")})})}function OR(){const e=ny.getState().profile.defaultPermissionMode;return e==="default"?null:e}const ta="provider-default",Io="__global_default__";function WR(e){switch(e){case"claude-code":case"codex":case"gemini":return e;default:return null}}function mo(e,t){const n=(t==null?void 0:t.trim())||null;return e==="cc-switch-preset"&&n?{providerConfigMode:"cc-switch-preset",providerPresetId:n}:{providerConfigMode:"global-default",providerPresetId:null}}function FR(e){const t=e!=null&&e.currentPresetName?e.currentModel?`${e.currentPresetName} · ${e.currentModel}`:e.currentPresetName:null;return[{value:Io,label:l("conversation.deploymentDefaultPreset"),summary:t},...((e==null?void 0:e.options)??[]).map(n=>({value:n.id,label:n.name,summary:n.model??n.summary??null}))]}function $R(e){return e.usesProviderDefault===!0||e.id===ta}function zR(e){return e?e.cliAvailable===!0&&e.status!=="unavailable"&&e.options.length>1:!0}function HR({triggerId:e,ariaLabel:t,triggerLabel:n,presetOptions:r,selectedPresetValue:i,selectedPresetSummary:a,onSelectPreset:o,modelOptions:c,selectedModelValue:u,onSelectModel:d,loadingPresets:h=!1,loadingModels:p=!1,modelColumnDisabled:g=!1,showPresetColumn:m=!0,modelEmptyText:y}){const[S,j]=f.useState(!1),x=f.useRef(null),A=f.useRef(null),T=f.useRef(null),[F,R]=f.useState(null),I=f.useId(),G=f.useCallback(()=>{const z=A.current;if(!z||typeof window>"u")return;const L=z.getBoundingClientRect(),E=z.closest(".workbench-modal-card"),H=E instanceof HTMLElement?E.getBoundingClientRect():null,B=window.innerWidth,oe=window.innerHeight,K=12,X=8,Y=320,D=Math.min(560,Math.max(320,B-K*2)),V=Math.min(D,420),le=Math.max(Math.min(D,Math.max(V,Math.round(L.width*1.9))),Math.min(320,D)),C=Math.min(Math.max(K,L.left),Math.max(K,B-le-K)),_e=H?Math.max(K,H.top+8):K,Z=H?Math.min(oe-K,H.bottom-8):oe-K,N=Math.max(0,L.top-_e-X),be=Math.max(0,Z-L.bottom-X),ne=H?!(be>=Y||be>N+40):N>=240||N>=be;R({position:"fixed",left:C,width:le,maxWidth:D,zIndex:1905,top:ne?void 0:L.bottom+X,bottom:ne?oe-L.top+X:void 0})},[]);return f.useEffect(()=>{if(!S)return;function z(E){var B,oe;const H=E.target;!((B=x.current)!=null&&B.contains(H))&&!((oe=T.current)!=null&&oe.contains(H))&&j(!1)}function L(E){E.key==="Escape"&&j(!1)}return window.addEventListener("pointerdown",z),window.addEventListener("keydown",L),window.addEventListener("resize",G),window.addEventListener("scroll",G,!0),G(),()=>{window.removeEventListener("pointerdown",z),window.removeEventListener("keydown",L),window.removeEventListener("resize",G),window.removeEventListener("scroll",G,!0)}},[S,G]),s.jsxs("div",{ref:x,className:"composer-mac-select composer-deployment-select","data-open":S?"true":"false",children:[s.jsxs("button",{id:e,ref:A,type:"button",className:"composer-mac-select-trigger composer-deployment-select-trigger","aria-label":t,"aria-haspopup":"dialog","aria-expanded":S,"aria-controls":I,onClick:()=>j(z=>!z),children:[s.jsx("span",{className:"composer-mac-select-label composer-deployment-select-label",children:n}),s.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),S&&F&&typeof document<"u"?Fr.createPortal(s.jsx("div",{ref:T,className:"composer-mac-select-popover composer-deployment-select-popover",style:F,role:"presentation",children:s.jsxs("div",{id:I,className:`composer-deployment-select-panel${m?"":" is-model-only"}`,role:"dialog","aria-label":t,children:[m?s.jsxs("div",{className:"composer-deployment-select-column",children:[s.jsx("div",{className:"composer-deployment-select-column-header",children:l("conversation.deploymentConfigColumn")}),s.jsxs("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":l("conversation.deploymentConfigColumn"),children:[r.map(z=>{const L=z.value===i;return s.jsxs("button",{type:"button",role:"option","aria-selected":L,className:`composer-deployment-select-option ${L?"is-selected":""}`,onClick:()=>o(z.value),children:[s.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:L?"✓":""}),s.jsxs("span",{className:"composer-deployment-select-option-copy",children:[s.jsx("span",{className:"composer-deployment-select-option-label",children:z.label}),z.summary?s.jsx("span",{className:"composer-deployment-select-option-summary",children:z.summary}):null]})]},z.value)}),h?s.jsx("div",{className:"composer-deployment-select-state",children:l("conversation.deploymentLoading")}):null]})]}):null,s.jsxs("div",{className:"composer-deployment-select-column","data-disabled":g?"true":"false",children:[s.jsx("div",{className:"composer-deployment-select-column-header",children:l("conversation.deploymentModelColumn")}),m&&a?s.jsx("div",{className:"composer-deployment-select-column-hint",children:a}):null,s.jsx("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":l("conversation.deploymentModelColumn"),children:p&&g?s.jsx("div",{className:"composer-deployment-select-state",children:l("conversation.deploymentModelLoading")}):c.length>0?c.map(z=>{const L=z.value===u;return s.jsxs("button",{type:"button",role:"option","aria-selected":L,className:`composer-deployment-select-option ${L?"is-selected":""}`,disabled:g,onClick:()=>{d(z.value),j(!1)},children:[s.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:L?"✓":""}),s.jsx("span",{className:"composer-deployment-select-option-copy",children:s.jsx("span",{className:"composer-deployment-select-option-label",children:z.label})})]},z.value)}):s.jsx("div",{className:"composer-deployment-select-state",children:y})})]})]})}),document.body):null]})}const Zb=144,UR=196,qR=124,GR=72;let Yp=null;function VR(e,t){if(typeof document>"u")return t.length*8;Yp??(Yp=document.createElement("canvas"));const n=Yp.getContext("2d");if(!n)return t.length*8;const r=window.getComputedStyle(e),i=r.fontStyle||"normal",a=r.fontWeight||"600",o=r.fontSize||"13px",c=r.fontFamily||"system-ui";return n.font=`${i} ${a} ${o} ${c}`,n.measureText(t).width}function KR({labels:e,triggerWidth:t,maxWidth:n,preferredWidth:r,measureText:i}){const a=e.reduce((o,c)=>Math.max(o,Math.ceil(i(c)+GR)),0);return Math.min(n,Math.max(t,Zb,r,a))}function Xp({triggerId:e,ariaLabel:t,value:n,options:r,onChange:i,disabled:a=!1,compact:o=!1,className:c}){const[u,d]=f.useState(!1),h=f.useRef(null),p=f.useRef(null),g=f.useRef(null),[m,y]=f.useState(null),S=f.useId(),j=r.find(T=>T.value===n)??r[0]??null,x=f.useMemo(()=>r.map(T=>T.label),[r]),A=f.useCallback(()=>{const T=p.current;if(!T||typeof window>"u")return;const F=T.getBoundingClientRect(),R=window.innerWidth,I=window.innerHeight,G=12,z=10,L=Math.max(Zb,R-G*2),E=o?qR:UR,H=KR({labels:x,triggerWidth:F.width,maxWidth:L,preferredWidth:E,measureText:Y=>VR(T,Y)}),B=Math.min(Math.max(G,F.left),Math.max(G,R-H-G)),oe=F.top-G,K=I-F.bottom-G,X=oe>=180||oe>=K;y({position:"fixed",left:B,width:H,maxWidth:L,zIndex:1905,top:X?void 0:F.bottom+z,bottom:X?I-F.top+z:void 0})},[o,x]);return f.useEffect(()=>{if(!u)return;function T(R){var G,z;const I=R.target;!((G=h.current)!=null&&G.contains(I))&&!((z=g.current)!=null&&z.contains(I))&&d(!1)}function F(R){R.key==="Escape"&&d(!1)}return window.addEventListener("pointerdown",T),window.addEventListener("keydown",F),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),A(),()=>{window.removeEventListener("pointerdown",T),window.removeEventListener("keydown",F),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[u,A]),j?s.jsxs("div",{ref:h,className:`composer-mac-select ${o?"is-compact":""}${c?` ${c}`:""}`,"data-open":u?"true":"false",children:[s.jsxs("button",{id:e,ref:p,type:"button",className:"composer-mac-select-trigger","aria-label":t,"aria-haspopup":"listbox","aria-expanded":u,"aria-controls":S,disabled:a,onClick:()=>d(T=>!T),children:[s.jsx("span",{className:"composer-mac-select-label",children:j.label}),s.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),u&&m&&typeof document<"u"?Fr.createPortal(s.jsx("div",{ref:g,className:"composer-mac-select-popover",style:m,role:"presentation",children:s.jsx("div",{id:S,className:"composer-mac-select-list",role:"listbox","aria-label":t,children:r.map(T=>{const F=T.value===n;return s.jsxs("button",{type:"button",role:"option","aria-selected":F,className:`composer-mac-select-option ${F?"is-selected":""}`,onClick:()=>{i(T.value),d(!1)},children:[s.jsx("span",{className:"composer-mac-select-option-check","aria-hidden":"true",children:F?"✓":""}),s.jsx("span",{className:"composer-mac-select-option-label",children:T.label})]},T.value)})})}),document.body):null]}):null}const go=["codex","claude-code","gemini"];function ek(e){return{provider:e,model:"",providerConfigMode:"global-default",providerPresetId:null,memberPrompt:"",workspaceIsolationMode:"none"}}function Jp(e,t){return Array.from({length:t},()=>ek(e))}function xc(e,t){var n;return(n=e==null?void 0:e.modelOptions)!=null&&n.length?e.modelOptions:yu(t).modelOptions??[]}function Qp(e,t,n){return t!=="cc-switch-preset"||!n?null:`${e}::${n}`}function Zp(e,t){return Math.max(0,e-t.length)}function YR({open:e,source:t,onClose:n,onCreated:r}){const i=f.useId(),a=(t==null?void 0:t.defaultProvider)??"codex",o=(t==null?void 0:t.kind)==="group",c=(t==null?void 0:t.kind)==="group"?Math.max(0,4-t.currentMemberCount):4,u=f.useMemo(()=>(t==null?void 0:t.kind)==="group"?Array.from({length:c},(ae,se)=>se+1):[2,3,4],[c,t==null?void 0:t.kind]),d=(t==null?void 0:t.kind)==="group"?1:2,h=(t==null?void 0:t.kind)==="group"?t.sharedPrompt:"",{visibleProviders:p}=fy(my,e),[g,m]=f.useState(h),[y,S]=f.useState(d),[j,x]=f.useState(()=>Jp(a,d)),[A,T]=f.useState({}),[F,R]=f.useState({}),[I,G]=f.useState({}),[z,L]=f.useState({}),[E,H]=f.useState({}),[B,oe]=f.useState(!1),[K,X]=f.useState(!1),[Y,D]=f.useState(null),[V,le]=f.useState(null),[C,_e]=f.useState({}),Z=f.useRef(!1),N=f.useRef({});f.useEffect(()=>{if(!e)return;const ae=(t==null?void 0:t.defaultProvider)??"codex",se=(t==null?void 0:t.kind)==="group"?1:2;m((t==null?void 0:t.kind)==="group"?t.sharedPrompt:""),S(se),x(Jp(ae,se)),T({}),R({}),G({}),L({}),H({}),oe(!1),X(!1),D(null),le(null),_e({}),Z.current=!1,Object.keys(N.current).forEach(ke=>{delete N.current[ke]})},[e,t==null?void 0:t.defaultProvider,t==null?void 0:t.kind,t==null?void 0:t.workspaceId,(t==null?void 0:t.kind)==="session"?t.sessionId:null,(t==null?void 0:t.kind)==="group"?t.groupId:null,(t==null?void 0:t.kind)==="group"?t.sharedPrompt:null]),f.useEffect(()=>{x(ae=>{var ye;if(ae.length===y)return ae;if(ae.length>y)return ae.slice(0,y);const se=ae.slice(),ke=((ye=ae[0])==null?void 0:ye.provider)??a;for(;se.length<y;)se.push(ek(ke));return se})},[a,y]),f.useEffect(()=>{u.length!==0&&S(ae=>u.includes(ae)?ae:u[0]??ae)},[u]),f.useEffect(()=>{if(!e||!t)return;let ae=!1;return oe(!0),gy(p,t.workspaceId).then(se=>{ae||T(se)}).finally(()=>{ae||oe(!1)}),()=>{ae=!0}},[e,t==null?void 0:t.workspaceId,p]),f.useEffect(()=>{e&&(Z.current||(Z.current=!0,G(ae=>({...ae,...Object.fromEntries(go.map(se=>[se,!0]))})),by().then(ae=>{const se=Object.fromEntries(ae.items.map(ke=>[ke.app,ke]));R(Object.fromEntries(go.map(ke=>[ke,se[ke]??null])))}).catch(()=>{R(Object.fromEntries(go.map(ae=>[ae,null])))}).finally(()=>{G(ae=>({...ae,...Object.fromEntries(go.map(se=>[se,!1]))}))})))},[e]),f.useEffect(()=>{if(!e||!t)return;const ae=Array.from(new Set(j.map(se=>{const ke=mo(se.providerConfigMode,se.providerPresetId);return Qp(se.provider,ke.providerConfigMode,ke.providerPresetId)}).filter(se=>se!==null))).filter(se=>z[se]===void 0&&!N.current[se]);if(ae.length!==0)for(const se of ae){const[ke,ye]=se.split("::");N.current[se]=!0,H(Me=>({...Me,[se]:!0})),qf(ke,t.workspaceId,{providerConfigMode:"cc-switch-preset",providerPresetId:ye}).then(Me=>{L($=>({...$,[se]:Me}))}).catch(()=>{L(Me=>({...Me,[se]:null}))}).finally(()=>{delete N.current[se],H(Me=>({...Me,[se]:!1}))})}},[z,j,e,t]);const be=f.useMemo(()=>p.filter(ae=>{const se=A[ae];return se?se.canStartSession!==!1:!1}),[A,p]);f.useEffect(()=>{if(!be.length)return;const ae=be.includes(a)?a:be[0];x(se=>{let ke=!1;const ye=se.map(Me=>be.includes(Me.provider)?Me:(ke=!0,{...Me,provider:ae,providerConfigMode:"global-default",providerPresetId:null,model:""}));return ke?ye:se})},[be,a]);const ne=f.useMemo(()=>j.map((ae,se)=>{var Ye;const ke=mo(ae.providerConfigMode,ae.providerPresetId),ye=WR(ae.provider),Me=ye?F[ye]??null:null,$=FR(Me),Q=ke.providerConfigMode==="cc-switch-preset"?ke.providerPresetId??Io:Io,ge=$.find(dt=>dt.value===Q)??$[0]??null,Ne=Qp(ae.provider,ke.providerConfigMode,ke.providerPresetId),Be=A[ae.provider]??null,Ke=Ne?z[Ne]??null:null,ut=(ke.providerConfigMode==="cc-switch-preset"?Ke?xc(Ke,ae.provider):[{id:ta,name:l("conversation.modelUseCliDefault"),usesProviderDefault:!0}]:xc(Be,ae.provider)).map(dt=>({value:dt.id,label:$R(dt)?l("conversation.modelUseCliDefault"):dt.name})),Qe=ae.model.trim()||ta,rt=((Ye=ut.find(dt=>dt.value===Qe))==null?void 0:Ye.label)??l("conversation.modelUseCliDefault"),st=zR(Me),qe=ye!==null,gt=Ne?E[Ne]===!0:!1,Ht=!!(Ne&&gt&&Ke===null);return{index:se,draft:ae,supportsDeploymentPicker:qe,showPresetColumn:st,deploymentPresetOptions:$,selectedPresetValue:Q,selectedPresetOption:ge,triggerLabel:st?`${(ge==null?void 0:ge.label)??l("conversation.deploymentDefaultPreset")} · ${rt}`:rt,selectedModelValue:Qe,modelOptions:ut,loadingPresets:ye?I[ye]===!0:!1,loadingModels:gt,modelColumnDisabled:Ht}}),[z,F,I,E,j,A]);if(f.useEffect(()=>{e&&x(ae=>{let se=!1;const ke=ae.map((ye,Me)=>{const $=ne[Me];if(!$)return ye;let Q=ye;const ge=mo(ye.providerConfigMode,ye.providerPresetId);ge.providerConfigMode==="cc-switch-preset"&&ge.providerPresetId&&!$.loadingPresets&&!$.deploymentPresetOptions.some(Ke=>Ke.value===ge.providerPresetId)&&(Q={...Q,providerConfigMode:"global-default",providerPresetId:null,model:""},se=!0);const Ne=new Set($.modelOptions.map(Ke=>Ke.value)),Be=Q.model.trim()||ta;return Ne.has(Be)||(Q={...Q,model:""},se=!0),Q});return se?ke:ae})},[ne,e]),!e||!t)return null;const fe=t,ue=V?Zp(j.length,V.memberFailures):0,He=new Set(V?j.map((ae,se)=>se).filter(ae=>!(ae in C)):[]),Ue=fe.kind==="group"?l("shell.parallelAppendModalTitle"):l("shell.parallelCreateModalTitle"),je=fe.kind==="session"?`${fe.workspaceName} · ${fe.sessionTitle}`:fe.workspaceName,Te=fe.kind==="group"?l("shell.parallelAppendSharedPromptLabel"):l("shell.parallelCreateSharedPromptLabel"),O=fe.kind==="group"?l("shell.parallelAppendCountLabel"):l("shell.parallelCreateCountLabel"),q=fe.kind==="group"?l("shell.parallelAppendSubmit"):l("shell.parallelCreateSubmit"),J=fe.kind==="group"?l("shell.parallelAppendSubmitting"):l("shell.parallelCreateSubmitting"),Ce=Y??(fe.kind==="group"&&c===0?l("shell.parallelAppendNoRemainingSlots"):null)??(!B&&be.length===0?l("shell.parallelCreateNoAvailableProviders"):null),Ee={"--parallel-member-columns":String(Math.max(1,Math.min(y,4)))};function ve(ae){D(null),le(null),_e(se=>{if(!(ae in se))return se;const ke={...se};return delete ke[ae],ke})}function Tt(){D(null),le(null),_e({})}function nt(ae,se){ve(ae);const ke=se?"temporary_worktree":"none";x(ye=>ye.map((Me,$)=>$===ae?{...Me,workspaceIsolationMode:ke}:Me))}async function mt(){const ae=g.trim();if(!o&&!ae){D(l("shell.parallelCreatePromptRequired"));return}if(fe.kind==="group"&&c===0){D(l("shell.parallelAppendNoRemainingSlots"));return}if(!be.length){D(l("shell.parallelCreateNoAvailableProviders"));return}X(!0),D(null),le(null),_e({});try{const se=OR(),ke=j.map(Me=>{const $=mo(Me.providerConfigMode,Me.providerPresetId);return{provider:Me.provider,model:Me.model.trim()||null,providerConfigMode:$.providerConfigMode,providerPresetId:$.providerConfigMode==="cc-switch-preset"?$.providerPresetId:null,memberPrompt:Me.memberPrompt.trim()||null,workspaceIsolationMode:Me.workspaceIsolationMode}}),ye=fe.kind==="group"?await ky(fe.groupId,{permissionMode:se,members:ke}):fe.kind==="session"?await yy(fe.sessionId,{sharedPrompt:ae,permissionMode:se,members:ke}):await xy(fe.workspaceId,{sharedPrompt:ae,permissionMode:se,members:ke});if(ye.memberFailures.length>0){const Me=Zp(j.length,ye.memberFailures);le(ye),_e(Object.fromEntries(ye.memberFailures.map($=>[$.ordinal,$]))),D(Me>0?l("shell.parallelCreatePartialFailure",{successCount:Me,failureCount:ye.memberFailures.length}):l("shell.parallelCreateAllFailed",{failureCount:ye.memberFailures.length}));return}await r(ye)}catch(se){D(se instanceof Error?se.message:l("shell.parallelGroupLoadFailed"))}finally{X(!1)}}return s.jsx(xu,{open:e,title:Ue,description:je,size:"xwide",layout:"form",className:"parallel-create-modal",bodyClassName:"parallel-create-modal-body",dismissible:!K,onClose:n,footer:s.jsxs(Ss,{align:"between",className:"parallel-create-modal-footer",children:[s.jsx("div",{className:"parallel-create-modal-status",role:"status","aria-live":"polite",children:Ce?s.jsx("span",{className:"parallel-create-modal-error",children:Ce}):null}),s.jsxs("div",{className:"parallel-create-modal-footer-actions",children:[V&&ue>0?s.jsx("button",{type:"button",className:"secondary-button",disabled:K,onClick:()=>{r(V)},children:l("shell.parallelCreateContinuePartial")}):null,s.jsx("button",{type:"button",className:"secondary-button",disabled:K,onClick:n,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:K||B||be.length===0||fe.kind==="group"&&c===0,onClick:()=>{mt()},children:K?J:q})]})]}),children:s.jsxs("div",{className:"parallel-create-layout",children:[s.jsx(Mn,{className:"parallel-create-shared-section",tone:"accent",children:s.jsxs("div",{className:"parallel-create-target-row",children:[s.jsx(Lt,{className:"parallel-create-target-field",label:Te,htmlFor:`${i}-shared-prompt`,children:s.jsx("textarea",{id:`${i}-shared-prompt`,className:"parallel-create-textarea parallel-create-textarea-target",rows:2,value:g,readOnly:o,"aria-readonly":o,"data-readonly":o?"true":void 0,onChange:ae=>{o||(Tt(),m(ae.target.value))}})}),s.jsx(Lt,{className:"parallel-create-count-field",label:O,children:s.jsx("div",{className:"parallel-create-count-group",role:"group","aria-label":O,children:u.map(ae=>s.jsx("button",{type:"button",className:"parallel-create-count-button","data-active":y===ae,onClick:()=>{Tt(),S(ae)},children:ae},ae))})})]})}),s.jsx(Mn,{className:"parallel-create-members-section",heading:l("shell.parallelCreateMembersTitle"),children:s.jsx("div",{className:"parallel-create-member-list",style:Ee,children:ne.map(({draft:ae,index:se,supportsDeploymentPicker:ke,showPresetColumn:ye,deploymentPresetOptions:Me,selectedPresetValue:$,selectedPresetOption:Q,triggerLabel:ge,selectedModelValue:Ne,modelOptions:Be,loadingPresets:Ke,loadingModels:Ie,modelColumnDisabled:ut})=>{var Ht;const Qe=be,rt=Qe.includes(ae.provider)?ae.provider:"",st=Qe.length>0?Qe.map(Ye=>({value:Ye,label:Ec(Ye,"full")})):[{value:"",label:B?l("shell.parallelCreateProvidersLoading"):l("shell.parallelCreateNoAvailableProviders")}],qe=xc(A[ae.provider]??null,ae.provider),gt=qe.length>0?[{value:"",label:((Ht=qe.find(Ye=>Ye.usesProviderDefault===!0))==null?void 0:Ht.name)??l("shell.parallelPaneModelFallback")},...qe.filter(Ye=>Ye.usesProviderDefault!==!0).map(Ye=>({value:Ye.id,label:Ye.name}))]:[{value:"",label:l("shell.parallelCreateNoModelsAvailable")}];return s.jsxs("article",{className:"parallel-create-member-card","data-state":C[se]?"error":He.has(se)?"success":void 0,children:[s.jsxs("header",{className:"parallel-create-member-header",children:[s.jsxs("div",{className:"parallel-create-member-title-block",children:[s.jsx("strong",{children:l("shell.parallelCreateMemberTitle",{index:se+1})}),s.jsx("span",{className:"parallel-create-member-provider",children:Ec(ae.provider,"full")}),s.jsxs("label",{className:"parallel-create-isolation-toggle",children:[s.jsx("input",{type:"checkbox",checked:ae.workspaceIsolationMode==="temporary_worktree",onChange:Ye=>{nt(se,Ye.target.checked)}}),s.jsx("span",{className:"parallel-create-isolation-copy",children:l("shell.parallelCreateIsolationLabel")})]})]}),C[se]?s.jsx("span",{className:"parallel-create-member-status error",children:l("shell.parallelCreateMemberFailed")}):He.has(se)?s.jsx("span",{className:"parallel-create-member-status success",children:l("shell.parallelCreateMemberSucceeded")}):null]}),s.jsxs("div",{className:"parallel-create-member-grid",children:[s.jsx(Lt,{label:l("shell.createSessionProviderLabel"),htmlFor:`${i}-member-${se}-provider`,children:s.jsx(Xp,{triggerId:`${i}-member-${se}-provider`,className:"parallel-create-provider-select",ariaLabel:l("shell.createSessionProviderLabel"),value:rt,options:st,disabled:!Qe.length,onChange:Ye=>{ve(se);const dt=Ye;x(De=>De.map((bt,Ze)=>Ze===se?{...bt,provider:dt,providerConfigMode:"global-default",providerPresetId:null,model:""}:bt))}})}),s.jsx(Lt,{label:l("shell.parallelCreateModelLabel"),htmlFor:ke?void 0:`${i}-member-${se}-model`,children:ke?s.jsx("div",{className:"parallel-create-deployment-select",children:s.jsx(HR,{triggerId:`${i}-member-${se}-model`,ariaLabel:l("shell.parallelCreateModelLabel"),triggerLabel:ge,presetOptions:Me,selectedPresetValue:$,selectedPresetSummary:(Q==null?void 0:Q.summary)??null,onSelectPreset:Ye=>{ve(se),x(dt=>dt.map((De,bt)=>bt!==se?De:Ye===Io?{...De,providerConfigMode:"global-default",providerPresetId:null,model:""}:{...De,providerConfigMode:"cc-switch-preset",providerPresetId:Ye,model:""}))},modelOptions:Be,selectedModelValue:Ne,onSelectModel:Ye=>{ve(se),x(dt=>dt.map((De,bt)=>bt===se?{...De,model:Ye===ta?"":Ye}:De))},loadingPresets:Ke,loadingModels:Ie,modelColumnDisabled:ut,showPresetColumn:ye,modelEmptyText:l("conversation.deploymentModelEmpty")})}):s.jsx(Xp,{triggerId:`${i}-member-${se}-model`,className:"parallel-create-provider-select",ariaLabel:l("shell.parallelCreateModelLabel"),value:ae.model,options:gt,disabled:!Qe.length||qe.length===0,onChange:Ye=>{ve(se),x(dt=>dt.map((De,bt)=>bt===se?{...De,model:Ye}:De))}})})]}),s.jsx(Lt,{label:l("shell.parallelCreateMemberPromptLabel"),htmlFor:`${i}-member-${se}-prompt`,children:s.jsx("textarea",{id:`${i}-member-${se}-prompt`,className:"parallel-create-textarea member",rows:2,value:ae.memberPrompt,onChange:Ye=>{ve(se);const dt=Ye.target.value;x(De=>De.map((bt,Ze)=>Ze===se?{...bt,memberPrompt:dt}:bt))}})}),C[se]?s.jsxs("div",{className:"parallel-create-member-error",role:"alert",children:[s.jsx("strong",{children:l("shell.parallelCreateMemberErrorTitle")}),s.jsx("p",{children:C[se].detail})]}):null]},`parallel-member-${se}`)})})})]})})}const XR=12,JR=180,ef=72;function QR(e,t){const[n,r]=f.useState(!1),[i,a]=f.useState(""),[o,c]=f.useState({}),[u,d]=f.useState({}),[h,p]=f.useState(!1),[g,m]=f.useState(null);f.useEffect(()=>{e||(r(!1),a(""),m(null))},[e]),f.useEffect(()=>{if(!e||!n)return;const j=t.filter(A=>u[A.sessionId]!==!0);if(j.length===0)return;let x=!1;return p(!0),m(null),Promise.allSettled(j.map(async A=>{const T=await Hf(A.sessionId,null,XR,"backward");return{sessionId:A.sessionId,summary:ZR(T.messages)}})).then(A=>{if(x)return;const T={},F={};let R=0;j.forEach(I=>{T[I.sessionId]=!0});for(const I of A){if(I.status==="fulfilled"){F[I.value.sessionId]=I.value.summary;continue}R+=1}d(I=>({...I,...T})),Object.keys(F).length>0&&c(I=>({...I,...F})),m(R>0?l("shell.archiveSearchSummaryFailed"):null)}).finally(()=>{x||p(!1)}),()=>{x=!0}},[u,e,n,t]);const y=f.useMemo(()=>{const j=wc(i);return j?t.filter(x=>wc(x.title).includes(j)?!0:wc(o[x.sessionId]??"").includes(j)):t},[i,t,o]);function S(){r(j=>{const x=!j;return x||(a(""),m(null)),x})}return{searchOpen:n,searchKeyword:i,filteredSessions:y,summaryLoading:h,summaryError:g,summaryBySessionId:o,setSearchKeyword:a,toggleSearch:S}}function ZR(e){const t=[...e].sort((r,i)=>r.sequence-i.sequence).map(eP).filter(r=>r.length>0);if(t.length===0)return"";const n=t.slice(-3).join(" · ");return ou(n,JR)}function eP(e){var n,r;const t=tk(e.content);return t.length>0?ou(t,ef):(r=(n=e.toolCall)==null?void 0:n.name)!=null&&r.trim()?ou(e.toolCall.name.trim(),ef):""}function wc(e){return tk(e).toLocaleLowerCase()}function tk(e){return e.replace(/\s+/g," ").trim()}function ou(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}const tf="workbench.left.width",nf="workbench.right.width",rf="workbench.left.collapsed",sf="workbench.right.collapsed",bo="workbench.last.session.path",vc="workbench.workspace.selected.id",af="workbench.notifications.seen_at",tP=280,nP=320,of=240,lf=280,cf=520,uf=560,rP=200,Sc=20,Yi=40,ko=5,sP=3e4,iP=12,df=60*1e3,aP=4e3,hf=220,pf=18,oP=6,si="data-workbench-panel-resizing",yo="data-workbench-window-resizing",lP=180,cP="workbench:focus-composer",uP=new Set(["starting","running","reconnecting","stale","unknown"]),dP=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"],hP=["--workbench-titlebar-live-content-shift-y","--workbench-nav-toolbar-live-shift-y","--workbench-info-tabs-live-shift-y","--workbench-auxiliary-toolbar-button-live-shift-y","--workbench-conversation-header-main-live-shift-y","--workbench-conversation-header-actions-live-shift-y","--workbench-terminal-tabbar-live-shift-y","--workbench-collapsed-controls-live-shift-y","--workbench-collapsed-left-controls-live-shift-y","--workbench-collapsed-right-controls-live-shift-y"],Rt={navToolbar:{selector:".workbench-nav-toolbar",variableName:"--workbench-nav-toolbar-live-shift-y"},infoTabs:{selector:".workbench-info-tabs",variableName:"--workbench-info-tabs-live-shift-y"},auxiliaryToolbarButton:{selector:".workbench-auxiliary-header > .workbench-nav-toolbar-button",variableName:"--workbench-auxiliary-toolbar-button-live-shift-y"},conversationHeaderMain:{selector:".conversation-header-main",variableName:"--workbench-conversation-header-main-live-shift-y"},conversationHeaderActions:{selector:".conversation-header-actions",variableName:"--workbench-conversation-header-actions-live-shift-y"},terminalTabbarMain:{selector:".terminal-tabbar-main",variableName:"--workbench-terminal-tabbar-live-shift-y"},collapsedLeftControls:{selector:'.workbench-collapsed-controls.left[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-left-controls-live-shift-y"},collapsedRightControls:{selector:'.workbench-collapsed-controls.right[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-right-controls-live-shift-y"}};function nk(e,t){const n=e.getPropertyValue(t).trim();if(!n)return null;const r=Number.parseFloat(n);return Number.isFinite(r)?r:null}function pP(e){return Math.round(e*100)/100}function fP(e,t){const n=t.getBoundingClientRect();if(n.width<=0||n.height<=0)return null;const r=window.getComputedStyle(t);return r.display==="none"||r.visibility==="hidden"?null:n.top-e.top+n.height/2}function ns(e,t){const n=e.getBoundingClientRect(),i=Array.from(e.querySelectorAll(t)).map(a=>fP(n,a)).filter(a=>a!==null);return i.length===0?null:i.reduce((a,o)=>a+o,0)/i.length}function Sr(e,t,n){const r=e.style.getPropertyValue(t).trim();if(n===null||!Number.isFinite(n)){r&&e.style.removeProperty(t);return}const i=`${pP(n)}px`;r!==i&&e.style.setProperty(t,i)}function Cr(e,t,n,r){return r===null?null:(nk(e,t)??0)+(n-r)}function ff(e){if(e)for(const t of hP)e.style.removeProperty(t)}function mP(e){return uP.has(e.runningState??"idle")||e.activityState==="running"}function gP(e,t){const n=[];for(const r of[...t].sort()){const i=e.get(r);!i||i.size===0||n.push(`${r}:${[...i].sort().join(",")}`)}return n.join("|")}function bP(e){var i,a;const t=((i=e.lastErrorCode)==null?void 0:i.trim())??"",n=((a=e.lastErrorDetail)==null?void 0:a.trim())??"",r=[t,n].filter(o=>o.length>0).join(" · ");return r?r.length<=hf?r:`${r.slice(0,hf-3)}...`:null}function kP(e,t,n){var a,o,c,u,d,h,p,g,m,y,S,j;const r=new Map(e.projects.map(x=>[x.id,x.workspaceId])),i=[];for(const x of n){const A=x.title.trim()||x.projectName;if(x.assistantState.lifecycleStage==="analyzed"&&!((a=x.assistantState.linkedSessionId)!=null&&a.trim())&&x.assistantState.lastAnalyzedAt){i.push({id:`todo-analysis-completed:${x.id}:${x.assistantState.lastAnalyzedAt}`,kind:"todo_analyzed",title:l("shell.globalNotificationTodoAnalyzedTitle",{title:A}),body:((o=x.assistantState.analysisSummary)==null?void 0:o.trim())||((c=x.assistantState.generatedPrompt)==null?void 0:c.trim())||x.content,routePath:Ms(x.workspaceId),workspaceId:x.workspaceId,createdAt:x.assistantState.lastAnalyzedAt});continue}x.assistantState.lifecycleStage==="failed"&&i.push({id:`todo-analysis-failed:${x.id}:${x.updatedAt}`,kind:"todo_analyze_failed",title:l("shell.globalNotificationTodoAnalyzeFailedTitle",{title:A}),body:((u=x.assistantState.lastError)==null?void 0:u.trim())||x.content,routePath:Ms(x.workspaceId),workspaceId:x.workspaceId,createdAt:x.updatedAt})}for(const x of t){const A=((d=x.sessionTitle)==null?void 0:d.trim())||x.projectName,T=x.updatedAt||x.lastAutomationAt||x.createdAt;if(x.status==="waiting_user"){i.push({id:`follow-up-waiting:${x.id}`,kind:"follow_up_waiting_user",title:l("shell.globalNotificationFollowUpWaitingTitle",{title:A}),body:((h=x.waitingReason)==null?void 0:h.trim())||((p=x.lastAutomationSummary)==null?void 0:p.trim())||x.objective,routePath:ir(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:T});continue}if(x.status==="completed"){i.push({id:`follow-up-completed:${x.id}`,kind:"follow_up_completed",title:l("shell.globalNotificationFollowUpCompletedTitle",{title:A}),body:((g=x.lastAutomationSummary)==null?void 0:g.trim())||x.objective,routePath:ir(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:T});continue}x.status==="failed"&&i.push({id:`follow-up-failed:${x.id}`,kind:"follow_up_failed",title:l("shell.globalNotificationFollowUpFailedTitle",{title:A}),body:((m=x.lastAutomationSummary)==null?void 0:m.trim())||((y=x.waitingReason)==null?void 0:y.trim())||x.objective,routePath:ir(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:T})}for(const x of e.verifications){if(x.status!=="failed")continue;const A=x.projectId?r.get(x.projectId)??null:null,T=((S=x.targetRef)==null?void 0:S.trim())||x.verificationType;i.push({id:`verification-failed:${x.id}`,kind:"verification_failed",title:l("shell.globalNotificationVerificationFailedTitle",{title:T}),body:((j=x.summary)==null?void 0:j.trim())||l("shell.globalNotificationVerificationFailedFallback"),routePath:A?Ms(A):null,workspaceId:A,createdAt:x.finishedAt||x.startedAt||x.createdAt})}return i.sort((x,A)=>{const T=mf(x.kind)-mf(A.kind);return T!==0?T:as(A.createdAt)-as(x.createdAt)}).slice(0,iP)}function mf(e){switch(e){case"follow_up_waiting_user":return 0;case"todo_analyze_failed":return 1;case"follow_up_failed":return 2;case"verification_failed":return 3;case"todo_analyzed":return 4;case"follow_up_completed":return 5;default:return 9}}function yP(e){switch(e){case"follow_up_waiting_user":return l("shell.globalNotificationKindWaitingUser");case"todo_analyzed":return l("shell.globalNotificationKindTodoAnalyzed");case"todo_analyze_failed":return l("shell.globalNotificationKindTodoAnalyzeFailed");case"follow_up_completed":return l("shell.globalNotificationKindFollowUpCompleted");case"follow_up_failed":return l("shell.globalNotificationKindFollowUpFailed");case"verification_failed":return l("shell.globalNotificationKindVerificationFailed");default:return l("shell.globalNotificationsPanelTitle")}}function as(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function xP(e){return/^(?:[A-Za-z0-9_-]+)(?:\/[A-Za-z0-9_-]+)*$/.test(e)}function wP(e){return/^(?:[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*\/?)?$/.test(e)}function vP(e,t){const n=new Set,r=(e==null?void 0:e.currentBranch)??"",i=((e==null?void 0:e.local)??[]).slice().sort((c,u)=>Number(u.current)-Number(c.current)||c.name.localeCompare(u.name)).map(c=>({value:c.name,current:c.current,recommended:c.name===r})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0)),a=((e==null?void 0:e.remote)??[]).map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0)),o=t.map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0));return{localBranches:i,remoteBranches:a,tags:o}}function SP(e){return e.getBoundingClientRect()}function CP(e,t){return t?as(e.createdAt)>as(t):!0}function NP(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t)}function gf(e,t){var o,c;const n=["/workspaces/:workspaceId","/workspaces/:workspaceId/sessions","/workspaces/:workspaceId/sessions/:sessionId","/workspaces/:workspaceId/tools","/workspaces/:workspaceId/tools/files","/workspaces/:workspaceId/tools/git","/workspaces/:workspaceId/tools/processes","/workspaces/:workspaceId/terminals","/workspaces/:workspaceId/butler"];for(const u of n){const d=vt(u,e),h=(o=d==null?void 0:d.params.workspaceId)==null?void 0:o.trim();if(h)return h}const r=la(e),i=(r==null?void 0:r.sessionId)??null;return!i||!_k(i)?null:((c=new URLSearchParams(t).get("workspaceId"))==null?void 0:c.trim())||null}function jP(e){return e.startsWith("/sessions")||e.startsWith("/terminals")||e.startsWith("/tools")}function Cc(e){return e==="mobile"?xn():"/landing"}function la(e){var a,o,c;const t=vt("/workspaces/:workspaceId/sessions/:sessionId",e),n=(a=t==null?void 0:t.params.sessionId)==null?void 0:a.trim();if(n)return{sessionId:n,workspaceId:((o=t==null?void 0:t.params.workspaceId)==null?void 0:o.trim())??null};const r=vt("/sessions/:sessionId",e),i=(c=r==null?void 0:r.params.sessionId)==null?void 0:c.trim();return i?{sessionId:i,workspaceId:null}:null}function TP(e){return!!(vt("/sessions",e)||vt("/workspaces/:workspaceId/sessions",e))}function bf(e){return!!la(e)}function IP(e){return!!(vt("/tools",e)||vt("/tools/files",e)||vt("/tools/git",e)||vt("/tools/processes",e)||vt("/workspaces/:workspaceId/tools",e)||vt("/workspaces/:workspaceId/tools/files",e)||vt("/workspaces/:workspaceId/tools/git",e)||vt("/workspaces/:workspaceId/tools/processes",e))}function Eo(e){return!!(vt("/terminals",e)||vt("/workspaces/:workspaceId/terminals",e))}function Mo(e){return!!vt("/workspaces/:workspaceId/butler",e)}function EP(e,t){return vt("/workspaces/:workspaceId/debug",e)?dm(t):vt("/workspaces/:workspaceId",e)?Ir(t):vt("/workspaces/:workspaceId/tools/files",e)||vt("/tools/files",e)?pm(t):vt("/workspaces/:workspaceId/tools/git",e)||vt("/tools/git",e)?fm(t):vt("/workspaces/:workspaceId/tools/processes",e)||vt("/tools/processes",e)?mm(t):vt("/workspaces/:workspaceId/tools",e)||vt("/tools",e)?hm(t):Eo(e)?js(t):Mo(e)?Ms(t):xi(t)}function MP(e){return e.trim().replace(/\\/g,"/").replace(/^(?:\.\/)+/,"").replace(/^\/+/,"")}const RP=f.lazy(async()=>({default:(await bu(()=>import("./FileContextPanel-BcM7AIT4.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).FileContextPanel})),PP=f.lazy(async()=>({default:(await bu(()=>import("./GitSidebar-CMtkaxuI.js"),__vite__mapDeps([11,1,2,3,4,5,7,6,8,9,10]))).GitSidebar})),AP=f.lazy(async()=>({default:(await bu(()=>import("./TerminalManagerPanel-BxlhZp8c.js"),__vite__mapDeps([12,1,2,6,3,4,5,13,14,8,9,10]))).TerminalManagerPanel}));function LP(e){return!!((e==null?void 0:e.item)??(e==null?void 0:e.session))}function Rn(e){return Ni(e)}function _P(e){return e&&"item"in e?e.item:(e==null?void 0:e.session)??null}function ci(e){return Array.isArray(e==null?void 0:e.visibleSessionTree)?e.visibleSessionTree.filter(LP):[]}async function rk(e,t){const n=await qf(t,e);if(n.canStartSession===!1)throw new Error(n.limitations[0]??l("conversation.capabilityDenied"))}const sk=f.createContext(null);function Qo(e){return OE(e)}function Tr(e){return e.isArchived===!0}function Ia(e){return am(e)}function ik(e,t){return Nu(e,{getId:n=>n.sessionId,getParentId:Ia,compare:(n,r)=>ya(n,r,t)})}function DP(e,t){const n=BP(e);return ak(n,t)}function ak(e,t){const n=OP(e);return Nu(n,{getId:r=>r.session.sessionId,getParentId:r=>Ia(r.session),compare:(r,i)=>ya(r.session,i.session,t)}).map(r=>lk(r))}function BP(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...ok(t.childWorktrees)])}function ok(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...ok(t.children)])}function OP(e){const t=[],n=new Set;for(const r of e){const i=r.session.sessionId.trim();!i||n.has(i)||(n.add(i),t.push(r))}return t}function lk(e,t=0){return{item:e.item.session,depth:t,children:e.children.map(n=>lk(n,t+1))}}function lu(e,t){return{...e,depth:e.depth+t,children:Rn(e).map(n=>lu(n,t))}}function kf(e){return`${e}::parallel-anchor-member`}function yf(e){const{session:t,depth:n,children:r}=e;return{item:t,depth:n,children:[...r]}}function cu(e,t){for(const n of e){if(n.item.sessionId===t)return n;const r=cu(Rn(n),t);if(r)return r}return null}function WP(e,t){const n=t.trim();if(!n)return null;for(const r of e){const i=ck(r,n,null);if(i)return i}return null}function ck(e,t,n){var i,a;const r=((a=(i=e.item.parallelGroup)==null?void 0:i.groupId)==null?void 0:a.trim())||n;if(e.item.sessionId===t)return r;for(const o of Rn(e)){const c=ck(o,t,r);if(c)return c}return null}function uk(e){return e.filter(t=>{if(Tr(t))return!1;const n=Ia(t);if(!n)return!0;const r=e.find(i=>i.sessionId===n);return r&&Tr(r)?!Qo(t):!0})}function FP(e){return e.flatMap(t=>{const n=_P(t);return n?[n,...lm(Rn(t))]:[]})}function $P(e,t,n){var g;const r=Rn(e),i=Ns(r).sort((m,y)=>ya(m.item,y.item,n));if(!(((g=e.item.parallelGroup)==null?void 0:g.role)==="anchor"&&r.some(m=>{var y,S;return((y=m.item.parallelGroup)==null?void 0:y.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}))){const m=new Set(i.slice(0,Math.max(0,t)).map(y=>y.item.sessionId));return{...e,children:uu(r,m)}}const o=r.slice().sort((m,y)=>ya(m.item,y.item,n)),c=o.filter(m=>{var y,S;return((y=m.item.parallelGroup)==null?void 0:y.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(m=>m.item.sessionId),u=o.filter(m=>{var y,S;return((y=m.item.parallelGroup)==null?void 0:y.groupId)!==((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(m=>m.item.sessionId),d=[...c,...u],h=Math.max(0,t-d.length),p=new Set(d);for(const m of i){if(p.size>=d.length+h)break;p.add(m.item.sessionId)}return{...e,children:uu(r,p)}}function uu(e,t){return e.flatMap(n=>{const r=uu(Rn(n),t);return!t.has(n.item.sessionId)&&r.length===0?[]:[{...n,children:r}]})}function xo(e,t,n,r=-1){if(e<=0)return 0;const i=r>=0?Math.max(t,r+1):t;return Math.min(e,Math.max(n??0,i))}function xf(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(i=>e[i]===t[i])}function zP(e){const t=e.lastMessageAt??e.updatedAt;return t?new Date(t).toLocaleDateString():""}function fl(e,t="compact"){return Ec(e,t)}const HP={position:"relative",zIndex:0},UP={zIndex:1};function dk(e,t,n,r){const i=[],a=(r==null?void 0:r.trim())||t.name;n&&i.push(a);const o=zP(e);return o&&i.push(o),i.join(" · ")||a}function wf(e,t){return fI("session-state-indicator",e,t)}function qP(e,t){return ob(e,t)}function vf(e,t){try{const n=window.localStorage.getItem(e),r=n?Number(n):Number.NaN;return Number.isFinite(r)?r:t}catch{return t}}function Sf(e,t){try{const n=window.localStorage.getItem(e);return n===null?t:n==="true"}catch{return t}}function Cf(e){var t;try{const n=(t=window.localStorage.getItem(e))==null?void 0:t.trim();return n||null}catch{return null}}function vs(e,t){try{window.localStorage.setItem(e,t)}catch{}}function GP(e){try{window.localStorage.removeItem(e)}catch{}}function wo(e,t,n){return Math.max(t,Math.min(n,e))}function vo(e){const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function VP(e){const t=window.getComputedStyle(e),n=vo(t.getPropertyValue("--desktop-macos-titlebar-height")),r=vo(t.getPropertyValue("--workbench-header-min-height")),i=vo(t.getPropertyValue("--workbench-macos-titlebar-padding-top")),a=vo(t.getPropertyValue("--workbench-macos-titlebar-padding-bottom"));return Math.max(n,r,40)+i+a+8}function Nf(e,t){const n=t.getBoundingClientRect();return e>=n.top&&e<=n.top+VP(t)}function KP(e){return e instanceof HTMLElement?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||!!e.closest("[contenteditable='true']"):!1}function YP(){typeof window>"u"||window.dispatchEvent(new CustomEvent(cP))}function hk(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){if(r.workspace.id===n)return r;const i=hk(r.children,n);if(i)return i}return null}function jf(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){const i=hk(r.childWorktrees,n);if(i)return i}return null}function pk(e){return e.flatMap(t=>[t.workspace.id,...pk(t.children)])}function fk(e){return new Set(e.flatMap(t=>[t.workspace.id,...pk(t.childWorktrees)]))}function Tf(e){return!e||!Array.isArray(e.items)?[]:e.items.filter(t=>{var n;return t.collapsed===!0&&((n=t.workspace)==null?void 0:n.id)}).map(t=>t.workspace.id)}function Nc(e,t){const n=new Set(t);return{items:e.map(r=>({workspace:r.workspace,sessions:r.sessions,childWorktrees:r.childWorktrees,collapsed:n.has(r.workspace.id)}))}}function mk(e,t,n,r=new Set){return e.map(i=>{const a=i.sessions.filter(c=>!r.has(c.sessionId)),o=uk(a);return{workspace:i.workspace,meta:i.meta,visibleSessions:o,archivedSessions:a.filter(c=>Tr(c)&&!Ia(c)),visibleSessionTree:ik(o,n).filter(c=>!t.has(c.item.sessionId)&&!ju(Rn(c),u=>t.has(u.sessionId))),children:mk(i.children,t,n,r)}})}function du(e){return e.flatMap(t=>[t.workspace.id,...du(t.children)])}function na(e){return e.flatMap(t=>[...t.visibleSessionTree,...na(t.children)])}function gk(e){return e.flatMap(t=>[t,...gk(t.children)])}function XP(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:ci(n)};const r=bk(n.childWorktrees,t);if(r)return r}return null}function bk(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:n.visibleSessionTree};const r=bk(n.children,t);if(r)return r}return null}function JP(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=kk(n.childWorktrees,t);if(r)return r}return null}function jc(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return n.workspace;const r=yk(n.childWorktrees,t);if(r)return r}return null}function kk(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=kk(n.children,t);if(r)return r}return null}function yk(e,t){for(const n of e){if(n.workspace.id===t)return n.workspace;const r=yk(n.children,t);if(r)return r}return null}function xk(e,t){for(const n of e){if(n.workspace.id===t)return[n.workspace.id];const r=xk(n.children,t);if(r.length>0)return[n.workspace.id,...r]}return[]}function If(e){return e.flatMap(t=>[t.workspace.id,...wk(t.childWorktrees)])}function wk(e){return e.flatMap(t=>[t.workspace.id,...wk(t.children)])}function QP(e,t=[]){if(e.tone!=="worktree")return e.rootDisplayName;if(t.length>0)return t.join(" / ");const n=[e.rootDisplayName];return e.parentDisplayName&&e.parentDisplayName!==e.rootDisplayName&&n.push(e.parentDisplayName),n.join(" / ")}function ZP(e,t,n,r){if(t===n)return e;const i=e.findIndex(d=>d.workspace.id===t),a=e.findIndex(d=>d.workspace.id===n);if(i<0||a<0)return e;const o=[...e],[c]=o.splice(i,1);if(!c)return e;const u=o.findIndex(d=>d.workspace.id===n);return u<0?e:(o.splice(r==="before"?u:u+1,0,c),o.every((d,h)=>{var p;return d.workspace.id===((p=e[h])==null?void 0:p.workspace.id)})?e:o)}function eA(e,t){if(!Array.isArray(e.items)||t.size===0)return e;let n=!1;const r=e.items.map(i=>{let a=!1;const o=i.sessions.map(u=>{const d=t.get(u.sessionId);return d===void 0||Tr(u)===d?u:(n=!0,a=!0,{...u,isArchived:d})}),c=Sk(i.childWorktrees??[],t,u=>{u&&(n=!0,a=!0)});return a?{...i,sessions:o,childWorktrees:c}:i});return n?{...e,items:r}:e}function tA(e,t){if(!(!Array.isArray(t.items)||e.size===0))for(const n of t.items){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&Tr(r)===i&&e.delete(r.sessionId)}Ck(e,n.childWorktrees??[])}}function nA(e,t,n){let r=!1;const i=e.map(a=>{if(a.workspace.id!==t.workspaceId){const{nodes:u,changed:d}=Nk(a.childWorktrees,t,n);return d?(r=!0,{...a,childWorktrees:u}):a}const o=a.sessions.findIndex(u=>u.sessionId===t.sessionId),c=o>=0?a.sessions.map((u,d)=>d===o?t:u):[t,...a.sessions];return r=!0,{...a,sessions:Ta(c,n)}});return r?i:e}function rA(e,t,n){let r=!1;const i=e.map(a=>{let o=!1;const c=a.sessions.map(d=>d.sessionId!==t?d:(r=!0,o=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState})),u=ml(a.childWorktrees,d=>d.sessionId!==t?d:(r=!0,o=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState}));return o?{...a,sessions:c,childWorktrees:u}:a});return r?i:e}function Ef(e,t,n){let r=!1;const i=e.map(a=>{let o=!1;const c=a.sessions.map(d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,o=!0,{...d,isArchived:n})),u=ml(a.childWorktrees,d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,o=!0,{...d,isArchived:n}));return o?{...a,sessions:c,childWorktrees:u}:a});return r?i:e}function Mf(e,t,n){let r=!1;const i=e.map(a=>{let o=!1;const c=a.sessions.map(d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,o=!0,{...d,isFavorite:n})),u=ml(a.childWorktrees,d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,o=!0,{...d,isFavorite:n}));return o?{...a,sessions:c,childWorktrees:u}:a});return r?i:e}function sA(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function iA(e){return e?e.slice(0,8):"--"}function Rf(e,t,n){return n?e.includes(t)?e:[...e,t]:e.includes(t)?e.filter(r=>r!==t):e}function vk(e,t){const n=e.filter(r=>t.has(r));return n.length===e.length?e:n}function Sk(e,t,n){return e.map(r=>{let i=!1;const a=r.sessions.map(c=>{const u=t.get(c.sessionId);return u===void 0||Tr(c)===u?c:(i=!0,{...c,isArchived:u})}),o=Sk(r.children,t,c=>{c&&(i=!0)});return n(i),i?{...r,sessions:a,children:o}:r})}function Ck(e,t){for(const n of t){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&Tr(r)===i&&e.delete(r.sessionId)}Ck(e,n.children)}}function Nk(e,t,n){let r=!1;const i=e.map(a=>{if(a.workspace.id===t.workspaceId){const c=a.sessions.findIndex(d=>d.sessionId===t.sessionId),u=c>=0?a.sessions.map((d,h)=>h===c?t:d):[t,...a.sessions];return r=!0,{...a,sessions:Ta(u,n)}}const o=Nk(a.children,t,n);return o.changed?(r=!0,{...a,children:o.nodes}):a});return{nodes:r?i:[...e],changed:r}}function aA(e,t){return e.map(n=>({...n,sessions:Ta(n.sessions,t),childWorktrees:cd(n.childWorktrees,t)}))}function ml(e,t){let n=!1;const r=e.map(i=>{let a=!1;const o=i.sessions.map(u=>{const d=t(u);return d!==u&&(a=!0,n=!0),d}),c=ml(i.children,t);return c!==i.children&&(a=!0,n=!0),a?{...i,sessions:o,children:c}:i});return n?r:[...e]}function hu(e){return`workspace-management.summary.${e}`}function jk(e){return`git-sidebar.snapshot.${e}`}function Tk(e,t){const n=e.repoRoot??null;return{workspaceId:e.id,name:e.name,path:e.path,git:{isRepository:!!n,repoRoot:n,currentBranch:null,commitCount:null,remotes:[],error:null},codeComposition:{scannedFileCount:0,truncated:!1,items:[],error:null}}}function Ik(e,t){const n=e.git.repoRoot??t.repoRoot??null;return{...e,workspaceId:t.id,name:t.name,path:t.path,git:{...e.git,isRepository:e.git.isRepository||!!n,repoRoot:n}}}function Ek(e,t){var a,o,c,u;const n=((a=t.status)==null?void 0:a.snapshot.enabled)!==!1,r=n?((o=t.status)==null?void 0:o.snapshot.repoRoot)??e.git.repoRoot:e.git.repoRoot,i=n?((c=t.status)==null?void 0:c.snapshot.branch)??((u=t.branches)==null?void 0:u.currentBranch)??e.git.currentBranch??null:e.git.currentBranch??null;return{...e,git:{...e.git,isRepository:n&&(e.git.isRepository||!!r),repoRoot:r,currentBranch:i,error:null}}}function Mk({count:e,className:t="workbench-skeleton-lines"}){return s.jsx("div",{className:t,"aria-hidden":"true",children:Array.from({length:e},(n,r)=>s.jsx("span",{className:"skeleton-line"},r))})}function oA(){return s.jsx("div",{className:"workbench-nav-loading","aria-hidden":"true",children:Array.from({length:3},(e,t)=>s.jsxs("section",{className:"workbench-skeleton-card",children:[s.jsxs("div",{className:"workbench-skeleton-heading",children:[s.jsx("span",{className:"skeleton-line short"}),s.jsx("span",{className:"skeleton-line tiny"})]}),s.jsx("div",{className:"workbench-skeleton-list",children:Array.from({length:3},(n,r)=>s.jsxs("div",{className:"workbench-skeleton-session",children:[s.jsx("span",{className:"workbench-skeleton-dot"}),s.jsx(Mk,{count:2,className:"workbench-skeleton-lines compact"})]},r))})]},t))})}function So(){return s.jsx("section",{className:"workbench-info-skeleton","aria-hidden":"true",children:Array.from({length:4},(e,t)=>s.jsxs("article",{className:"workbench-info-skeleton-card",children:[s.jsx("span",{className:"skeleton-line short"}),s.jsx(Mk,{count:3})]},t))})}function lA({side:e,collapsed:t}){const n=e==="left"?8.5:15.5,r=e==="left"?t?"12 9 15 12 12 15":"15 9 12 12 15 15":t?"12 9 9 12 12 15":"9 9 12 12 9 15";return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("line",{x1:n,y1:"4",x2:n,y2:"20"}),s.jsx("polyline",{points:r})]})}function Pf({ariaLabel:e,side:t,collapsed:n,className:r="panel-icon-button",onClick:i}){return s.jsx("button",{className:r,type:"button","aria-label":e,title:e,onClick:i,children:s.jsx(lA,{side:t,collapsed:n})})}function fi({expanded:e}){return s.jsx("svg",{className:e?"workbench-chevron":"workbench-chevron collapsed",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 9 12 15 18 9"})})}function cA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function uA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"2"}),s.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),s.jsx("line",{x1:"8",y1:"14",x2:"12",y2:"14"}),s.jsx("circle",{cx:"17.5",cy:"15.5",r:"2.5"})]})}function dA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M7.5 10.2a4.5 4.5 0 1 1 9 0v3.1c0 .8.3 1.6.9 2.2l.8.8H5.8l.8-.8c.6-.6.9-1.4.9-2.2z",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 18.5a2 2 0 0 0 4 0",strokeLinecap:"round"})]})}function Rk(e){return s.jsx("div",{className:"workbench-notification-anchor",children:s.jsxs("button",{type:"button",className:e.collapsed?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":l("shell.globalNotificationsAction"),title:l("shell.globalNotificationsAction"),"aria-expanded":e.open,onClick:e.onToggle,children:[s.jsx(dA,{}),e.unreadCount>0?s.jsx("span",{className:"workbench-notification-badge","aria-label":l("shell.globalNotificationsUnreadAria",{count:String(e.unreadCount)}),children:e.unreadCount>99?"99+":e.unreadCount}):null]})})}function hA(e){const[t,n]=f.useState("notifications");f.useEffect(()=>{e.open&&n("notifications")},[e.open]);const r=f.useMemo(()=>e.notifications.filter(i=>e.showArchivedNotifications||!e.archivedNotificationIds.has(i.id)),[e.archivedNotificationIds,e.notifications,e.showArchivedNotifications]);return s.jsxs(St,{open:e.open,title:l("shell.globalNotificationsPanelTitle"),description:l("shell.globalNotificationsPanelDescription"),className:"workbench-notification-modal-card workspace-inbox-modal-card",showCloseButton:!1,onClose:e.onClose,children:[s.jsxs("div",{className:"workbench-notification-tabs",role:"tablist","aria-label":l("shell.globalNotificationsPanelTitle"),children:[s.jsx("button",{type:"button",className:t==="notifications"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="notifications",onClick:()=>n("notifications"),children:l("shell.globalNotificationsAction")}),s.jsx("button",{type:"button",className:t==="inbox"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="inbox",onClick:()=>n("inbox"),children:l("shell.butlerInboxAction")})]}),s.jsx("div",{className:"workbench-notification-content","data-tab":t,children:t==="notifications"?s.jsxs("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":l("shell.globalNotificationsAction"),children:[s.jsx("div",{className:"workbench-notification-toolbar",children:s.jsxs("label",{className:"workbench-notification-filter",children:[s.jsx("input",{type:"checkbox",checked:e.showArchivedNotifications,onChange:i=>e.onToggleShowArchivedNotifications(i.target.checked)}),s.jsx("span",{children:l("shell.globalNotificationsShowArchived")})]})}),r.length>0?s.jsx("div",{className:"workbench-notification-list",children:r.map(i=>{const a=e.archivedNotificationIds.has(i.id);return s.jsxs("article",{className:"workbench-notification-item","data-archived":a,children:[s.jsxs("button",{type:"button",className:"workbench-notification-item-content",onClick:()=>{e.onSelectNotification(i)},children:[s.jsx("span",{className:"workbench-notification-item-kind",children:yP(i.kind)}),s.jsx("strong",{children:i.title}),s.jsx("p",{children:i.body})]}),s.jsxs("div",{className:"workbench-notification-item-side",children:[s.jsx("time",{children:NP(i.createdAt)}),s.jsx("button",{type:"button",className:"secondary-button workbench-notification-item-action-button",onClick:()=>{if(a){e.onUnarchiveNotification(i.id);return}e.onArchiveNotification(i.id)},children:a?l("shell.globalNotificationsRemoveArchiveAction"):l("shell.globalNotificationsArchiveAction")})]})]},i.id)})}):s.jsx("p",{className:"workbench-notification-empty",children:l("shell.globalNotificationsEmpty")})]}):s.jsx("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":l("shell.butlerInboxAction"),children:s.jsx(Qb,{active:e.open&&t==="inbox",preferredWorkspaceId:e.preferredWorkspaceId,preferredSessionId:e.preferredSessionId})})}),s.jsx("div",{className:"workbench-modal-actions workbench-notification-footer-actions",children:s.jsx("button",{type:"button",className:"secondary-button",onClick:e.onClose,children:l("common.close")})})]})}function pA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function fA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("circle",{cx:"11",cy:"11",r:"7"}),s.jsx("line",{x1:"20",y1:"20",x2:"16.65",y2:"16.65"})]})}function mA(){return s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function gA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("path",{d:"M7 9l3 3-3 3"}),s.jsx("path",{d:"M13 15h4"})]})}function bA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"3"}),s.jsx("circle",{cx:"9",cy:"11",r:"1"}),s.jsx("circle",{cx:"15",cy:"11",r:"1"}),s.jsx("path",{d:"M8 15h8"}),s.jsx("path",{d:"M12 5V3"})]})}function kA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M12 4.5 13.6 8l3.9.4-2.9 2.7.8 3.9L12 13.2 8.6 15l.8-3.9-2.9-2.7L10.4 8 12 4.5Z"}),s.jsx("path",{d:"m18.5 4.5.5 1.3 1.3.5-1.3.5-.5 1.3-.5-1.3-1.3-.5 1.3-.5.5-1.3Z"})]})}function Pk(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),s.jsx("polyline",{points:"14 9 11 12 14 15"})]})}function yA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"18",cy:"6",r:"3"}),s.jsx("circle",{cx:"6",cy:"6",r:"3"}),s.jsx("circle",{cx:"18",cy:"18",r:"3"}),s.jsx("path",{d:"M6 9v6a3 3 0 0 0 3 3h3"}),s.jsx("line",{x1:"18",y1:"9",x2:"18",y2:"15"})]})}function xA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function wA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"5",width:"6",height:"6",rx:"1.5"}),s.jsx("rect",{x:"14",y:"5",width:"6",height:"6",rx:"1.5"}),s.jsx("rect",{x:"4",y:"13",width:"6",height:"6",rx:"1.5"}),s.jsx("path",{d:"M14 16l2 2 4-4"})]})}function vA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"6",width:"10",height:"12",rx:"2"}),s.jsx("path",{d:"M10 12h8"}),s.jsx("path",{d:"M15 8l4 4-4 4"})]})}function SA({selected:e}){return e?s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"}),s.jsx("path",{d:"M8 12.5l2.8 2.8L16.5 9.5"})]}):s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"})})}function Ak({active:e,className:t}){return e?s.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.5",children:s.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})}):s.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:s.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})})}function CA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 7h18"}),s.jsx("path",{d:"M5 7l1 12h12l1-12"}),s.jsx("path",{d:"M9 11h6"}),s.jsx("path",{d:"M8 4h8l1 3H7l1-3z"})]})}function NA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M12 20h9"}),s.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}function jA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M12 4v10"}),s.jsx("path",{d:"M8.5 7.5L12 4l3.5 3.5"}),s.jsx("path",{d:"M5 14v4a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-4"})]})}function TA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M8 6V4h8v2"}),s.jsx("path",{d:"M6 6l1 14h10l1-14"}),s.jsx("path",{d:"M10 11v5"}),s.jsx("path",{d:"M14 11v5"})]})}function IA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M9 13h6"})]})}function EA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M9.7 9.4a2.5 2.5 0 1 1 4.1 2c-.8.7-1.8 1.2-1.8 2.6",strokeLinecap:"round"}),s.jsx("circle",{cx:"12",cy:"17.2",r:"1",fill:"currentColor",stroke:"none"})]})}function MA({open:e,mode:t,keyword:n,codeWorkspaceId:r,codeResults:i,codeLoading:a,codeError:o,workspaceOptions:c,sessionResults:u,onClose:d,onModeChange:h,onKeywordChange:p,onCodeWorkspaceChange:g,onCodeSearch:m,onOpenSession:y}){const S=n.trim().length>0&&r.trim().length>0;return s.jsx(St,{open:e,title:l("shell.searchModalTitle"),description:l("shell.searchModalDescription"),onClose:d,children:s.jsxs("div",{className:"workbench-search-modal",children:[s.jsxs("div",{className:"workbench-search-mode-switch",role:"tablist","aria-label":l("shell.searchModeLabel"),children:[s.jsx("button",{type:"button",className:t==="sessions"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="sessions",onClick:()=>h("sessions"),children:l("shell.searchModeSessions")}),s.jsx("button",{type:"button",className:t==="code"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="code",onClick:()=>h("code"),children:l("shell.searchModeCode")})]}),t==="sessions"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchKeywordLabel")}),s.jsx("input",{type:"text",value:n,placeholder:l("shell.searchSessionPlaceholder"),autoFocus:!0,onChange:j=>p(j.target.value)})]}),s.jsx("div",{className:"workbench-search-results",children:n.trim().length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchSessionHint")}):u.length>0?u.map(j=>{const x=ld(j.session.title,l("common.unknown"));return s.jsxs("button",{type:"button",className:"workbench-search-result-item",onClick:()=>y(j.session.sessionId),children:[s.jsx("span",{className:"workbench-search-result-title",title:x.fullTitle,children:x.displayTitle}),s.jsxs("span",{className:"workbench-search-result-meta",children:[j.workspace.name," · ",fl(j.session.provider,"full")]})]},j.session.sessionId)}):s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchSessionEmpty")})})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchWorkspaceLabel")}),s.jsx("select",{value:r,onChange:j=>g(j.target.value),children:c.map(j=>s.jsx("option",{value:j.id,children:j.name},j.id))})]}),s.jsxs("form",{className:"workbench-search-code-form",onSubmit:j=>{j.preventDefault(),m()},children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchKeywordLabel")}),s.jsx("input",{type:"text",value:n,placeholder:l("shell.searchCodePlaceholder"),autoFocus:!0,onChange:j=>p(j.target.value)})]}),s.jsx("button",{type:"submit",className:"primary-button",disabled:!S||a,children:a?l("common.loading"):l("shell.searchSubmit")})]}),s.jsxs("div",{className:"workbench-search-results",children:[o?s.jsx("p",{className:"status-text","data-tone":"error",children:o}):null,!o&&n.trim().length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeHint")}):null,!o&&n.trim().length>0&&!a&&i.length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeEmpty")}):null,i.map(j=>s.jsxs("div",{className:"workbench-search-result-item static",children:[s.jsx("span",{className:"workbench-search-result-title",children:j.name}),s.jsx("span",{className:"workbench-search-result-meta",children:j.path})]},`${j.path}-${j.kind}`))]})]})]})})}const RA=`
71
+ `)),new TextEncoder().encode(d.join(""))}const _p=48;function tR(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function ld(e,t){const n=tR(e)||t,r=n.length>_p?n.slice(0,_p).trimEnd():n;return{fullTitle:n,displayTitle:r}}function co(e,t){return(t??"").localeCompare(e??"")}function Dp(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function uo(e){return(e==null?void 0:e.trim())??""}function ya(e,t,n){if(n==="updatedAt"){const o=co(e.updatedAt,t.updatedAt);if(o!==0)return o}if(n==="title"){const o=Dp(uo(e.title),uo(t.title));if(o!==0)return o}else{const o=co(e.createdAt,t.createdAt);if(o!==0)return o}const r=co(e.updatedAt,t.updatedAt);if(r!==0)return r;const i=co(e.createdAt,t.createdAt);if(i!==0)return i;const a=Dp(uo(e.title),uo(t.title));return a!==0?a:e.sessionId.localeCompare(t.sessionId)}function Ta(e,t){return[...e].sort((n,r)=>ya(n,r,t))}function cd(e,t){return Array.isArray(e)?e.map(n=>({...n,sessions:Ta(n.sessions,t),children:cd(n.children,t)})):[]}const mc=5,gc=["#2563eb","#0891b2","#16a34a","#d97706","#dc2626","#64748b"];function nR(e){const t=Math.round(e.ratio*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}function rR(e,t){const n=e.reduce((c,u)=>c+u.count,0);if(n<=0)return[];const i=e.slice(0,mc).map((c,u)=>({...c,key:c.type,ratio:c.count/n,color:gc[u]??gc[0]})),a=e.slice(mc);if(a.length===0)return i;const o=a.reduce((c,u)=>c+u.count,0);return i.push({key:"other",type:t,count:o,ratio:o/n,color:gc[mc]}),i}function sR(e){if(e.length===0)return"conic-gradient(color-mix(in srgb, var(--border-primary) 78%, transparent) 0% 100%)";let t=0;return`conic-gradient(${e.map((r,i)=>{const a=t,o=i===e.length-1?1:Math.min(1,t+r.ratio);return t=o,`${r.color} ${Bp(a)} ${Bp(o)}`}).join(", ")})`}function iR(e){return{"--workbench-manage-chart-background":sR(e)}}function Bp(e){const t=Math.round(e*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}const aR=8,oR=12,lR=160,Op=96;function cR(e,t,n,r={}){const i=r.gapPx??aR,a=r.viewportMarginPx??oR,o=r.defaultWidthPx??lR,c=r.estimatedHeightPx??Op,u=r.minHeightPx??Op,d=Math.max(0,n.width),h=Math.max(0,n.height),p=Math.max(0,h-a*2),g=Math.max(0,d-a*2),m=ho(Math.max(t.width||o,o),0,g),y=Math.max(t.height||c,c),S=Math.max(0,d-e.x-a),j=Math.max(0,e.x-a),x=S<m&&j>S,A=Math.max(0,h-e.y-i-a),T=Math.max(0,e.y-i-a),F=A<y&&T>A,I=ho(Math.max(F?T:A,u),0,p),G=Math.min(y,I),z=x?e.x-m:e.x,L=Math.max(a,d-a-m),E=F?e.y-i-G:e.y+i,H=Math.max(a,h-a-G),B=ho(z,a,L),oe=ho(E,a,H),K=x||B<e.x?"right":"left";return{top:oe,left:B,width:m,maxHeight:Math.max(0,I),transformOrigin:`${F?"bottom":"top"} ${K}`}}function ho(e,t,n){return!Number.isFinite(e)||n<t?t:Math.min(Math.max(e,t),n)}const Vb="workbench.navigation.snapshot",Kb=1800*1e3,uR="workbench.navigation.snapshot.host.";function Yb(e){return`${uR}${e}`}function dR(e=Kb,t=Zo(ar.getState())){if(t){const n=Ao(Yb(t),e);if(n)return n}return Ao(Vb,e)}function po(e,t=Zo(ar.getState())){ra(Vb,e),t&&ra(Yb(t),e)}function Wp(e,t="createdAt"){return!e||!Array.isArray(e.items)?[]:e.items.map(n=>({workspace:n.workspace,sessions:Ta(n.sessions,t),childWorktrees:hR(n.childWorktrees,t)}))}function hR(e,t){return cd(e,t)}function Jo(e){return{workspaceId:e.id,tone:"root",backgroundColor:e.backgroundColor??null,displayName:e.name,workspaceName:e.name,branchName:null,depth:0,rootWorkspaceId:e.id,rootDisplayName:e.name,parentWorkspaceId:null,parentDisplayName:null}}function pR(e){const t=new Map;for(const n of e)t.set(n.workspace.id,Jo(n.workspace)),Xb(t,n.childWorktrees??[],n.workspace,n.workspace);return Object.fromEntries(t)}function Wr(e){if(e!=null&&e.backgroundColor)return{"--workspace-tone-color":e.backgroundColor}}function Xb(e,t,n,r,i=r.name){var a;for(const o of t){const c=((a=o.meta.displayName)==null?void 0:a.trim())||o.workspace.name;e.set(o.workspace.id,{workspaceId:o.workspace.id,tone:"worktree",backgroundColor:o.workspace.backgroundColor??null,displayName:c,workspaceName:o.workspace.name,branchName:o.meta.branchName||null,depth:o.meta.depth,rootWorkspaceId:n.id,rootDisplayName:n.name,parentWorkspaceId:o.meta.parentWorkspaceId||r.id,parentDisplayName:i}),Xb(e,o.children,n,o.workspace,c)}}class au extends Error{constructor(t,n){super(n),this.code=t,this.name="HostSwitchError"}}class fR{constructor(){at(this,"inFlight",null)}async switchHost(t){this.inFlight&&await this.inFlight;const n=this.performSwitch(t).finally(()=>{this.inFlight===n&&(this.inFlight=null)});this.inFlight=n,await n}async performSwitch(t){const n=ar.getState();if(Zo(n)===t)return;const r=Xk(n,t);if(!r)throw new au("HOST_NOT_FOUND",`找不到 HOST:${t}`);if(!(await Jk(r.baseUrl)).reachable)throw new au("HOST_UNREACHABLE",`目标 HOST 不可达:${r.baseUrl}`);const a=Ff(r.id);if(a)try{await ca.loginForHost(r,{username:a.username,password:a.password})}catch{}const o=ar.getState(),c=new Date().toISOString();if($f(r)){ar.updateRuntime({discoveredHosts:o.discoveredHosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeDiscoveredHostId:t});return}Tc.setActiveDiscoveredHost(null),await ar.update({hosts:o.hosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeHostId:t})}}const mR=new fR,gR=1700;function bR({open:e,id:t,role:n="dialog",labelledBy:r,className:i,anchorRef:a,popoverRef:o,children:c,maxWidth:u=360,gap:d=10,viewportPadding:h=16}){const[p,g]=f.useState(null);if(f.useEffect(()=>{if(!e||typeof window>"u"||typeof document>"u"){g(null);return}let y=0;const S=()=>{const x=a.current;if(!x)return;const A=x.getBoundingClientRect(),T=Math.max(180,Math.min(u,window.innerWidth-h*2)),F=Math.min(Math.max(h,A.right-T),Math.max(h,window.innerWidth-h-T)),R=A.top>=Math.min(240,window.innerHeight*.42),I=Math.round(R?A.top-d:A.bottom+d);g({top:I,left:Math.round(F),width:T,placeAbove:R})},j=()=>{window.cancelAnimationFrame(y),y=window.requestAnimationFrame(S)};return S(),window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.cancelAnimationFrame(y),window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[a,d,u,e,h]),!e||!p||typeof document>"u")return null;const m={position:"fixed",top:p.top,left:p.left,width:p.width,maxWidth:`calc(100vw - ${h*2}px)`,zIndex:gR,transform:p.placeAbove?"translateY(-100%)":void 0};return Fr.createPortal(s.jsx("div",{id:t,ref:o,role:n,"aria-labelledby":r,className:i,"data-placement":p.placeAbove?"top":"bottom",style:m,children:c}),document.body)}const bc={status:"idle",latencyMs:null};function Jb({collapsed:e=!1}){const[t,n]=f.useState(!1),[r,i]=f.useState(!1),[a,o]=f.useState(""),[c,u]=f.useState(""),[d,h]=f.useState(""),[p,g]=f.useState(""),[m,y]=f.useState(null),[S,j]=f.useState(null),[x,A]=f.useState(null),[T,F]=f.useState(!1),[R,I]=f.useState(!1),[G,z]=f.useState(bc),[L,E]=f.useState(null),H=f.useRef(null),B=f.useRef(null),oe=f.useRef(null),K=f.useRef(null),X=gu(O=>O),Y=fu(O=>O.session),{showToast:D}=lr(),V=Ic(X),le=Zo(X),C=ly(),_e=Qk(le),Z=f.useMemo(()=>Fp(X.hosts,le),[le,X.hosts]),N=f.useMemo(()=>Fp(zf(X),le),[le,X]),be=f.useCallback(()=>{if(typeof window>"u")return;const O=H.current;if(!O)return;const q=O.getBoundingClientRect(),J=window.innerWidth,Ce=window.innerHeight,Ee=16,ve=8,nt=Math.min(320,Math.max(240,J-Ee*2)),mt=Math.min(e?Math.max(Ee,q.right+ve):Math.max(Ee,q.left),Math.max(Ee,J-nt-Ee)),ae=r?440:240,se=e?q.top:q.bottom+ve,ke=Math.min(Math.max(Ee,se),Math.max(Ee,Ce-ae-Ee));E({position:"fixed",top:ke,left:mt,width:nt,maxWidth:J-Ee*2})},[e,r]);f.useEffect(()=>{if(!t){E(null),F(!1),z(bc);return}Tc.refresh();function O(J){var Ce,Ee,ve;J.target instanceof Node&&!((Ce=H.current)!=null&&Ce.contains(J.target))&&!((Ee=B.current)!=null&&Ee.contains(J.target))&&!((ve=K.current)!=null&&ve.contains(J.target))&&(n(!1),i(!1),F(!1),A(null))}function q(J){J.key==="Escape"&&(n(!1),i(!1),F(!1),A(null))}return window.addEventListener("pointerdown",O),window.addEventListener("keydown",q),window.addEventListener("resize",be),window.addEventListener("scroll",be,!0),be(),()=>{window.removeEventListener("pointerdown",O),window.removeEventListener("keydown",q),window.removeEventListener("resize",be),window.removeEventListener("scroll",be,!0)}},[t,be]),f.useEffect(()=>{if(!T||!t||(C==null?void 0:C.kind)!=="relay"){z(bc);return}let O=!1;const q=performance.now();return z({status:"probing",latencyMs:null}),pe.request("/api/client/runtime-config").then(()=>{O||z({status:"ready",latencyMs:performance.now()-q})}).catch(()=>{O||z({status:"error",latencyMs:null})}),()=>{O=!0}},[C==null?void 0:C.kind,T,t]);async function ne(O){if(m||S||O.id===le){n(!1);return}y(O.id);try{await mR.switchHost(O.id),n(!1),i(!1),F(!1),A(null)}catch(q){D({title:vR(q,O.name),tone:"error"})}finally{y(null)}}async function fe(O){if(!(O.id===le||m||S)){if(x!==O.id){A(O.id);return}j(O.id);try{await ar.update({hosts:X.hosts.filter(q=>q.id!==O.id)}),Zk(O.id),ca.clearHostSession(O.id),A(null),D({title:l("shell.hostDeleteSuccess",{name:O.name})})}catch{D({title:l("shell.hostDeleteFailed",{name:O.name}),tone:"error"})}finally{j(null)}}}async function ue(){if(R)return;const O=a.trim(),q=d.trim();if((q.length>0||p.length>0)&&(!q||!p)){D({title:l("shell.hostAddIncompleteCredentials"),tone:"error"});return}let Ce;try{Ce=ey(c)}catch{D({title:l("shell.hostAddInvalidUrl"),tone:"error"});return}I(!0);try{const Ee=await Ly(Ce),ve=ar.getState(),Tt=Ic(ve);if(Ee?ve.hosts.find(ke=>{var ye;return ke.baseUrl===Ce||!!Ee.bindingId&&((ye=ke.relayTunnel)==null?void 0:ye.bindingId)===Ee.bindingId}):ve.hosts.find(ke=>ke.baseUrl===Ce)){D({title:l("shell.hostAddDuplicate"),tone:"error"});return}const mt=$f(Tt)&&Tt.baseUrl===Ce;mt&&Tc.setActiveDiscoveredHost(null);let ae,se;if(Ee){const ye=(await ar.update(_y(ve,Ee,{activate:mt,displayName:O}))).hosts.find(Me=>xR(Me,Ce,Ee.bindingId??null));if(!ye)throw new Error("relay entry host missing after save");ae=ye.id,se=ye.name}else{const ke=new Date().toISOString(),ye={id:wR(),name:O||kR(Ce),baseUrl:Ce,kind:yR(Ce),createdAt:ke,updatedAt:ke,lastConnectedAt:null,lastUserId:null,lastUsername:null};await ar.update({hosts:[...ve.hosts,ye],activeHostId:mt?ye.id:ve.activeHostId}),ae=ye.id,se=ye.name}q&&p&&ty({hostId:ae,username:q,password:p}),He(),i(!1),A(null),D({title:l("shell.hostAddSuccess",{name:se})})}catch{D({title:l("shell.hostAddFailed"),tone:"error"})}finally{I(!1)}}function He(){o(""),u(""),h(""),g("")}if(!V)return null;const Ue=Y!=null&&Y.user.username?`${V.baseUrl} · ${Y.user.username}`:V.baseUrl,je=(C==null?void 0:C.kind)==="relay"?l("shell.hostSwitcherDetailStatusRelay"):l("shell.hostSwitcherDetailStatusDirect"),Te=C?l(cy(C.kind)):l("common.unknown");return s.jsxs("div",{ref:H,className:"workbench-host-switcher-anchor","data-collapsed":e,children:[s.jsx("button",{type:"button",className:e?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":l("shell.hostSwitcherAriaLabel"),title:Ue,"aria-expanded":t,onClick:()=>{n(O=>!O),i(!1)},children:s.jsx(NR,{})}),t&&L&&typeof document<"u"?Fr.createPortal(s.jsxs("div",{ref:B,className:"workbench-host-switcher-menu",style:L,role:"menu","aria-label":l("shell.hostSwitcherTitle"),children:[s.jsx("div",{className:"workbench-host-switcher-menu-header",children:s.jsx("strong",{children:l("shell.hostSwitcherTitle")})}),s.jsxs("div",{className:"workbench-host-switcher-list",children:[s.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherSavedSection")}),Z.map(O=>{const q=O.id===le,J=q?(Y==null?void 0:Y.user.username)??O.lastUsername??O.baseUrl:O.lastUsername??O.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":q,children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:m!==null||S!==null,onClick:()=>{ne(O)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[O.name,q?s.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),s.jsx("span",{className:"workbench-host-switcher-item-meta",children:J})]}),s.jsx("span",{className:"workbench-host-switcher-item-trailing",children:m===O.id?l("shell.hostSwitcherSwitching"):q?s.jsx(zp,{}):s.jsx($p,{})})]}),q?s.jsx("button",{ref:oe,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:O.name}),"aria-expanded":T,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{F(Ce=>!Ce),A(null)},children:l("shell.hostSwitcherDetailAction")}):s.jsx("button",{type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostDeleteAriaLabel",{name:O.name}),title:x===O.id?l("shell.hostDeleteConfirmAction"):l("shell.hostDeleteAction"),"data-confirming":x===O.id,disabled:m!==null||S!==null,onClick:()=>{fe(O)},children:S===O.id?l("shell.hostDeleteBusy"):x===O.id?l("shell.hostDeleteConfirmAction"):s.jsx(TR,{})})]},O.id)}),N.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherDiscoveredSection")}),N.map(O=>{const q=O.id===le,J=Ff(O.id),Ce=q?(Y==null?void 0:Y.user.username)??(J==null?void 0:J.username)??O.baseUrl:(J==null?void 0:J.username)??O.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":q,"data-discovered":"true",children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:m!==null||S!==null,onClick:()=>{ne(O)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[O.name,s.jsx("span",{className:"workbench-host-switcher-item-badge","data-tone":"discovered",children:l("shell.hostSwitcherDiscoveredBadge")}),q?s.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),s.jsx("span",{className:"workbench-host-switcher-item-meta",children:Ce})]}),s.jsx("span",{className:"workbench-host-switcher-item-trailing",children:m===O.id?l("shell.hostSwitcherSwitching"):q?s.jsx(zp,{}):s.jsx($p,{})})]}),q?s.jsx("button",{ref:oe,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:O.name}),"aria-expanded":T,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{F(Ee=>!Ee),A(null)},children:l("shell.hostSwitcherDetailAction")}):null]},O.id)})]}):null,X.localHostDiscovery.status==="refreshing"?s.jsx("div",{className:"workbench-host-switcher-state-row",children:l("shell.hostDiscoveryRefreshing")}):null,X.localHostDiscovery.status==="failed"?s.jsx("div",{className:"workbench-host-switcher-state-row","data-tone":"error",children:l("shell.hostDiscoveryFailed")}):null]}),r?s.jsxs("div",{className:"workbench-host-switcher-form",children:[s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("shell.hostSwitcherNameLabel")}),s.jsx("input",{value:a,disabled:R,onChange:O=>o(O.target.value),placeholder:l("shell.hostSwitcherNamePlaceholder")})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("shell.hostSwitcherUrlLabel")}),s.jsx("input",{value:c,disabled:R,onChange:O=>u(O.target.value),placeholder:l("shell.hostSwitcherUrlPlaceholder")})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("auth.username")}),s.jsx("input",{value:d,disabled:R,onChange:O=>h(O.target.value),autoComplete:"username"})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("auth.password")}),s.jsx("input",{type:"password",value:p,disabled:R,onChange:O=>g(O.target.value),autoComplete:"current-password"})]}),s.jsxs("div",{className:"workbench-host-switcher-form-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:R,onClick:()=>{i(!1),He()},children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:R,onClick:()=>{ue()},children:R?l("common.loading"):l("shell.hostSwitcherSaveAction")})]})]}):s.jsxs("button",{type:"button",className:"workbench-host-switcher-add",onClick:()=>{i(!0),A(null)},children:[s.jsx(jR,{}),l("shell.hostSwitcherAddAction")]}),s.jsxs(bR,{open:T&&C!==null&&oe.current!==null,className:"workbench-host-switcher-detail-popover",anchorRef:oe,popoverRef:K,labelledBy:"workbench-host-switcher-detail-title",children:[s.jsx("div",{className:"workbench-host-switcher-detail-header",children:s.jsx("strong",{id:"workbench-host-switcher-detail-title",children:l("shell.hostSwitcherDetailTitle")})}),s.jsxs("div",{className:"workbench-host-switcher-detail-grid",children:[s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailStatusLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:je})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailRouteLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:Te})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailAddressLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value","data-multiline":"true",children:(C==null?void 0:C.url)??V.baseUrl})]}),(C==null?void 0:C.kind)==="relay"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailLatencyLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:SR(G)})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailTrafficLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:CR(_e.totalBytes)})]})]}):null]})]})]}),document.body):null]})}function Fp(e,t){return[...e].sort((n,r)=>{if(n.id===t)return-1;if(r.id===t)return 1;const i=n.lastConnectedAt??n.updatedAt??n.createdAt;return(r.lastConnectedAt??r.updatedAt??r.createdAt).localeCompare(i)})}function kR(e){try{const t=new URL(e),n=t.pathname==="/"?"":t.pathname.replace(/\/+$/,"");return`${t.host}${n}`}catch{return e}}function yR(e){try{const t=new URL(e).hostname.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="[::1]"?"local":/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[0-1])\./.test(t)?"lan":"remote"}catch{return"custom"}}function xR(e,t,n){var r;return!!(e.baseUrl===t||n&&((r=e.relayTunnel)==null?void 0:r.bindingId)===n)}function wR(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`host-${crypto.randomUUID()}`:`host-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function vR(e,t){return e instanceof au?e.code==="HOST_UNREACHABLE"?l("shell.hostSwitchUnreachable",{name:t}):l("shell.hostSwitchMissing"):l("shell.hostSwitchFailed")}function SR(e){return e.status==="probing"?l("shell.hostSwitcherDetailLatencyLoading"):e.status==="error"?l("shell.hostSwitcherDetailUnavailable"):e.status==="ready"?`${Math.max(1,Math.round(e.latencyMs))} ms`:l("shell.hostSwitcherDetailUnavailable")}function CR(e){return!Number.isFinite(e)||e<1024?`${Math.max(0,Math.round(e))} B`:e<1024**2?`${(e/1024).toFixed(1)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}function NR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"4",y:"4.5",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("rect",{x:"4",y:"13",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("path",{d:"M11 7.75h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),s.jsx("path",{d:"M11 16.25h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),s.jsx("circle",{cx:"7.5",cy:"7.75",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"7.5",cy:"16.25",r:"1",fill:"currentColor",stroke:"none"})]})}function $p(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function zp(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function jR(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M8 3.5v9M3.5 8h9",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function TR(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 4.5h9M6.5 2.75h3M5 4.5v7.25a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1V4.5M6.75 6.5v4M9.25 6.5v4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.35"})})}const fo={repositoryUrl:"",parentPath:"",directoryName:"",name:"",authMode:"none",username:"",password:"",token:""};function IR({open:e,onClose:t,onCloned:n}){const{showToast:r}=lr(),[i,a]=f.useState(!1),[o,c]=f.useState(fo),[u,d]=f.useState(!1),[h,p]=f.useState(!1),[g,m]=f.useState(null),[y,S]=f.useState(""),[j,x]=f.useState(""),[A,T]=f.useState(null),[F,R]=f.useState([]),[I,G]=f.useState([]),z=i||h;f.useEffect(()=>{!e&&!i&&(c(fo),d(!1),m(null))},[i,e]);const L=f.useCallback(async Y=>{p(!0),m(null);try{const D=await Uf(Y);S(D.currentPath),x(D.currentPath),T(D.parentPath),R(D.roots),G(D.items),c(V=>({...V,parentPath:D.currentPath}))}catch(D){S(""),T(null),G([]),m(D instanceof Error?D.message:l("shell.importBrowserBrowseFailed"))}finally{p(!1)}},[]);function E(){i||(d(!1),m(null),c(fo),t())}function H(){d(!0),L(o.parentPath||void 0)}function B(){i||(d(!1),m(null))}async function oe(Y){Y.preventDefault(),await L(j)}function K(){c(Y=>({...Y,parentPath:y})),d(!1),m(null)}async function X(Y){Y.preventDefault();const D=o.repositoryUrl.trim(),V=o.parentPath.trim();if(!D){r({title:l("shell.cloneRepoRequired"),tone:"error"});return}if(!V){r({title:l("shell.clonePathRequired"),tone:"error"});return}a(!0);try{const le=await uy({repositoryUrl:D,parentPath:V,directoryName:o.directoryName.trim()||void 0,name:o.name.trim()||void 0,auth:o.authMode==="none"?{mode:"none"}:o.authMode==="basic"?{mode:"basic",username:o.username.trim(),password:o.password}:{mode:"token",username:o.username.trim()||void 0,token:o.token}});await(n==null?void 0:n(le)),c(fo),d(!1),r({title:l("shell.cloneSuccess"),description:le.path,tone:"success"}),t()}catch(le){r({title:le instanceof Error?le.message:l("shell.cloneFailed"),tone:"error"})}finally{a(!1)}}return s.jsxs(s.Fragment,{children:[s.jsx(St,{open:e,title:l("shell.cloneWorkspaceTitle"),description:l("shell.cloneWorkspaceHint"),onClose:E,children:s.jsxs("form",{className:"workbench-clone-form",onSubmit:Y=>void X(Y),children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneRepositoryLabel")}),s.jsx("input",{type:"text",value:o.repositoryUrl,placeholder:l("shell.cloneRepositoryPlaceholder"),onChange:Y=>c(D=>({...D,repositoryUrl:Y.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneParentPathLabel")}),s.jsxs("div",{className:"workbench-modal-inline-field",children:[s.jsx("input",{type:"text",value:o.parentPath,placeholder:l("shell.cloneParentPathPlaceholder"),onChange:Y=>c(D=>({...D,parentPath:Y.target.value}))}),s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:H,children:l("shell.clonePickDirectory")})]})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneDirectoryNameLabel")}),s.jsx("input",{type:"text",value:o.directoryName,placeholder:l("shell.cloneDirectoryNamePlaceholder"),onChange:Y=>c(D=>({...D,directoryName:Y.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importNameLabel")}),s.jsx("input",{type:"text",value:o.name,placeholder:l("shell.importNamePlaceholder"),onChange:Y=>c(D=>({...D,name:Y.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneAuthModeLabel")}),s.jsxs("select",{value:o.authMode,onChange:Y=>c(D=>({...D,authMode:Y.target.value})),children:[s.jsx("option",{value:"none",children:l("shell.cloneAuthModeNone")}),s.jsx("option",{value:"basic",children:l("shell.cloneAuthModeBasic")}),s.jsx("option",{value:"token",children:l("shell.cloneAuthModeToken")})]})]}),o.authMode==="basic"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneUsernameLabel")}),s.jsx("input",{type:"text",value:o.username,placeholder:l("shell.cloneUsernamePlaceholder"),autoComplete:"username",onChange:Y=>c(D=>({...D,username:Y.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.clonePasswordLabel")}),s.jsx("input",{type:"password",value:o.password,placeholder:l("shell.clonePasswordPlaceholder"),autoComplete:"current-password",onChange:Y=>c(D=>({...D,password:Y.target.value}))})]})]}):null,o.authMode==="token"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneUsernameLabel")}),s.jsx("input",{type:"text",value:o.username,placeholder:l("shell.cloneTokenUsernamePlaceholder"),onChange:Y=>c(D=>({...D,username:Y.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneTokenLabel")}),s.jsx("input",{type:"password",value:o.token,placeholder:l("shell.cloneTokenPlaceholder"),onChange:Y=>c(D=>({...D,token:Y.target.value}))})]})]}):null,s.jsx("p",{className:"workbench-import-hint",children:l("shell.cloneHint")}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:E,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:i,children:i?l("shell.cloneSubmitting"):l("shell.cloneSubmit")})]})]})}),s.jsxs(St,{open:e&&u,title:l("shell.cloneBrowserTitle"),description:l("shell.cloneBrowserDescription"),onClose:B,children:[s.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:oe,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCurrentPath")}),s.jsx("input",{type:"text",value:j,placeholder:l("shell.importPathPlaceholder"),onChange:Y=>x(Y.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:z||!A,onClick:()=>{A&&L(A)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:z,children:l("shell.importBrowserOpenPath")})]})]}),s.jsxs("section",{className:"workbench-directory-browser-panel",children:[s.jsxs("div",{className:"workbench-directory-browser-section",children:[s.jsx("span",{className:"workbench-directory-browser-section-title",children:l("shell.importBrowserRoots")}),s.jsx("div",{className:"workbench-directory-browser-root-list",children:F.map(Y=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:z,onClick:()=>{L(Y.path)},children:Y.name},Y.path))})]}),s.jsx("div",{className:"workbench-directory-browser-current-path",children:y}),g?s.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:g}):null,h?s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("common.loading")}):I.length>0?s.jsx("div",{className:"workbench-directory-browser-list",children:I.map(Y=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:z,onClick:()=>{L(Y.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:Y.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:Y.path})]},Y.path))}):s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("shell.importBrowserEmpty")})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:B,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:z||!y,onClick:K,children:l("shell.cloneBrowserSubmit")})]})]})]})}const ER="butler:inbox-updated";function kc(){typeof window>"u"||window.dispatchEvent(new Event(ER))}const Hp={projectId:"",itemType:"task",title:"",content:"",status:"pending"};function Qb({active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,compactComposer:a=!1,composerOpen:o=!0,onComposerOpenChange:c}){const{showToast:u}=lr(),[d,h]=f.useState(!1),[p,g]=f.useState(!1),[m,y]=f.useState([]),[S,j]=f.useState([]),[x,A]=f.useState(null),[T,F]=f.useState(null),[R,I]=f.useState(Hp),[G,z]=f.useState(!1),L=f.useMemo(()=>qp(m,t,T),[T,t,m]),E=f.useMemo(()=>G?S:S.filter(D=>D.status!=="closed"),[S,G]);f.useEffect(()=>{e&&H()},[e,n]),f.useEffect(()=>{!e||x||I(D=>{const V=Vp({projects:L,currentProjectId:D.projectId,preferredProjectId:T,preferredWorkspaceId:t});return V===D.projectId?D:{...D,projectId:V}})},[e,x,T,t,L]),f.useEffect(()=>{!e||r<=0||(B(void 0,t,i,T),c==null||c(!0))},[e,r,i,c,T,t]);async function H(){h(!0);try{const[D,V,le]=await Promise.all([pT(),qg(),n?xT(n).catch(()=>null):Promise.resolve(null)]),C=(le==null?void 0:le.target.project.id)??null;F(C),y(D.items),j(V.items),x||B(D.items,t,r>0?i:null,C)}catch(D){u({title:l("shell.butlerInboxLoadFailed"),description:D instanceof Error?D.message:void 0,tone:"error"})}finally{h(!1)}}function B(D=m,V=t,le=i,C=T){var Z,N;const _e=qp(D,V,C);A(null),I({...Hp,projectId:Vp({projects:_e,preferredProjectId:C,preferredWorkspaceId:V}),title:((Z=le==null?void 0:le.title)==null?void 0:Z.trim())??"",content:((N=le==null?void 0:le.content)==null?void 0:N.trim())??""})}function oe(D){A(D.id),I({projectId:D.projectId,itemType:D.itemType,title:D.title,content:D.content,status:D.status}),a&&(c==null||c(!0))}async function K(D){D.preventDefault(),g(!0);try{x?(await tp(x,{projectId:R.projectId,itemType:R.itemType,title:R.title,content:R.content,status:R.status,priority:"medium"}),u({title:l("shell.butlerInboxUpdated"),tone:"success"})):(await fT({projectId:R.projectId,itemType:R.itemType,title:R.title,content:R.content,status:R.status,priority:"medium"}),u({title:l("shell.butlerInboxCreated"),tone:"success"})),kc(),await H(),B(),a&&(c==null||c(!1))}catch(V){u({title:l("shell.butlerInboxSaveFailed"),description:V instanceof Error?V.message:void 0,tone:"error"})}finally{g(!1)}}async function X(D){g(!0);try{await bT(D),u({title:l("shell.butlerInboxDeleted"),tone:"success"}),kc(),await H(),x===D&&B()}catch(V){u({title:l("shell.butlerInboxDeleteFailed"),description:V instanceof Error?V.message:void 0,tone:"error"})}finally{g(!1)}}async function Y(D,V){if(D.status!==V){g(!0);try{await tp(D.id,{status:V}),u({title:l("shell.butlerInboxUpdated"),tone:"success"}),kc(),await H(),x===D.id&&I(le=>({...le,status:V}))}catch(le){u({title:l("shell.butlerInboxSaveFailed"),description:le instanceof Error?le.message:void 0,tone:"error"})}finally{g(!1)}}}return s.jsxs("div",{className:"workspace-inbox-modal",children:[a?null:s.jsx("section",{className:"workspace-inbox-panel",children:s.jsx(Up,{selectableProjects:L,formState:R,saving:p,editingItemId:x,useMobilePicker:!1,onProjectChange:D=>{I(V=>({...V,projectId:D}))},onItemTypeChange:D=>{I(V=>({...V,itemType:D}))},onStatusChange:D=>{I(V=>({...V,status:D}))},onTitleChange:D=>{I(V=>({...V,title:D}))},onContentChange:D=>{I(V=>({...V,content:D}))},onCancel:()=>B(),onSubmit:K})}),s.jsxs("section",{className:"workspace-inbox-panel",children:[s.jsxs("header",{className:"workspace-inbox-panel-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:l("shell.butlerInboxListTitle")}),s.jsx("p",{children:l("shell.butlerInboxListDescription")})]}),s.jsxs("label",{className:"workspace-inbox-closed-toggle",children:[s.jsx("input",{type:"checkbox",checked:G,onChange:D=>z(D.target.checked)}),s.jsx("span",{children:l("shell.butlerInboxShowClosedAction")})]})]}),d?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxLoading")}):null,!d&&E.length===0?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxEmpty")}):null,!d&&E.length>0?s.jsx("div",{className:"workspace-inbox-list",children:E.map(D=>s.jsxs("article",{className:"workspace-inbox-item",children:[s.jsxs("div",{className:"workspace-inbox-item-header",children:[s.jsxs("div",{children:[s.jsx("strong",{children:D.title}),s.jsx("p",{children:D.projectName})]}),s.jsxs("div",{className:"workspace-inbox-item-badges",children:[s.jsx("span",{className:"workspace-inbox-badge",children:Kp(D.status)}),s.jsx("span",{className:"workspace-inbox-badge",children:LR(D.itemType)})]})]}),s.jsx("p",{className:"workspace-inbox-item-content",children:D.content}),s.jsxs("div",{className:"workspace-inbox-item-footer",children:[s.jsx("span",{children:_R(D.updatedAt)}),s.jsxs("div",{className:"workspace-inbox-item-actions",children:[s.jsx("div",{className:"workspace-inbox-status-quick-actions",role:"group","aria-label":l("shell.butlerInboxQuickStatusLabel"),children:["pending","in_progress","closed"].map(V=>{const le=D.status===V;return s.jsx("button",{type:"button",className:"secondary-button","data-active":le,disabled:p,onClick:()=>{Y(D,V)},children:Kp(V)},`${D.id}:${V}`)})}),s.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>oe(D),children:l("shell.butlerInboxEditAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{X(D.id)},children:l("shell.butlerInboxDeleteAction")})]})]})]},D.id))}):null]}),a?s.jsx(St,{open:e&&o,title:x?l("shell.butlerInboxEditingTitle"):l("shell.butlerInboxCreateTitle"),description:l("shell.butlerInboxFormDescription"),className:"workspace-inbox-modal-card workspace-inbox-composer-modal-card",onClose:()=>{c==null||c(!1),B()},children:s.jsx("div",{className:"workspace-inbox-composer-modal-body",children:s.jsx(Up,{selectableProjects:L,formState:R,saving:p,editingItemId:x,useMobilePicker:!0,onProjectChange:D=>{I(V=>({...V,projectId:D}))},onItemTypeChange:D=>{I(V=>({...V,itemType:D}))},onStatusChange:D=>{I(V=>({...V,status:D}))},onTitleChange:D=>{I(V=>({...V,title:D}))},onContentChange:D=>{I(V=>({...V,content:D}))},onCancel:()=>{c==null||c(!1),B()},onSubmit:K})})}):null]})}function Up(e){const t=e.selectableProjects.map(i=>({value:i.id,label:i.name})),n=[{value:"task",label:l("shell.butlerInboxTypeTask")},{value:"bug",label:l("shell.butlerInboxTypeBug")},{value:"feature",label:l("shell.butlerInboxTypeFeature")},{value:"change",label:l("shell.butlerInboxTypeChange")}],r=[{value:"pending",label:l("shell.butlerInboxStatusPending")},{value:"in_progress",label:l("shell.butlerInboxStatusInProgress")},{value:"closed",label:l("shell.butlerInboxStatusClosed")}];return s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"workspace-inbox-panel-header",children:[s.jsx("h3",{children:e.editingItemId?l("shell.butlerInboxEditingTitle"):l("shell.butlerInboxCreateTitle")}),s.jsx("p",{children:l("shell.butlerInboxFormDescription")})]}),e.selectableProjects.length===0?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxProjectsEmpty")}):s.jsxs("form",{className:"workspace-inbox-form",onSubmit:e.onSubmit,children:[s.jsx("div",{className:"workspace-inbox-form-grid",children:e.useMobilePicker?s.jsxs(s.Fragment,{children:[s.jsx(yc,{label:l("shell.butlerInboxProjectLabel"),value:e.formState.projectId,options:t,disabled:e.saving,onChange:e.onProjectChange}),s.jsx(yc,{label:l("shell.butlerInboxTypeLabel"),value:e.formState.itemType,options:n,disabled:e.saving,onChange:e.onItemTypeChange}),s.jsx(yc,{label:l("shell.butlerInboxStatusLabel"),value:e.formState.status,options:r,disabled:e.saving,onChange:e.onStatusChange})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxProjectLabel")}),s.jsx("select",{value:e.formState.projectId,disabled:e.saving,onChange:i=>e.onProjectChange(i.target.value),children:e.selectableProjects.map(i=>s.jsx("option",{value:i.id,children:i.name},i.id))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxTypeLabel")}),s.jsxs("select",{value:e.formState.itemType,disabled:e.saving,onChange:i=>e.onItemTypeChange(i.target.value),children:[s.jsx("option",{value:"task",children:l("shell.butlerInboxTypeTask")}),s.jsx("option",{value:"bug",children:l("shell.butlerInboxTypeBug")}),s.jsx("option",{value:"feature",children:l("shell.butlerInboxTypeFeature")}),s.jsx("option",{value:"change",children:l("shell.butlerInboxTypeChange")})]})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxStatusLabel")}),s.jsxs("select",{value:e.formState.status,disabled:e.saving,onChange:i=>e.onStatusChange(i.target.value),children:[s.jsx("option",{value:"pending",children:l("shell.butlerInboxStatusPending")}),s.jsx("option",{value:"in_progress",children:l("shell.butlerInboxStatusInProgress")}),s.jsx("option",{value:"closed",children:l("shell.butlerInboxStatusClosed")})]})]})]})}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxTitleLabel")}),s.jsx("input",{value:e.formState.title,placeholder:l("shell.butlerInboxTitlePlaceholder"),disabled:e.saving,onChange:i=>e.onTitleChange(i.target.value)})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxContentLabel")}),s.jsx("textarea",{rows:4,value:e.formState.content,placeholder:l("shell.butlerInboxContentPlaceholder"),disabled:e.saving,onChange:i=>e.onContentChange(i.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:e.saving,onClick:e.onCancel,children:e.editingItemId?l("shell.butlerInboxCancelEditAction"):l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:e.saving||!e.formState.projectId,children:e.editingItemId?l("shell.butlerInboxUpdateAction"):l("shell.butlerInboxCreateAction")})]})]})]})}function yc({label:e,value:t,options:n,disabled:r,onChange:i}){const[a,o]=f.useState(!1),c=n.find(u=>u.value===t)??n[0]??null;return f.useEffect(()=>{if(!a)return;function u(d){d.key==="Escape"&&o(!1)}return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},[a]),s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-modal-field workspace-inbox-mobile-picker",children:[s.jsx("span",{children:e}),s.jsxs("button",{type:"button",className:"workspace-inbox-mobile-picker-trigger","aria-label":e,"aria-haspopup":"dialog","aria-expanded":a,disabled:r||n.length===0,onClick:()=>o(!0),children:[s.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-value",children:(c==null?void 0:c.label)??""}),s.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-icon",children:s.jsx(PR,{expanded:a})})]})]}),s.jsx(MR,{open:a,title:e,options:n,selectedValue:t,onClose:()=>o(!1),onSelect:u=>{i(u),o(!1)}})]})}function MR({open:e,title:t,options:n,selectedValue:r,onClose:i,onSelect:a}){return e?s.jsx(dy,{open:e,title:t,kind:"picker",height:"half",className:"workspace-inbox-picker-sheet",cardClassName:"workspace-inbox-picker-sheet-card",bodyClassName:"workspace-inbox-picker-sheet-body",showHandle:!0,onClose:i,children:s.jsx(mi,{className:"workspace-inbox-picker-sheet-options",role:"listbox","aria-label":t,children:n.map(o=>{const c=o.value===r;return s.jsx(Jt,{as:"button",className:"workspace-inbox-picker-option",role:"option","aria-selected":c,selected:c,trailing:s.jsx("span",{className:"workspace-inbox-picker-option-indicator","aria-hidden":"true",children:c?s.jsx(AR,{}):null}),onClick:()=>a(o.value),children:s.jsxs("span",{className:"workspace-inbox-picker-option-copy",children:[s.jsx("strong",{children:o.label}),o.description?s.jsx("span",{children:o.description}):null]})},o.value)})})}):null}function b2({open:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,onClose:a,compactComposer:o=!1}){const[c,u]=f.useState(0),[d,h]=f.useState(!o);return f.useEffect(()=>{e||h(!o)},[o,e]),s.jsx(St,{open:e,title:l("shell.butlerInboxModalTitle"),description:l("shell.butlerInboxModalDescription"),className:"workspace-inbox-modal-card",showCloseButton:!o,headerActions:o?s.jsx("button",{type:"button",className:"workspace-inbox-modal-create-button","aria-label":l("shell.butlerInboxCreateAction"),title:l("shell.butlerInboxCreateAction"),onClick:()=>{u(p=>p+1),h(!0)},children:s.jsx(RR,{})}):void 0,onClose:a,children:s.jsx(Qb,{active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:Math.max(r,c),initialDraft:i,compactComposer:o,composerOpen:d,onComposerOpenChange:h})})}function qp(e,t,n){return[...e].filter(r=>r.lifecycleStatus!=="archived").sort((r,i)=>{const a=Gp(r,t,n),o=Gp(i,t,n);return a!==o?o-a:r.name.localeCompare(i.name,"zh-Hans-CN")})}function Gp(e,t,n){return n&&e.id===n?2:t&&e.workspaceId===t?1:0}function Vp({projects:e,currentProjectId:t,preferredProjectId:n,preferredWorkspaceId:r}){var a;if(t&&e.some(o=>o.id===t))return t;if(n&&e.some(o=>o.id===n))return n;const i=r?e.find(o=>o.workspaceId===r):null;return(i==null?void 0:i.id)||((a=e[0])==null?void 0:a.id)||""}function RR(){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("path",{d:"M12 5v14"}),s.jsx("path",{d:"M5 12h14"})]})}function PR({expanded:e}){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true","data-expanded":e?"true":void 0,children:s.jsx("path",{d:"M3.5 6 8 10l4.5-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function AR(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 8.4 6.6 11.5 12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function LR(e){switch(e){case"bug":return l("shell.butlerInboxTypeBug");case"feature":return l("shell.butlerInboxTypeFeature");case"change":return l("shell.butlerInboxTypeChange");case"task":default:return l("shell.butlerInboxTypeTask")}}function Kp(e){switch(e){case"in_progress":return l("shell.butlerInboxStatusInProgress");case"closed":return l("shell.butlerInboxStatusClosed");case"pending":default:return l("shell.butlerInboxStatusPending")}}function _R(e){return new Date(e).toLocaleString()}function DR({open:e,onClose:t,onImported:n}){const{showToast:r}=lr(),[i,a]=f.useState(!1),[o,c]=f.useState(!1),[u,d]=f.useState(!1),[h,p]=f.useState(null),[g,m]=f.useState(""),[y,S]=f.useState(""),[j,x]=f.useState(null),[A,T]=f.useState([]),[F,R]=f.useState([]),[I,G]=f.useState(!1),[z,L]=f.useState(""),E=i||o||u,H=f.useCallback(async V=>{a(!0),p(null);try{const le=await Uf(V);m(le.currentPath),S(le.currentPath),x(le.parentPath),T(le.roots),R(le.items)}catch(le){m(""),x(null),R([]),p(le instanceof Error?le.message:l("shell.importBrowserBrowseFailed"))}finally{a(!1)}},[]);f.useEffect(()=>{if(!e){G(!1),L(""),p(null);return}H(g||void 0)},[H,e]);function B(){E||(G(!1),L(""),t())}async function oe(V){V.preventDefault(),await H(y)}function K(){!g||E||(L(""),G(!0))}function X(){o||(G(!1),L(""))}async function Y(V){V==null||V.preventDefault();const le=z.trim();if(!(!g||!le||E)){c(!0),p(null);try{const C=await py({parentPath:g,directoryName:le});r({title:l("shell.importBrowserCreateDirectorySuccess"),description:C.path,tone:"success"}),G(!1),L(""),await H(C.path)}catch(C){const _e=C instanceof Error?C.message:l("shell.importBrowserCreateDirectoryFailed");p(_e),r({title:_e,tone:"error"})}finally{c(!1)}}}async function D(){const V=g.trim();if(!(!V||E)){d(!0),p(null);try{const le=await hy({path:V});r({title:l("shell.importSuccess"),description:le.path,tone:"success"}),t(),Promise.resolve().then(()=>n==null?void 0:n(le)).catch(C=>{r({title:C instanceof Error?C.message:l("shell.navigationLoadFailed"),tone:"error"})})}catch(le){r({title:le instanceof Error?le.message:l("shell.importFailed"),tone:"error"})}finally{d(!1)}}}return s.jsxs(s.Fragment,{children:[s.jsxs(St,{open:e,title:l("shell.importBrowserTitle"),description:l("shell.importBrowserDescription"),onClose:B,children:[s.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:oe,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCurrentPath")}),s.jsx("input",{type:"text",value:y,placeholder:l("shell.importPathPlaceholder"),onChange:V=>S(V.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:E||!j,onClick:()=>{j&&H(j)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:E,children:l("shell.importBrowserOpenPath")}),s.jsx("button",{type:"button",className:"secondary-button",disabled:E||!g,onClick:K,children:l("shell.importBrowserCreateDirectory")})]})]}),s.jsxs("section",{className:"workbench-directory-browser-panel",children:[s.jsxs("div",{className:"workbench-directory-browser-section",children:[s.jsx("span",{className:"workbench-directory-browser-section-title",children:l("shell.importBrowserRoots")}),s.jsx("div",{className:"workbench-directory-browser-root-list",children:A.map(V=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:E,onClick:()=>{H(V.path)},children:V.name},V.path))})]}),s.jsx("div",{className:"workbench-directory-browser-current-path",children:g}),h?s.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:h}):null,i?s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("common.loading")}):F.length>0?s.jsx("div",{className:"workbench-directory-browser-list",children:F.map(V=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:E,onClick:()=>{H(V.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:V.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:V.path})]},V.path))}):s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("shell.importBrowserEmpty")})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:E,onClick:B,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:E||!g,onClick:()=>{D()},children:u?l("shell.importSubmitting"):l("shell.importBrowserSubmit")})]})]}),s.jsx(St,{open:e&&I,title:l("shell.importBrowserCreateDirectoryTitle"),description:l("shell.importBrowserCreateDirectoryDescription"),onClose:X,children:s.jsxs("form",{className:"workbench-rename-form",onSubmit:V=>void Y(V),children:[s.jsx("div",{className:"workbench-directory-browser-current-path",children:g}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCreateDirectoryLabel")}),s.jsx("input",{type:"text",value:z,placeholder:l("shell.importBrowserCreateDirectoryPlaceholder"),autoFocus:!0,onChange:V=>L(V.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:o,onClick:X,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:o||!z.trim(),children:o?l("shell.importBrowserCreatingDirectory"):l("shell.importBrowserCreateDirectorySubmit")})]})]})})]})}function BR({onOpenSoftwareUpdate:e}){var r;const t=gu(i=>i.platform),n=ry(i=>i.latestState);return t!=="desktop"||!(n!=null&&n.hasUpdate)?null:s.jsx("button",{className:"workbench-nav-update-badge",type:"button",title:((r=n.manifest)==null?void 0:r.version)??l("settings.releaseUpdateReady"),onClick:e,children:s.jsx("span",{className:"workbench-nav-update-badge-label",children:l("settings.releaseUpdateBadge")})})}function OR(){const e=ny.getState().profile.defaultPermissionMode;return e==="default"?null:e}const ta="provider-default",Io="__global_default__";function WR(e){switch(e){case"claude-code":case"codex":case"gemini":return e;default:return null}}function mo(e,t){const n=(t==null?void 0:t.trim())||null;return e==="cc-switch-preset"&&n?{providerConfigMode:"cc-switch-preset",providerPresetId:n}:{providerConfigMode:"global-default",providerPresetId:null}}function FR(e){const t=e!=null&&e.currentPresetName?e.currentModel?`${e.currentPresetName} · ${e.currentModel}`:e.currentPresetName:null;return[{value:Io,label:l("conversation.deploymentDefaultPreset"),summary:t},...((e==null?void 0:e.options)??[]).map(n=>({value:n.id,label:n.name,summary:n.model??n.summary??null}))]}function $R(e){return e.usesProviderDefault===!0||e.id===ta}function zR(e){return e?e.cliAvailable===!0&&e.status!=="unavailable"&&e.options.length>1:!0}function HR({triggerId:e,ariaLabel:t,triggerLabel:n,presetOptions:r,selectedPresetValue:i,selectedPresetSummary:a,onSelectPreset:o,modelOptions:c,selectedModelValue:u,onSelectModel:d,loadingPresets:h=!1,loadingModels:p=!1,modelColumnDisabled:g=!1,showPresetColumn:m=!0,modelEmptyText:y}){const[S,j]=f.useState(!1),x=f.useRef(null),A=f.useRef(null),T=f.useRef(null),[F,R]=f.useState(null),I=f.useId(),G=f.useCallback(()=>{const z=A.current;if(!z||typeof window>"u")return;const L=z.getBoundingClientRect(),E=z.closest(".workbench-modal-card"),H=E instanceof HTMLElement?E.getBoundingClientRect():null,B=window.innerWidth,oe=window.innerHeight,K=12,X=8,Y=320,D=Math.min(560,Math.max(320,B-K*2)),V=Math.min(D,420),le=Math.max(Math.min(D,Math.max(V,Math.round(L.width*1.9))),Math.min(320,D)),C=Math.min(Math.max(K,L.left),Math.max(K,B-le-K)),_e=H?Math.max(K,H.top+8):K,Z=H?Math.min(oe-K,H.bottom-8):oe-K,N=Math.max(0,L.top-_e-X),be=Math.max(0,Z-L.bottom-X),ne=H?!(be>=Y||be>N+40):N>=240||N>=be;R({position:"fixed",left:C,width:le,maxWidth:D,zIndex:1905,top:ne?void 0:L.bottom+X,bottom:ne?oe-L.top+X:void 0})},[]);return f.useEffect(()=>{if(!S)return;function z(E){var B,oe;const H=E.target;!((B=x.current)!=null&&B.contains(H))&&!((oe=T.current)!=null&&oe.contains(H))&&j(!1)}function L(E){E.key==="Escape"&&j(!1)}return window.addEventListener("pointerdown",z),window.addEventListener("keydown",L),window.addEventListener("resize",G),window.addEventListener("scroll",G,!0),G(),()=>{window.removeEventListener("pointerdown",z),window.removeEventListener("keydown",L),window.removeEventListener("resize",G),window.removeEventListener("scroll",G,!0)}},[S,G]),s.jsxs("div",{ref:x,className:"composer-mac-select composer-deployment-select","data-open":S?"true":"false",children:[s.jsxs("button",{id:e,ref:A,type:"button",className:"composer-mac-select-trigger composer-deployment-select-trigger","aria-label":t,"aria-haspopup":"dialog","aria-expanded":S,"aria-controls":I,onClick:()=>j(z=>!z),children:[s.jsx("span",{className:"composer-mac-select-label composer-deployment-select-label",children:n}),s.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),S&&F&&typeof document<"u"?Fr.createPortal(s.jsx("div",{ref:T,className:"composer-mac-select-popover composer-deployment-select-popover",style:F,role:"presentation",children:s.jsxs("div",{id:I,className:`composer-deployment-select-panel${m?"":" is-model-only"}`,role:"dialog","aria-label":t,children:[m?s.jsxs("div",{className:"composer-deployment-select-column",children:[s.jsx("div",{className:"composer-deployment-select-column-header",children:l("conversation.deploymentConfigColumn")}),s.jsxs("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":l("conversation.deploymentConfigColumn"),children:[r.map(z=>{const L=z.value===i;return s.jsxs("button",{type:"button",role:"option","aria-selected":L,className:`composer-deployment-select-option ${L?"is-selected":""}`,onClick:()=>o(z.value),children:[s.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:L?"✓":""}),s.jsxs("span",{className:"composer-deployment-select-option-copy",children:[s.jsx("span",{className:"composer-deployment-select-option-label",children:z.label}),z.summary?s.jsx("span",{className:"composer-deployment-select-option-summary",children:z.summary}):null]})]},z.value)}),h?s.jsx("div",{className:"composer-deployment-select-state",children:l("conversation.deploymentLoading")}):null]})]}):null,s.jsxs("div",{className:"composer-deployment-select-column","data-disabled":g?"true":"false",children:[s.jsx("div",{className:"composer-deployment-select-column-header",children:l("conversation.deploymentModelColumn")}),m&&a?s.jsx("div",{className:"composer-deployment-select-column-hint",children:a}):null,s.jsx("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":l("conversation.deploymentModelColumn"),children:p&&g?s.jsx("div",{className:"composer-deployment-select-state",children:l("conversation.deploymentModelLoading")}):c.length>0?c.map(z=>{const L=z.value===u;return s.jsxs("button",{type:"button",role:"option","aria-selected":L,className:`composer-deployment-select-option ${L?"is-selected":""}`,disabled:g,onClick:()=>{d(z.value),j(!1)},children:[s.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:L?"✓":""}),s.jsx("span",{className:"composer-deployment-select-option-copy",children:s.jsx("span",{className:"composer-deployment-select-option-label",children:z.label})})]},z.value)}):s.jsx("div",{className:"composer-deployment-select-state",children:y})})]})]})}),document.body):null]})}const Zb=144,UR=196,qR=124,GR=72;let Yp=null;function VR(e,t){if(typeof document>"u")return t.length*8;Yp??(Yp=document.createElement("canvas"));const n=Yp.getContext("2d");if(!n)return t.length*8;const r=window.getComputedStyle(e),i=r.fontStyle||"normal",a=r.fontWeight||"600",o=r.fontSize||"13px",c=r.fontFamily||"system-ui";return n.font=`${i} ${a} ${o} ${c}`,n.measureText(t).width}function KR({labels:e,triggerWidth:t,maxWidth:n,preferredWidth:r,measureText:i}){const a=e.reduce((o,c)=>Math.max(o,Math.ceil(i(c)+GR)),0);return Math.min(n,Math.max(t,Zb,r,a))}function Xp({triggerId:e,ariaLabel:t,value:n,options:r,onChange:i,disabled:a=!1,compact:o=!1,className:c}){const[u,d]=f.useState(!1),h=f.useRef(null),p=f.useRef(null),g=f.useRef(null),[m,y]=f.useState(null),S=f.useId(),j=r.find(T=>T.value===n)??r[0]??null,x=f.useMemo(()=>r.map(T=>T.label),[r]),A=f.useCallback(()=>{const T=p.current;if(!T||typeof window>"u")return;const F=T.getBoundingClientRect(),R=window.innerWidth,I=window.innerHeight,G=12,z=10,L=Math.max(Zb,R-G*2),E=o?qR:UR,H=KR({labels:x,triggerWidth:F.width,maxWidth:L,preferredWidth:E,measureText:Y=>VR(T,Y)}),B=Math.min(Math.max(G,F.left),Math.max(G,R-H-G)),oe=F.top-G,K=I-F.bottom-G,X=oe>=180||oe>=K;y({position:"fixed",left:B,width:H,maxWidth:L,zIndex:1905,top:X?void 0:F.bottom+z,bottom:X?I-F.top+z:void 0})},[o,x]);return f.useEffect(()=>{if(!u)return;function T(R){var G,z;const I=R.target;!((G=h.current)!=null&&G.contains(I))&&!((z=g.current)!=null&&z.contains(I))&&d(!1)}function F(R){R.key==="Escape"&&d(!1)}return window.addEventListener("pointerdown",T),window.addEventListener("keydown",F),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),A(),()=>{window.removeEventListener("pointerdown",T),window.removeEventListener("keydown",F),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[u,A]),j?s.jsxs("div",{ref:h,className:`composer-mac-select ${o?"is-compact":""}${c?` ${c}`:""}`,"data-open":u?"true":"false",children:[s.jsxs("button",{id:e,ref:p,type:"button",className:"composer-mac-select-trigger","aria-label":t,"aria-haspopup":"listbox","aria-expanded":u,"aria-controls":S,disabled:a,onClick:()=>d(T=>!T),children:[s.jsx("span",{className:"composer-mac-select-label",children:j.label}),s.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),u&&m&&typeof document<"u"?Fr.createPortal(s.jsx("div",{ref:g,className:"composer-mac-select-popover",style:m,role:"presentation",children:s.jsx("div",{id:S,className:"composer-mac-select-list",role:"listbox","aria-label":t,children:r.map(T=>{const F=T.value===n;return s.jsxs("button",{type:"button",role:"option","aria-selected":F,className:`composer-mac-select-option ${F?"is-selected":""}`,onClick:()=>{i(T.value),d(!1)},children:[s.jsx("span",{className:"composer-mac-select-option-check","aria-hidden":"true",children:F?"✓":""}),s.jsx("span",{className:"composer-mac-select-option-label",children:T.label})]},T.value)})})}),document.body):null]}):null}const go=["codex","claude-code","gemini"];function ek(e){return{provider:e,model:"",providerConfigMode:"global-default",providerPresetId:null,memberPrompt:"",workspaceIsolationMode:"none"}}function Jp(e,t){return Array.from({length:t},()=>ek(e))}function xc(e,t){var n;return(n=e==null?void 0:e.modelOptions)!=null&&n.length?e.modelOptions:yu(t).modelOptions??[]}function Qp(e,t,n){return t!=="cc-switch-preset"||!n?null:`${e}::${n}`}function Zp(e,t){return Math.max(0,e-t.length)}function YR({open:e,source:t,onClose:n,onCreated:r}){const i=f.useId(),a=(t==null?void 0:t.defaultProvider)??"codex",o=(t==null?void 0:t.kind)==="group",c=(t==null?void 0:t.kind)==="group"?Math.max(0,4-t.currentMemberCount):4,u=f.useMemo(()=>(t==null?void 0:t.kind)==="group"?Array.from({length:c},(ae,se)=>se+1):[2,3,4],[c,t==null?void 0:t.kind]),d=(t==null?void 0:t.kind)==="group"?1:2,h=(t==null?void 0:t.kind)==="group"?t.sharedPrompt:"",{visibleProviders:p}=fy(my,e),[g,m]=f.useState(h),[y,S]=f.useState(d),[j,x]=f.useState(()=>Jp(a,d)),[A,T]=f.useState({}),[F,R]=f.useState({}),[I,G]=f.useState({}),[z,L]=f.useState({}),[E,H]=f.useState({}),[B,oe]=f.useState(!1),[K,X]=f.useState(!1),[Y,D]=f.useState(null),[V,le]=f.useState(null),[C,_e]=f.useState({}),Z=f.useRef(!1),N=f.useRef({});f.useEffect(()=>{if(!e)return;const ae=(t==null?void 0:t.defaultProvider)??"codex",se=(t==null?void 0:t.kind)==="group"?1:2;m((t==null?void 0:t.kind)==="group"?t.sharedPrompt:""),S(se),x(Jp(ae,se)),T({}),R({}),G({}),L({}),H({}),oe(!1),X(!1),D(null),le(null),_e({}),Z.current=!1,Object.keys(N.current).forEach(ke=>{delete N.current[ke]})},[e,t==null?void 0:t.defaultProvider,t==null?void 0:t.kind,t==null?void 0:t.workspaceId,(t==null?void 0:t.kind)==="session"?t.sessionId:null,(t==null?void 0:t.kind)==="group"?t.groupId:null,(t==null?void 0:t.kind)==="group"?t.sharedPrompt:null]),f.useEffect(()=>{x(ae=>{var ye;if(ae.length===y)return ae;if(ae.length>y)return ae.slice(0,y);const se=ae.slice(),ke=((ye=ae[0])==null?void 0:ye.provider)??a;for(;se.length<y;)se.push(ek(ke));return se})},[a,y]),f.useEffect(()=>{u.length!==0&&S(ae=>u.includes(ae)?ae:u[0]??ae)},[u]),f.useEffect(()=>{if(!e||!t)return;let ae=!1;return oe(!0),gy(p,t.workspaceId).then(se=>{ae||T(se)}).finally(()=>{ae||oe(!1)}),()=>{ae=!0}},[e,t==null?void 0:t.workspaceId,p]),f.useEffect(()=>{e&&(Z.current||(Z.current=!0,G(ae=>({...ae,...Object.fromEntries(go.map(se=>[se,!0]))})),by().then(ae=>{const se=Object.fromEntries(ae.items.map(ke=>[ke.app,ke]));R(Object.fromEntries(go.map(ke=>[ke,se[ke]??null])))}).catch(()=>{R(Object.fromEntries(go.map(ae=>[ae,null])))}).finally(()=>{G(ae=>({...ae,...Object.fromEntries(go.map(se=>[se,!1]))}))})))},[e]),f.useEffect(()=>{if(!e||!t)return;const ae=Array.from(new Set(j.map(se=>{const ke=mo(se.providerConfigMode,se.providerPresetId);return Qp(se.provider,ke.providerConfigMode,ke.providerPresetId)}).filter(se=>se!==null))).filter(se=>z[se]===void 0&&!N.current[se]);if(ae.length!==0)for(const se of ae){const[ke,ye]=se.split("::");N.current[se]=!0,H(Me=>({...Me,[se]:!0})),qf(ke,t.workspaceId,{providerConfigMode:"cc-switch-preset",providerPresetId:ye}).then(Me=>{L($=>({...$,[se]:Me}))}).catch(()=>{L(Me=>({...Me,[se]:null}))}).finally(()=>{delete N.current[se],H(Me=>({...Me,[se]:!1}))})}},[z,j,e,t]);const be=f.useMemo(()=>p.filter(ae=>{const se=A[ae];return se?se.canStartSession!==!1:!1}),[A,p]);f.useEffect(()=>{if(!be.length)return;const ae=be.includes(a)?a:be[0];x(se=>{let ke=!1;const ye=se.map(Me=>be.includes(Me.provider)?Me:(ke=!0,{...Me,provider:ae,providerConfigMode:"global-default",providerPresetId:null,model:""}));return ke?ye:se})},[be,a]);const ne=f.useMemo(()=>j.map((ae,se)=>{var Ye;const ke=mo(ae.providerConfigMode,ae.providerPresetId),ye=WR(ae.provider),Me=ye?F[ye]??null:null,$=FR(Me),Q=ke.providerConfigMode==="cc-switch-preset"?ke.providerPresetId??Io:Io,ge=$.find(dt=>dt.value===Q)??$[0]??null,Ne=Qp(ae.provider,ke.providerConfigMode,ke.providerPresetId),Be=A[ae.provider]??null,Ke=Ne?z[Ne]??null:null,ut=(ke.providerConfigMode==="cc-switch-preset"?Ke?xc(Ke,ae.provider):[{id:ta,name:l("conversation.modelUseCliDefault"),usesProviderDefault:!0}]:xc(Be,ae.provider)).map(dt=>({value:dt.id,label:$R(dt)?l("conversation.modelUseCliDefault"):dt.name})),Qe=ae.model.trim()||ta,rt=((Ye=ut.find(dt=>dt.value===Qe))==null?void 0:Ye.label)??l("conversation.modelUseCliDefault"),st=zR(Me),qe=ye!==null,gt=Ne?E[Ne]===!0:!1,Ht=!!(Ne&&gt&&Ke===null);return{index:se,draft:ae,supportsDeploymentPicker:qe,showPresetColumn:st,deploymentPresetOptions:$,selectedPresetValue:Q,selectedPresetOption:ge,triggerLabel:st?`${(ge==null?void 0:ge.label)??l("conversation.deploymentDefaultPreset")} · ${rt}`:rt,selectedModelValue:Qe,modelOptions:ut,loadingPresets:ye?I[ye]===!0:!1,loadingModels:gt,modelColumnDisabled:Ht}}),[z,F,I,E,j,A]);if(f.useEffect(()=>{e&&x(ae=>{let se=!1;const ke=ae.map((ye,Me)=>{const $=ne[Me];if(!$)return ye;let Q=ye;const ge=mo(ye.providerConfigMode,ye.providerPresetId);ge.providerConfigMode==="cc-switch-preset"&&ge.providerPresetId&&!$.loadingPresets&&!$.deploymentPresetOptions.some(Ke=>Ke.value===ge.providerPresetId)&&(Q={...Q,providerConfigMode:"global-default",providerPresetId:null,model:""},se=!0);const Ne=new Set($.modelOptions.map(Ke=>Ke.value)),Be=Q.model.trim()||ta;return Ne.has(Be)||(Q={...Q,model:""},se=!0),Q});return se?ke:ae})},[ne,e]),!e||!t)return null;const fe=t,ue=V?Zp(j.length,V.memberFailures):0,He=new Set(V?j.map((ae,se)=>se).filter(ae=>!(ae in C)):[]),Ue=fe.kind==="group"?l("shell.parallelAppendModalTitle"):l("shell.parallelCreateModalTitle"),je=fe.kind==="session"?`${fe.workspaceName} · ${fe.sessionTitle}`:fe.workspaceName,Te=fe.kind==="group"?l("shell.parallelAppendSharedPromptLabel"):l("shell.parallelCreateSharedPromptLabel"),O=fe.kind==="group"?l("shell.parallelAppendCountLabel"):l("shell.parallelCreateCountLabel"),q=fe.kind==="group"?l("shell.parallelAppendSubmit"):l("shell.parallelCreateSubmit"),J=fe.kind==="group"?l("shell.parallelAppendSubmitting"):l("shell.parallelCreateSubmitting"),Ce=Y??(fe.kind==="group"&&c===0?l("shell.parallelAppendNoRemainingSlots"):null)??(!B&&be.length===0?l("shell.parallelCreateNoAvailableProviders"):null),Ee={"--parallel-member-columns":String(Math.max(1,Math.min(y,4)))};function ve(ae){D(null),le(null),_e(se=>{if(!(ae in se))return se;const ke={...se};return delete ke[ae],ke})}function Tt(){D(null),le(null),_e({})}function nt(ae,se){ve(ae);const ke=se?"temporary_worktree":"none";x(ye=>ye.map((Me,$)=>$===ae?{...Me,workspaceIsolationMode:ke}:Me))}async function mt(){const ae=g.trim();if(!o&&!ae){D(l("shell.parallelCreatePromptRequired"));return}if(fe.kind==="group"&&c===0){D(l("shell.parallelAppendNoRemainingSlots"));return}if(!be.length){D(l("shell.parallelCreateNoAvailableProviders"));return}X(!0),D(null),le(null),_e({});try{const se=OR(),ke=j.map(Me=>{const $=mo(Me.providerConfigMode,Me.providerPresetId);return{provider:Me.provider,model:Me.model.trim()||null,providerConfigMode:$.providerConfigMode,providerPresetId:$.providerConfigMode==="cc-switch-preset"?$.providerPresetId:null,memberPrompt:Me.memberPrompt.trim()||null,workspaceIsolationMode:Me.workspaceIsolationMode}}),ye=fe.kind==="group"?await ky(fe.groupId,{permissionMode:se,members:ke}):fe.kind==="session"?await yy(fe.sessionId,{sharedPrompt:ae,permissionMode:se,members:ke}):await xy(fe.workspaceId,{sharedPrompt:ae,permissionMode:se,members:ke});if(ye.memberFailures.length>0){const Me=Zp(j.length,ye.memberFailures);le(ye),_e(Object.fromEntries(ye.memberFailures.map($=>[$.ordinal,$]))),D(Me>0?l("shell.parallelCreatePartialFailure",{successCount:Me,failureCount:ye.memberFailures.length}):l("shell.parallelCreateAllFailed",{failureCount:ye.memberFailures.length}));return}await r(ye)}catch(se){D(se instanceof Error?se.message:l("shell.parallelGroupLoadFailed"))}finally{X(!1)}}return s.jsx(xu,{open:e,title:Ue,description:je,size:"xwide",layout:"form",className:"parallel-create-modal",bodyClassName:"parallel-create-modal-body",dismissible:!K,onClose:n,footer:s.jsxs(Ss,{align:"between",className:"parallel-create-modal-footer",children:[s.jsx("div",{className:"parallel-create-modal-status",role:"status","aria-live":"polite",children:Ce?s.jsx("span",{className:"parallel-create-modal-error",children:Ce}):null}),s.jsxs("div",{className:"parallel-create-modal-footer-actions",children:[V&&ue>0?s.jsx("button",{type:"button",className:"secondary-button",disabled:K,onClick:()=>{r(V)},children:l("shell.parallelCreateContinuePartial")}):null,s.jsx("button",{type:"button",className:"secondary-button",disabled:K,onClick:n,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:K||B||be.length===0||fe.kind==="group"&&c===0,onClick:()=>{mt()},children:K?J:q})]})]}),children:s.jsxs("div",{className:"parallel-create-layout",children:[s.jsx(Mn,{className:"parallel-create-shared-section",tone:"accent",children:s.jsxs("div",{className:"parallel-create-target-row",children:[s.jsx(Lt,{className:"parallel-create-target-field",label:Te,htmlFor:`${i}-shared-prompt`,children:s.jsx("textarea",{id:`${i}-shared-prompt`,className:"parallel-create-textarea parallel-create-textarea-target",rows:2,value:g,readOnly:o,"aria-readonly":o,"data-readonly":o?"true":void 0,onChange:ae=>{o||(Tt(),m(ae.target.value))}})}),s.jsx(Lt,{className:"parallel-create-count-field",label:O,children:s.jsx("div",{className:"parallel-create-count-group",role:"group","aria-label":O,children:u.map(ae=>s.jsx("button",{type:"button",className:"parallel-create-count-button","data-active":y===ae,onClick:()=>{Tt(),S(ae)},children:ae},ae))})})]})}),s.jsx(Mn,{className:"parallel-create-members-section",heading:l("shell.parallelCreateMembersTitle"),children:s.jsx("div",{className:"parallel-create-member-list",style:Ee,children:ne.map(({draft:ae,index:se,supportsDeploymentPicker:ke,showPresetColumn:ye,deploymentPresetOptions:Me,selectedPresetValue:$,selectedPresetOption:Q,triggerLabel:ge,selectedModelValue:Ne,modelOptions:Be,loadingPresets:Ke,loadingModels:Ie,modelColumnDisabled:ut})=>{var Ht;const Qe=be,rt=Qe.includes(ae.provider)?ae.provider:"",st=Qe.length>0?Qe.map(Ye=>({value:Ye,label:Ec(Ye,"full")})):[{value:"",label:B?l("shell.parallelCreateProvidersLoading"):l("shell.parallelCreateNoAvailableProviders")}],qe=xc(A[ae.provider]??null,ae.provider),gt=qe.length>0?[{value:"",label:((Ht=qe.find(Ye=>Ye.usesProviderDefault===!0))==null?void 0:Ht.name)??l("shell.parallelPaneModelFallback")},...qe.filter(Ye=>Ye.usesProviderDefault!==!0).map(Ye=>({value:Ye.id,label:Ye.name}))]:[{value:"",label:l("shell.parallelCreateNoModelsAvailable")}];return s.jsxs("article",{className:"parallel-create-member-card","data-state":C[se]?"error":He.has(se)?"success":void 0,children:[s.jsxs("header",{className:"parallel-create-member-header",children:[s.jsxs("div",{className:"parallel-create-member-title-block",children:[s.jsx("strong",{children:l("shell.parallelCreateMemberTitle",{index:se+1})}),s.jsx("span",{className:"parallel-create-member-provider",children:Ec(ae.provider,"full")}),s.jsxs("label",{className:"parallel-create-isolation-toggle",children:[s.jsx("input",{type:"checkbox",checked:ae.workspaceIsolationMode==="temporary_worktree",onChange:Ye=>{nt(se,Ye.target.checked)}}),s.jsx("span",{className:"parallel-create-isolation-copy",children:l("shell.parallelCreateIsolationLabel")})]})]}),C[se]?s.jsx("span",{className:"parallel-create-member-status error",children:l("shell.parallelCreateMemberFailed")}):He.has(se)?s.jsx("span",{className:"parallel-create-member-status success",children:l("shell.parallelCreateMemberSucceeded")}):null]}),s.jsxs("div",{className:"parallel-create-member-grid",children:[s.jsx(Lt,{label:l("shell.createSessionProviderLabel"),htmlFor:`${i}-member-${se}-provider`,children:s.jsx(Xp,{triggerId:`${i}-member-${se}-provider`,className:"parallel-create-provider-select",ariaLabel:l("shell.createSessionProviderLabel"),value:rt,options:st,disabled:!Qe.length,onChange:Ye=>{ve(se);const dt=Ye;x(De=>De.map((bt,Ze)=>Ze===se?{...bt,provider:dt,providerConfigMode:"global-default",providerPresetId:null,model:""}:bt))}})}),s.jsx(Lt,{label:l("shell.parallelCreateModelLabel"),htmlFor:ke?void 0:`${i}-member-${se}-model`,children:ke?s.jsx("div",{className:"parallel-create-deployment-select",children:s.jsx(HR,{triggerId:`${i}-member-${se}-model`,ariaLabel:l("shell.parallelCreateModelLabel"),triggerLabel:ge,presetOptions:Me,selectedPresetValue:$,selectedPresetSummary:(Q==null?void 0:Q.summary)??null,onSelectPreset:Ye=>{ve(se),x(dt=>dt.map((De,bt)=>bt!==se?De:Ye===Io?{...De,providerConfigMode:"global-default",providerPresetId:null,model:""}:{...De,providerConfigMode:"cc-switch-preset",providerPresetId:Ye,model:""}))},modelOptions:Be,selectedModelValue:Ne,onSelectModel:Ye=>{ve(se),x(dt=>dt.map((De,bt)=>bt===se?{...De,model:Ye===ta?"":Ye}:De))},loadingPresets:Ke,loadingModels:Ie,modelColumnDisabled:ut,showPresetColumn:ye,modelEmptyText:l("conversation.deploymentModelEmpty")})}):s.jsx(Xp,{triggerId:`${i}-member-${se}-model`,className:"parallel-create-provider-select",ariaLabel:l("shell.parallelCreateModelLabel"),value:ae.model,options:gt,disabled:!Qe.length||qe.length===0,onChange:Ye=>{ve(se),x(dt=>dt.map((De,bt)=>bt===se?{...De,model:Ye}:De))}})})]}),s.jsx(Lt,{label:l("shell.parallelCreateMemberPromptLabel"),htmlFor:`${i}-member-${se}-prompt`,children:s.jsx("textarea",{id:`${i}-member-${se}-prompt`,className:"parallel-create-textarea member",rows:2,value:ae.memberPrompt,onChange:Ye=>{ve(se);const dt=Ye.target.value;x(De=>De.map((bt,Ze)=>Ze===se?{...bt,memberPrompt:dt}:bt))}})}),C[se]?s.jsxs("div",{className:"parallel-create-member-error",role:"alert",children:[s.jsx("strong",{children:l("shell.parallelCreateMemberErrorTitle")}),s.jsx("p",{children:C[se].detail})]}):null]},`parallel-member-${se}`)})})})]})})}const XR=12,JR=180,ef=72;function QR(e,t){const[n,r]=f.useState(!1),[i,a]=f.useState(""),[o,c]=f.useState({}),[u,d]=f.useState({}),[h,p]=f.useState(!1),[g,m]=f.useState(null);f.useEffect(()=>{e||(r(!1),a(""),m(null))},[e]),f.useEffect(()=>{if(!e||!n)return;const j=t.filter(A=>u[A.sessionId]!==!0);if(j.length===0)return;let x=!1;return p(!0),m(null),Promise.allSettled(j.map(async A=>{const T=await Hf(A.sessionId,null,XR,"backward");return{sessionId:A.sessionId,summary:ZR(T.messages)}})).then(A=>{if(x)return;const T={},F={};let R=0;j.forEach(I=>{T[I.sessionId]=!0});for(const I of A){if(I.status==="fulfilled"){F[I.value.sessionId]=I.value.summary;continue}R+=1}d(I=>({...I,...T})),Object.keys(F).length>0&&c(I=>({...I,...F})),m(R>0?l("shell.archiveSearchSummaryFailed"):null)}).finally(()=>{x||p(!1)}),()=>{x=!0}},[u,e,n,t]);const y=f.useMemo(()=>{const j=wc(i);return j?t.filter(x=>wc(x.title).includes(j)?!0:wc(o[x.sessionId]??"").includes(j)):t},[i,t,o]);function S(){r(j=>{const x=!j;return x||(a(""),m(null)),x})}return{searchOpen:n,searchKeyword:i,filteredSessions:y,summaryLoading:h,summaryError:g,summaryBySessionId:o,setSearchKeyword:a,toggleSearch:S}}function ZR(e){const t=[...e].sort((r,i)=>r.sequence-i.sequence).map(eP).filter(r=>r.length>0);if(t.length===0)return"";const n=t.slice(-3).join(" · ");return ou(n,JR)}function eP(e){var n,r;const t=tk(e.content);return t.length>0?ou(t,ef):(r=(n=e.toolCall)==null?void 0:n.name)!=null&&r.trim()?ou(e.toolCall.name.trim(),ef):""}function wc(e){return tk(e).toLocaleLowerCase()}function tk(e){return e.replace(/\s+/g," ").trim()}function ou(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}const tf="workbench.left.width",nf="workbench.right.width",rf="workbench.left.collapsed",sf="workbench.right.collapsed",bo="workbench.last.session.path",vc="workbench.workspace.selected.id",af="workbench.notifications.seen_at",tP=280,nP=320,of=240,lf=280,cf=520,uf=560,rP=200,Sc=20,Yi=40,ko=5,sP=3e4,iP=12,df=60*1e3,aP=4e3,hf=220,pf=18,oP=6,si="data-workbench-panel-resizing",yo="data-workbench-window-resizing",lP=180,cP="workbench:focus-composer",uP=new Set(["starting","running","reconnecting","stale","unknown"]),dP=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"],hP=["--workbench-titlebar-live-content-shift-y","--workbench-nav-toolbar-live-shift-y","--workbench-info-tabs-live-shift-y","--workbench-auxiliary-toolbar-button-live-shift-y","--workbench-conversation-header-main-live-shift-y","--workbench-conversation-header-actions-live-shift-y","--workbench-terminal-tabbar-live-shift-y","--workbench-collapsed-controls-live-shift-y","--workbench-collapsed-left-controls-live-shift-y","--workbench-collapsed-right-controls-live-shift-y"],Rt={navToolbar:{selector:".workbench-nav-toolbar",variableName:"--workbench-nav-toolbar-live-shift-y"},infoTabs:{selector:".workbench-info-tabs",variableName:"--workbench-info-tabs-live-shift-y"},auxiliaryToolbarButton:{selector:".workbench-auxiliary-header > .workbench-nav-toolbar-button",variableName:"--workbench-auxiliary-toolbar-button-live-shift-y"},conversationHeaderMain:{selector:".conversation-header-main",variableName:"--workbench-conversation-header-main-live-shift-y"},conversationHeaderActions:{selector:".conversation-header-actions",variableName:"--workbench-conversation-header-actions-live-shift-y"},terminalTabbarMain:{selector:".terminal-tabbar-main",variableName:"--workbench-terminal-tabbar-live-shift-y"},collapsedLeftControls:{selector:'.workbench-collapsed-controls.left[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-left-controls-live-shift-y"},collapsedRightControls:{selector:'.workbench-collapsed-controls.right[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-right-controls-live-shift-y"}};function nk(e,t){const n=e.getPropertyValue(t).trim();if(!n)return null;const r=Number.parseFloat(n);return Number.isFinite(r)?r:null}function pP(e){return Math.round(e*100)/100}function fP(e,t){const n=t.getBoundingClientRect();if(n.width<=0||n.height<=0)return null;const r=window.getComputedStyle(t);return r.display==="none"||r.visibility==="hidden"?null:n.top-e.top+n.height/2}function ns(e,t){const n=e.getBoundingClientRect(),i=Array.from(e.querySelectorAll(t)).map(a=>fP(n,a)).filter(a=>a!==null);return i.length===0?null:i.reduce((a,o)=>a+o,0)/i.length}function Sr(e,t,n){const r=e.style.getPropertyValue(t).trim();if(n===null||!Number.isFinite(n)){r&&e.style.removeProperty(t);return}const i=`${pP(n)}px`;r!==i&&e.style.setProperty(t,i)}function Cr(e,t,n,r){return r===null?null:(nk(e,t)??0)+(n-r)}function ff(e){if(e)for(const t of hP)e.style.removeProperty(t)}function mP(e){return uP.has(e.runningState??"idle")||e.activityState==="running"}function gP(e,t){const n=[];for(const r of[...t].sort()){const i=e.get(r);!i||i.size===0||n.push(`${r}:${[...i].sort().join(",")}`)}return n.join("|")}function bP(e){var i,a;const t=((i=e.lastErrorCode)==null?void 0:i.trim())??"",n=((a=e.lastErrorDetail)==null?void 0:a.trim())??"",r=[t,n].filter(o=>o.length>0).join(" · ");return r?r.length<=hf?r:`${r.slice(0,hf-3)}...`:null}function kP(e,t,n){var a,o,c,u,d,h,p,g,m,y,S,j;const r=new Map(e.projects.map(x=>[x.id,x.workspaceId])),i=[];for(const x of n){const A=x.title.trim()||x.projectName;if(x.assistantState.lifecycleStage==="analyzed"&&!((a=x.assistantState.linkedSessionId)!=null&&a.trim())&&x.assistantState.lastAnalyzedAt){i.push({id:`todo-analysis-completed:${x.id}:${x.assistantState.lastAnalyzedAt}`,kind:"todo_analyzed",title:l("shell.globalNotificationTodoAnalyzedTitle",{title:A}),body:((o=x.assistantState.analysisSummary)==null?void 0:o.trim())||((c=x.assistantState.generatedPrompt)==null?void 0:c.trim())||x.content,routePath:Ms(x.workspaceId),workspaceId:x.workspaceId,createdAt:x.assistantState.lastAnalyzedAt});continue}x.assistantState.lifecycleStage==="failed"&&i.push({id:`todo-analysis-failed:${x.id}:${x.updatedAt}`,kind:"todo_analyze_failed",title:l("shell.globalNotificationTodoAnalyzeFailedTitle",{title:A}),body:((u=x.assistantState.lastError)==null?void 0:u.trim())||x.content,routePath:Ms(x.workspaceId),workspaceId:x.workspaceId,createdAt:x.updatedAt})}for(const x of t){const A=((d=x.sessionTitle)==null?void 0:d.trim())||x.projectName,T=x.updatedAt||x.lastAutomationAt||x.createdAt;if(x.status==="waiting_user"){i.push({id:`follow-up-waiting:${x.id}`,kind:"follow_up_waiting_user",title:l("shell.globalNotificationFollowUpWaitingTitle",{title:A}),body:((h=x.waitingReason)==null?void 0:h.trim())||((p=x.lastAutomationSummary)==null?void 0:p.trim())||x.objective,routePath:ir(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:T});continue}if(x.status==="completed"){i.push({id:`follow-up-completed:${x.id}`,kind:"follow_up_completed",title:l("shell.globalNotificationFollowUpCompletedTitle",{title:A}),body:((g=x.lastAutomationSummary)==null?void 0:g.trim())||x.objective,routePath:ir(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:T});continue}x.status==="failed"&&i.push({id:`follow-up-failed:${x.id}`,kind:"follow_up_failed",title:l("shell.globalNotificationFollowUpFailedTitle",{title:A}),body:((m=x.lastAutomationSummary)==null?void 0:m.trim())||((y=x.waitingReason)==null?void 0:y.trim())||x.objective,routePath:ir(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:T})}for(const x of e.verifications){if(x.status!=="failed")continue;const A=x.projectId?r.get(x.projectId)??null:null,T=((S=x.targetRef)==null?void 0:S.trim())||x.verificationType;i.push({id:`verification-failed:${x.id}`,kind:"verification_failed",title:l("shell.globalNotificationVerificationFailedTitle",{title:T}),body:((j=x.summary)==null?void 0:j.trim())||l("shell.globalNotificationVerificationFailedFallback"),routePath:A?Ms(A):null,workspaceId:A,createdAt:x.finishedAt||x.startedAt||x.createdAt})}return i.sort((x,A)=>{const T=mf(x.kind)-mf(A.kind);return T!==0?T:as(A.createdAt)-as(x.createdAt)}).slice(0,iP)}function mf(e){switch(e){case"follow_up_waiting_user":return 0;case"todo_analyze_failed":return 1;case"follow_up_failed":return 2;case"verification_failed":return 3;case"todo_analyzed":return 4;case"follow_up_completed":return 5;default:return 9}}function yP(e){switch(e){case"follow_up_waiting_user":return l("shell.globalNotificationKindWaitingUser");case"todo_analyzed":return l("shell.globalNotificationKindTodoAnalyzed");case"todo_analyze_failed":return l("shell.globalNotificationKindTodoAnalyzeFailed");case"follow_up_completed":return l("shell.globalNotificationKindFollowUpCompleted");case"follow_up_failed":return l("shell.globalNotificationKindFollowUpFailed");case"verification_failed":return l("shell.globalNotificationKindVerificationFailed");default:return l("shell.globalNotificationsPanelTitle")}}function as(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function xP(e){return/^(?:[A-Za-z0-9_-]+)(?:\/[A-Za-z0-9_-]+)*$/.test(e)}function wP(e){return/^(?:[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*\/?)?$/.test(e)}function vP(e,t){const n=new Set,r=(e==null?void 0:e.currentBranch)??"",i=((e==null?void 0:e.local)??[]).slice().sort((c,u)=>Number(u.current)-Number(c.current)||c.name.localeCompare(u.name)).map(c=>({value:c.name,current:c.current,recommended:c.name===r})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0)),a=((e==null?void 0:e.remote)??[]).map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0)),o=t.map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0));return{localBranches:i,remoteBranches:a,tags:o}}function SP(e){return e.getBoundingClientRect()}function CP(e,t){return t?as(e.createdAt)>as(t):!0}function NP(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t)}function gf(e,t){var o,c;const n=["/workspaces/:workspaceId","/workspaces/:workspaceId/sessions","/workspaces/:workspaceId/sessions/:sessionId","/workspaces/:workspaceId/tools","/workspaces/:workspaceId/tools/files","/workspaces/:workspaceId/tools/git","/workspaces/:workspaceId/tools/processes","/workspaces/:workspaceId/terminals","/workspaces/:workspaceId/butler"];for(const u of n){const d=vt(u,e),h=(o=d==null?void 0:d.params.workspaceId)==null?void 0:o.trim();if(h)return h}const r=la(e),i=(r==null?void 0:r.sessionId)??null;return!i||!_k(i)?null:((c=new URLSearchParams(t).get("workspaceId"))==null?void 0:c.trim())||null}function jP(e){return e.startsWith("/sessions")||e.startsWith("/terminals")||e.startsWith("/tools")}function Cc(e){return e==="mobile"?xn():"/landing"}function la(e){var a,o,c;const t=vt("/workspaces/:workspaceId/sessions/:sessionId",e),n=(a=t==null?void 0:t.params.sessionId)==null?void 0:a.trim();if(n)return{sessionId:n,workspaceId:((o=t==null?void 0:t.params.workspaceId)==null?void 0:o.trim())??null};const r=vt("/sessions/:sessionId",e),i=(c=r==null?void 0:r.params.sessionId)==null?void 0:c.trim();return i?{sessionId:i,workspaceId:null}:null}function TP(e){return!!(vt("/sessions",e)||vt("/workspaces/:workspaceId/sessions",e))}function bf(e){return!!la(e)}function IP(e){return!!(vt("/tools",e)||vt("/tools/files",e)||vt("/tools/git",e)||vt("/tools/processes",e)||vt("/workspaces/:workspaceId/tools",e)||vt("/workspaces/:workspaceId/tools/files",e)||vt("/workspaces/:workspaceId/tools/git",e)||vt("/workspaces/:workspaceId/tools/processes",e))}function Eo(e){return!!(vt("/terminals",e)||vt("/workspaces/:workspaceId/terminals",e))}function Mo(e){return!!vt("/workspaces/:workspaceId/butler",e)}function EP(e,t){return vt("/workspaces/:workspaceId/debug",e)?dm(t):vt("/workspaces/:workspaceId",e)?Ir(t):vt("/workspaces/:workspaceId/tools/files",e)||vt("/tools/files",e)?pm(t):vt("/workspaces/:workspaceId/tools/git",e)||vt("/tools/git",e)?fm(t):vt("/workspaces/:workspaceId/tools/processes",e)||vt("/tools/processes",e)?mm(t):vt("/workspaces/:workspaceId/tools",e)||vt("/tools",e)?hm(t):Eo(e)?js(t):Mo(e)?Ms(t):xi(t)}function MP(e){return e.trim().replace(/\\/g,"/").replace(/^(?:\.\/)+/,"").replace(/^\/+/,"")}const RP=f.lazy(async()=>({default:(await bu(()=>import("./FileContextPanel-lM5mBcfn.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).FileContextPanel})),PP=f.lazy(async()=>({default:(await bu(()=>import("./GitSidebar-CmXAhyjo.js"),__vite__mapDeps([11,1,2,3,4,5,7,6,8,9,10]))).GitSidebar})),AP=f.lazy(async()=>({default:(await bu(()=>import("./TerminalManagerPanel-D9JHCS6d.js"),__vite__mapDeps([12,1,2,6,3,4,5,13,14,8,9,10]))).TerminalManagerPanel}));function LP(e){return!!((e==null?void 0:e.item)??(e==null?void 0:e.session))}function Rn(e){return Ni(e)}function _P(e){return e&&"item"in e?e.item:(e==null?void 0:e.session)??null}function ci(e){return Array.isArray(e==null?void 0:e.visibleSessionTree)?e.visibleSessionTree.filter(LP):[]}async function rk(e,t){const n=await qf(t,e);if(n.canStartSession===!1)throw new Error(n.limitations[0]??l("conversation.capabilityDenied"))}const sk=f.createContext(null);function Qo(e){return OE(e)}function Tr(e){return e.isArchived===!0}function Ia(e){return am(e)}function ik(e,t){return Nu(e,{getId:n=>n.sessionId,getParentId:Ia,compare:(n,r)=>ya(n,r,t)})}function DP(e,t){const n=BP(e);return ak(n,t)}function ak(e,t){const n=OP(e);return Nu(n,{getId:r=>r.session.sessionId,getParentId:r=>Ia(r.session),compare:(r,i)=>ya(r.session,i.session,t)}).map(r=>lk(r))}function BP(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...ok(t.childWorktrees)])}function ok(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...ok(t.children)])}function OP(e){const t=[],n=new Set;for(const r of e){const i=r.session.sessionId.trim();!i||n.has(i)||(n.add(i),t.push(r))}return t}function lk(e,t=0){return{item:e.item.session,depth:t,children:e.children.map(n=>lk(n,t+1))}}function lu(e,t){return{...e,depth:e.depth+t,children:Rn(e).map(n=>lu(n,t))}}function kf(e){return`${e}::parallel-anchor-member`}function yf(e){const{session:t,depth:n,children:r}=e;return{item:t,depth:n,children:[...r]}}function cu(e,t){for(const n of e){if(n.item.sessionId===t)return n;const r=cu(Rn(n),t);if(r)return r}return null}function WP(e,t){const n=t.trim();if(!n)return null;for(const r of e){const i=ck(r,n,null);if(i)return i}return null}function ck(e,t,n){var i,a;const r=((a=(i=e.item.parallelGroup)==null?void 0:i.groupId)==null?void 0:a.trim())||n;if(e.item.sessionId===t)return r;for(const o of Rn(e)){const c=ck(o,t,r);if(c)return c}return null}function uk(e){return e.filter(t=>{if(Tr(t))return!1;const n=Ia(t);if(!n)return!0;const r=e.find(i=>i.sessionId===n);return r&&Tr(r)?!Qo(t):!0})}function FP(e){return e.flatMap(t=>{const n=_P(t);return n?[n,...lm(Rn(t))]:[]})}function $P(e,t,n){var g;const r=Rn(e),i=Ns(r).sort((m,y)=>ya(m.item,y.item,n));if(!(((g=e.item.parallelGroup)==null?void 0:g.role)==="anchor"&&r.some(m=>{var y,S;return((y=m.item.parallelGroup)==null?void 0:y.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}))){const m=new Set(i.slice(0,Math.max(0,t)).map(y=>y.item.sessionId));return{...e,children:uu(r,m)}}const o=r.slice().sort((m,y)=>ya(m.item,y.item,n)),c=o.filter(m=>{var y,S;return((y=m.item.parallelGroup)==null?void 0:y.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(m=>m.item.sessionId),u=o.filter(m=>{var y,S;return((y=m.item.parallelGroup)==null?void 0:y.groupId)!==((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(m=>m.item.sessionId),d=[...c,...u],h=Math.max(0,t-d.length),p=new Set(d);for(const m of i){if(p.size>=d.length+h)break;p.add(m.item.sessionId)}return{...e,children:uu(r,p)}}function uu(e,t){return e.flatMap(n=>{const r=uu(Rn(n),t);return!t.has(n.item.sessionId)&&r.length===0?[]:[{...n,children:r}]})}function xo(e,t,n,r=-1){if(e<=0)return 0;const i=r>=0?Math.max(t,r+1):t;return Math.min(e,Math.max(n??0,i))}function xf(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(i=>e[i]===t[i])}function zP(e){const t=e.lastMessageAt??e.updatedAt;return t?new Date(t).toLocaleDateString():""}function fl(e,t="compact"){return Ec(e,t)}const HP={position:"relative",zIndex:0},UP={zIndex:1};function dk(e,t,n,r){const i=[],a=(r==null?void 0:r.trim())||t.name;n&&i.push(a);const o=zP(e);return o&&i.push(o),i.join(" · ")||a}function wf(e,t){return fI("session-state-indicator",e,t)}function qP(e,t){return ob(e,t)}function vf(e,t){try{const n=window.localStorage.getItem(e),r=n?Number(n):Number.NaN;return Number.isFinite(r)?r:t}catch{return t}}function Sf(e,t){try{const n=window.localStorage.getItem(e);return n===null?t:n==="true"}catch{return t}}function Cf(e){var t;try{const n=(t=window.localStorage.getItem(e))==null?void 0:t.trim();return n||null}catch{return null}}function vs(e,t){try{window.localStorage.setItem(e,t)}catch{}}function GP(e){try{window.localStorage.removeItem(e)}catch{}}function wo(e,t,n){return Math.max(t,Math.min(n,e))}function vo(e){const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function VP(e){const t=window.getComputedStyle(e),n=vo(t.getPropertyValue("--desktop-macos-titlebar-height")),r=vo(t.getPropertyValue("--workbench-header-min-height")),i=vo(t.getPropertyValue("--workbench-macos-titlebar-padding-top")),a=vo(t.getPropertyValue("--workbench-macos-titlebar-padding-bottom"));return Math.max(n,r,40)+i+a+8}function Nf(e,t){const n=t.getBoundingClientRect();return e>=n.top&&e<=n.top+VP(t)}function KP(e){return e instanceof HTMLElement?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||!!e.closest("[contenteditable='true']"):!1}function YP(){typeof window>"u"||window.dispatchEvent(new CustomEvent(cP))}function hk(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){if(r.workspace.id===n)return r;const i=hk(r.children,n);if(i)return i}return null}function jf(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){const i=hk(r.childWorktrees,n);if(i)return i}return null}function pk(e){return e.flatMap(t=>[t.workspace.id,...pk(t.children)])}function fk(e){return new Set(e.flatMap(t=>[t.workspace.id,...pk(t.childWorktrees)]))}function Tf(e){return!e||!Array.isArray(e.items)?[]:e.items.filter(t=>{var n;return t.collapsed===!0&&((n=t.workspace)==null?void 0:n.id)}).map(t=>t.workspace.id)}function Nc(e,t){const n=new Set(t);return{items:e.map(r=>({workspace:r.workspace,sessions:r.sessions,childWorktrees:r.childWorktrees,collapsed:n.has(r.workspace.id)}))}}function mk(e,t,n,r=new Set){return e.map(i=>{const a=i.sessions.filter(c=>!r.has(c.sessionId)),o=uk(a);return{workspace:i.workspace,meta:i.meta,visibleSessions:o,archivedSessions:a.filter(c=>Tr(c)&&!Ia(c)),visibleSessionTree:ik(o,n).filter(c=>!t.has(c.item.sessionId)&&!ju(Rn(c),u=>t.has(u.sessionId))),children:mk(i.children,t,n,r)}})}function du(e){return e.flatMap(t=>[t.workspace.id,...du(t.children)])}function na(e){return e.flatMap(t=>[...t.visibleSessionTree,...na(t.children)])}function gk(e){return e.flatMap(t=>[t,...gk(t.children)])}function XP(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:ci(n)};const r=bk(n.childWorktrees,t);if(r)return r}return null}function bk(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:n.visibleSessionTree};const r=bk(n.children,t);if(r)return r}return null}function JP(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=kk(n.childWorktrees,t);if(r)return r}return null}function jc(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return n.workspace;const r=yk(n.childWorktrees,t);if(r)return r}return null}function kk(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=kk(n.children,t);if(r)return r}return null}function yk(e,t){for(const n of e){if(n.workspace.id===t)return n.workspace;const r=yk(n.children,t);if(r)return r}return null}function xk(e,t){for(const n of e){if(n.workspace.id===t)return[n.workspace.id];const r=xk(n.children,t);if(r.length>0)return[n.workspace.id,...r]}return[]}function If(e){return e.flatMap(t=>[t.workspace.id,...wk(t.childWorktrees)])}function wk(e){return e.flatMap(t=>[t.workspace.id,...wk(t.children)])}function QP(e,t=[]){if(e.tone!=="worktree")return e.rootDisplayName;if(t.length>0)return t.join(" / ");const n=[e.rootDisplayName];return e.parentDisplayName&&e.parentDisplayName!==e.rootDisplayName&&n.push(e.parentDisplayName),n.join(" / ")}function ZP(e,t,n,r){if(t===n)return e;const i=e.findIndex(d=>d.workspace.id===t),a=e.findIndex(d=>d.workspace.id===n);if(i<0||a<0)return e;const o=[...e],[c]=o.splice(i,1);if(!c)return e;const u=o.findIndex(d=>d.workspace.id===n);return u<0?e:(o.splice(r==="before"?u:u+1,0,c),o.every((d,h)=>{var p;return d.workspace.id===((p=e[h])==null?void 0:p.workspace.id)})?e:o)}function eA(e,t){if(!Array.isArray(e.items)||t.size===0)return e;let n=!1;const r=e.items.map(i=>{let a=!1;const o=i.sessions.map(u=>{const d=t.get(u.sessionId);return d===void 0||Tr(u)===d?u:(n=!0,a=!0,{...u,isArchived:d})}),c=Sk(i.childWorktrees??[],t,u=>{u&&(n=!0,a=!0)});return a?{...i,sessions:o,childWorktrees:c}:i});return n?{...e,items:r}:e}function tA(e,t){if(!(!Array.isArray(t.items)||e.size===0))for(const n of t.items){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&Tr(r)===i&&e.delete(r.sessionId)}Ck(e,n.childWorktrees??[])}}function nA(e,t,n){let r=!1;const i=e.map(a=>{if(a.workspace.id!==t.workspaceId){const{nodes:u,changed:d}=Nk(a.childWorktrees,t,n);return d?(r=!0,{...a,childWorktrees:u}):a}const o=a.sessions.findIndex(u=>u.sessionId===t.sessionId),c=o>=0?a.sessions.map((u,d)=>d===o?t:u):[t,...a.sessions];return r=!0,{...a,sessions:Ta(c,n)}});return r?i:e}function rA(e,t,n){let r=!1;const i=e.map(a=>{let o=!1;const c=a.sessions.map(d=>d.sessionId!==t?d:(r=!0,o=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState})),u=ml(a.childWorktrees,d=>d.sessionId!==t?d:(r=!0,o=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState}));return o?{...a,sessions:c,childWorktrees:u}:a});return r?i:e}function Ef(e,t,n){let r=!1;const i=e.map(a=>{let o=!1;const c=a.sessions.map(d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,o=!0,{...d,isArchived:n})),u=ml(a.childWorktrees,d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,o=!0,{...d,isArchived:n}));return o?{...a,sessions:c,childWorktrees:u}:a});return r?i:e}function Mf(e,t,n){let r=!1;const i=e.map(a=>{let o=!1;const c=a.sessions.map(d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,o=!0,{...d,isFavorite:n})),u=ml(a.childWorktrees,d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,o=!0,{...d,isFavorite:n}));return o?{...a,sessions:c,childWorktrees:u}:a});return r?i:e}function sA(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function iA(e){return e?e.slice(0,8):"--"}function Rf(e,t,n){return n?e.includes(t)?e:[...e,t]:e.includes(t)?e.filter(r=>r!==t):e}function vk(e,t){const n=e.filter(r=>t.has(r));return n.length===e.length?e:n}function Sk(e,t,n){return e.map(r=>{let i=!1;const a=r.sessions.map(c=>{const u=t.get(c.sessionId);return u===void 0||Tr(c)===u?c:(i=!0,{...c,isArchived:u})}),o=Sk(r.children,t,c=>{c&&(i=!0)});return n(i),i?{...r,sessions:a,children:o}:r})}function Ck(e,t){for(const n of t){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&Tr(r)===i&&e.delete(r.sessionId)}Ck(e,n.children)}}function Nk(e,t,n){let r=!1;const i=e.map(a=>{if(a.workspace.id===t.workspaceId){const c=a.sessions.findIndex(d=>d.sessionId===t.sessionId),u=c>=0?a.sessions.map((d,h)=>h===c?t:d):[t,...a.sessions];return r=!0,{...a,sessions:Ta(u,n)}}const o=Nk(a.children,t,n);return o.changed?(r=!0,{...a,children:o.nodes}):a});return{nodes:r?i:[...e],changed:r}}function aA(e,t){return e.map(n=>({...n,sessions:Ta(n.sessions,t),childWorktrees:cd(n.childWorktrees,t)}))}function ml(e,t){let n=!1;const r=e.map(i=>{let a=!1;const o=i.sessions.map(u=>{const d=t(u);return d!==u&&(a=!0,n=!0),d}),c=ml(i.children,t);return c!==i.children&&(a=!0,n=!0),a?{...i,sessions:o,children:c}:i});return n?r:[...e]}function hu(e){return`workspace-management.summary.${e}`}function jk(e){return`git-sidebar.snapshot.${e}`}function Tk(e,t){const n=e.repoRoot??null;return{workspaceId:e.id,name:e.name,path:e.path,git:{isRepository:!!n,repoRoot:n,currentBranch:null,commitCount:null,remotes:[],error:null},codeComposition:{scannedFileCount:0,truncated:!1,items:[],error:null}}}function Ik(e,t){const n=e.git.repoRoot??t.repoRoot??null;return{...e,workspaceId:t.id,name:t.name,path:t.path,git:{...e.git,isRepository:e.git.isRepository||!!n,repoRoot:n}}}function Ek(e,t){var a,o,c,u;const n=((a=t.status)==null?void 0:a.snapshot.enabled)!==!1,r=n?((o=t.status)==null?void 0:o.snapshot.repoRoot)??e.git.repoRoot:e.git.repoRoot,i=n?((c=t.status)==null?void 0:c.snapshot.branch)??((u=t.branches)==null?void 0:u.currentBranch)??e.git.currentBranch??null:e.git.currentBranch??null;return{...e,git:{...e.git,isRepository:n&&(e.git.isRepository||!!r),repoRoot:r,currentBranch:i,error:null}}}function Mk({count:e,className:t="workbench-skeleton-lines"}){return s.jsx("div",{className:t,"aria-hidden":"true",children:Array.from({length:e},(n,r)=>s.jsx("span",{className:"skeleton-line"},r))})}function oA(){return s.jsx("div",{className:"workbench-nav-loading","aria-hidden":"true",children:Array.from({length:3},(e,t)=>s.jsxs("section",{className:"workbench-skeleton-card",children:[s.jsxs("div",{className:"workbench-skeleton-heading",children:[s.jsx("span",{className:"skeleton-line short"}),s.jsx("span",{className:"skeleton-line tiny"})]}),s.jsx("div",{className:"workbench-skeleton-list",children:Array.from({length:3},(n,r)=>s.jsxs("div",{className:"workbench-skeleton-session",children:[s.jsx("span",{className:"workbench-skeleton-dot"}),s.jsx(Mk,{count:2,className:"workbench-skeleton-lines compact"})]},r))})]},t))})}function So(){return s.jsx("section",{className:"workbench-info-skeleton","aria-hidden":"true",children:Array.from({length:4},(e,t)=>s.jsxs("article",{className:"workbench-info-skeleton-card",children:[s.jsx("span",{className:"skeleton-line short"}),s.jsx(Mk,{count:3})]},t))})}function lA({side:e,collapsed:t}){const n=e==="left"?8.5:15.5,r=e==="left"?t?"12 9 15 12 12 15":"15 9 12 12 15 15":t?"12 9 9 12 12 15":"9 9 12 12 9 15";return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("line",{x1:n,y1:"4",x2:n,y2:"20"}),s.jsx("polyline",{points:r})]})}function Pf({ariaLabel:e,side:t,collapsed:n,className:r="panel-icon-button",onClick:i}){return s.jsx("button",{className:r,type:"button","aria-label":e,title:e,onClick:i,children:s.jsx(lA,{side:t,collapsed:n})})}function fi({expanded:e}){return s.jsx("svg",{className:e?"workbench-chevron":"workbench-chevron collapsed",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 9 12 15 18 9"})})}function cA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function uA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"2"}),s.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),s.jsx("line",{x1:"8",y1:"14",x2:"12",y2:"14"}),s.jsx("circle",{cx:"17.5",cy:"15.5",r:"2.5"})]})}function dA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M7.5 10.2a4.5 4.5 0 1 1 9 0v3.1c0 .8.3 1.6.9 2.2l.8.8H5.8l.8-.8c.6-.6.9-1.4.9-2.2z",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 18.5a2 2 0 0 0 4 0",strokeLinecap:"round"})]})}function Rk(e){return s.jsx("div",{className:"workbench-notification-anchor",children:s.jsxs("button",{type:"button",className:e.collapsed?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":l("shell.globalNotificationsAction"),title:l("shell.globalNotificationsAction"),"aria-expanded":e.open,onClick:e.onToggle,children:[s.jsx(dA,{}),e.unreadCount>0?s.jsx("span",{className:"workbench-notification-badge","aria-label":l("shell.globalNotificationsUnreadAria",{count:String(e.unreadCount)}),children:e.unreadCount>99?"99+":e.unreadCount}):null]})})}function hA(e){const[t,n]=f.useState("notifications");f.useEffect(()=>{e.open&&n("notifications")},[e.open]);const r=f.useMemo(()=>e.notifications.filter(i=>e.showArchivedNotifications||!e.archivedNotificationIds.has(i.id)),[e.archivedNotificationIds,e.notifications,e.showArchivedNotifications]);return s.jsxs(St,{open:e.open,title:l("shell.globalNotificationsPanelTitle"),description:l("shell.globalNotificationsPanelDescription"),className:"workbench-notification-modal-card workspace-inbox-modal-card",showCloseButton:!1,onClose:e.onClose,children:[s.jsxs("div",{className:"workbench-notification-tabs",role:"tablist","aria-label":l("shell.globalNotificationsPanelTitle"),children:[s.jsx("button",{type:"button",className:t==="notifications"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="notifications",onClick:()=>n("notifications"),children:l("shell.globalNotificationsAction")}),s.jsx("button",{type:"button",className:t==="inbox"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="inbox",onClick:()=>n("inbox"),children:l("shell.butlerInboxAction")})]}),s.jsx("div",{className:"workbench-notification-content","data-tab":t,children:t==="notifications"?s.jsxs("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":l("shell.globalNotificationsAction"),children:[s.jsx("div",{className:"workbench-notification-toolbar",children:s.jsxs("label",{className:"workbench-notification-filter",children:[s.jsx("input",{type:"checkbox",checked:e.showArchivedNotifications,onChange:i=>e.onToggleShowArchivedNotifications(i.target.checked)}),s.jsx("span",{children:l("shell.globalNotificationsShowArchived")})]})}),r.length>0?s.jsx("div",{className:"workbench-notification-list",children:r.map(i=>{const a=e.archivedNotificationIds.has(i.id);return s.jsxs("article",{className:"workbench-notification-item","data-archived":a,children:[s.jsxs("button",{type:"button",className:"workbench-notification-item-content",onClick:()=>{e.onSelectNotification(i)},children:[s.jsx("span",{className:"workbench-notification-item-kind",children:yP(i.kind)}),s.jsx("strong",{children:i.title}),s.jsx("p",{children:i.body})]}),s.jsxs("div",{className:"workbench-notification-item-side",children:[s.jsx("time",{children:NP(i.createdAt)}),s.jsx("button",{type:"button",className:"secondary-button workbench-notification-item-action-button",onClick:()=>{if(a){e.onUnarchiveNotification(i.id);return}e.onArchiveNotification(i.id)},children:a?l("shell.globalNotificationsRemoveArchiveAction"):l("shell.globalNotificationsArchiveAction")})]})]},i.id)})}):s.jsx("p",{className:"workbench-notification-empty",children:l("shell.globalNotificationsEmpty")})]}):s.jsx("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":l("shell.butlerInboxAction"),children:s.jsx(Qb,{active:e.open&&t==="inbox",preferredWorkspaceId:e.preferredWorkspaceId,preferredSessionId:e.preferredSessionId})})}),s.jsx("div",{className:"workbench-modal-actions workbench-notification-footer-actions",children:s.jsx("button",{type:"button",className:"secondary-button",onClick:e.onClose,children:l("common.close")})})]})}function pA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function fA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("circle",{cx:"11",cy:"11",r:"7"}),s.jsx("line",{x1:"20",y1:"20",x2:"16.65",y2:"16.65"})]})}function mA(){return s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function gA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("path",{d:"M7 9l3 3-3 3"}),s.jsx("path",{d:"M13 15h4"})]})}function bA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"3"}),s.jsx("circle",{cx:"9",cy:"11",r:"1"}),s.jsx("circle",{cx:"15",cy:"11",r:"1"}),s.jsx("path",{d:"M8 15h8"}),s.jsx("path",{d:"M12 5V3"})]})}function kA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M12 4.5 13.6 8l3.9.4-2.9 2.7.8 3.9L12 13.2 8.6 15l.8-3.9-2.9-2.7L10.4 8 12 4.5Z"}),s.jsx("path",{d:"m18.5 4.5.5 1.3 1.3.5-1.3.5-.5 1.3-.5-1.3-1.3-.5 1.3-.5.5-1.3Z"})]})}function Pk(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),s.jsx("polyline",{points:"14 9 11 12 14 15"})]})}function yA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"18",cy:"6",r:"3"}),s.jsx("circle",{cx:"6",cy:"6",r:"3"}),s.jsx("circle",{cx:"18",cy:"18",r:"3"}),s.jsx("path",{d:"M6 9v6a3 3 0 0 0 3 3h3"}),s.jsx("line",{x1:"18",y1:"9",x2:"18",y2:"15"})]})}function xA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function wA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"5",width:"6",height:"6",rx:"1.5"}),s.jsx("rect",{x:"14",y:"5",width:"6",height:"6",rx:"1.5"}),s.jsx("rect",{x:"4",y:"13",width:"6",height:"6",rx:"1.5"}),s.jsx("path",{d:"M14 16l2 2 4-4"})]})}function vA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"6",width:"10",height:"12",rx:"2"}),s.jsx("path",{d:"M10 12h8"}),s.jsx("path",{d:"M15 8l4 4-4 4"})]})}function SA({selected:e}){return e?s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"}),s.jsx("path",{d:"M8 12.5l2.8 2.8L16.5 9.5"})]}):s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"})})}function Ak({active:e,className:t}){return e?s.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.5",children:s.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})}):s.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:s.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})})}function CA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 7h18"}),s.jsx("path",{d:"M5 7l1 12h12l1-12"}),s.jsx("path",{d:"M9 11h6"}),s.jsx("path",{d:"M8 4h8l1 3H7l1-3z"})]})}function NA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M12 20h9"}),s.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}function jA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M12 4v10"}),s.jsx("path",{d:"M8.5 7.5L12 4l3.5 3.5"}),s.jsx("path",{d:"M5 14v4a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-4"})]})}function TA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M8 6V4h8v2"}),s.jsx("path",{d:"M6 6l1 14h10l1-14"}),s.jsx("path",{d:"M10 11v5"}),s.jsx("path",{d:"M14 11v5"})]})}function IA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M9 13h6"})]})}function EA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M9.7 9.4a2.5 2.5 0 1 1 4.1 2c-.8.7-1.8 1.2-1.8 2.6",strokeLinecap:"round"}),s.jsx("circle",{cx:"12",cy:"17.2",r:"1",fill:"currentColor",stroke:"none"})]})}function MA({open:e,mode:t,keyword:n,codeWorkspaceId:r,codeResults:i,codeLoading:a,codeError:o,workspaceOptions:c,sessionResults:u,onClose:d,onModeChange:h,onKeywordChange:p,onCodeWorkspaceChange:g,onCodeSearch:m,onOpenSession:y}){const S=n.trim().length>0&&r.trim().length>0;return s.jsx(St,{open:e,title:l("shell.searchModalTitle"),description:l("shell.searchModalDescription"),onClose:d,children:s.jsxs("div",{className:"workbench-search-modal",children:[s.jsxs("div",{className:"workbench-search-mode-switch",role:"tablist","aria-label":l("shell.searchModeLabel"),children:[s.jsx("button",{type:"button",className:t==="sessions"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="sessions",onClick:()=>h("sessions"),children:l("shell.searchModeSessions")}),s.jsx("button",{type:"button",className:t==="code"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="code",onClick:()=>h("code"),children:l("shell.searchModeCode")})]}),t==="sessions"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchKeywordLabel")}),s.jsx("input",{type:"text",value:n,placeholder:l("shell.searchSessionPlaceholder"),autoFocus:!0,onChange:j=>p(j.target.value)})]}),s.jsx("div",{className:"workbench-search-results",children:n.trim().length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchSessionHint")}):u.length>0?u.map(j=>{const x=ld(j.session.title,l("common.unknown"));return s.jsxs("button",{type:"button",className:"workbench-search-result-item",onClick:()=>y(j.session.sessionId),children:[s.jsx("span",{className:"workbench-search-result-title",title:x.fullTitle,children:x.displayTitle}),s.jsxs("span",{className:"workbench-search-result-meta",children:[j.workspace.name," · ",fl(j.session.provider,"full")]})]},j.session.sessionId)}):s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchSessionEmpty")})})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchWorkspaceLabel")}),s.jsx("select",{value:r,onChange:j=>g(j.target.value),children:c.map(j=>s.jsx("option",{value:j.id,children:j.name},j.id))})]}),s.jsxs("form",{className:"workbench-search-code-form",onSubmit:j=>{j.preventDefault(),m()},children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchKeywordLabel")}),s.jsx("input",{type:"text",value:n,placeholder:l("shell.searchCodePlaceholder"),autoFocus:!0,onChange:j=>p(j.target.value)})]}),s.jsx("button",{type:"submit",className:"primary-button",disabled:!S||a,children:a?l("common.loading"):l("shell.searchSubmit")})]}),s.jsxs("div",{className:"workbench-search-results",children:[o?s.jsx("p",{className:"status-text","data-tone":"error",children:o}):null,!o&&n.trim().length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeHint")}):null,!o&&n.trim().length>0&&!a&&i.length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeEmpty")}):null,i.map(j=>s.jsxs("div",{className:"workbench-search-result-item static",children:[s.jsx("span",{className:"workbench-search-result-title",children:j.name}),s.jsx("span",{className:"workbench-search-result-meta",children:j.path})]},`${j.path}-${j.kind}`))]})]})]})})}const RA=`
72
72
  html,
73
73
  body {
74
74
  width: 100% !important;