@jetcrab/pi-desk 1.1.28-dev → 1.1.30-dev

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 (362) hide show
  1. package/docs/plugins.md +2 -2
  2. package/package.json +1 -1
  3. package/src/app/api/work-sessions/search/route.ts +1 -0
  4. package/src/app/project-preview/page.tsx +1 -3
  5. package/src/client/l1_entry/pages/l1-error-page.tsx +1 -1
  6. package/src/client/l1_entry/providers/l1-app-providers.tsx +2 -0
  7. package/src/client/l2_biz/auth/l2-login.module.css +1 -1
  8. package/src/client/l2_biz/plugin-host/l2-plugin-composer-panel.tsx +1 -1
  9. package/src/client/l2_biz/plugin-host/l2-plugin-contribution-host.tsx +1 -1
  10. package/src/client/l2_biz/plugin-host/l2-plugin-session-header-layout.ts +6 -3
  11. package/src/client/l2_biz/plugin-host/l2-plugin-session-header.tsx +75 -18
  12. package/src/client/l2_biz/project-preview/hooks/l2-use-project-preview.ts +1 -14
  13. package/src/client/l2_biz/project-preview/l2-project-preview-dialog.tsx +2 -3
  14. package/src/client/l2_biz/project-preview/l2-project-preview-page.tsx +1 -2
  15. package/src/client/l2_biz/project-preview/l2-project-preview.tsx +1 -4
  16. package/src/client/l2_biz/project-preview/views/l2-project-branch-select.tsx +42 -3
  17. package/src/client/l2_biz/settings/l2-settings.tsx +1 -1
  18. package/src/client/l2_biz/settings/l2-skills-settings.tsx +1 -1
  19. package/src/client/l2_biz/task-center/l2-task-center.tsx +1 -1
  20. package/src/client/l2_biz/workbench/file-workspace/l2-plugin-standalone-file-preview.tsx +1 -1
  21. package/src/client/l2_biz/workbench/file-workspace/l2-work-session-file-preview.tsx +1 -1
  22. package/src/client/l2_biz/workbench/git-workspace/l2-git-workspace-runtime.ts +11 -10
  23. package/src/client/l2_biz/workbench/hooks/l2-work-session-search.ts +52 -0
  24. package/src/client/l2_biz/workbench/hooks/l2-workbench-branch-picker.ts +42 -7
  25. package/src/client/l2_biz/workbench/hooks/l2-workbench-session-history.ts +143 -131
  26. package/src/client/l2_biz/workbench/hooks/l2-workbench-session-search.ts +97 -0
  27. package/src/client/l2_biz/workbench/l2-work-session-columns.tsx +8 -0
  28. package/src/client/l2_biz/workbench/l2-work-session-sidebar.tsx +129 -10
  29. package/src/client/l2_biz/workbench/l2-workbench-biz.ts +20 -2
  30. package/src/client/l2_biz/workbench/l2-workbench-branch-filter-preferences.ts +34 -0
  31. package/src/client/l2_biz/workbench/l2-workbench-branch-picker.tsx +34 -71
  32. package/src/client/l2_biz/workbench/l2-workbench-chat-input-runtime.ts +38 -1
  33. package/src/client/l2_biz/workbench/l2-workbench-chat-view.tsx +11 -1
  34. package/src/client/l2_biz/workbench/l2-workbench-picker-dialog.tsx +55 -215
  35. package/src/client/l2_biz/workbench/l2-workbench.tsx +21 -39
  36. package/src/client/l2_biz/workbench/views/l2-workbench-session-search.tsx +123 -0
  37. package/src/client/l3_modules/conversation/l3-conversation-messages.tsx +43 -4
  38. package/src/client/l3_modules/project-files/l3-markdown-preview.module.css +1 -1
  39. package/src/client/l3_modules/project-files/l3-project-document-git.ts +13 -29
  40. package/src/client/l3_modules/project-files/l3-project-document-view.tsx +1 -4
  41. package/src/client/l3_modules/project-files/l3-project-file-browser.module.css +14 -18
  42. package/src/client/l3_modules/project-files/l3-project-file-browser.tsx +52 -95
  43. package/src/client/l3_modules/project-files/l3-project-file-runtime.ts +52 -21
  44. package/src/client/l3_modules/project-files/l3-project-file-tabs.tsx +41 -62
  45. package/src/client/l3_modules/project-files/l3-project-git-runtime.ts +5 -4
  46. package/src/client/l3_modules/project-files/l3-use-project-refresh.ts +36 -0
  47. package/src/client/l3_modules/project-files/views/l3-project-search-results.tsx +2 -2
  48. package/src/client/l3_modules/project-files/views/l3-project-tree-folder.tsx +86 -0
  49. package/src/client/l4_foundation/desktop-window/l4-desktop-titlebar.tsx +188 -0
  50. package/src/client/l4_foundation/desktop-window/l4-desktop-window.css +107 -0
  51. package/src/client/l4_foundation/desktop-window/l4-desktop-window.ts +20 -0
  52. package/src/client/l4_foundation/ui/file-icons/README.md +1 -1
  53. package/src/client/l4_foundation/ui/file-icons/l4-file-icon.tsx +49 -2
  54. package/src/client/l4_foundation/ui/l4-app-dialog.tsx +2 -2
  55. package/src/common/l2_biz/pi-session/l2-pi-session-contract.ts +11 -24
  56. package/src/common/l2_biz/project-preview/l2-project-preview-navigation.ts +5 -12
  57. package/src/common/l2_biz/work-session/l2-work-session-search-contract.ts +26 -0
  58. package/src/common/l2_biz/work-session/l2-work-session-tree-contract.ts +9 -1
  59. package/src/common/l2_biz/workbench/l2-workbench-locale-messages.ts +12 -0
  60. package/src/common/l2_biz/workbench/l2-workbench-picker-messages.ts +6 -2
  61. package/src/common/l3_modules/conversation/l3-conversation-locale-messages.ts +2 -0
  62. package/src/common/l3_modules/pi/l3-pi-session-search-contract.ts +26 -0
  63. package/src/common/l4_foundation/locale/l4-host-error-messages.ts +2 -0
  64. package/src/server/l1_entry/api/l1-work-session-branch-route.ts +21 -15
  65. package/src/server/l1_entry/api/l1-work-session-search-route.ts +38 -0
  66. package/src/server/l2_biz/work-session/l2-work-session-chat-runtime.ts +4 -2
  67. package/src/server/l2_biz/work-session/l2-work-session-manage.ts +46 -10
  68. package/src/server/l3_modules/work-session/l3-work-session.ts +11 -6
  69. package/src/server/l4_foundation/pi/l4-pi-chat-worker.ts +35 -2
  70. package/src/server/l4_foundation/pi/l4-pi-session-history-catalog.ts +62 -113
  71. package/src/server/l4_foundation/pi/l4-pi-session-search.ts +166 -0
  72. package/src/server/l4_foundation/pi/l4-pi-work-session-runtime.ts +66 -5
  73. package/temp/build/pi-desk/release/.next/BUILD_ID +1 -1
  74. package/temp/build/pi-desk/release/.next/app-path-routes-manifest.json +1 -0
  75. package/temp/build/pi-desk/release/.next/build-manifest.json +3 -3
  76. package/temp/build/pi-desk/release/.next/required-server-files.js +2 -2
  77. package/temp/build/pi-desk/release/.next/required-server-files.json +2 -2
  78. package/temp/build/pi-desk/release/.next/routes-manifest.json +6 -0
  79. package/temp/build/pi-desk/release/.next/server/app/_global-error/page.js +2 -2
  80. package/temp/build/pi-desk/release/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  81. package/temp/build/pi-desk/release/.next/server/app/_global-error.html +1 -1
  82. package/temp/build/pi-desk/release/.next/server/app/_global-error.rsc +3 -3
  83. package/temp/build/pi-desk/release/.next/server/app/_global-error.segments/_full.segment.rsc +3 -3
  84. package/temp/build/pi-desk/release/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +3 -3
  85. package/temp/build/pi-desk/release/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  86. package/temp/build/pi-desk/release/.next/server/app/_not-found/page.js +1 -1
  87. package/temp/build/pi-desk/release/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  88. package/temp/build/pi-desk/release/.next/server/app/api/auth/login/route.js +2 -2
  89. package/temp/build/pi-desk/release/.next/server/app/api/auth/logout/route.js +1 -1
  90. package/temp/build/pi-desk/release/.next/server/app/api/auth-settings/get/route.js +1 -1
  91. package/temp/build/pi-desk/release/.next/server/app/api/auth-settings/replace/route.js +1 -1
  92. package/temp/build/pi-desk/release/.next/server/app/api/capability-modes/get/route.js +1 -1
  93. package/temp/build/pi-desk/release/.next/server/app/api/capability-modes/replace/route.js +1 -1
  94. package/temp/build/pi-desk/release/.next/server/app/api/chat/context/get/route.js +1 -1
  95. package/temp/build/pi-desk/release/.next/server/app/api/chat/images/get/route.js +1 -1
  96. package/temp/build/pi-desk/release/.next/server/app/api/chat/messages/get/route.js +1 -1
  97. package/temp/build/pi-desk/release/.next/server/app/api/health/route.js +1 -1
  98. package/temp/build/pi-desk/release/.next/server/app/api/mcp-check/get/route.js +1 -1
  99. package/temp/build/pi-desk/release/.next/server/app/api/mcp-settings/del/route.js +1 -1
  100. package/temp/build/pi-desk/release/.next/server/app/api/mcp-settings/get/route.js +1 -1
  101. package/temp/build/pi-desk/release/.next/server/app/api/mcp-settings/replace/route.js +1 -1
  102. package/temp/build/pi-desk/release/.next/server/app/api/model-catalog/list/route.js +1 -1
  103. package/temp/build/pi-desk/release/.next/server/app/api/model-settings/get/route.js +1 -1
  104. package/temp/build/pi-desk/release/.next/server/app/api/model-settings/preview/route.js +1 -1
  105. package/temp/build/pi-desk/release/.next/server/app/api/model-settings/replace/route.js +1 -1
  106. package/temp/build/pi-desk/release/.next/server/app/api/pi/directories/list/route.js +1 -1
  107. package/temp/build/pi-desk/release/.next/server/app/api/pi/directory-entries/list/route.js +1 -1
  108. package/temp/build/pi-desk/release/.next/server/app/api/pi/directory-ignores/list/route.js +1 -1
  109. package/temp/build/pi-desk/release/.next/server/app/api/pi/directory-ignores/replace/route.js +1 -1
  110. package/temp/build/pi-desk/release/.next/server/app/api/pi/models/list/route.js +1 -1
  111. package/temp/build/pi-desk/release/.next/server/app/api/pi/session-user-messages/list/route.js +1 -1
  112. package/temp/build/pi-desk/release/.next/server/app/api/pi/sessions/list/route.js +1 -1
  113. package/temp/build/pi-desk/release/.next/server/app/api/plugin-catalog/get/route.js +1 -1
  114. package/temp/build/pi-desk/release/.next/server/app/api/plugin-catalog/search/route.js +1 -1
  115. package/temp/build/pi-desk/release/.next/server/app/api/plugin-catalog/settings-get/route.js +1 -1
  116. package/temp/build/pi-desk/release/.next/server/app/api/plugin-catalog/settings-replace/route.js +1 -1
  117. package/temp/build/pi-desk/release/.next/server/app/api/plugins/add/route.js +1 -1
  118. package/temp/build/pi-desk/release/.next/server/app/api/plugins/apply/route.js +1 -1
  119. package/temp/build/pi-desk/release/.next/server/app/api/plugins/batch/route.js +1 -1
  120. package/temp/build/pi-desk/release/.next/server/app/api/plugins/browser-resources/[resourceGroup]/[...resourcePath]/route.js +1 -1
  121. package/temp/build/pi-desk/release/.next/server/app/api/plugins/del/route.js +1 -1
  122. package/temp/build/pi-desk/release/.next/server/app/api/plugins/enabled-set/route.js +1 -1
  123. package/temp/build/pi-desk/release/.next/server/app/api/plugins/get/route.js +1 -1
  124. package/temp/build/pi-desk/release/.next/server/app/api/plugins/host-runtime/[runtimeVersion]/[...resourcePath]/route.js +1 -1
  125. package/temp/build/pi-desk/release/.next/server/app/api/plugins/list/route.js +1 -1
  126. package/temp/build/pi-desk/release/.next/server/app/api/plugins/reload/route.js +1 -1
  127. package/temp/build/pi-desk/release/.next/server/app/api/plugins/update/route.js +1 -1
  128. package/temp/build/pi-desk/release/.next/server/app/api/project-files/get/route.js +2 -2
  129. package/temp/build/pi-desk/release/.next/server/app/api/project-files/list/route.js +1 -1
  130. package/temp/build/pi-desk/release/.next/server/app/api/project-files/reveal/route.js +1 -1
  131. package/temp/build/pi-desk/release/.next/server/app/api/project-files/search/route.js +1 -1
  132. package/temp/build/pi-desk/release/.next/server/app/api/project-git/get/route.js +2 -2
  133. package/temp/build/pi-desk/release/.next/server/app/api/project-git-branches/list/route.js +2 -2
  134. package/temp/build/pi-desk/release/.next/server/app/api/project-git-changes/list/route.js +1 -1
  135. package/temp/build/pi-desk/release/.next/server/app/api/project-git-diff/get/route.js +2 -2
  136. package/temp/build/pi-desk/release/.next/server/app/api/project-git-heads/get/route.js +1 -1
  137. package/temp/build/pi-desk/release/.next/server/app/api/project-git-log/list/route.js +2 -2
  138. package/temp/build/pi-desk/release/.next/server/app/api/project-model-default/get/route.js +1 -1
  139. package/temp/build/pi-desk/release/.next/server/app/api/project-model-default/replace/route.js +1 -1
  140. package/temp/build/pi-desk/release/.next/server/app/api/skill-files/get/route.js +1 -1
  141. package/temp/build/pi-desk/release/.next/server/app/api/skill-files/list/route.js +1 -1
  142. package/temp/build/pi-desk/release/.next/server/app/api/skill-files/replace/route.js +1 -1
  143. package/temp/build/pi-desk/release/.next/server/app/api/skills/list/route.js +1 -1
  144. package/temp/build/pi-desk/release/.next/server/app/api/task-center/images/get/route.js +1 -1
  145. package/temp/build/pi-desk/release/.next/server/app/api/task-center/messages/get/route.js +1 -1
  146. package/temp/build/pi-desk/release/.next/server/app/api/work-session-git-branch/add/route.js +1 -1
  147. package/temp/build/pi-desk/release/.next/server/app/api/work-session-git-branch/replace/route.js +1 -1
  148. package/temp/build/pi-desk/release/.next/server/app/api/work-session-tree/get/route.js +1 -1
  149. package/temp/build/pi-desk/release/.next/server/app/api/work-session-tree-entry/get/route.js +1 -1
  150. package/temp/build/pi-desk/release/.next/server/app/api/work-sessions/add/route.js +1 -1
  151. package/temp/build/pi-desk/release/.next/server/app/api/work-sessions/branch/route.js +1 -1
  152. package/temp/build/pi-desk/release/.next/server/app/api/work-sessions/del/route.js +1 -1
  153. package/temp/build/pi-desk/release/.next/server/app/api/work-sessions/rename/route.js +1 -1
  154. package/temp/build/pi-desk/release/.next/server/app/api/work-sessions/replace/route.js +1 -1
  155. package/temp/build/pi-desk/release/.next/server/app/api/work-sessions/search/route.js +1 -0
  156. package/temp/build/pi-desk/release/.next/server/app/api/work-sessions/search/route_client-reference-manifest.js +1 -0
  157. package/temp/build/pi-desk/release/.next/server/app/api/work-sessions/sort/route.js +1 -1
  158. package/temp/build/pi-desk/release/.next/server/app/favicon.ico/route.js +1 -1
  159. package/temp/build/pi-desk/release/.next/server/app/login/page.js +1 -1
  160. package/temp/build/pi-desk/release/.next/server/app/login/page_client-reference-manifest.js +1 -1
  161. package/temp/build/pi-desk/release/.next/server/app/page.js +138 -138
  162. package/temp/build/pi-desk/release/.next/server/app/page_client-reference-manifest.js +1 -1
  163. package/temp/build/pi-desk/release/.next/server/app/project-preview/page.js +1 -1
  164. package/temp/build/pi-desk/release/.next/server/app/project-preview/page_client-reference-manifest.js +1 -1
  165. package/temp/build/pi-desk/release/.next/server/app-paths-manifest.json +1 -0
  166. package/temp/build/pi-desk/release/.next/server/chunks/23054.js +2 -2
  167. package/temp/build/pi-desk/release/.next/server/chunks/25406.js +8 -8
  168. package/temp/build/pi-desk/release/.next/server/chunks/27344.js +3 -3
  169. package/temp/build/pi-desk/release/.next/server/chunks/3108.js +3 -3
  170. package/temp/build/pi-desk/release/.next/server/chunks/35985.js +3 -3
  171. package/temp/build/pi-desk/release/.next/server/chunks/41856.js +1 -0
  172. package/temp/build/pi-desk/release/.next/server/chunks/62900.js +235 -0
  173. package/temp/build/pi-desk/release/.next/server/chunks/6917.js +1 -1
  174. package/temp/build/pi-desk/release/.next/server/chunks/81363.js +1 -1
  175. package/temp/build/pi-desk/release/.next/server/chunks/81912.js +3 -0
  176. package/temp/build/pi-desk/release/.next/server/chunks/92386.js +2 -2
  177. package/temp/build/pi-desk/release/.next/server/middleware-build-manifest.js +1 -1
  178. package/temp/build/pi-desk/release/.next/server/pages/500.html +1 -1
  179. package/temp/build/pi-desk/release/.next/static/ErYBfYXAir5b-6rlacGvL/_buildManifest.js +1 -0
  180. package/temp/build/pi-desk/release/.next/static/chunks/10043-9d6c3735418ccaf9.js +238 -0
  181. package/temp/build/pi-desk/release/.next/static/chunks/11937-ac71fb0f7cef482a.js +1 -0
  182. package/temp/build/pi-desk/release/.next/static/chunks/30669-ffa76d39e0e25194.js +1 -0
  183. package/temp/build/pi-desk/release/.next/static/chunks/36643-f60e98278740073c.js +3 -0
  184. package/temp/build/pi-desk/release/.next/static/chunks/65232-f5b71cec787a30ec.js +15 -0
  185. package/temp/build/pi-desk/release/.next/static/chunks/{51474-8dc714cb76b2e60a.js → 65350-23bb961d87addf14.js} +3 -3
  186. package/temp/build/pi-desk/release/.next/static/chunks/app/_global-error/page-295cb63da5f7262f.js +1 -0
  187. package/temp/build/pi-desk/release/.next/static/chunks/app/_not-found/page-295cb63da5f7262f.js +1 -0
  188. package/temp/build/pi-desk/release/.next/static/chunks/app/api/auth/login/route-295cb63da5f7262f.js +1 -0
  189. package/temp/build/pi-desk/release/.next/static/chunks/app/api/auth/logout/route-295cb63da5f7262f.js +1 -0
  190. package/temp/build/pi-desk/release/.next/static/chunks/app/api/auth-settings/get/route-295cb63da5f7262f.js +1 -0
  191. package/temp/build/pi-desk/release/.next/static/chunks/app/api/auth-settings/replace/route-295cb63da5f7262f.js +1 -0
  192. package/temp/build/pi-desk/release/.next/static/chunks/app/api/capability-modes/get/route-295cb63da5f7262f.js +1 -0
  193. package/temp/build/pi-desk/release/.next/static/chunks/app/api/capability-modes/replace/route-295cb63da5f7262f.js +1 -0
  194. package/temp/build/pi-desk/release/.next/static/chunks/app/api/chat/context/get/route-295cb63da5f7262f.js +1 -0
  195. package/temp/build/pi-desk/release/.next/static/chunks/app/api/chat/images/get/route-295cb63da5f7262f.js +1 -0
  196. package/temp/build/pi-desk/release/.next/static/chunks/app/api/chat/messages/get/route-295cb63da5f7262f.js +1 -0
  197. package/temp/build/pi-desk/release/.next/static/chunks/app/api/health/route-295cb63da5f7262f.js +1 -0
  198. package/temp/build/pi-desk/release/.next/static/chunks/app/api/mcp-check/get/route-295cb63da5f7262f.js +1 -0
  199. package/temp/build/pi-desk/release/.next/static/chunks/app/api/mcp-settings/del/route-295cb63da5f7262f.js +1 -0
  200. package/temp/build/pi-desk/release/.next/static/chunks/app/api/mcp-settings/get/route-295cb63da5f7262f.js +1 -0
  201. package/temp/build/pi-desk/release/.next/static/chunks/app/api/mcp-settings/replace/route-295cb63da5f7262f.js +1 -0
  202. package/temp/build/pi-desk/release/.next/static/chunks/app/api/model-catalog/list/route-295cb63da5f7262f.js +1 -0
  203. package/temp/build/pi-desk/release/.next/static/chunks/app/api/model-settings/get/route-295cb63da5f7262f.js +1 -0
  204. package/temp/build/pi-desk/release/.next/static/chunks/app/api/model-settings/preview/route-295cb63da5f7262f.js +1 -0
  205. package/temp/build/pi-desk/release/.next/static/chunks/app/api/model-settings/replace/route-295cb63da5f7262f.js +1 -0
  206. package/temp/build/pi-desk/release/.next/static/chunks/app/api/pi/directories/list/route-295cb63da5f7262f.js +1 -0
  207. package/temp/build/pi-desk/release/.next/static/chunks/app/api/pi/directory-entries/list/route-295cb63da5f7262f.js +1 -0
  208. package/temp/build/pi-desk/release/.next/static/chunks/app/api/pi/directory-ignores/list/route-295cb63da5f7262f.js +1 -0
  209. package/temp/build/pi-desk/release/.next/static/chunks/app/api/pi/directory-ignores/replace/route-295cb63da5f7262f.js +1 -0
  210. package/temp/build/pi-desk/release/.next/static/chunks/app/api/pi/models/list/route-295cb63da5f7262f.js +1 -0
  211. package/temp/build/pi-desk/release/.next/static/chunks/app/api/pi/session-user-messages/list/route-295cb63da5f7262f.js +1 -0
  212. package/temp/build/pi-desk/release/.next/static/chunks/app/api/pi/sessions/list/route-295cb63da5f7262f.js +1 -0
  213. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugin-catalog/get/route-295cb63da5f7262f.js +1 -0
  214. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugin-catalog/search/route-295cb63da5f7262f.js +1 -0
  215. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugin-catalog/settings-get/route-295cb63da5f7262f.js +1 -0
  216. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugin-catalog/settings-replace/route-295cb63da5f7262f.js +1 -0
  217. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/add/route-295cb63da5f7262f.js +1 -0
  218. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/apply/route-295cb63da5f7262f.js +1 -0
  219. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/batch/route-295cb63da5f7262f.js +1 -0
  220. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/browser-resources/[resourceGroup]/[...resourcePath]/route-295cb63da5f7262f.js +1 -0
  221. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/del/route-295cb63da5f7262f.js +1 -0
  222. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/enabled-set/route-295cb63da5f7262f.js +1 -0
  223. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/get/route-295cb63da5f7262f.js +1 -0
  224. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/host-runtime/[runtimeVersion]/[...resourcePath]/route-295cb63da5f7262f.js +1 -0
  225. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/list/route-295cb63da5f7262f.js +1 -0
  226. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/reload/route-295cb63da5f7262f.js +1 -0
  227. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/update/route-295cb63da5f7262f.js +1 -0
  228. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-files/get/route-295cb63da5f7262f.js +1 -0
  229. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-files/list/route-295cb63da5f7262f.js +1 -0
  230. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-files/reveal/route-295cb63da5f7262f.js +1 -0
  231. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-files/search/route-295cb63da5f7262f.js +1 -0
  232. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-git/get/route-295cb63da5f7262f.js +1 -0
  233. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-git-branches/list/route-295cb63da5f7262f.js +1 -0
  234. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-git-changes/list/route-295cb63da5f7262f.js +1 -0
  235. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-git-diff/get/route-295cb63da5f7262f.js +1 -0
  236. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-git-heads/get/route-295cb63da5f7262f.js +1 -0
  237. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-git-log/list/route-295cb63da5f7262f.js +1 -0
  238. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-model-default/get/route-295cb63da5f7262f.js +1 -0
  239. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-model-default/replace/route-295cb63da5f7262f.js +1 -0
  240. package/temp/build/pi-desk/release/.next/static/chunks/app/api/skill-files/get/route-295cb63da5f7262f.js +1 -0
  241. package/temp/build/pi-desk/release/.next/static/chunks/app/api/skill-files/list/route-295cb63da5f7262f.js +1 -0
  242. package/temp/build/pi-desk/release/.next/static/chunks/app/api/skill-files/replace/route-295cb63da5f7262f.js +1 -0
  243. package/temp/build/pi-desk/release/.next/static/chunks/app/api/skills/list/route-295cb63da5f7262f.js +1 -0
  244. package/temp/build/pi-desk/release/.next/static/chunks/app/api/task-center/images/get/route-295cb63da5f7262f.js +1 -0
  245. package/temp/build/pi-desk/release/.next/static/chunks/app/api/task-center/messages/get/route-295cb63da5f7262f.js +1 -0
  246. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-session-git-branch/add/route-295cb63da5f7262f.js +1 -0
  247. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-session-git-branch/replace/route-295cb63da5f7262f.js +1 -0
  248. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-session-tree/get/route-295cb63da5f7262f.js +1 -0
  249. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-session-tree-entry/get/route-295cb63da5f7262f.js +1 -0
  250. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-sessions/add/route-295cb63da5f7262f.js +1 -0
  251. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-sessions/branch/route-295cb63da5f7262f.js +1 -0
  252. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-sessions/del/route-295cb63da5f7262f.js +1 -0
  253. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-sessions/rename/route-295cb63da5f7262f.js +1 -0
  254. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-sessions/replace/route-295cb63da5f7262f.js +1 -0
  255. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-sessions/search/route-295cb63da5f7262f.js +1 -0
  256. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-sessions/sort/route-295cb63da5f7262f.js +1 -0
  257. package/temp/build/pi-desk/release/.next/static/chunks/app/error-1ab62762c5f4144f.js +1 -0
  258. package/temp/build/pi-desk/release/.next/static/chunks/app/layout-ca5ef5994165eb2e.js +1 -0
  259. package/temp/build/pi-desk/release/.next/static/chunks/app/login/{page-0d3d4827802108e5.js → page-0df9df996aa68060.js} +1 -1
  260. package/temp/build/pi-desk/release/.next/static/chunks/app/not-found-b8b9b7ef5ccb7601.js +1 -0
  261. package/temp/build/pi-desk/release/.next/static/chunks/app/page-978906de76a8dcfe.js +158 -0
  262. package/temp/build/pi-desk/release/.next/static/chunks/app/project-preview/{page-038b6c14e03ed878.js → page-aaa845016a934245.js} +1 -1
  263. package/temp/build/pi-desk/release/.next/static/chunks/next/dist/client/components/builtin/app-error-295cb63da5f7262f.js +1 -0
  264. package/temp/build/pi-desk/release/.next/static/chunks/next/dist/client/components/builtin/forbidden-295cb63da5f7262f.js +1 -0
  265. package/temp/build/pi-desk/release/.next/static/chunks/next/dist/client/components/builtin/unauthorized-295cb63da5f7262f.js +1 -0
  266. package/temp/build/pi-desk/release/.next/static/chunks/{webpack-c0b805df46fcf8b3.js → webpack-a84310d111797bef.js} +1 -1
  267. package/temp/build/pi-desk/release/.next/static/css/053a8d82c09326cd.css +1 -0
  268. package/temp/build/pi-desk/release/.next/static/css/1cc92eec583aa639.css +1 -0
  269. package/temp/build/pi-desk/release/.next/static/css/{1e780a4936aa6ba3.css → 2bb393927ba8f71d.css} +1 -1
  270. package/temp/build/pi-desk/release/.next/static/css/3a07dcc86ffdf88c.css +1 -0
  271. package/temp/build/pi-desk/release/.next/static/css/3c59ac068ae404da.css +1 -0
  272. package/temp/build/pi-desk/release/.next/trace-build +1 -1
  273. package/temp/build/pi-desk/release/.next/server/chunks/35348.js +0 -3
  274. package/temp/build/pi-desk/release/.next/server/chunks/56830.js +0 -235
  275. package/temp/build/pi-desk/release/.next/server/chunks/80780.js +0 -1
  276. package/temp/build/pi-desk/release/.next/static/bj2dB_Z10YB_CqK_VNhDx/_buildManifest.js +0 -1
  277. package/temp/build/pi-desk/release/.next/static/chunks/11937-1d0a9822f2c7995b.js +0 -1
  278. package/temp/build/pi-desk/release/.next/static/chunks/14197-3d3ddd426ac06c9c.js +0 -3
  279. package/temp/build/pi-desk/release/.next/static/chunks/37313-d5970e2d0c270d22.js +0 -238
  280. package/temp/build/pi-desk/release/.next/static/chunks/65232-ef4e5a4174f62faf.js +0 -15
  281. package/temp/build/pi-desk/release/.next/static/chunks/79267-7d21d7cdbd7cfca1.js +0 -1
  282. package/temp/build/pi-desk/release/.next/static/chunks/app/_global-error/page-9969fe0baa238786.js +0 -1
  283. package/temp/build/pi-desk/release/.next/static/chunks/app/_not-found/page-9969fe0baa238786.js +0 -1
  284. package/temp/build/pi-desk/release/.next/static/chunks/app/api/auth/login/route-9969fe0baa238786.js +0 -1
  285. package/temp/build/pi-desk/release/.next/static/chunks/app/api/auth/logout/route-9969fe0baa238786.js +0 -1
  286. package/temp/build/pi-desk/release/.next/static/chunks/app/api/auth-settings/get/route-9969fe0baa238786.js +0 -1
  287. package/temp/build/pi-desk/release/.next/static/chunks/app/api/auth-settings/replace/route-9969fe0baa238786.js +0 -1
  288. package/temp/build/pi-desk/release/.next/static/chunks/app/api/capability-modes/get/route-9969fe0baa238786.js +0 -1
  289. package/temp/build/pi-desk/release/.next/static/chunks/app/api/capability-modes/replace/route-9969fe0baa238786.js +0 -1
  290. package/temp/build/pi-desk/release/.next/static/chunks/app/api/chat/context/get/route-9969fe0baa238786.js +0 -1
  291. package/temp/build/pi-desk/release/.next/static/chunks/app/api/chat/images/get/route-9969fe0baa238786.js +0 -1
  292. package/temp/build/pi-desk/release/.next/static/chunks/app/api/chat/messages/get/route-9969fe0baa238786.js +0 -1
  293. package/temp/build/pi-desk/release/.next/static/chunks/app/api/health/route-9969fe0baa238786.js +0 -1
  294. package/temp/build/pi-desk/release/.next/static/chunks/app/api/mcp-check/get/route-9969fe0baa238786.js +0 -1
  295. package/temp/build/pi-desk/release/.next/static/chunks/app/api/mcp-settings/del/route-9969fe0baa238786.js +0 -1
  296. package/temp/build/pi-desk/release/.next/static/chunks/app/api/mcp-settings/get/route-9969fe0baa238786.js +0 -1
  297. package/temp/build/pi-desk/release/.next/static/chunks/app/api/mcp-settings/replace/route-9969fe0baa238786.js +0 -1
  298. package/temp/build/pi-desk/release/.next/static/chunks/app/api/model-catalog/list/route-9969fe0baa238786.js +0 -1
  299. package/temp/build/pi-desk/release/.next/static/chunks/app/api/model-settings/get/route-9969fe0baa238786.js +0 -1
  300. package/temp/build/pi-desk/release/.next/static/chunks/app/api/model-settings/preview/route-9969fe0baa238786.js +0 -1
  301. package/temp/build/pi-desk/release/.next/static/chunks/app/api/model-settings/replace/route-9969fe0baa238786.js +0 -1
  302. package/temp/build/pi-desk/release/.next/static/chunks/app/api/pi/directories/list/route-9969fe0baa238786.js +0 -1
  303. package/temp/build/pi-desk/release/.next/static/chunks/app/api/pi/directory-entries/list/route-9969fe0baa238786.js +0 -1
  304. package/temp/build/pi-desk/release/.next/static/chunks/app/api/pi/directory-ignores/list/route-9969fe0baa238786.js +0 -1
  305. package/temp/build/pi-desk/release/.next/static/chunks/app/api/pi/directory-ignores/replace/route-9969fe0baa238786.js +0 -1
  306. package/temp/build/pi-desk/release/.next/static/chunks/app/api/pi/models/list/route-9969fe0baa238786.js +0 -1
  307. package/temp/build/pi-desk/release/.next/static/chunks/app/api/pi/session-user-messages/list/route-9969fe0baa238786.js +0 -1
  308. package/temp/build/pi-desk/release/.next/static/chunks/app/api/pi/sessions/list/route-9969fe0baa238786.js +0 -1
  309. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugin-catalog/get/route-9969fe0baa238786.js +0 -1
  310. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugin-catalog/search/route-9969fe0baa238786.js +0 -1
  311. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugin-catalog/settings-get/route-9969fe0baa238786.js +0 -1
  312. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugin-catalog/settings-replace/route-9969fe0baa238786.js +0 -1
  313. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/add/route-9969fe0baa238786.js +0 -1
  314. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/apply/route-9969fe0baa238786.js +0 -1
  315. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/batch/route-9969fe0baa238786.js +0 -1
  316. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/browser-resources/[resourceGroup]/[...resourcePath]/route-9969fe0baa238786.js +0 -1
  317. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/del/route-9969fe0baa238786.js +0 -1
  318. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/enabled-set/route-9969fe0baa238786.js +0 -1
  319. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/get/route-9969fe0baa238786.js +0 -1
  320. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/host-runtime/[runtimeVersion]/[...resourcePath]/route-9969fe0baa238786.js +0 -1
  321. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/list/route-9969fe0baa238786.js +0 -1
  322. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/reload/route-9969fe0baa238786.js +0 -1
  323. package/temp/build/pi-desk/release/.next/static/chunks/app/api/plugins/update/route-9969fe0baa238786.js +0 -1
  324. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-files/get/route-9969fe0baa238786.js +0 -1
  325. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-files/list/route-9969fe0baa238786.js +0 -1
  326. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-files/reveal/route-9969fe0baa238786.js +0 -1
  327. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-files/search/route-9969fe0baa238786.js +0 -1
  328. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-git/get/route-9969fe0baa238786.js +0 -1
  329. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-git-branches/list/route-9969fe0baa238786.js +0 -1
  330. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-git-changes/list/route-9969fe0baa238786.js +0 -1
  331. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-git-diff/get/route-9969fe0baa238786.js +0 -1
  332. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-git-heads/get/route-9969fe0baa238786.js +0 -1
  333. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-git-log/list/route-9969fe0baa238786.js +0 -1
  334. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-model-default/get/route-9969fe0baa238786.js +0 -1
  335. package/temp/build/pi-desk/release/.next/static/chunks/app/api/project-model-default/replace/route-9969fe0baa238786.js +0 -1
  336. package/temp/build/pi-desk/release/.next/static/chunks/app/api/skill-files/get/route-9969fe0baa238786.js +0 -1
  337. package/temp/build/pi-desk/release/.next/static/chunks/app/api/skill-files/list/route-9969fe0baa238786.js +0 -1
  338. package/temp/build/pi-desk/release/.next/static/chunks/app/api/skill-files/replace/route-9969fe0baa238786.js +0 -1
  339. package/temp/build/pi-desk/release/.next/static/chunks/app/api/skills/list/route-9969fe0baa238786.js +0 -1
  340. package/temp/build/pi-desk/release/.next/static/chunks/app/api/task-center/images/get/route-9969fe0baa238786.js +0 -1
  341. package/temp/build/pi-desk/release/.next/static/chunks/app/api/task-center/messages/get/route-9969fe0baa238786.js +0 -1
  342. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-session-git-branch/add/route-9969fe0baa238786.js +0 -1
  343. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-session-git-branch/replace/route-9969fe0baa238786.js +0 -1
  344. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-session-tree/get/route-9969fe0baa238786.js +0 -1
  345. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-session-tree-entry/get/route-9969fe0baa238786.js +0 -1
  346. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-sessions/add/route-9969fe0baa238786.js +0 -1
  347. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-sessions/branch/route-9969fe0baa238786.js +0 -1
  348. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-sessions/del/route-9969fe0baa238786.js +0 -1
  349. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-sessions/rename/route-9969fe0baa238786.js +0 -1
  350. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-sessions/replace/route-9969fe0baa238786.js +0 -1
  351. package/temp/build/pi-desk/release/.next/static/chunks/app/api/work-sessions/sort/route-9969fe0baa238786.js +0 -1
  352. package/temp/build/pi-desk/release/.next/static/chunks/app/error-216b14b5da089ed3.js +0 -1
  353. package/temp/build/pi-desk/release/.next/static/chunks/app/layout-20718f1503910291.js +0 -1
  354. package/temp/build/pi-desk/release/.next/static/chunks/app/not-found-720cdf6a606b821a.js +0 -1
  355. package/temp/build/pi-desk/release/.next/static/chunks/app/page-ce2ebf7d8ea7a330.js +0 -158
  356. package/temp/build/pi-desk/release/.next/static/chunks/next/dist/client/components/builtin/app-error-9969fe0baa238786.js +0 -1
  357. package/temp/build/pi-desk/release/.next/static/chunks/next/dist/client/components/builtin/forbidden-9969fe0baa238786.js +0 -1
  358. package/temp/build/pi-desk/release/.next/static/chunks/next/dist/client/components/builtin/unauthorized-9969fe0baa238786.js +0 -1
  359. package/temp/build/pi-desk/release/.next/static/css/2bdcf40eca12b794.css +0 -1
  360. package/temp/build/pi-desk/release/.next/static/css/2c3b0c0ff1f49c68.css +0 -1
  361. package/temp/build/pi-desk/release/.next/static/css/c43b04c244a64fb4.css +0 -1
  362. /package/temp/build/pi-desk/release/.next/static/{bj2dB_Z10YB_CqK_VNhDx → ErYBfYXAir5b-6rlacGvL}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- exports.id=27344,exports.ids=[27344],exports.modules={1222:(a,b,c)=>{"use strict";c.d(b,{Ms:()=>u,N1:()=>t,Sb:()=>w,tQ:()=>v});var d=c(87883),e=c(51949),f=c(98722);let g="pi-super:project-preview:global",h="pi-super:project-preview:projects",i=d.ai().min(5).max(95),j=d.Ik({maximized:d.zM(),directoryOpen:d.zM(),gitOpen:d.zM(),gitMaximized:d.zM(),treeLayout:d.k5(["directory","repository"]),directorySize:i,gitSize:i,logSize:i,changeSize:i}),k={maximized:!1,directoryOpen:!0,gitOpen:!1,gitMaximized:!1,treeLayout:"directory",directorySize:22,gitSize:45,logSize:62,changeSize:70},l=d.Ik({repositoryRoot:d.Yj().nullable(),mode:d.k5(["history","compare"]),tip:d.Yj(),base:d.Yj(),target:d.Yj(),strategy:d.k5(["merge-base","direct"]),query:d.Yj().max(200),author:d.Yj().max(200),selectedCommit:f.aD.nullable(),selectedChangePath:e._g.nullable(),logScroll:d.ai().nonnegative(),changesScroll:d.ai().nonnegative()}),m=d.Ie(a=>"object"==typeof a&&null!==a&&Array.isArray(a.cursorState)&&"object"==typeof a.viewState),n=d.Ik({repositoryRoot:d.Yj(),path:e._g,comparison:f.xv.optional()}),o=d.Ik({page:d.k5(["files","code","git"]),historyPane:d.k5(["log","files"]),tabs:d.YO(e._g).max(20),activePath:e._g.nullable(),editorStates:d.g1(e._g,m),fileViewModes:d.g1(e._g,d.k5(["source","preview"])),expandedPaths:d.YO(d.Yj()).max(500),treeScrollTop:d.ai().nonnegative(),searchQuery:d.Yj().max(200),changesOnly:d.zM(),expandedRepositories:d.YO(d.Yj()).max(100),history:l,diffs:d.YO(n).max(20).optional(),activeDiff:n.nullable()}),p=d.Ik({cwd:d.Yj(),lastOpenedAt:d.ai(),state:o});function q(a){let b=a.replaceAll("\\","/").replace(/\/+$/,"");return/^[a-z]:\//i.test(b)||b.startsWith("//")?b.toLowerCase():b}function r(){try{let a=JSON.parse(window.localStorage.getItem(h)??"[]");if(!Array.isArray(a))return[];let b=Date.now();return a.flatMap(a=>{let c=p.safeParse(a);return c.success&&b-c.data.lastOpenedAt<2592e6?[c.data]:[]})}catch{return[]}}function s(a){try{window.localStorage.setItem(h,JSON.stringify(a.sort((a,b)=>b.lastOpenedAt-a.lastOpenedAt).slice(0,50)))}catch(a){console.warn("[Pi Desk][ProjectPreview] 保存项目浏览状态失败",a)}}function t(){try{let a=JSON.parse(window.localStorage.getItem(g)??"null");return{...k,...j.partial().parse(a)}}catch{return{...k}}}function u(a){try{window.localStorage.setItem(g,JSON.stringify(a))}catch(a){console.warn("[Pi Desk][ProjectPreview] 保存全局布局失败",a)}}function v(a){let b=q(a),c=r(),d=c.find(a=>a.cwd===b);return d&&(d.lastOpenedAt=Date.now()),s(c),d?.state??null}function w(a,b){let c=o.safeParse(b);if(!c.success)return;let d=q(a),e=r(),f=e.find(a=>a.cwd===d);f?f.state=c.data:e.push({cwd:d,lastOpenedAt:Date.now(),state:c.data}),s(e)}},4935:a=>{a.exports={markdown:"l4-markdown_markdown__oIf6d",status:"l4-markdown_status__EVcKw",alert:"l4-markdown_alert__Aooao",alertTitle:"l4-markdown_alertTitle__GIoFs",alertBody:"l4-markdown_alertBody__BtDVT"}},5701:(a,b,c)=>{"use strict";c.d(b,{V:()=>l});var d=c(52834);c(49147);var e=c(58029),f=c(82260),g=c(13943),h=c(15620),i=c(39395),j=c(54239);function k({className:a,orientation:b="vertical",...c}){return(0,d.jsx)(i.V,{"data-slot":"scroll-area-scrollbar","data-orientation":b,orientation:b,className:(0,h.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",a),...c,children:(0,d.jsx)(j.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}function l({className:a,viewportClassName:b,viewportRef:c,onViewportScroll:i,children:j,...m}){return(0,d.jsxs)(e.V,{"data-slot":"l4-scroll-area",className:(0,h.cn)("relative min-h-0 overflow-hidden",a),...m,children:[(0,d.jsx)(f.B,{ref:c,"data-slot":"l4-scroll-area-viewport",className:(0,h.cn)("size-full rounded-[inherit] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",b),onScroll:i,children:j}),(0,d.jsx)(k,{className:"data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent"}),(0,d.jsx)(g.I,{})]})}},6995:a=>{a.exports={document:"l3-markdown-preview_document__tuJfC"}},9860:(a,b,c)=>{"use strict";c.d(b,{G7:()=>k,L$:()=>n,h_:()=>o,oI:()=>l,uB:()=>j,xL:()=>m});var d=c(52834);c(49147);var e=c(86536),f=c(15620);c(16664);var g=c(89101),h=c(41568),i=c(97832);function j({className:a,...b}){return(0,d.jsx)(e.uB,{"data-slot":"command",className:(0,f.cn)("flex size-full flex-col overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground",a),...b})}function k({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"command-input-wrapper",className:"p-1 pb-0",children:(0,d.jsxs)(g.MG,{className:"has-[[data-slot=command-input]:focus-visible]:outline-2 has-[[data-slot=command-input]:focus-visible]:outline-solid has-[[data-slot=command-input]:focus-visible]:-outline-offset-2 has-[[data-slot=command-input]:focus-visible]:outline-ring",children:[(0,d.jsx)(e.uB.Input,{"data-slot":"command-input",className:(0,f.cn)("min-h-8 w-full bg-transparent px-2.5 text-sm leading-5 outline-none disabled:cursor-not-allowed disabled:opacity-50",a),...b}),(0,d.jsx)(g.Sq,{children:(0,d.jsx)(h.A,{className:"size-4 shrink-0 opacity-50"})})]})})}function l({className:a,...b}){return(0,d.jsx)(e.uB.List,{"data-slot":"command-list",className:(0,f.cn)("pi-desk-chat-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",a),...b})}function m({className:a,...b}){return(0,d.jsx)(e.uB.Empty,{"data-slot":"command-empty",className:(0,f.cn)("py-6 text-center text-sm",a),...b})}function n({className:a,...b}){return(0,d.jsx)(e.uB.Group,{"data-slot":"command-group",className:(0,f.cn)("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",a),...b})}function o({className:a,children:b,...c}){return(0,d.jsxs)(e.uB.Item,{"data-slot":"command-item",className:(0,f.cn)("group/command-item relative flex min-h-8 cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-sm leading-5 outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[selected=true]:*:[svg]:text-foreground",a),...c,children:[b,(0,d.jsx)(i.A,{className:"ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100"})]})}},11071:(a,b,c)=>{"use strict";c.d(b,{p:()=>g});var d=c(52834);c(49147);var e=c(17372),f=c(15620);function g({className:a,type:b,...c}){return(0,d.jsx)(e.p,{type:b,"data-slot":"input",className:(0,f.cn)("min-h-8 w-full min-w-0 rounded-lg border border-input bg-card px-2.5 py-1 text-sm leading-5 transition-colors duration-150 outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-50 aria-invalid:border-destructive aria-invalid:outline-destructive",a),...c})}},13221:(a,b,c)=>{"use strict";c.d(b,{T:()=>f});var d=c(52834);c(49147);var e=c(15620);function f({className:a,...b}){return(0,d.jsx)("textarea",{"data-slot":"textarea",className:(0,e.cn)("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-card px-2.5 py-2 text-sm leading-5 transition-colors duration-150 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-50 aria-invalid:border-destructive aria-invalid:outline-destructive",a),...b})}},13749:(a,b,c)=>{"use strict";c.d(b,{$:()=>g,P:()=>f});var d=c(17983),e=c(95186);async function f(a,b,c,f){await (0,e.QL)(a,d.Ot,{...b,path:c,targetType:f})}function g(a,b){let c=/^[a-zA-Z]:[\\/]/.test(a)||a.startsWith("\\\\"),d=c?"\\":"/",e=(c?a.replaceAll("/","\\"):a).replace(/[\\/]+$/,"");return b?`${e}${d}${b.replaceAll("/",d)}`:/^[a-z]:$/i.test(e)?`${e}${d}`:e||d}},16664:(a,b,c)=>{"use strict";c.d(b,{Hl:()=>x,YM:()=>A,YV:()=>t,_Y:()=>y,hA:()=>w,uX:()=>B,vu:()=>z});var d=c(52834);c(49147);var e=c(52878),f=c(40282),g=c(40898),h=c(24505),i=c(56500),j=c(61576),k=c(82488),l=c(58029),m=c(82260),n=c(39395),o=c(54239),p=c(13943),q=c(32772),r=c(57850),s=c(15620);function t({onOpenChange:a,...b}){return(0,d.jsx)(e.D,{"data-slot":"app-dialog",...b,onOpenChange:(c,d)=>{c||!1===b.modal||"outside-press"!==d.reason||d.event.target instanceof Element&&"app-dialog-backdrop"===d.event.target.getAttribute("data-slot")?a?.(c,d):d.cancel()}})}function u({...a}){return(0,d.jsx)(f.Z,{"data-slot":"app-dialog-portal",...a})}function v({className:a,...b}){return(0,d.jsx)(g.X,{"data-slot":"app-dialog-backdrop",className:(0,s.cn)("fixed inset-0 z-[100] bg-black/35 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",a),...b})}function w({className:a,children:b,showCloseButton:c=!0,finalFocus:e=!1,backdropClassName:f,...g}){let{t:j}=(0,r.Bd)("common");return(0,d.jsxs)(u,{children:[(0,d.jsx)(v,{className:f,forceRender:!!f}),(0,d.jsxs)(h.h,{"data-slot":"app-dialog-content",finalFocus:e,className:(0,s.cn)("fixed top-1/2 left-1/2 z-[110] flex max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-[27.5rem] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border bg-popover text-sm text-popover-foreground shadow-lg outline-none duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",a),...g,children:[b,c?(0,d.jsxs)(i.H,{"data-slot":"app-dialog-close-button","aria-label":j("closeDialog"),title:j("closeDialog"),className:"absolute top-2 right-2 flex size-8 cursor-pointer items-center justify-center rounded-lg text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground active:bg-foreground/14 focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",children:[(0,d.jsx)(q.A,{className:"size-4"}),(0,d.jsx)("span",{className:"sr-only",children:j("closeDialog")})]}):null]})]})}function x({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"app-dialog-header",className:(0,s.cn)("flex shrink-0 flex-col gap-1.5",a),...b})}function y({className:a,children:b,...c}){return(0,d.jsxs)(l.V,{"data-slot":"app-dialog-body",className:(0,s.cn)("relative min-h-0 flex-1 overflow-hidden",a),...c,children:[(0,d.jsx)(m.B,{"data-slot":"app-dialog-body-viewport",className:"h-full max-h-[inherit] w-full overscroll-contain rounded-[inherit] outline-none focus-visible:ring-2 focus-visible:ring-ring",children:b}),(0,d.jsx)(n.V,{"data-slot":"app-dialog-body-scrollbar",orientation:"vertical",className:"flex h-full w-2.5 touch-none border-l border-l-transparent p-px select-none",children:(0,d.jsx)(o.l,{"data-slot":"app-dialog-body-thumb",className:"relative flex-1 rounded-full bg-muted-foreground/45 hover:bg-muted-foreground/70"})}),(0,d.jsx)(p.I,{})]})}function z({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"app-dialog-footer",className:(0,s.cn)("flex shrink-0 flex-wrap justify-end gap-2 border-t bg-popover px-4 py-3",a),...b})}function A({className:a,...b}){return(0,d.jsx)(j.L,{"data-slot":"app-dialog-title",className:(0,s.cn)("text-lg leading-[1.4] font-semibold",a),...b})}function B({className:a,...b}){return(0,d.jsx)(k.r,{"data-slot":"app-dialog-description",className:(0,s.cn)("text-sm leading-5 text-muted-foreground",a),...b})}},17983:(a,b,c)=>{"use strict";c.d(b,{OC:()=>u,Ot:()=>l,Xe:()=>m,ZI:()=>o,_X:()=>q,fg:()=>n,p0:()=>p,p3:()=>s,ry:()=>r,ys:()=>t});var d=c(87883),e=c(51949),f=c(18997),g=c(98722);let h=d.Ik({cwd:d.Yj().trim().min(1).max(4096),workId:d.Yj().trim().min(1).optional()}).strict(),i=h.extend({repositoryRoot:e.rh}),j=h.extend({path:e.eC,imagePreviewMode:e.p$}).superRefine((a,b)=>{a.workId||e._g.safeParse(a.path).success||b.addIssue({code:"custom",path:["path"],message:"独立项目预览只接受根内相对路径"})}),k=d.k5(["file","directory"]),l={path:"/api/project-files/reveal",request:h.extend({path:d.KC([e.rh,e.eC]),targetType:k.optional()}).refine(a=>""!==a.path||"directory"===a.targetType,"文件路径不能为空").refine(a=>a.workId&&"directory"!==a.targetType||e.rh.safeParse(a.path).success,"独立项目和目录定位只接受根内相对路径"),response:d.Ik({}).strict()},m={path:"/api/project-files/list",request:h.extend({path:e.rh}).strict(),response:e.JH},n={path:"/api/project-files/search",request:h.extend(e.Nu.shape).strict(),response:e.jI},o={path:"/api/project-files/get",request:j,response:e.ih},p={path:"/api/project-git/get",request:h.extend({refresh:d.zM().optional()}).strict(),response:d.Ik({repositories:d.YO(f.u2).max(100)}).strict()},q={path:"/api/project-git-heads/get",request:h,response:d.Ik({repositories:d.YO(f.yl).max(f.y2)}).strict()},r={path:"/api/project-git-branches/list",request:i.strict(),response:g.WW},s={path:"/api/project-git-log/list",request:i.extend(g.co.shape).strict(),response:g.yw},t={path:"/api/project-git-changes/list",request:i.extend(g.ph.shape).strict(),response:g.T8},u={path:"/api/project-git-diff/get",request:i.extend({path:e._g,comparison:g.xv.optional()}).strict(),response:g.lw}},18997:(a,b,c)=>{"use strict";c.d(b,{FJ:()=>t,Ww:()=>h,cP:()=>i,gf:()=>r,u2:()=>p,y2:()=>g,yl:()=>o,zp:()=>m,zt:()=>q});var d=c(87883),e=c(53403),f=c(51949);let g=100,h=f.rh,i=d.Yj().trim().min(1).max(1024),j=d.gM("type",[d.Ik({type:d.eu("branch"),name:i}).strict(),d.Ik({type:d.eu("detached"),commit:d.Yj().regex(/^[0-9a-f]{40,64}$/)}).strict()]),k=d.k5(["added","modified","deleted","renamed","unmerged","untracked"]),l=d.Ik({path:f._g,oldPath:f._g.nullable(),indexStatus:k.nullable(),worktreeStatus:k.nullable()}).strict(),m=d.Ik({root:h,state:d.eu("ready"),head:j,changes:d.YO(l).max(5e4)}).strict(),n=d.Ik({root:h,state:d.eu("unavailable"),message:e.qf.refine(a=>("string"==typeof a?[a]:[a.default,...Object.values(a.translations)]).every(a=>a.length>0&&a.length<=2e3))}).strict(),o=d.gM("state",[m.omit({changes:!0}),n]),p=d.gM("state",[m,n]),q=d.gM("type",[d.Ik({type:d.eu("local"),name:i}).strict(),d.Ik({type:d.eu("remote"),name:i}).strict()]),r=d.Ik({head:j,recent:d.YO(i).max(5),local:d.YO(i).max(1e4),remote:d.YO(i).max(1e4)}).strict(),s=d.Ik({path:f._g,content:d.Yj()}).strict(),t=d.gM("kind",[d.Ik({kind:d.eu("text"),original:s,modified:s}).strict(),d.Ik({kind:d.eu("binary")}).strict(),d.Ik({kind:d.eu("too_large")}).strict()])},23423:(a,b,c)=>{"use strict";c.d(b,{$E:()=>f,Rv:()=>g,m4:()=>e});var d=c(87883);let e=d.Yj().trim().min(1),f=d.Yj().trim().min(1),g=d.Yj().trim().min(1)},28661:(a,b,c)=>{"use strict";function d(a){let b=atob(a.data),c=new Uint8Array(b.length);for(let a=0;a<b.length;a+=1)c[a]=b.charCodeAt(a);return new Blob([c],{type:a.mimeType})}c.d(b,{E:()=>d})},37096:(a,b,c)=>{"use strict";c.d(b,{HK:()=>g,WM:()=>i,wV:()=>h});var d=c(52834),e=c(39169),f=c(15620);function g({className:a,...b}){return(0,d.jsx)(e.YJ,{"data-slot":"resizable-panel-group",className:(0,f.cn)("flex h-full w-full aria-[orientation=vertical]:flex-col",a),...b})}function h({...a}){return(0,d.jsx)(e.Zk,{"data-slot":"resizable-panel",...a})}function i({withHandle:a,className:b,...c}){return(0,d.jsx)(e.wv,{"data-slot":"resizable-handle",className:(0,f.cn)("relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",b),...c})}},41994:(a,b,c)=>{"use strict";c.d(b,{k:()=>d});let d=c(87883).ai().int().nonnegative().max(Number.MAX_SAFE_INTEGER)},42704:(a,b,c)=>{"use strict";c.d(b,{AM:()=>l,Wv:()=>m,eO:()=>o,hl:()=>n});var d=c(52834);c(49147);var e=c(20104),f=c(10834),g=c(43088),h=c(47900),i=c(93915),j=c(62688),k=c(15620);function l({...a}){return(0,d.jsx)(e.y,{"data-slot":"popover",...a})}function m({...a}){return(0,d.jsx)(f.W,{"data-slot":"popover-trigger",...a})}function n({className:a,positionerClassName:b,align:c="center",alignOffset:e=0,side:f="bottom",sideOffset:j=4,finalFocus:l=!1,...m}){return(0,d.jsx)(g.i,{children:(0,d.jsx)(h.U,{align:c,alignOffset:e,side:f,sideOffset:j,className:(0,k.cn)("isolate z-50",b),children:(0,d.jsx)(i.i,{"data-slot":"popover-content",finalFocus:l,className:(0,k.cn)("z-50 flex w-80 max-w-[calc(100vw-2rem)] origin-(--transform-origin) flex-col gap-3 rounded-lg border border-border bg-popover p-3 text-sm text-popover-foreground shadow-md outline-hidden duration-100 motion-reduce:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",a),...m})})})}function o({className:a,...b}){return(0,d.jsx)(j.e,{"data-slot":"popover-title",className:(0,k.cn)("font-medium",a),...b})}},45427:(a,b,c)=>{"use strict";c.d(b,{n:()=>m});var d=c(52834),e=c(19480),f=c(36331),g=c(49147),h=c(38684),i=c(53437),j=c(6995),k=c.n(j);let l={cjk:e.h,code:f.a},m=(0,g.memo)(function({content:a,label:b,savedScrollTop:c,onScroll:e}){let f=(0,g.useRef)(null),j=(0,g.useRef)(c);return(0,g.useLayoutEffect)(()=>{f.current&&(f.current.scrollTop=j.current)},[]),(0,d.jsx)("div",{ref:f,"data-testid":"markdown-preview",role:"region","aria-label":b,tabIndex:0,className:"h-full min-h-0 overflow-auto overscroll-contain bg-background outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onScroll:a=>e(a.currentTarget.scrollTop),children:(0,d.jsx)(h.jH,{className:`${k().document} ${i.om}`,allowedTags:i.IV,components:i.e6,remarkPlugins:i.XC,mode:"static",parseIncompleteMarkdown:!1,isAnimating:!1,controls:!1,lineNumbers:!1,plugins:l,children:a})})})},45694:(a,b,c)=>{"use strict";c.d(b,{z:()=>e});let d=`<script>
1
+ exports.id=27344,exports.ids=[27344],exports.modules={1222:(a,b,c)=>{"use strict";c.d(b,{Ms:()=>u,N1:()=>t,Sb:()=>w,tQ:()=>v});var d=c(87883),e=c(51949),f=c(98722);let g="pi-super:project-preview:global",h="pi-super:project-preview:projects",i=d.ai().min(5).max(95),j=d.Ik({maximized:d.zM(),directoryOpen:d.zM(),gitOpen:d.zM(),gitMaximized:d.zM(),treeLayout:d.k5(["directory","repository"]),directorySize:i,gitSize:i,logSize:i,changeSize:i}),k={maximized:!1,directoryOpen:!0,gitOpen:!1,gitMaximized:!1,treeLayout:"directory",directorySize:22,gitSize:45,logSize:62,changeSize:70},l=d.Ik({repositoryRoot:d.Yj().nullable(),mode:d.k5(["history","compare"]),tip:d.Yj(),base:d.Yj(),target:d.Yj(),strategy:d.k5(["merge-base","direct"]),query:d.Yj().max(200),author:d.Yj().max(200),selectedCommit:f.aD.nullable(),selectedChangePath:e._g.nullable(),logScroll:d.ai().nonnegative(),changesScroll:d.ai().nonnegative()}),m=d.Ie(a=>"object"==typeof a&&null!==a&&Array.isArray(a.cursorState)&&"object"==typeof a.viewState),n=d.Ik({repositoryRoot:d.Yj(),path:e._g,comparison:f.xv.optional()}),o=d.Ik({page:d.k5(["files","code","git"]),historyPane:d.k5(["log","files"]),tabs:d.YO(e._g).max(20),activePath:e._g.nullable(),editorStates:d.g1(e._g,m),fileViewModes:d.g1(e._g,d.k5(["source","preview"])),expandedPaths:d.YO(d.Yj()).max(500),treeScrollTop:d.ai().nonnegative(),searchQuery:d.Yj().max(200),changesOnly:d.zM(),expandedRepositories:d.YO(d.Yj()).max(100),history:l,diffs:d.YO(n).max(20).optional(),activeDiff:n.nullable()}),p=d.Ik({cwd:d.Yj(),lastOpenedAt:d.ai(),state:o});function q(a){let b=a.replaceAll("\\","/").replace(/\/+$/,"");return/^[a-z]:\//i.test(b)||b.startsWith("//")?b.toLowerCase():b}function r(){try{let a=JSON.parse(window.localStorage.getItem(h)??"[]");if(!Array.isArray(a))return[];let b=Date.now();return a.flatMap(a=>{let c=p.safeParse(a);return c.success&&b-c.data.lastOpenedAt<2592e6?[c.data]:[]})}catch{return[]}}function s(a){try{window.localStorage.setItem(h,JSON.stringify(a.sort((a,b)=>b.lastOpenedAt-a.lastOpenedAt).slice(0,50)))}catch(a){console.warn("[Pi Desk][ProjectPreview] 保存项目浏览状态失败",a)}}function t(){try{let a=JSON.parse(window.localStorage.getItem(g)??"null");return{...k,...j.partial().parse(a)}}catch{return{...k}}}function u(a){try{window.localStorage.setItem(g,JSON.stringify(a))}catch(a){console.warn("[Pi Desk][ProjectPreview] 保存全局布局失败",a)}}function v(a){let b=q(a),c=r(),d=c.find(a=>a.cwd===b);return d&&(d.lastOpenedAt=Date.now()),s(c),d?.state??null}function w(a,b){let c=o.safeParse(b);if(!c.success)return;let d=q(a),e=r(),f=e.find(a=>a.cwd===d);f?f.state=c.data:e.push({cwd:d,lastOpenedAt:Date.now(),state:c.data}),s(e)}},4935:a=>{a.exports={markdown:"l4-markdown_markdown__oIf6d",status:"l4-markdown_status__EVcKw",alert:"l4-markdown_alert__Aooao",alertTitle:"l4-markdown_alertTitle__GIoFs",alertBody:"l4-markdown_alertBody__BtDVT"}},5701:(a,b,c)=>{"use strict";c.d(b,{V:()=>l});var d=c(52834);c(49147);var e=c(58029),f=c(82260),g=c(13943),h=c(15620),i=c(39395),j=c(54239);function k({className:a,orientation:b="vertical",...c}){return(0,d.jsx)(i.V,{"data-slot":"scroll-area-scrollbar","data-orientation":b,orientation:b,className:(0,h.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",a),...c,children:(0,d.jsx)(j.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}function l({className:a,viewportClassName:b,viewportRef:c,onViewportScroll:i,children:j,...m}){return(0,d.jsxs)(e.V,{"data-slot":"l4-scroll-area",className:(0,h.cn)("relative min-h-0 overflow-hidden",a),...m,children:[(0,d.jsx)(f.B,{ref:c,"data-slot":"l4-scroll-area-viewport",className:(0,h.cn)("size-full rounded-[inherit] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",b),onScroll:i,children:j}),(0,d.jsx)(k,{className:"data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent"}),(0,d.jsx)(g.I,{})]})}},6995:a=>{a.exports={document:"l3-markdown-preview_document__tuJfC"}},9860:(a,b,c)=>{"use strict";c.d(b,{G7:()=>k,L$:()=>n,h_:()=>o,oI:()=>l,uB:()=>j,xL:()=>m});var d=c(52834);c(49147);var e=c(86536),f=c(15620);c(16664);var g=c(89101),h=c(41568),i=c(97832);function j({className:a,...b}){return(0,d.jsx)(e.uB,{"data-slot":"command",className:(0,f.cn)("flex size-full flex-col overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground",a),...b})}function k({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"command-input-wrapper",className:"p-1 pb-0",children:(0,d.jsxs)(g.MG,{className:"has-[[data-slot=command-input]:focus-visible]:outline-2 has-[[data-slot=command-input]:focus-visible]:outline-solid has-[[data-slot=command-input]:focus-visible]:-outline-offset-2 has-[[data-slot=command-input]:focus-visible]:outline-ring",children:[(0,d.jsx)(e.uB.Input,{"data-slot":"command-input",className:(0,f.cn)("min-h-8 w-full bg-transparent px-2.5 text-sm leading-5 outline-none disabled:cursor-not-allowed disabled:opacity-50",a),...b}),(0,d.jsx)(g.Sq,{children:(0,d.jsx)(h.A,{className:"size-4 shrink-0 opacity-50"})})]})})}function l({className:a,...b}){return(0,d.jsx)(e.uB.List,{"data-slot":"command-list",className:(0,f.cn)("pi-desk-chat-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",a),...b})}function m({className:a,...b}){return(0,d.jsx)(e.uB.Empty,{"data-slot":"command-empty",className:(0,f.cn)("py-6 text-center text-sm",a),...b})}function n({className:a,...b}){return(0,d.jsx)(e.uB.Group,{"data-slot":"command-group",className:(0,f.cn)("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",a),...b})}function o({className:a,children:b,...c}){return(0,d.jsxs)(e.uB.Item,{"data-slot":"command-item",className:(0,f.cn)("group/command-item relative flex min-h-8 cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-sm leading-5 outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[selected=true]:*:[svg]:text-foreground",a),...c,children:[b,(0,d.jsx)(i.A,{className:"ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100"})]})}},11071:(a,b,c)=>{"use strict";c.d(b,{p:()=>g});var d=c(52834);c(49147);var e=c(17372),f=c(15620);function g({className:a,type:b,...c}){return(0,d.jsx)(e.p,{type:b,"data-slot":"input",className:(0,f.cn)("min-h-8 w-full min-w-0 rounded-lg border border-input bg-card px-2.5 py-1 text-sm leading-5 transition-colors duration-150 outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-50 aria-invalid:border-destructive aria-invalid:outline-destructive",a),...c})}},13221:(a,b,c)=>{"use strict";c.d(b,{T:()=>f});var d=c(52834);c(49147);var e=c(15620);function f({className:a,...b}){return(0,d.jsx)("textarea",{"data-slot":"textarea",className:(0,e.cn)("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-card px-2.5 py-2 text-sm leading-5 transition-colors duration-150 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-50 aria-invalid:border-destructive aria-invalid:outline-destructive",a),...b})}},13749:(a,b,c)=>{"use strict";c.d(b,{$:()=>g,P:()=>f});var d=c(17983),e=c(95186);async function f(a,b,c,f){await (0,e.QL)(a,d.Ot,{...b,path:c,targetType:f})}function g(a,b){let c=/^[a-zA-Z]:[\\/]/.test(a)||a.startsWith("\\\\"),d=c?"\\":"/",e=(c?a.replaceAll("/","\\"):a).replace(/[\\/]+$/,"");return b?`${e}${d}${b.replaceAll("/",d)}`:/^[a-z]:$/i.test(e)?`${e}${d}`:e||d}},14120:(a,b,c)=>{"use strict";c.d(b,{s:()=>y});var d=c(52834),e=c(79694),f=c(97586),g=c(83401),h=c(97993);let i={src:"/_next/static/media/console.fdac8a18.svg",height:16,width:16,blurWidth:0,blurHeight:0},j={src:"/_next/static/media/docker.1e10aab8.svg",height:24,width:24,blurWidth:0,blurHeight:0},k={src:"/_next/static/media/git.f893cb5f.svg",height:32,width:32,blurWidth:0,blurHeight:0},l={src:"/_next/static/media/html.97f145d3.svg",height:32,width:32,blurWidth:0,blurHeight:0},m={src:"/_next/static/media/image.69ad851c.svg",height:16,width:16,blurWidth:0,blurHeight:0},n={src:"/_next/static/media/javascript.9ef61c53.svg",height:16,width:16,blurWidth:0,blurHeight:0},o={src:"/_next/static/media/json.eb8fe488.svg",height:960,width:960,blurWidth:0,blurHeight:0},p={src:"/_next/static/media/markdown.ee1bbe18.svg",height:32,width:32,blurWidth:0,blurHeight:0},q={src:"/_next/static/media/nodejs.2f5d7983.svg",height:32,width:32,blurWidth:0,blurHeight:0},r={src:"/_next/static/media/typescript.cd97905b.svg",height:16,width:16,blurWidth:0,blurHeight:0},s={src:"/_next/static/media/yaml.8927dd24.svg",height:24,width:24,blurWidth:0,blurHeight:0},t=new Map(Object.entries({"agents.md":{src:"/_next/static/media/agent.84538518.svg",height:32,width:32,blurWidth:0,blurHeight:0},"skill.md":{src:"/_next/static/media/skill.a97e8eb6.svg",height:16,width:16,blurWidth:0,blurHeight:0},"package.json":q,"package-lock.json":q,"npm-shrinkwrap.json":q,dockerfile:j,".dockerignore":j,".gitignore":k,".gitattributes":k,".gitmodules":k})),u=new Map(Object.entries({ts:r,mts:r,cts:r,tsx:{src:"/_next/static/media/react_ts.3d16336c.svg",height:32,width:32,blurWidth:0,blurHeight:0},js:n,mjs:n,cjs:n,jsx:{src:"/_next/static/media/react.b5a87f7d.svg",height:32,width:32,blurWidth:0,blurHeight:0},json:o,jsonc:o,jsonl:o,yaml:s,yml:s,md:p,mdx:p,png:m,jpg:m,jpeg:m,gif:m,webp:m,avif:m,bmp:m,ico:m,svg:{src:"/_next/static/media/svg.4aa98763.svg",height:32,width:32,blurWidth:0,blurHeight:0},sh:i,bash:i,zsh:i,fish:i,ps1:i,bat:i,cmd:i,html:l,htm:l,css:{src:"/_next/static/media/css.0d88d948.svg",height:32,width:32,blurWidth:0,blurHeight:0},py:{src:"/_next/static/media/python.e376d0bc.svg",height:24,width:24,blurWidth:0,blurHeight:0}})),v=new Set(["env","toml","ini","conf","cfg","properties"]),w=new Set([".editorconfig",".npmrc",".yarnrc",".prettierignore",".eslintignore"]),x=new Set(["c","cpp","cc","cxx","h","hpp","cs","go","rs","java","kt","kts","rb","php","swift","dart","vue","svelte","scss","sass","less","sql","xml"]);function y({path:a,className:b}){let c=a.replaceAll("\\","/").split("/").at(-1)?.toLowerCase()??"",i=c.includes(".")?c.slice(c.lastIndexOf(".")+1):"";if(v.has(i)||w.has(c)||c.startsWith(".env.")||c.startsWith(".eslintrc")||c.startsWith(".prettierrc")||c.startsWith("eslint.config.")||c.startsWith("prettier.config."))return(0,d.jsx)(e.A,{className:b,"aria-hidden":"true"});let k=t.get(c)??(c.startsWith("dockerfile.")?j:void 0)??u.get(i);if(!k){let a=x.has(i)?f.A:g.A;return(0,d.jsx)(a,{className:b,"aria-hidden":"true"})}return(0,d.jsx)(h.default,{src:k,alt:"","aria-hidden":"true",width:16,height:16,className:b,unoptimized:!0})}},16664:(a,b,c)=>{"use strict";c.d(b,{Hl:()=>x,YM:()=>A,YV:()=>t,_Y:()=>y,hA:()=>w,uX:()=>B,vu:()=>z});var d=c(52834);c(49147);var e=c(52878),f=c(40282),g=c(40898),h=c(24505),i=c(56500),j=c(61576),k=c(82488),l=c(58029),m=c(82260),n=c(39395),o=c(54239),p=c(13943),q=c(32772),r=c(57850),s=c(15620);function t({onOpenChange:a,...b}){return(0,d.jsx)(e.D,{"data-slot":"app-dialog",...b,onOpenChange:(c,d)=>{c||!1===b.modal||"outside-press"!==d.reason||d.event.target instanceof Element&&"app-dialog-backdrop"===d.event.target.getAttribute("data-slot")?a?.(c,d):d.cancel()}})}function u({...a}){return(0,d.jsx)(f.Z,{"data-slot":"app-dialog-portal",...a})}function v({className:a,...b}){return(0,d.jsx)(g.X,{"data-slot":"app-dialog-backdrop",className:(0,s.cn)("fixed inset-x-0 top-[var(--pi-desk-window-inset)] bottom-0 z-[100] bg-black/35 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",a),...b})}function w({className:a,children:b,showCloseButton:c=!0,finalFocus:e=!1,backdropClassName:f,...g}){let{t:j}=(0,r.Bd)("common");return(0,d.jsxs)(u,{children:[(0,d.jsx)(v,{className:f,forceRender:!!f}),(0,d.jsxs)(h.h,{"data-slot":"app-dialog-content",finalFocus:e,className:(0,s.cn)("fixed top-[calc(50%+var(--pi-desk-window-inset)/2)] left-1/2 z-[110] flex max-h-[calc(var(--pi-desk-content-height)-2rem)] w-[calc(100%-2rem)] max-w-[27.5rem] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border bg-popover text-sm text-popover-foreground shadow-lg outline-none duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",a),...g,children:[b,c?(0,d.jsxs)(i.H,{"data-slot":"app-dialog-close-button","aria-label":j("closeDialog"),title:j("closeDialog"),className:"absolute top-2 right-2 flex size-8 cursor-pointer items-center justify-center rounded-lg text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground active:bg-foreground/14 focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",children:[(0,d.jsx)(q.A,{className:"size-4"}),(0,d.jsx)("span",{className:"sr-only",children:j("closeDialog")})]}):null]})]})}function x({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"app-dialog-header",className:(0,s.cn)("flex shrink-0 flex-col gap-1.5",a),...b})}function y({className:a,children:b,...c}){return(0,d.jsxs)(l.V,{"data-slot":"app-dialog-body",className:(0,s.cn)("relative min-h-0 flex-1 overflow-hidden",a),...c,children:[(0,d.jsx)(m.B,{"data-slot":"app-dialog-body-viewport",className:"h-full max-h-[inherit] w-full overscroll-contain rounded-[inherit] outline-none focus-visible:ring-2 focus-visible:ring-ring",children:b}),(0,d.jsx)(n.V,{"data-slot":"app-dialog-body-scrollbar",orientation:"vertical",className:"flex h-full w-2.5 touch-none border-l border-l-transparent p-px select-none",children:(0,d.jsx)(o.l,{"data-slot":"app-dialog-body-thumb",className:"relative flex-1 rounded-full bg-muted-foreground/45 hover:bg-muted-foreground/70"})}),(0,d.jsx)(p.I,{})]})}function z({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"app-dialog-footer",className:(0,s.cn)("flex shrink-0 flex-wrap justify-end gap-2 border-t bg-popover px-4 py-3",a),...b})}function A({className:a,...b}){return(0,d.jsx)(j.L,{"data-slot":"app-dialog-title",className:(0,s.cn)("text-lg leading-[1.4] font-semibold",a),...b})}function B({className:a,...b}){return(0,d.jsx)(k.r,{"data-slot":"app-dialog-description",className:(0,s.cn)("text-sm leading-5 text-muted-foreground",a),...b})}},17983:(a,b,c)=>{"use strict";c.d(b,{OC:()=>u,Ot:()=>l,Xe:()=>m,ZI:()=>o,_X:()=>q,fg:()=>n,p0:()=>p,p3:()=>s,ry:()=>r,ys:()=>t});var d=c(87883),e=c(51949),f=c(18997),g=c(98722);let h=d.Ik({cwd:d.Yj().trim().min(1).max(4096),workId:d.Yj().trim().min(1).optional()}).strict(),i=h.extend({repositoryRoot:e.rh}),j=h.extend({path:e.eC,imagePreviewMode:e.p$}).superRefine((a,b)=>{a.workId||e._g.safeParse(a.path).success||b.addIssue({code:"custom",path:["path"],message:"独立项目预览只接受根内相对路径"})}),k=d.k5(["file","directory"]),l={path:"/api/project-files/reveal",request:h.extend({path:d.KC([e.rh,e.eC]),targetType:k.optional()}).refine(a=>""!==a.path||"directory"===a.targetType,"文件路径不能为空").refine(a=>a.workId&&"directory"!==a.targetType||e.rh.safeParse(a.path).success,"独立项目和目录定位只接受根内相对路径"),response:d.Ik({}).strict()},m={path:"/api/project-files/list",request:h.extend({path:e.rh}).strict(),response:e.JH},n={path:"/api/project-files/search",request:h.extend(e.Nu.shape).strict(),response:e.jI},o={path:"/api/project-files/get",request:j,response:e.ih},p={path:"/api/project-git/get",request:h.extend({refresh:d.zM().optional()}).strict(),response:d.Ik({repositories:d.YO(f.u2).max(100)}).strict()},q={path:"/api/project-git-heads/get",request:h,response:d.Ik({repositories:d.YO(f.yl).max(f.y2)}).strict()},r={path:"/api/project-git-branches/list",request:i.strict(),response:g.WW},s={path:"/api/project-git-log/list",request:i.extend(g.co.shape).strict(),response:g.yw},t={path:"/api/project-git-changes/list",request:i.extend(g.ph.shape).strict(),response:g.T8},u={path:"/api/project-git-diff/get",request:i.extend({path:e._g,comparison:g.xv.optional()}).strict(),response:g.lw}},18997:(a,b,c)=>{"use strict";c.d(b,{FJ:()=>t,Ww:()=>h,cP:()=>i,gf:()=>r,u2:()=>p,y2:()=>g,yl:()=>o,zp:()=>m,zt:()=>q});var d=c(87883),e=c(53403),f=c(51949);let g=100,h=f.rh,i=d.Yj().trim().min(1).max(1024),j=d.gM("type",[d.Ik({type:d.eu("branch"),name:i}).strict(),d.Ik({type:d.eu("detached"),commit:d.Yj().regex(/^[0-9a-f]{40,64}$/)}).strict()]),k=d.k5(["added","modified","deleted","renamed","unmerged","untracked"]),l=d.Ik({path:f._g,oldPath:f._g.nullable(),indexStatus:k.nullable(),worktreeStatus:k.nullable()}).strict(),m=d.Ik({root:h,state:d.eu("ready"),head:j,changes:d.YO(l).max(5e4)}).strict(),n=d.Ik({root:h,state:d.eu("unavailable"),message:e.qf.refine(a=>("string"==typeof a?[a]:[a.default,...Object.values(a.translations)]).every(a=>a.length>0&&a.length<=2e3))}).strict(),o=d.gM("state",[m.omit({changes:!0}),n]),p=d.gM("state",[m,n]),q=d.gM("type",[d.Ik({type:d.eu("local"),name:i}).strict(),d.Ik({type:d.eu("remote"),name:i}).strict()]),r=d.Ik({head:j,recent:d.YO(i).max(5),local:d.YO(i).max(1e4),remote:d.YO(i).max(1e4)}).strict(),s=d.Ik({path:f._g,content:d.Yj()}).strict(),t=d.gM("kind",[d.Ik({kind:d.eu("text"),original:s,modified:s}).strict(),d.Ik({kind:d.eu("binary")}).strict(),d.Ik({kind:d.eu("too_large")}).strict()])},23423:(a,b,c)=>{"use strict";c.d(b,{$E:()=>f,Rv:()=>g,m4:()=>e});var d=c(87883);let e=d.Yj().trim().min(1),f=d.Yj().trim().min(1),g=d.Yj().trim().min(1)},28661:(a,b,c)=>{"use strict";function d(a){let b=atob(a.data),c=new Uint8Array(b.length);for(let a=0;a<b.length;a+=1)c[a]=b.charCodeAt(a);return new Blob([c],{type:a.mimeType})}c.d(b,{E:()=>d})},37096:(a,b,c)=>{"use strict";c.d(b,{HK:()=>g,WM:()=>i,wV:()=>h});var d=c(52834),e=c(39169),f=c(15620);function g({className:a,...b}){return(0,d.jsx)(e.YJ,{"data-slot":"resizable-panel-group",className:(0,f.cn)("flex h-full w-full aria-[orientation=vertical]:flex-col",a),...b})}function h({...a}){return(0,d.jsx)(e.Zk,{"data-slot":"resizable-panel",...a})}function i({withHandle:a,className:b,...c}){return(0,d.jsx)(e.wv,{"data-slot":"resizable-handle",className:(0,f.cn)("relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",b),...c})}},39511:(a,b,c)=>{"use strict";c.d(b,{F:()=>W});var d=c(52834),e=c(90814),f=c(37496),g=c(26890),h=c(75152),i=c(35385),j=c(63155),k=c(41568),l=c(49147),m=c(57850),n=c(53403),o=c(4998),p=c(15620),q=c(82563),r=c(85278);let s=(0,l.createContext)({expandedPaths:new Set,togglePath:()=>{}}),t=({expanded:a,defaultExpanded:b=new Set,selectedPath:c,onSelect:e,onExpandedChange:f,className:g,children:h,...i})=>{let[j,k]=(0,l.useState)(b),m=a??j,n=(0,l.useCallback)(a=>{let b=new Set(m);b.has(a)?b.delete(a):b.add(a),k(b),f?.(b)},[m,f]),o=(0,l.useMemo)(()=>({expandedPaths:m,onSelect:e,selectedPath:c,togglePath:n}),[m,e,c,n]);return(0,d.jsx)(s.Provider,{value:o,children:(0,d.jsx)("div",{className:(0,p.cn)("rounded-lg border bg-background font-sans text-sm",g),role:"tree",...i,children:(0,d.jsx)("div",{className:"p-2",children:h})})})},u=({className:a,children:b,...c})=>(0,d.jsx)("span",{className:(0,p.cn)("shrink-0",a),...c,children:b}),v=({className:a,children:b,...c})=>(0,d.jsx)("span",{className:(0,p.cn)("truncate",a),...c,children:b}),w=(0,l.createContext)({name:"",path:""}),x=({path:a,name:b,icon:c,className:e,children:f,...g})=>{let{selectedPath:h,onSelect:i}=(0,l.useContext)(s),j=h===a,k=(0,l.useCallback)(()=>{i?.(a)},[i,a]),m=(0,l.useCallback)(b=>{("Enter"===b.key||" "===b.key)&&i?.(a)},[i,a]),n=(0,l.useMemo)(()=>({name:b,path:a}),[b,a]);return(0,d.jsx)(w.Provider,{value:n,children:(0,d.jsx)("div",{className:(0,p.cn)("flex min-h-9 cursor-pointer items-center gap-2 rounded-md px-2 py-1 outline-none transition-colors hover:bg-foreground/8 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",j&&"bg-accent",e),onClick:k,onKeyDown:m,role:"treeitem","aria-selected":j,tabIndex:0,...g,children:f??(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"size-6 shrink-0"}),(0,d.jsx)(u,{children:c??(0,d.jsx)(r.A,{className:"size-4 text-muted-foreground"})}),(0,d.jsx)(v,{children:b})]})})})};var y=c(5701),z=c(14120),A=c(9365);function B({directory:a,expanded:b,onToggle:c,children:e,...g}){let i=a.label.split("/"),j=i.at(-1),k=i.slice(0,-1).join(" \\ "),l=i.join(" \\ "),m=b?A.A:h.A;return(0,d.jsx)(q.Nt,{open:b,onOpenChange:c,children:(0,d.jsxs)("div",{role:"treeitem","aria-expanded":b,"aria-selected":!1,title:a.targetPath,...g,children:[(0,d.jsx)("div",{className:"flex min-h-9 items-center rounded-sm px-2 py-1 transition-colors hover:bg-foreground/8",children:(0,d.jsxs)(q.R6,{className:"flex min-h-7 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-sm bg-transparent p-0 text-left text-sm outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":l,onKeyDown:a=>{("ArrowLeft"===a.key&&b||"ArrowRight"===a.key&&!b)&&(a.preventDefault(),a.stopPropagation(),c())},children:[(0,d.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center",children:(0,d.jsx)(f.A,{className:(0,p.cn)("size-4 text-muted-foreground transition-transform",b&&"rotate-90")})}),(0,d.jsx)(m,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,d.jsxs)("span",{className:"flex min-w-0 items-baseline",children:[k?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"min-w-0 shrink-[2] truncate text-muted-foreground",children:k}),(0,d.jsx)("span",{className:"shrink-0 px-1 text-muted-foreground","aria-hidden":"true",children:"\\"})]}):null,(0,d.jsx)("span",{className:"min-w-0 truncate",children:j})]})]})}),(0,d.jsx)(q.Ke,{children:(0,d.jsx)("div",{role:"group",className:"ml-4 border-l pl-2",children:e})})]})})}var C=c(5319),D=c(32772),E=c(89101),F=c(59582);let G=["all","files","content"],H=[{key:"caseSensitive",label:"searchCaseSensitive",text:"Aa"},{key:"wholeWord",label:"searchWholeWord",text:"Ab"},{key:"regex",label:"searchRegex",text:".*"}];function I({input:a,inputRef:b,invalid:c,onQueryChange:e,onOptionsChange:f,onComposingChange:g,onClose:h,onOpenFirst:i,onFocusResults:j}){let{t:n}=(0,m.Bd)("projectFiles"),[o,q]=(0,l.useState)(null),r=(0,l.useRef)(!1),s=n("files"===a.scope?"searchFiles":"content"===a.scope?"searchContent":"searchAll");return(0,d.jsxs)("div",{className:"shrink-0 px-1 pt-1",children:[(0,d.jsxs)(E.MG,{className:"rounded-md",children:[(0,d.jsx)(E.Sq,{className:"pl-1.5 py-0",children:(0,d.jsx)(k.A,{className:"size-3.5"})}),(0,d.jsx)(E.iV,{ref:b,"data-testid":"project-file-search",className:"min-h-7 min-w-0 px-1.5 py-0.5 text-sm placeholder:text-xs",value:o??a.query,placeholder:s,"aria-label":s,"aria-invalid":c||void 0,autoComplete:"off",spellCheck:!1,onChange:a=>{r.current?q(a.target.value):e(a.target.value)},onCompositionStart:a=>{r.current=!0,q(a.currentTarget.value),g(!0)},onCompositionEnd:a=>{r.current=!1,q(null),e(a.currentTarget.value),g(!1)},onKeyDown:a=>{a.nativeEvent.isComposing||r.current||("Enter"===a.key?(a.preventDefault(),i()):"ArrowDown"===a.key&&(a.preventDefault(),j()))}}),(0,d.jsx)(E.Sq,{align:"inline-end",className:"pr-0.5 py-0 has-[>button]:mr-0",children:(0,d.jsxs)(F.m_,{children:[(0,d.jsx)(F.k$,{render:(0,d.jsx)(E.Ik,{size:"icon-xs",className:"min-h-7","aria-label":n("closeSearch"),onClick:h}),children:(0,d.jsx)(D.A,{className:"size-4"})}),(0,d.jsx)(F.ZI,{children:n("closeSearch")})]})})]}),(0,d.jsxs)("div",{className:"flex min-h-7 flex-wrap items-center justify-between gap-x-1",children:[(0,d.jsx)("div",{className:"flex min-w-0 items-center",role:"radiogroup","aria-label":n("searchScope"),children:G.map((b,c)=>(0,d.jsx)(C.$,{type:"button",role:"radio","aria-checked":a.scope===b,tabIndex:a.scope===b?0:-1,disabled:null!==o,variant:"ghost",size:"sm","data-testid":`project-search-scope-${b}`,className:(0,p.cn)("px-1 text-xs",a.scope===b&&"bg-accent text-accent-foreground"),onClick:()=>f({scope:b}),onKeyDown:a=>{let b="ArrowRight"===a.key||"ArrowDown"===a.key,d="ArrowLeft"===a.key||"ArrowUp"===a.key;if(!b&&!d&&"Home"!==a.key&&"End"!==a.key)return;a.preventDefault();let e="Home"===a.key?0:"End"===a.key?2:(c+(b?1:2))%3;f({scope:G[e]}),a.currentTarget.parentElement?.querySelectorAll('[role="radio"]')[e]?.focus()},children:n("all"===b?"searchScopeAll":"files"===b?"searchScopeFiles":"searchScopeContent")},b))}),(0,d.jsx)("div",{className:"ml-auto flex items-center",children:H.map(({key:b,label:c,text:e})=>(0,d.jsxs)(F.m_,{children:[(0,d.jsx)(F.k$,{render:(0,d.jsx)(C.$,{type:"button",variant:"ghost",size:"icon-sm",disabled:null!==o,"aria-label":n(c),"aria-pressed":a[b],"data-testid":`project-search-option-${b}`,className:(0,p.cn)("font-mono text-xs text-muted-foreground","wholeWord"===b&&"underline underline-offset-4"),onClick:()=>f({[b]:!a[b]})}),children:e}),(0,d.jsx)(F.ZI,{children:n(c)})]},b))})]})]})}function J(a,b,c=0){let e=[],f=0;for(let g of b){let b=Math.max(f,g.start-c,0),h=Math.min(g.end-c,a.length);h<=b||(e.push(a.slice(f,b)),e.push((0,d.jsx)("mark",{className:"rounded-sm bg-foreground/15 text-inherit",children:a.slice(b,h)},`${b}:${h}`)),f=h)}return e.push(a.slice(f)),e}function K({search:a,resultsRef:b,activePath:c,onOpen:g,wrapFile:h,renderFileIcon:i,fileDecoration:j}){let{t:n}=(0,m.Bd)("projectFiles"),o=(0,l.useId)(),[q,r]=(0,l.useState)(!1),[s,t]=(0,l.useState)(new Set),[u,v]=(0,l.useState)(null),w=new Map;for(let b of a.contentMatches){let a=w.get(b.path);a?a.push(b):w.set(b.path,[b])}let x=!!a.query.trim(),z=x&&"ready"===a.status,A=a.fileMatches.length,B=a.contentMatches.length,D="all"===a.scope&&A>3&&B>0&&!q,E=D?a.fileMatches.slice(0,3):a.fileMatches,F=n("searchCounts",{files:new Set([...a.fileMatches.map(a=>a.path),...w.keys()]).size,lines:B}),G=a=>{t(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})};return(0,d.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,d.jsxs)("div",{className:"flex min-h-6 flex-wrap items-center justify-between gap-x-2 px-2 text-xs text-muted-foreground",role:"status","aria-live":"polite",children:[(0,d.jsx)("span",{children:n("searchResults")}),z?(0,d.jsx)("span",{className:"tabular-nums",children:a.truncated?n("searchShownCounts",{counts:F}):F}):null]}),(0,d.jsx)(y.V,{className:"min-h-0 flex-1",viewportClassName:"pb-2",children:(0,d.jsx)("div",{ref:b,role:"region","aria-label":n("searchResults"),"aria-busy":x&&"loading"===a.status,onKeyDown:a=>{if("ArrowDown"!==a.key&&"ArrowUp"!==a.key&&"Home"!==a.key&&"End"!==a.key)return;let b=[...a.currentTarget.querySelectorAll("button")].filter(a=>!a.disabled&&!a.closest("[hidden]")),c=b.indexOf(document.activeElement);if(c<0)return;a.preventDefault();let d="Home"===a.key?0:"End"===a.key?b.length-1:Math.max(0,Math.min(b.length-1,c+("ArrowDown"===a.key?1:-1)));b[d]?.focus()},children:x?"loading"===a.status?(0,d.jsxs)("div",{className:"flex min-h-10 items-center gap-2 px-3 text-xs text-muted-foreground",children:[(0,d.jsx)(e.A,{className:"size-3.5 animate-spin"}),n("searching")]}):"error"===a.status?(0,d.jsx)("p",{role:"alert",className:"mx-3 my-2 break-words rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:a.error||n("searchFailed")}):z&&0===A&&0===B?(0,d.jsxs)("div",{className:"px-5 py-9 text-center text-sm text-muted-foreground",children:[(0,d.jsx)(k.A,{className:"mx-auto mb-3 size-6"}),(0,d.jsx)("p",{children:n(a.truncated?"resultLimit":"noMatches")}),(0,d.jsx)("p",{className:"mt-2 text-xs",children:n("searchTryOptions")})]}):z?(0,d.jsxs)(d.Fragment,{children:[A>0?(0,d.jsxs)("section",{children:["all"===a.scope?(0,d.jsxs)("h3",{className:"flex min-h-6 items-center gap-2 px-2 text-xs text-muted-foreground",children:[n("searchFileHeading"),(0,d.jsx)("span",{className:"tabular-nums",children:A})]}):null,E.map(({path:a,ranges:b})=>{let e=a.lastIndexOf("/"),f=j(a);return h(a,void 0,(0,d.jsxs)(C.$,{type:"button",variant:"ghost","data-testid":`project-search-result-${a}`,"data-search-result":"true",className:(0,p.cn)("mx-1 flex min-h-6 w-[calc(100%-0.5rem)] justify-start gap-1 px-1 py-0 text-left font-normal [@media(pointer:coarse)]:min-h-9",c===a&&"bg-accent"),title:a,onClick:()=>g(a),children:[(0,d.jsx)("span",{className:"shrink-0",children:i(a)}),(0,d.jsxs)("span",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[(0,d.jsx)("span",{className:(0,p.cn)("truncate text-sm",f.className),children:J(a.slice(e+1),b,e+1)}),e>=0?(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:J(a.slice(0,e),b)}):null]}),f.badge?(0,d.jsx)("span",{className:(0,p.cn)("text-xs",f.className),"aria-label":n("gitStatus",{status:f.badge}),children:f.badge}):null]},a))}),D?(0,d.jsx)(C.$,{type:"button",variant:"ghost",size:"sm",className:"ml-5 min-h-6 py-0 text-xs text-muted-foreground [@media(pointer:coarse)]:min-h-9",onClick:()=>r(!0),children:n("searchExpandFiles",{count:A-3})}):null]}):null,B>0?(0,d.jsxs)("section",{className:(0,p.cn)(A>0&&"mt-1"),children:["all"===a.scope?(0,d.jsxs)("h3",{className:"flex min-h-6 flex-wrap items-center gap-x-2 px-2 text-xs text-muted-foreground",children:[n("searchContentHeading"),(0,d.jsx)("span",{children:n("searchContentCounts",{lines:B,files:w.size})})]}):null,[...w].map(([a,b],c)=>{let e=a.lastIndexOf("/"),j=!s.has(a),k=`${o}-${c}`;return(0,d.jsxs)("section",{className:"mb-1",children:[(0,d.jsxs)(C.$,{type:"button",variant:"ghost",className:"min-h-6 w-full justify-start gap-1 rounded-none px-2 py-0 text-left font-normal [@media(pointer:coarse)]:min-h-9",title:a,"aria-expanded":j,"aria-controls":k,onClick:()=>G(a),onKeyDown:b=>{("ArrowLeft"===b.key&&j||"ArrowRight"===b.key&&!j)&&(b.preventDefault(),G(a))},children:[(0,d.jsx)(f.A,{className:(0,p.cn)("size-3 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none",j&&"rotate-90")}),(0,d.jsx)("span",{className:"shrink-0",children:i(a)}),(0,d.jsxs)("span",{className:"min-w-0 truncate text-sm",children:[a.slice(e+1),(0,d.jsx)("span",{className:"ml-1.5 text-xs text-muted-foreground",children:a.slice(0,Math.max(0,e))})]}),(0,d.jsx)("span",{className:"ml-auto shrink-0 rounded bg-muted px-1 text-xs text-muted-foreground tabular-nums",children:b.length})]}),(0,d.jsx)("div",{id:k,hidden:!j,children:b.map(({line:b,text:c,ranges:e})=>h(a,b,(0,d.jsxs)(C.$,{type:"button",variant:"ghost","data-testid":`project-search-line-${a}-${b}`,"data-search-result":"true",className:(0,p.cn)("min-h-6 w-full justify-start gap-1 rounded-none border-l-2 border-transparent py-0 pr-2 pl-5 text-left font-mono font-normal [@media(pointer:coarse)]:min-h-9",u?.path===a&&u.line===b&&"border-l-foreground/50 bg-accent"),title:c,"aria-label":n("searchOpenLine",{path:a,line:b}),onClick:()=>{v({path:a,line:b}),g(a,b)},children:[(0,d.jsx)("span",{className:"min-w-5 shrink-0 text-right text-xs text-muted-foreground tabular-nums",children:b}),(0,d.jsx)("span",{className:"min-w-0 truncate whitespace-pre text-sm",children:J(c,e)})]},`${a}:${b}`)))})]},a)})]}):null,a.truncated?(0,d.jsx)("p",{className:"px-3 py-2 text-xs leading-5 text-muted-foreground",children:n("resultLimit")}):null]}):null:(0,d.jsxs)("div",{className:"px-5 py-9 text-center text-sm text-muted-foreground",children:[(0,d.jsx)(k.A,{className:"mx-auto mb-3 size-6"}),(0,d.jsx)("p",{children:n("searchStart")}),(0,d.jsx)("p",{className:"mt-2 text-xs",children:n("files"===a.scope?"searchFiles":"content"===a.scope?"searchContent":"searchAll")})]})})}),"files"!==a.scope?(0,d.jsx)("p",{className:"shrink-0 px-2 py-1 text-xs leading-5 text-muted-foreground",children:n("searchTextLimit")}):null]})}var L=c(49057),M=c(51108),N=c(61332),O=c(57396),P=c.n(O),Q=c(83731);let R=[],S=new WeakMap;function T(a){return(0,d.jsx)(z.s,{path:a,className:"size-4 text-muted-foreground"})}function U(a){if(a)return(0,L.iH)(a.change)}function V({state:a,onRetry:b}){let{t:c}=(0,m.Bd)("projectFiles");return a&&"idle"!==a.status&&"loading"!==a.status?"error"!==a.status?null:(0,d.jsx)("button",{type:"button",onClick:b,className:"min-h-8 w-full rounded px-2 text-left text-xs text-destructive hover:bg-destructive/10",children:c("retryReading",{error:a.error})}):(0,d.jsxs)("div",{className:"flex min-h-8 items-center gap-2 px-2 text-xs text-muted-foreground",children:[(0,d.jsx)(e.A,{className:"size-3.5 animate-spin"})," ",c("reading")]})}function W({cwd:a,projectName:b,runtime:c,gitRuntime:e,onOpenGitBranches:q,onFileOpened:r,rootTitle:s,showRootTitle:w=!0,gitReadOnly:z=!1}){let A,D,E,{t:F}=(0,m.Bd)("projectFiles"),{locale:G}=(0,o.i)();(0,l.useSyncExternalStore)(c.subscribe,c.getRevision,c.getRevision),(0,l.useSyncExternalStore)(e.subscribe,e.getRevision,e.getRevision);let H=c.state,J=e.getWorkspace(a),O=(0,l.useRef)(null),X=(0,l.useRef)(null),Y=(0,l.useRef)(null),Z=(0,l.useRef)(null),$=(0,l.useRef)(null),[_,aa]=(0,l.useState)(!1),ab=(0,l.useRef)({}),ac=(0,l.useCallback)(a=>{a?S.set(c,ab.current):S.get(c)===ab.current&&S.delete(c),aa(a)},[c]),ad=H.searchOpen,ae=()=>{aa(!1),c.setSearchOpen(!1),requestAnimationFrame(()=>$.current?.focus())},[af,ag]=(0,l.useState)({}),ah=(a,b)=>{let c=af[a]??300;return c<b?(0,d.jsx)("button",{type:"button",className:"min-h-8 px-3 text-sm text-muted-foreground hover:bg-accent",onClick:b=>{b.stopPropagation(),ag(b=>({...b,[a]:c+300}))},children:F("showMore",{visible:c,total:b})}):null};H?.search.query;let ai=J?.snapshot.repositories??R,aj=(0,L.eP)(ai),ak=new Map(aj.map(a=>[a.projectPath,a])),al=ai.map(a=>a.root).filter(Boolean),am=(0,l.useCallback)(()=>{e.refreshSnapshot(a);let b=e.getWorkspace(a);if(c.state.searchOpen||b?.changesOnly)return;let d=b?.layout==="repository"&&(1!==b.snapshot.repositories.length||b.snapshot.repositories[0]?.root!=="")?[...b.expandedRepositories].sort((a,b)=>b.length-a.length):[""],f=c.state.expandedPaths,g=new Set(d);for(let a of f){let b=d.find(b=>!b||a.startsWith(`${b}/`));if(void 0===b)continue;let c=a.slice(b?b.length+1:0).split("/");c.slice(0,-1).every((a,d)=>f.has((0,Q._J)(b,c.slice(0,d+1).join("/"))))&&g.add(a)}c.refreshDirectories(g)},[a,e,c]);(0,N.L)(O,am),[...J?.expandedRepositories??[]].join("\0");let an=new Set(al),ao=(a,b)=>{let d=new Set(H.expandedPaths);for(let c of a.paths)b?d.add(c):d.delete(c);c.setExpandedPaths(d,!1),b&&!J?.changesOnly&&Promise.all(a.paths.map(a=>c.ensureDirectory(a,!0))).then(()=>c.expandDirectoryChain(a.path,an))},ap=(a,b)=>{c.openFile(a,b),r?.()},aq=a=>{c.openDiff(a.repositoryRoot,a.path),r?.()},ar=(b,e)=>(0,d.jsx)(M.J,{cwd:a,path:b.targetPath,type:"directory",trigger:e,expanded:H.expandedPaths.has(b.path),onToggle:()=>ao(b,!H.expandedPaths.has(b.path)),onReveal:c.canReveal?(a,b)=>c.revealFile(a,b):void 0},(0,Q.Im)("directory",b.path)),as=(b,e,f=null,g=!1,h)=>(0,d.jsx)(M.J,{cwd:a,path:b,type:"file",trigger:e,openLabel:F(g?"viewDiff":"openPreview"),onOpen:()=>g&&f?aq(f):ap(b,h),oldPath:f?.change.oldPath?(0,Q._J)(f.repositoryRoot,f.change.oldPath):void 0,onReveal:c.canReveal?(a,b)=>c.revealFile(a,b):void 0},void 0===h?(0,Q.Im)("file",b):`${b}:${h}`),at=(a,b,c,e)=>as(a,(0,d.jsxs)(x,{path:(0,Q.Im)("file",a),name:b,title:a,"data-testid":`project-file-${a}`,onClick:()=>{e&&c?aq(c):ap(a)},children:[(0,d.jsx)("span",{className:"size-6 shrink-0"}),(0,d.jsx)(u,{children:T(a)}),(0,d.jsx)(v,{"data-testid":`project-file-name-${a}`,className:(0,p.cn)("min-w-0 flex-1",U(c)),children:b}),c?(0,d.jsx)("span",{className:(0,p.cn)("text-xs tabular-nums",U(c)),"aria-label":F("gitStatus",{status:(0,L.XB)(c.change)}),children:(0,L.XB)(c.change)}):null]}),c,e),au=(a,b,e)=>{let f=H?.directories.get(a);if(f?.status!=="ready")return(0,d.jsx)(V,{state:f,onRetry:()=>void c.ensureDirectory(a)});let g=e?f.entries.filter(c=>{let d;return d=(0,Q._J)(a,c.name),!al.some(a=>a!==b&&d===a)}):f.entries;return(0,d.jsxs)(d.Fragment,{children:[g.slice(0,af[`directory:${a}`]??300).map(f=>{let g=(0,Q._J)(a,f.name);if("file"===f.type)return at(g,f.name,ak.get(g)??null,!1);let h=c.compactDirectory(g,an);return ar(h,(0,d.jsx)(B,{directory:h,expanded:H.expandedPaths.has(g),onToggle:()=>ao(h,!H.expandedPaths.has(g)),"data-testid":`project-folder-${g}`,children:au(h.targetPath,b,e)}))}),ah(`directory:${a}`,g.length),f.truncated?(0,d.jsx)("p",{className:"px-2 py-2 text-xs leading-5 text-amber-600 dark:text-amber-400",children:F("directoryLimit")}):null,0===g.length?(0,d.jsx)("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:F("emptyDirectory")}):null]})},av=(a,b)=>{let c=a.get(b);if(!c)return null;let e=[...c.directories.keys()].sort(Q.Kn),f=[...c.files].sort(Q.Kn),g=af[`changes:${b}`]??300;return(0,d.jsxs)(d.Fragment,{children:[e.slice(0,g).map(b=>{let c=(0,Q.xV)(b,a,an);return ar(c,(0,d.jsx)(B,{directory:c,expanded:H.expandedPaths.has(b),onToggle:()=>ao(c,!H.expandedPaths.has(b)),"data-testid":`project-folder-${b}`,children:av(a,c.targetPath)}))}),f.slice(0,Math.max(0,g-e.length)).map(a=>at(a,a.slice(a.lastIndexOf("/")+1),ak.get(a)??null,!0)),ah(`changes:${b}`,e.length+f.length)]})},aw=a=>{let b=a.slice(5),c=ak.get(b);J?.changesOnly&&c?aq(c):ap(b)},ax=(j,k,l)=>{if(J?.changesOnly&&!j)return null;let m=J?.expandedRepositories.has(k)??!1,o=j?.state==="ready"?aj.filter(a=>a.repositoryRoot===k):[],r=o.length;if(J?.changesOnly&&j?.state==="ready"&&0===r)return null;let s=(0,Q.OA)(o.map(a=>a.projectPath),k);return(0,d.jsxs)("section",{"data-testid":`project-git-repository-${k||"root"}`,className:"border-b last:border-b-0",children:[(0,d.jsxs)("div",{className:"flex min-h-8 items-center gap-1 px-1 py-0.5",children:[(0,d.jsxs)("button",{"data-testid":`project-git-repository-toggle-${k||"root"}`,type:"button",className:"flex min-w-0 flex-1 items-center gap-1 rounded-md px-1 py-0.5 text-left hover:bg-muted/60","aria-expanded":m,onClick:()=>{m&&c.cancelDirectoryExpansion(k),e.toggleRepository(a,k),m||c.ensureDirectory(k,!0)},children:[(0,d.jsx)(f.A,{className:(0,p.cn)("size-3 shrink-0 text-muted-foreground transition-transform",m&&"rotate-90")}),j?(0,d.jsx)(g.A,{className:"size-4 shrink-0 text-muted-foreground"}):(0,d.jsx)(h.A,{className:"size-4 shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:j&&k||b,children:l})]}),j?(0,d.jsxs)("button",{"data-testid":`project-git-branch-${k||"root"}`,type:"button",disabled:z||"ready"!==j.state,className:(0,p.cn)((0,C.r)({variant:"ghost",size:"sm"}),"max-w-28 shrink gap-1 font-mono text-xs text-muted-foreground"),title:"ready"===j.state?F(z?"gitBranchReadOnly":"gitBranches"):(0,n.fD)(j.message,G),"aria-label":F(z?"gitBranchReadOnly":"gitBranches"),onClick:()=>q(k),children:[(0,d.jsx)(i.A,{className:"size-3 shrink-0"}),(0,d.jsx)("span",{className:"min-w-0 truncate",children:"ready"===j.state?(0,L.ws)(j.head):F("unavailable")}),r>0?(0,d.jsx)("span",{className:"rounded-md bg-muted px-1 text-xs text-status-warning",children:r}):null]}):null]}),m?J?.changesOnly?(0,d.jsx)(t,{className:"rounded-none border-0 bg-transparent px-1 pb-1",selectedPath:H?.activeDiff?(0,Q.Im)("file",(0,L.oW)(H.activeDiff.repositoryRoot,H.activeDiff.path)):void 0,onSelect:aw,children:r>0?av(s,k):(0,d.jsx)("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:F("noChanges")})}):(0,d.jsx)(t,{className:"rounded-none border-0 bg-transparent px-1 pb-1",selectedPath:H.activePath?(0,Q.Im)("file",H.activePath):void 0,onSelect:aw,children:au(k,j?.root??null,!0)}):null]},j?`git:${k}`:"workspace")},ay=1===ai.length&&ai[0]?.root===""?ai[0]:null,az=ai.length>0&&!ay,aA=az?J?.layout??"directory":"directory",aB=ay?(0,d.jsxs)("button",{type:"button",disabled:z||"ready"!==ay.state,className:(0,p.cn)((0,C.r)({variant:"ghost",size:"sm"}),"max-w-32 shrink gap-1 font-mono text-xs text-muted-foreground",!w&&"min-w-0 flex-1 justify-start"),"aria-label":F(z?"gitBranchReadOnly":"gitBranches"),title:"ready"===ay.state?`${F(z?"gitBranchReadOnly":"gitBranches")} \xb7 ${(0,L.ws)(ay.head)}`:(0,n.fD)(ay.message,G),onClick:()=>q(""),children:[(0,d.jsx)(i.A,{className:"size-3 shrink-0"}),(0,d.jsx)("span",{className:"truncate",children:"ready"===ay.state?(0,L.ws)(ay.head):F("unavailable")})]}):null,aC=(0,d.jsxs)("div",{className:"flex min-h-8 min-w-0 flex-wrap items-center gap-x-1 gap-y-0.5 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",tabIndex:w?void 0:0,"aria-label":F("projectFiles",{name:b}),children:[az?(0,d.jsx)("div",{className:"flex shrink-0 gap-0.5",role:"group","aria-label":F("layout"),children:["directory","repository"].map(b=>(0,d.jsx)("button",{"data-testid":`project-file-layout-${b}`,type:"button","aria-pressed":aA===b,className:(0,p.cn)((0,C.r)({variant:"ghost",size:"sm"}),aA===b&&"bg-accent text-accent-foreground"),onClick:()=>{c.cancelDirectoryExpansion(),e.setLayout(a,b)},children:F("directory"===b?"directory":"repository")},b))}):null,ai.length>0?(0,d.jsxs)("button",{"data-testid":"project-git-changes-toggle",type:"button","aria-pressed":J?.changesOnly??!1,className:(0,p.cn)((0,C.r)({variant:"ghost",size:"sm"}),"min-w-0 gap-1",J?.changesOnly&&"bg-accent text-accent-foreground"),onClick:()=>{c.cancelDirectoryExpansion(),e.setChangesOnly(a,!J?.changesOnly)},children:[(0,d.jsx)(j.A,{className:"size-3 shrink-0"}),(0,d.jsx)("span",{className:"truncate",children:F("changesOnly")}),(0,d.jsx)("span",{className:"rounded-md bg-muted px-1 font-mono text-xs",children:aj.length})]}):null,w?null:aB,(0,d.jsx)("button",{ref:$,type:"button",className:(0,p.cn)((0,C.r)({variant:"ghost",size:"icon-sm"}),"ml-auto"),"aria-label":F("searchProject"),title:F("searchProject"),onClick:()=>{c.setSearchOpen(!0),requestAnimationFrame(()=>Y.current?.focus())},children:(0,d.jsx)(k.A,{className:"size-3.5"})})]});return(0,d.jsxs)("section",{ref:O,className:"flex h-full min-h-0 flex-col bg-sidebar","aria-label":F("projectFiles",{name:b}),onKeyDown:a=>{!ad||"Escape"!==a.key||(a.stopPropagation(),a.nativeEvent.isComposing||_||(a.preventDefault(),ae()))},children:[ad?(0,d.jsx)(I,{input:H.search,inputRef:Y,invalid:"error"===H.search.status,onQueryChange:a=>c.setSearchQuery(a),onOptionsChange:a=>c.setSearchOptions(a),onComposingChange:ac,onClose:ae,onOpenFirst:()=>{let a=c.state.search;if("ready"!==a.status)return;let b=a.fileMatches[0],d=a.contentMatches[0];b?ap(b.path):d&&ap(d.path,d.line)},onFocusResults:()=>Z.current?.querySelector("button")?.focus()}):(0,d.jsxs)("div",{className:"border-b px-1",children:[w?(0,d.jsxs)("div",{className:"flex min-h-7 min-w-0 items-center gap-1",children:[(0,d.jsx)(M.J,{cwd:a,path:"",type:"directory",onReveal:c.canReveal?(a,b)=>c.revealFile(a,b):void 0,trigger:s?(0,d.jsx)("div",{className:"flex min-w-0 flex-1",children:s}):(0,d.jsxs)("div",{tabIndex:0,className:"flex min-w-0 flex-1 items-baseline gap-1",children:[(0,d.jsx)("p",{className:"shrink-0 truncate text-xs font-semibold",title:b,children:b}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"\xb7"}),(0,d.jsx)("p",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",title:a,children:(A=a.replaceAll("\\","/").split("/").filter(Boolean)).length<=2?a:`…/${A.slice(-2).join("/")}`})]})}),aB]}):null,w?aC:(0,d.jsx)(M.J,{cwd:a,path:"",type:"directory",onReveal:c.canReveal?(a,b)=>c.revealFile(a,b):void 0,trigger:aC})]}),ad?(0,d.jsx)(K,{search:H.search,resultsRef:Z,activePath:H.activeDiff?null:H.activePath,onOpen:ap,wrapFile:(a,b,c)=>as(a,c,ak.get(a)??null,!1,b),renderFileIcon:T,fileDecoration:a=>{let b=ak.get(a)??null;return{className:U(b),badge:b?(0,L.XB)(b.change):void 0}}},JSON.stringify([H.search.query,H.search.scope,H.search.caseSensitive,H.search.wholeWord,H.search.regex])):(0,d.jsxs)(y.V,{className:(0,p.cn)(P().tree,"min-h-0 flex-1"),viewportClassName:"py-0.5",viewportRef:X,onViewportScroll:a=>c.setTreeScrollTop(a.currentTarget.scrollTop),children:[ai.filter(a=>"unavailable"===a.state).map(a=>"unavailable"===a.state?(0,d.jsxs)("p",{role:"alert",className:"mx-2 mb-1 break-words rounded-md bg-muted px-2 py-2 text-sm text-destructive",children:[a.root||b,":",(0,n.fD)(a.message,G)]},a.root):null),J?.snapshot.status==="error"?(0,d.jsx)("p",{className:"mx-2 mb-1 rounded-md bg-muted px-2 py-2 text-sm text-destructive",children:J.snapshot.error}):null,"repository"===aA?(D=ai.some(a=>""===a.root),E=J?.changesOnly?ai.filter(a=>"unavailable"===a.state||a.changes.length>0):ai,(0,d.jsxs)("div",{className:"px-1",children:[D?null:ax(null,"",b),E.map(a=>ax(a,a.root,(0,L.Hj)(b,a.root))),J?.changesOnly&&0===E.length?(0,d.jsx)("p",{className:"px-2 py-5 text-center text-xs text-muted-foreground",children:F("noChangedFiles")}):null]})):(()=>{if(J?.changesOnly){let a=(0,Q.OA)(aj.map(a=>a.projectPath));return(0,d.jsx)(t,{className:"rounded-none border-0 bg-transparent",selectedPath:H?.activeDiff?(0,Q.Im)("file",(0,L.oW)(H.activeDiff.repositoryRoot,H.activeDiff.path)):H.activePath?(0,Q.Im)("file",H.activePath):void 0,onSelect:aw,children:aj.length>0?av(a,""):(0,d.jsx)("p",{className:"px-2 py-5 text-center text-xs text-muted-foreground",children:ai.some(a=>"unavailable"===a.state)?F("incompleteRepository"):F("noChangedFiles")})})}return(0,d.jsx)(t,{className:"rounded-none border-0 bg-transparent",selectedPath:H.activePath?(0,Q.Im)("file",H.activePath):void 0,onSelect:aw,children:au("",null,!1)})})()]})]})}},41994:(a,b,c)=>{"use strict";c.d(b,{k:()=>d});let d=c(87883).ai().int().nonnegative().max(Number.MAX_SAFE_INTEGER)},42704:(a,b,c)=>{"use strict";c.d(b,{AM:()=>l,Wv:()=>m,eO:()=>o,hl:()=>n});var d=c(52834);c(49147);var e=c(20104),f=c(10834),g=c(43088),h=c(47900),i=c(93915),j=c(62688),k=c(15620);function l({...a}){return(0,d.jsx)(e.y,{"data-slot":"popover",...a})}function m({...a}){return(0,d.jsx)(f.W,{"data-slot":"popover-trigger",...a})}function n({className:a,positionerClassName:b,align:c="center",alignOffset:e=0,side:f="bottom",sideOffset:j=4,finalFocus:l=!1,...m}){return(0,d.jsx)(g.i,{children:(0,d.jsx)(h.U,{align:c,alignOffset:e,side:f,sideOffset:j,className:(0,k.cn)("isolate z-50",b),children:(0,d.jsx)(i.i,{"data-slot":"popover-content",finalFocus:l,className:(0,k.cn)("z-50 flex w-80 max-w-[calc(100vw-2rem)] origin-(--transform-origin) flex-col gap-3 rounded-lg border border-border bg-popover p-3 text-sm text-popover-foreground shadow-md outline-hidden duration-100 motion-reduce:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",a),...m})})})}function o({className:a,...b}){return(0,d.jsx)(j.e,{"data-slot":"popover-title",className:(0,k.cn)("font-medium",a),...b})}},45427:(a,b,c)=>{"use strict";c.d(b,{n:()=>m});var d=c(52834),e=c(19480),f=c(36331),g=c(49147),h=c(38684),i=c(53437),j=c(6995),k=c.n(j);let l={cjk:e.h,code:f.a},m=(0,g.memo)(function({content:a,label:b,savedScrollTop:c,onScroll:e}){let f=(0,g.useRef)(null),j=(0,g.useRef)(c);return(0,g.useLayoutEffect)(()=>{f.current&&(f.current.scrollTop=j.current)},[]),(0,d.jsx)("div",{ref:f,"data-testid":"markdown-preview",role:"region","aria-label":b,tabIndex:0,className:"h-full min-h-0 overflow-auto overscroll-contain bg-background outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onScroll:a=>e(a.currentTarget.scrollTop),children:(0,d.jsx)(h.jH,{className:`${k().document} ${i.om}`,allowedTags:i.IV,components:i.e6,remarkPlugins:i.XC,mode:"static",parseIncompleteMarkdown:!1,isAnimating:!1,controls:!1,lineNumbers:!1,plugins:l,children:a})})})},45694:(a,b,c)=>{"use strict";c.d(b,{z:()=>e});let d=`<script>
2
2
  window.addEventListener('keydown', function (event) {
3
3
  if (event.defaultPrevented || event.isComposing || event.repeat) return;
4
4
  if (event.key === 'Escape' && !event.ctrlKey && !event.altKey && !event.metaKey && !event.shiftKey) {
@@ -10,6 +10,6 @@ window.addEventListener('keydown', function (event) {
10
10
  }
11
11
  });
12
12
  </script>`;function e(a){return`${a}
13
- ${d}`}},45741:(a,b,c)=>{"use strict";c.d(b,{F:()=>Z});var d=c(52834),e=c(3935),f=c(22232),g=c(83401),h=c(97586),i=c(85278),j=c(90814),k=c(37496),l=c(26890),m=c(75152),n=c(35385),o=c(63155),p=c(41568),q=c(49147),r=c(57850),s=c(53403),t=c(4998),u=c(15620),v=c(82563),w=c(9365);let x=(0,q.createContext)({expandedPaths:new Set,togglePath:()=>{}}),y=({expanded:a,defaultExpanded:b=new Set,selectedPath:c,onSelect:e,onExpandedChange:f,className:g,children:h,...i})=>{let[j,k]=(0,q.useState)(b),l=a??j,m=(0,q.useCallback)(a=>{let b=new Set(l);b.has(a)?b.delete(a):b.add(a),k(b),f?.(b)},[l,f]),n=(0,q.useMemo)(()=>({expandedPaths:l,onSelect:e,selectedPath:c,togglePath:m}),[l,e,c,m]);return(0,d.jsx)(x.Provider,{value:n,children:(0,d.jsx)("div",{className:(0,u.cn)("rounded-lg border bg-background font-sans text-sm",g),role:"tree",...i,children:(0,d.jsx)("div",{className:"p-2",children:h})})})},z=({className:a,children:b,...c})=>(0,d.jsx)("span",{className:(0,u.cn)("shrink-0",a),...c,children:b}),A=({className:a,children:b,...c})=>(0,d.jsx)("span",{className:(0,u.cn)("truncate",a),...c,children:b}),B=(0,q.createContext)({isExpanded:!1,name:"",path:""}),C=({path:a,name:b,className:c,children:e,...f})=>{let{expandedPaths:g,togglePath:h,selectedPath:i,onSelect:j}=(0,q.useContext)(x),l=g.has(a),n=i===a,o=(0,q.useCallback)(()=>{h(a)},[h,a]),p=(0,q.useCallback)(()=>{j?.(a)},[j,a]),r=(0,q.useMemo)(()=>({isExpanded:l,name:b,path:a}),[l,b,a]);return(0,d.jsx)(B.Provider,{value:r,children:(0,d.jsx)(v.Nt,{onOpenChange:o,open:l,children:(0,d.jsxs)("div",{className:(0,u.cn)("",c),role:"treeitem","aria-expanded":l,"aria-selected":n,tabIndex:0,...f,children:[(0,d.jsxs)("div",{className:(0,u.cn)("flex min-h-9 w-full items-center gap-2 rounded-md px-2 py-1 text-left transition-colors hover:bg-foreground/8",n&&"bg-accent"),children:[(0,d.jsx)(v.R6,{render:(0,d.jsx)("button",{className:"flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md border-none bg-transparent p-0 outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":`${l?"收起":"展开"} ${b}`,type:"button"}),children:(0,d.jsx)(k.A,{className:(0,u.cn)("size-4 shrink-0 text-muted-foreground transition-transform",l&&"rotate-90")})}),(0,d.jsxs)("button",{className:"flex min-h-7 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md border-none bg-transparent p-0 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:p,type:"button",children:[(0,d.jsx)(z,{children:l?(0,d.jsx)(w.A,{className:"size-4 text-muted-foreground"}):(0,d.jsx)(m.A,{className:"size-4 text-muted-foreground"})}),(0,d.jsx)(A,{children:b})]})]}),(0,d.jsx)(v.Ke,{children:(0,d.jsx)("div",{className:"ml-4 border-l pl-2",children:e})})]})})})},D=(0,q.createContext)({name:"",path:""}),E=({path:a,name:b,icon:c,className:e,children:f,...g})=>{let{selectedPath:h,onSelect:j}=(0,q.useContext)(x),k=h===a,l=(0,q.useCallback)(()=>{j?.(a)},[j,a]),m=(0,q.useCallback)(b=>{("Enter"===b.key||" "===b.key)&&j?.(a)},[j,a]),n=(0,q.useMemo)(()=>({name:b,path:a}),[b,a]);return(0,d.jsx)(D.Provider,{value:n,children:(0,d.jsx)("div",{className:(0,u.cn)("flex min-h-9 cursor-pointer items-center gap-2 rounded-md px-2 py-1 outline-none transition-colors hover:bg-foreground/8 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",k&&"bg-accent",e),onClick:l,onKeyDown:m,role:"treeitem","aria-selected":k,tabIndex:0,...g,children:f??(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"size-6 shrink-0"}),(0,d.jsx)(z,{children:c??(0,d.jsx)(i.A,{className:"size-4 text-muted-foreground"})}),(0,d.jsx)(A,{children:b})]})})})};var F=c(5701),G=c(5319),H=c(32772),I=c(89101),J=c(59582);let K=["all","files","content"],L=[{key:"caseSensitive",label:"searchCaseSensitive",text:"Aa"},{key:"wholeWord",label:"searchWholeWord",text:"Ab"},{key:"regex",label:"searchRegex",text:".*"}];function M({input:a,inputRef:b,invalid:c,onQueryChange:e,onOptionsChange:f,onComposingChange:g,onClose:h,onOpenFirst:i,onFocusResults:j}){let{t:k}=(0,r.Bd)("projectFiles"),[l,m]=(0,q.useState)(null),n=(0,q.useRef)(!1),o=k("files"===a.scope?"searchFiles":"content"===a.scope?"searchContent":"searchAll");return(0,d.jsxs)("div",{className:"shrink-0 px-1 pt-1",children:[(0,d.jsxs)(I.MG,{className:"rounded-md",children:[(0,d.jsx)(I.Sq,{className:"pl-1.5 py-0",children:(0,d.jsx)(p.A,{className:"size-3.5"})}),(0,d.jsx)(I.iV,{ref:b,"data-testid":"project-file-search",className:"min-h-7 min-w-0 px-1.5 py-0.5 text-sm placeholder:text-xs",value:l??a.query,placeholder:o,"aria-label":o,"aria-invalid":c||void 0,autoComplete:"off",spellCheck:!1,onChange:a=>{n.current?m(a.target.value):e(a.target.value)},onCompositionStart:a=>{n.current=!0,m(a.currentTarget.value),g(!0)},onCompositionEnd:a=>{n.current=!1,m(null),e(a.currentTarget.value),g(!1)},onKeyDown:a=>{a.nativeEvent.isComposing||n.current||("Enter"===a.key?(a.preventDefault(),i()):"ArrowDown"===a.key&&(a.preventDefault(),j()))}}),(0,d.jsx)(I.Sq,{align:"inline-end",className:"pr-0.5 py-0 has-[>button]:mr-0",children:(0,d.jsxs)(J.m_,{children:[(0,d.jsx)(J.k$,{render:(0,d.jsx)(I.Ik,{size:"icon-xs",className:"min-h-7","aria-label":k("closeSearch"),onClick:h}),children:(0,d.jsx)(H.A,{className:"size-4"})}),(0,d.jsx)(J.ZI,{children:k("closeSearch")})]})})]}),(0,d.jsxs)("div",{className:"flex min-h-7 flex-wrap items-center justify-between gap-x-1",children:[(0,d.jsx)("div",{className:"flex min-w-0 items-center",role:"radiogroup","aria-label":k("searchScope"),children:K.map((b,c)=>(0,d.jsx)(G.$,{type:"button",role:"radio","aria-checked":a.scope===b,tabIndex:a.scope===b?0:-1,disabled:null!==l,variant:"ghost",size:"sm","data-testid":`project-search-scope-${b}`,className:(0,u.cn)("px-1 text-xs",a.scope===b&&"bg-accent text-accent-foreground"),onClick:()=>f({scope:b}),onKeyDown:a=>{let b="ArrowRight"===a.key||"ArrowDown"===a.key,d="ArrowLeft"===a.key||"ArrowUp"===a.key;if(!b&&!d&&"Home"!==a.key&&"End"!==a.key)return;a.preventDefault();let e="Home"===a.key?0:"End"===a.key?2:(c+(b?1:2))%3;f({scope:K[e]}),a.currentTarget.parentElement?.querySelectorAll('[role="radio"]')[e]?.focus()},children:k("all"===b?"searchScopeAll":"files"===b?"searchScopeFiles":"searchScopeContent")},b))}),(0,d.jsx)("div",{className:"ml-auto flex items-center",children:L.map(({key:b,label:c,text:e})=>(0,d.jsxs)(J.m_,{children:[(0,d.jsx)(J.k$,{render:(0,d.jsx)(G.$,{type:"button",variant:"ghost",size:"icon-sm",disabled:null!==l,"aria-label":k(c),"aria-pressed":a[b],"data-testid":`project-search-option-${b}`,className:(0,u.cn)("font-mono text-xs text-muted-foreground","wholeWord"===b&&"underline underline-offset-4"),onClick:()=>f({[b]:!a[b]})}),children:e}),(0,d.jsx)(J.ZI,{children:k(c)})]},b))})]})]})}function N(a,b,c=0){let e=[],f=0;for(let g of b){let b=Math.max(f,g.start-c,0),h=Math.min(g.end-c,a.length);h<=b||(e.push(a.slice(f,b)),e.push((0,d.jsx)("mark",{className:"rounded-sm bg-foreground/15 text-inherit",children:a.slice(b,h)},`${b}:${h}`)),f=h)}return e.push(a.slice(f)),e}function O({search:a,resultsRef:b,activePath:c,onOpen:e,wrapFile:f,renderFileIcon:g,fileDecoration:h}){let{t:l}=(0,r.Bd)("projectFiles"),m=(0,q.useId)(),[n,o]=(0,q.useState)(!1),[s,t]=(0,q.useState)(new Set),[v,w]=(0,q.useState)(null),x=new Map;for(let b of a.contentMatches){let a=x.get(b.path);a?a.push(b):x.set(b.path,[b])}let y=!!a.query.trim(),z=y&&"ready"===a.status,A=a.fileMatches.length,B=a.contentMatches.length,C="all"===a.scope&&A>3&&B>0&&!n,D=C?a.fileMatches.slice(0,3):a.fileMatches,E=l("searchCounts",{files:new Set([...a.fileMatches.map(a=>a.path),...x.keys()]).size,lines:B}),H=a=>{t(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})};return(0,d.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,d.jsxs)("div",{className:"flex min-h-6 flex-wrap items-center justify-between gap-x-2 px-2 text-xs text-muted-foreground",role:"status","aria-live":"polite",children:[(0,d.jsx)("span",{children:l("searchResults")}),z?(0,d.jsx)("span",{className:"tabular-nums",children:a.truncated?l("searchShownCounts",{counts:E}):E}):null]}),(0,d.jsx)(F.V,{className:"min-h-0 flex-1",viewportClassName:"pb-2",children:(0,d.jsx)("div",{ref:b,role:"region","aria-label":l("searchResults"),"aria-busy":y&&"loading"===a.status,onKeyDown:a=>{if("ArrowDown"!==a.key&&"ArrowUp"!==a.key&&"Home"!==a.key&&"End"!==a.key)return;let b=[...a.currentTarget.querySelectorAll("button")].filter(a=>!a.disabled&&!a.closest("[hidden]")),c=b.indexOf(document.activeElement);if(c<0)return;a.preventDefault();let d="Home"===a.key?0:"End"===a.key?b.length-1:Math.max(0,Math.min(b.length-1,c+("ArrowDown"===a.key?1:-1)));b[d]?.focus()},children:y?"loading"===a.status?(0,d.jsxs)("div",{className:"flex min-h-10 items-center gap-2 px-3 text-xs text-muted-foreground",children:[(0,d.jsx)(j.A,{className:"size-3.5 animate-spin"}),l("searching")]}):"error"===a.status?(0,d.jsx)("p",{role:"alert",className:"mx-3 my-2 break-words rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:a.error||l("searchFailed")}):z&&0===A&&0===B?(0,d.jsxs)("div",{className:"px-5 py-9 text-center text-sm text-muted-foreground",children:[(0,d.jsx)(p.A,{className:"mx-auto mb-3 size-6"}),(0,d.jsx)("p",{children:l(a.truncated?"resultLimit":"noMatches")}),(0,d.jsx)("p",{className:"mt-2 text-xs",children:l("searchTryOptions")})]}):z?(0,d.jsxs)(d.Fragment,{children:[A>0?(0,d.jsxs)("section",{children:["all"===a.scope?(0,d.jsxs)("h3",{className:"flex min-h-6 items-center gap-2 px-2 text-xs text-muted-foreground",children:[l("searchFileHeading"),(0,d.jsx)("span",{className:"tabular-nums",children:A})]}):null,D.map(({path:a,ranges:b})=>{let i=a.lastIndexOf("/"),j=h(a);return f(a,void 0,(0,d.jsxs)(G.$,{type:"button",variant:"ghost","data-testid":`project-search-result-${a}`,"data-search-result":"true",className:(0,u.cn)("mx-1 flex min-h-6 w-[calc(100%-0.5rem)] justify-start gap-1 px-1 py-0 text-left font-normal [@media(pointer:coarse)]:min-h-9",c===a&&"bg-accent"),title:a,onClick:()=>e(a),children:[(0,d.jsx)("span",{className:"shrink-0",children:g(a)}),(0,d.jsxs)("span",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[(0,d.jsx)("span",{className:(0,u.cn)("truncate text-sm",j.className),children:N(a.slice(i+1),b,i+1)}),i>=0?(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:N(a.slice(0,i),b)}):null]}),j.badge?(0,d.jsx)("span",{className:(0,u.cn)("text-xs",j.className),"aria-label":l("gitStatus",{status:j.badge}),children:j.badge}):null]},a))}),C?(0,d.jsx)(G.$,{type:"button",variant:"ghost",size:"sm",className:"ml-5 min-h-6 py-0 text-xs text-muted-foreground [@media(pointer:coarse)]:min-h-9",onClick:()=>o(!0),children:l("searchExpandFiles",{count:A-3})}):null]}):null,B>0?(0,d.jsxs)("section",{className:(0,u.cn)(A>0&&"mt-1"),children:["all"===a.scope?(0,d.jsxs)("h3",{className:"flex min-h-6 flex-wrap items-center gap-x-2 px-2 text-xs text-muted-foreground",children:[l("searchContentHeading"),(0,d.jsx)("span",{children:l("searchContentCounts",{lines:B,files:x.size})})]}):null,[...x].map(([a,b],c)=>{let g=a.lastIndexOf("/"),h=!s.has(a),j=`${m}-${c}`;return(0,d.jsxs)("section",{className:"mb-1",children:[(0,d.jsxs)(G.$,{type:"button",variant:"ghost",className:"min-h-6 w-full justify-start gap-1 rounded-none px-2 py-0 text-left font-normal [@media(pointer:coarse)]:min-h-9",title:a,"aria-expanded":h,"aria-controls":j,onClick:()=>H(a),onKeyDown:b=>{("ArrowLeft"===b.key&&h||"ArrowRight"===b.key&&!h)&&(b.preventDefault(),H(a))},children:[(0,d.jsx)(k.A,{className:(0,u.cn)("size-3 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none",h&&"rotate-90")}),(0,d.jsx)(i.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,d.jsxs)("span",{className:"min-w-0 truncate text-sm",children:[a.slice(g+1),(0,d.jsx)("span",{className:"ml-1.5 text-xs text-muted-foreground",children:a.slice(0,Math.max(0,g))})]}),(0,d.jsx)("span",{className:"ml-auto shrink-0 rounded bg-muted px-1 text-xs text-muted-foreground tabular-nums",children:b.length})]}),(0,d.jsx)("div",{id:j,hidden:!h,children:b.map(({line:b,text:c,ranges:g})=>f(a,b,(0,d.jsxs)(G.$,{type:"button",variant:"ghost","data-testid":`project-search-line-${a}-${b}`,"data-search-result":"true",className:(0,u.cn)("min-h-6 w-full justify-start gap-1 rounded-none border-l-2 border-transparent py-0 pr-2 pl-5 text-left font-mono font-normal [@media(pointer:coarse)]:min-h-9",v?.path===a&&v.line===b&&"border-l-foreground/50 bg-accent"),title:c,"aria-label":l("searchOpenLine",{path:a,line:b}),onClick:()=>{w({path:a,line:b}),e(a,b)},children:[(0,d.jsx)("span",{className:"min-w-5 shrink-0 text-right text-xs text-muted-foreground tabular-nums",children:b}),(0,d.jsx)("span",{className:"min-w-0 truncate whitespace-pre text-sm",children:N(c,g)})]},`${a}:${b}`)))})]},a)})]}):null,a.truncated?(0,d.jsx)("p",{className:"px-3 py-2 text-xs leading-5 text-muted-foreground",children:l("resultLimit")}):null]}):null:(0,d.jsxs)("div",{className:"px-5 py-9 text-center text-sm text-muted-foreground",children:[(0,d.jsx)(p.A,{className:"mx-auto mb-3 size-6"}),(0,d.jsx)("p",{children:l("searchStart")}),(0,d.jsx)("p",{className:"mt-2 text-xs",children:l("files"===a.scope?"searchFiles":"content"===a.scope?"searchContent":"searchAll")})]})})}),"files"!==a.scope?(0,d.jsx)("p",{className:"shrink-0 px-2 py-1 text-xs leading-5 text-muted-foreground",children:l("searchTextLimit")}):null]})}var P=c(49057),Q=c(51108),R=c(57396),S=c.n(R),T=c(83731);let U=[],V=new WeakMap;function W(a){let b=a.split("/").at(-1)?.toLocaleLowerCase()??"",c=b.includes(".")?b.split(".").at(-1)??"":"";return["png","jpg","jpeg","webp","gif"].includes(c)?(0,d.jsx)(e.A,{className:"size-4 text-muted-foreground"}):"json"===c||"jsonl"===c?(0,d.jsx)(f.A,{className:"size-4 text-muted-foreground"}):["md","mdx","txt"].includes(c)?(0,d.jsx)(g.A,{className:"size-4 text-muted-foreground"}):["ts","tsx","js","jsx","mjs","cjs","py","go","rs","java","c","cpp","h","hpp","css","scss","html","xml","yaml","yml","toml","sql","sh"].includes(c)?(0,d.jsx)(h.A,{className:"size-4 text-muted-foreground"}):(0,d.jsx)(i.A,{className:"size-4 text-muted-foreground"})}function X(a){if(a)return(0,P.iH)(a.change)}function Y({state:a,onRetry:b}){let{t:c}=(0,r.Bd)("projectFiles");return a&&"idle"!==a.status&&"loading"!==a.status?"error"!==a.status?null:(0,d.jsx)("button",{type:"button",onClick:b,className:"min-h-8 w-full rounded px-2 text-left text-xs text-destructive hover:bg-destructive/10",children:c("retryReading",{error:a.error})}):(0,d.jsxs)("div",{className:"flex min-h-8 items-center gap-2 px-2 text-xs text-muted-foreground",children:[(0,d.jsx)(j.A,{className:"size-3.5 animate-spin"})," ",c("reading")]})}function Z({cwd:a,projectName:b,runtime:c,gitRuntime:e,onOpenGitBranches:f,onFileOpened:g,rootTitle:h,showRootTitle:i=!0,gitReadOnly:j=!1}){let v,w,x,{t:B}=(0,r.Bd)("projectFiles"),{locale:D}=(0,t.i)();(0,q.useSyncExternalStore)(c.subscribe,c.getRevision,c.getRevision),(0,q.useSyncExternalStore)(e.subscribe,e.getRevision,e.getRevision);let H=c.state,I=e.getWorkspace(a),J=(0,q.useRef)(null),K=(0,q.useRef)(null),L=(0,q.useRef)(null),N=(0,q.useRef)(null),[R,$]=(0,q.useState)(!1),_=(0,q.useRef)({}),aa=(0,q.useCallback)(a=>{a?V.set(c,_.current):V.get(c)===_.current&&V.delete(c),$(a)},[c]),ab=H.searchOpen,ac=()=>{$(!1),c.setSearchOpen(!1),requestAnimationFrame(()=>N.current?.focus())},[ad,ae]=(0,q.useState)({}),af=(a,b)=>{let c=ad[a]??300;return c<b?(0,d.jsx)("button",{type:"button",className:"min-h-8 px-3 text-sm text-muted-foreground hover:bg-accent",onClick:b=>{b.stopPropagation(),ae(b=>({...b,[a]:c+300}))},children:B("showMore",{visible:c,total:b})}):null};H?.search.query;let ag=I?.snapshot.repositories??U,ah=(0,P.eP)(ag),ai=new Map(ah.map(a=>[a.projectPath,a])),aj=ag.map(a=>a.root).filter(Boolean);[...I?.expandedRepositories??[]].join("\0");let ak=new Set(aj),al=new Map,am=new Set([...H.expandedPaths].map(a=>(0,T.Im)("directory",a))),an=(a,b)=>{let d=new Set(H.expandedPaths);for(let c of a.paths)b?d.add(c):d.delete(c);c.setExpandedPaths(d,!1),b&&!I?.changesOnly&&c.expandDirectoryChain(a.path,ak)},ao=a=>{for(let[b,c]of[...al].filter(([b])=>a.has((0,T.Im)("directory",b))!==H.expandedPaths.has(b)))an(c,a.has((0,T.Im)("directory",b)))},ap=(a,b)=>{c.openFile(a,b),g?.()},aq=a=>{c.openDiff(a.repositoryRoot,a.path),g?.()},ar=(b,e)=>(0,d.jsx)(Q.J,{cwd:a,path:b.targetPath,type:"directory",trigger:e,expanded:H.expandedPaths.has(b.path),onToggle:()=>an(b,!H.expandedPaths.has(b.path)),onReveal:c.canReveal?(a,b)=>c.revealFile(a,b):void 0},(0,T.Im)("directory",b.path)),as=(b,e,f=null,g=!1,h)=>(0,d.jsx)(Q.J,{cwd:a,path:b,type:"file",trigger:e,openLabel:B(g?"viewDiff":"openPreview"),onOpen:()=>g&&f?aq(f):ap(b,h),oldPath:f?.change.oldPath?(0,T._J)(f.repositoryRoot,f.change.oldPath):void 0,onReveal:c.canReveal?(a,b)=>c.revealFile(a,b):void 0},void 0===h?(0,T.Im)("file",b):`${b}:${h}`),at=(a,b,c,e)=>as(a,(0,d.jsxs)(E,{path:(0,T.Im)("file",a),name:b,title:a,"data-testid":`project-file-${a}`,onClick:()=>{e&&c?aq(c):ap(a)},children:[(0,d.jsx)("span",{className:"size-6 shrink-0"}),(0,d.jsx)(z,{children:W(a)}),(0,d.jsx)(A,{"data-testid":`project-file-name-${a}`,className:(0,u.cn)("min-w-0 flex-1",X(c)),children:b}),c?(0,d.jsx)("span",{className:(0,u.cn)("text-xs tabular-nums",X(c)),"aria-label":B("gitStatus",{status:(0,P.XB)(c.change)}),children:(0,P.XB)(c.change)}):null]}),c,e),au=(a,b,e)=>{let f=H?.directories.get(a);if(f?.status!=="ready")return(0,d.jsx)(Y,{state:f,onRetry:()=>void c.ensureDirectory(a)});let g=e?f.entries.filter(c=>{let d;return d=(0,T._J)(a,c.name),!aj.some(a=>a!==b&&d===a)}):f.entries;return(0,d.jsxs)(d.Fragment,{children:[g.slice(0,ad[`directory:${a}`]??300).map(f=>{let g=(0,T._J)(a,f.name);if("file"===f.type)return at(g,f.name,ai.get(g)??null,!1);let h=c.compactDirectory(g,ak);return al.set(g,h),ar(h,(0,d.jsx)(C,{path:(0,T.Im)("directory",g),name:h.label,title:h.targetPath,"data-testid":`project-folder-${g}`,children:au(h.targetPath,b,e)}))}),af(`directory:${a}`,g.length),f.truncated?(0,d.jsx)("p",{className:"px-2 py-2 text-xs leading-5 text-amber-600 dark:text-amber-400",children:B("directoryLimit")}):null,0===g.length?(0,d.jsx)("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:B("emptyDirectory")}):null]})},av=(a,b)=>{let c=a.get(b);if(!c)return null;let e=[...c.directories.keys()].sort(T.Kn),f=[...c.files].sort(T.Kn),g=ad[`changes:${b}`]??300;return(0,d.jsxs)(d.Fragment,{children:[e.slice(0,g).map(b=>{let c=(0,T.xV)(b,a,ak);return al.set(b,c),ar(c,(0,d.jsx)(C,{path:(0,T.Im)("directory",b),name:c.label,title:c.targetPath,"data-testid":`project-folder-${b}`,children:av(a,c.targetPath)}))}),f.slice(0,Math.max(0,g-e.length)).map(a=>at(a,a.slice(a.lastIndexOf("/")+1),ai.get(a)??null,!0)),af(`changes:${b}`,e.length+f.length)]})},aw=a=>{if(a.startsWith("directory:")){let b=al.get(a.slice(10));b&&an(b,!H.expandedPaths.has(b.path));return}let b=a.slice(5),c=ai.get(b);I?.changesOnly&&c?aq(c):ap(b)},ax=(g,h,i)=>{if(I?.changesOnly&&!g)return null;let o=I?.expandedRepositories.has(h)??!1,p=g?.state==="ready"?ah.filter(a=>a.repositoryRoot===h):[],q=p.length;if(I?.changesOnly&&g?.state==="ready"&&0===q)return null;let r=(0,T.OA)(p.map(a=>a.projectPath),h);return(0,d.jsxs)("section",{"data-testid":`project-git-repository-${h||"root"}`,className:"border-b last:border-b-0",children:[(0,d.jsxs)("div",{className:"flex min-h-8 items-center gap-1 px-1 py-0.5",children:[(0,d.jsxs)("button",{"data-testid":`project-git-repository-toggle-${h||"root"}`,type:"button",className:"flex min-w-0 flex-1 items-center gap-1 rounded-md px-1 py-0.5 text-left hover:bg-muted/60","aria-expanded":o,onClick:()=>{o&&c.cancelDirectoryExpansion(h),e.toggleRepository(a,h),o||c.ensureDirectory(h)},children:[(0,d.jsx)(k.A,{className:(0,u.cn)("size-3 shrink-0 text-muted-foreground transition-transform",o&&"rotate-90")}),g?(0,d.jsx)(l.A,{className:"size-4 shrink-0 text-muted-foreground"}):(0,d.jsx)(m.A,{className:"size-4 shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:g&&h||b,children:i})]}),g?(0,d.jsxs)("button",{"data-testid":`project-git-branch-${h||"root"}`,type:"button",disabled:j||"ready"!==g.state,className:(0,u.cn)((0,G.r)({variant:"ghost",size:"sm"}),"max-w-28 shrink gap-1 font-mono text-xs text-muted-foreground"),title:"ready"===g.state?B(j?"gitBranchReadOnly":"gitBranches"):(0,s.fD)(g.message,D),"aria-label":B(j?"gitBranchReadOnly":"gitBranches"),onClick:()=>f(h),children:[(0,d.jsx)(n.A,{className:"size-3 shrink-0"}),(0,d.jsx)("span",{className:"min-w-0 truncate",children:"ready"===g.state?(0,P.ws)(g.head):B("unavailable")}),q>0?(0,d.jsx)("span",{className:"rounded-md bg-muted px-1 text-xs text-status-warning",children:q}):null]}):null]}),o?I?.changesOnly?(0,d.jsx)(y,{className:"rounded-none border-0 bg-transparent px-1 pb-1",expanded:am,selectedPath:H?.activeDiff?(0,T.Im)("file",(0,P.oW)(H.activeDiff.repositoryRoot,H.activeDiff.path)):void 0,onExpandedChange:ao,onSelect:aw,children:q>0?av(r,h):(0,d.jsx)("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:B("noChanges")})}):(0,d.jsx)(y,{className:"rounded-none border-0 bg-transparent px-1 pb-1",expanded:am,selectedPath:H.activePath?(0,T.Im)("file",H.activePath):void 0,onExpandedChange:ao,onSelect:aw,children:au(h,g?.root??null,!0)}):null]},g?`git:${h}`:"workspace")},ay=1===ag.length&&ag[0]?.root===""?ag[0]:null,az=ag.length>0&&!ay,aA=az?I?.layout??"directory":"directory",aB=ay?(0,d.jsxs)("button",{type:"button",disabled:j||"ready"!==ay.state,className:(0,u.cn)((0,G.r)({variant:"ghost",size:"sm"}),"max-w-32 shrink gap-1 font-mono text-xs text-muted-foreground",!i&&"min-w-0 flex-1 justify-start"),"aria-label":B(j?"gitBranchReadOnly":"gitBranches"),title:"ready"===ay.state?`${B(j?"gitBranchReadOnly":"gitBranches")} \xb7 ${(0,P.ws)(ay.head)}`:(0,s.fD)(ay.message,D),onClick:()=>f(""),children:[(0,d.jsx)(n.A,{className:"size-3 shrink-0"}),(0,d.jsx)("span",{className:"truncate",children:"ready"===ay.state?(0,P.ws)(ay.head):B("unavailable")})]}):null,aC=(0,d.jsxs)("div",{className:"flex min-h-8 min-w-0 flex-wrap items-center gap-x-1 gap-y-0.5 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",tabIndex:i?void 0:0,"aria-label":B("projectFiles",{name:b}),children:[az?(0,d.jsx)("div",{className:"flex shrink-0 gap-0.5",role:"group","aria-label":B("layout"),children:["directory","repository"].map(b=>(0,d.jsx)("button",{"data-testid":`project-file-layout-${b}`,type:"button","aria-pressed":aA===b,className:(0,u.cn)((0,G.r)({variant:"ghost",size:"sm"}),aA===b&&"bg-accent text-accent-foreground"),onClick:()=>{c.cancelDirectoryExpansion(),e.setLayout(a,b)},children:B("directory"===b?"directory":"repository")},b))}):null,ag.length>0?(0,d.jsxs)("button",{"data-testid":"project-git-changes-toggle",type:"button","aria-pressed":I?.changesOnly??!1,className:(0,u.cn)((0,G.r)({variant:"ghost",size:"sm"}),"min-w-0 gap-1",I?.changesOnly&&"bg-accent text-accent-foreground"),onClick:()=>{c.cancelDirectoryExpansion(),e.setChangesOnly(a,!I?.changesOnly)},children:[(0,d.jsx)(o.A,{className:"size-3 shrink-0"}),(0,d.jsx)("span",{className:"truncate",children:B("changesOnly")}),(0,d.jsx)("span",{className:"rounded-md bg-muted px-1 font-mono text-xs",children:ah.length})]}):null,i?null:aB,(0,d.jsx)("button",{ref:N,type:"button",className:(0,u.cn)((0,G.r)({variant:"ghost",size:"icon-sm"}),"ml-auto"),"aria-label":B("searchProject"),title:B("searchProject"),onClick:()=>{c.setSearchOpen(!0),requestAnimationFrame(()=>K.current?.focus())},children:(0,d.jsx)(p.A,{className:"size-3.5"})})]});return(0,d.jsxs)("section",{className:"flex h-full min-h-0 flex-col bg-sidebar","aria-label":B("projectFiles",{name:b}),onKeyDown:a=>{!ab||"Escape"!==a.key||(a.stopPropagation(),a.nativeEvent.isComposing||R||(a.preventDefault(),ac()))},children:[ab?(0,d.jsx)(M,{input:H.search,inputRef:K,invalid:"error"===H.search.status,onQueryChange:a=>c.setSearchQuery(a),onOptionsChange:a=>c.setSearchOptions(a),onComposingChange:aa,onClose:ac,onOpenFirst:()=>{let a=c.state.search;if("ready"!==a.status)return;let b=a.fileMatches[0],d=a.contentMatches[0];b?ap(b.path):d&&ap(d.path,d.line)},onFocusResults:()=>L.current?.querySelector("button")?.focus()}):(0,d.jsxs)("div",{className:"border-b px-1",children:[i?(0,d.jsxs)("div",{className:"flex min-h-7 min-w-0 items-center gap-1",children:[(0,d.jsx)(Q.J,{cwd:a,path:"",type:"directory",onReveal:c.canReveal?(a,b)=>c.revealFile(a,b):void 0,trigger:h?(0,d.jsx)("div",{className:"flex min-w-0 flex-1",children:h}):(0,d.jsxs)("div",{tabIndex:0,className:"flex min-w-0 flex-1 items-baseline gap-1",children:[(0,d.jsx)("p",{className:"shrink-0 truncate text-xs font-semibold",title:b,children:b}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"\xb7"}),(0,d.jsx)("p",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",title:a,children:(v=a.replaceAll("\\","/").split("/").filter(Boolean)).length<=2?a:`…/${v.slice(-2).join("/")}`})]})}),aB]}):null,i?aC:(0,d.jsx)(Q.J,{cwd:a,path:"",type:"directory",onReveal:c.canReveal?(a,b)=>c.revealFile(a,b):void 0,trigger:aC})]}),ab?(0,d.jsx)(O,{search:H.search,resultsRef:L,activePath:H.activeDiff?null:H.activePath,onOpen:ap,wrapFile:(a,b,c)=>as(a,c,ai.get(a)??null,!1,b),renderFileIcon:W,fileDecoration:a=>{let b=ai.get(a)??null;return{className:X(b),badge:b?(0,P.XB)(b.change):void 0}}},JSON.stringify([H.search.query,H.search.scope,H.search.caseSensitive,H.search.wholeWord,H.search.regex])):(0,d.jsxs)(F.V,{className:(0,u.cn)(S().tree,"min-h-0 flex-1"),viewportClassName:"py-0.5",viewportRef:J,onViewportScroll:a=>c.setTreeScrollTop(a.currentTarget.scrollTop),children:[ag.filter(a=>"unavailable"===a.state).map(a=>"unavailable"===a.state?(0,d.jsxs)("p",{role:"alert",className:"mx-2 mb-1 break-words rounded-md bg-muted px-2 py-2 text-sm text-destructive",children:[a.root||b,":",(0,s.fD)(a.message,D)]},a.root):null),I?.snapshot.status==="error"?(0,d.jsx)("p",{className:"mx-2 mb-1 rounded-md bg-muted px-2 py-2 text-sm text-destructive",children:I.snapshot.error}):null,"repository"===aA?(w=ag.some(a=>""===a.root),x=I?.changesOnly?ag.filter(a=>"unavailable"===a.state||a.changes.length>0):ag,(0,d.jsxs)("div",{className:"px-1",children:[w?null:ax(null,"",b),x.map(a=>ax(a,a.root,(0,P.Hj)(b,a.root))),I?.changesOnly&&0===x.length?(0,d.jsx)("p",{className:"px-2 py-5 text-center text-xs text-muted-foreground",children:B("noChangedFiles")}):null]})):(()=>{if(I?.changesOnly){let a=(0,T.OA)(ah.map(a=>a.projectPath));return(0,d.jsx)(y,{className:"rounded-none border-0 bg-transparent",expanded:am,selectedPath:H?.activeDiff?(0,T.Im)("file",(0,P.oW)(H.activeDiff.repositoryRoot,H.activeDiff.path)):H.activePath?(0,T.Im)("file",H.activePath):void 0,onExpandedChange:ao,onSelect:aw,children:ah.length>0?av(a,""):(0,d.jsx)("p",{className:"px-2 py-5 text-center text-xs text-muted-foreground",children:ag.some(a=>"unavailable"===a.state)?B("incompleteRepository"):B("noChangedFiles")})})}return(0,d.jsx)(y,{className:"rounded-none border-0 bg-transparent",expanded:am,selectedPath:H.activePath?(0,T.Im)("file",H.activePath):void 0,onExpandedChange:ao,onSelect:aw,children:au("",null,!1)})})()]})]})}},49057:(a,b,c)=>{"use strict";c.d(b,{A_:()=>k,Hj:()=>i,XB:()=>l,eP:()=>o,iH:()=>m,lN:()=>n,oW:()=>h,oY:()=>g,ws:()=>j});var d=c(53403),e=c(89172),f=c(83731);function g(a){let b=new Map;for(let c of a){let a=c.split("/").filter(Boolean),d=b,e="";for(let[b,f]of a.entries()){e=e?`${e}/${f}`:f;let g=d.get(f);g||(g={name:f,path:e,branchName:null,children:new Map},d.set(f,g)),b===a.length-1&&(g.branchName=c),d=g.children}}return function a(b){return[...b].sort((a,b)=>a.name.localeCompare(b.name,void 0,{numeric:!0,sensitivity:"base"})).map(b=>({name:b.name,path:b.path,branchName:b.branchName,children:a(b.children.values())}))}(b.values())}function h(a,b){return(0,f._J)(a,b)}function i(a,b){return b.split("/").at(-1)||a}function j(a){return"branch"===a.type?a.name:`@ ${a.commit.slice(0,7)}`}function k(a,b,c="en"){if(0===b.length)return null;let f=e.C[c];if(1===b.length){let e=b[0],g=i(a,e.root);if("unavailable"===e.state){let a=f.gitUnavailable;return{full:e.root?`${g} \xb7 ${a}`:a,compact:"Git !",title:`${g}${"en"===c?": ":":"}${(0,d.fD)(e.message,c)}`,diverged:!0}}let h=j(e.head);return{full:e.root?`${g} \xb7 ${h}`:h,compact:h,title:`${f.gitBranches}: ${g} \xb7 ${h}`,diverged:"detached"===e.head.type}}let g=`${b.length} ${f.repositoriesUnit}`;return{full:g,compact:`Git ${b.length}`,title:`${f.gitBranches}: ${g}`,diverged:!1}}function l(a){let b=[a.indexStatus,a.worktreeStatus];return b.includes("unmerged")?"!":b.includes("deleted")?"D":b.includes("renamed")?"R":b.includes("added")?"A":b.includes("modified")?"M":"?"}function m(a){let b=l(a);return"D"===b?"text-muted-foreground":"?"===b?"text-red-600 dark:text-red-400":"A"===b?"text-emerald-600 dark:text-emerald-400":"!"===b?"text-violet-600 dark:text-violet-400":"text-blue-600 dark:text-blue-400"}function n(a,b,c){if(/^(?:[a-z]:|\/|\\\\)/i.test(b))return null;let d=/^[a-z]:[\\/]/i.test(a)||a.startsWith("\\\\"),e=a=>d?a.toLowerCase():a,f=[...c].sort((a,b)=>b.root.length-a.root.length).find(a=>!a.root||e(b).startsWith(`${e(a.root)}/`));if(!f)return null;let g=f.root?b.slice(f.root.length+1):b;return{repository:f,path:g,change:"ready"===f.state?f.changes.find(a=>e(a.path)===e(g)):void 0}}function o(a){return a.flatMap(a=>"ready"===a.state?a.changes.map(b=>({repositoryRoot:a.root,repository:a,path:b.path,projectPath:h(a.root,b.path),change:b})):[])}},51108:(a,b,c)=>{"use strict";c.d(b,{J:()=>q});var d=c(52834),e=c(97586),f=c(87366),g=c(37496),h=c(9365),i=c(50599),j=c(49147),k=c(57850),l=c(93306),m=c(2719),n=c(91816),o=c(60819),p=c(13749);function q({cwd:a,path:b,type:c,trigger:r,openLabel:s,onOpen:t,expanded:u,onToggle:v,historical:w,oldPath:x,onReveal:y}){let{t:z}=(0,k.Bd)("projectFiles"),A=(0,m.G)(),[B,C]=(0,j.useState)(null),D=B??{cwd:a,path:b,type:c,oldPath:x},E=(0,j.useRef)(!1),F=(0,j.useRef)(""),G="file"===c?"file":"folder",H=a=>{(0,l.x)(a).then(a=>{a?A.success(z("copied")):A.error(z("copyFailed"))})},I=(D.path||D.cwd.replaceAll("\\","/")).split("/").filter(Boolean).at(-1)??D.cwd;return(0,d.jsxs)(n.tz,{onOpenChange:(d,e)=>{C(d?{cwd:a,path:b,type:c,oldPath:x}:null);let f=e.event;d&&("touch"===F.current||"pointerType"in f&&"touch"===f.pointerType||f.type.startsWith("touch"))&&(E.current=!0)},children:[(0,d.jsx)(n.Rc,{render:r,"data-project-path-menu-trigger":"",onPointerDown:a=>{F.current=a.pointerType,E.current=!1},onTouchEndCapture:a=>{let b=a.target;!B||!E.current||"touch"!==F.current||b instanceof Element&&b.closest("[data-project-path-menu-trigger]")===a.currentTarget&&a.cancelable&&a.preventDefault()},onClickCapture:a=>{E.current&&(a.preventDefault(),a.stopPropagation(),E.current=!1)},onKeyDownCapture:a=>{if(a.defaultPrevented||a.nativeEvent.isComposing)return;let b=a.target;if(!(b instanceof Element)||b.closest("[data-project-path-menu-trigger]")!==a.currentTarget||(F.current="keyboard",E.current=!1,"ContextMenu"!==a.key&&!("F10"===a.key&&a.shiftKey)))return;a.preventDefault(),a.stopPropagation();let c=b.getBoundingClientRect();a.currentTarget.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,button:2,clientX:c.left+Math.min(c.width,120)/2,clientY:c.top+Math.min(c.height,36)/2}))}}),(0,d.jsxs)(o.D,{children:[t?(0,d.jsxs)(n.kt,{onClick:t,children:[(0,d.jsx)(e.A,{}),s??z("openPreview")]}):null,v?(0,d.jsxs)(n.kt,{onClick:v,children:[u?(0,d.jsx)(f.A,{}):(0,d.jsx)(g.A,{}),z(u?"collapse":"expand")]}):null,t||v?(0,d.jsx)(n.K5,{}):null,y?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(n.kt,{"data-testid":`project-${G}-reveal-${b}`,onClick:()=>{y&&y(D.path,D.type).then(()=>A.success(z("revealRequested"))).catch(a=>{A.error(a instanceof Error?a.message:z("revealFailed"))})},children:[(0,d.jsx)(h.A,{}),w?"directory"===c?z("openCurrentWorkspace"):z("locateCurrentWorkspace"):"directory"===c?z("openFolder"):z("openContainingFolder")]}),(0,d.jsx)(n.K5,{})]}):null,(0,d.jsxs)(n.kt,{"data-testid":`project-${G}-copy-address-${b}`,onClick:()=>H((0,p.$)(D.cwd,D.path)),children:[(0,d.jsx)(i.A,{}),z("copyAbsolutePath")]}),(0,d.jsxs)(n.kt,{onClick:()=>H(D.path||"."),children:[(0,d.jsx)(i.A,{}),z("copyRelativePath")]}),(0,d.jsxs)(n.kt,{onClick:()=>H(I),children:[(0,d.jsx)(i.A,{}),z("directory"===c?"copyFolderName":"copyFileName")]}),D.oldPath?(0,d.jsxs)(n.kt,{onClick:()=>H(D.oldPath),children:[(0,d.jsx)(i.A,{}),z("copyOldRelativePath")]}):null]})]})}},51949:(a,b,c)=>{"use strict";c.d(b,{CT:()=>n,JH:()=>p,NL:()=>g,Nu:()=>q,_g:()=>k,eC:()=>l,gB:()=>h,ih:()=>v,jI:()=>u,p$:()=>m,rh:()=>j,uV:()=>e,xm:()=>f});var d=c(87883);let e=4096,f=5e3,g=5242880,h=1048576;function i(a,b){return""===a?b:!(a.length>e||a.startsWith("/")||a.includes("\\")||a.includes("\0")||/^[a-zA-Z]:/.test(a))&&a.split("/").every(a=>a.length>0&&"."!==a&&".."!==a)}let j=d.Yj().max(e).refine(a=>i(a,!0),"目录路径必须是规范相对路径"),k=d.Yj().min(1).max(e).refine(a=>i(a,!1),"文件路径必须是规范相对路径"),l=d.Yj().min(1).max(e).refine(a=>i(a,!1)||a.length>0&&a.length<=e&&!a.includes("\0")&&(a.startsWith("/")||a.startsWith("\\\\")||/^[a-zA-Z]:[\\/]/.test(a)),"预览路径必须是规范相对路径或绝对路径"),m=d.k5(["compressed","original"]),n=d.k5(["image/jpeg","image/png","image/webp","image/gif"]),o=d.Ik({name:d.Yj().min(1),type:d.k5(["directory","file"])}).strict(),p=d.Ik({entries:d.YO(o).max(f),truncated:d.zM()}).strict(),q=d.Ik({query:d.Yj().min(1).max(200).refine(a=>a.trim().length>0&&!/[\0\r\n]/.test(a),"搜索词必须是非空单行文本"),scope:d.k5(["all","files","content"]).default("all"),caseSensitive:d.zM().default(!1),wholeWord:d.zM().default(!1),regex:d.zM().default(!1)}).strict(),r=d.Ik({start:d.ai().int().nonnegative(),end:d.ai().int().nonnegative()}).strict().refine(a=>a.start<=a.end,"搜索命中区间无效"),s=d.Ik({path:k,ranges:d.YO(r)}).strict().refine(a=>a.ranges.every(b=>b.end<=a.path.length),"文件名命中区间越界"),t=d.Ik({path:k,line:d.ai().int().positive(),text:d.Yj().max(1e3),ranges:d.YO(r)}).strict().refine(a=>a.ranges.every(b=>b.end<=a.text.length),"正文命中区间越界"),u=d.Ik({fileMatches:d.YO(s).max(100),contentMatches:d.YO(t).max(200),truncated:d.zM()}).strict(),v=d.gM("kind",[d.Ik({kind:d.eu("text"),content:d.Yj(),size:d.ai().int().nonnegative().max(g)}).strict(),d.Ik({kind:d.eu("image"),mimeType:n,data:d.Yj().min(1),size:d.ai().int().positive().max(0xa00000)}).strict()])},51972:(a,b,c)=>{"use strict";function d(a,b,c){a.addCommand(b,c,"editorTextFocus && !findWidgetVisible && !suggestWidgetVisible && !renameInputVisible && !parameterHintsVisible && !referenceSearchVisible && !editorHoverVisible && !editorHoverFocused")}c.d(b,{e:()=>d})},52660:(a,b,c)=>{"use strict";c.d(b,{Wq:()=>g,ku:()=>i,lU:()=>h}),c(51949);let d=new Set,e="compressed";function f(){}function g(){return f(),e}function h(a){if(f(),e!==a){e=a;try{window.localStorage.setItem("pi-super:image-preview-mode",a)}catch{}for(let a of[...d])a()}}function i(a){return d.add(a),()=>d.delete(a)}},53403:(a,b,c)=>{"use strict";c.d(b,{fD:()=>f,qf:()=>e});var d=c(87883);let e=d.KC([d.Yj(),d.Ik({default:d.Yj(),translations:d.g1(d.Yj().min(1).max(35),d.Yj()).refine(a=>Object.keys(a).length<=16,"too many translations")}).strict()]);function f(a,b){return"string"==typeof a?a:a.translations[b]??a.translations[b.split("-")[0]]??a.default}},53437:(a,b,c)=>{"use strict";c.d(b,{IV:()=>o,om:()=>t,e6:()=>v,XC:()=>s});var d=c(52834),e=c(60816),f=c(63345),g=c(98004),h=c(40181),i=c(49028),j=c(21556),k=c(97832),l=c(57850),m=c(38684),n=c(15620);let o={input:["dataPiMarkdownProgress"],blockquote:["dataPiMarkdownAlert"]};function p(a){return{type:"paragraph",children:[],data:{hName:"input",hProperties:{type:"checkbox",disabled:!0,checked:"[x]"===a.toLowerCase(),..."[-]"===a?{dataPiMarkdownProgress:"true"}:{}}}}}var q=c(4935),r=c.n(q);let s=[...Object.values(m.U2),function(){return(a,b)=>{let c=String(b.value),d=(a,b)=>{let d=a.position?.start.offset;return void 0!==d&&c.slice(d,d+b.length)===b},e=a=>{let b=a.children?.[0];if("tableCell"===a.type&&a.children?.length===1&&b?.type==="text"){let c=b.value??"";/^\[[ xX-]\]$/.test(c)&&d(b,c)&&(a.children=[p(c)])}else if("listItem"===a.type&&b?.type==="paragraph"){let c=b.children?.[0];c?.type==="text"&&/^\[-\](?:\s|$)/.test(c.value??"")&&d(c,"[-]")&&(c.value=c.value.slice(3),b.children.unshift(p("[-]")),a.data={...a.data,hProperties:{className:["task-list-item"]}})}else if("blockquote"===a.type&&b?.type==="paragraph"){let c=b.children?.[0],e=c?.value?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\][ \t]*(?:\r?\n|$)/);c?.type==="text"&&e&&d(c,`[!${e[1]}]`)&&(e[0].endsWith("\n")||1===b.children.length||b.children[1]?.type==="break")&&(c.value=c.value.slice(e[0].length),c.value||(b.children.shift(),b.children[0]?.type==="break"&&b.children.shift()),0===b.children.length&&a.children.shift(),a.data={...a.data,hProperties:{dataPiMarkdownAlert:e[1].toLowerCase()}})}for(let b of a.children??[])e(b)};e(a)}}],t=r().markdown,u={note:{icon:e.A,label:"markdownNote"},tip:{icon:f.A,label:"markdownTip"},important:{icon:g.A,label:"markdownImportant"},warning:{icon:h.A,label:"markdownWarning"},caution:{icon:i.A,label:"markdownCaution"}},v={input:function({"data-pi-markdown-progress":a,...b}){let{t:c}=(0,l.Bd)("common");if(delete b.node,"checkbox"!==b.type)return(0,d.jsx)("input",{...b});let e=a?"progress":b.checked?"completed":"pending",f=a?"[-]":b.checked?"[x]":"[ ]",g=c(a?"markdownProgress":b.checked?"markdownCompleted":"markdownPending");return(0,d.jsxs)("span",{className:r().status,"data-state":e,role:"img","aria-label":g,title:g,children:[a?(0,d.jsx)(j.A,{"aria-hidden":"true"}):b.checked?(0,d.jsx)(k.A,{"aria-hidden":"true"}):null,(0,d.jsx)("span",{className:"sr-only","aria-hidden":"true",children:f})]})},blockquote:function({"data-pi-markdown-alert":a,className:b,children:c,...e}){let{t:f}=(0,l.Bd)("common");delete e.node;let g=Object.entries(u).find(([b])=>b===a)?.[1];if(!g)return(0,d.jsx)("blockquote",{...e,"data-streamdown":"blockquote",className:(0,n.cn)("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",b),children:c});let h=g.icon;return(0,d.jsxs)("aside",{className:r().alert,role:"note","aria-label":f(g.label),children:[(0,d.jsxs)("div",{className:r().alertTitle,children:[(0,d.jsx)(h,{"aria-hidden":"true"}),f(g.label)]}),(0,d.jsx)("div",{className:r().alertBody,children:c})]})}}},55091:(a,b,c)=>{"use strict";function d(a){return/\.(md|markdown)$/i.test(a)?"markdown":/\.html?$/i.test(a)?"html":null}c.d(b,{g:()=>d})},55579:(a,b,c)=>{"use strict";c.d(b,{Fj:()=>e}),c(51601);let d="/project-preview";function e(a){return a?`${d}?cwd=${encodeURIComponent(a)}`:d}},57396:a=>{a.exports={tree:"l3-project-file-browser_tree__KA1C9"}},59411:(a,b,c)=>{"use strict";c.d(b,{FH:()=>h,N$:()=>i,rB:()=>k,rn:()=>l});var d=c(87883),e=c(23423),f=c(41994);let g=d.Ik({cwd:e.m4,sessionCount:d.ai().int().nonnegative(),updatedAt:f.k}).strict(),h=d.Ik({forceRefresh:d.zM().default(!1)}).strict(),i=d.Ik({directories:d.YO(g)}).strict();d.Ik({cwd:e.m4,ignored:d.zM()}).strict(),d.Ik({}).strict();let j=d.Ik({cwd:e.m4,name:d.Yj().trim().min(1)}).strict(),k=d.Ik({cwd:e.m4.nullable()}).strict(),l=d.Ik({cwd:e.m4.nullable(),parentCwd:e.m4.nullable(),directories:d.YO(j)}).strict(),m=d.k5(["title","user","assistant","sessionId"]),n=d.Ik({scope:m,count:d.ai().int().positive(),entryId:e.Rv.nullable(),timestampMs:f.k.nullable(),preview:d.Yj().min(1).max(160)}).strict(),o=d.Ik({sessionId:e.$E,cwd:e.m4,name:d.Yj().nullable(),createdAt:f.k,updatedAt:f.k,messageCount:d.ai().int().nonnegative(),userMessageCount:d.ai().int().nonnegative(),firstMessage:d.Yj().max(160),matches:d.YO(n).min(1).max(4).nullable()}).strict();d.Ik({cwd:e.m4,query:d.Yj().trim().max(120).default(""),forceRefresh:d.zM().default(!1),searchIn:d.YO(m).min(1).max(4).default(["title","user"])}).strict(),d.Ik({cwd:e.m4,sessions:d.YO(o)}).strict(),d.Ik({cwd:e.m4,sessionId:e.$E,query:d.Yj().trim().max(120).default(""),page:d.Ik({index:d.ai().int().positive(),size:d.ai().int().positive().max(50)}).strict()}).strict();let p=d.Ik({entryId:e.Rv,timestampMs:f.k,text:d.Yj()}).strict();d.Ik({page:d.Ik({index:d.ai().int().positive(),size:d.ai().int().positive(),total:d.ai().int().nonnegative()}).strict(),messages:d.YO(p)}).strict()},60819:(a,b,c)=>{"use strict";c.d(b,{D:()=>k});var d=c(52834),e=c(65614),f=c(9698),g=c(5701),h=c(91816),i=c(15620),j=c(91464);function k({children:a}){return(0,d.jsx)(h.JW,{children:(0,d.jsx)(e.y,{className:"isolate z-[130] outline-none",side:"right",align:"start",alignOffset:4,children:(0,d.jsx)(f._,{"data-slot":"context-menu-content",finalFocus:!1,className:(0,i.cn)(j.hD,"flex flex-col overflow-hidden p-0"),children:(0,d.jsx)(g.V,{className:"min-h-0",viewportClassName:"p-1",children:a})})})})}},68341:(a,b,c)=>{"use strict";c.d(b,{Cp:()=>q,ph:()=>r,Tk:()=>p});var d=c(13749),e=c(95186),f=c(59411),g=c(92494);class h{constructor(a,b){this.cwd=a,this.reader=b,this.state={snapshot:{status:"idle",repositories:[],error:null},layout:"directory",changesOnly:!1,expandedRepositories:new Set},this.listeners=new Set,this.revision=0,this.request=null,this.disposed=!1,this.subscribe=a=>(this.listeners.add(a),()=>this.listeners.delete(a)),this.getRevision=()=>this.revision}getWorkspace(a){return a===this.cwd?this.state:null}ensureSnapshot(a){return a!==this.cwd||"ready"===this.state.snapshot.status||this.request?Promise.resolve():this.load(!1)}refreshSnapshot(a){return a===this.cwd?this.load(!0):Promise.resolve()}setLayout(a,b){this.state.layout=b,this.publish()}setChangesOnly(a,b){this.state.changesOnly=b,this.publish()}toggleRepository(a,b){let c=new Set(this.state.expandedRepositories);c.has(b)?c.delete(b):c.add(b),this.state.expandedRepositories=c,this.publish()}dispose(){this.disposed=!0,this.request?.abort(),this.request=null,this.listeners.clear()}async load(a){if(this.disposed)return;this.request?.abort();let b=new AbortController;this.request=b,this.state.snapshot={...this.state.snapshot,status:"loading",error:null},this.publish();try{let c=await this.reader.snapshot(b.signal,a);if(this.request!==b)return;this.state.snapshot={status:"ready",repositories:c.repositories,error:null}}catch(a){if(this.request!==b)return;this.state.snapshot={...this.state.snapshot,status:"error",error:a instanceof Error?a.message:"读取 Git 状态失败"}}this.request===b&&(this.request=null,this.publish())}publish(){if(!this.disposed)for(let a of(this.revision+=1,this.listeners))a()}}var i=c(52660),j=c(51601),k=c(21850),l=c(83731);function m(a,b){return(0,k.B)({msg:j.p["zh-CN"][a],i18n:{key:`projectHistory:${a}`,...b?{params:b}:{}}})}function n(){return{status:"idle",data:null,error:null}}class o{constructor(a,b){this.reader=a,this.files=b,this.state={repositoryRoot:null,mode:"history",tip:"HEAD",base:"",target:"HEAD",strategy:"merge-base",query:"",author:"",authorSuggestions:[],selectedCommit:null,selectedChangePath:null,branches:n(),log:n(),changes:n()},this.scroll={log:0,changes:0},this.listeners=new Set,this.requests=new Map,this.revision=0,this.disposed=!1,this.logPage=1,this.changesPage=1,this.range=null,this.selection=null,this.restoredCommit=null,this.restoredChangePath=null,this.restoredChangesScroll=null,this.queryTimer=null,this.collapsedDirectories=new Set,this.changeTree=(0,l.OA)([]),this.changeRows=[],this.changeRowHeight=36,this.subscribe=a=>(this.listeners.add(a),()=>this.listeners.delete(a)),this.getRevision=()=>this.revision}getChangeRows(){return this.changeRows}restoreBrowsing(a,b=!0){Object.assign(this.state,{repositoryRoot:a.repositoryRoot,mode:a.mode,tip:a.tip,base:a.base,target:a.target,strategy:a.strategy,query:a.query,author:a.author}),this.scroll.log=a.logScroll,this.restoredChangesScroll=a.changesScroll,this.restoredCommit=a.selectedCommit,this.restoredChangePath=a.selectedChangePath,b&&null!==a.repositoryRoot&&(this.loadBranches(),this.reload())}selectChange(a){this.state.changes.data?.items.some(b=>b.path===a)&&(this.state.selectedChangePath=a,this.publish())}toggleChangeDirectory(a){let b=this.changeRows.find(b=>b.directory?.path===a);if(b?.directory){if(b.expanded)this.collapsedDirectories.add(a);else for(let a of b.directory.paths)this.collapsedDirectories.delete(a);this.rebuildChangeRows(),this.publish()}}setScroll(a,b){this.scroll[a]=b}setChangeRowHeight(a){this.changeRowHeight!==a&&(this.scroll.changes=this.scroll.changes/this.changeRowHeight*a,this.changeRowHeight=a,this.publish())}setRepository(a){if(a===this.state.repositoryRoot){"idle"===this.state.branches.status&&(this.loadBranches(),this.reload());return}this.cancel("branches"),this.state.repositoryRoot=a,this.state.tip=this.state.target="HEAD",this.state.base="",this.state.author="",this.state.authorSuggestions=[],this.state.branches=n(),this.resetSelection(),this.loadBranches(),this.reload()}setMode(a){this.state.mode!==a&&(this.state.mode=a,this.resetSelection(),this.reload())}setRevision(a,b){this.state[a]!==b&&(this.state[a]=b,this.resetSelection(),this.reload())}setStrategy(a){this.state.strategy!==a&&(this.state.strategy=a,this.resetSelection(),this.reload())}setQuery(a){this.setLogFilter("query",a)}setAuthor(a){this.setLogFilter("author",a)}setLogFilter(a,b){this.state[a]=b,this.resetSelection(),this.queryTimer=setTimeout(()=>{this.queryTimer=null,this.reload()},220)}refresh(){this.resetSelection(),this.loadBranches(),this.reload()}async reload(){if(!this.disposed&&null!==this.state.repositoryRoot){if("compare"===this.state.mode)return this.state.base?void await this.loadChanges({base:this.state.base,target:this.state.target,strategy:this.state.strategy},1,!0):void this.publish();await this.loadLog(1)}}selectCommit(a,b){let c="string"==typeof a?a:a.oid;this.state.selectedCommit=c,this.scroll.changes=0,this.loadChanges({commit:c,...b?{parent:b}:{}},1)}showAggregate(){this.range&&(this.state.selectedCommit=null,this.loadChanges(this.range,1))}loadMoreLog(){("ready"===this.state.log.status||"error"===this.state.log.status)&&this.state.log.data?.hasMore&&!(this.state.log.data.items.length>=2e3)&&this.loadLog(this.logPage+1)}loadMoreChanges(){this.selection&&"ready"===this.state.changes.status&&this.state.changes.data?.hasMore&&this.loadChanges(this.selection,this.changesPage+1)}openChange(a){if(null===this.state.repositoryRoot)return;let b=this.state.changes.data,c=b?.items.find(b=>b.path===a);if(!b||!c)return;this.state.selectedChangePath=a,this.publish();let{original:d,target:e}=b.comparison,f=d?d.slice(0,8):m("emptyRevision"),g=m(this.state.selectedCommit||"merge-base"!==this.state.strategy?"historyDiffDirect":"historyDiffAncestor",{left:f,target:e.slice(0,8)});this.files.openDiff(this.state.repositoryRoot,a,{baseCommit:d,targetCommit:e,...c.oldPath?{oldPath:c.oldPath}:{}},g)}dispose(){for(let a of(this.disposed=!0,this.queryTimer&&clearTimeout(this.queryTimer),this.requests.values()))a.abort();this.requests.clear(),this.resetChangeTree(),this.listeners.clear()}async loadBranches(){let a=this.state.repositoryRoot;if(null===a||this.disposed)return;let b=this.begin("branches");this.state.branches={status:"loading",data:this.state.branches.data,error:null},this.publish();try{let c=await this.reader.branches(a,b.signal);if(!this.current("branches",b))return;this.state.branches={status:"ready",data:c,error:null}}catch(a){if(!this.current("branches",b))return;this.state.branches={status:"error",data:null,error:this.error(a)}}this.requests.delete("branches"),this.publish()}async loadLog(a){let b=this.state.repositoryRoot;if(this.disposed||null===b)return;let c=a>1?this.state.log.data:null,d=c?.tip??("compare"===this.state.mode?this.range?.target:this.state.tip),e=c?.exclude??("compare"===this.state.mode?this.range?.base:void 0);if(!d)return;let f=this.begin("log");this.state.log={status:"loading",data:c,error:null},this.publish();try{let g=await this.reader.log(b,{tip:d,...e?{exclude:e}:{},query:this.state.query,...this.state.author.trim()?{author:this.state.author.trim()}:{},page:{index:a,size:50}},f.signal);if(!this.current("log",f))return;for(let{author:b}of(this.logPage=a,g.items))b&&this.state.authorSuggestions.length<200&&!this.state.authorSuggestions.includes(b)&&this.state.authorSuggestions.push(b);if(this.state.log={status:"ready",data:{...g,items:[...c?.items??[],...g.items].slice(0,2e3)},error:null},1===a&&g.items[0]){let a=g.items.find(a=>a.oid===this.restoredCommit);this.restoredCommit=null,a?(this.state.selectedCommit=a.oid,this.loadChanges({commit:a.oid},1)):"history"===this.state.mode&&this.selectCommit(g.items[0])}}catch(a){if(!this.current("log",f))return;this.state.log={status:"error",data:c,error:this.error(a)}}this.requests.delete("log"),this.publish()}async loadChanges(a,b,c=!1){let d=this.state.repositoryRoot;if(this.disposed||null===d)return;let e=this.begin("changes"),f=b>1?this.state.changes.data:null;1===b&&this.resetChangeTree(),this.selection=a,this.state.changes={status:"loading",data:f,error:null},this.publish();try{let g=await this.reader.changes(d,{selection:a,page:{index:b,size:200}},e.signal);if(!this.current("changes",e))return;this.changesPage=b;let h=[...f?.items??[],...g.items];this.state.changes={status:"ready",data:{...g,items:h},error:null},this.changeTree=(0,l.OA)(h.map(a=>a.path)),null!==this.restoredChangesScroll&&(this.scroll.changes=this.restoredChangesScroll,this.restoredChangesScroll=null),this.rebuildChangeRows(),this.restoredChangePath&&h.some(a=>a.path===this.restoredChangePath)&&(this.state.selectedChangePath=this.restoredChangePath,this.restoredChangePath=null),this.selection="commit"in a?{commit:g.comparison.target,...g.commit?.selectedParent?{parent:g.commit.selectedParent}:{}}:{base:g.comparison.base,target:g.comparison.target,strategy:a.strategy},c&&"base"in this.selection&&(this.range=this.selection,this.loadLog(1))}catch(a){if(!this.current("changes",e))return;this.state.changes={status:"error",data:f,error:this.error(a)}}this.requests.delete("changes"),this.publish()}resetSelection(){this.restoredCommit=null,this.restoredChangePath=null,this.restoredChangesScroll=null,this.queryTimer&&clearTimeout(this.queryTimer),this.queryTimer=null,this.scroll.log=this.scroll.changes=0,this.cancel("log"),this.cancel("changes"),this.range=null,this.selection=null,this.state.selectedCommit=null,this.state.log=n(),this.state.changes=n(),this.resetChangeTree(),this.publish()}resetChangeTree(){this.collapsedDirectories.clear(),this.changeTree=(0,l.OA)([]),this.changeRows=[],this.state.selectedChangePath=null,this.scroll.changes=0}rebuildChangeRows(){let a=this.changeRowHeight,b=Math.floor(this.scroll.changes/a),c=this.changeRows[b],d=this.scroll.changes%a;this.changeRows=(0,l.qV)(this.changeTree,this.collapsedDirectories);let e=c?this.changeRows.findIndex(a=>a.key===c.key):-1;this.scroll.changes=e>=0?e*a+d:Math.min(this.scroll.changes,Math.max(0,(this.changeRows.length-1)*a))}begin(a){this.cancel(a);let b=new AbortController;return this.requests.set(a,b),b}cancel(a){this.requests.get(a)?.abort(),this.requests.delete(a)}current(a,b){return!this.disposed&&this.requests.get(a)===b}error(a){return a instanceof Error?a.message:m("historyReadFailed")}publish(){if(!this.disposed)for(let a of(this.revision+=1,this.listeners))a()}}function p(a,b){return(0,e.QL)(a,{path:"/api/pi/directories/list",request:f.FH,response:f.N$},{forceRefresh:!1},b)}function q(a,b,c){return(0,e.QL)(a,{path:"/api/pi/directory-entries/list",request:f.rB,response:f.rn},{cwd:b},c)}function r(a,b,c,f,j,k={}){let l=(0,e.Y4)(a,{cwd:b},k.onUnauthorized),m=new g.h(b,l,{imagePreviewMode:i.Wq,onNotice:c,reveal:(c,e="file")=>(0,d.P)(a,{cwd:b},c,e),maxTabs:20}),n=new h(b,l),p=new o(l,m),q=!1;return{files:m,git:n,history:p,restore(){if(!q&&(q=!0,n.setLayout(b,j.treeLayout),f)){for(let a of(n.setChangesOnly(b,f.changesOnly),f.expandedRepositories))n.toggleRepository(b,a);m.restoreBrowsing(f),p.restoreBrowsing(f.history,!k.lazyHistory)}},dispose(){p.dispose(),n.dispose(),m.dispose()}}}},70448:a=>{a.exports={host:"l4-code-line-markers_host__BBo2H",added:"l4-code-line-markers_added__oTNsK",modified:"l4-code-line-markers_modified__PZnY_",deletedBefore:"l4-code-line-markers_deletedBefore___1b0w",deletedAfter:"l4-code-line-markers_deletedAfter__SEoHy"}},82386:(a,b,c)=>{"use strict";c.d(b,{B3:()=>m,BK:()=>g,R:()=>f,Tr:()=>l,cu:()=>j,dC:()=>k,ix:()=>n});var d=c(51949),e=c(37222);function f(){let a=Number.parseFloat(getComputedStyle(document.documentElement).fontSize)/16;return{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:14*a,lineHeight:Math.round(22*a)}}function g(a){let b=new MutationObserver(()=>a(f()));return b.observe(document.documentElement,{attributes:!0,attributeFilter:["data-pi-desk-display-size"]}),()=>b.disconnect()}let h=null,i=0;function j(){return h||(h=(async()=>{(0,e.fx)()?.locale==="zh-CN"&&await c.e(80880).then(c.t.bind(c,80880,23));let{monaco:a}=await Promise.all([c.e(73691),c.e(20842),c.e(82499)]).then(c.bind(c,82499));return globalThis.MonacoEnvironment={getWorker:(a,b)=>new Worker(new URL(c.p+c.u(354),c.b),{type:void 0,name:b})},a})())}function k(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}function l(a){let b=new MutationObserver(()=>a(k()));return b.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>b.disconnect()}function m(a,b,c){i+=1;let d=b.split("/").map(a=>encodeURIComponent(a)).join("/");return a.Uri.parse(`inmemory://pi-desk/${i}/${c}/${d}`)}function n(a,b){if(b>d.gB)return"plaintext";let c=a.replaceAll("\\","/").split("/").at(-1)?.toLocaleLowerCase()??"";return"dockerfile"===c?"dockerfile":"makefile"===c?"plaintext":({bat:"bat",c:"c",cc:"cpp",cjs:"javascript",cpp:"cpp",cs:"csharp",css:"css",dockerfile:"dockerfile",go:"go",h:"cpp",hpp:"cpp",htm:"html",html:"html",ini:"ini",java:"java",js:"javascript",json:"javascript",jsonl:"javascript",jsx:"javascript",kt:"kotlin",less:"less",lua:"lua",md:"markdown",mdx:"markdown",mjs:"javascript",php:"php",ps1:"powershell",py:"python",rb:"ruby",rs:"rust",scss:"scss",sh:"shell",sql:"sql",swift:"swift",toml:"ini",ts:"typescript",tsx:"typescript",txt:"plaintext",xml:"xml",yaml:"yaml",yml:"yaml"})[c.includes(".")?c.split(".").at(-1)??"":""]??"plaintext"}},82563:(a,b,c)=>{"use strict";c.d(b,{Ke:()=>j,Nt:()=>h,R6:()=>i});var d=c(52834),e=c(33023),f=c(42500),g=c(91047);function h({...a}){return(0,d.jsx)(e.N,{"data-slot":"collapsible",...a})}function i({...a}){return(0,d.jsx)(f.R,{"data-slot":"collapsible-trigger",...a})}function j({...a}){return(0,d.jsx)(g.j,{"data-slot":"collapsible-content",...a})}},82589:(a,b,c)=>{"use strict";c.d(b,{b:()=>l});var d=c(52834),e=c(99451),f=c(49147),g=c(57850),h=c(5319),i=c(9860),j=c(42704),k=c(15620);function l({value:a,options:b,onChange:c,ariaLabel:m,placeholder:n,searchPlaceholder:o,emptyText:p,disabled:q=!1,className:r}){let{t:s}=(0,g.Bd)("common"),[t,u]=(0,f.useState)(!1),v=b.find(b=>b.value===a);return(0,d.jsxs)(j.AM,{open:t,onOpenChange:u,children:[(0,d.jsx)(j.Wv,{render:(0,d.jsxs)(h.$,{type:"button",variant:"outline",role:"combobox","aria-label":m,"aria-expanded":t,disabled:q,className:(0,k.cn)("w-full min-w-0 justify-between border-input px-2.5 font-normal focus-visible:-outline-offset-2",r),children:[(0,d.jsx)("span",{className:(0,k.cn)("min-w-0 truncate",!v&&"text-muted-foreground"),children:v?.label??n??s("selectPlaceholder")}),(0,d.jsx)(e.A,{className:"text-muted-foreground"})]})}),(0,d.jsx)(j.hl,{align:"start",sideOffset:4,positionerClassName:"z-[120]",className:"w-(--anchor-width) max-w-[calc(100vw-2rem)] gap-0 p-0",children:(0,d.jsxs)(i.uB,{children:[(0,d.jsx)(i.G7,{placeholder:o??s("searchPlaceholder"),autoFocus:!0}),(0,d.jsxs)(i.oI,{className:"max-h-[min(20rem,var(--available-height))]",children:[(0,d.jsx)(i.xL,{children:p??s("noMatches")}),(0,d.jsx)(i.L$,{children:b.map(b=>(0,d.jsx)(i.h_,{value:`${b.label} ${b.description??""} ${b.value}`,"data-checked":b.value===a?"true":void 0,onSelect:()=>{c(b.value),u(!1)},children:(0,d.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,d.jsx)("span",{className:"block truncate",children:b.label}),b.description?(0,d.jsx)("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:b.description}):null]})},b.value))})]})]})})]})}},83731:(a,b,c)=>{"use strict";function d(a,b){return`${a}:${b}`}function e(a,b){return a?`${a}/${b}`:b}function f(a,b){return a.localeCompare(b,void 0,{numeric:!0,sensitivity:"base"})}function g(a,b,c=new Set){let d=[a],e=a;for(;!c.has(e);){let a=b(e);if(!a||c.has(a)||!a.startsWith(`${e}/`))break;d.push(a),e=a}return{path:a,targetPath:e,paths:d,label:e.slice(a.lastIndexOf("/")+1)}}function h(a,b=""){let c={path:b,directories:new Map,files:[]},d=new Map([[b,c]]);for(let f of a){let a=(b?f.slice(b.length+1):f).split("/"),g=c;for(let b of a.slice(0,-1)){let a=e(g.path,b),c=d.get(a);c||(c={path:a,directories:new Map,files:[]},d.set(a,c),g.directories.set(a,c)),g=c}g.files.push(f)}return d}function i(a,b,c){return g(a,a=>{let c=b.get(a);return c&&0===c.files.length&&1===c.directories.size?c.directories.keys().next().value??null:null},c)}function j(a,b,c=""){let e=[],g=(c,h)=>{let j=a.get(c);if(j){for(let c of[...j.directories.keys()].sort(f)){let f=i(c,a),j=!f.paths.some(a=>b.has(a));e.push({key:d("directory",c),type:"directory",path:f.targetPath,label:f.label,depth:h,directory:f,expanded:j}),j&&g(f.targetPath,h+1)}for(let a of[...j.files].sort(f))e.push({key:d("file",a),type:"file",path:a,label:a.slice(a.lastIndexOf("/")+1),depth:h})}};return g(c,0),e}c.d(b,{Im:()=>d,Kn:()=>f,OA:()=>h,_J:()=>e,qV:()=>j,rk:()=>g,xV:()=>i})},84386:(a,b,c)=>{"use strict";c.d(b,{q:()=>ay});var d=c(52834),e=c(57850),f=c(35385),g=c(46505),h=c(34911),i=c(38721),j=c(22207),k=c(79918),l=c(39620),m=c(9665),n=c(97586),o=c(84912),p=c(37096),q=c(5319),r=c(45741),s=c(32772),t=c(9913),u=c(87366),v=c(49147),w=c(15620),x=c(91816),y=c(92494),z=c(60819),A=c(49057);let B=[{scope:"current",label:"closeTab"},{scope:"others",label:"closeOtherTabs"},{scope:"right",label:"closeRightTabs"},{scope:"left",label:"closeLeftTabs"},{scope:"all",label:"closeAllTabs"}];function C(a,b){let c=a.replaceAll("\\","/").split("/"),d=c.at(-1)??a;return b.some(b=>b!==a&&b.split("/").at(-1)===d)&&c.length>1?c.slice(-2).join("/"):d}function D({cwd:a,gitRuntime:b,paths:c,activePath:f,diffs:g,activeDiff:h,mobile:i,actions:j,onActivate:k,onClose:l}){let{t:m}=(0,e.Bd)("projectFiles");(0,v.useSyncExternalStore)(b.subscribe,b.getRevision,b.getRevision);let o=b.getWorkspace(a)?.snapshot,p=(0,v.useRef)(null),r=(0,v.useRef)(!1),[E,F]=(0,v.useState)(!1),[G,H]=(0,v.useState)(!1),[I,J]=(0,v.useState)([]),K=void 0!==j,L=K&&!i?32:36,M=[...c,...g.map(a=>[a.repositoryRoot,a.path].filter(Boolean).join("/"))],N=c.map(a=>({target:a,key:`file:${a}`,path:a,label:C(a,M),title:a,testId:`file-tab-${a}`}));for(let a of g){let b=[a.repositoryRoot,a.path].filter(Boolean).join("/"),c=a.comparison,d=c?`${c.baseCommit?.slice(0,7)??"∅"} → ${c.targetCommit.slice(0,7)}`:"",e=(0,y.Q)(a);N.push({target:a,key:`diff:${e}`,path:b,label:`${C(b,M)} \xb7 Diff`,revisions:d,title:[b,c?.oldPath,c?`${c.baseCommit??"∅"} → ${c.targetCommit}`:null].filter(Boolean).join("\n"),testId:`file-diff-tab-${b}${c?`-${e}`:""}`})}let O=h?`diff:${(0,y.Q)(h)}`:`file:${f}`;return 0===N.length?null:(0,d.jsxs)("div",{className:(0,w.cn)("shrink-0 bg-muted",K?"flex flex-wrap items-start":"border-b"),"data-testid":"file-tabs",children:[(0,d.jsx)("div",{className:(0,w.cn)("overflow-hidden",K&&"min-w-0 flex-[1_1_12rem]"),style:{maxHeight:E?void 0:(i?2:3)*L},children:(0,d.jsx)("div",{ref:p,role:"tablist","aria-label":m("openFiles"),className:"relative flex flex-wrap content-start items-start",children:N.map((b,c)=>{let e=!E&&I.includes(c),f=b.key===O,g="string"!=typeof b.target,h=g||o?.status!=="ready"?void 0:(0,A.lN)(a,b.path,o.repositories)?.change,j=g?m("closeDiff",{name:`${b.path.split("/").at(-1)}${b.revisions?` \xb7 ${b.revisions}`:""}`}):m("closeFile",{name:b.path.split("/").at(-1)});return(0,d.jsxs)(x.tz,{onOpenChange:(a,b)=>{a&&"pointerType"in b.event&&"touch"===b.event.pointerType&&(r.current=!0)},children:[(0,d.jsxs)(x.Rc,{render:(0,d.jsx)("div",{"data-file-tab":!0,"data-testid":b.testId,"aria-hidden":e||void 0,inert:e||void 0,title:b.title,className:(0,w.cn)("flex max-w-full items-center text-sm",K?i?"h-9":"h-8":"h-9 border-r border-b",i?b.revisions?"w-full":"w-[min(50%,12rem)]":b.revisions?"max-w-80":"max-w-60",e&&"invisible",f?"bg-background text-foreground shadow-[inset_0_-2px_0_var(--primary)]":"text-muted-foreground"),onPointerDown:a=>{"touch"===a.pointerType&&(r.current=!1)}}),children:[(0,d.jsxs)("button",{type:"button",role:"tab","aria-selected":f,className:"flex h-full min-w-0 flex-1 cursor-pointer items-center gap-2 pl-3 pr-1 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:()=>{if(r.current){r.current=!1;return}k(b.target)},onKeyDown:a=>{if("F10"===a.key&&a.shiftKey){a.preventDefault(),a.stopPropagation();let b=a.currentTarget.closest('[data-slot="context-menu-trigger"]');if(b){let a=b.getBoundingClientRect();b.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:a.left+a.width/2,clientY:a.top+a.height/2}))}return}let b="ArrowRight"===a.key||"ArrowDown"===a.key?1:"ArrowLeft"===a.key||"ArrowUp"===a.key?-1:0;if(!b)return;a.preventDefault();let d=(c+b+N.length)%N.length;F(!0);let e=p.current?.querySelectorAll('[role="tab"]');e?.[d]?.focus({preventScroll:!0})},children:[(0,d.jsx)(n.A,{className:"size-3.5 shrink-0"}),(0,d.jsx)("span",{className:(0,w.cn)("truncate",h&&(0,A.iH)(h)),children:b.label}),b.revisions?(0,d.jsx)("span",{className:"shrink-0 font-mono text-xs",children:b.revisions}):null,h?(0,d.jsx)("span",{className:(0,w.cn)("shrink-0 text-xs",(0,A.iH)(h)),"aria-label":m("gitStatus",{status:(0,A.XB)(h)}),children:(0,A.XB)(h)}):null]}),(0,d.jsx)(q.$,{variant:"ghost",size:"icon","data-testid":g?b.testId.replace("file-diff-tab-","file-diff-tab-close-"):`file-tab-close-${b.path}`,"aria-label":j,onClick:a=>{if(a.stopPropagation(),r.current){r.current=!1;return}l(b.target,"current")},children:(0,d.jsx)(s.A,{className:"size-3.5"})})]}),(0,d.jsx)(z.D,{children:B.map(({scope:a,label:e})=>(0,d.jsxs)("span",{children:["all"===a?(0,d.jsx)(x.K5,{}):null,(0,d.jsx)(x.kt,{disabled:"others"===a?N.length<=1:"left"===a?0===c:"right"===a&&c===N.length-1,onClick:()=>{r.current=!1,l(b.target,a)},children:m(e)})]},a))})]},b.key)})})}),K&&j?(0,d.jsx)("div",{className:"ml-auto flex min-h-8 max-w-full flex-wrap items-center justify-end gap-1 px-1",role:"group","aria-label":m("fileActions"),children:j}):null,G?(0,d.jsxs)(q.$,{variant:"ghost",className:"w-full rounded-none text-muted-foreground","aria-expanded":E,onClick:()=>F(a=>!a),children:[E?(0,d.jsx)(t.A,{className:"size-3.5"}):(0,d.jsx)(u.A,{className:"size-3.5"}),E?m("collapseTabs"):m("expandTabs",{count:N.length})]}):null]})}var E=c(17747),F=c(31748),G=c(51314),H=c(30340),I=c(29837),J=c(41568),K=c(79904),L=c(50599),M=c(90814),N=c(93306),O=c(87348);c(82386),c(51972);var P=c(96478);let Q=(0,v.forwardRef)(function({original:a,modified:b,viewMode:c,onEscape:f,savedState:g,onSaveState:h,initialLine:i},j){let{t:k}=(0,e.Bd)("common"),{wrapLines:l,collapseUnchanged:m}=(0,P.TX)(),n=(0,v.useRef)(null),o=(0,v.useRef)(null);(0,v.useRef)({viewMode:c,wrapLines:l,collapseUnchanged:m}),(0,v.useRef)(f),(0,v.useRef)(g),(0,v.useRef)(h),(0,v.useRef)(i);let[p,q]=(0,v.useState)("loading"),[r,s]=(0,v.useState)(null);return(0,v.useImperativeHandle)(j,()=>({previousChange(){o.current?.goToDiff("previous")},nextChange(){o.current?.goToDiff("next")},focus(){o.current?.getModifiedEditor().focus()}}),[]),(0,d.jsxs)("div",{"data-testid":"code-diff",className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden bg-background",children:[(0,d.jsx)("div",{ref:n,className:"min-h-0 flex-1"}),(0,d.jsx)("div",{role:"status","aria-label":k("diffStatus"),className:"flex min-h-6 shrink-0 items-center justify-end border-t px-3 text-xs text-muted-foreground",children:null===r?k("diffCalculating"):k("diffCount",{count:r})}),"loading"===p?(0,d.jsxs)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center gap-2 bg-background text-sm text-muted-foreground",children:[(0,d.jsx)(M.A,{className:"size-4 animate-spin"})," ",k("diffLoading")]}):null,"error"===p?(0,d.jsx)("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center text-sm text-destructive",children:k("diffFailed")}):null]})});var R=c(85544),S=c(2719),T=c(59582);function U({label:a,onClick:b,active:c=!1,children:e}){return(0,d.jsxs)(T.m_,{children:[(0,d.jsx)(T.k$,{render:(0,d.jsx)(q.$,{type:"button",size:"icon-sm",variant:"ghost","aria-label":a,"aria-pressed":c||void 0,onPointerDown:a=>a.preventDefault(),onClick:b}),children:e}),(0,d.jsx)(T.ZI,{children:a})]})}var V=c(45694),W=c(45427),X=c(55091);function Y({ref:a,runtime:b,gitRuntime:c,compact:f,visible:g=!0,refreshOnFocus:h=!0,onEscape:i,onSwitchPane:j,renderHeader:k}){let{t:m}=(0,e.Bd)("projectFiles"),{wrapLines:p,diffViewMode:r,collapseUnchanged:s}=(0,P.TX)();(0,v.useSyncExternalStore)(b.subscribe,b.getRevision,b.getRevision);let{activeDiff:t,activePath:u}=b.state,w=!t&&u?b.state.documents.get(u):null,x=u?(0,X.g)(u):null,z=w?.status==="text"&&(!x||"source"===w.viewMode),B=(0,v.useRef)(null),C=(0,v.useRef)(null),D=(0,v.useRef)(null),M=(0,v.useRef)(null),T=(0,S.G)();(0,v.useImperativeHandle)(a,()=>({focus(){z?C.current?.focus():t?D.current?.focus():B.current?.querySelector('[data-testid="markdown-preview"]')?.focus()}}),[t,z]);let $=()=>{u&&C.current&&b.saveEditorState(u,C.current.getViewState())},{refresh:_,unavailable:aa}=function(a,b,c,d=!0){(0,v.useSyncExternalStore)(b.subscribe,b.getRevision,b.getRevision);let e=b.getWorkspace(a.cwd)?.snapshot,f=a.state.activePath,g=!!a.state.activeDiff;f&&a.state.documents.get(f);let h=(0,v.useRef)(c),i=(0,v.useCallback)(()=>{f&&!g&&(h.current(),a.reloadFile(f),b.refreshSnapshot(a.cwd))},[g,b,f,a]),j=f&&e?.status==="ready"?(0,A.lN)(a.cwd,f,e.repositories):null;return{refresh:i,unavailable:e?.status==="error"||j?.repository.state==="unavailable"}}(b,c,$,h),ab=w?.status==="text"?w.comparison:void 0,[ac,ad]=(0,v.useState)(null),ae=ab?.status==="ready"&&w?.status==="text"&&ac?.original===ab.original.content&&ac.modified===w.content?ac.count:void 0,af=a=>{u&&($(),b.openFileDiff(u,a))},ag=aa||ab?.status==="error"?m("gitMarkersFailed"):ab?.status==="unavailable"||ab?.status==="ready"&&null===ae?m("gitMarkersUnavailable"):ab?.status==="loading"||ab?.status==="ready"&&void 0===ae?m("gitMarkersLoading"):ab?.status==="ready"?m("gitChangesCount",{count:ae}):null,ah=t||u?(0,d.jsx)(d.Fragment,{children:t?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"mr-auto shrink-0 px-1 text-xs text-muted-foreground",children:[t.label??(t.comparison?`${t.comparison.baseCommit?.slice(0,7)??"∅"} → ${t.comparison.targetCommit.slice(0,7)}`:m("headToWorking")),"text"===t.status&&t.original.content===t.modified.content?m("noDiffChanges"):""]}),(0,d.jsx)(U,{label:m("previousChange"),onClick:()=>D.current?.previousChange(),children:(0,d.jsx)(E.A,{className:"size-4"})}),(0,d.jsx)(U,{label:m("nextChange"),onClick:()=>D.current?.nextChange(),children:(0,d.jsx)(F.A,{className:"size-4"})}),f?null:(0,d.jsx)(U,{label:"side-by-side"===r?m("inlineDiff"):m("sideBySideDiff"),active:"inline"===r,onClick:()=>b.setDiffViewMode("side-by-side"===r?"inline":"side-by-side"),children:(0,d.jsx)(o.A,{className:"size-4"})}),(0,d.jsx)(U,{label:m(p?"wrapOff":"wrapOn"),active:p,onClick:()=>b.setDiffWrapLines(!p),children:(0,d.jsx)(G.A,{className:"size-4"})}),(0,d.jsx)(U,{label:m(s?"expandUnchanged":"collapseUnchanged"),active:s,onClick:()=>b.setDiffCollapseUnchanged(!s),children:(0,d.jsx)(H.A,{className:"size-4"})}),(0,d.jsx)(U,{label:m("reloadDiff"),onClick:()=>b.reloadDiff(),children:(0,d.jsx)(l.A,{className:"size-4"})})]}):(0,d.jsxs)(d.Fragment,{children:[x&&w?.status==="text"&&u?(0,d.jsx)("div",{className:"mr-auto flex shrink-0",role:"group","aria-label":m("markdown"===x?"markdownMode":"htmlMode"),children:["preview","source"].map(a=>(0,d.jsx)(q.$,{variant:w.viewMode===a?"secondary":"ghost",size:"sm","aria-pressed":w.viewMode===a,onClick:()=>{$(),b.setTextViewMode(u,a)},children:m("preview"===a?"previewMode":"sourceMode")},a))}):null,z&&ag?(0,d.jsx)("span",{"data-testid":"file-git-status",role:"status",className:"mr-auto min-w-0 truncate text-xs text-muted-foreground",title:ab?.status==="error"?ab.error:ag,children:f&&ab?.status==="ready"&&"number"==typeof ae?m("gitChangesCompact",{count:ae}):ag}):null,z&&ab?.status==="ready"?(0,d.jsxs)(d.Fragment,{children:["number"==typeof ae&&ae>0?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(U,{label:m("previousChange"),onClick:()=>C.current?.previousChange(),children:(0,d.jsx)(E.A,{className:"size-4"})}),(0,d.jsx)(U,{label:m("nextChange"),onClick:()=>C.current?.nextChange(),children:(0,d.jsx)(F.A,{className:"size-4"})})]}):null,(0,d.jsx)(U,{label:m("viewDiff"),onClick:()=>af(),children:(0,d.jsx)(I.A,{className:"size-4"})})]}):null,z&&u?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(U,{label:m("findInFile"),onClick:()=>C.current?.openSearch(),children:(0,d.jsx)(J.A,{className:"size-4"})}),f?null:(0,d.jsx)(U,{label:m("goToLine"),onClick:()=>C.current?.gotoLine(),children:(0,d.jsx)(K.A,{className:"size-4"})}),(0,d.jsx)(U,{label:m(p?"wrapOff":"wrapOn"),active:p,onClick:()=>b.setWrapLines(u,!p),children:(0,d.jsx)(G.A,{className:"size-4"})}),(0,d.jsx)(U,{label:m("copySelectionOrAll"),onClick:()=>{if(w?.status!=="text")return;let a=C.current?.getSelectionText()??"";(0,N.x)(a||w.content).then(b=>{b?T.success(m(a?"selectedCodeCopied":"allCodeCopied")):T.error(m("copyContentFailed"))})},children:(0,d.jsx)(L.A,{className:"size-4"})})]}):null,u?(0,d.jsx)(U,{label:m("reloadCurrentFile"),onClick:_,children:(0,d.jsx)(l.A,{className:"size-4"})}):null]})}):null;return(0,d.jsxs)("div",{ref:B,className:"flex size-full min-h-0 min-w-0 flex-col outline-none",tabIndex:-1,onFocus:a=>{a.target===a.currentTarget&&(z?C.current?.focus():t?D.current?.focus():B.current?.querySelector('[data-testid="markdown-preview"]')?.focus())},children:[k?k(ah):ah?(0,d.jsx)("div",{className:"flex min-h-9 shrink-0 flex-wrap items-center justify-end gap-2 border-b px-3 py-1","aria-label":m("fileActions"),children:ah}):null,(0,d.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden pb-[env(safe-area-inset-bottom)]",children:t?"text"===t.status?(0,d.jsx)(Q,{ref:D,original:t.original,modified:t.modified,viewMode:f?"inline":r,savedState:t.editorState,initialLine:t.initialLine,onSaveState:a=>b.saveDiffState(t,a),onEscape:i},(0,y.Q)(t)):"metadata"===t.status?(0,d.jsxs)("div",{className:"grid h-full grid-cols-1 gap-4 overflow-auto p-4 md:grid-cols-2",children:[(0,d.jsx)("pre",{className:"whitespace-pre-wrap break-all text-sm",children:t.originalMetadata}),(0,d.jsx)("pre",{className:"whitespace-pre-wrap break-all text-sm",children:t.modifiedMetadata})]}):"loading"===t.status||"unloaded"===t.status?(0,d.jsx)(Z,{}):(0,d.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-center text-sm",children:[(0,d.jsx)("p",{className:"text-muted-foreground",children:"binary"===t.status?m("binaryDiffUnavailable"):"too_large"===t.status?m("largeDiffUnavailable"):t.error}),"error"===t.status?(0,d.jsx)(q.$,{variant:"outline",onClick:()=>b.reloadDiff(),children:m("readAgain")}):null]}):u&&w?"loading"===w.status||"unloaded"===w.status?(0,d.jsx)(Z,{}):"error"===w.status?(0,d.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-center",children:[(0,d.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:w.error}),(0,d.jsx)(q.$,{variant:"outline",onClick:()=>b.reloadFile(u),children:m("readAgain")})]}):"image"===w.status?(0,d.jsx)(R.k,{mode:"inline",slides:[{src:w.objectUrl,alt:u}],ariaLabel:m("imageViewer",{name:u.replaceAll("\\","/").split("/").at(-1)??u})},w.objectUrl):"markdown"===x&&"preview"===w.viewMode?(0,d.jsx)(W.n,{content:w.content,label:m("markdownPreview",{name:u}),savedScrollTop:w.previewScrollTop,onScroll:a=>b.savePreviewScrollTop(u,a)},u):"html"===x&&"preview"===w.viewMode?(0,d.jsx)("iframe",{ref:M,className:"block size-full border-0 bg-white",sandbox:"allow-scripts",srcDoc:(0,V.z)(w.content),title:m("htmlPreview",{name:u})}):(0,d.jsx)(O.e,{ref:C,path:u,content:w.content,size:w.size,originalContent:ab?.status==="ready"?ab.original.content:void 0,onChanges:a=>{ab?.status==="ready"&&ad({original:ab.original.content,modified:w.content,count:a})},onOpenDiff:af,savedState:w.editorState,navigation:b.pendingNavigation,onNavigation:(a,c)=>b.consumeNavigation(a,c),onSaveState:(a,c)=>b.saveEditorState(a,c),onEscape:i},u):(0,d.jsxs)("div",{"data-testid":"file-workspace-empty",className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-sm text-muted-foreground",children:[(0,d.jsx)(n.A,{className:"size-6"}),m("noOpenFile")]})})]})}function Z(){let{t:a}=(0,e.Bd)("projectFiles");return(0,d.jsxs)("div",{className:"flex size-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,d.jsx)(M.A,{className:"size-4 animate-spin"}),a("loadingFile")]})}var $=c(68341),_=c(1222);function aa(a){let b=window.matchMedia("(pointer: fine)");return b.addEventListener("change",a),()=>b.removeEventListener("change",a)}function ab(){return window.matchMedia("(pointer: fine)").matches}function ac(){return!1}var ad=c(79739),ae=c(53403),af=c(4998),ag=c(5701),ah=c(11071),ai=c(82589);function aj({items:a,label:b,scrollTop:c,onScroll:e,render:f,role:g="listbox",onKeyDown:h,rowHeight:i=36,onNearEnd:j,footer:k}){let l=(0,v.useRef)(null),[m,n]=(0,v.useState)({top:c,height:300}),o=Math.max(0,Math.floor(m.top/i)-8),p=Math.min(a.length,Math.ceil((m.top+m.height)/i)+8);return(0,d.jsxs)("div",{ref:l,role:g,tabIndex:"tree"===g?0:void 0,onKeyDown:h,"aria-label":b,className:"min-h-0 flex-1 overflow-auto overscroll-contain",onScroll:a=>{let b=a.currentTarget.scrollTop;n(a=>({...a,top:b})),e(b)},children:[(0,d.jsx)("div",{style:{height:a.length*i,position:"relative"},children:(0,d.jsx)("div",{style:{position:"absolute",top:o*i,left:0,right:0},children:a.slice(o,p).map((a,b)=>f(a,o+b))})}),k]})}var ak=c(37496),al=c(9365),am=c(75152),an=c(51108),ao=c(83731);let ap={added:"A",modified:"M",deleted:"D",renamed:"R","type-changed":"T"};function aq({cwd:a,repositoryRoot:b,rows:c,changes:f,selectedPath:g,scrollTop:h,rowHeight:i,onScroll:j,onSelect:k,onToggle:l,onOpen:m,onReveal:n}){let{t:p}=(0,e.Bd)("projectHistory"),r=(0,v.useRef)(null),s=(a,b)=>{a&&r.current===b&&(r.current=null,a.focus({preventScroll:!0}))},t=new Map(f.map(a=>[a.path,a]));return(0,d.jsx)(aj,{role:"tree",label:p("changeFiles"),items:c,scrollTop:h,rowHeight:i,onScroll:j,onKeyDown:a=>{if(a.defaultPrevented||!a.currentTarget.contains(a.target))return;let b=a.target instanceof Element?a.target.closest("[data-tree-key]"):null;if(a.target instanceof Element&&a.target.closest("button"))return;let d=b?c.findIndex(a=>a.key===b.dataset.treeKey):-1,e=c[d],f=d;if("ArrowDown"===a.key)f=Math.min(c.length-1,d+1);else if("ArrowUp"===a.key)f=Math.max(0,d-1);else if("Home"===a.key)f=0;else if("End"===a.key)f=c.length-1;else if("ArrowRight"===a.key&&e?.directory)e.expanded?f=Math.min(c.length-1,d+1):l(e.directory.path);else if("ArrowLeft"===a.key&&e){if(e.expanded&&e.directory)l(e.directory.path);else for(let a=d-1;a>=0;a-=1)if(c[a].depth<e.depth){f=a;break}}else{if("Enter"!==a.key&&" "!==a.key||!e)return;e.directory?l(e.directory.path):"Enter"===a.key?m(e.path):k(e.path)}a.preventDefault();let g=c[f];if(!g)return;let h=a.currentTarget;f*i<h.scrollTop?h.scrollTop=f*i:(f+1)*i>h.scrollTop+h.clientHeight&&(h.scrollTop=(f+1)*i-h.clientHeight),r.current=g.key,s([...h.querySelectorAll("[data-tree-key]")].find(a=>a.dataset.treeKey===g.key)??null,g.key)},render:c=>{let e=t.get(c.path),f=(0,ao._J)(b,c.path),h=c.directory;return(0,d.jsx)(an.J,{cwd:a,path:f,type:c.type,historical:!0,expanded:c.expanded,onToggle:h?()=>l(h.path):void 0,onOpen:"file"===c.type?()=>m(c.path):void 0,openLabel:p("viewDiff"),oldPath:"file"===c.type&&e?.oldPath?(0,ao._J)(b,e.oldPath):void 0,onReveal:n,trigger:(0,d.jsxs)("div",{ref:a=>s(a,c.key),role:"treeitem",tabIndex:0,"aria-level":c.depth+1,"aria-expanded":c.expanded,"aria-selected":"file"===c.type&&g===c.path,"data-tree-key":c.key,className:(0,w.cn)("flex min-w-0 cursor-pointer items-center gap-1 pr-1 text-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","file"===c.type&&g===c.path&&"bg-accent"),style:{height:i,paddingLeft:4+c.depth*(24===i?12:24)},title:e?.oldPath&&"file"===c.type?`${(0,ao._J)(b,e.oldPath)} → ${f}`:f,onClick:a=>{h?a.detail<2&&l(h.path):k(c.path)},onDoubleClick:()=>{"file"===c.type&&m(c.path)},children:[h?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ak.A,{className:(0,w.cn)("size-4 shrink-0 text-muted-foreground",c.expanded&&"rotate-90")}),c.expanded?(0,d.jsx)(al.A,{className:"size-4 shrink-0 text-muted-foreground"}):(0,d.jsx)(am.A,{className:"size-4 shrink-0 text-muted-foreground"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"w-4 shrink-0"}),(0,d.jsx)("span",{className:(0,w.cn)("w-4 shrink-0 font-mono text-xs",e?.status==="added"?"text-emerald-600 dark:text-emerald-400":e?.status==="deleted"?"text-red-600 dark:text-red-400":"text-blue-600 dark:text-blue-400"),"aria-label":p("gitStatus",{status:e?ap[e.status]:""}),children:e?ap[e.status]:""})]}),(0,d.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[c.label,"directory"===c.type&&t.has(c.path)?"/":""]}),"file"===c.type?(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost",className:24===i?"size-6":void 0,"aria-label":p("viewDiffPath",{path:c.path}),onDoubleClick:a=>a.stopPropagation(),onClick:a=>{a.stopPropagation(),m(c.path)},children:(0,d.jsx)(o.A,{className:"size-4"})}):null]})},c.key)}})}var ar=c(99451),as=c(97832),at=c(42704);function au(a){let b=[],c=a;for(;c.includes("/")&&"refs"!==(c=c.slice(0,c.lastIndexOf("/")));)b.push(c);return b}function av({branches:a,value:b,onChange:c,ariaLabel:f,placeholder:g,className:h}){let{t:i}=(0,e.Bd)("projectHistory"),{t:j}=(0,e.Bd)("common"),k=(0,v.useId)(),l=(0,v.useRef)(null),m=(0,v.useRef)(null),n=(0,v.useRef)(new Map),[o,p]=(0,v.useState)(!1),[r,s]=(0,v.useState)(""),[t,x]=(0,v.useState)(b),[y,z]=(0,v.useState)(()=>new Set(["refs/heads","refs/remotes",...au(b)])),B=r.trim().toLocaleLowerCase(),C="HEAD"===b?i("currentHead"):b.replace(/^refs\/(heads|remotes)\//,""),D=(0,v.useMemo)(()=>{let b=[],c=[{key:"refs/heads",label:i("localBranch"),names:a?.local??[]},{key:"refs/remotes",label:i("remoteBranch"),names:a?.remote??[]}].map(a=>({...a,nodes:(0,A.oY)(a.names.filter(a=>a.toLocaleLowerCase().includes(B)))})).filter(a=>a.nodes.length>0),d=`HEAD ${i("currentHead")}`.toLocaleLowerCase().includes(B),e=c.length+Number(d);d&&b.push({key:"HEAD",label:i("currentHead"),fullName:i("currentHead"),parentKey:null,level:1,position:1,siblingCount:e,expandable:!1});let f=(a,c,d,e)=>{a.forEach((g,h)=>{let i=`${c}/${g.path}`;b.push({key:i,label:g.name,fullName:g.path,parentKey:d,level:e,position:h+1,siblingCount:a.length,expandable:g.children.length>0}),y.has(i)&&f(g.children,c,i,e+1)})};return c.forEach((a,c)=>{b.push({key:a.key,label:a.label,fullName:a.label,parentKey:null,level:1,position:c+Number(d)+1,siblingCount:e,expandable:!0}),y.has(a.key)&&f(a.nodes,a.key,a.key,2)}),b},[a,y,B,i]),E=D.find(a=>a.key===t)??D.find(a=>a.key===b)??D.find(a=>!a.expandable)??D[0],F=a=>{if(!a)return;x(a.key);let b=n.current.get(a.key);b?.focus({preventScroll:!0}),b?.scrollIntoView({block:"nearest"})},G=a=>{z(b=>{let c=new Set(b);return c.has(a.key)?c.delete(a.key):c.add(a.key),c})};return(0,d.jsxs)(at.AM,{open:o,onOpenChange:a=>{a&&(s(""),x(b),z(a=>new Set([...a,...au(b)]))),p(a)},onOpenChangeComplete:a=>{a&&document.activeElement===l.current&&n.current.get(b)?.scrollIntoView({block:"nearest"})},children:[(0,d.jsx)(at.Wv,{render:(0,d.jsxs)(q.$,{ref:m,type:"button",variant:"outline",role:"combobox","aria-haspopup":"dialog","aria-label":f,"aria-expanded":o,title:C||g,className:(0,w.cn)("w-full min-w-0 justify-between border-input px-2.5 font-normal focus-visible:-outline-offset-2",h),children:[(0,d.jsx)("span",{className:(0,w.cn)("min-w-0 truncate",!b&&"text-muted-foreground"),children:C||g||j("selectPlaceholder")}),(0,d.jsx)(ar.A,{className:"text-muted-foreground"})]})}),(0,d.jsxs)(at.hl,{align:"start","aria-label":f,initialFocus:l,finalFocus:m,positionerClassName:"z-[120]",className:"max-h-[min(30rem,var(--available-height))] w-[max(26rem,calc(var(--anchor-width)+8rem))] max-w-[min(calc(100vw-2rem),var(--available-width))] gap-0 overflow-hidden p-0",children:[(0,d.jsx)("div",{className:"shrink-0 border-b p-2",children:(0,d.jsx)(ah.p,{ref:l,type:"search","aria-label":j("searchPlaceholder"),"aria-controls":k,placeholder:j("searchPlaceholder"),value:r,onChange:b=>(b=>{s(b),x("");let c=b.trim().toLocaleLowerCase();if(!c)return;let d=[...(a?.local??[]).filter(a=>a.toLocaleLowerCase().includes(c)).map(a=>`refs/heads/${a}`),...(a?.remote??[]).filter(a=>a.toLocaleLowerCase().includes(c)).map(a=>`refs/remotes/${a}`)];z(a=>new Set([...a,...d.flatMap(au)]))})(b.target.value),onKeyDown:a=>{a.nativeEvent.isComposing||a.altKey||a.ctrlKey||a.metaKey||("ArrowDown"===a.key||"ArrowUp"===a.key)&&(a.preventDefault(),a.stopPropagation(),F("ArrowDown"===a.key?E:D.at(-1)))}})}),(0,d.jsx)("div",{id:k,role:"tree","aria-label":f,className:"min-h-0 overflow-y-auto overscroll-contain p-1",children:D.map(a=>{let e=!a.expandable&&a.key===b,f=a.expandable?y.has(a.key):void 0;return(0,d.jsxs)("button",{ref:b=>{b?n.current.set(a.key,b):n.current.delete(a.key)},type:"button",role:"treeitem","aria-label":a.fullName,"aria-level":a.level,"aria-posinset":a.position,"aria-setsize":a.siblingCount,"aria-selected":a.expandable?void 0:e,"aria-expanded":f,tabIndex:E?.key===a.key?0:-1,title:a.fullName,className:(0,w.cn)("flex min-h-8 w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left text-sm outline-none transition-colors duration-150 hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring [@media(pointer:coarse)]:min-h-10",e&&"bg-accent text-accent-foreground",1===a.level&&a.expandable&&"font-medium text-muted-foreground"),style:{paddingLeft:8+12*Math.min(a.level-1,8)},onFocus:()=>x(a.key),onKeyDown:b=>((a,b)=>{if(a.nativeEvent.isComposing||a.altKey||a.ctrlKey||a.metaKey)return;let c=D.indexOf(b);switch(a.key){case"ArrowDown":F(D[Math.min(c+1,D.length-1)]);break;case"ArrowUp":F(D[Math.max(c-1,0)]);break;case"Home":F(D[0]);break;case"End":F(D.at(-1));break;case"ArrowRight":b.expandable&&(y.has(b.key)?F(D[c+1]):G(b));break;case"ArrowLeft":b.expandable&&y.has(b.key)?G(b):F(D.find(a=>a.key===b.parentKey));break;default:return}a.preventDefault(),a.stopPropagation()})(b,a),onClick:()=>{x(a.key),a.expandable?G(a):(c(a.key),p(!1))},children:[a.expandable?f?(0,d.jsx)(u.A,{"aria-hidden":"true",className:"size-3.5 shrink-0"}):(0,d.jsx)(ak.A,{"aria-hidden":"true",className:"size-3.5 shrink-0"}):(0,d.jsx)("span",{"aria-hidden":"true",className:"size-3.5 shrink-0"}),(0,d.jsx)("span",{className:"min-w-0 flex-1 break-all",children:a.label}),e?(0,d.jsx)(as.A,{"aria-hidden":"true",className:"size-3.5 shrink-0"}):null]},a.key)})}),D.length?null:(0,d.jsx)("p",{role:"status",className:"px-3 py-6 text-center text-sm text-muted-foreground",children:j("noMatches")}),E&&E.fullName!==E.label?(0,d.jsx)("div",{className:"max-h-24 shrink-0 overflow-y-auto border-t px-3 py-2 text-xs break-all text-muted-foreground",children:E.fullName}):null]})]})}function aw(a){let{state:b,repositories:c,projectName:f,narrow:g,scroll:h}=a,{t:i}=(0,e.Bd)("projectHistory"),{locale:j,timeZone:k}=(0,af.i)(),m=(0,v.useMemo)(()=>new Intl.DateTimeFormat("en"===j?"en-US":"zh-CN",{timeZone:k,month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),[j,k]),n=(0,v.useMemo)(()=>new Intl.DateTimeFormat("en"===j?"en-US":"zh-CN",{timeZone:k,timeZoneName:"shortOffset",year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),[j,k]),o=(0,v.useId)(),{mobilePane:r,onMobilePane:s}=a,t=b.changes.data,u=`${b.repositoryRoot}:${t?.comparison.original}:${t?.comparison.target}`,x=b.selectedChangePath,y=b.branches.data?.upstream,z=t?.commit,A=(c,e=a.onRefresh)=>c?(0,d.jsxs)("div",{role:"alert",className:"flex flex-wrap items-center gap-2 p-3 text-sm text-destructive",children:[(0,d.jsx)("span",{className:"min-w-0 flex-1 break-words",children:c}),(0,d.jsx)(q.$,{size:"sm",variant:"outline",onClick:e,children:i("retry")}),"compare"===b.mode&&"merge-base"===b.strategy?(0,d.jsx)(q.$,{size:"sm",variant:"outline",onClick:()=>a.onStrategy("direct"),children:i("compareDirect")}):null]}):null,B=(0,d.jsx)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:(0,d.jsx)(aj,{items:b.log.data?.items??[],label:i("commitList"),scrollTop:h.log,onScroll:b=>a.onScroll("log",b),onNearEnd:"ready"===b.log.status&&b.log.data?.hasMore&&b.log.data.items.length<2e3?a.onMoreLog:void 0,footer:(0,d.jsxs)(d.Fragment,{children:[A(b.log.error,b.log.data?a.onMoreLog:a.onRefresh),"loading"===b.log.status?(0,d.jsxs)("div",{role:"status",className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,d.jsx)(M.A,{className:"size-4 animate-spin"}),i("loadingCommits")]}):null,"ready"!==b.log.status||b.log.data?.items.length?null:(0,d.jsx)("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:b.query||b.author?i("noMatchingCommits"):i("noCommits")}),b.log.data?.truncated?(0,d.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("scanLimit")}):(b.log.data?.items.length??0)>=2e3?(0,d.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("loadedLimit")}):"ready"===b.log.status&&b.log.data?.items.length&&!b.log.data.hasMore?(0,d.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("noMoreCommits")}):null]}),render:c=>(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":b.selectedCommit===c.oid,className:(0,w.cn)("flex h-9 w-full items-center gap-3 border-b border-border/40 px-3 text-left text-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",b.selectedCommit===c.oid&&"bg-accent"),onClick:()=>{var b;return b=c.oid,void(a.onCommit(b),g&&s("files"))},title:`${c.subject}
13
+ ${d}`}},49057:(a,b,c)=>{"use strict";c.d(b,{A_:()=>k,Hj:()=>i,XB:()=>l,eP:()=>o,iH:()=>m,lN:()=>n,oW:()=>h,oY:()=>g,ws:()=>j});var d=c(53403),e=c(89172),f=c(83731);function g(a){let b=new Map;for(let c of a){let a=c.split("/").filter(Boolean),d=b,e="";for(let[b,f]of a.entries()){e=e?`${e}/${f}`:f;let g=d.get(f);g||(g={name:f,path:e,branchName:null,children:new Map},d.set(f,g)),b===a.length-1&&(g.branchName=c),d=g.children}}return function a(b){return[...b].sort((a,b)=>a.name.localeCompare(b.name,void 0,{numeric:!0,sensitivity:"base"})).map(b=>({name:b.name,path:b.path,branchName:b.branchName,children:a(b.children.values())}))}(b.values())}function h(a,b){return(0,f._J)(a,b)}function i(a,b){return b.split("/").at(-1)||a}function j(a){return"branch"===a.type?a.name:`@ ${a.commit.slice(0,7)}`}function k(a,b,c="en"){if(0===b.length)return null;let f=e.C[c];if(1===b.length){let e=b[0],g=i(a,e.root);if("unavailable"===e.state){let a=f.gitUnavailable;return{full:e.root?`${g} \xb7 ${a}`:a,compact:"Git !",title:`${g}${"en"===c?": ":":"}${(0,d.fD)(e.message,c)}`,diverged:!0}}let h=j(e.head);return{full:e.root?`${g} \xb7 ${h}`:h,compact:h,title:`${f.gitBranches}: ${g} \xb7 ${h}`,diverged:"detached"===e.head.type}}let g=`${b.length} ${f.repositoriesUnit}`;return{full:g,compact:`Git ${b.length}`,title:`${f.gitBranches}: ${g}`,diverged:!1}}function l(a){let b=[a.indexStatus,a.worktreeStatus];return b.includes("unmerged")?"!":b.includes("deleted")?"D":b.includes("renamed")?"R":b.includes("added")?"A":b.includes("modified")?"M":"?"}function m(a){let b=l(a);return"D"===b?"text-muted-foreground":"?"===b?"text-red-600 dark:text-red-400":"A"===b?"text-emerald-600 dark:text-emerald-400":"!"===b?"text-violet-600 dark:text-violet-400":"text-blue-600 dark:text-blue-400"}function n(a,b,c){if(/^(?:[a-z]:|\/|\\\\)/i.test(b))return null;let d=/^[a-z]:[\\/]/i.test(a)||a.startsWith("\\\\"),e=a=>d?a.toLowerCase():a,f=[...c].sort((a,b)=>b.root.length-a.root.length).find(a=>!a.root||e(b).startsWith(`${e(a.root)}/`));if(!f)return null;let g=f.root?b.slice(f.root.length+1):b;return{repository:f,path:g,change:"ready"===f.state?f.changes.find(a=>e(a.path)===e(g)):void 0}}function o(a){return a.flatMap(a=>"ready"===a.state?a.changes.map(b=>({repositoryRoot:a.root,repository:a,path:b.path,projectPath:h(a.root,b.path),change:b})):[])}},51108:(a,b,c)=>{"use strict";c.d(b,{J:()=>q});var d=c(52834),e=c(97586),f=c(87366),g=c(37496),h=c(9365),i=c(50599),j=c(49147),k=c(57850),l=c(93306),m=c(2719),n=c(91816),o=c(60819),p=c(13749);function q({cwd:a,path:b,type:c,trigger:r,openLabel:s,onOpen:t,expanded:u,onToggle:v,historical:w,oldPath:x,onReveal:y}){let{t:z}=(0,k.Bd)("projectFiles"),A=(0,m.G)(),[B,C]=(0,j.useState)(null),D=B??{cwd:a,path:b,type:c,oldPath:x},E=(0,j.useRef)(!1),F=(0,j.useRef)(""),G="file"===c?"file":"folder",H=a=>{(0,l.x)(a).then(a=>{a?A.success(z("copied")):A.error(z("copyFailed"))})},I=(D.path||D.cwd.replaceAll("\\","/")).split("/").filter(Boolean).at(-1)??D.cwd;return(0,d.jsxs)(n.tz,{onOpenChange:(d,e)=>{C(d?{cwd:a,path:b,type:c,oldPath:x}:null);let f=e.event;d&&("touch"===F.current||"pointerType"in f&&"touch"===f.pointerType||f.type.startsWith("touch"))&&(E.current=!0)},children:[(0,d.jsx)(n.Rc,{render:r,"data-project-path-menu-trigger":"",onPointerDown:a=>{F.current=a.pointerType,E.current=!1},onTouchEndCapture:a=>{let b=a.target;!B||!E.current||"touch"!==F.current||b instanceof Element&&b.closest("[data-project-path-menu-trigger]")===a.currentTarget&&a.cancelable&&a.preventDefault()},onClickCapture:a=>{E.current&&(a.preventDefault(),a.stopPropagation(),E.current=!1)},onKeyDownCapture:a=>{if(a.defaultPrevented||a.nativeEvent.isComposing)return;let b=a.target;if(!(b instanceof Element)||b.closest("[data-project-path-menu-trigger]")!==a.currentTarget||(F.current="keyboard",E.current=!1,"ContextMenu"!==a.key&&!("F10"===a.key&&a.shiftKey)))return;a.preventDefault(),a.stopPropagation();let c=b.getBoundingClientRect();a.currentTarget.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,button:2,clientX:c.left+Math.min(c.width,120)/2,clientY:c.top+Math.min(c.height,36)/2}))}}),(0,d.jsxs)(o.D,{children:[t?(0,d.jsxs)(n.kt,{onClick:t,children:[(0,d.jsx)(e.A,{}),s??z("openPreview")]}):null,v?(0,d.jsxs)(n.kt,{onClick:v,children:[u?(0,d.jsx)(f.A,{}):(0,d.jsx)(g.A,{}),z(u?"collapse":"expand")]}):null,t||v?(0,d.jsx)(n.K5,{}):null,y?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(n.kt,{"data-testid":`project-${G}-reveal-${b}`,onClick:()=>{y&&y(D.path,D.type).then(()=>A.success(z("revealRequested"))).catch(a=>{A.error(a instanceof Error?a.message:z("revealFailed"))})},children:[(0,d.jsx)(h.A,{}),w?"directory"===c?z("openCurrentWorkspace"):z("locateCurrentWorkspace"):"directory"===c?z("openFolder"):z("openContainingFolder")]}),(0,d.jsx)(n.K5,{})]}):null,(0,d.jsxs)(n.kt,{"data-testid":`project-${G}-copy-address-${b}`,onClick:()=>H((0,p.$)(D.cwd,D.path)),children:[(0,d.jsx)(i.A,{}),z("copyAbsolutePath")]}),(0,d.jsxs)(n.kt,{onClick:()=>H(D.path||"."),children:[(0,d.jsx)(i.A,{}),z("copyRelativePath")]}),(0,d.jsxs)(n.kt,{onClick:()=>H(I),children:[(0,d.jsx)(i.A,{}),z("directory"===c?"copyFolderName":"copyFileName")]}),D.oldPath?(0,d.jsxs)(n.kt,{onClick:()=>H(D.oldPath),children:[(0,d.jsx)(i.A,{}),z("copyOldRelativePath")]}):null]})]})}},51949:(a,b,c)=>{"use strict";c.d(b,{CT:()=>n,JH:()=>p,NL:()=>g,Nu:()=>q,_g:()=>k,eC:()=>l,gB:()=>h,ih:()=>v,jI:()=>u,p$:()=>m,rh:()=>j,uV:()=>e,xm:()=>f});var d=c(87883);let e=4096,f=5e3,g=5242880,h=1048576;function i(a,b){return""===a?b:!(a.length>e||a.startsWith("/")||a.includes("\\")||a.includes("\0")||/^[a-zA-Z]:/.test(a))&&a.split("/").every(a=>a.length>0&&"."!==a&&".."!==a)}let j=d.Yj().max(e).refine(a=>i(a,!0),"目录路径必须是规范相对路径"),k=d.Yj().min(1).max(e).refine(a=>i(a,!1),"文件路径必须是规范相对路径"),l=d.Yj().min(1).max(e).refine(a=>i(a,!1)||a.length>0&&a.length<=e&&!a.includes("\0")&&(a.startsWith("/")||a.startsWith("\\\\")||/^[a-zA-Z]:[\\/]/.test(a)),"预览路径必须是规范相对路径或绝对路径"),m=d.k5(["compressed","original"]),n=d.k5(["image/jpeg","image/png","image/webp","image/gif"]),o=d.Ik({name:d.Yj().min(1),type:d.k5(["directory","file"])}).strict(),p=d.Ik({entries:d.YO(o).max(f),truncated:d.zM()}).strict(),q=d.Ik({query:d.Yj().min(1).max(200).refine(a=>a.trim().length>0&&!/[\0\r\n]/.test(a),"搜索词必须是非空单行文本"),scope:d.k5(["all","files","content"]).default("all"),caseSensitive:d.zM().default(!1),wholeWord:d.zM().default(!1),regex:d.zM().default(!1)}).strict(),r=d.Ik({start:d.ai().int().nonnegative(),end:d.ai().int().nonnegative()}).strict().refine(a=>a.start<=a.end,"搜索命中区间无效"),s=d.Ik({path:k,ranges:d.YO(r)}).strict().refine(a=>a.ranges.every(b=>b.end<=a.path.length),"文件名命中区间越界"),t=d.Ik({path:k,line:d.ai().int().positive(),text:d.Yj().max(1e3),ranges:d.YO(r)}).strict().refine(a=>a.ranges.every(b=>b.end<=a.text.length),"正文命中区间越界"),u=d.Ik({fileMatches:d.YO(s).max(100),contentMatches:d.YO(t).max(200),truncated:d.zM()}).strict(),v=d.gM("kind",[d.Ik({kind:d.eu("text"),content:d.Yj(),size:d.ai().int().nonnegative().max(g)}).strict(),d.Ik({kind:d.eu("image"),mimeType:n,data:d.Yj().min(1),size:d.ai().int().positive().max(0xa00000)}).strict()])},51972:(a,b,c)=>{"use strict";function d(a,b,c){a.addCommand(b,c,"editorTextFocus && !findWidgetVisible && !suggestWidgetVisible && !renameInputVisible && !parameterHintsVisible && !referenceSearchVisible && !editorHoverVisible && !editorHoverFocused")}c.d(b,{e:()=>d})},52660:(a,b,c)=>{"use strict";c.d(b,{Wq:()=>g,ku:()=>i,lU:()=>h}),c(51949);let d=new Set,e="compressed";function f(){}function g(){return f(),e}function h(a){if(f(),e!==a){e=a;try{window.localStorage.setItem("pi-super:image-preview-mode",a)}catch{}for(let a of[...d])a()}}function i(a){return d.add(a),()=>d.delete(a)}},53403:(a,b,c)=>{"use strict";c.d(b,{fD:()=>f,qf:()=>e});var d=c(87883);let e=d.KC([d.Yj(),d.Ik({default:d.Yj(),translations:d.g1(d.Yj().min(1).max(35),d.Yj()).refine(a=>Object.keys(a).length<=16,"too many translations")}).strict()]);function f(a,b){return"string"==typeof a?a:a.translations[b]??a.translations[b.split("-")[0]]??a.default}},53437:(a,b,c)=>{"use strict";c.d(b,{IV:()=>o,om:()=>t,e6:()=>v,XC:()=>s});var d=c(52834),e=c(60816),f=c(63345),g=c(98004),h=c(40181),i=c(49028),j=c(21556),k=c(97832),l=c(57850),m=c(38684),n=c(15620);let o={input:["dataPiMarkdownProgress"],blockquote:["dataPiMarkdownAlert"]};function p(a){return{type:"paragraph",children:[],data:{hName:"input",hProperties:{type:"checkbox",disabled:!0,checked:"[x]"===a.toLowerCase(),..."[-]"===a?{dataPiMarkdownProgress:"true"}:{}}}}}var q=c(4935),r=c.n(q);let s=[...Object.values(m.U2),function(){return(a,b)=>{let c=String(b.value),d=(a,b)=>{let d=a.position?.start.offset;return void 0!==d&&c.slice(d,d+b.length)===b},e=a=>{let b=a.children?.[0];if("tableCell"===a.type&&a.children?.length===1&&b?.type==="text"){let c=b.value??"";/^\[[ xX-]\]$/.test(c)&&d(b,c)&&(a.children=[p(c)])}else if("listItem"===a.type&&b?.type==="paragraph"){let c=b.children?.[0];c?.type==="text"&&/^\[-\](?:\s|$)/.test(c.value??"")&&d(c,"[-]")&&(c.value=c.value.slice(3),b.children.unshift(p("[-]")),a.data={...a.data,hProperties:{className:["task-list-item"]}})}else if("blockquote"===a.type&&b?.type==="paragraph"){let c=b.children?.[0],e=c?.value?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\][ \t]*(?:\r?\n|$)/);c?.type==="text"&&e&&d(c,`[!${e[1]}]`)&&(e[0].endsWith("\n")||1===b.children.length||b.children[1]?.type==="break")&&(c.value=c.value.slice(e[0].length),c.value||(b.children.shift(),b.children[0]?.type==="break"&&b.children.shift()),0===b.children.length&&a.children.shift(),a.data={...a.data,hProperties:{dataPiMarkdownAlert:e[1].toLowerCase()}})}for(let b of a.children??[])e(b)};e(a)}}],t=r().markdown,u={note:{icon:e.A,label:"markdownNote"},tip:{icon:f.A,label:"markdownTip"},important:{icon:g.A,label:"markdownImportant"},warning:{icon:h.A,label:"markdownWarning"},caution:{icon:i.A,label:"markdownCaution"}},v={input:function({"data-pi-markdown-progress":a,...b}){let{t:c}=(0,l.Bd)("common");if(delete b.node,"checkbox"!==b.type)return(0,d.jsx)("input",{...b});let e=a?"progress":b.checked?"completed":"pending",f=a?"[-]":b.checked?"[x]":"[ ]",g=c(a?"markdownProgress":b.checked?"markdownCompleted":"markdownPending");return(0,d.jsxs)("span",{className:r().status,"data-state":e,role:"img","aria-label":g,title:g,children:[a?(0,d.jsx)(j.A,{"aria-hidden":"true"}):b.checked?(0,d.jsx)(k.A,{"aria-hidden":"true"}):null,(0,d.jsx)("span",{className:"sr-only","aria-hidden":"true",children:f})]})},blockquote:function({"data-pi-markdown-alert":a,className:b,children:c,...e}){let{t:f}=(0,l.Bd)("common");delete e.node;let g=Object.entries(u).find(([b])=>b===a)?.[1];if(!g)return(0,d.jsx)("blockquote",{...e,"data-streamdown":"blockquote",className:(0,n.cn)("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",b),children:c});let h=g.icon;return(0,d.jsxs)("aside",{className:r().alert,role:"note","aria-label":f(g.label),children:[(0,d.jsxs)("div",{className:r().alertTitle,children:[(0,d.jsx)(h,{"aria-hidden":"true"}),f(g.label)]}),(0,d.jsx)("div",{className:r().alertBody,children:c})]})}}},55091:(a,b,c)=>{"use strict";function d(a){return/\.(md|markdown)$/i.test(a)?"markdown":/\.html?$/i.test(a)?"html":null}c.d(b,{g:()=>d})},55579:(a,b,c)=>{"use strict";c.d(b,{Fj:()=>e});let d="/project-preview";function e(a){return a?`${d}?cwd=${encodeURIComponent(a)}`:d}},57396:a=>{a.exports={tree:"l3-project-file-browser_tree__KA1C9"}},59411:(a,b,c)=>{"use strict";c.d(b,{FH:()=>i,N$:()=>j,qY:()=>p,rB:()=>l,rn:()=>m});var d=c(87883),e=c(23423),f=c(41994),g=c(62598);let h=d.Ik({cwd:e.m4,sessionCount:d.ai().int().nonnegative(),updatedAt:f.k}).strict(),i=d.Ik({forceRefresh:d.zM().default(!1)}).strict(),j=d.Ik({directories:d.YO(h)}).strict();d.Ik({cwd:e.m4,ignored:d.zM()}).strict(),d.Ik({}).strict();let k=d.Ik({cwd:e.m4,name:d.Yj().trim().min(1)}).strict(),l=d.Ik({cwd:e.m4.nullable()}).strict(),m=d.Ik({cwd:e.m4.nullable(),parentCwd:e.m4.nullable(),directories:d.YO(k)}).strict(),n=g.Jk,o=d.Ik({sessionId:e.$E,cwd:e.m4,name:d.Yj().nullable(),createdAt:f.k,updatedAt:f.k,messageCount:d.ai().int().nonnegative(),userMessageCount:d.ai().int().nonnegative(),firstMessage:d.Yj().max(160),matches:d.YO(n).min(1).max(4).nullable()}).strict();g.Gm.extend({cwd:e.m4,forceRefresh:d.zM().default(!1)});let p=d.Ik({cwd:e.m4,sessions:d.YO(o)}).strict();d.Ik({cwd:e.m4,sessionId:e.$E,query:d.Yj().trim().max(120).default(""),page:d.Ik({index:d.ai().int().positive(),size:d.ai().int().positive().max(50)}).strict()}).strict();let q=d.Ik({entryId:e.Rv,timestampMs:f.k,text:d.Yj()}).strict();d.Ik({page:d.Ik({index:d.ai().int().positive(),size:d.ai().int().positive(),total:d.ai().int().nonnegative()}).strict(),messages:d.YO(q)}).strict()},60819:(a,b,c)=>{"use strict";c.d(b,{D:()=>k});var d=c(52834),e=c(65614),f=c(9698),g=c(5701),h=c(91816),i=c(15620),j=c(91464);function k({children:a}){return(0,d.jsx)(h.JW,{children:(0,d.jsx)(e.y,{className:"isolate z-[130] outline-none",side:"right",align:"start",alignOffset:4,children:(0,d.jsx)(f._,{"data-slot":"context-menu-content",finalFocus:!1,className:(0,i.cn)(j.hD,"flex flex-col overflow-hidden p-0"),children:(0,d.jsx)(g.V,{className:"min-h-0",viewportClassName:"p-1",children:a})})})})}},61332:(a,b,c)=>{"use strict";function d(a,b,c=!0){}c.d(b,{L:()=>d}),c(49147)},62598:(a,b,c)=>{"use strict";c.d(b,{Gm:()=>i,Jk:()=>h});var d=c(87883),e=c(23423),f=c(41994);let g=d.k5(["title","user","assistant","sessionId"]),h=d.Ik({scope:g,count:d.ai().int().positive(),entryId:e.Rv.nullable(),timestampMs:f.k.nullable(),preview:d.Yj().min(1).max(160)}).strict(),i=d.Ik({query:d.Yj().trim().max(120).default(""),searchIn:d.YO(g).min(1).max(4).default(["title","user"])}).strict()},68341:(a,b,c)=>{"use strict";c.d(b,{Cp:()=>q,ph:()=>r,Tk:()=>p});var d=c(13749),e=c(95186),f=c(59411),g=c(92494);class h{constructor(a,b){this.cwd=a,this.reader=b,this.state={snapshot:{status:"idle",repositories:[],error:null},layout:"directory",changesOnly:!1,expandedRepositories:new Set},this.listeners=new Set,this.revision=0,this.request=null,this.disposed=!1,this.subscribe=a=>(this.listeners.add(a),()=>this.listeners.delete(a)),this.getRevision=()=>this.revision}getWorkspace(a){return a===this.cwd?this.state:null}ensureSnapshot(a){return a!==this.cwd||"ready"===this.state.snapshot.status||this.request?Promise.resolve():this.load(!1)}refreshSnapshot(a){return a===this.cwd?this.load(!0):Promise.resolve()}setLayout(a,b){this.state.layout=b,this.publish()}setChangesOnly(a,b){this.state.changesOnly=b,this.publish()}toggleRepository(a,b){let c=new Set(this.state.expandedRepositories);c.has(b)?c.delete(b):c.add(b),this.state.expandedRepositories=c,this.publish()}dispose(){this.disposed=!0,this.request?.abort(),this.request=null,this.listeners.clear()}async load(a){if(this.disposed||this.request)return;let b=new AbortController;this.request=b,"ready"!==this.state.snapshot.status&&(this.state.snapshot={...this.state.snapshot,status:"loading",error:null},this.publish());try{let c=await this.reader.snapshot(b.signal,a);if(this.request!==b)return;this.state.snapshot={status:"ready",repositories:c.repositories,error:null}}catch(a){if(this.request!==b)return;this.state.snapshot={...this.state.snapshot,status:"error",error:a instanceof Error?a.message:"读取 Git 状态失败"}}this.request===b&&(this.request=null,this.publish())}publish(){if(!this.disposed)for(let a of(this.revision+=1,this.listeners))a()}}var i=c(52660),j=c(51601),k=c(21850),l=c(83731);function m(a,b){return(0,k.B)({msg:j.p["zh-CN"][a],i18n:{key:`projectHistory:${a}`,...b?{params:b}:{}}})}function n(){return{status:"idle",data:null,error:null}}class o{constructor(a,b){this.reader=a,this.files=b,this.state={repositoryRoot:null,mode:"history",tip:"HEAD",base:"",target:"HEAD",strategy:"merge-base",query:"",author:"",authorSuggestions:[],selectedCommit:null,selectedChangePath:null,branches:n(),log:n(),changes:n()},this.scroll={log:0,changes:0},this.listeners=new Set,this.requests=new Map,this.revision=0,this.disposed=!1,this.logPage=1,this.changesPage=1,this.range=null,this.selection=null,this.restoredCommit=null,this.restoredChangePath=null,this.restoredChangesScroll=null,this.queryTimer=null,this.collapsedDirectories=new Set,this.changeTree=(0,l.OA)([]),this.changeRows=[],this.changeRowHeight=36,this.subscribe=a=>(this.listeners.add(a),()=>this.listeners.delete(a)),this.getRevision=()=>this.revision}getChangeRows(){return this.changeRows}restoreBrowsing(a,b=!0){Object.assign(this.state,{repositoryRoot:a.repositoryRoot,mode:a.mode,tip:a.tip,base:a.base,target:a.target,strategy:a.strategy,query:a.query,author:a.author}),this.scroll.log=a.logScroll,this.restoredChangesScroll=a.changesScroll,this.restoredCommit=a.selectedCommit,this.restoredChangePath=a.selectedChangePath,b&&null!==a.repositoryRoot&&(this.loadBranches(),this.reload())}selectChange(a){this.state.changes.data?.items.some(b=>b.path===a)&&(this.state.selectedChangePath=a,this.publish())}toggleChangeDirectory(a){let b=this.changeRows.find(b=>b.directory?.path===a);if(b?.directory){if(b.expanded)this.collapsedDirectories.add(a);else for(let a of b.directory.paths)this.collapsedDirectories.delete(a);this.rebuildChangeRows(),this.publish()}}setScroll(a,b){this.scroll[a]=b}setChangeRowHeight(a){this.changeRowHeight!==a&&(this.scroll.changes=this.scroll.changes/this.changeRowHeight*a,this.changeRowHeight=a,this.publish())}setRepository(a){if(a===this.state.repositoryRoot){"idle"===this.state.branches.status&&(this.loadBranches(),this.reload());return}this.cancel("branches"),this.state.repositoryRoot=a,this.state.tip=this.state.target="HEAD",this.state.base="",this.state.author="",this.state.authorSuggestions=[],this.state.branches=n(),this.resetSelection(),this.loadBranches(),this.reload()}setMode(a){this.state.mode!==a&&(this.state.mode=a,this.resetSelection(),this.reload())}setRevision(a,b){this.state[a]!==b&&(this.state[a]=b,this.resetSelection(),this.reload())}setStrategy(a){this.state.strategy!==a&&(this.state.strategy=a,this.resetSelection(),this.reload())}setQuery(a){this.setLogFilter("query",a)}setAuthor(a){this.setLogFilter("author",a)}setLogFilter(a,b){this.state[a]=b,this.resetSelection(),this.queryTimer=setTimeout(()=>{this.queryTimer=null,this.reload()},220)}refresh(){this.resetSelection(),this.loadBranches(),this.reload()}async reload(){if(!this.disposed&&null!==this.state.repositoryRoot){if("compare"===this.state.mode)return this.state.base?void await this.loadChanges({base:this.state.base,target:this.state.target,strategy:this.state.strategy},1,!0):void this.publish();await this.loadLog(1)}}selectCommit(a,b){let c="string"==typeof a?a:a.oid;this.state.selectedCommit=c,this.scroll.changes=0,this.loadChanges({commit:c,...b?{parent:b}:{}},1)}showAggregate(){this.range&&(this.state.selectedCommit=null,this.loadChanges(this.range,1))}loadMoreLog(){("ready"===this.state.log.status||"error"===this.state.log.status)&&this.state.log.data?.hasMore&&!(this.state.log.data.items.length>=2e3)&&this.loadLog(this.logPage+1)}loadMoreChanges(){this.selection&&"ready"===this.state.changes.status&&this.state.changes.data?.hasMore&&this.loadChanges(this.selection,this.changesPage+1)}openChange(a){if(null===this.state.repositoryRoot)return;let b=this.state.changes.data,c=b?.items.find(b=>b.path===a);if(!b||!c)return;this.state.selectedChangePath=a,this.publish();let{original:d,target:e}=b.comparison,f=d?d.slice(0,8):m("emptyRevision"),g=m(this.state.selectedCommit||"merge-base"!==this.state.strategy?"historyDiffDirect":"historyDiffAncestor",{left:f,target:e.slice(0,8)});this.files.openDiff(this.state.repositoryRoot,a,{baseCommit:d,targetCommit:e,...c.oldPath?{oldPath:c.oldPath}:{}},g)}dispose(){for(let a of(this.disposed=!0,this.queryTimer&&clearTimeout(this.queryTimer),this.requests.values()))a.abort();this.requests.clear(),this.resetChangeTree(),this.listeners.clear()}async loadBranches(){let a=this.state.repositoryRoot;if(null===a||this.disposed)return;let b=this.begin("branches");this.state.branches={status:"loading",data:this.state.branches.data,error:null},this.publish();try{let c=await this.reader.branches(a,b.signal);if(!this.current("branches",b))return;this.state.branches={status:"ready",data:c,error:null}}catch(a){if(!this.current("branches",b))return;this.state.branches={status:"error",data:null,error:this.error(a)}}this.requests.delete("branches"),this.publish()}async loadLog(a){let b=this.state.repositoryRoot;if(this.disposed||null===b)return;let c=a>1?this.state.log.data:null,d=c?.tip??("compare"===this.state.mode?this.range?.target:this.state.tip),e=c?.exclude??("compare"===this.state.mode?this.range?.base:void 0);if(!d)return;let f=this.begin("log");this.state.log={status:"loading",data:c,error:null},this.publish();try{let g=await this.reader.log(b,{tip:d,...e?{exclude:e}:{},query:this.state.query,...this.state.author.trim()?{author:this.state.author.trim()}:{},page:{index:a,size:50}},f.signal);if(!this.current("log",f))return;for(let{author:b}of(this.logPage=a,g.items))b&&this.state.authorSuggestions.length<200&&!this.state.authorSuggestions.includes(b)&&this.state.authorSuggestions.push(b);if(this.state.log={status:"ready",data:{...g,items:[...c?.items??[],...g.items].slice(0,2e3)},error:null},1===a&&g.items[0]){let a=g.items.find(a=>a.oid===this.restoredCommit);this.restoredCommit=null,a?(this.state.selectedCommit=a.oid,this.loadChanges({commit:a.oid},1)):"history"===this.state.mode&&this.selectCommit(g.items[0])}}catch(a){if(!this.current("log",f))return;this.state.log={status:"error",data:c,error:this.error(a)}}this.requests.delete("log"),this.publish()}async loadChanges(a,b,c=!1){let d=this.state.repositoryRoot;if(this.disposed||null===d)return;let e=this.begin("changes"),f=b>1?this.state.changes.data:null;1===b&&this.resetChangeTree(),this.selection=a,this.state.changes={status:"loading",data:f,error:null},this.publish();try{let g=await this.reader.changes(d,{selection:a,page:{index:b,size:200}},e.signal);if(!this.current("changes",e))return;this.changesPage=b;let h=[...f?.items??[],...g.items];this.state.changes={status:"ready",data:{...g,items:h},error:null},this.changeTree=(0,l.OA)(h.map(a=>a.path)),null!==this.restoredChangesScroll&&(this.scroll.changes=this.restoredChangesScroll,this.restoredChangesScroll=null),this.rebuildChangeRows(),this.restoredChangePath&&h.some(a=>a.path===this.restoredChangePath)&&(this.state.selectedChangePath=this.restoredChangePath,this.restoredChangePath=null),this.selection="commit"in a?{commit:g.comparison.target,...g.commit?.selectedParent?{parent:g.commit.selectedParent}:{}}:{base:g.comparison.base,target:g.comparison.target,strategy:a.strategy},c&&"base"in this.selection&&(this.range=this.selection,this.loadLog(1))}catch(a){if(!this.current("changes",e))return;this.state.changes={status:"error",data:f,error:this.error(a)}}this.requests.delete("changes"),this.publish()}resetSelection(){this.restoredCommit=null,this.restoredChangePath=null,this.restoredChangesScroll=null,this.queryTimer&&clearTimeout(this.queryTimer),this.queryTimer=null,this.scroll.log=this.scroll.changes=0,this.cancel("log"),this.cancel("changes"),this.range=null,this.selection=null,this.state.selectedCommit=null,this.state.log=n(),this.state.changes=n(),this.resetChangeTree(),this.publish()}resetChangeTree(){this.collapsedDirectories.clear(),this.changeTree=(0,l.OA)([]),this.changeRows=[],this.state.selectedChangePath=null,this.scroll.changes=0}rebuildChangeRows(){let a=this.changeRowHeight,b=Math.floor(this.scroll.changes/a),c=this.changeRows[b],d=this.scroll.changes%a;this.changeRows=(0,l.qV)(this.changeTree,this.collapsedDirectories);let e=c?this.changeRows.findIndex(a=>a.key===c.key):-1;this.scroll.changes=e>=0?e*a+d:Math.min(this.scroll.changes,Math.max(0,(this.changeRows.length-1)*a))}begin(a){this.cancel(a);let b=new AbortController;return this.requests.set(a,b),b}cancel(a){this.requests.get(a)?.abort(),this.requests.delete(a)}current(a,b){return!this.disposed&&this.requests.get(a)===b}error(a){return a instanceof Error?a.message:m("historyReadFailed")}publish(){if(!this.disposed)for(let a of(this.revision+=1,this.listeners))a()}}function p(a,b){return(0,e.QL)(a,{path:"/api/pi/directories/list",request:f.FH,response:f.N$},{forceRefresh:!1},b)}function q(a,b,c){return(0,e.QL)(a,{path:"/api/pi/directory-entries/list",request:f.rB,response:f.rn},{cwd:b},c)}function r(a,b,c,f,j,k={}){let l=(0,e.Y4)(a,{cwd:b},k.onUnauthorized),m=new g.h(b,l,{imagePreviewMode:i.Wq,onNotice:c,reveal:(c,e="file")=>(0,d.P)(a,{cwd:b},c,e),maxTabs:20}),n=new h(b,l),p=new o(l,m),q=!1;return{files:m,git:n,history:p,restore(){if(!q&&(q=!0,n.setLayout(b,j.treeLayout),f)){for(let a of(n.setChangesOnly(b,f.changesOnly),f.expandedRepositories))n.toggleRepository(b,a);m.restoreBrowsing(f),p.restoreBrowsing(f.history,!k.lazyHistory)}},dispose(){p.dispose(),n.dispose(),m.dispose()}}}},70448:a=>{a.exports={host:"l4-code-line-markers_host__BBo2H",added:"l4-code-line-markers_added__oTNsK",modified:"l4-code-line-markers_modified__PZnY_",deletedBefore:"l4-code-line-markers_deletedBefore___1b0w",deletedAfter:"l4-code-line-markers_deletedAfter__SEoHy"}},82386:(a,b,c)=>{"use strict";c.d(b,{B3:()=>m,BK:()=>g,R:()=>f,Tr:()=>l,cu:()=>j,dC:()=>k,ix:()=>n});var d=c(51949),e=c(37222);function f(){let a=Number.parseFloat(getComputedStyle(document.documentElement).fontSize)/16;return{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:14*a,lineHeight:Math.round(22*a)}}function g(a){let b=new MutationObserver(()=>a(f()));return b.observe(document.documentElement,{attributes:!0,attributeFilter:["data-pi-desk-display-size"]}),()=>b.disconnect()}let h=null,i=0;function j(){return h||(h=(async()=>{(0,e.fx)()?.locale==="zh-CN"&&await c.e(80880).then(c.t.bind(c,80880,23));let{monaco:a}=await Promise.all([c.e(73691),c.e(20842),c.e(82499)]).then(c.bind(c,82499));return globalThis.MonacoEnvironment={getWorker:(a,b)=>new Worker(new URL(c.p+c.u(354),c.b),{type:void 0,name:b})},a})())}function k(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}function l(a){let b=new MutationObserver(()=>a(k()));return b.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>b.disconnect()}function m(a,b,c){i+=1;let d=b.split("/").map(a=>encodeURIComponent(a)).join("/");return a.Uri.parse(`inmemory://pi-desk/${i}/${c}/${d}`)}function n(a,b){if(b>d.gB)return"plaintext";let c=a.replaceAll("\\","/").split("/").at(-1)?.toLocaleLowerCase()??"";return"dockerfile"===c?"dockerfile":"makefile"===c?"plaintext":({bat:"bat",c:"c",cc:"cpp",cjs:"javascript",cpp:"cpp",cs:"csharp",css:"css",dockerfile:"dockerfile",go:"go",h:"cpp",hpp:"cpp",htm:"html",html:"html",ini:"ini",java:"java",js:"javascript",json:"javascript",jsonl:"javascript",jsx:"javascript",kt:"kotlin",less:"less",lua:"lua",md:"markdown",mdx:"markdown",mjs:"javascript",php:"php",ps1:"powershell",py:"python",rb:"ruby",rs:"rust",scss:"scss",sh:"shell",sql:"sql",swift:"swift",toml:"ini",ts:"typescript",tsx:"typescript",txt:"plaintext",xml:"xml",yaml:"yaml",yml:"yaml"})[c.includes(".")?c.split(".").at(-1)??"":""]??"plaintext"}},82563:(a,b,c)=>{"use strict";c.d(b,{Ke:()=>j,Nt:()=>h,R6:()=>i});var d=c(52834),e=c(33023),f=c(42500),g=c(91047);function h({...a}){return(0,d.jsx)(e.N,{"data-slot":"collapsible",...a})}function i({...a}){return(0,d.jsx)(f.R,{"data-slot":"collapsible-trigger",...a})}function j({...a}){return(0,d.jsx)(g.j,{"data-slot":"collapsible-content",...a})}},82589:(a,b,c)=>{"use strict";c.d(b,{b:()=>l});var d=c(52834),e=c(99451),f=c(49147),g=c(57850),h=c(5319),i=c(9860),j=c(42704),k=c(15620);function l({value:a,options:b,onChange:c,ariaLabel:m,placeholder:n,searchPlaceholder:o,emptyText:p,disabled:q=!1,className:r}){let{t:s}=(0,g.Bd)("common"),[t,u]=(0,f.useState)(!1),v=b.find(b=>b.value===a);return(0,d.jsxs)(j.AM,{open:t,onOpenChange:u,children:[(0,d.jsx)(j.Wv,{render:(0,d.jsxs)(h.$,{type:"button",variant:"outline",role:"combobox","aria-label":m,"aria-expanded":t,disabled:q,className:(0,k.cn)("w-full min-w-0 justify-between border-input px-2.5 font-normal focus-visible:-outline-offset-2",r),children:[(0,d.jsx)("span",{className:(0,k.cn)("min-w-0 truncate",!v&&"text-muted-foreground"),children:v?.label??n??s("selectPlaceholder")}),(0,d.jsx)(e.A,{className:"text-muted-foreground"})]})}),(0,d.jsx)(j.hl,{align:"start",sideOffset:4,positionerClassName:"z-[120]",className:"w-(--anchor-width) max-w-[calc(100vw-2rem)] gap-0 p-0",children:(0,d.jsxs)(i.uB,{children:[(0,d.jsx)(i.G7,{placeholder:o??s("searchPlaceholder"),autoFocus:!0}),(0,d.jsxs)(i.oI,{className:"max-h-[min(20rem,var(--available-height))]",children:[(0,d.jsx)(i.xL,{children:p??s("noMatches")}),(0,d.jsx)(i.L$,{children:b.map(b=>(0,d.jsx)(i.h_,{value:`${b.label} ${b.description??""} ${b.value}`,"data-checked":b.value===a?"true":void 0,onSelect:()=>{c(b.value),u(!1)},children:(0,d.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,d.jsx)("span",{className:"block truncate",children:b.label}),b.description?(0,d.jsx)("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:b.description}):null]})},b.value))})]})]})})]})}},83731:(a,b,c)=>{"use strict";function d(a,b){return`${a}:${b}`}function e(a,b){return a?`${a}/${b}`:b}function f(a,b){return a.localeCompare(b,void 0,{numeric:!0,sensitivity:"base"})}function g(a,b,c=new Set){let d=[a],e=a;for(;!c.has(e);){let a=b(e);if(!a||c.has(a)||!a.startsWith(`${e}/`))break;d.push(a),e=a}return{path:a,targetPath:e,paths:d,label:e.slice(a.lastIndexOf("/")+1)}}function h(a,b=""){let c={path:b,directories:new Map,files:[]},d=new Map([[b,c]]);for(let f of a){let a=(b?f.slice(b.length+1):f).split("/"),g=c;for(let b of a.slice(0,-1)){let a=e(g.path,b),c=d.get(a);c||(c={path:a,directories:new Map,files:[]},d.set(a,c),g.directories.set(a,c)),g=c}g.files.push(f)}return d}function i(a,b,c){return g(a,a=>{let c=b.get(a);return c&&0===c.files.length&&1===c.directories.size?c.directories.keys().next().value??null:null},c)}function j(a,b,c=""){let e=[],g=(c,h)=>{let j=a.get(c);if(j){for(let c of[...j.directories.keys()].sort(f)){let f=i(c,a),j=!f.paths.some(a=>b.has(a));e.push({key:d("directory",c),type:"directory",path:f.targetPath,label:f.label,depth:h,directory:f,expanded:j}),j&&g(f.targetPath,h+1)}for(let a of[...j.files].sort(f))e.push({key:d("file",a),type:"file",path:a,label:a.slice(a.lastIndexOf("/")+1),depth:h})}};return g(c,0),e}c.d(b,{Im:()=>d,Kn:()=>f,OA:()=>h,_J:()=>e,qV:()=>j,rk:()=>g,xV:()=>i})},84386:(a,b,c)=>{"use strict";c.d(b,{q:()=>aA});var d=c(52834),e=c(57850),f=c(35385),g=c(46505),h=c(34911),i=c(38721),j=c(22207),k=c(79918),l=c(39620),m=c(9665),n=c(97586),o=c(84912),p=c(37096),q=c(5319),r=c(39511),s=c(32772),t=c(49147),u=c(15620),v=c(14120),w=c(91816),x=c(92494),y=c(60819),z=c(49057);let A=[{scope:"current",label:"closeTab"},{scope:"others",label:"closeOtherTabs"},{scope:"right",label:"closeRightTabs"},{scope:"left",label:"closeLeftTabs"},{scope:"all",label:"closeAllTabs"}];function B(a,b){let c=a.replaceAll("\\","/").split("/"),d=b.map(a=>a.replaceAll("\\","/")).filter(a=>a!==c.join("/"));for(let a=1;a<c.length;a++){let b=c.slice(-a).join("/");if(!d.some(c=>c.split("/").slice(-a).join("/")===b))return b}return c.join("/")}function C({cwd:a,gitRuntime:b,paths:c,activePath:f,diffs:g,activeDiff:h,mobile:i,actions:j,onActivate:k,onClose:l}){let{t:m}=(0,e.Bd)("projectFiles");(0,t.useSyncExternalStore)(b.subscribe,b.getRevision,b.getRevision);let n=b.getWorkspace(a)?.snapshot,o=(0,t.useRef)(null),p=(0,t.useRef)(!1),r=[...c,...g.map(a=>[a.repositoryRoot,a.path].filter(Boolean).join("/"))],D=c.map(a=>({target:a,key:`file:${a}`,path:a,label:B(a,r),title:a,testId:`file-tab-${a}`}));for(let a of g){let b=[a.repositoryRoot,a.path].filter(Boolean).join("/"),c=a.comparison,d=c?`${c.baseCommit?.slice(0,7)??"∅"} → ${c.targetCommit.slice(0,7)}`:"",e=(0,x.Q)(a);D.push({target:a,key:`diff:${e}`,path:b,label:`${B(b,r)} \xb7 Diff`,revisions:d,title:[b,c?.oldPath,c?`${c.baseCommit??"∅"} → ${c.targetCommit}`:null].filter(Boolean).join("\n"),testId:`file-diff-tab-${b}${c?`-${e}`:""}`})}let E=h?`diff:${(0,x.Q)(h)}`:`file:${f}`;return 0===D.length?null:(0,d.jsxs)("div",{className:"flex min-w-0 max-w-full shrink-0 flex-col border-b bg-muted","data-testid":"file-tabs",children:[(0,d.jsx)("div",{className:"min-w-0 max-w-full",children:(0,d.jsx)("div",{ref:o,role:"tablist","aria-label":m("openFiles"),"aria-orientation":"horizontal",className:"relative flex min-w-0 flex-nowrap items-stretch overflow-x-auto overflow-y-hidden overscroll-x-contain [scrollbar-color:var(--border)_transparent] [scrollbar-width:thin]",children:D.map((b,c)=>{let e=b.key===E,f="string"!=typeof b.target,g=f||n?.status!=="ready"?void 0:(0,z.lN)(a,b.path,n.repositories)?.change,h=f?m("closeDiff",{name:`${b.path.split("/").at(-1)}${b.revisions?` \xb7 ${b.revisions}`:""}`}):m("closeFile",{name:b.path.split("/").at(-1)});return(0,d.jsxs)(w.tz,{onOpenChange:(a,b)=>{a&&"pointerType"in b.event&&"touch"===b.event.pointerType&&(p.current=!0)},children:[(0,d.jsxs)(w.Rc,{render:(0,d.jsx)("div",{"data-file-tab":!0,"data-testid":b.testId,title:b.title,className:(0,u.cn)("flex shrink-0 items-center border-r text-sm transition-colors",i?"h-9":"h-8",b.revisions?"max-w-[min(100%,20rem)]":"max-w-[min(100%,15rem)]",e?"bg-background text-foreground shadow-[inset_0_-2px_0_var(--foreground)]":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),onPointerDown:a=>{"touch"===a.pointerType&&(p.current=!1)}}),children:[(0,d.jsxs)("button",{type:"button",role:"tab","aria-selected":e,className:"flex h-full min-w-0 flex-1 cursor-pointer items-center gap-2 pl-3 pr-1 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onFocus:a=>{var b;let c,d,e=a.currentTarget.closest("[data-file-tab]");o.current&&e&&(b=o.current,d=(c=e.offsetLeft)+e.offsetWidth,c<b.scrollLeft?b.scrollLeft=c:d>b.scrollLeft+b.clientWidth&&(b.scrollLeft=d-b.clientWidth))},onClick:()=>{if(p.current){p.current=!1;return}k(b.target)},onKeyDown:a=>{if("F10"===a.key&&a.shiftKey){a.preventDefault(),a.stopPropagation();let b=a.currentTarget.closest('[data-slot="context-menu-trigger"]');if(b){let a=b.getBoundingClientRect();b.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:a.left+a.width/2,clientY:a.top+a.height/2}))}return}let b="ArrowRight"===a.key||"ArrowDown"===a.key?1:"ArrowLeft"===a.key||"ArrowUp"===a.key?-1:0;if(!b)return;a.preventDefault();let d=(c+b+D.length)%D.length,e=o.current?.querySelectorAll('[role="tab"]');e?.[d]?.focus({preventScroll:!0})},children:[(0,d.jsx)(v.s,{path:b.path,className:"size-4 shrink-0"}),(0,d.jsx)("span",{className:(0,u.cn)("truncate",g&&(0,z.iH)(g)),children:b.label}),b.revisions?(0,d.jsx)("span",{className:"max-w-36 truncate font-mono text-xs",children:b.revisions}):null,g?(0,d.jsx)("span",{className:(0,u.cn)("shrink-0 text-xs",(0,z.iH)(g)),"aria-label":m("gitStatus",{status:(0,z.XB)(g)}),children:(0,z.XB)(g)}):null]}),(0,d.jsx)(q.$,{variant:"ghost",size:"icon",className:(0,u.cn)("shrink-0 rounded-none",i&&"size-9"),"data-testid":f?b.testId.replace("file-diff-tab-","file-diff-tab-close-"):`file-tab-close-${b.path}`,"aria-label":h,onClick:a=>{if(a.stopPropagation(),p.current){p.current=!1;return}l(b.target,"current")},children:(0,d.jsx)(s.A,{className:"size-3.5"})})]}),(0,d.jsx)(y.D,{children:A.map(({scope:a,label:e})=>(0,d.jsxs)("span",{children:["all"===a?(0,d.jsx)(w.K5,{}):null,(0,d.jsx)(w.kt,{disabled:"others"===a?D.length<=1:"left"===a?0===c:"right"===a&&c===D.length-1,onClick:()=>{p.current=!1,l(b.target,a)},children:m(e)})]},a))})]},b.key)})})}),j?(0,d.jsx)("div",{className:(0,u.cn)("flex min-h-9 min-w-0 max-w-full flex-wrap items-center justify-end gap-1 overflow-x-auto border-t bg-background p-1 [&>*]:min-w-0 [&>*]:max-w-full [&>span]:break-all [&>[role=group]]:flex-wrap",i&&"[&_button]:min-h-9 [&_button]:min-w-9"),role:"group","aria-label":m("fileActions"),children:j}):null]})}var D=c(17747),E=c(31748),F=c(51314),G=c(30340),H=c(29837),I=c(41568),J=c(79904),K=c(50599),L=c(90814),M=c(93306),N=c(87348);c(82386),c(51972);var O=c(96478);let P=(0,t.forwardRef)(function({original:a,modified:b,viewMode:c,onEscape:f,savedState:g,onSaveState:h,initialLine:i},j){let{t:k}=(0,e.Bd)("common"),{wrapLines:l,collapseUnchanged:m}=(0,O.TX)(),n=(0,t.useRef)(null),o=(0,t.useRef)(null);(0,t.useRef)({viewMode:c,wrapLines:l,collapseUnchanged:m}),(0,t.useRef)(f),(0,t.useRef)(g),(0,t.useRef)(h),(0,t.useRef)(i);let[p,q]=(0,t.useState)("loading"),[r,s]=(0,t.useState)(null);return(0,t.useImperativeHandle)(j,()=>({previousChange(){o.current?.goToDiff("previous")},nextChange(){o.current?.goToDiff("next")},focus(){o.current?.getModifiedEditor().focus()}}),[]),(0,d.jsxs)("div",{"data-testid":"code-diff",className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden bg-background",children:[(0,d.jsx)("div",{ref:n,className:"min-h-0 flex-1"}),(0,d.jsx)("div",{role:"status","aria-label":k("diffStatus"),className:"flex min-h-6 shrink-0 items-center justify-end border-t px-3 text-xs text-muted-foreground",children:null===r?k("diffCalculating"):k("diffCount",{count:r})}),"loading"===p?(0,d.jsxs)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center gap-2 bg-background text-sm text-muted-foreground",children:[(0,d.jsx)(L.A,{className:"size-4 animate-spin"})," ",k("diffLoading")]}):null,"error"===p?(0,d.jsx)("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center text-sm text-destructive",children:k("diffFailed")}):null]})});var Q=c(85544),R=c(2719),S=c(61332),T=c(59582);function U({label:a,onClick:b,active:c=!1,children:e}){return(0,d.jsxs)(T.m_,{children:[(0,d.jsx)(T.k$,{render:(0,d.jsx)(q.$,{type:"button",size:"icon-sm",variant:"ghost","aria-label":a,"aria-pressed":c||void 0,onPointerDown:a=>a.preventDefault(),onClick:b}),children:e}),(0,d.jsx)(T.ZI,{children:a})]})}var V=c(45694),W=c(45427),X=c(55091);function Y({ref:a,runtime:b,gitRuntime:c,compact:f,visible:g=!0,onEscape:h,onSwitchPane:i,renderHeader:j}){let k,m,p,r,s,u,v,w,{t:y}=(0,e.Bd)("projectFiles"),{wrapLines:A,diffViewMode:B,collapseUnchanged:C}=(0,O.TX)();(0,t.useSyncExternalStore)(b.subscribe,b.getRevision,b.getRevision);let{activeDiff:L,activePath:T}=b.state,$=!L&&T?b.state.documents.get(T):null,_=T?(0,X.g)(T):null,aa=$?.status==="text"&&(!_||"source"===$.viewMode),ab=(0,t.useRef)(null),ac=(0,t.useRef)(null),ad=(0,t.useRef)(null),ae=(0,t.useRef)(null),af=(0,R.G)();(0,t.useImperativeHandle)(a,()=>({focus(){aa?ac.current?.focus():L?ad.current?.focus():ab.current?.querySelector('[data-testid="markdown-preview"]')?.focus()}}),[L,aa]);let ag=()=>{T&&ac.current&&b.saveEditorState(T,ac.current.getViewState())},{refresh:ah,unavailable:ai}=((0,t.useSyncExternalStore)(c.subscribe,c.getRevision,c.getRevision),k=c.getWorkspace(b.cwd)?.snapshot,m=b.state.activePath,r=!!(p=b.state.activeDiff),m&&b.state.documents.get(m),s=(0,t.useRef)(ag),u=(0,t.useCallback)(()=>{m&&!r&&(s.current(),b.reloadFile(m),c.refreshSnapshot(b.cwd))},[r,c,m,b]),v=(0,t.useCallback)(()=>{p?b.refreshDiff():m&&(s.current(),b.ensureDocument(m,!0)),c.refreshSnapshot(b.cwd)},[p,c,m,b]),(0,S.L)(ab,v,g),w=m&&k?.status==="ready"?(0,z.lN)(b.cwd,m,k.repositories):null,{refresh:u,unavailable:k?.status==="error"||w?.repository.state==="unavailable"}),aj=$?.status==="text"?$.comparison:void 0,[ak,al]=(0,t.useState)(null),am=aj?.status==="ready"&&$?.status==="text"&&ak?.original===aj.original.content&&ak.modified===$.content?ak.count:void 0,an=a=>{T&&(ag(),b.openFileDiff(T,a))},ao=ai||aj?.status==="error"?y("gitMarkersFailed"):aj?.status==="unavailable"||aj?.status==="ready"&&null===am?y("gitMarkersUnavailable"):aj?.status==="loading"||aj?.status==="ready"&&void 0===am?y("gitMarkersLoading"):aj?.status==="ready"?y("gitChangesCount",{count:am}):null,ap=L||T?(0,d.jsx)(d.Fragment,{children:L?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"mr-auto shrink-0 px-1 text-xs text-muted-foreground",children:[L.label??(L.comparison?`${L.comparison.baseCommit?.slice(0,7)??"∅"} → ${L.comparison.targetCommit.slice(0,7)}`:y("headToWorking")),"text"===L.status&&L.original.content===L.modified.content?y("noDiffChanges"):""]}),(0,d.jsx)(U,{label:y("previousChange"),onClick:()=>ad.current?.previousChange(),children:(0,d.jsx)(D.A,{className:"size-4"})}),(0,d.jsx)(U,{label:y("nextChange"),onClick:()=>ad.current?.nextChange(),children:(0,d.jsx)(E.A,{className:"size-4"})}),f?null:(0,d.jsx)(U,{label:"side-by-side"===B?y("inlineDiff"):y("sideBySideDiff"),active:"inline"===B,onClick:()=>b.setDiffViewMode("side-by-side"===B?"inline":"side-by-side"),children:(0,d.jsx)(o.A,{className:"size-4"})}),(0,d.jsx)(U,{label:y(A?"wrapOff":"wrapOn"),active:A,onClick:()=>b.setDiffWrapLines(!A),children:(0,d.jsx)(F.A,{className:"size-4"})}),(0,d.jsx)(U,{label:y(C?"expandUnchanged":"collapseUnchanged"),active:C,onClick:()=>b.setDiffCollapseUnchanged(!C),children:(0,d.jsx)(G.A,{className:"size-4"})}),(0,d.jsx)(U,{label:y("reloadDiff"),onClick:()=>b.reloadDiff(),children:(0,d.jsx)(l.A,{className:"size-4"})})]}):(0,d.jsxs)(d.Fragment,{children:[_&&$?.status==="text"&&T?(0,d.jsx)("div",{className:"mr-auto flex shrink-0",role:"group","aria-label":y("markdown"===_?"markdownMode":"htmlMode"),children:["preview","source"].map(a=>(0,d.jsx)(q.$,{variant:$.viewMode===a?"secondary":"ghost",size:"sm","aria-pressed":$.viewMode===a,onClick:()=>{ag(),b.setTextViewMode(T,a)},children:y("preview"===a?"previewMode":"sourceMode")},a))}):null,aa&&ao?(0,d.jsx)("span",{"data-testid":"file-git-status",role:"status",className:"mr-auto min-w-0 truncate text-xs text-muted-foreground",title:aj?.status==="error"?aj.error:ao,children:f&&aj?.status==="ready"&&"number"==typeof am?y("gitChangesCompact",{count:am}):ao}):null,aa&&aj?.status==="ready"?(0,d.jsxs)(d.Fragment,{children:["number"==typeof am&&am>0?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(U,{label:y("previousChange"),onClick:()=>ac.current?.previousChange(),children:(0,d.jsx)(D.A,{className:"size-4"})}),(0,d.jsx)(U,{label:y("nextChange"),onClick:()=>ac.current?.nextChange(),children:(0,d.jsx)(E.A,{className:"size-4"})})]}):null,(0,d.jsx)(U,{label:y("viewDiff"),onClick:()=>an(),children:(0,d.jsx)(H.A,{className:"size-4"})})]}):null,aa&&T?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(U,{label:y("findInFile"),onClick:()=>ac.current?.openSearch(),children:(0,d.jsx)(I.A,{className:"size-4"})}),f?null:(0,d.jsx)(U,{label:y("goToLine"),onClick:()=>ac.current?.gotoLine(),children:(0,d.jsx)(J.A,{className:"size-4"})}),(0,d.jsx)(U,{label:y(A?"wrapOff":"wrapOn"),active:A,onClick:()=>b.setWrapLines(T,!A),children:(0,d.jsx)(F.A,{className:"size-4"})}),(0,d.jsx)(U,{label:y("copySelectionOrAll"),onClick:()=>{if($?.status!=="text")return;let a=ac.current?.getSelectionText()??"";(0,M.x)(a||$.content).then(b=>{b?af.success(y(a?"selectedCodeCopied":"allCodeCopied")):af.error(y("copyContentFailed"))})},children:(0,d.jsx)(K.A,{className:"size-4"})})]}):null,T?(0,d.jsx)(U,{label:y("reloadCurrentFile"),onClick:ah,children:(0,d.jsx)(l.A,{className:"size-4"})}):null]})}):null;return(0,d.jsxs)("div",{ref:ab,className:"flex size-full min-h-0 min-w-0 flex-col outline-none",tabIndex:-1,onFocus:a=>{a.target===a.currentTarget&&(aa?ac.current?.focus():L?ad.current?.focus():ab.current?.querySelector('[data-testid="markdown-preview"]')?.focus())},children:[j?j(ap):ap?(0,d.jsx)("div",{className:"flex min-h-9 shrink-0 flex-wrap items-center justify-end gap-2 border-b px-3 py-1","aria-label":y("fileActions"),children:ap}):null,(0,d.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden pb-[env(safe-area-inset-bottom)]",children:L?"text"===L.status?(0,d.jsx)(P,{ref:ad,original:L.original,modified:L.modified,viewMode:f?"inline":B,savedState:L.editorState,initialLine:L.initialLine,onSaveState:a=>b.saveDiffState(L,a),onEscape:h},(0,x.Q)(L)):"metadata"===L.status?(0,d.jsxs)("div",{className:"grid h-full grid-cols-1 gap-4 overflow-auto p-4 md:grid-cols-2",children:[(0,d.jsx)("pre",{className:"whitespace-pre-wrap break-all text-sm",children:L.originalMetadata}),(0,d.jsx)("pre",{className:"whitespace-pre-wrap break-all text-sm",children:L.modifiedMetadata})]}):"loading"===L.status||"unloaded"===L.status?(0,d.jsx)(Z,{}):(0,d.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-center text-sm",children:[(0,d.jsx)("p",{className:"text-muted-foreground",children:"binary"===L.status?y("binaryDiffUnavailable"):"too_large"===L.status?y("largeDiffUnavailable"):L.error}),"error"===L.status?(0,d.jsx)(q.$,{variant:"outline",onClick:()=>b.reloadDiff(),children:y("readAgain")}):null]}):T&&$?"loading"===$.status||"unloaded"===$.status?(0,d.jsx)(Z,{}):"error"===$.status?(0,d.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-center",children:[(0,d.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:$.error}),(0,d.jsx)(q.$,{variant:"outline",onClick:()=>b.reloadFile(T),children:y("readAgain")})]}):"image"===$.status?(0,d.jsx)(Q.k,{mode:"inline",slides:[{src:$.objectUrl,alt:T}],ariaLabel:y("imageViewer",{name:T.replaceAll("\\","/").split("/").at(-1)??T})},$.objectUrl):"markdown"===_&&"preview"===$.viewMode?(0,d.jsx)(W.n,{content:$.content,label:y("markdownPreview",{name:T}),savedScrollTop:$.previewScrollTop,onScroll:a=>b.savePreviewScrollTop(T,a)},T):"html"===_&&"preview"===$.viewMode?(0,d.jsx)("iframe",{ref:ae,className:"block size-full border-0 bg-white",sandbox:"allow-scripts",srcDoc:(0,V.z)($.content),title:y("htmlPreview",{name:T})}):(0,d.jsx)(N.e,{ref:ac,path:T,content:$.content,size:$.size,originalContent:aj?.status==="ready"?aj.original.content:void 0,onChanges:a=>{aj?.status==="ready"&&al({original:aj.original.content,modified:$.content,count:a})},onOpenDiff:an,savedState:$.editorState,navigation:b.pendingNavigation,onNavigation:(a,c)=>b.consumeNavigation(a,c),onSaveState:(a,c)=>b.saveEditorState(a,c),onEscape:h},T):(0,d.jsxs)("div",{"data-testid":"file-workspace-empty",className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-sm text-muted-foreground",children:[(0,d.jsx)(n.A,{className:"size-6"}),y("noOpenFile")]})})]})}function Z(){let{t:a}=(0,e.Bd)("projectFiles");return(0,d.jsxs)("div",{className:"flex size-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,d.jsx)(L.A,{className:"size-4 animate-spin"}),a("loadingFile")]})}var $=c(68341),_=c(1222);function aa(a){let b=window.matchMedia("(pointer: fine)");return b.addEventListener("change",a),()=>b.removeEventListener("change",a)}function ab(){return window.matchMedia("(pointer: fine)").matches}function ac(){return!1}var ad=c(79739),ae=c(53403),af=c(4998),ag=c(5701),ah=c(11071),ai=c(82589);function aj({items:a,label:b,scrollTop:c,onScroll:e,render:f,role:g="listbox",onKeyDown:h,rowHeight:i=36,onNearEnd:j,footer:k}){let l=(0,t.useRef)(null),[m,n]=(0,t.useState)({top:c,height:300}),o=Math.max(0,Math.floor(m.top/i)-8),p=Math.min(a.length,Math.ceil((m.top+m.height)/i)+8);return(0,d.jsxs)("div",{ref:l,role:g,tabIndex:"tree"===g?0:void 0,onKeyDown:h,"aria-label":b,className:"min-h-0 flex-1 overflow-auto overscroll-contain",onScroll:a=>{let b=a.currentTarget.scrollTop;n(a=>({...a,top:b})),e(b)},children:[(0,d.jsx)("div",{style:{height:a.length*i,position:"relative"},children:(0,d.jsx)("div",{style:{position:"absolute",top:o*i,left:0,right:0},children:a.slice(o,p).map((a,b)=>f(a,o+b))})}),k]})}var ak=c(37496),al=c(9365),am=c(75152),an=c(51108),ao=c(83731);let ap={added:"A",modified:"M",deleted:"D",renamed:"R","type-changed":"T"};function aq({cwd:a,repositoryRoot:b,rows:c,changes:f,selectedPath:g,scrollTop:h,rowHeight:i,onScroll:j,onSelect:k,onToggle:l,onOpen:m,onReveal:n}){let{t:p}=(0,e.Bd)("projectHistory"),r=(0,t.useRef)(null),s=(a,b)=>{a&&r.current===b&&(r.current=null,a.focus({preventScroll:!0}))},v=new Map(f.map(a=>[a.path,a]));return(0,d.jsx)(aj,{role:"tree",label:p("changeFiles"),items:c,scrollTop:h,rowHeight:i,onScroll:j,onKeyDown:a=>{if(a.defaultPrevented||!a.currentTarget.contains(a.target))return;let b=a.target instanceof Element?a.target.closest("[data-tree-key]"):null;if(a.target instanceof Element&&a.target.closest("button"))return;let d=b?c.findIndex(a=>a.key===b.dataset.treeKey):-1,e=c[d],f=d;if("ArrowDown"===a.key)f=Math.min(c.length-1,d+1);else if("ArrowUp"===a.key)f=Math.max(0,d-1);else if("Home"===a.key)f=0;else if("End"===a.key)f=c.length-1;else if("ArrowRight"===a.key&&e?.directory)e.expanded?f=Math.min(c.length-1,d+1):l(e.directory.path);else if("ArrowLeft"===a.key&&e){if(e.expanded&&e.directory)l(e.directory.path);else for(let a=d-1;a>=0;a-=1)if(c[a].depth<e.depth){f=a;break}}else{if("Enter"!==a.key&&" "!==a.key||!e)return;e.directory?l(e.directory.path):"Enter"===a.key?m(e.path):k(e.path)}a.preventDefault();let g=c[f];if(!g)return;let h=a.currentTarget;f*i<h.scrollTop?h.scrollTop=f*i:(f+1)*i>h.scrollTop+h.clientHeight&&(h.scrollTop=(f+1)*i-h.clientHeight),r.current=g.key,s([...h.querySelectorAll("[data-tree-key]")].find(a=>a.dataset.treeKey===g.key)??null,g.key)},render:c=>{let e=v.get(c.path),f=(0,ao._J)(b,c.path),h=c.directory;return(0,d.jsx)(an.J,{cwd:a,path:f,type:c.type,historical:!0,expanded:c.expanded,onToggle:h?()=>l(h.path):void 0,onOpen:"file"===c.type?()=>m(c.path):void 0,openLabel:p("viewDiff"),oldPath:"file"===c.type&&e?.oldPath?(0,ao._J)(b,e.oldPath):void 0,onReveal:n,trigger:(0,d.jsxs)("div",{ref:a=>s(a,c.key),role:"treeitem",tabIndex:0,"aria-level":c.depth+1,"aria-expanded":c.expanded,"aria-selected":"file"===c.type&&g===c.path,"data-tree-key":c.key,className:(0,u.cn)("flex min-w-0 cursor-pointer items-center gap-1 pr-1 text-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","file"===c.type&&g===c.path&&"bg-accent"),style:{height:i,paddingLeft:4+c.depth*(24===i?12:24)},title:e?.oldPath&&"file"===c.type?`${(0,ao._J)(b,e.oldPath)} → ${f}`:f,onClick:a=>{h?a.detail<2&&l(h.path):k(c.path)},onDoubleClick:()=>{"file"===c.type&&m(c.path)},children:[h?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ak.A,{className:(0,u.cn)("size-4 shrink-0 text-muted-foreground",c.expanded&&"rotate-90")}),c.expanded?(0,d.jsx)(al.A,{className:"size-4 shrink-0 text-muted-foreground"}):(0,d.jsx)(am.A,{className:"size-4 shrink-0 text-muted-foreground"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"w-4 shrink-0"}),(0,d.jsx)("span",{className:(0,u.cn)("w-4 shrink-0 font-mono text-xs",e?.status==="added"?"text-emerald-600 dark:text-emerald-400":e?.status==="deleted"?"text-red-600 dark:text-red-400":"text-blue-600 dark:text-blue-400"),"aria-label":p("gitStatus",{status:e?ap[e.status]:""}),children:e?ap[e.status]:""})]}),(0,d.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[c.label,"directory"===c.type&&v.has(c.path)?"/":""]}),"file"===c.type?(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost",className:24===i?"size-6":void 0,"aria-label":p("viewDiffPath",{path:c.path}),onDoubleClick:a=>a.stopPropagation(),onClick:a=>{a.stopPropagation(),m(c.path)},children:(0,d.jsx)(o.A,{className:"size-4"})}):null]})},c.key)}})}var ar=c(37259),as=c(99451),at=c(87366),au=c(97832),av=c(42704);function aw(a){let b=[],c=a;for(;c.includes("/")&&"refs"!==(c=c.slice(0,c.lastIndexOf("/")));)b.push(c);return b}function ax({branches:a,value:b,onChange:c,ariaLabel:g,placeholder:h,className:i}){let{t:j}=(0,e.Bd)("projectHistory"),{t:k}=(0,e.Bd)("common"),l=(0,t.useId)(),m=(0,t.useRef)(null),n=(0,t.useRef)(null),o=(0,t.useRef)(new Map),[p,r]=(0,t.useState)(!1),[s,v]=(0,t.useState)(""),[w,x]=(0,t.useState)(b),[y,A]=(0,t.useState)(()=>new Set(["refs/heads","refs/remotes",...aw(b)])),B=s.trim().toLocaleLowerCase(),C="HEAD"===b?j("currentHead"):b.replace(/^refs\/(heads|remotes)\//,""),D=(0,t.useMemo)(()=>{let b=[],c=[{key:"refs/heads",label:j("localBranch"),names:a?.local??[]},{key:"refs/remotes",label:j("remoteBranch"),names:a?.remote??[]}].map(a=>({...a,nodes:(0,z.oY)(a.names.filter(a=>a.toLocaleLowerCase().includes(B)))})).filter(a=>a.nodes.length>0),d=`HEAD ${j("currentHead")}`.toLocaleLowerCase().includes(B),e=c.length+Number(d);d&&b.push({key:"HEAD",label:j("currentHead"),fullName:j("currentHead"),parentKey:null,level:1,position:1,siblingCount:e,expandable:!1});let f=(a,c,d,e)=>{a.forEach((g,h)=>{let i=`${c}/${g.path}`;b.push({key:i,label:g.name,fullName:g.path,parentKey:d,level:e,position:h+1,siblingCount:a.length,expandable:g.children.length>0}),y.has(i)&&f(g.children,c,i,e+1)})};return c.forEach((a,c)=>{b.push({key:a.key,label:a.label,fullName:a.label,parentKey:null,level:1,position:c+Number(d)+1,siblingCount:e,expandable:!0}),y.has(a.key)&&f(a.nodes,a.key,a.key,2)}),b},[a,y,B,j]),E=D.find(a=>a.key===w)??D.find(a=>a.key===b)??D.find(a=>!a.expandable)??D[0],F=a=>{if(!a)return;x(a.key);let b=o.current.get(a.key);b?.focus({preventScroll:!0}),b?.scrollIntoView({block:"nearest"})},G=a=>{A(b=>{let c=new Set(b);return c.has(a.key)?c.delete(a.key):c.add(a.key),c})};return(0,d.jsxs)(av.AM,{open:p,onOpenChange:a=>{a&&(v(""),x(b),A(a=>new Set([...a,...aw(b)]))),r(a)},onOpenChangeComplete:a=>{a&&document.activeElement===m.current&&o.current.get(b)?.scrollIntoView({block:"nearest"})},children:[(0,d.jsx)(av.Wv,{render:(0,d.jsxs)(q.$,{ref:n,type:"button",variant:"outline",role:"combobox","aria-haspopup":"dialog","aria-label":g,"aria-expanded":p,title:C||h,className:(0,u.cn)("w-full min-w-0 justify-between border-input px-2.5 font-normal focus-visible:-outline-offset-2",i),children:[(0,d.jsxs)("span",{className:(0,u.cn)("flex min-w-0 flex-1 items-center gap-2",!b&&"text-muted-foreground"),children:["HEAD"===b?(0,d.jsx)(ar.A,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"}):(0,d.jsx)(f.A,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"min-w-0 truncate",children:C||h||k("selectPlaceholder")})]}),(0,d.jsx)(as.A,{className:"text-muted-foreground"})]})}),(0,d.jsxs)(av.hl,{align:"start","aria-label":g,initialFocus:m,finalFocus:n,positionerClassName:"z-[120]",className:"max-h-[min(30rem,var(--available-height))] w-[max(26rem,calc(var(--anchor-width)+8rem))] max-w-[min(calc(100vw-2rem),var(--available-width))] gap-0 overflow-hidden p-0",children:[(0,d.jsx)("div",{className:"shrink-0 border-b p-2",children:(0,d.jsx)(ah.p,{ref:m,type:"search","aria-label":k("searchPlaceholder"),"aria-controls":l,placeholder:k("searchPlaceholder"),value:s,onChange:b=>(b=>{v(b),x("");let c=b.trim().toLocaleLowerCase();if(!c)return;let d=[...(a?.local??[]).filter(a=>a.toLocaleLowerCase().includes(c)).map(a=>`refs/heads/${a}`),...(a?.remote??[]).filter(a=>a.toLocaleLowerCase().includes(c)).map(a=>`refs/remotes/${a}`)];A(a=>new Set([...a,...d.flatMap(aw)]))})(b.target.value),onKeyDown:a=>{a.nativeEvent.isComposing||a.altKey||a.ctrlKey||a.metaKey||("ArrowDown"===a.key||"ArrowUp"===a.key)&&(a.preventDefault(),a.stopPropagation(),F("ArrowDown"===a.key?E:D.at(-1)))}})}),(0,d.jsx)("div",{id:l,role:"tree","aria-label":g,className:"min-h-0 overflow-y-auto overscroll-contain p-1",children:D.map(a=>{let e=!a.expandable&&a.key===b,g=a.expandable?y.has(a.key):void 0,h=a.expandable?1===a.level?null:g?al.A:am.A:"HEAD"===a.key?ar.A:f.A;return(0,d.jsxs)("button",{ref:b=>{b?o.current.set(a.key,b):o.current.delete(a.key)},type:"button",role:"treeitem","aria-label":a.fullName,"aria-level":a.level,"aria-posinset":a.position,"aria-setsize":a.siblingCount,"aria-selected":a.expandable?void 0:e,"aria-expanded":g,tabIndex:E?.key===a.key?0:-1,title:a.fullName,className:(0,u.cn)("flex min-h-8 w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left text-sm outline-none transition-colors duration-150 hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring [@media(pointer:coarse)]:min-h-10",e&&"bg-accent text-accent-foreground",1===a.level&&a.expandable&&"font-medium text-muted-foreground"),style:{paddingLeft:8+12*Math.min(a.level-1,8)},onFocus:()=>x(a.key),onKeyDown:b=>((a,b)=>{if(a.nativeEvent.isComposing||a.altKey||a.ctrlKey||a.metaKey)return;let c=D.indexOf(b);switch(a.key){case"ArrowDown":F(D[Math.min(c+1,D.length-1)]);break;case"ArrowUp":F(D[Math.max(c-1,0)]);break;case"Home":F(D[0]);break;case"End":F(D.at(-1));break;case"ArrowRight":b.expandable&&(y.has(b.key)?F(D[c+1]):G(b));break;case"ArrowLeft":b.expandable&&y.has(b.key)?G(b):F(D.find(a=>a.key===b.parentKey));break;default:return}a.preventDefault(),a.stopPropagation()})(b,a),onClick:()=>{x(a.key),a.expandable?G(a):(c(a.key),r(!1))},children:[a.expandable?g?(0,d.jsx)(at.A,{"aria-hidden":"true",className:"size-3.5 shrink-0"}):(0,d.jsx)(ak.A,{"aria-hidden":"true",className:"size-3.5 shrink-0"}):(0,d.jsx)("span",{"aria-hidden":"true",className:"size-3.5 shrink-0"}),h?(0,d.jsx)(h,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"}):null,(0,d.jsx)("span",{className:"min-w-0 flex-1 break-all",children:a.label}),e?(0,d.jsx)(au.A,{"aria-hidden":"true",className:"size-3.5 shrink-0"}):null]},a.key)})}),D.length?null:(0,d.jsx)("p",{role:"status",className:"px-3 py-6 text-center text-sm text-muted-foreground",children:k("noMatches")}),E&&E.fullName!==E.label?(0,d.jsx)("div",{className:"max-h-24 shrink-0 overflow-y-auto border-t px-3 py-2 text-xs break-all text-muted-foreground",children:E.fullName}):null]})]})}function ay(a){let{state:b,repositories:c,projectName:f,narrow:g,scroll:h}=a,{t:i}=(0,e.Bd)("projectHistory"),{locale:j,timeZone:k}=(0,af.i)(),m=(0,t.useMemo)(()=>new Intl.DateTimeFormat("en"===j?"en-US":"zh-CN",{timeZone:k,month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),[j,k]),n=(0,t.useMemo)(()=>new Intl.DateTimeFormat("en"===j?"en-US":"zh-CN",{timeZone:k,timeZoneName:"shortOffset",year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),[j,k]),o=(0,t.useId)(),{mobilePane:r,onMobilePane:s}=a,v=b.changes.data,w=`${b.repositoryRoot}:${v?.comparison.original}:${v?.comparison.target}`,x=b.selectedChangePath,y=b.branches.data?.upstream,z=v?.commit,A=(c,e=a.onRefresh)=>c?(0,d.jsxs)("div",{role:"alert",className:"flex flex-wrap items-center gap-2 p-3 text-sm text-destructive",children:[(0,d.jsx)("span",{className:"min-w-0 flex-1 break-words",children:c}),(0,d.jsx)(q.$,{size:"sm",variant:"outline",onClick:e,children:i("retry")}),"compare"===b.mode&&"merge-base"===b.strategy?(0,d.jsx)(q.$,{size:"sm",variant:"outline",onClick:()=>a.onStrategy("direct"),children:i("compareDirect")}):null]}):null,B=(0,d.jsx)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:(0,d.jsx)(aj,{items:b.log.data?.items??[],label:i("commitList"),scrollTop:h.log,onScroll:b=>a.onScroll("log",b),onNearEnd:"ready"===b.log.status&&b.log.data?.hasMore&&b.log.data.items.length<2e3?a.onMoreLog:void 0,footer:(0,d.jsxs)(d.Fragment,{children:[A(b.log.error,b.log.data?a.onMoreLog:a.onRefresh),"loading"===b.log.status?(0,d.jsxs)("div",{role:"status",className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,d.jsx)(L.A,{className:"size-4 animate-spin"}),i("loadingCommits")]}):null,"ready"!==b.log.status||b.log.data?.items.length?null:(0,d.jsx)("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:b.query||b.author?i("noMatchingCommits"):i("noCommits")}),b.log.data?.truncated?(0,d.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("scanLimit")}):(b.log.data?.items.length??0)>=2e3?(0,d.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("loadedLimit")}):"ready"===b.log.status&&b.log.data?.items.length&&!b.log.data.hasMore?(0,d.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("noMoreCommits")}):null]}),render:c=>(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":b.selectedCommit===c.oid,className:(0,u.cn)("flex h-9 w-full items-center gap-3 border-b border-border/40 px-3 text-left text-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",b.selectedCommit===c.oid&&"bg-accent"),onClick:()=>{var b;return b=c.oid,void(a.onCommit(b),g&&s("files"))},title:`${c.subject}
14
14
  ${c.oid}
15
- ${c.author} \xb7 ${n.format(c.timestampMs)}`,children:[(0,d.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[c.subject||i("noCommitMessage"),c.refs.length?(0,d.jsx)("span",{className:"ml-2 text-xs text-muted-foreground",children:c.refs.join(" \xb7 ")}):null]}),(0,d.jsx)("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:c.oid.slice(0,7)}),g?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"w-20 truncate text-xs text-muted-foreground",children:c.author}),(0,d.jsx)("time",{className:"w-28 shrink-0 text-right text-xs text-muted-foreground",children:m.format(c.timestampMs)})]})]},c.oid)},`${b.repositoryRoot}:${b.mode}:${b.tip}:${b.base}:${b.target}:${b.query}:${b.author}`)}),C=(0,d.jsxs)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:[(0,d.jsxs)("div",{className:"flex min-h-9 shrink-0 flex-wrap items-center gap-2 border-b px-3 py-1",children:[g?(0,d.jsx)(q.$,{variant:"ghost",size:"icon-sm","aria-label":i("backCommits"),onClick:()=>s("log"),children:(0,d.jsx)(ad.A,{className:"size-4"})}):null,(0,d.jsx)("span",{className:"text-sm font-medium",children:b.selectedCommit?i("commitChanges"):i("cumulativeChanges")}),t?(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:i("loadedFiles",{count:t.items.length})}):null,"compare"===b.mode&&b.selectedCommit?(0,d.jsx)(q.$,{variant:"ghost",size:"sm",onClick:a.onAggregate,children:i("backCumulative")}):null]}),A(b.changes.error),"loading"===b.changes.status?(0,d.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,d.jsx)(M.A,{className:"size-4 animate-spin"}),i("loadingChanges")]}):null,(0,d.jsxs)(p.HK,{orientation:"vertical",defaultLayout:{"project-changes":a.panelSizes.changes,"project-detail":100-a.panelSizes.changes},onLayoutChanged:(b,c)=>{c.isUserInteraction&&void 0!==b["project-changes"]&&a.onPanelSize("changes",b["project-changes"])},children:[(0,d.jsx)(p.wV,{id:"project-changes",defaultSize:`${a.panelSizes.changes}%`,minSize:"80px",children:(0,d.jsxs)("div",{className:"flex size-full min-h-0 flex-col",children:[(0,d.jsx)(aq,{cwd:a.cwd,repositoryRoot:b.repositoryRoot??"",rows:a.changeRows,rowHeight:a.changeRowHeight,changes:t?.items??[],selectedPath:x,scrollTop:h.changes,onScroll:b=>a.onScroll("changes",b),onSelect:a.onSelectChange,onToggle:a.onToggleDirectory,onOpen:a.onOpenFile,onReveal:a.onReveal},u),"ready"!==b.changes.status||t?.items.length?null:(0,d.jsx)("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:i("noDiff")}),t?.hasMore?(0,d.jsx)(q.$,{size:"sm",variant:"ghost",disabled:"loading"===b.changes.status,onClick:a.onMoreChanges,children:i("loadMoreFiles")}):null,t?.truncated?(0,d.jsx)("p",{className:"p-3 text-xs text-muted-foreground",children:i("changesLimit")}):null]})}),(0,d.jsx)(p.WM,{}),(0,d.jsx)(p.wV,{id:"project-detail",defaultSize:`${100-a.panelSizes.changes}%`,minSize:"60px",children:(0,d.jsxs)(ag.V,{className:"h-full",viewportClassName:"p-3 text-sm",role:"region","aria-label":i("commitDetails"),children:[z?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("pre",{className:"mb-3 whitespace-pre-wrap break-words font-sans leading-relaxed",children:z.message}),(0,d.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,d.jsx)("span",{className:"min-w-0 flex-1 break-all font-mono text-xs",children:z.oid}),(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":i("copySha"),onClick:()=>a.onCopy(z.oid),children:(0,d.jsx)(L.A,{className:"size-4"})})]}),(0,d.jsxs)("p",{className:"mb-3 text-xs text-muted-foreground",children:[z.author," \xb7 ",n.format(z.timestampMs)]}),z.parents.length>1?(0,d.jsx)(ai.b,{className:"mb-3",ariaLabel:i("compareParent"),value:z.selectedParent??"",options:z.parents.map((a,b)=>({value:a,label:i("parentCommit",{count:b+1,oid:a.slice(0,10)})})),onChange:b=>a.onCommit(z.oid,b)}):null]}):t?(0,d.jsxs)("div",{className:"space-y-2 text-xs text-muted-foreground",children:[(0,d.jsx)("p",{children:"merge-base"===b.strategy?i("mergeBaseToTarget"):i("baseToTarget")}),(0,d.jsx)("p",{className:"break-all font-mono",children:t.comparison.original??i("emptyRevision")}),(0,d.jsx)("p",{className:"break-all font-mono",children:t.comparison.target})]}):(0,d.jsx)("p",{className:"text-muted-foreground",children:i("selectCommit")}),x?(0,d.jsx)("p",{className:"mt-3 break-all font-mono text-xs text-muted-foreground",children:x}):null]})})]})]});return(0,d.jsxs)("section",{className:"flex size-full min-h-0 min-w-0 flex-col","aria-label":i("historyAndCompare"),children:[(0,d.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b px-3 py-2",children:[(0,d.jsxs)("div",{className:"flex gap-1",role:"group","aria-label":i("viewMode"),children:[(0,d.jsx)(q.$,{size:"sm",variant:"history"===b.mode?"secondary":"ghost","aria-pressed":"history"===b.mode,onClick:()=>{a.onMode("history"),s("log")},children:i("historyMode")}),(0,d.jsx)(q.$,{size:"sm",variant:"compare"===b.mode?"secondary":"ghost","aria-pressed":"compare"===b.mode,onClick:()=>{a.onMode("compare"),s("log")},children:i("compareMode")})]}),(0,d.jsx)(ai.b,{className:"w-44",ariaLabel:i("selectRepository"),value:b.repositoryRoot??"",options:c.map(a=>({value:a.root,label:a.root||f,description:"unavailable"===a.state?(0,ae.fD)(a.message,j):void 0})),onChange:a.onRepository}),"history"===b.mode?(0,d.jsx)(av,{className:"w-48",ariaLabel:i("viewBranch"),value:b.tip,branches:b.branches.data,onChange:b=>a.onRevision("tip",b)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(av,{className:"w-44",ariaLabel:i("baseBranch"),placeholder:i("chooseBase"),value:b.base,branches:b.branches.data,onChange:b=>a.onRevision("base",b)}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"→"}),(0,d.jsx)(av,{className:"w-44",ariaLabel:i("targetBranch"),value:b.target,branches:b.branches.data,onChange:b=>a.onRevision("target",b)}),(0,d.jsx)(ai.b,{className:"w-48",ariaLabel:i("comparison"),value:b.strategy,options:[{value:"merge-base",label:i("introducedChanges")},{value:"direct",label:i("directComparison")}],onChange:b=>a.onStrategy("direct"===b?"direct":"merge-base")}),g?(0,d.jsx)(q.$,{size:"sm",variant:"outline",onClick:()=>s("files"),children:i("cumulativeChanges")}):null]}),(0,d.jsx)(ah.p,{className:"w-40 shrink-0","aria-label":i("filterAuthor"),placeholder:i("author"),list:o,value:b.author,onChange:b=>a.onAuthor(b.target.value)}),(0,d.jsx)("datalist",{id:o,children:b.authorSuggestions.map(a=>(0,d.jsx)("option",{value:a},a))}),(0,d.jsx)(ah.p,{className:"min-w-32 flex-1 basis-40","aria-label":i("searchCommits"),placeholder:i("searchCommits"),value:b.query,onChange:b=>a.onQuery(b.target.value)}),(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":i("refreshGit"),onClick:a.onRefresh,children:(0,d.jsx)(l.A,{className:"size-4"})})]}),b.branches.error?A(b.branches.error):null,y?(0,d.jsxs)("p",{className:"shrink-0 truncate border-b px-3 py-1 text-xs text-muted-foreground",title:y.ref,children:[y.ref.replace("refs/remotes/","")," \xb7 ",i("localRecord")," \xb7"," ",null===y.ahead||null===y.behind?i("refUnavailable"):i("aheadBehind",{ahead:y.ahead,behind:y.behind})]}):null,"compare"!==b.mode||b.base?g?"log"===r?B:C:(0,d.jsxs)(p.HK,{orientation:"horizontal",defaultLayout:{"project-log":a.panelSizes.log,"project-files":100-a.panelSizes.log},onLayoutChanged:(b,c)=>{c.isUserInteraction&&void 0!==b["project-log"]&&a.onPanelSize("log",b["project-log"])},children:[(0,d.jsx)(p.wV,{id:"project-log",defaultSize:`${a.panelSizes.log}%`,minSize:"30%",children:B}),(0,d.jsx)(p.WM,{}),(0,d.jsx)(p.wV,{id:"project-files",defaultSize:`${100-a.panelSizes.log}%`,minSize:"25%",children:C})]}):(0,d.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:i("chooseBaseBranch")})]})}let ax=()=>{};function ay({clientId:a,cwd:b,refreshOnFocus:c,title:s,actions:t,onEscape:u=ax,onUnauthorized:w}){let{t:x}=(0,e.Bd)("projectHistory"),y=(0,S.G)(),{files:z,git:A,history:B,global:C,updateGlobal:E,page:F,setPage:G,historyPane:H,setHistoryPane:I,setContainer:J,narrow:K,stacked:L,width:M,changeRowHeight:O,openGit:P,refresh:Q}=function(a,b,c,d){let e=(0,S.G)(),[f]=(0,v.useState)(_.N1),[g,h]=(0,v.useState)(f),i=(0,v.useCallback)(a=>{h(b=>({...b,...a})),(0,_.Ms)({...(0,_.N1)(),...a})},[]),[j]=(0,v.useState)(()=>(0,_.tQ)(b)),[k]=(0,v.useState)(()=>(0,$.ph)(a,b,a=>e.show({level:"info",title:a}),j,f,{lazyHistory:!c,onUnauthorized:d})),{files:l,git:m,history:n}=k;(0,v.useSyncExternalStore)(l.subscribe,l.getRevision,l.getRevision),(0,v.useSyncExternalStore)(m.subscribe,m.getRevision,m.getRevision),(0,v.useSyncExternalStore)(n.subscribe,n.getRevision,n.getRevision);let[o,p]=(0,v.useState)(j?.page??"files"),[q,r]=(0,v.useState)(j?.historyPane??"log"),[s,t]=(0,v.useState)({width:1200,height:800}),[u,w]=(0,v.useState)(null);(0,v.useRef)(!1),(0,v.useRef)(()=>void 0);let x=s.width<900,y=x||s.height<680;m.getWorkspace(b).snapshot.repositories;let z=l.state,A=(0,v.useSyncExternalStore)(aa,ab,ac),B=g.gitOpen&&(!y||"git"===o);return{files:l,git:m,history:n,global:g,updateGlobal:i,page:o,setPage:p,historyPane:q,setHistoryPane:r,setContainer:w,narrow:x,stacked:y,width:s.width,changeRowHeight:A?24:36,openGit(a){i({gitOpen:!0}),p("git"),void 0!==a&&n.setRepository(a)},refresh(){l.refreshTree(),m.refreshSnapshot(b),z.activeDiff?l.reloadDiff():z.activePath&&l.reloadFile(z.activePath),B&&n.refresh()}}}(a,b,c,w),{directoryOpen:R,gitOpen:T,gitMaximized:U}=C,V=b.replaceAll("\\","/").split("/").filter(Boolean).at(-1)??b,W=A.getWorkspace(b),X=W.snapshot.repositories,Z=z.state,ad=(0,d.jsx)(r.F,{cwd:b,projectName:V,showRootTitle:!1,runtime:z,gitRuntime:A,onOpenGitBranches:P,onFileOpened:()=>G("code")}),ae=(0,d.jsx)(Y,{runtime:z,gitRuntime:A,compact:M<1100,refreshOnFocus:c,onEscape:u,renderHeader:a=>(0,d.jsx)(D,{cwd:b,gitRuntime:A,paths:Z.tabs,activePath:Z.activePath,diffs:Z.diffs,activeDiff:Z.activeDiff,mobile:K,actions:a,onActivate:a=>{"string"==typeof a?z.openFile(a):z.openDiff(a.repositoryRoot,a.path,a.comparison)},onClose:(a,b)=>z.closeTabs(a,b)})}),af=(0,d.jsxs)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:[(0,d.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-2 border-b bg-muted px-3",children:[(0,d.jsx)(f.A,{className:"size-4"}),(0,d.jsx)("span",{className:"flex-1 text-sm font-medium",children:"Git"}),L?null:(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":x(U?"restoreGit":"maximizeGit"),onClick:()=>E({gitMaximized:!U}),children:U?(0,d.jsx)(g.A,{className:"size-4"}):(0,d.jsx)(h.A,{className:"size-4"})}),(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":x("collapseGit"),onClick:()=>{E({gitOpen:!1,gitMaximized:!1}),G("code")},children:(0,d.jsx)(i.A,{className:"size-4"})})]}),X.length?(0,d.jsx)(aw,{state:B.state,cwd:b,changeRows:B.getChangeRows(),changeRowHeight:O,onSelectChange:a=>B.selectChange(a),onToggleDirectory:a=>B.toggleChangeDirectory(a),onReveal:(a,b)=>z.revealFile(a,b),repositories:X,projectName:V,narrow:K,mobilePane:H,onMobilePane:I,scroll:B.scroll,onScroll:(a,b)=>B.setScroll(a,b),panelSizes:{log:C.logSize,changes:C.changeSize},onPanelSize:(a,b)=>E("log"===a?{logSize:b}:{changeSize:b}),onRepository:a=>{B.setRepository(a),I("log")},onMode:a=>B.setMode(a),onRevision:(a,b)=>B.setRevision(a,b),onStrategy:a=>B.setStrategy(a),onQuery:a=>B.setQuery(a),onAuthor:a=>B.setAuthor(a),onCommit:(a,b)=>B.selectCommit(a,b),onAggregate:()=>B.showAggregate(),onMoreLog:()=>B.loadMoreLog(),onMoreChanges:()=>B.loadMoreChanges(),onOpenFile:a=>{B.openChange(a),G("code"),E({gitMaximized:!1})},onRefresh:()=>B.refresh(),onCopy:a=>{(0,N.x)(a).then(a=>{a||y.error(x("copyFailed"))})}}):(0,d.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:"loading"===W.snapshot.status||"idle"===W.snapshot.status?x("findingGit"):W.snapshot.error??x("noGit")})]}),ag=(0,d.jsxs)(p.HK,{orientation:"horizontal",defaultLayout:R?{"project-tree":C.directorySize,"project-code":100-C.directorySize}:void 0,onLayoutChanged:(a,b)=>{b.isUserInteraction&&void 0!==a["project-tree"]&&E({directorySize:a["project-tree"]})},children:[R?(0,d.jsx)(p.wV,{id:"project-tree",defaultSize:`${C.directorySize}%`,minSize:"180px",maxSize:"40%",children:ad}):null,R?(0,d.jsx)(p.WM,{}):null,(0,d.jsx)(p.wV,{id:"project-code",minSize:"40%",children:ae})]},R?"tree-visible":"tree-hidden");return(0,d.jsxs)("div",{ref:J,className:"flex size-full min-h-0 min-w-0 flex-col overflow-hidden","data-testid":"project-preview",children:[(0,d.jsxs)("header",{className:"flex min-h-9 shrink-0 items-center gap-1 bg-muted px-2 py-1 pt-[max(4px,env(safe-area-inset-top))]",children:[L?null:(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":x(R?"collapseDirectory":"expandDirectory"),onClick:()=>E({directoryOpen:!R}),children:R?(0,d.jsx)(j.A,{className:"size-4"}):(0,d.jsx)(k.A,{className:"size-4"})}),(0,d.jsxs)("div",{className:"flex min-w-0 flex-1 items-baseline gap-3",title:b,children:[(0,d.jsx)("div",{className:"min-w-0 shrink-0 max-w-[50%] max-sm:max-w-full max-sm:shrink",children:s??(0,d.jsx)("h1",{className:"truncate text-sm font-semibold",children:V})}),(0,d.jsx)("p",{className:"min-w-0 truncate text-xs text-muted-foreground max-sm:hidden",children:b})]}),(0,d.jsxs)(q.$,{size:"sm",variant:T?"secondary":"ghost","aria-pressed":T,onClick:()=>P(),children:[(0,d.jsx)(f.A,{className:"size-4"}),(0,d.jsx)("span",{className:"max-sm:hidden",children:x("gitRecords")})]}),(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":x("refreshPreview"),onClick:Q,children:(0,d.jsx)(l.A,{className:"size-4"})}),t]}),W.snapshot.error?(0,d.jsx)("p",{role:"alert",className:"shrink-0 border-b px-3 py-2 text-sm text-destructive",children:W.snapshot.error}):null,L?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex shrink-0 gap-1 px-2 py-1",role:"group","aria-label":x("previewArea"),children:[(0,d.jsxs)(q.$,{size:"sm",variant:"files"===F?"secondary":"ghost",onClick:()=>G("files"),children:[(0,d.jsx)(m.A,{className:"size-4"}),x("files")]}),(0,d.jsxs)(q.$,{size:"sm",variant:"code"===F?"secondary":"ghost",onClick:()=>G("code"),children:[(0,d.jsx)(n.A,{className:"size-4"}),x("code")]}),(0,d.jsxs)(q.$,{size:"sm",variant:"git"===F?"secondary":"ghost",onClick:()=>P(),children:[(0,d.jsx)(o.A,{className:"size-4"}),"Git"]})]}),(0,d.jsx)("div",{className:"min-h-0 flex-1",children:"files"===F?ad:"git"===F?af:ae})]}):U&&T?af:(0,d.jsxs)(p.HK,{orientation:"vertical",defaultLayout:T?{"project-main":100-C.gitSize,"project-git":C.gitSize}:void 0,onLayoutChanged:(a,b)=>{b.isUserInteraction&&void 0!==a["project-git"]&&E({gitSize:a["project-git"]})},children:[(0,d.jsx)(p.wV,{id:"project-main",defaultSize:T?`${100-C.gitSize}%`:"100%",minSize:"35%",children:ag}),T?(0,d.jsx)(p.WM,{}):null,T?(0,d.jsx)(p.wV,{id:"project-git",defaultSize:`${C.gitSize}%`,minSize:"300px",children:af}):null]},T?"git-visible":"git-hidden")]})}},85544:(a,b,c)=>{"use strict";c.d(b,{k:()=>h});var d=c(52834);c(84593);var e=c(49147),f=c(15620),g=c(4998);function h(a){let{locale:b}=(0,g.i)(),{slides:c,index:h=0,onIndexChange:i,className:j,thumbnails:k=!0,ariaLabel:l="en"===b?"Image preview":"图片预览"}=a,m="inline"===a.mode,n="inline"===a.mode||a.open,o="modal"===a.mode?a.onClose:void 0;c.length;let p=Math.min(Math.max(h,0),Math.max(c.length-1,0)),q=`pi-desk-image-viewer-${(0,e.useId)().replaceAll(":","")}`,r=(0,e.useRef)(null),s=(0,e.useRef)(null),t=(0,e.useRef)(null);if((0,e.useRef)(""),(0,e.useRef)(""),(0,e.useRef)(p),(0,e.useRef)(p),(0,e.useRef)(i),(0,e.useRef)(o),(0,e.useMemo)(()=>JSON.stringify(c.map(a=>[a.src,a.alt])),[c]),(0,f.cn)("pi-desk-image-viewer",m?"pi-desk-image-viewer-inline":"pi-desk-image-viewer-modal",q,j),0===c.length||!n)return null;let u=(0,d.jsx)("span",{ref:r,className:"pi-desk-image-viewer-source","aria-hidden":"true",children:c.map((a,b)=>(0,d.jsx)("img",{src:a.src,alt:a.alt,width:a.width,height:a.height,decoding:"async",draggable:!1},b))});return m?(0,d.jsx)("div",{ref:s,className:"pi-desk-image-viewer-host",role:"region","aria-label":l,tabIndex:0,onKeyDown:a=>{let b=t.current;!b||b.fulled||a.altKey||a.ctrlKey||a.metaKey||a.nativeEvent.isComposing||("ArrowLeft"===a.key||"ArrowRight"===a.key)&&(a.preventDefault(),a.stopPropagation(),"ArrowLeft"===a.key?b.prev(!1):b.next(!1))},children:u}):u}},87348:(a,b,c)=>{"use strict";c.d(b,{e:()=>k});var d=c(52834),e=c(90814),f=c(49147),g=c(57850);c(82386),c(51972);var h=c(96478),i=c(70448),j=c.n(i);let k=(0,f.forwardRef)(function({path:a,content:b,size:c,savedState:i,onSaveState:k,onEscape:l,originalContent:m,onChanges:n,onOpenDiff:o,navigation:p,onNavigation:q},r){let{t:s}=(0,g.Bd)("common"),{t:t}=(0,g.Bd)("projectFiles"),{wrapLines:u}=(0,h.TX)(),v=(0,f.useRef)(null),w=(0,f.useRef)(null);(0,f.useRef)(k),(0,f.useRef)(u),(0,f.useRef)(i),(0,f.useRef)(l);let x=(0,f.useRef)(null);(0,f.useRef)(n),(0,f.useRef)(o),(0,f.useRef)(q);let y=(0,f.useRef)(null),z=(0,f.useRef)(null);(0,f.useCallback)(a=>{let b=z.current;y.current?.clear(),null===b||b>(a.getModel()?.getLineCount()??0)||(y.current??=a.createDecorationsCollection(),y.current.set([{range:{startLineNumber:b,startColumn:1,endLineNumber:b,endColumn:1},options:{isWholeLine:!0,className:"bg-accent"}}]))},[]);let[A,B]=(0,f.useState)("loading");return(0,f.useImperativeHandle)(r,()=>({openSearch(){w.current?.getAction("actions.find")?.run()},gotoLine(){w.current?.getAction("editor.action.gotoLine")?.run()},getSelectionText(){let a=w.current,b=a?.getModel(),c=a?.getSelection();return b&&c&&!c.isEmpty()?b.getValueInRange(c):""},getViewState:()=>w.current?.saveViewState()??null,focus(){w.current?.focus()},previousChange(){x.current?.previousChange()},nextChange(){x.current?.nextChange()}}),[]),(0,d.jsxs)("div",{"data-testid":"code-preview",className:"relative h-full min-h-0 w-full overflow-hidden bg-background",children:[(0,d.jsx)("div",{ref:v,className:`size-full ${j().host}`}),"loading"===A?(0,d.jsxs)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center gap-2 bg-background text-sm text-muted-foreground",children:[(0,d.jsx)(e.A,{className:"size-4 animate-spin"})," ",s("codeLoading")]}):null,"error"===A?(0,d.jsx)("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center text-sm text-destructive",children:s("codeFailed")}):null]})})},89101:(a,b,c)=>{"use strict";c.d(b,{Ik:()=>n,MG:()=>j,Sq:()=>l,iV:()=>o,oR:()=>p});var d=c(52834);c(49147);var e=c(80546),f=c(15620),g=c(5319),h=c(11071),i=c(13221);function j({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"input-group",role:"group",className:(0,f.cn)("group/input-group relative flex min-h-8 w-full min-w-0 items-center rounded-lg border border-input bg-card transition-colors duration-150 outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-muted has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:outline-2 has-[[data-slot=input-group-control]:focus-visible]:outline-solid has-[[data-slot=input-group-control]:focus-visible]:-outline-offset-2 has-[[data-slot=input-group-control]:focus-visible]:outline-ring has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",a),...b})}let k=(0,e.F)("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function l({className:a,align:b="inline-start",...c}){return(0,d.jsx)("div",{role:"group","data-slot":"input-group-addon","data-align":b,className:(0,f.cn)(k({align:b}),a),onClick:a=>{a.target.closest("button")||a.currentTarget.parentElement?.querySelector("input")?.focus()},...c})}let m=(0,e.F)("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"min-h-7 gap-2 rounded-md px-2",sm:"","icon-xs":"size-7 rounded-md p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function n({className:a,type:b="button",variant:c="ghost",size:e="xs",...h}){return(0,d.jsx)(g.$,{type:b,"data-size":e,variant:c,className:(0,f.cn)(m({size:e}),a),...h})}function o({className:a,...b}){return(0,d.jsx)(h.p,{"data-slot":"input-group-control",className:(0,f.cn)("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:outline-none focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0",a),...b})}function p({className:a,...b}){return(0,d.jsx)(i.T,{"data-slot":"input-group-control",className:(0,f.cn)("flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:outline-none focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0",a),...b})}},91464:(a,b,c)=>{"use strict";c.d(b,{S6:()=>d,dQ:()=>e,hD:()=>f});let d="relative flex min-h-7 cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-sm leading-5 outline-none select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e="data-[variant=destructive]:text-destructive data-[variant=destructive]:data-highlighted:bg-destructive/10 data-[variant=destructive]:data-highlighted:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive",f="z-50 max-h-(--available-height) min-w-60 max-w-[calc(100vw-2rem)] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-md outline-none transition-[opacity,transform] duration-100 ease-out data-starting-style:scale-[0.98] data-starting-style:opacity-0 data-ending-style:scale-[0.98] data-ending-style:opacity-0 motion-reduce:transition-none"},91816:(a,b,c)=>{"use strict";c.d(b,{Ip:()=>q,JW:()=>o,K5:()=>s,Rc:()=>p,kt:()=>r,tz:()=>n});var d=c(52834);c(49147);var e=c(49067),f=c(10962),g=c(48329),h=c(65614),i=c(9698),j=c(16484),k=c(36089),l=c(15620),m=c(91464);function n({...a}){return(0,d.jsx)(e.D,{"data-slot":"context-menu",...a})}function o({...a}){return(0,d.jsx)(f.g,{"data-slot":"context-menu-portal",...a})}function p({className:a,...b}){return(0,d.jsx)(g.R,{"data-slot":"context-menu-trigger",className:(0,l.cn)("select-none",a),...b})}function q({className:a,align:b="start",alignOffset:c=4,side:e="right",sideOffset:g=0,finalFocus:j=!1,...k}){return(0,d.jsx)(f.g,{children:(0,d.jsx)(h.y,{className:"isolate z-50 outline-none",align:b,alignOffset:c,side:e,sideOffset:g,children:(0,d.jsx)(i._,{"data-slot":"context-menu-content",finalFocus:j,className:(0,l.cn)(m.hD,a),...k})})})}function r({className:a,inset:b,variant:c="default",...e}){return(0,d.jsx)(j.D,{"data-slot":"context-menu-item","data-inset":b,"data-variant":c,className:(0,l.cn)(m.S6,m.dQ,"group/context-menu-item",a),...e})}function s({className:a,...b}){return(0,d.jsx)(k.w,{"data-slot":"context-menu-separator",className:(0,l.cn)("-mx-1 my-1 h-px bg-border",a),...b})}},92494:(a,b,c)=>{"use strict";c.d(b,{Q:()=>m,h:()=>p});var d=c(89172),e=c(21850),f=c(28661),g=c(96478),h=c(95186),i=c(55091),j=c(83731);let k={scope:"all",caseSensitive:!1,wholeWord:!1,regex:!1};function l(a){return{...a,status:a.query.trim()?"loading":"idle",fileMatches:[],contentMatches:[],truncated:!1,error:null}}function m(a){return JSON.stringify([a.repositoryRoot,a.path,a.comparison?.baseCommit??null,a.comparison?.targetCommit??null,a.comparison?.oldPath??null])}function n(a,b){return(0,e.B)({msg:d.C["zh-CN"][a],i18n:{key:`projectFiles:${a}`,...b?{params:b}:{}}})}function o(a){return a instanceof Error?a.message:n("projectReadFailed")}class p{constructor(a,b,c){this.cwd=a,this.reader=b,this.options=c,this.state={tabs:[],activePath:null,directories:new Map,expandedPaths:new Set,treeScrollTop:0,search:l({query:"",...k}),searchOpen:!1,documents:new Map,diffs:[],activeDiff:null},this.listeners=new Set,this.directoryRequests=new Map,this.compactRequests=new Map,this.documentRequests=new Map,this.closeMissing=new Set,this.restoredTabs=new Set,this.restoredEditorStates=new Map,this.restoredFileViewModes=new Map,this.restoredPreviewScrollTops=new Map,this.searchRequest=null,this.navigation=null,this.diffRequests=new Map,this.revision=0,this.disposed=!1,this.subscribe=a=>(this.listeners.add(a),()=>this.listeners.delete(a)),this.getRevision=()=>this.revision}setSearchOpen(a){this.disposed||this.state.searchOpen===a||(this.cancelSearch(),this.state.searchOpen=a,this.state.search=l({...this.searchInput(),scope:a?"all":this.state.search.scope}),this.publish())}get pendingNavigation(){let a=this.state.activePath;return a&&!this.documentRequests.has(a)?this.navigation:null}consumeNavigation(a,b){this.navigation===a&&(this.navigation=null,b||this.options.onNotice?.(n("searchLineUnavailable")),this.publish())}get canReveal(){return!!this.options.reveal}getBrowsingDocumentSettings(){let a={},b={};for(let c of this.state.tabs){let d=this.state.documents.get(c),e=d?.status==="text"?d.editorState:this.restoredEditorStates.get(c);e&&JSON.stringify(e).length<32768&&(a[c]=e);let f=d?.status==="text"?d.viewMode:this.restoredFileViewModes.get(c);f&&(b[c]=f)}return{editorStates:a,fileViewModes:b}}restoreBrowsing(a){if(this.disposed)return;for(let b of(this.state.tabs=a.tabs.slice(0,this.options.maxTabs),this.state.tabs)){this.restoredTabs.add(b);let c=a.editorStates[b];c&&this.restoredEditorStates.set(b,c);let d=a.fileViewModes[b];d&&this.restoredFileViewModes.set(b,d)}for(let b of(this.state.activePath=a.activePath&&this.state.tabs.includes(a.activePath)?a.activePath:null,this.state.expandedPaths=new Set(a.expandedPaths),this.state.treeScrollTop=a.treeScrollTop,this.state.search=l({query:a.searchQuery,...k}),this.state.tabs))this.state.documents.set(b,{status:"unloaded"});for(let b of[...a.diffs??[],...a.activeDiff?[a.activeDiff]:[]])if(!this.state.diffs.some(a=>m(a)===m(b))){if(this.options.maxTabs&&this.state.tabs.length+this.state.diffs.length>=this.options.maxTabs)break;this.state.diffs.push({...b,status:"unloaded"})}for(let b of a.expandedPaths)this.ensureDirectory(b);this.publish();let b=a.activeDiff,c=b?this.state.diffs.find(a=>m(a)===m(b)):null;c?this.openDiff(c.repositoryRoot,c.path,c.comparison):this.state.activePath&&this.ensureDocument(this.state.activePath)}async revealFile(a,b="file"){if(!this.options.reveal)throw Error(n("revealUnavailable"));await this.options.reveal(a,b)}ensureRoot(){return this.ensureDirectory("")}ensureDirectory(a){if(this.disposed||this.state.directories.get(a)?.status==="ready")return Promise.resolve();let b=this.directoryRequests.get(a);if(b)return b.promise;let c=new AbortController,d=Promise.resolve().then(async()=>{try{if(c.signal.aborted)return;let b=await this.reader.list(a,c.signal);if(this.directoryRequests.get(a)?.controller!==c)return;this.state.directories.set(a,{status:"ready",...b})}catch(b){if(this.directoryRequests.get(a)?.controller!==c)return;this.state.directories.set(a,{status:"error",error:o(b)})}this.directoryRequests.get(a)?.controller===c&&(this.directoryRequests.delete(a),this.publish())});return this.directoryRequests.set(a,{controller:c,promise:d}),this.state.directories.set(a,{status:"loading"}),this.publish(),d}setExpandedPaths(a,b=!0){let c=[...this.state.expandedPaths].filter(b=>!a.has(b));for(let b of(this.state.expandedPaths=new Set(a),this.compactRequests.keys()))c.some(a=>b===a||b.startsWith(`${a}/`))&&this.compactRequests.delete(b);if(this.publish(),b)for(let b of a)this.ensureDirectory(b)}cancelDirectoryExpansion(a=""){for(let b of this.compactRequests.keys())(!a||b===a||b.startsWith(`${a}/`))&&this.compactRequests.delete(b)}compactDirectory(a,b){return(0,j.rk)(a,a=>{let b=this.onlyDirectory(a);return b&&this.state.directories.has(b)?b:null},b)}async expandDirectoryChain(a,b){let c={};this.compactRequests.set(a,c);let d=a,e=16;for(;!this.disposed&&this.compactRequests.get(a)===c&&this.state.expandedPaths.has(a);){if(this.state.directories.get(d)?.status!=="ready"){if(e--<=0)break;await this.ensureDirectory(d)}if(this.compactRequests.get(a)!==c||this.disposed)return;let f=this.onlyDirectory(d);if(!f||b.has(d)||b.has(f)||e<=0&&this.state.directories.get(f)?.status!=="ready")break;this.state.expandedPaths.add(f),d=f,this.publish()}this.compactRequests.get(a)===c&&this.compactRequests.delete(a)}onlyDirectory(a){let b=this.state.directories.get(a);if(b?.status!=="ready"||b.truncated||1!==b.entries.length)return null;let c=b.entries[0];return"directory"===c.type?(0,j._J)(a,c.name):null}setTreeScrollTop(a){this.state.treeScrollTop=a}refreshTree(){for(let a of(this.compactRequests.clear(),this.directoryRequests.values()))a.controller.abort();this.directoryRequests.clear(),this.state.directories.clear(),this.cancelSearch(),this.state.search=l(this.searchInput()),this.publish(),this.ensureRoot().then(()=>{if(!this.disposed){for(let a of this.state.expandedPaths)this.ensureDirectory(a);this.state.searchOpen&&this.state.search.query.trim()&&(this.cancelSearch(),this.state.search={...this.state.search,status:"loading"},this.search(this.state.search.query))}})}setSearchQuery(a){this.disposed||this.state.search.query===a||(this.cancelSearch(),this.state.search=l({...this.searchInput(),query:a}),this.publish())}setSearchOptions(a){if(this.disposed)return;let b=this.searchInput(),c={...b,...a};(c.scope!==b.scope||c.caseSensitive!==b.caseSensitive||c.wholeWord!==b.wholeWord||c.regex!==b.regex)&&(this.cancelSearch(),this.state.search=l(c),this.publish(),this.state.searchOpen&&this.search(c.query))}searchInput(){let{query:a,scope:b,caseSensitive:c,wholeWord:d,regex:e}=this.state.search;return{query:a,scope:b,caseSensitive:c,wholeWord:d,regex:e}}async search(a){if(this.disposed||!a.trim()||this.state.search.query!==a||"ready"===this.state.search.status||this.searchRequest)return;let b=new AbortController;this.searchRequest=b;let c=this.searchInput();this.state.search=l(c),this.publish();try{let a=await this.reader.search(c,b.signal);if(this.searchRequest!==b)return;this.state.search={...c,status:"ready",...a,error:null}}catch(a){if(this.searchRequest!==b)return;this.state.search={...l(c),status:"error",error:o(a)}}this.searchRequest===b&&(this.searchRequest=null,this.publish())}openFile(a,b){var c;let d,e;if(this.disposed)return;let f=(c=this.cwd,d=a.replaceAll("\\","/"),e=`${c.replaceAll("\\","/").replace(/\/+$/,"")}/`,(/^[a-z]:\//i.test(e)||e.startsWith("//")?d.toLowerCase().startsWith(e.toLowerCase()):d.startsWith(e))?d.slice(e.length):d),g=/^[a-z]:[\\/]/i.test(this.cwd)||this.cwd.startsWith("\\\\")?this.state.tabs.find(a=>a.toLowerCase()===f.toLowerCase())??f:f;if(!this.state.tabs.includes(g)){if(!this.canOpenTab())return;this.state.tabs.push(g)}this.state.activeDiff=null,this.state.documents.has(g)||this.state.documents.set(g,{status:"unloaded"}),this.state.activePath=g,this.navigation=void 0===b?null:{line:b};let h=this.state.documents.get(g);void 0!==b&&h?.status==="text"&&(h.viewMode="source"),this.ensureDocument(g,void 0!==b),this.publish()}closeTabs(a,b){if(this.disposed)return;let c=this.state,d=[...c.tabs,...c.diffs],e=null===a?c.activeDiff:"string"==typeof a?a:c.diffs.find(b=>m(b)===m(a)),f=null==e?-1:d.indexOf(e);if(f<0&&"all"!==b)return;let g=new Set(d.filter((a,c)=>"all"===b||("current"===b?a===e:"others"===b?a!==e:"left"===b?c<f:c>f)));if(!g.size)return;let h=c.activeDiff??c.activePath;for(let a of g){if("string"!=typeof a){this.invalidateDiff(a);continue}this.documentRequests.get(a)?.abort(),this.documentRequests.delete(a),this.releaseDocument(c.documents.get(a)),c.documents.delete(a),this.restoredEditorStates.delete(a),this.restoredFileViewModes.delete(a),this.restoredPreviewScrollTops.delete(a),this.closeMissing.delete(a),this.restoredTabs.delete(a)}if(c.tabs=c.tabs.filter(a=>!g.has(a)),c.diffs=c.diffs.filter(a=>!g.has(a)),c.activePath&&g.has(c.activePath)){let a=d.filter(a=>"string"==typeof a),b=a.indexOf(c.activePath);c.activePath=a.slice(b+1).find(a=>!g.has(a))??a.slice(0,b).reverse().find(a=>!g.has(a))??null}if(null!==h&&g.has(h)){this.navigation=null;let a=d.indexOf(h),b=d.slice(a+1).find(a=>!g.has(a))??d.slice(0,a).reverse().find(a=>!g.has(a));c.activeDiff="object"==typeof b?b:null,"string"==typeof b&&(c.activePath=b)}this.publish(),c.activeDiff?this.ensureDiff(c.activeDiff):c.activePath&&h!==c.activePath&&this.ensureDocument(c.activePath)}reloadFile(a){if(this.state.tabs.includes(a)){if(this.state.activePath===a&&this.navigation)return void this.ensureDocument(a,!0);this.invalidateDocument(a),this.publish(),this.ensureDocument(a)}}async ensureDocument(a,b=!1){if(this.disposed||!this.state.tabs.includes(a)||this.documentRequests.has(a))return;let c=this.state.documents.get(a);if(!b&&c&&["loading","text","image"].includes(c.status))return;let d=new AbortController;this.documentRequests.set(a,d),c?.status!=="text"&&this.state.documents.set(a,{status:"loading"}),this.publish();try{let b=await this.reader.get(a,this.options.imagePreviewMode(),d.signal);if(this.documentRequests.get(a)!==d)return;this.documentRequests.delete(a),this.closeMissing.delete(a),this.restoredTabs.delete(a),(c?.status!=="text"||"text"!==b.kind||c.content!==b.content||c.size!==b.size)&&this.state.documents.set(a,"text"===b.kind?{status:"text",content:b.content,size:b.size,editorState:c?.status==="text"?c.editorState:this.restoredEditorStates.get(a)??null,viewMode:this.state.activePath===a&&this.navigation?"source":c?.status==="text"?c.viewMode:this.restoredFileViewModes.get(a)??("markdown"===(0,i.g)(a)||this.options.htmlPreview&&"html"===(0,i.g)(a)?"preview":"source"),previewScrollTop:c?.status==="text"?c.previewScrollTop:this.restoredPreviewScrollTops.get(a)??0}:{status:"image",mimeType:b.mimeType,size:b.size,objectUrl:URL.createObjectURL((0,f.E)(b))}),this.state.activePath===a&&"text"!==b.kind&&(this.navigation=null),this.releaseDocument(c)}catch(f){if(this.documentRequests.get(a)!==d)return;this.documentRequests.delete(a);let b=this.restoredTabs.delete(a),e=this.closeMissing.delete(a);if((b||e)&&f instanceof h.aw&&404===f.status&&"errors:fileMissing"===f.errorKey){this.closeTabs(a,"current"),e&&this.options.onNotice?.(n("branchFileClosed",{path:a}));return}console.warn("[Pi Desk][ProjectFile] 读取文件失败",{cwd:this.cwd,path:a,error:o(f)}),this.state.documents.set(a,{status:"error",error:o(f)}),this.releaseDocument(c),this.state.activePath===a&&(this.navigation=null)}this.publish()}async compareFile(a,b,c){let d=this.state.documents.get(a);if(this.disposed||c.aborted||d?.status!=="text")return;if(!b){d.comparison&&(delete d.comparison,this.publish());return}let e={status:"loading"};d.comparison=e,this.publish();let f=()=>!this.disposed&&!c.aborted&&this.state.documents.get(a)===d&&d.comparison===e;try{let a=await this.reader.diff(b.repositoryRoot,b.path,c);if(!f())return;"text"===a.kind?(d.content=a.modified.content,d.size=new TextEncoder().encode(a.modified.content).length,d.comparison={status:"ready",repositoryRoot:b.repositoryRoot,path:b.path,original:a.original}):d.comparison={status:"unavailable"}}catch(b){if(!f())return;console.warn("[Pi Desk][ProjectFile] 读取行变更失败",{cwd:this.cwd,path:a,error:o(b)}),d.comparison={status:"error",error:o(b)}}this.publish()}openFileDiff(a,b){let c=this.state.documents.get(a);if(this.disposed||c?.status!=="text"||c.comparison?.status!=="ready")return;let d=c.comparison,e=this.state.diffs.find(a=>!a.comparison&&a.repositoryRoot===d.repositoryRoot&&a.path===d.path);if(e)this.invalidateDiff(e),Object.assign(e,{status:"text",original:d.original,modified:{path:d.path,content:c.content}});else{if(!this.canOpenTab())return;e={status:"text",repositoryRoot:d.repositoryRoot,path:d.path,original:d.original,modified:{path:d.path,content:c.content}},this.state.diffs.push(e)}void 0!==b&&(e.initialLine=b),this.openDiff(e.repositoryRoot,e.path)}openDiff(a,b,c,d){if(this.disposed)return;let e={repositoryRoot:a,path:b,comparison:c},f=this.state.diffs.find(a=>m(a)===m(e));if(f)void 0!==d&&(f.label=d);else{if(!this.canOpenTab())return;f={...e,status:"unloaded",label:d},this.state.diffs.push(f)}this.navigation=null,this.state.activeDiff=f,this.publish(),this.ensureDiff(f)}closeDiff(){this.closeTabs(null,"current")}reloadDiff(){let a=this.state.activeDiff;a&&!this.disposed&&(this.invalidateDiff(a),this.publish(),this.ensureDiff(a))}saveDiffState(a,b){!this.disposed&&this.state.diffs.includes(a)&&b&&(a.editorState=b,delete a.initialLine)}setDiffViewMode(a){this.state.activeDiff&&(0,g.ZQ)({diffViewMode:a})}setDiffWrapLines(a){this.state.activeDiff&&(0,g.ZQ)({wrapLines:a})}setDiffCollapseUnchanged(a){this.state.activeDiff&&(0,g.ZQ)({collapseUnchanged:a})}handleGitBranchChanged(a){for(let b of(this.refreshTree(),this.state.tabs))(!a||b===a||b.startsWith(`${a}/`))&&(this.invalidateDocument(b),this.closeMissing.add(b));for(let b of this.state.diffs)b.repositoryRoot!==a||b.comparison||this.invalidateDiff(b);this.publish(),this.state.activeDiff?this.ensureDiff(this.state.activeDiff):this.state.activePath&&this.ensureDocument(this.state.activePath)}saveEditorState(a,b){let c=this.state.documents.get(a);c?.status==="text"&&(c.editorState=b)}savePreviewScrollTop(a,b){let c=this.state.documents.get(a);c?.status==="text"&&(c.previewScrollTop=b)}setWrapLines(a,b){this.state.documents.get(a)?.status==="text"&&(0,g.ZQ)({wrapLines:b})}setTextViewMode(a,b){let c=this.state.documents.get(a);c?.status==="text"&&c.viewMode!==b&&(c.viewMode=b,this.publish())}dispose(){for(let a of(this.disposed=!0,this.compactRequests.clear(),this.directoryRequests.values()))a.controller.abort();for(let a of(this.directoryRequests.clear(),this.documentRequests.values()))a.abort();for(let a of(this.documentRequests.clear(),this.cancelSearch(),this.state.diffs))this.invalidateDiff(a);for(let a of(this.state.diffs=[],this.state.activeDiff=null,this.state.documents.values()))this.releaseDocument(a);this.state.documents.clear(),this.restoredPreviewScrollTops.clear(),this.listeners.clear()}async ensureDiff(a){let b=m(a);if(this.disposed||"unloaded"!==a.status||this.diffRequests.has(b))return;let c=new AbortController;this.diffRequests.set(b,c),Object.assign(a,{status:"loading"}),this.publish();try{let d=await this.reader.diff(a.repositoryRoot,a.path,c.signal,a.comparison);if(this.diffRequests.get(b)!==c)return;Object.assign(a,"text"===d.kind?{status:"text",original:d.original,modified:d.modified}:"metadata"===d.kind?{status:"metadata",originalMetadata:d.original,modifiedMetadata:d.modified}:{status:d.kind,error:null})}catch(d){if(this.diffRequests.get(b)!==c)return;console.warn("[Pi Desk][ProjectFile] 读取 Diff 失败",{cwd:this.cwd,repositoryRoot:a.repositoryRoot,path:a.path,error:o(d)}),Object.assign(a,{status:"error",error:o(d)})}this.diffRequests.get(b)===c&&(this.diffRequests.delete(b),this.publish())}invalidateDiff(a){let b=m(a);for(let c of(this.diffRequests.get(b)?.abort(),this.diffRequests.delete(b),Object.assign(a,{status:"unloaded"}),["original","modified","originalMetadata","modifiedMetadata","error"]))Reflect.deleteProperty(a,c)}canOpenTab(){let a=this.options.maxTabs;return!a||this.state.tabs.length+this.state.diffs.length<a||(this.options.onNotice?.(n("maxOpenFiles",{count:a})),!1)}cancelSearch(){this.searchRequest?.abort(),this.searchRequest=null}invalidateDocument(a){this.state.activePath===a&&(this.navigation=null),this.documentRequests.get(a)?.abort(),this.documentRequests.delete(a);let b=this.state.documents.get(a);b?.status==="text"&&(b.editorState&&this.restoredEditorStates.set(a,b.editorState),this.restoredFileViewModes.set(a,b.viewMode),this.restoredPreviewScrollTops.set(a,b.previewScrollTop)),this.releaseDocument(b),this.state.documents.set(a,{status:"unloaded"})}releaseDocument(a){a?.status==="image"&&URL.revokeObjectURL(a.objectUrl)}publish(){if(!this.disposed)for(let a of(this.revision+=1,this.listeners))a()}}},93306:(a,b,c)=>{"use strict";c.d(b,{x:()=>e});var d=c(97563);function e(a){return(0,d.h3)(a)}},95186:(a,b,c)=>{"use strict";c.d(b,{QL:()=>g,Y4:()=>h,aw:()=>f});var d=c(21850),e=c(17983);class f extends Error{constructor(a,b,c,d=null){super(c),this.status=a,this.code=b,this.errorKey=d,this.name="L3ProjectRequestError"}}async function g(a,b,c,e){let g=await fetch(b.path,{method:"POST",headers:{"Content-Type":"application/json","X-Pi-Desk-Client-Id":a},body:JSON.stringify(b.request.parse(c)),signal:e}),h=await g.json();if(!g.ok||0!==h.code||null===h.data)throw new f(g.status,h.code,h.msg?(0,d.B)(h):"项目读取失败",h.i18n?.key??null);return b.response.parse(h.data)}function h(a,b,c){async function d(b,d,e){try{return await g(a,b,d,e)}catch(a){throw!e?.aborted&&a instanceof f&&401===a.status&&c?.(),a}}return{list:(a,c)=>d(e.Xe,{...b,path:a},c),search:(a,c)=>d(e.fg,{...b,...a},c),get:(a,c,f)=>d(e.ZI,{...b,path:a,imagePreviewMode:c},f),snapshot:(a,c)=>d(e.p0,{...b,refresh:c},a),branches:(a,c)=>d(e.ry,{...b,repositoryRoot:a},c),log:(a,c,f)=>d(e.p3,{...b,repositoryRoot:a,...c},f),changes:(a,c,f)=>d(e.ys,{...b,repositoryRoot:a,...c},f),diff:(a,c,f,g)=>d(e.OC,{...b,repositoryRoot:a,path:c,comparison:g},f)}}},97563:(a,b,c)=>{"use strict";async function d(a){let b="u"<typeof navigator?void 0:navigator.clipboard;if(b?.writeText)try{return await b.writeText(a),!0}catch{}if("u"<typeof document||!document.body)return!1;let c=document.activeElement instanceof HTMLElement?document.activeElement:null,d=document.createElement("textarea");d.value=a,d.setAttribute("readonly",""),d.setAttribute("aria-hidden","true"),d.style.position="fixed",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.opacity="0";try{return document.body.append(d),d.select(),d.setSelectionRange(0,d.value.length),document.execCommand("copy")}catch{return!1}finally{d.remove();try{c?.focus()}catch{}}}c.d(b,{h3:()=>d,qj:()=>e});class e extends Error{constructor(a){super(a.message,{cause:a.cause}),this.name="PiDeskBrowserPluginError",this.pluginName=a.pluginName,this.contributionName=a.contributionName??null,this.phase=a.phase}}},98722:(a,b,c)=>{"use strict";c.d(b,{T8:()=>q,WW:()=>r,aD:()=>g,co:()=>m,lw:()=>s,ph:()=>p,xv:()=>k,yw:()=>n});var d=c(87883),e=c(51949),f=c(18997);let g=d.Yj().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),h=d.KC([g,d.eu("HEAD"),d.Yj().max(1024).regex(/^refs\/(?:heads|remotes)\/[^\0\r\n]+$/)]).refine(a=>!a.includes("..")&&!a.endsWith("/"),"Git 版本无效"),i=d.KC([d.Ik({commit:h,parent:g.optional()}).strict(),d.Ik({base:h,target:h,strategy:d.k5(["merge-base","direct"])}).strict()]),j=d.Ik({base:g.nullable(),target:g,original:g.nullable()}).strict(),k=d.Ik({baseCommit:g.nullable(),targetCommit:g,oldPath:e._g.optional()}).strict(),l=d.Ik({oid:g,parents:d.YO(g),subject:d.Yj(),author:d.Yj(),timestampMs:d.ai().int(),refs:d.YO(d.Yj())}).strict(),m=d.Ik({tip:h,exclude:h.optional(),query:d.Yj().trim().max(200).default(""),author:d.Yj().trim().max(200).optional(),page:d.Ik({index:d.ai().int().min(1).max(2e3),size:d.ai().int().min(1).max(100)}).strict()}).strict(),n=d.Ik({tip:g.nullable(),exclude:g.nullable(),items:d.YO(l),hasMore:d.zM(),truncated:d.zM()}).strict(),o=d.Ik({path:e._g,oldPath:e._g.nullable(),status:d.k5(["added","modified","deleted","renamed","type-changed"])}).strict(),p=d.Ik({selection:i,page:d.Ik({index:d.ai().int().min(1).max(5e4),size:d.ai().int().min(1).max(500)}).strict()}).strict(),q=d.Ik({comparison:j,commit:l.extend({message:d.Yj(),selectedParent:g.nullable()}).nullable(),items:d.YO(o),hasMore:d.zM(),truncated:d.zM()}).strict(),r=f.gf.extend({upstream:d.Ik({ref:d.Yj(),ahead:d.ai().int().nonnegative().nullable(),behind:d.ai().int().nonnegative().nullable()}).strict().nullable()}).strict(),s=d.KC([f.FJ,d.Ik({kind:d.eu("metadata"),original:d.Yj(),modified:d.Yj()}).strict()])}};
15
+ ${c.author} \xb7 ${n.format(c.timestampMs)}`,children:[(0,d.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[c.subject||i("noCommitMessage"),c.refs.length?(0,d.jsx)("span",{className:"ml-2 text-xs text-muted-foreground",children:c.refs.join(" \xb7 ")}):null]}),(0,d.jsx)("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:c.oid.slice(0,7)}),g?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"w-20 truncate text-xs text-muted-foreground",children:c.author}),(0,d.jsx)("time",{className:"w-28 shrink-0 text-right text-xs text-muted-foreground",children:m.format(c.timestampMs)})]})]},c.oid)},`${b.repositoryRoot}:${b.mode}:${b.tip}:${b.base}:${b.target}:${b.query}:${b.author}`)}),C=(0,d.jsxs)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:[(0,d.jsxs)("div",{className:"flex min-h-9 shrink-0 flex-wrap items-center gap-2 border-b px-3 py-1",children:[g?(0,d.jsx)(q.$,{variant:"ghost",size:"icon-sm","aria-label":i("backCommits"),onClick:()=>s("log"),children:(0,d.jsx)(ad.A,{className:"size-4"})}):null,(0,d.jsx)("span",{className:"text-sm font-medium",children:b.selectedCommit?i("commitChanges"):i("cumulativeChanges")}),v?(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:i("loadedFiles",{count:v.items.length})}):null,"compare"===b.mode&&b.selectedCommit?(0,d.jsx)(q.$,{variant:"ghost",size:"sm",onClick:a.onAggregate,children:i("backCumulative")}):null]}),A(b.changes.error),"loading"===b.changes.status?(0,d.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,d.jsx)(L.A,{className:"size-4 animate-spin"}),i("loadingChanges")]}):null,(0,d.jsxs)(p.HK,{orientation:"vertical",defaultLayout:{"project-changes":a.panelSizes.changes,"project-detail":100-a.panelSizes.changes},onLayoutChanged:(b,c)=>{c.isUserInteraction&&void 0!==b["project-changes"]&&a.onPanelSize("changes",b["project-changes"])},children:[(0,d.jsx)(p.wV,{id:"project-changes",defaultSize:`${a.panelSizes.changes}%`,minSize:"80px",children:(0,d.jsxs)("div",{className:"flex size-full min-h-0 flex-col",children:[(0,d.jsx)(aq,{cwd:a.cwd,repositoryRoot:b.repositoryRoot??"",rows:a.changeRows,rowHeight:a.changeRowHeight,changes:v?.items??[],selectedPath:x,scrollTop:h.changes,onScroll:b=>a.onScroll("changes",b),onSelect:a.onSelectChange,onToggle:a.onToggleDirectory,onOpen:a.onOpenFile,onReveal:a.onReveal},w),"ready"!==b.changes.status||v?.items.length?null:(0,d.jsx)("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:i("noDiff")}),v?.hasMore?(0,d.jsx)(q.$,{size:"sm",variant:"ghost",disabled:"loading"===b.changes.status,onClick:a.onMoreChanges,children:i("loadMoreFiles")}):null,v?.truncated?(0,d.jsx)("p",{className:"p-3 text-xs text-muted-foreground",children:i("changesLimit")}):null]})}),(0,d.jsx)(p.WM,{}),(0,d.jsx)(p.wV,{id:"project-detail",defaultSize:`${100-a.panelSizes.changes}%`,minSize:"60px",children:(0,d.jsxs)(ag.V,{className:"h-full",viewportClassName:"p-3 text-sm",role:"region","aria-label":i("commitDetails"),children:[z?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("pre",{className:"mb-3 whitespace-pre-wrap break-words font-sans leading-relaxed",children:z.message}),(0,d.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,d.jsx)("span",{className:"min-w-0 flex-1 break-all font-mono text-xs",children:z.oid}),(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":i("copySha"),onClick:()=>a.onCopy(z.oid),children:(0,d.jsx)(K.A,{className:"size-4"})})]}),(0,d.jsxs)("p",{className:"mb-3 text-xs text-muted-foreground",children:[z.author," \xb7 ",n.format(z.timestampMs)]}),z.parents.length>1?(0,d.jsx)(ai.b,{className:"mb-3",ariaLabel:i("compareParent"),value:z.selectedParent??"",options:z.parents.map((a,b)=>({value:a,label:i("parentCommit",{count:b+1,oid:a.slice(0,10)})})),onChange:b=>a.onCommit(z.oid,b)}):null]}):v?(0,d.jsxs)("div",{className:"space-y-2 text-xs text-muted-foreground",children:[(0,d.jsx)("p",{children:"merge-base"===b.strategy?i("mergeBaseToTarget"):i("baseToTarget")}),(0,d.jsx)("p",{className:"break-all font-mono",children:v.comparison.original??i("emptyRevision")}),(0,d.jsx)("p",{className:"break-all font-mono",children:v.comparison.target})]}):(0,d.jsx)("p",{className:"text-muted-foreground",children:i("selectCommit")}),x?(0,d.jsx)("p",{className:"mt-3 break-all font-mono text-xs text-muted-foreground",children:x}):null]})})]})]});return(0,d.jsxs)("section",{className:"flex size-full min-h-0 min-w-0 flex-col","aria-label":i("historyAndCompare"),children:[(0,d.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b px-3 py-2",children:[(0,d.jsxs)("div",{className:"flex gap-1",role:"group","aria-label":i("viewMode"),children:[(0,d.jsx)(q.$,{size:"sm",variant:"history"===b.mode?"secondary":"ghost","aria-pressed":"history"===b.mode,onClick:()=>{a.onMode("history"),s("log")},children:i("historyMode")}),(0,d.jsx)(q.$,{size:"sm",variant:"compare"===b.mode?"secondary":"ghost","aria-pressed":"compare"===b.mode,onClick:()=>{a.onMode("compare"),s("log")},children:i("compareMode")})]}),(0,d.jsx)(ai.b,{className:"w-44",ariaLabel:i("selectRepository"),value:b.repositoryRoot??"",options:c.map(a=>({value:a.root,label:a.root||f,description:"unavailable"===a.state?(0,ae.fD)(a.message,j):void 0})),onChange:a.onRepository}),"history"===b.mode?(0,d.jsx)(ax,{className:"w-48",ariaLabel:i("viewBranch"),value:b.tip,branches:b.branches.data,onChange:b=>a.onRevision("tip",b)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ax,{className:"w-44",ariaLabel:i("baseBranch"),placeholder:i("chooseBase"),value:b.base,branches:b.branches.data,onChange:b=>a.onRevision("base",b)}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"→"}),(0,d.jsx)(ax,{className:"w-44",ariaLabel:i("targetBranch"),value:b.target,branches:b.branches.data,onChange:b=>a.onRevision("target",b)}),(0,d.jsx)(ai.b,{className:"w-48",ariaLabel:i("comparison"),value:b.strategy,options:[{value:"merge-base",label:i("introducedChanges")},{value:"direct",label:i("directComparison")}],onChange:b=>a.onStrategy("direct"===b?"direct":"merge-base")}),g?(0,d.jsx)(q.$,{size:"sm",variant:"outline",onClick:()=>s("files"),children:i("cumulativeChanges")}):null]}),(0,d.jsx)(ah.p,{className:"w-40 shrink-0","aria-label":i("filterAuthor"),placeholder:i("author"),list:o,value:b.author,onChange:b=>a.onAuthor(b.target.value)}),(0,d.jsx)("datalist",{id:o,children:b.authorSuggestions.map(a=>(0,d.jsx)("option",{value:a},a))}),(0,d.jsx)(ah.p,{className:"min-w-32 flex-1 basis-40","aria-label":i("searchCommits"),placeholder:i("searchCommits"),value:b.query,onChange:b=>a.onQuery(b.target.value)}),(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":i("refreshGit"),onClick:a.onRefresh,children:(0,d.jsx)(l.A,{className:"size-4"})})]}),b.branches.error?A(b.branches.error):null,y?(0,d.jsxs)("p",{className:"shrink-0 truncate border-b px-3 py-1 text-xs text-muted-foreground",title:y.ref,children:[y.ref.replace("refs/remotes/","")," \xb7 ",i("localRecord")," \xb7"," ",null===y.ahead||null===y.behind?i("refUnavailable"):i("aheadBehind",{ahead:y.ahead,behind:y.behind})]}):null,"compare"!==b.mode||b.base?g?"log"===r?B:C:(0,d.jsxs)(p.HK,{orientation:"horizontal",defaultLayout:{"project-log":a.panelSizes.log,"project-files":100-a.panelSizes.log},onLayoutChanged:(b,c)=>{c.isUserInteraction&&void 0!==b["project-log"]&&a.onPanelSize("log",b["project-log"])},children:[(0,d.jsx)(p.wV,{id:"project-log",defaultSize:`${a.panelSizes.log}%`,minSize:"30%",children:B}),(0,d.jsx)(p.WM,{}),(0,d.jsx)(p.wV,{id:"project-files",defaultSize:`${100-a.panelSizes.log}%`,minSize:"25%",children:C})]}):(0,d.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:i("chooseBaseBranch")})]})}let az=()=>{};function aA({clientId:a,cwd:b,title:c,actions:s,onEscape:u=az,onUnauthorized:v}){let{t:w}=(0,e.Bd)("projectHistory"),x=(0,R.G)(),{files:y,git:z,history:A,global:B,updateGlobal:D,page:E,setPage:F,historyPane:G,setHistoryPane:H,setContainer:I,narrow:J,stacked:K,width:L,changeRowHeight:N,openGit:O,refresh:P}=function(a,b,c){let d=(0,R.G)(),[e]=(0,t.useState)(_.N1),[f,g]=(0,t.useState)(e),h=(0,t.useCallback)(a=>{g(b=>({...b,...a})),(0,_.Ms)({...(0,_.N1)(),...a})},[]),[i]=(0,t.useState)(()=>(0,_.tQ)(b)),[j]=(0,t.useState)(()=>(0,$.ph)(a,b,a=>d.show({level:"info",title:a}),i,e,{lazyHistory:!0,onUnauthorized:c})),{files:k,git:l,history:m}=j;(0,t.useSyncExternalStore)(k.subscribe,k.getRevision,k.getRevision),(0,t.useSyncExternalStore)(l.subscribe,l.getRevision,l.getRevision),(0,t.useSyncExternalStore)(m.subscribe,m.getRevision,m.getRevision);let[n,o]=(0,t.useState)(i?.page??"files"),[p,q]=(0,t.useState)(i?.historyPane??"log"),[r,s]=(0,t.useState)({width:1200,height:800}),[u,v]=(0,t.useState)(null);(0,t.useRef)(!1),(0,t.useRef)(()=>void 0);let w=r.width<900,x=w||r.height<680;l.getWorkspace(b).snapshot.repositories;let y=k.state,z=(0,t.useSyncExternalStore)(aa,ab,ac),A=f.gitOpen&&(!x||"git"===n);return{files:k,git:l,history:m,global:f,updateGlobal:h,page:n,setPage:o,historyPane:p,setHistoryPane:q,setContainer:v,narrow:w,stacked:x,width:r.width,changeRowHeight:z?24:36,openGit(a){h({gitOpen:!0}),o("git"),void 0!==a&&m.setRepository(a)},refresh(){k.refreshTree(),l.refreshSnapshot(b),y.activeDiff?k.reloadDiff():y.activePath&&k.reloadFile(y.activePath),A&&m.refresh()}}}(a,b,v),{directoryOpen:Q,gitOpen:S,gitMaximized:T}=B,U=b.replaceAll("\\","/").split("/").filter(Boolean).at(-1)??b,V=z.getWorkspace(b),W=V.snapshot.repositories,X=y.state,Z=(0,d.jsx)(r.F,{cwd:b,projectName:U,showRootTitle:!1,runtime:y,gitRuntime:z,onOpenGitBranches:O,onFileOpened:()=>F("code")}),ad=(0,d.jsx)(Y,{runtime:y,gitRuntime:z,compact:L<1100,onEscape:u,renderHeader:a=>(0,d.jsx)(C,{cwd:b,gitRuntime:z,paths:X.tabs,activePath:X.activePath,diffs:X.diffs,activeDiff:X.activeDiff,mobile:J,actions:a,onActivate:a=>{"string"==typeof a?y.openFile(a):y.openDiff(a.repositoryRoot,a.path,a.comparison)},onClose:(a,b)=>y.closeTabs(a,b)})}),ae=(0,d.jsxs)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:[(0,d.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-2 border-b bg-muted px-3",children:[(0,d.jsx)(f.A,{className:"size-4"}),(0,d.jsx)("span",{className:"flex-1 text-sm font-medium",children:"Git"}),K?null:(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":w(T?"restoreGit":"maximizeGit"),onClick:()=>D({gitMaximized:!T}),children:T?(0,d.jsx)(g.A,{className:"size-4"}):(0,d.jsx)(h.A,{className:"size-4"})}),(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":w("collapseGit"),onClick:()=>{D({gitOpen:!1,gitMaximized:!1}),F("code")},children:(0,d.jsx)(i.A,{className:"size-4"})})]}),W.length?(0,d.jsx)(ay,{state:A.state,cwd:b,changeRows:A.getChangeRows(),changeRowHeight:N,onSelectChange:a=>A.selectChange(a),onToggleDirectory:a=>A.toggleChangeDirectory(a),onReveal:(a,b)=>y.revealFile(a,b),repositories:W,projectName:U,narrow:J,mobilePane:G,onMobilePane:H,scroll:A.scroll,onScroll:(a,b)=>A.setScroll(a,b),panelSizes:{log:B.logSize,changes:B.changeSize},onPanelSize:(a,b)=>D("log"===a?{logSize:b}:{changeSize:b}),onRepository:a=>{A.setRepository(a),H("log")},onMode:a=>A.setMode(a),onRevision:(a,b)=>A.setRevision(a,b),onStrategy:a=>A.setStrategy(a),onQuery:a=>A.setQuery(a),onAuthor:a=>A.setAuthor(a),onCommit:(a,b)=>A.selectCommit(a,b),onAggregate:()=>A.showAggregate(),onMoreLog:()=>A.loadMoreLog(),onMoreChanges:()=>A.loadMoreChanges(),onOpenFile:a=>{A.openChange(a),F("code"),D({gitMaximized:!1})},onRefresh:()=>A.refresh(),onCopy:a=>{(0,M.x)(a).then(a=>{a||x.error(w("copyFailed"))})}}):(0,d.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:"loading"===V.snapshot.status||"idle"===V.snapshot.status?w("findingGit"):V.snapshot.error??w("noGit")})]}),af=(0,d.jsxs)(p.HK,{orientation:"horizontal",defaultLayout:Q?{"project-tree":B.directorySize,"project-code":100-B.directorySize}:void 0,onLayoutChanged:(a,b)=>{b.isUserInteraction&&void 0!==a["project-tree"]&&D({directorySize:a["project-tree"]})},children:[Q?(0,d.jsx)(p.wV,{id:"project-tree",defaultSize:`${B.directorySize}%`,minSize:"180px",maxSize:"40%",children:Z}):null,Q?(0,d.jsx)(p.WM,{}):null,(0,d.jsx)(p.wV,{id:"project-code",minSize:"40%",children:ad})]},Q?"tree-visible":"tree-hidden");return(0,d.jsxs)("div",{ref:I,className:"flex size-full min-h-0 min-w-0 flex-col overflow-hidden","data-testid":"project-preview",children:[(0,d.jsxs)("header",{className:"flex min-h-9 shrink-0 items-center gap-1 bg-muted px-2 py-1 pt-[max(4px,env(safe-area-inset-top))]",children:[K?null:(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":w(Q?"collapseDirectory":"expandDirectory"),onClick:()=>D({directoryOpen:!Q}),children:Q?(0,d.jsx)(j.A,{className:"size-4"}):(0,d.jsx)(k.A,{className:"size-4"})}),(0,d.jsxs)("div",{className:"flex min-w-0 flex-1 items-baseline gap-3",title:b,children:[(0,d.jsx)("div",{className:"min-w-0 shrink-0 max-w-[50%] max-sm:max-w-full max-sm:shrink",children:c??(0,d.jsx)("h1",{className:"truncate text-sm font-semibold",children:U})}),(0,d.jsx)("p",{className:"min-w-0 truncate text-xs text-muted-foreground max-sm:hidden",children:b})]}),(0,d.jsxs)(q.$,{size:"sm",variant:S?"secondary":"ghost","aria-pressed":S,onClick:()=>O(),children:[(0,d.jsx)(f.A,{className:"size-4"}),(0,d.jsx)("span",{className:"max-sm:hidden",children:w("gitRecords")})]}),(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":w("refreshPreview"),onClick:P,children:(0,d.jsx)(l.A,{className:"size-4"})}),s]}),V.snapshot.error?(0,d.jsx)("p",{role:"alert",className:"shrink-0 border-b px-3 py-2 text-sm text-destructive",children:V.snapshot.error}):null,K?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex shrink-0 gap-1 px-2 py-1",role:"group","aria-label":w("previewArea"),children:[(0,d.jsxs)(q.$,{size:"sm",variant:"files"===E?"secondary":"ghost",onClick:()=>F("files"),children:[(0,d.jsx)(m.A,{className:"size-4"}),w("files")]}),(0,d.jsxs)(q.$,{size:"sm",variant:"code"===E?"secondary":"ghost",onClick:()=>F("code"),children:[(0,d.jsx)(n.A,{className:"size-4"}),w("code")]}),(0,d.jsxs)(q.$,{size:"sm",variant:"git"===E?"secondary":"ghost",onClick:()=>O(),children:[(0,d.jsx)(o.A,{className:"size-4"}),"Git"]})]}),(0,d.jsx)("div",{className:"min-h-0 flex-1",children:"files"===E?Z:"git"===E?ae:ad})]}):T&&S?ae:(0,d.jsxs)(p.HK,{orientation:"vertical",defaultLayout:S?{"project-main":100-B.gitSize,"project-git":B.gitSize}:void 0,onLayoutChanged:(a,b)=>{b.isUserInteraction&&void 0!==a["project-git"]&&D({gitSize:a["project-git"]})},children:[(0,d.jsx)(p.wV,{id:"project-main",defaultSize:S?`${100-B.gitSize}%`:"100%",minSize:"35%",children:af}),S?(0,d.jsx)(p.WM,{}):null,S?(0,d.jsx)(p.wV,{id:"project-git",defaultSize:`${B.gitSize}%`,minSize:"300px",children:ae}):null]},S?"git-visible":"git-hidden")]})}},85544:(a,b,c)=>{"use strict";c.d(b,{k:()=>h});var d=c(52834);c(84593);var e=c(49147),f=c(15620),g=c(4998);function h(a){let{locale:b}=(0,g.i)(),{slides:c,index:h=0,onIndexChange:i,className:j,thumbnails:k=!0,ariaLabel:l="en"===b?"Image preview":"图片预览"}=a,m="inline"===a.mode,n="inline"===a.mode||a.open,o="modal"===a.mode?a.onClose:void 0;c.length;let p=Math.min(Math.max(h,0),Math.max(c.length-1,0)),q=`pi-desk-image-viewer-${(0,e.useId)().replaceAll(":","")}`,r=(0,e.useRef)(null),s=(0,e.useRef)(null),t=(0,e.useRef)(null);if((0,e.useRef)(""),(0,e.useRef)(""),(0,e.useRef)(p),(0,e.useRef)(p),(0,e.useRef)(i),(0,e.useRef)(o),(0,e.useMemo)(()=>JSON.stringify(c.map(a=>[a.src,a.alt])),[c]),(0,f.cn)("pi-desk-image-viewer",m?"pi-desk-image-viewer-inline":"pi-desk-image-viewer-modal",q,j),0===c.length||!n)return null;let u=(0,d.jsx)("span",{ref:r,className:"pi-desk-image-viewer-source","aria-hidden":"true",children:c.map((a,b)=>(0,d.jsx)("img",{src:a.src,alt:a.alt,width:a.width,height:a.height,decoding:"async",draggable:!1},b))});return m?(0,d.jsx)("div",{ref:s,className:"pi-desk-image-viewer-host",role:"region","aria-label":l,tabIndex:0,onKeyDown:a=>{let b=t.current;!b||b.fulled||a.altKey||a.ctrlKey||a.metaKey||a.nativeEvent.isComposing||("ArrowLeft"===a.key||"ArrowRight"===a.key)&&(a.preventDefault(),a.stopPropagation(),"ArrowLeft"===a.key?b.prev(!1):b.next(!1))},children:u}):u}},87348:(a,b,c)=>{"use strict";c.d(b,{e:()=>k});var d=c(52834),e=c(90814),f=c(49147),g=c(57850);c(82386),c(51972);var h=c(96478),i=c(70448),j=c.n(i);let k=(0,f.forwardRef)(function({path:a,content:b,size:c,savedState:i,onSaveState:k,onEscape:l,originalContent:m,onChanges:n,onOpenDiff:o,navigation:p,onNavigation:q},r){let{t:s}=(0,g.Bd)("common"),{t:t}=(0,g.Bd)("projectFiles"),{wrapLines:u}=(0,h.TX)(),v=(0,f.useRef)(null),w=(0,f.useRef)(null);(0,f.useRef)(k),(0,f.useRef)(u),(0,f.useRef)(i),(0,f.useRef)(l);let x=(0,f.useRef)(null);(0,f.useRef)(n),(0,f.useRef)(o),(0,f.useRef)(q);let y=(0,f.useRef)(null),z=(0,f.useRef)(null);(0,f.useCallback)(a=>{let b=z.current;y.current?.clear(),null===b||b>(a.getModel()?.getLineCount()??0)||(y.current??=a.createDecorationsCollection(),y.current.set([{range:{startLineNumber:b,startColumn:1,endLineNumber:b,endColumn:1},options:{isWholeLine:!0,className:"bg-accent"}}]))},[]);let[A,B]=(0,f.useState)("loading");return(0,f.useImperativeHandle)(r,()=>({openSearch(){w.current?.getAction("actions.find")?.run()},gotoLine(){w.current?.getAction("editor.action.gotoLine")?.run()},getSelectionText(){let a=w.current,b=a?.getModel(),c=a?.getSelection();return b&&c&&!c.isEmpty()?b.getValueInRange(c):""},getViewState:()=>w.current?.saveViewState()??null,focus(){w.current?.focus()},previousChange(){x.current?.previousChange()},nextChange(){x.current?.nextChange()}}),[]),(0,d.jsxs)("div",{"data-testid":"code-preview",className:"relative h-full min-h-0 w-full overflow-hidden bg-background",children:[(0,d.jsx)("div",{ref:v,className:`size-full ${j().host}`}),"loading"===A?(0,d.jsxs)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center gap-2 bg-background text-sm text-muted-foreground",children:[(0,d.jsx)(e.A,{className:"size-4 animate-spin"})," ",s("codeLoading")]}):null,"error"===A?(0,d.jsx)("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center text-sm text-destructive",children:s("codeFailed")}):null]})})},89101:(a,b,c)=>{"use strict";c.d(b,{Ik:()=>n,MG:()=>j,Sq:()=>l,iV:()=>o,oR:()=>p});var d=c(52834);c(49147);var e=c(80546),f=c(15620),g=c(5319),h=c(11071),i=c(13221);function j({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"input-group",role:"group",className:(0,f.cn)("group/input-group relative flex min-h-8 w-full min-w-0 items-center rounded-lg border border-input bg-card transition-colors duration-150 outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-muted has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:outline-2 has-[[data-slot=input-group-control]:focus-visible]:outline-solid has-[[data-slot=input-group-control]:focus-visible]:-outline-offset-2 has-[[data-slot=input-group-control]:focus-visible]:outline-ring has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",a),...b})}let k=(0,e.F)("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function l({className:a,align:b="inline-start",...c}){return(0,d.jsx)("div",{role:"group","data-slot":"input-group-addon","data-align":b,className:(0,f.cn)(k({align:b}),a),onClick:a=>{a.target.closest("button")||a.currentTarget.parentElement?.querySelector("input")?.focus()},...c})}let m=(0,e.F)("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"min-h-7 gap-2 rounded-md px-2",sm:"","icon-xs":"size-7 rounded-md p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function n({className:a,type:b="button",variant:c="ghost",size:e="xs",...h}){return(0,d.jsx)(g.$,{type:b,"data-size":e,variant:c,className:(0,f.cn)(m({size:e}),a),...h})}function o({className:a,...b}){return(0,d.jsx)(h.p,{"data-slot":"input-group-control",className:(0,f.cn)("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:outline-none focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0",a),...b})}function p({className:a,...b}){return(0,d.jsx)(i.T,{"data-slot":"input-group-control",className:(0,f.cn)("flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:outline-none focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0",a),...b})}},91464:(a,b,c)=>{"use strict";c.d(b,{S6:()=>d,dQ:()=>e,hD:()=>f});let d="relative flex min-h-7 cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-sm leading-5 outline-none select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e="data-[variant=destructive]:text-destructive data-[variant=destructive]:data-highlighted:bg-destructive/10 data-[variant=destructive]:data-highlighted:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive",f="z-50 max-h-(--available-height) min-w-60 max-w-[calc(100vw-2rem)] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-md outline-none transition-[opacity,transform] duration-100 ease-out data-starting-style:scale-[0.98] data-starting-style:opacity-0 data-ending-style:scale-[0.98] data-ending-style:opacity-0 motion-reduce:transition-none"},91816:(a,b,c)=>{"use strict";c.d(b,{Ip:()=>q,JW:()=>o,K5:()=>s,Rc:()=>p,kt:()=>r,tz:()=>n});var d=c(52834);c(49147);var e=c(49067),f=c(10962),g=c(48329),h=c(65614),i=c(9698),j=c(16484),k=c(36089),l=c(15620),m=c(91464);function n({...a}){return(0,d.jsx)(e.D,{"data-slot":"context-menu",...a})}function o({...a}){return(0,d.jsx)(f.g,{"data-slot":"context-menu-portal",...a})}function p({className:a,...b}){return(0,d.jsx)(g.R,{"data-slot":"context-menu-trigger",className:(0,l.cn)("select-none",a),...b})}function q({className:a,align:b="start",alignOffset:c=4,side:e="right",sideOffset:g=0,finalFocus:j=!1,...k}){return(0,d.jsx)(f.g,{children:(0,d.jsx)(h.y,{className:"isolate z-50 outline-none",align:b,alignOffset:c,side:e,sideOffset:g,children:(0,d.jsx)(i._,{"data-slot":"context-menu-content",finalFocus:j,className:(0,l.cn)(m.hD,a),...k})})})}function r({className:a,inset:b,variant:c="default",...e}){return(0,d.jsx)(j.D,{"data-slot":"context-menu-item","data-inset":b,"data-variant":c,className:(0,l.cn)(m.S6,m.dQ,"group/context-menu-item",a),...e})}function s({className:a,...b}){return(0,d.jsx)(k.w,{"data-slot":"context-menu-separator",className:(0,l.cn)("-mx-1 my-1 h-px bg-border",a),...b})}},92494:(a,b,c)=>{"use strict";c.d(b,{Q:()=>m,h:()=>q});var d=c(89172),e=c(21850),f=c(28661),g=c(96478),h=c(95186),i=c(55091),j=c(83731);let k={scope:"all",caseSensitive:!1,wholeWord:!1,regex:!1};function l(a){return{...a,status:a.query.trim()?"loading":"idle",fileMatches:[],contentMatches:[],truncated:!1,error:null}}function m(a){return JSON.stringify([a.repositoryRoot,a.path,a.comparison?.baseCommit??null,a.comparison?.targetCommit??null,a.comparison?.oldPath??null])}function n(a,b){return(0,e.B)({msg:d.C["zh-CN"][a],i18n:{key:`projectFiles:${a}`,...b?{params:b}:{}}})}function o(a){return a instanceof Error?a.message:n("projectReadFailed")}async function p(a,b){if(a.type!==b.type||a.size!==b.size)return!1;let[c,d]=await Promise.all([a.arrayBuffer(),b.arrayBuffer()]),e=new Uint8Array(d);return new Uint8Array(c).every((a,b)=>a===e[b])}class q{constructor(a,b,c){this.cwd=a,this.reader=b,this.options=c,this.state={tabs:[],activePath:null,directories:new Map,expandedPaths:new Set,treeScrollTop:0,search:l({query:"",...k}),searchOpen:!1,documents:new Map,diffs:[],activeDiff:null},this.listeners=new Set,this.directoryRequests=new Map,this.compactRequests=new Map,this.documentRequests=new Map,this.closeMissing=new Set,this.restoredTabs=new Set,this.restoredEditorStates=new Map,this.restoredFileViewModes=new Map,this.restoredPreviewScrollTops=new Map,this.searchRequest=null,this.navigation=null,this.diffRequests=new Map,this.revision=0,this.disposed=!1,this.subscribe=a=>(this.listeners.add(a),()=>this.listeners.delete(a)),this.getRevision=()=>this.revision}setSearchOpen(a){this.disposed||this.state.searchOpen===a||(this.cancelSearch(),this.state.searchOpen=a,this.state.search=l({...this.searchInput(),scope:a?"all":this.state.search.scope}),this.publish())}get pendingNavigation(){let a=this.state.activePath;return a&&!this.documentRequests.has(a)?this.navigation:null}consumeNavigation(a,b){this.navigation===a&&(this.navigation=null,b||this.options.onNotice?.(n("searchLineUnavailable")),this.publish())}get canReveal(){return!!this.options.reveal}getBrowsingDocumentSettings(){let a={},b={};for(let c of this.state.tabs){let d=this.state.documents.get(c),e=d?.status==="text"?d.editorState:this.restoredEditorStates.get(c);e&&JSON.stringify(e).length<32768&&(a[c]=e);let f=d?.status==="text"?d.viewMode:this.restoredFileViewModes.get(c);f&&(b[c]=f)}return{editorStates:a,fileViewModes:b}}restoreBrowsing(a){if(this.disposed)return;for(let b of(this.state.tabs=a.tabs.slice(0,this.options.maxTabs),this.state.tabs)){this.restoredTabs.add(b);let c=a.editorStates[b];c&&this.restoredEditorStates.set(b,c);let d=a.fileViewModes[b];d&&this.restoredFileViewModes.set(b,d)}for(let b of(this.state.activePath=a.activePath&&this.state.tabs.includes(a.activePath)?a.activePath:null,this.state.expandedPaths=new Set(a.expandedPaths),this.state.treeScrollTop=a.treeScrollTop,this.state.search=l({query:a.searchQuery,...k}),this.state.tabs))this.state.documents.set(b,{status:"unloaded"});for(let b of[...a.diffs??[],...a.activeDiff?[a.activeDiff]:[]])if(!this.state.diffs.some(a=>m(a)===m(b))){if(this.options.maxTabs&&this.state.tabs.length+this.state.diffs.length>=this.options.maxTabs)break;this.state.diffs.push({...b,status:"unloaded"})}for(let b of a.expandedPaths)this.ensureDirectory(b);this.publish();let b=a.activeDiff,c=b?this.state.diffs.find(a=>m(a)===m(b)):null;c?this.openDiff(c.repositoryRoot,c.path,c.comparison):this.state.activePath&&this.ensureDocument(this.state.activePath)}async revealFile(a,b="file"){if(!this.options.reveal)throw Error(n("revealUnavailable"));await this.options.reveal(a,b)}ensureRoot(){return this.ensureDirectory("")}ensureDirectory(a,b=!1){let c=this.state.directories.get(a);if(this.disposed||!b&&c?.status==="ready")return Promise.resolve();let d=this.directoryRequests.get(a);if(d)return d.promise;let e=new AbortController,f=Promise.resolve().then(async()=>{try{if(e.signal.aborted)return;let b=await this.reader.list(a,e.signal);if(this.directoryRequests.get(a)?.controller!==e)return;this.state.directories.set(a,{status:"ready",...b})}catch(b){if(this.directoryRequests.get(a)?.controller!==e)return;this.state.directories.set(a,{status:"error",error:o(b)})}this.directoryRequests.get(a)?.controller===e&&(this.directoryRequests.delete(a),this.publish())});return this.directoryRequests.set(a,{controller:e,promise:f}),c?.status!=="ready"&&(this.state.directories.set(a,{status:"loading"}),this.publish()),f}refreshDirectories(a){for(let b of new Set(a))this.ensureDirectory(b,!0)}setExpandedPaths(a,b=!0){let c=[...this.state.expandedPaths].filter(b=>!a.has(b));for(let b of(this.state.expandedPaths=new Set(a),this.compactRequests.keys()))c.some(a=>b===a||b.startsWith(`${a}/`))&&this.compactRequests.delete(b);if(this.publish(),b)for(let b of a)this.ensureDirectory(b,!0)}cancelDirectoryExpansion(a=""){for(let b of this.compactRequests.keys())(!a||b===a||b.startsWith(`${a}/`))&&this.compactRequests.delete(b)}compactDirectory(a,b){return(0,j.rk)(a,a=>{let b=this.onlyDirectory(a);return b&&this.state.directories.has(b)?b:null},b)}async expandDirectoryChain(a,b){let c={};this.compactRequests.set(a,c);let d=a,e=16;for(;!this.disposed&&this.compactRequests.get(a)===c&&this.state.expandedPaths.has(a);){if(this.state.directories.get(d)?.status!=="ready"){if(e--<=0)break;await this.ensureDirectory(d)}if(this.compactRequests.get(a)!==c||this.disposed)return;let f=this.onlyDirectory(d);if(!f||b.has(d)||b.has(f)||e<=0&&this.state.directories.get(f)?.status!=="ready")break;this.state.expandedPaths.add(f),d=f,this.publish()}this.compactRequests.get(a)===c&&this.compactRequests.delete(a)}onlyDirectory(a){let b=this.state.directories.get(a);if(b?.status!=="ready"||b.truncated||1!==b.entries.length)return null;let c=b.entries[0];return"directory"===c.type?(0,j._J)(a,c.name):null}setTreeScrollTop(a){this.state.treeScrollTop=a}refreshTree(){for(let a of(this.compactRequests.clear(),this.directoryRequests.values()))a.controller.abort();this.directoryRequests.clear(),this.state.directories.clear(),this.cancelSearch(),this.state.search=l(this.searchInput()),this.publish(),this.ensureRoot().then(()=>{if(!this.disposed){for(let a of this.state.expandedPaths)this.ensureDirectory(a);this.state.searchOpen&&this.state.search.query.trim()&&(this.cancelSearch(),this.state.search={...this.state.search,status:"loading"},this.search(this.state.search.query))}})}setSearchQuery(a){this.disposed||this.state.search.query===a||(this.cancelSearch(),this.state.search=l({...this.searchInput(),query:a}),this.publish())}setSearchOptions(a){if(this.disposed)return;let b=this.searchInput(),c={...b,...a};(c.scope!==b.scope||c.caseSensitive!==b.caseSensitive||c.wholeWord!==b.wholeWord||c.regex!==b.regex)&&(this.cancelSearch(),this.state.search=l(c),this.publish(),this.state.searchOpen&&this.search(c.query))}searchInput(){let{query:a,scope:b,caseSensitive:c,wholeWord:d,regex:e}=this.state.search;return{query:a,scope:b,caseSensitive:c,wholeWord:d,regex:e}}async search(a){if(this.disposed||!a.trim()||this.state.search.query!==a||"ready"===this.state.search.status||this.searchRequest)return;let b=new AbortController;this.searchRequest=b;let c=this.searchInput();this.state.search=l(c),this.publish();try{let a=await this.reader.search(c,b.signal);if(this.searchRequest!==b)return;this.state.search={...c,status:"ready",...a,error:null}}catch(a){if(this.searchRequest!==b)return;this.state.search={...l(c),status:"error",error:o(a)}}this.searchRequest===b&&(this.searchRequest=null,this.publish())}openFile(a,b){var c;let d,e;if(this.disposed)return;let f=(c=this.cwd,d=a.replaceAll("\\","/"),e=`${c.replaceAll("\\","/").replace(/\/+$/,"")}/`,(/^[a-z]:\//i.test(e)||e.startsWith("//")?d.toLowerCase().startsWith(e.toLowerCase()):d.startsWith(e))?d.slice(e.length):d),g=/^[a-z]:[\\/]/i.test(this.cwd)||this.cwd.startsWith("\\\\")?this.state.tabs.find(a=>a.toLowerCase()===f.toLowerCase())??f:f;if(!this.state.tabs.includes(g)){if(!this.canOpenTab())return;this.state.tabs.push(g)}this.state.activeDiff=null,this.state.documents.has(g)||this.state.documents.set(g,{status:"unloaded"}),this.state.activePath=g,this.navigation=void 0===b?null:{line:b};let h=this.state.documents.get(g);void 0!==b&&h?.status==="text"&&(h.viewMode="source"),this.ensureDocument(g,void 0!==b),this.publish()}closeTabs(a,b){if(this.disposed)return;let c=this.state,d=[...c.tabs,...c.diffs],e=null===a?c.activeDiff:"string"==typeof a?a:c.diffs.find(b=>m(b)===m(a)),f=null==e?-1:d.indexOf(e);if(f<0&&"all"!==b)return;let g=new Set(d.filter((a,c)=>"all"===b||("current"===b?a===e:"others"===b?a!==e:"left"===b?c<f:c>f)));if(!g.size)return;let h=c.activeDiff??c.activePath;for(let a of g){if("string"!=typeof a){this.invalidateDiff(a);continue}this.documentRequests.get(a)?.abort(),this.documentRequests.delete(a),this.releaseDocument(c.documents.get(a)),c.documents.delete(a),this.restoredEditorStates.delete(a),this.restoredFileViewModes.delete(a),this.restoredPreviewScrollTops.delete(a),this.closeMissing.delete(a),this.restoredTabs.delete(a)}if(c.tabs=c.tabs.filter(a=>!g.has(a)),c.diffs=c.diffs.filter(a=>!g.has(a)),c.activePath&&g.has(c.activePath)){let a=d.filter(a=>"string"==typeof a),b=a.indexOf(c.activePath);c.activePath=a.slice(b+1).find(a=>!g.has(a))??a.slice(0,b).reverse().find(a=>!g.has(a))??null}if(null!==h&&g.has(h)){this.navigation=null;let a=d.indexOf(h),b=d.slice(a+1).find(a=>!g.has(a))??d.slice(0,a).reverse().find(a=>!g.has(a));c.activeDiff="object"==typeof b?b:null,"string"==typeof b&&(c.activePath=b)}this.publish(),c.activeDiff?this.ensureDiff(c.activeDiff):c.activePath&&h!==c.activePath&&this.ensureDocument(c.activePath)}reloadFile(a){if(this.state.tabs.includes(a)){if(this.state.activePath===a&&this.navigation)return void this.ensureDocument(a,!0);this.invalidateDocument(a),this.publish(),this.ensureDocument(a)}}async ensureDocument(a,b=!1){if(this.disposed||!this.state.tabs.includes(a)||this.documentRequests.has(a))return;let c=this.state.documents.get(a);if(!b&&c&&["loading","text","image"].includes(c.status))return;let d=new AbortController;this.documentRequests.set(a,d),c?.status!=="text"&&c?.status!=="image"&&(this.state.documents.set(a,{status:"loading"}),this.publish());try{let b=await this.reader.get(a,this.options.imagePreviewMode(),d.signal);if(this.documentRequests.get(a)!==d)return;let e="image"===b.kind?(0,f.E)(b):null,g=c?.status==="text"&&"text"===b.kind&&c.content===b.content&&c.size===b.size||c?.status==="image"&&null!==e&&await p(c.blob,e);if(this.documentRequests.get(a)!==d)return;this.documentRequests.delete(a),this.closeMissing.delete(a),this.restoredTabs.delete(a),g||this.state.documents.set(a,"text"===b.kind?{status:"text",content:b.content,size:b.size,editorState:c?.status==="text"?c.editorState:this.restoredEditorStates.get(a)??null,viewMode:this.state.activePath===a&&this.navigation?"source":c?.status==="text"?c.viewMode:this.restoredFileViewModes.get(a)??("markdown"===(0,i.g)(a)||this.options.htmlPreview&&"html"===(0,i.g)(a)?"preview":"source"),previewScrollTop:c?.status==="text"?c.previewScrollTop:this.restoredPreviewScrollTops.get(a)??0}:{status:"image",mimeType:b.mimeType,size:b.size,objectUrl:URL.createObjectURL(e),blob:e}),this.state.activePath===a&&"text"!==b.kind&&(this.navigation=null),g||this.releaseDocument(c)}catch(f){if(this.documentRequests.get(a)!==d)return;this.documentRequests.delete(a);let b=this.restoredTabs.delete(a),e=this.closeMissing.delete(a);if((b||e)&&f instanceof h.aw&&404===f.status&&"errors:fileMissing"===f.errorKey){this.closeTabs(a,"current"),e&&this.options.onNotice?.(n("branchFileClosed",{path:a}));return}console.warn("[Pi Desk][ProjectFile] 读取文件失败",{cwd:this.cwd,path:a,error:o(f)}),this.state.documents.set(a,{status:"error",error:o(f)}),this.releaseDocument(c),this.state.activePath===a&&(this.navigation=null)}this.publish()}async compareFile(a,b,c){let d=this.state.documents.get(a);if(this.disposed||c.aborted||d?.status!=="text")return;if(!b){d.comparison&&(delete d.comparison,this.publish());return}let e={status:"loading"};d.comparison=e,this.publish();let f=()=>!this.disposed&&!c.aborted&&this.state.documents.get(a)===d&&d.comparison===e;try{let a=await this.reader.diff(b.repositoryRoot,b.path,c);if(!f())return;"text"===a.kind?(d.content=a.modified.content,d.size=new TextEncoder().encode(a.modified.content).length,d.comparison={status:"ready",repositoryRoot:b.repositoryRoot,path:b.path,original:a.original}):d.comparison={status:"unavailable"}}catch(b){if(!f())return;console.warn("[Pi Desk][ProjectFile] 读取行变更失败",{cwd:this.cwd,path:a,error:o(b)}),d.comparison={status:"error",error:o(b)}}this.publish()}openFileDiff(a,b){let c=this.state.documents.get(a);if(this.disposed||c?.status!=="text"||c.comparison?.status!=="ready")return;let d=c.comparison,e=this.state.diffs.find(a=>!a.comparison&&a.repositoryRoot===d.repositoryRoot&&a.path===d.path);if(e)this.invalidateDiff(e),Object.assign(e,{status:"text",original:d.original,modified:{path:d.path,content:c.content}});else{if(!this.canOpenTab())return;e={status:"text",repositoryRoot:d.repositoryRoot,path:d.path,original:d.original,modified:{path:d.path,content:c.content}},this.state.diffs.push(e)}void 0!==b&&(e.initialLine=b),this.openDiff(e.repositoryRoot,e.path)}openDiff(a,b,c,d){if(this.disposed)return;let e={repositoryRoot:a,path:b,comparison:c},f=this.state.diffs.find(a=>m(a)===m(e));if(f)void 0!==d&&(f.label=d);else{if(!this.canOpenTab())return;f={...e,status:"unloaded",label:d},this.state.diffs.push(f)}this.navigation=null,this.state.activeDiff=f,this.publish(),this.ensureDiff(f)}closeDiff(){this.closeTabs(null,"current")}reloadDiff(){let a=this.state.activeDiff;a&&!this.disposed&&(this.invalidateDiff(a),this.publish(),this.ensureDiff(a))}refreshDiff(){let a=this.state.activeDiff;a&&!a.comparison&&this.ensureDiff(a,!0)}saveDiffState(a,b){!this.disposed&&this.state.diffs.includes(a)&&b&&(a.editorState=b,delete a.initialLine)}setDiffViewMode(a){this.state.activeDiff&&(0,g.ZQ)({diffViewMode:a})}setDiffWrapLines(a){this.state.activeDiff&&(0,g.ZQ)({wrapLines:a})}setDiffCollapseUnchanged(a){this.state.activeDiff&&(0,g.ZQ)({collapseUnchanged:a})}handleGitBranchChanged(a){for(let b of(this.refreshTree(),this.state.tabs))(!a||b===a||b.startsWith(`${a}/`))&&(this.invalidateDocument(b),this.closeMissing.add(b));for(let b of this.state.diffs)b.repositoryRoot!==a||b.comparison||this.invalidateDiff(b);this.publish(),this.state.activeDiff?this.ensureDiff(this.state.activeDiff):this.state.activePath&&this.ensureDocument(this.state.activePath)}saveEditorState(a,b){let c=this.state.documents.get(a);c?.status==="text"&&(c.editorState=b)}savePreviewScrollTop(a,b){let c=this.state.documents.get(a);c?.status==="text"&&(c.previewScrollTop=b)}setWrapLines(a,b){this.state.documents.get(a)?.status==="text"&&(0,g.ZQ)({wrapLines:b})}setTextViewMode(a,b){let c=this.state.documents.get(a);c?.status==="text"&&c.viewMode!==b&&(c.viewMode=b,this.publish())}dispose(){for(let a of(this.disposed=!0,this.compactRequests.clear(),this.directoryRequests.values()))a.controller.abort();for(let a of(this.directoryRequests.clear(),this.documentRequests.values()))a.abort();for(let a of(this.documentRequests.clear(),this.cancelSearch(),this.state.diffs))this.invalidateDiff(a);for(let a of(this.state.diffs=[],this.state.activeDiff=null,this.state.documents.values()))this.releaseDocument(a);this.state.documents.clear(),this.restoredPreviewScrollTops.clear(),this.listeners.clear()}async ensureDiff(a,b=!1){let c=m(a);if(this.disposed||!b&&"unloaded"!==a.status||this.diffRequests.has(c))return;let d=new AbortController;this.diffRequests.set(c,d),"text"!==a.status&&"metadata"!==a.status&&(Object.assign(a,{status:"loading"}),this.publish());try{let b=await this.reader.diff(a.repositoryRoot,a.path,d.signal,a.comparison);if(this.diffRequests.get(c)!==d)return;Object.assign(a,"text"===b.kind?{status:"text",original:b.original,modified:b.modified}:"metadata"===b.kind?{status:"metadata",originalMetadata:b.original,modifiedMetadata:b.modified}:{status:b.kind,error:null})}catch(b){if(this.diffRequests.get(c)!==d)return;console.warn("[Pi Desk][ProjectFile] 读取 Diff 失败",{cwd:this.cwd,repositoryRoot:a.repositoryRoot,path:a.path,error:o(b)}),Object.assign(a,{status:"error",error:o(b)})}this.diffRequests.get(c)===d&&(this.diffRequests.delete(c),this.publish())}invalidateDiff(a){let b=m(a);for(let c of(this.diffRequests.get(b)?.abort(),this.diffRequests.delete(b),Object.assign(a,{status:"unloaded"}),["original","modified","originalMetadata","modifiedMetadata","error"]))Reflect.deleteProperty(a,c)}canOpenTab(){let a=this.options.maxTabs;return!a||this.state.tabs.length+this.state.diffs.length<a||(this.options.onNotice?.(n("maxOpenFiles",{count:a})),!1)}cancelSearch(){this.searchRequest?.abort(),this.searchRequest=null}invalidateDocument(a){this.state.activePath===a&&(this.navigation=null),this.documentRequests.get(a)?.abort(),this.documentRequests.delete(a);let b=this.state.documents.get(a);b?.status==="text"&&(b.editorState&&this.restoredEditorStates.set(a,b.editorState),this.restoredFileViewModes.set(a,b.viewMode),this.restoredPreviewScrollTops.set(a,b.previewScrollTop)),this.releaseDocument(b),this.state.documents.set(a,{status:"unloaded"})}releaseDocument(a){a?.status==="image"&&URL.revokeObjectURL(a.objectUrl)}publish(){if(!this.disposed)for(let a of(this.revision+=1,this.listeners))a()}}},93306:(a,b,c)=>{"use strict";c.d(b,{x:()=>e});var d=c(97563);function e(a){return(0,d.h3)(a)}},95186:(a,b,c)=>{"use strict";c.d(b,{QL:()=>g,Y4:()=>h,aw:()=>f});var d=c(21850),e=c(17983);class f extends Error{constructor(a,b,c,d=null){super(c),this.status=a,this.code=b,this.errorKey=d,this.name="L3ProjectRequestError"}}async function g(a,b,c,e){let g=await fetch(b.path,{method:"POST",headers:{"Content-Type":"application/json","X-Pi-Desk-Client-Id":a},body:JSON.stringify(b.request.parse(c)),signal:e}),h=await g.json();if(!g.ok||0!==h.code||null===h.data)throw new f(g.status,h.code,h.msg?(0,d.B)(h):"项目读取失败",h.i18n?.key??null);return b.response.parse(h.data)}function h(a,b,c){async function d(b,d,e){try{return await g(a,b,d,e)}catch(a){throw!e?.aborted&&a instanceof f&&401===a.status&&c?.(),a}}return{list:(a,c)=>d(e.Xe,{...b,path:a},c),search:(a,c)=>d(e.fg,{...b,...a},c),get:(a,c,f)=>d(e.ZI,{...b,path:a,imagePreviewMode:c},f),snapshot:(a,c)=>d(e.p0,{...b,refresh:c},a),branches:(a,c)=>d(e.ry,{...b,repositoryRoot:a},c),log:(a,c,f)=>d(e.p3,{...b,repositoryRoot:a,...c},f),changes:(a,c,f)=>d(e.ys,{...b,repositoryRoot:a,...c},f),diff:(a,c,f,g)=>d(e.OC,{...b,repositoryRoot:a,path:c,comparison:g},f)}}},97563:(a,b,c)=>{"use strict";async function d(a){let b="u"<typeof navigator?void 0:navigator.clipboard;if(b?.writeText)try{return await b.writeText(a),!0}catch{}if("u"<typeof document||!document.body)return!1;let c=document.activeElement instanceof HTMLElement?document.activeElement:null,d=document.createElement("textarea");d.value=a,d.setAttribute("readonly",""),d.setAttribute("aria-hidden","true"),d.style.position="fixed",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.opacity="0";try{return document.body.append(d),d.select(),d.setSelectionRange(0,d.value.length),document.execCommand("copy")}catch{return!1}finally{d.remove();try{c?.focus()}catch{}}}c.d(b,{h3:()=>d,qj:()=>e});class e extends Error{constructor(a){super(a.message,{cause:a.cause}),this.name="PiDeskBrowserPluginError",this.pluginName=a.pluginName,this.contributionName=a.contributionName??null,this.phase=a.phase}}},98722:(a,b,c)=>{"use strict";c.d(b,{T8:()=>q,WW:()=>r,aD:()=>g,co:()=>m,lw:()=>s,ph:()=>p,xv:()=>k,yw:()=>n});var d=c(87883),e=c(51949),f=c(18997);let g=d.Yj().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),h=d.KC([g,d.eu("HEAD"),d.Yj().max(1024).regex(/^refs\/(?:heads|remotes)\/[^\0\r\n]+$/)]).refine(a=>!a.includes("..")&&!a.endsWith("/"),"Git 版本无效"),i=d.KC([d.Ik({commit:h,parent:g.optional()}).strict(),d.Ik({base:h,target:h,strategy:d.k5(["merge-base","direct"])}).strict()]),j=d.Ik({base:g.nullable(),target:g,original:g.nullable()}).strict(),k=d.Ik({baseCommit:g.nullable(),targetCommit:g,oldPath:e._g.optional()}).strict(),l=d.Ik({oid:g,parents:d.YO(g),subject:d.Yj(),author:d.Yj(),timestampMs:d.ai().int(),refs:d.YO(d.Yj())}).strict(),m=d.Ik({tip:h,exclude:h.optional(),query:d.Yj().trim().max(200).default(""),author:d.Yj().trim().max(200).optional(),page:d.Ik({index:d.ai().int().min(1).max(2e3),size:d.ai().int().min(1).max(100)}).strict()}).strict(),n=d.Ik({tip:g.nullable(),exclude:g.nullable(),items:d.YO(l),hasMore:d.zM(),truncated:d.zM()}).strict(),o=d.Ik({path:e._g,oldPath:e._g.nullable(),status:d.k5(["added","modified","deleted","renamed","type-changed"])}).strict(),p=d.Ik({selection:i,page:d.Ik({index:d.ai().int().min(1).max(5e4),size:d.ai().int().min(1).max(500)}).strict()}).strict(),q=d.Ik({comparison:j,commit:l.extend({message:d.Yj(),selectedParent:g.nullable()}).nullable(),items:d.YO(o),hasMore:d.zM(),truncated:d.zM()}).strict(),r=f.gf.extend({upstream:d.Ik({ref:d.Yj(),ahead:d.ai().int().nonnegative().nullable(),behind:d.ai().int().nonnegative().nullable()}).strict().nullable()}).strict(),s=d.KC([f.FJ,d.Ik({kind:d.eu("metadata"),original:d.Yj(),modified:d.Yj()}).strict()])}};