@pi-chamber/web 1.0.4 → 1.0.5-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.js +21 -2
  3. package/bin/cli.test.js +164 -4
  4. package/bin/lib/DOCUMENTATION.md +3 -3
  5. package/bin/lib/cli-args.js +96 -13
  6. package/bin/lib/commands-connect-url-tailscale.test.js +136 -0
  7. package/bin/lib/commands-connect-url.js +146 -39
  8. package/bin/lib/commands-connect-url.test.js +126 -0
  9. package/bin/lib/commands-serve.js +45 -2
  10. package/bin/lib/commands-status.js +28 -5
  11. package/bin/lib/commands-status.test.js +107 -0
  12. package/bin/lib/commands-tunnel.js +36 -10
  13. package/dist/assets/{DiagramView-BpG1c3Hi.js → DiagramView-D-OSWTbO.js} +1 -1
  14. package/dist/assets/DiffView-BKT-MIH4.js +18 -0
  15. package/dist/assets/{FileSaveConflictDialog-DP7k9a-i.js → FileSaveConflictDialog-DBkVFssC.js} +2 -2
  16. package/dist/assets/FilesView-B7GIuRlh.js +6 -0
  17. package/dist/assets/{GitHubDetailScaffold-UxLAMAOl.js → GitHubDetailScaffold-C9rCZMUT.js} +2 -2
  18. package/dist/assets/{GitHubLinkPicker-Bh9RO1yK.js → GitHubLinkPicker-Bm09hvhJ.js} +1 -1
  19. package/dist/assets/{GitHubListPrimitives-DQyhT5wG.js → GitHubListPrimitives-DlhAlxI6.js} +1 -1
  20. package/dist/assets/{GitView-XBBheKRM.js → GitView-BgqdMb0m.js} +4 -4
  21. package/dist/assets/{IssuesSurface-BA1kpvAJ.js → IssuesSurface-BZXAvt49.js} +3 -3
  22. package/dist/assets/{JsonTreeView-BAaEPL4O.js → JsonTreeView-BKgCQjh_.js} +1 -1
  23. package/dist/assets/{MarkdownRendererImpl-DzgDmUsL.js → MarkdownRendererImpl-BdcyMPw-.js} +1 -1
  24. package/dist/assets/{PatchDiff-BMEUsgXH.js → PatchDiff-2MmWXcGe.js} +1 -1
  25. package/dist/assets/PierreDiffViewer-D1F2WvD0.js +135 -0
  26. package/dist/assets/PullRequestsSurface-CN2z3DFv.js +2 -0
  27. package/dist/assets/SessionSwitcherContent-CCljxAZb.js +1 -0
  28. package/dist/assets/SessionSwitcherDropdown-DtNt3qw4.js +2 -0
  29. package/dist/assets/SessionUnreadDot-B9bHMy5q.js +1 -0
  30. package/dist/assets/SettingsView-DaZVCInW.js +6 -0
  31. package/dist/assets/{SettingsWindow-j0e99YI0.js → SettingsWindow-C-ydfopH.js} +1 -1
  32. package/dist/assets/StickyHorizontalScrollbar-BMITjK4e.js +8 -0
  33. package/dist/assets/{ToolOutputDialog-VlS12Xyq.js → ToolOutputDialog-DJUAx_Oj.js} +4 -4
  34. package/dist/assets/{ToolPartDiffPreview-DdSneZws.js → ToolPartDiffPreview-DFyuJM4c.js} +1 -1
  35. package/dist/assets/{VirtualizedFileDiff-BqiXjvP6.js → VirtualizedFileDiff-BS-af6rn.js} +4 -4
  36. package/dist/assets/{Virtualizer-Cp_cJWbI.js → Virtualizer-DP6HbEeC.js} +1 -1
  37. package/dist/assets/{collapsible-C7oyikVm.js → collapsible-BOcd0lzY.js} +1 -1
  38. package/dist/assets/{computeVirtualFileMetrics-BJjC-tXV.js → computeVirtualFileMetrics-BI6wORhM.js} +1 -1
  39. package/dist/assets/{contextFileOpenGuard-BBzqKGei.js → contextFileOpenGuard-DUMSGR4M.js} +1 -1
  40. package/dist/assets/{gitStatusPredicates-Dq-E5DaH.js → gitStatusPredicates-FdKYDZe3.js} +1 -1
  41. package/dist/assets/{githubLink-Cryd7GkG.js → githubLink-B3-BaGpb.js} +5 -5
  42. package/dist/assets/index-DWSrsQWl.js +11 -0
  43. package/dist/assets/{index-BbhXFTId.js → index-Df-vmvzu.js} +1 -1
  44. package/dist/assets/index-DsQIBAWK.css +1 -0
  45. package/dist/assets/main-61_cd7S7.js +2 -0
  46. package/dist/assets/main-q43jqZ2I.js +136 -0
  47. package/dist/assets/{markdownCore-B9AuEyYi.js → markdownCore-CqHYlXi_.js} +2 -2
  48. package/dist/assets/{miniChat-CgOaJfD8.js → miniChat-vOuWN5pV.js} +2 -2
  49. package/dist/assets/mobile-mrXWV5ky.js +2 -0
  50. package/dist/assets/{nativeFileSave-BzhtrDoD.js → nativeFileSave-CFuugNKV.js} +1 -1
  51. package/dist/assets/pi-session-focus-preference-BEufpwC6.js +9 -0
  52. package/dist/assets/{renderDiffWithHighlighter-CVLsdtQ5.js → renderDiffWithHighlighter-BD9CAhZU.js} +1 -1
  53. package/dist/assets/renderElectronMiniChatApp-QQFXkY5Y.js +2 -0
  54. package/dist/assets/{renderFileWithHighlighter-DJ9mk2bZ.js → renderFileWithHighlighter-KiEWMtzI.js} +1 -1
  55. package/dist/assets/renderMobileApp-DIZYvrhi.js +11 -0
  56. package/dist/assets/runtimeEndpointReset-BA2uP2rj.js +62 -0
  57. package/dist/assets/{runtimeSurface-DBiUWYK2.js → runtimeSurface-Der4qUnI.js} +1 -1
  58. package/dist/assets/useAppFontEffects-Bfw_d5eB.js +212 -0
  59. package/dist/assets/{useFilesViewSearch-D2Au5Xgt.js → useFilesViewSearch-Budwejnx.js} +3 -3
  60. package/dist/assets/useGitHubRemoteSearch-gUdylYy3.js +1 -0
  61. package/dist/assets/{useSwitcherItems-Dej8BzXI.js → useSwitcherItems-yHSMduoo.js} +1 -1
  62. package/dist/assets/{vendor-aparajita-capacitor-secure-storage-BYohCVY0.js → vendor-aparajita-capacitor-secure-storage-BDrMx_CE.js} +1 -1
  63. package/dist/assets/{vendor-base-ui-BscvGUFt.js → vendor-base-ui-CKRUCG-f.js} +1 -1
  64. package/dist/assets/{vendor-boot-Dgb9NVFe.js → vendor-boot-EC6IyLt1.js} +13 -13
  65. package/dist/assets/{vendor-capacitor-app-BjdQVib9.js → vendor-capacitor-app-BaupizkW.js} +1 -1
  66. package/dist/assets/{vendor-capacitor-keyboard-eTtI5go3.js → vendor-capacitor-keyboard-9BVxykO7.js} +1 -1
  67. package/dist/assets/{vendor-capacitor-status-bar-9rNIGxlO.js → vendor-capacitor-status-bar-BsrUwiaA.js} +1 -1
  68. package/dist/assets/{vendor-codemirror-autocomplete-DxS3jwvE.js → vendor-codemirror-autocomplete-CGpAsPWp.js} +1 -1
  69. package/dist/assets/{vendor-codemirror-lang-angular-DdjXl9e2.js → vendor-codemirror-lang-angular-CDJoHJSY.js} +1 -1
  70. package/dist/assets/{vendor-codemirror-lang-cpp--aMr7NVt.js → vendor-codemirror-lang-cpp-BmHofQls.js} +1 -1
  71. package/dist/assets/{vendor-codemirror-lang-css-CZ_qxZY9.js → vendor-codemirror-lang-css-RM2HqXZ0.js} +1 -1
  72. package/dist/assets/{vendor-codemirror-lang-go-Ca-y2Alu.js → vendor-codemirror-lang-go-Crwca_X7.js} +1 -1
  73. package/dist/assets/{vendor-codemirror-lang-html-COZ0L5wT.js → vendor-codemirror-lang-html-CHSHUpwq.js} +1 -1
  74. package/dist/assets/{vendor-codemirror-lang-java-D3Rf3QNJ.js → vendor-codemirror-lang-java-lhQXgWu0.js} +1 -1
  75. package/dist/assets/{vendor-codemirror-lang-javascript-DwJ-IvCs.js → vendor-codemirror-lang-javascript-Dw4kFO4e.js} +1 -1
  76. package/dist/assets/{vendor-codemirror-lang-jinja-D_5lod6k.js → vendor-codemirror-lang-jinja-_pAC3UTN.js} +1 -1
  77. package/dist/assets/{vendor-codemirror-lang-json-BG8C7OpC.js → vendor-codemirror-lang-json-B-b1vAv-.js} +1 -1
  78. package/dist/assets/{vendor-codemirror-lang-less-CVEkoaTw.js → vendor-codemirror-lang-less-xIgOi1ze.js} +1 -1
  79. package/dist/assets/{vendor-codemirror-lang-liquid-U9vj0m8w.js → vendor-codemirror-lang-liquid-CP49m5dB.js} +1 -1
  80. package/dist/assets/{vendor-codemirror-lang-markdown-DqlYH9gY.js → vendor-codemirror-lang-markdown-BTht2ATe.js} +1 -1
  81. package/dist/assets/{vendor-codemirror-lang-php-BFEiEVA1.js → vendor-codemirror-lang-php-BguZDhaO.js} +1 -1
  82. package/dist/assets/{vendor-codemirror-lang-python-Cz1dQXQd.js → vendor-codemirror-lang-python-CH6_em9L.js} +1 -1
  83. package/dist/assets/{vendor-codemirror-lang-rust-C_CoD9mj.js → vendor-codemirror-lang-rust-EG_DtGyi.js} +1 -1
  84. package/dist/assets/{vendor-codemirror-lang-sass-BuR0aKh5.js → vendor-codemirror-lang-sass-BknY5Qpo.js} +1 -1
  85. package/dist/assets/{vendor-codemirror-lang-sql-DggNUjdM.js → vendor-codemirror-lang-sql-B0f-qCZo.js} +1 -1
  86. package/dist/assets/{vendor-codemirror-lang-vue-DFZHi2J3.js → vendor-codemirror-lang-vue-CyGn9snv.js} +1 -1
  87. package/dist/assets/{vendor-codemirror-lang-wast-zuTN3SHT.js → vendor-codemirror-lang-wast-CsFfSyyB.js} +1 -1
  88. package/dist/assets/{vendor-codemirror-lang-xml-CrcvhI-k.js → vendor-codemirror-lang-xml-Cdan_Jp1.js} +1 -1
  89. package/dist/assets/{vendor-codemirror-lang-yaml-DcVWsakb.js → vendor-codemirror-lang-yaml-COI5hck8.js} +1 -1
  90. package/dist/assets/{vendor-codemirror-language-data-CCLITgCF.js → vendor-codemirror-language-data-CqU7kHmg.js} +2 -2
  91. package/dist/assets/{vendor-codemirror-search-H7NOEdbX.js → vendor-codemirror-search-DUfSCF9S.js} +1 -1
  92. package/dist/assets/{vendor-lezer-cpp-C8aD2KAr.js → vendor-lezer-cpp-DMZOJzBa.js} +1 -1
  93. package/dist/assets/{vendor-lezer-css-2lbTJF-Y.js → vendor-lezer-css-DUkkbMp7.js} +1 -1
  94. package/dist/assets/{vendor-lezer-go-Bw6LFTrZ.js → vendor-lezer-go-CHIhCNY6.js} +1 -1
  95. package/dist/assets/{vendor-lezer-html-D7ym2z7S.js → vendor-lezer-html-B3h0MOrG.js} +1 -1
  96. package/dist/assets/{vendor-lezer-java-CZhK7w21.js → vendor-lezer-java-tMazV_6X.js} +1 -1
  97. package/dist/assets/{vendor-lezer-javascript-rpKeTHZp.js → vendor-lezer-javascript-ctwLWf4v.js} +1 -1
  98. package/dist/assets/{vendor-lezer-json-C7jwsd2G.js → vendor-lezer-json-BP_UAzLL.js} +1 -1
  99. package/dist/assets/{vendor-lezer-lr-DR-ylqNN.js → vendor-lezer-lr-B8TQctNw.js} +1 -1
  100. package/dist/assets/{vendor-lezer-markdown-Bir0m5nB.js → vendor-lezer-markdown-aGLZf_3h.js} +1 -1
  101. package/dist/assets/{vendor-lezer-php-y0hIEfo1.js → vendor-lezer-php-D5zCNzlt.js} +1 -1
  102. package/dist/assets/{vendor-lezer-python-D64A9lNV.js → vendor-lezer-python-EJ4Im4y2.js} +1 -1
  103. package/dist/assets/{vendor-lezer-rust-E3ZA9T2L.js → vendor-lezer-rust-DO5c7OtA.js} +1 -1
  104. package/dist/assets/{vendor-lezer-sass-C5UFI9SP.js → vendor-lezer-sass-CMi6zfXI.js} +1 -1
  105. package/dist/assets/{vendor-lezer-xml-DOy7FzCR.js → vendor-lezer-xml-0MHMeZDp.js} +1 -1
  106. package/dist/assets/{vendor-lezer-yaml-kEjaSCvZ.js → vendor-lezer-yaml-BE2EFjpA.js} +1 -1
  107. package/dist/assets/{vendor-replit-codemirror-vim-BLfh0LPy.js → vendor-replit-codemirror-vim-AnOuN8yJ.js} +1 -1
  108. package/dist/assets/{web-components-C7CmoFxi.js → web-components-CeHLxvED.js} +3 -3
  109. package/dist/index.html +4 -4
  110. package/dist/mini-chat.html +3 -3
  111. package/dist/mobile.html +3 -3
  112. package/dist/sw.js +1 -1
  113. package/package.json +1 -2
  114. package/server/index.js +69 -30
  115. package/server/lib/client-auth/DOCUMENTATION.md +15 -1
  116. package/server/lib/client-auth/pairing.js +2 -12
  117. package/server/lib/client-auth/remote-clients.js +2 -12
  118. package/server/lib/cloudflare-tunnel.js +0 -132
  119. package/server/lib/fs/DOCUMENTATION.md +8 -0
  120. package/server/lib/fs/atomic-write.js +111 -0
  121. package/server/lib/fs/atomic-write.test.js +133 -0
  122. package/server/lib/notifications/DOCUMENTATION.md +43 -32
  123. package/server/lib/notifications/pi-notification-watcher.js +8 -7
  124. package/server/lib/notifications/pi-notification-watcher.test.js +88 -2
  125. package/server/lib/pi/routes-extension-events.test.js +231 -0
  126. package/server/lib/pi/routes.js +137 -4
  127. package/server/lib/pi/routes.test.js +248 -2
  128. package/server/lib/pi/session-daemon/DOCUMENTATION.md +17 -4
  129. package/server/lib/pi/session-daemon/daemon-process.js +2 -0
  130. package/server/lib/pi/session-daemon/engines/index.js +6 -0
  131. package/server/lib/pi/session-daemon/extension-bridge-draft.test.js +1 -1
  132. package/server/lib/pi/session-daemon/extension-bridge.js +24 -0
  133. package/server/lib/pi/session-daemon/extension-message-render.js +74 -0
  134. package/server/lib/pi/session-daemon/extension-message-render.test.js +164 -0
  135. package/server/lib/pi/session-daemon/extension-tool-render.js +13 -6
  136. package/server/lib/pi/session-daemon/pending-input.js +188 -0
  137. package/server/lib/pi/session-daemon/pending-input.test.js +202 -0
  138. package/server/lib/pi/session-daemon/session-daemon-engines.test.js +828 -0
  139. package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +296 -6
  140. package/server/lib/pi/session-daemon/session-daemon-turn.e2e.test.js +9 -0
  141. package/server/lib/pi/session-daemon/session-daemon.js +219 -19
  142. package/server/lib/pi/session-daemon/session-daemon.test.js +30 -2
  143. package/server/lib/pi/session-daemon/session-engine-router.js +390 -0
  144. package/server/lib/pi/session-daemon/session-engine-router.test.js +515 -0
  145. package/server/lib/pi/session-daemon/session-engines.js +467 -0
  146. package/server/lib/pi/session-daemon/session-engines.test.js +383 -0
  147. package/server/lib/pi/snippets-store.js +8 -17
  148. package/server/lib/pi/ui-settings-store.js +6 -10
  149. package/server/lib/pi/ui-settings-store.test.js +37 -1
  150. package/server/lib/relay/DOCUMENTATION.md +6 -4
  151. package/server/lib/relay/identity-store.js +116 -0
  152. package/server/lib/relay/identity-store.test.js +169 -0
  153. package/server/lib/relay/identity.js +6 -4
  154. package/server/lib/relay/server-id.js +63 -0
  155. package/server/lib/relay/server-id.test.js +132 -0
  156. package/server/lib/relay/signing-key.js +14 -11
  157. package/server/lib/security/bind-host.js +6 -2
  158. package/server/lib/security/bind-host.test.js +17 -0
  159. package/server/lib/server/core-routes.js +27 -1
  160. package/server/lib/server/lan-addresses.js +18 -6
  161. package/server/lib/server/lan-addresses.test.js +28 -0
  162. package/server/lib/server/tunnel-auth.js +47 -7
  163. package/server/lib/server/tunnel-auth.rate-limit.test.js +164 -0
  164. package/server/lib/server/tunnel-service.DOCUMENTATION.md +3 -4
  165. package/server/lib/server/tunnel-service.js +23 -20
  166. package/server/lib/server/tunnel-service.test.js +19 -2
  167. package/server/lib/stt/config-store.js +5 -15
  168. package/server/lib/tailscale/DOCUMENTATION.md +264 -0
  169. package/server/lib/tailscale/routes.js +45 -0
  170. package/server/lib/tailscale/service.js +959 -0
  171. package/server/lib/tailscale/tailscale.js +302 -0
  172. package/server/lib/tailscale/tailscale.test.js +1861 -0
  173. package/server/lib/tunnels/DOCUMENTATION.md +3 -4
  174. package/server/lib/tunnels/providers/cloudflare.js +1 -22
  175. package/server/lib/tunnels/types.js +0 -2
  176. package/server/lib/ui-auth/DOCUMENTATION.md +31 -0
  177. package/server/lib/ui-auth/ui-auth.js +80 -6
  178. package/server/lib/ui-auth/ui-auth.test.js +136 -0
  179. package/server/lib/ui-auth/ui-passkeys.js +2 -13
  180. package/server/lib/update-job-store.js +4 -6
  181. package/dist/assets/DiffView-BxwoRCYx.js +0 -18
  182. package/dist/assets/FilesView-D_2QcdUt.js +0 -6
  183. package/dist/assets/PierreDiffViewer-BW8MO-O6.js +0 -134
  184. package/dist/assets/PullRequestsSurface-B3ictm4I.js +0 -2
  185. package/dist/assets/SessionSwitcherContent-rLoyVqgs.js +0 -1
  186. package/dist/assets/SessionSwitcherDropdown-CfySKnUu.js +0 -2
  187. package/dist/assets/SessionUnreadDot-CmEF9sxM.js +0 -1
  188. package/dist/assets/SettingsView-BiwlwnTK.js +0 -6
  189. package/dist/assets/index-BnZVqcki.js +0 -11
  190. package/dist/assets/index-BnieExes.css +0 -1
  191. package/dist/assets/main-9O5IAtT_.js +0 -136
  192. package/dist/assets/main-DWGwALIw.js +0 -2
  193. package/dist/assets/mobile-BbJcYVym.js +0 -2
  194. package/dist/assets/pi-session-focus-preference-Bmk1iOvn.js +0 -10
  195. package/dist/assets/renderElectronMiniChatApp-R5o9NwFC.js +0 -2
  196. package/dist/assets/renderMobileApp-CQ9tWYIj.js +0 -11
  197. package/dist/assets/runtimeEndpointReset-CtK4C_5h.js +0 -62
  198. package/dist/assets/useAppFontEffects-DviRbaCJ.js +0 -212
  199. package/dist/assets/useGitHubRemoteSearch-D-K7aolk.js +0 -1
  200. package/dist/assets/vendor-capacitor-push-notifications-CBKq2Arn.js +0 -1
  201. package/server/lib/notifications/delivery-runtime.js +0 -314
  202. package/server/lib/notifications/delivery-runtime.test.js +0 -85
  203. package/server/lib/notifications/routes.js +0 -74
  204. package/server/lib/relay/service.js +0 -9
@@ -0,0 +1,135 @@
1
+ import{aN as Se,k as z}from"./vendor-boot-EC6IyLt1.js";import{a as f,R as ae}from"./vendor-react-DASdDPIk.js";import{B as Ee}from"./web-components-CeHLxvED.js";import{f as ce}from"./computeVirtualFileMetrics-BI6wORhM.js";import{V as ke,F as Te}from"./VirtualizedFileDiff-BS-af6rn.js";import{b5 as xe,at as Oe}from"./useAppFontEffects-Bfw_d5eB.js";import{P as ze,S as De}from"./StickyHorizontalScrollbar-BMITjK4e.js";import{b0 as Ce}from"./runtimeEndpointReset-BA2uP2rj.js";import{ensurePierreThemeRegistered as ue,getResolvedShikiTheme as he}from"./appThemeRegistry-gegrE2dq.js";import{T as de,e as fe}from"./index-DWSrsQWl.js";const J=new Set;let ne=null;function E(n){J.add(n),ne??=requestAnimationFrame(be)}function be(n){const e=new Set(J);J.clear();for(const t of e)try{t(n)}catch(r){console.error(r)}J.size>0?ne=requestAnimationFrame(be):ne=null}function ge({scrollTop:n,scrollHeight:e,height:t,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:s}){const h=t+s*2,d=r?t+i*2:h;if(e=Math.max(e,d),h>=e||r){const g=Math.max(n-i,0),y=Math.min(n+d,e);return{top:g,bottom:Math.max(y,g)}}let c=n+t/2-h/2,m=c+h;return c<0&&(c=0),m>e&&(m=e),c=Math.floor(Math.max(c,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(m,e),c))}}function Ie(n,e){return n==null||e==null?n===e:n.top===e.top&&n.bottom===e.bottom}const ye=1e3,Me=ye*4,He=[0,1e-6,.99999,1],Pe={overscrollSize:ye,intersectionObserverMargin:Me,resizeDebugging:!1};let Z=0,Le=-1;var _e=class T{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++Le}`;config;type="simple";intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...Pe,...e}}setup(e,t){if(this.root==null){this.root=e,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:He,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),e instanceof Document?this.setupWindow():this.setupElement(t),window.__INSTANCE=this,window.__TOGGLE=()=>{T.__STOP?(T.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:T.__lastScrollPosition}),E(this.computeRenderRangeAndEmit)):(T.__lastScrollPosition=this.getScrollTop(),T.__STOP=!0)};for(const[r,i]of this.connectQueue.entries())this.connect(r,i);this.connectQueue.clear(),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}}instanceChanged(e,t){this.instancesChanged.add(e),t&&this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=ge({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){const r=this.getScrollTop(),i=this.getHeight(),s=this.config.intersectionObserverMargin,h=r-s,d=r+i+s;return!(e<h-t||e>d)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(const r of e){const i=r.borderBoxSize[0].blockSize;this.root instanceof Document?i!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:i-Z,newSize:i}),Z=i)):r.target===this.root?i!==this.height&&(this.heightDirty=!0,t=!0):r.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:i-Z,newSize:i}),Z=i))}t&&E(this.computeRenderRangeAndEmit)};setupWindow(){if(this.root==null||!(this.root instanceof Document))throw new Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(this.root==null||this.root instanceof Document)throw new Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),e??=this.root.firstElementChild??void 0,e instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0}getOffsetInScrollContainer(e){return this.getScrollTop()+U(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw new Error("Virtualizer.connect: instance is already connected...");return this.intersectionObserver==null?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){const t=this.observers.get(e);this.connectQueue.delete(e),t!=null&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),E(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{T.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,E(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{T.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{T.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(T.__STOP)return;const e=this.heightDirty||this.scrollHeightDirty;if(!this.scrollDirty&&!this.scrollHeightDirty&&!this.heightDirty&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.instancesChanged.size===0)return;let t=this.instancesChanged.size>0;if(this.instancesChanged.size===0){const s=ge({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!e&&Ie(this.windowSpecs,s)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty)return;this.windowSpecs=s}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;const r=this.getScrollAnchor(this.height),i=new Set;for(const s of e?this.observers.values():this.visibleInstances.values())s.onRender(e)&&i.add(s);for(const s of this.instancesChanged)i.has(s)||s.onRender(e)&&i.add(s);this.scrollFix(r);for(const s of i)s.reconcileHeights();t||=this.instancesChanged.size>0,t&&this.markDOMDirty(),(t||e)&&E(this.computeRenderRangeAndEmit),i.clear(),this.instancesChanged.clear()};scrollFix(e){if(e==null)return;const t=this.getScrollContainerElement(),{lineIndex:r,lineOffset:i,fileElement:s,fileOffset:h,fileTypeOffset:d}=e;if(r!=null&&i!=null){const m=s.shadowRoot?.querySelector(`[data-line][data-line-index="${r}"]`);if(m instanceof HTMLElement){const g=U(m,t);if(g!==i){const y=g-i;this.applyScrollFix(y)}return}}const c=U(s,t);if(d==="top")c!==h&&this.applyScrollFix(c-h);else{const m=c+s.getBoundingClientRect().height;m!==h&&this.applyScrollFix(m-h)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(e){const t=this.getScrollContainerElement();let r;for(const[i]of this.visibleInstances.entries()){const s=U(i,t),h=s+i.offsetHeight;let d,c;h<=0?(d=h,c="bottom"):(d=s,c="top");let m,g;if(h>0&&s<e)for(const w of i.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(w instanceof HTMLElement))continue;const B=w.dataset.lineIndex;if(B==null)continue;const D=U(w,t);if(!(D<0)){m=B,g=D;break}}if(r?.lineOffset!=null&&g==null)continue;let y=!1;(r==null||g!=null&&(r.lineOffset==null||g<r.lineOffset)||g==null&&r.lineOffset==null&&(d>=0&&(r.fileOffset<0||d<r.fileOffset)||d<0&&r.fileOffset<0&&d>r.fileOffset))&&(y=!0),y&&(r={fileElement:i,fileTypeOffset:c,fileOffset:d,lineIndex:m,lineOffset:g})}return r}handleIntersectionChange=e=>{this.scrollDirty=!0;for(const{target:t,isIntersecting:r}of e){if(!(t instanceof HTMLElement))throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");const i=this.observers.get(t);i!=null&&(r&&!this.visibleInstances.has(t)?(i.setVisibility(!0),this.visibleInstances.set(t,i),this.visibleInstancesDirty=!0):!r&&this.visibleInstances.has(t)&&(i.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&E(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight())),this.scrollTop=e,e}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}};function U(n,e){const t=n.getBoundingClientRect(),r=e?.getBoundingClientRect().top??0;return t.top-r}const pe=5e5,Fe=`
2
+ :host {
3
+ font-family: var(--font-mono);
4
+ font-size: var(--text-code);
5
+ }
6
+
7
+ pre, [data-code] {
8
+ font-family: var(--font-mono);
9
+ font-size: var(--text-code);
10
+ }
11
+
12
+ /* Mobile touch selection support */
13
+ [data-line-number] {
14
+ touch-action: manipulation;
15
+ -webkit-tap-highlight-color: transparent;
16
+ cursor: pointer;
17
+ }
18
+
19
+ /* Ensure interactive line numbers work on touch */
20
+ pre[data-interactive-line-numbers] [data-line-number] {
21
+ touch-action: manipulation;
22
+ }
23
+ `,me=`
24
+ ${Fe}
25
+
26
+ :host {
27
+ --diffs-bg-separator-override: var(--surface-elevated);
28
+ }
29
+
30
+ [data-diff-header],
31
+ [data-diff] {
32
+ [data-separator] {
33
+ height: 24px !important;
34
+ }
35
+ }
36
+
37
+ [data-separator="line-info-basic"] {
38
+ height: 24px !important;
39
+ background: var(--diffs-bg) !important;
40
+ position: relative;
41
+ }
42
+
43
+ [data-diff-type="single"] [data-gutter],
44
+ [data-diff-type="split"] [data-deletions] [data-gutter] {
45
+ [data-separator-wrapper] {
46
+ position: absolute;
47
+ left: 100%;
48
+ display: flex;
49
+ align-items: center;
50
+ gap: unset;
51
+ width: max-content;
52
+ background: transparent;
53
+ color: var(--diffs-fg-number);
54
+ font-family: var(--diffs-header-font-family, var(--font-sans));
55
+ font-size: 0.75rem;
56
+ line-height: 1;
57
+ margin-left: calc(-2ch - 2px);
58
+ }
59
+
60
+ [data-separator-wrapper][data-separator-multi-button] {
61
+ margin-left: calc(-3ch - 2px);
62
+ }
63
+
64
+ [data-expand-button],
65
+ [data-separator-content] {
66
+ display: block;
67
+ align-self: unset;
68
+ min-width: unset;
69
+ min-height: unset;
70
+ padding: 0;
71
+ flex-shrink: 0;
72
+ grid-column: unset;
73
+ border: none;
74
+ width: auto;
75
+ height: auto;
76
+ background-color: transparent;
77
+ color: inherit;
78
+ font: inherit;
79
+ }
80
+
81
+ [data-expand-button]:not([data-expand-all-button]) {
82
+ &[data-expand-down]::before {
83
+ content: '\\2191';
84
+ }
85
+
86
+ &[data-expand-up]::before {
87
+ content: '\\2193';
88
+ }
89
+
90
+ &[data-expand-both]::before {
91
+ content: '\\2195';
92
+ }
93
+
94
+ svg {
95
+ display: none;
96
+ }
97
+ }
98
+
99
+ [data-separator-content] {
100
+ background: transparent;
101
+ margin-left: calc(2px + 1ch);
102
+ }
103
+
104
+ [data-expand-all-button] {
105
+ position: relative;
106
+ margin-left: 14px;
107
+ text-transform: lowercase;
108
+ }
109
+
110
+ [data-expand-all-button]::before {
111
+ content: '';
112
+ display: block;
113
+ position: absolute;
114
+ top: 50%;
115
+ left: -8px;
116
+ margin-top: -1px;
117
+ width: 3px;
118
+ height: 3px;
119
+ border-radius: 2px;
120
+ background-color: var(--diffs-fg-number);
121
+ pointer-events: none;
122
+ }
123
+
124
+ [data-separator-content]:hover,
125
+ [data-expand-button]:hover,
126
+ [data-expand-all-button]:hover {
127
+ color: var(--diffs-fg);
128
+ }
129
+
130
+ [data-expand-all-button]:hover {
131
+ text-decoration: underline;
132
+ }
133
+ }
134
+ `;function Ae(n){let e=2166136261;for(let t=0;t<n.length;t+=1)e^=n.charCodeAt(t),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)}function ve(n){const e=n.length>400?`${n.slice(0,200)}${n.slice(-200)}`:n;return`${n.length}:${Ae(e)}`}const Ve=n=>n==="auto"||n==="scroll"||n==="overlay",$e=n=>{let e=n?.parentElement??null;for(;e;){const t=window.getComputedStyle(e);if(Ve(t.overflowY))return e;e=e.parentElement}return null},qe=(n,e)=>{if(!n||!e||typeof window>"u")return()=>{};const t=$e(n);if(!t)return()=>{};const r=e.getBoundingClientRect().height;if(!r)return()=>{};const i=n.getBoundingClientRect().top-t.getBoundingClientRect().top,s=e.style.minHeight;e.style.minHeight=`${Math.ceil(r)}px`;let h=!1;return()=>{if(h)return;h=!0,e.style.minHeight=s;const c=n.getBoundingClientRect().top-t.getBoundingClientRect().top-i;c&&(t.scrollTop+=c)}},Be=(n,e)=>{if(typeof window>"u")return()=>{};let t=null,r=null,i=!1;const s=()=>{i||(r?.disconnect(),r=null,t=window.requestAnimationFrame(()=>{t=window.requestAnimationFrame(()=>{i||e()})}))},h=()=>n.querySelector("diffs-container")?.shadowRoot??void 0,d=(c=h())=>!!c?.querySelector("[data-line]");return d()?s():typeof MutationObserver<"u"?(r=new MutationObserver(()=>{const c=h();if(c){if(d(c)){s();return}r?.disconnect(),r=new MutationObserver(()=>{d(c)&&s()}),r.observe(c,{childList:!0,subtree:!0})}}),r.observe(n,{childList:!0,subtree:!0})):t=window.requestAnimationFrame(s),()=>{i=!0,r?.disconnect(),t!==null&&window.cancelAnimationFrame(t)}},X=new WeakMap,Ne={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function We(n){const e=n.closest("[data-diff-virtual-root]");if(e instanceof HTMLElement){const t=e.querySelector("[data-diff-virtual-content]");return{key:e,root:e,content:t instanceof HTMLElement?t:void 0}}return{key:document,root:document,content:void 0}}function je(n){if(typeof document>"u")return null;const e=We(n);let t=X.get(e.key);if(!t){const i=new _e;i.setup(e.root,e.content),t={virtualizer:i,refs:0},X.set(e.key,t)}t.refs+=1;let r=!1;return{virtualizer:t.virtualizer,root:e.root,release:()=>{if(r)return;r=!0;const i=X.get(e.key);i&&(i.refs-=1,!(i.refs>0)&&(i.virtualizer.cleanUp(),X.delete(e.key)))}}}const Ue=(n,e,t)=>{if(typeof window>"u")return()=>{};const r=[],i=()=>{try{n.rerender()}catch{}const s=e?.root;s instanceof HTMLElement?s.dispatchEvent(new Event("scroll",{bubbles:!1})):document.dispatchEvent(new Event("scroll",{bubbles:!1})),window.dispatchEvent(new Event("resize")),t()};return r.push(window.requestAnimationFrame(i)),r.push(window.requestAnimationFrame(()=>{r.push(window.requestAnimationFrame(i))})),()=>{for(const s of r)window.cancelAnimationFrame(s)}},nt=({original:n,modified:e,fileDiff:t,language:r,fileName:i,renderSideBySide:s,wrapLines:h,layout:d="fill",enableGutterUtility:c=!1,enableLineSelection:m=!1,onGutterUtilityClick:g,onLineSelectionEnd:y,lineAnnotations:w,renderAnnotation:B})=>{const D=xe(),C=D?.currentTheme.metadata.variant==="dark",_=D?.availableThemes.find(o=>o.metadata.id===D.lightThemeId)??de(!1),F=D?.availableThemes.find(o=>o.metadata.id===D.darkThemeId)??de(!0);ue(_),ue(F);const N=`${_.metadata.id}:${F.metadata.id}:${C?"dark":"light"}`,W=f.useMemo(()=>{if(t){const o=t.deletionLines.reduce((a,u)=>a+u.length,0),l=t.additionLines.reduce((a,u)=>a+u.length,0);return Math.max(o,l)>pe}return Math.max(n.length,e.length)>pe},[t,e.length,n.length]),K=f.useRef(null),A=f.useRef(null),V=f.useRef(null),j=f.useRef(null),ee=f.useRef(null),te=f.useRef(null),re=f.useRef(void 0),Q=f.useRef(void 0),Y=f.useRef(void 0),G=f.useRef(void 0),[,se]=ae.useReducer(o=>o+1,0),$=Ce(W?"unified":s?"split":"unified"),I=f.useRef(new Map),ie=f.useRef(B);ie.current=B;const oe=o=>`${o.side}:${o.lineNumber}`,le=f.useCallback(o=>{if(typeof document>"u")return;const l=`${o.side}:${o.lineNumber}`;let a=I.current.get(l);if(!a){const u=document.createElement("div");u.setAttribute("data-pichamber-line-annotation",l),a={root:Se.createRoot(u),element:u},I.current.set(l,a)}return a.root.render(ie.current?.(o)??null),a.element},[]);f.useEffect(()=>{if(!w){for(const[,a]of I.current)a.root.unmount();I.current.clear();return}const o=new Set(w.map(oe));for(const[a,u]of I.current)o.has(a)||(u.root.unmount(),I.current.delete(a));const l=ie.current;if(l)for(const a of w){const u=I.current.get(oe(a));u&&u.root.render(l(a))}},[w]),f.useEffect(()=>{const o=I.current;return()=>{for(const l of o.values())l.root.unmount();o.clear()}},[]);const x=f.useMemo(()=>he(_),[_]),O=f.useMemo(()=>he(F),[F]);ae.useLayoutEffect(()=>{const o=K.current;if(!o)return;const l=o.querySelector("diffs-container");if(!l)return;const a=C?O:x,u=(we,Re)=>we.colors?.[Re],R=u(x,"terminal.ansiGreen"),v=u(x,"terminal.ansiRed"),b=u(x,"terminal.ansiBlue"),P=u(O,"terminal.ansiGreen"),k=u(O,"terminal.ansiRed"),M=u(O,"terminal.ansiBlue");l.style.setProperty("--shiki-light",x.fg),l.style.setProperty("--shiki-light-bg",x.bg),R&&l.style.setProperty("--shiki-light-addition-color",R),v&&l.style.setProperty("--shiki-light-deletion-color",v),b&&l.style.setProperty("--shiki-light-modified-color",b),l.style.setProperty("--shiki-dark",O.fg),l.style.setProperty("--shiki-dark-bg",O.bg),P&&l.style.setProperty("--shiki-dark-addition-color",P),k&&l.style.setProperty("--shiki-dark-deletion-color",k),M&&l.style.setProperty("--shiki-dark-modified-color",M),l.style.setProperty("--diffs-bg",a.bg),l.style.setProperty("--diffs-fg",a.fg);const S=C?P:R,L=C?k:v,q=C?M:b;S&&l.style.setProperty("--diffs-addition-color-override",S),L&&l.style.setProperty("--diffs-deletion-color-override",L),q&&l.style.setProperty("--diffs-modified-color-override",q);const p=l.shadowRoot?.querySelector("pre");p&&(p.style.setProperty("--shiki-light",x.fg),p.style.setProperty("--shiki-light-bg",x.bg),R&&p.style.setProperty("--shiki-light-addition-color",R),v&&p.style.setProperty("--shiki-light-deletion-color",v),b&&p.style.setProperty("--shiki-light-modified-color",b),p.style.setProperty("--shiki-dark",O.fg),p.style.setProperty("--shiki-dark-bg",O.bg),P&&p.style.setProperty("--shiki-dark-addition-color",P),k&&p.style.setProperty("--shiki-dark-deletion-color",k),M&&p.style.setProperty("--shiki-dark-modified-color",M),p.style.setProperty("--diffs-bg",a.bg),p.style.setProperty("--diffs-fg",a.fg),S&&p.style.setProperty("--diffs-addition-color-override",S),L&&p.style.setProperty("--diffs-deletion-color-override",L),q&&p.style.setProperty("--diffs-modified-color-override",q))},[O,N,C,x]);const H=f.useMemo(()=>({theme:{dark:F.metadata.id,light:_.metadata.id},themeType:C?"dark":"light",diffStyle:s?"split":"unified",diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:W?0:1e3,maxLineLengthForHighlighting:W?1:1e3,tokenizeMaxLineLength:W?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:h?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:m,enableGutterUtility:c,enableHoverUtility:!1,...g?{onGutterUtilityClick:g}:{},...y?{onLineSelectionEnd:y}:{},renderAnnotation:le,unsafeCSS:d==="inline"?`${me}
135
+ ${ze}`:me}),[le,F.metadata.id,c,m,C,W,d,_.metadata.id,g,y,s,h]);return f.useEffect(()=>{const o=A.current;return()=>{V.current?.cleanUp(),V.current=null,j.current?.release(),j.current=null,ee.current=null,te.current=null,re.current=void 0,Q.current=void 0,Y.current=void 0,G.current=void 0,o&&(o.innerHTML="")}},[]),f.useEffect(()=>{if(typeof window>"u")return;const o=A.current,l=K.current;if(!o||!$)return;const a=qe(l,o);let u=j.current;u||(u=je(o),j.current=u),j.current=u;const R=u?.virtualizer??null,v=t?void 0:{name:i||"",contents:n,lang:r,cacheKey:`old:${N}:${i}:${ve(n)}`},b=t?void 0:{name:i||"",contents:e,lang:r,cacheKey:`new:${N}:${i}:${ve(e)}`},P=t?Q.current!==t:Q.current!==void 0||!v||!b||!Y.current||!G.current||!ce(Y.current,v)||!ce(G.current,b),k=V.current,M=!!(k&&(ee.current!==R||te.current!==$||R&&(re.current!==H.hunkSeparators||P)));M&&(k?.cleanUp(),V.current=null,o.innerHTML="");let S=V.current;const L=!M&&k?!Ee(k.options,H):!1;if(S?S.setOptions(H):(S=u?new ke(H,u.virtualizer,Ne,$):new Te(H,$),V.current=S),ee.current=R,te.current=$,re.current=R?H.hunkSeparators:void 0,Q.current=t,Y.current=v,G.current=b,t)S.render({fileDiff:t,forceRender:L,containerWrapper:o,...w?{lineAnnotations:w}:{}});else{if(!v||!b)return;S.render({oldFile:v,newFile:b,forceRender:L,containerWrapper:o,...w?{lineAnnotations:w}:{}})}const q=Be(o,()=>{a(),Ue(S,u,se)});return()=>{q(),a()}},[N,t,i,r,w,e,H,n,$]),f.useEffect(()=>{const o=A.current;if(!o)return;let l=null,a=null;const R=setTimeout(()=>{const v=o.querySelector("diffs-container");if(!(v instanceof HTMLElement))return;const b=v.shadowRoot;l=new MutationObserver(()=>{a&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{se(),a=null})}),l.observe(v,{childList:!0,subtree:!0}),b&&l.observe(b,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(R),a&&cancelAnimationFrame(a),l?.disconnect()}},[N,i]),typeof window>"u"?null:d==="fill"?z.jsx("div",{className:fe("flex flex-col relative","size-full"),"data-diff-virtual-root":!0,children:z.jsx("div",{className:"flex-1 relative min-h-0",children:z.jsx(Oe,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:z.jsx("div",{ref:K,className:"size-full relative",children:z.jsx("div",{ref:A,className:"size-full"})})})})}):z.jsx("div",{className:fe("relative","w-full"),children:z.jsxs("div",{ref:K,className:"pierre-diff-wrapper w-full relative","data-no-drawer-swipe":"true",children:[z.jsx("div",{ref:A,className:"w-full"}),z.jsx(De,{hostRef:A,enabled:!h})]})})};export{nt as P};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useAppFontEffects-Bfw_d5eB.js","assets/index-DWSrsQWl.js","assets/vendor-zustand-CUi8eEds.js","assets/vendor-react-DASdDPIk.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-DsQIBAWK.css","assets/vendor-boot-EC6IyLt1.js","assets/runtimeSurface-Der4qUnI.js","assets/nativeFileSave-CFuugNKV.js"])))=>i.map(i=>d[i]);
2
+ import{_ as Ne}from"./vendor-vite-runtime-DD1OZmLC.js";import{k as e,bV as Ye,bW as Qe,bX as Xe,bY as Ze,bZ as et}from"./vendor-boot-EC6IyLt1.js";import{R as o}from"./vendor-react-DASdDPIk.js";import{u as le,a as Le,b as ht,c as ft,G as xt,d as pt,e as gt,f as bt,r as vt,g as tt,t as yt,h as ce,i as jt,j as wt,k as kt,l as Ct,m as Nt,n as St,o as Rt}from"./useGitHubRemoteSearch-gUdylYy3.js";import{z as Ee,t as H,af as Lt,B as P,I as z,bd as Et,as as st,ai as Me,al as ze,an as Ae,cH as Ft,cI as Pt,o as Se,ap as we,aq as Tt,y as Mt}from"./useAppFontEffects-Bfw_d5eB.js";import{Q as O,_ as zt,$ as At,R as Dt,a0 as $t,a1 as Gt,a2 as Ht,a3 as qt,a4 as It,a5 as De,a6 as Ot,a7 as Bt,a8 as _t,a9 as Ut,aa as Vt,ab as Kt,ac as Jt,ad as Wt}from"./runtimeEndpointReset-BA2uP2rj.js";import{c as Yt,d as Qt,s as Xt,m as Zt,g as nt,e as es,f as ts,h as ge,l as ss,G as ns,i as te,j as as,k as ls,n as os,o as is,b as fe,u as rs,p as cs,q as ds,r as us,t as $e,w as ke,x as Ce,y as ms,z as Ge,A as He,B as qe,C as at,D as hs,E as Ie,F as fs,H as xs,I as ps,J as gs,K as bs,P as be,L as he,M as vs,a as ys,N as Oe,O as js,Q as ws}from"./GitHubDetailScaffold-C9rCZMUT.js";import{e as xe,aL as ks,m as Cs,f as Ns,n as Ss}from"./index-DWSrsQWl.js";import{S as ve,G as Rs}from"./GitHubListPrimitives-DlhAlxI6.js";import{P as Ls}from"./PierreDiffViewer-D1F2WvD0.js";import{c as Es,p as Fs}from"./vendor-zustand-CUi8eEds.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-Der4qUnI.js";import"./nativeFileSave-CFuugNKV.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./SessionUnreadDot-B9bHMy5q.js";/* empty css */import"./permissionStore-B9Hkrqny.js";import"./vendor-dompurify-r8glNMJW.js";import"./web-components-CeHLxvED.js";import"./computeVirtualFileMetrics-BI6wORhM.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-BS-af6rn.js";import"./renderDiffWithHighlighter-BD9CAhZU.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-BMITjK4e.js";import"./appThemeRegistry-gegrE2dq.js";import"./registerCustomTheme-DmolaWWZ.js";const Fe=()=>{const t=Ee(),[s,n]=o.useState(null);return{send:o.useCallback(async l=>{const d=t.github;if(!d)return H.error("GitHub is not available in this runtime"),!1;n(l.key);try{const c=await d.agentContext(l.directory,l.repo,l.contextType,l.number,l.contextOptions),r=Yt({kind:l.kind,repo:l.repo,number:l.number,detail:l.detail}),x=Qt({kind:l.kind,repo:l.repo,number:l.number,contextText:c.text}),p=Lt.getState();p.setPendingInputText(r,"append");const k=p.pendingSyntheticParts??[];return p.setPendingSyntheticParts([...k,{text:x,synthetic:!0}]),H.success("Added to composer"),!0}catch(c){return H.error(c instanceof Error?c.message:"Failed to fetch GitHub context"),!1}finally{n(null)}},[t.github]),sendingKey:s}},Ps=800,Ts=3,Pe={added:{icon:"add-circle",letter:"A",tint:"text-[var(--status-success)]"},removed:{icon:"subtract",letter:"D",tint:"text-[var(--status-error)]"},modified:{icon:"pencil",letter:"M",tint:"text-[var(--status-warning)]"},renamed:{icon:"expand-up-down",letter:"R",tint:"text-[var(--status-info)]"},other:{icon:"file",letter:"•",tint:"text-muted-foreground"}},lt=t=>{switch((t??"").toLowerCase()){case"added":return"added";case"removed":return"removed";case"modified":return"modified";case"renamed":return"renamed";default:return"other"}},ot=t=>Pe[t].icon,Ms=t=>Pe[t].letter,Re=t=>Pe[t].tint,it=t=>{const s=t.lastIndexOf("/");return s<0?{dir:"",base:t}:{dir:t.slice(0,s),base:t.slice(s+1)}},rt=t=>{const s=typeof t.additions=="number"?t.additions:0,n=typeof t.deletions=="number"?t.deletions:0;return s!==0||n!==0?s+n:typeof t.changes=="number"?t.changes:0},ct=t=>rt(t)>Ps,zs=t=>{const s=new Map;for(const a of t){const l=a.filename.lastIndexOf("/"),d=l<0?"":a.filename.slice(0,l),c=s.get(d);c?c.push(a):s.set(d,[a])}const n=[...s.entries()].map(([a,l])=>({folder:a,files:[...l].sort((d,c)=>d.filename.localeCompare(c.filename,void 0,{sensitivity:"base"}))}));return n.sort((a,l)=>a.folder===""?1:l.folder===""?-1:a.folder.localeCompare(l.folder,void 0,{sensitivity:"base"})),n},As=t=>{let s=0,n=0;for(const a of t)s+=typeof a.additions=="number"?a.additions:0,n+=typeof a.deletions=="number"?a.deletions:0;return{additions:s,deletions:n}},Ds=t=>{const s={};return t.forEach((n,a)=>{s[n.filename]=a>=Ts||ct(n)}),s},$s=(t,s,n)=>{if(!s)return null;const a=t.split("/");if(a.length!==3||a.some(r=>r.length===0))return null;const[l,d,c]=a;return`https://${l}/${d}/${c}/blob/${s}/${n}`},Gs=({comment:t,onRemove:s})=>e.jsxs("div",{className:"rounded-md border border-dashed border-border p-2.5 typography-ui text-foreground",contentEditable:!1,onPointerDown:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(z,{name:"chat-1",className:"size-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{children:"Pending — sent when you submit the review"}),e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Discard this comment",title:"Discard this comment",onClick:s,className:"ml-auto size-6",children:e.jsx(z,{name:"delete-bin",className:"size-3.5"})})]}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap break-words",children:t.body})]}),Be=({thread:t,replyAllowed:s,replyDisabledReason:n,resolveAllowed:a,resolveDisabledReason:l,busy:d,onReply:c,onToggleResolved:r})=>{const[x,p]=o.useState(!t.resolved),[k,m]=o.useState(!1),[b,h]=o.useState(""),[A,F]=o.useState(!1),T=t.comments.length,j=async()=>{const g=b.trim();if(!(g.length===0||A||d)){F(!0);try{await c(g)&&(h(""),m(!1))}finally{F(!1)}}};return e.jsxs("div",{className:"rounded-md border border-border/60 bg-[var(--surface-elevated)] p-2.5 typography-ui text-foreground",contentEditable:!1,onPointerDown:g=>g.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(z,{name:t.resolved?"check":"chat-1",className:xe("size-3.5 shrink-0",t.resolved?"text-[var(--status-success)]":""),"aria-hidden":"true"}),e.jsxs("button",{type:"button",className:"hover:text-foreground","aria-expanded":x,onClick:()=>p(g=>!g),children:[t.resolved?"Resolved":"Open"," · ",T," ",T===1?"comment":"comments"]}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"ml-auto",disabled:!a||d,title:l??(t.resolved?"Reopen this conversation":"Resolve this conversation"),"aria-label":t.resolved?"Reopen conversation":"Resolve conversation",onClick:r,children:t.resolved?"Unresolve":"Resolve"})]}),x?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 flex flex-col gap-2",children:t.comments.map((g,i)=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"typography-micro text-muted-foreground",children:g.author?.login??"ghost"}),e.jsx(ns,{markdown:g.body,html:g.bodyHtml??null,fallbackUrl:g.url})]},g.id??`${t.id}-${i}`))}),s?k?e.jsxs("div",{className:"mt-2",children:[e.jsx("textarea",{autoFocus:!0,value:b,rows:2,placeholder:"Reply","aria-label":"Reply to this conversation",disabled:A||d,onChange:g=>h(g.target.value),onKeyDown:g=>{g.nativeEvent.isComposing||(g.key==="Escape"&&(g.preventDefault(),m(!1)),g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&!g.shiftKey&&!g.altKey&&!g.repeat&&(g.preventDefault(),g.stopPropagation(),j()))},className:"min-h-12 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"mt-1.5 flex justify-end gap-1.5",children:[e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>m(!1),children:"Cancel"}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:A||d||b.trim().length===0,onClick:()=>{j()},children:A?"Replying…":"Reply"})]})]}):e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"mt-2",onClick:()=>m(!0),children:"Reply"}):n?e.jsxs("p",{className:"mt-2 typography-micro text-muted-foreground",title:n,children:["Reply unavailable — ",n.charAt(0).toLowerCase()+n.slice(1)]}):null]}):null]})},Hs=({path:t,line:s,sendingToAgent:n,onCancel:a,onAddToReview:l,onSendToAgent:d})=>{const[c,r]=o.useState(""),x=o.useRef(null),p=c.trim();o.useLayoutEffect(()=>{const m=window.requestAnimationFrame(()=>{x.current?.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(m)},[]);const k=()=>{p&&l(p)};return e.jsxs("div",{className:"rounded-md border border-border/60 bg-[var(--surface-elevated)] p-2.5",contentEditable:!1,onPointerDown:m=>m.stopPropagation(),children:[e.jsxs("p",{className:"truncate font-mono typography-micro text-muted-foreground",title:`${t}:${s}`,children:[t,":",s]}),e.jsx("textarea",{ref:x,value:c,rows:3,placeholder:"Add a comment…","aria-label":`Comment on ${t} line ${s}`,onChange:m=>r(m.target.value),onFocus:m=>{const b=m.currentTarget.value.length;m.currentTarget.setSelectionRange(b,b)},onKeyDown:m=>{m.nativeEvent.isComposing||(m.key==="Escape"&&(m.preventDefault(),a()),m.key==="Enter"&&(m.metaKey||m.ctrlKey)&&!m.shiftKey&&!m.altKey&&!m.repeat&&(m.preventDefault(),m.stopPropagation(),k()))},className:"mt-1.5 min-h-16 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"mr-auto typography-micro text-muted-foreground",children:"Ctrl/Cmd+Enter to add"}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:a,children:"Cancel"}),e.jsx(P,{type:"button",variant:"outline",size:"xs",disabled:!p||n,title:"Send this line to the agent",onClick:()=>d(p),children:n?"Sending…":"Send to agent"}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:!p,onClick:k,children:"Add to review"})]})]})},qs=({file:t,collapsed:s,onToggleCollapse:n,viewed:a,onToggleViewed:l,blobUrl:d,threads:c,directory:r,repo:x,number:p,github:k,access:m,onThreadsChanged:b})=>{const h=O(w=>w.threadAction),A=le(w=>w.removeComment),F=le(w=>w.addComment),T=Le(x,p),[j,g]=o.useState(null),[i,C]=o.useState(!1),{send:L,sendingKey:f}=Fe(),{original:N,modified:E}=o.useMemo(()=>Xt(t.patch),[t.patch]),M=o.useMemo(()=>Zt(t.patch),[t.patch]),B=`pr-${p}-file-${t.filename}`,V=nt(m),S=es(m),$=ts(m),K=o.useCallback(w=>{if(!w||!V.allowed)return;const q=(w.endSide??w.side??"additions")==="deletions"?"deletions":"additions",ie=q==="deletions"?M.syntheticToOld.get(w.end):M.syntheticToNew.get(w.end);if(ie==null){H.error("That line is outside the rendered hunks");return}g({synthLine:w.end,side:q,realLine:ie,realSide:q==="deletions"?"LEFT":"RIGHT"})},[V.allowed,M]),_=lt(t.status),{dir:X,base:R}=it(t.filename),I=ct(t),[y,de]=o.useState(!1),Q=I&&!y&&!a&&t.patch!=null,ee=c.filter(w=>!w.resolved).length,Z=o.useMemo(()=>T.filter(w=>w.path===t.filename),[T,t.filename]),{annotations:se,orphans:ne}=o.useMemo(()=>{const w=new Map,G=[],q=(D,U)=>{const W=`${D}:${U}`;let J=w.get(W);return J||(J={side:D,synthLine:U,threads:[],pendings:[]},w.set(W,J)),J};for(const D of c){const U=D.line??D.originalLine??null;if(U==null){G.push(D);continue}let W,J;if(D.diffSide==="LEFT"?(J="deletions",W=M.oldToSynthetic.get(U)):D.diffSide==="RIGHT"?(J="additions",W=M.newToSynthetic.get(U)):(W=M.newToSynthetic.get(U),J="additions",W==null&&(W=M.oldToSynthetic.get(U),J="deletions")),W==null){G.push(D);continue}q(J,W).threads.push(D)}for(const D of Z){if(D.line==null)continue;const U=D.side==="LEFT"?"deletions":"additions",W=U==="deletions"?M.oldToSynthetic.get(D.line):M.newToSynthetic.get(D.line);W!=null&&q(U,W).pendings.push(D)}return j&&q(j.side,j.synthLine),{annotations:[...w.values()].sort((D,U)=>D.synthLine-U.synthLine).map(D=>({side:D.side,lineNumber:D.synthLine,metadata:{threads:D.threads,pendings:D.pendings,draft:j&&j.side===D.side&&j.synthLine===D.synthLine?{realLine:j.realLine,realSide:j.realSide}:null}})),orphans:G}},[c,Z,j,M]),oe=o.useCallback(async(w,G)=>{const q=w.comments[w.comments.length-1]?.id??null;if(typeof q!="number")return H.error("Cannot reply to this thread yet"),!1;if(i)return!1;C(!0);try{return(await h(r,x,p,w.id,{action:"reply",body:G,commentId:q},k)).ok?(H.success("Reply posted"),b(),!0):(H.error("Failed to post reply"),!1)}finally{C(!1)}},[r,x,p,k,h,i,b]),ae=o.useCallback(w=>{i||(C(!0),h(r,x,p,w.id,w.resolved?{action:"unresolve"}:{action:"resolve"},k).then(G=>{G.ok?(H.success(w.resolved?"Thread reopened":"Thread resolved"),b()):H.error("Failed to update thread")}).finally(()=>C(!1)))},[r,x,p,k,h,i,b]),ue=o.useCallback(w=>e.jsxs("div",{className:"flex flex-col gap-1.5 px-3 py-2",contentEditable:!1,onPointerDown:G=>G.stopPropagation(),children:[w.metadata.threads.map(G=>e.jsx(Be,{thread:G,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:$.allowed,resolveDisabledReason:$.reason,busy:i,onReply:q=>oe(G,q),onToggleResolved:()=>ae(G)},G.id)),w.metadata.pendings.map(G=>e.jsx(Gs,{comment:G,onRemove:()=>A(x,p,G.id)},G.id)),w.metadata.draft?e.jsx(Hs,{path:t.filename,line:w.metadata.draft.realLine,sendingToAgent:f===`${B}-draft-agent`,onCancel:()=>g(null),onAddToReview:G=>{const q=w.metadata.draft;q&&(F(x,p,{path:t.filename,body:G,line:q.realLine,side:q.realSide}),g(null),H.success("Added to review"))},onSendToAgent:G=>{const q=w.metadata.draft;q&&L({key:`${B}-draft-agent`,kind:"lines",directory:r,repo:x,number:p,contextType:"pr",contextOptions:{includeDiff:!0},detail:`${t.filename} line ${q.realLine} ("${G.trim()}")`})}}):null]}),[S.allowed,S.reason,$.allowed,$.reason,i,oe,ae,A,F,x,p,t.filename,B,f,r,L]);return e.jsxs("article",{className:"overflow-hidden rounded-md border border-border/60",children:[e.jsxs("div",{className:"sticky top-8 z-[5] flex items-center gap-1.5 bg-[var(--surface-muted)] px-2 py-1.5",children:[e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:()=>n(t.filename),"aria-label":s?`Expand ${t.filename}`:`Collapse ${t.filename}`,title:s?"Expand":"Collapse",className:"size-6",children:e.jsx(z,{name:s?"arrow-right-s":"arrow-down-s",className:"size-4"})}),e.jsx(z,{name:ot(_),className:xe("size-3.5 shrink-0",Re(_)),"aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono typography-micro",title:t.filename,children:[X?e.jsxs("span",{className:"text-muted-foreground",children:[X,"/"]}):null,e.jsx("span",{className:"text-foreground",children:R})]}),_!=="other"?e.jsx("span",{className:xe("shrink-0 rounded px-1 font-mono typography-micro",Re(_)),title:t.status??void 0,children:Ms(_)}):null,e.jsx(ge,{additions:t.additions,deletions:t.deletions,className:"typography-micro"}),c.length>0||Z.length>0?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-muted-foreground",title:`${c.length} ${c.length===1?"conversation":"conversations"}${Z.length>0?`, ${Z.length} pending`:""}`,children:[e.jsx(z,{name:"chat-1",className:"size-3.5","aria-hidden":"true"}),c.length>0?e.jsx("span",{className:"tabular-nums",children:ee>0?ee:c.length}):null,Z.length>0?e.jsxs("span",{className:"tabular-nums",children:["+",Z.length]}):null]}):null,e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",onClick:w=>w.stopPropagation(),children:[e.jsx(Et,{checked:a,onChange:w=>l(t.filename,w),ariaLabel:a?`Mark ${t.filename} as not viewed`:`Mark ${t.filename} as viewed`}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Viewed"})]}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{L({key:`${B}-agent`,kind:"file",directory:r,repo:x,number:p,contextType:"pr",contextOptions:{includeDiff:!0},detail:t.filename})},disabled:f===`${B}-agent`,"aria-label":`Send ${t.filename} to agent`,children:"Send to agent"})]}),s?null:e.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[ne.length>0?e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md bg-[var(--surface-muted)] px-2 py-2",children:[e.jsxs("p",{className:"typography-micro text-muted-foreground",children:["Other conversations (",ne.length,") — ",ne.length===1?"this line is":"these lines are"," no longer in the diff"]}),ne.map(w=>e.jsx(Be,{thread:w,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:$.allowed,resolveDisabledReason:$.reason,busy:i,onReply:G=>oe(w,G),onToggleResolved:()=>ae(w)},w.id))]}):null,Q?e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-[var(--surface-muted)] px-3 py-3 typography-ui",children:[e.jsx(z,{name:"file",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsxs("p",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:["Large diff — ",rt(t)," changed lines"]}),e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>de(!0),children:"Load diff"})]}):t.patch?e.jsx("div",{className:"min-h-24 overflow-hidden",children:e.jsx(Ls,{original:N,modified:E,language:ss(t.filename),fileName:t.filename,renderSideBySide:!1,layout:"inline",enableGutterUtility:V.allowed&&j===null,enableLineSelection:V.allowed&&j===null,onGutterUtilityClick:K,onLineSelectionEnd:K,lineAnnotations:se,renderAnnotation:w=>ue(w)})}):e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-[var(--surface-muted)] px-3 py-3 typography-ui",children:[e.jsx(z,{name:"file",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("p",{className:"min-w-0 flex-1 text-muted-foreground",children:"Diff not available for this file."}),d?e.jsx(P,{type:"button",variant:"link",size:"sm",asChild:!0,children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",children:"Open on GitHub"})}):null]})]})]})},Is=o.memo(qs),Os=({directory:t,repo:s,number:n,github:a,pr:l,access:d,onCommented:c})=>{const r=O(i=>i.addComment),x=O(i=>i.performAction),p=le(i=>i.clearCommentDraft),{draft:k,onDraftChange:m,flushDraft:b}=ht(s,n),{busy:h,error:A,submit:F}=ft({postComment:i=>r(t,s,n,i,a),runFollowUp:i=>x(t,s,n,i,a),verbs:{close:"close",reopen:"reopen"},doneLabels:{close:"Closed with comment",reopen:"Reopened with comment"},afterPost:()=>{m(""),p(s,n),c()}}),T=nt(d),j=l.state==="open"?"close":l.state==="closed"?"reopen":null,g=j?te(j,l,d):null;return T.allowed?e.jsx(xt,{draft:k,onDraftChange:m,onDraftBlur:b,ariaLabel:"Leave a comment on this pull request",busy:h,error:A,disabledReason:T.reason,followUp:j?{id:j,label:j==="close"?"Close with comment":"Reopen with comment",busyLabel:j==="close"?"Closing…":"Reopening…",onRun:()=>{F(j,k)},allowed:g?.allowed===!0,reason:g?.reason}:null,onSubmitComment:()=>{F("comment",k)}}):null},Bs={comment:"Comment",approve:"Approve","request-changes":"Request changes"},_s=({repo:t,number:s,verdicts:n,summary:a,verdict:l,pendingCount:d,busy:c,textareaRef:r,onSubmit:x})=>{const p=le(h=>h.setSummary),k=le(h=>h.setVerdict),m=n.includes(l)?l:n[0]??"comment",b=ls({verdict:m,summary:a,pendingCount:d});return e.jsxs("div",{children:[e.jsx(zt,{ref:r,rows:3,value:a,placeholder:"Summarize your review (optional)","aria-label":"Review summary",disabled:c,onChange:h=>p(t,s,h.target.value),onKeyDown:h=>{h.nativeEvent.isComposing||h.key==="Enter"&&(h.metaKey||h.ctrlKey)&&!h.shiftKey&&!h.altKey&&!h.repeat&&(h.preventDefault(),h.stopPropagation(),b&&!c&&x())}}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsxs("label",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"sr-only",children:"Review verdict"}),e.jsx("select",{value:m,disabled:c,onChange:h=>k(t,s,h.target.value),"aria-label":"Review verdict",className:"h-7 max-w-40 truncate rounded-md border border-border bg-[var(--surface-elevated)] px-1.5 typography-micro text-foreground",children:n.map(h=>e.jsx("option",{value:h,children:Bs[h]},h))})]}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:c||!b,title:b?`Submit review${d>0?` with ${d} ${d===1?"line comment":"line comments"}`:""}`:"Add a summary or a line comment first",onClick:x,children:c?"Submitting…":"Submit review"})]})]})},dt=({directory:t,repo:s,number:n,github:a,access:l,size:d="sm",onReviewSubmitted:c})=>{const r=O(M=>M.submitReview),x=le(M=>M.removeComments),p=le(M=>M.clearSummary),k=le(M=>M.clearComments),m=Le(s,n),b=pt(s,n),h=gt(s,n),[A,F]=o.useState(!1),[T,j]=o.useState(!1),g=o.useRef(null),i=o.useMemo(()=>as(l),[l]),C=i.includes(h)?h:i[0]??"comment",L=m.length,f=L>0||b.trim().length>0;if(o.useEffect(()=>{if(!A)return;const M=window.requestAnimationFrame(()=>g.current?.focus({preventScroll:!0}));return()=>window.cancelAnimationFrame(M)},[A]),i.length===0)return null;const N=async()=>{if(T)return;const M=b,B=[...m];j(!0);try{const V=B.map($=>({path:$.path,body:$.body,...$.line!=null?{line:$.line}:{},...$.side?{side:$.side}:{}})),S=await r(t,s,n,{event:C,body:M.trim()?M:void 0,comments:V},a);if(!S.ok){H.error(S.error?.kind==="failed"?S.error.message:"Failed to submit review");return}x(s,n,B.map($=>$.id)),p(s,n,M),H.success(C==="approve"?"Pull request approved":C==="request-changes"?"Changes requested":"Review submitted"),F(!1),c?.()}finally{j(!1)}},E=L>0?`Review · ${L}`:"Review";return e.jsxs(Ye,{open:A,onOpenChange:F,children:[e.jsxs(Qe,{render:e.jsx(P,{type:"button",variant:L>0?"default":"outline",size:d,className:"shrink-0","aria-label":L>0?`Review pull request, ${L} ${L===1?"line comment":"line comments"} pending`:"Review pull request",title:f?"Finish your review":"Approve, request changes, or comment with a review"}),children:[e.jsx(z,{name:"file-check",className:"size-3.5","aria-hidden":"true"}),E]}),e.jsx(Xe,{children:e.jsx(Ze,{className:"z-50",side:"top",align:"end",sideOffset:8,collisionPadding:8,children:e.jsxs(et,{"aria-label":"Review pull request",className:"w-[min(24rem,calc(100vw-2rem))] rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3 shadow-lg",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 truncate typography-ui-label text-foreground",children:L>0?`Review · ${L} ${L===1?"line comment":"line comments"}`:"Review pull request"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[L>0?e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Discard pending line comments",title:"Discard pending line comments",disabled:T,onClick:()=>k(s,n),className:"size-6",children:e.jsx(z,{name:"delete-bin",className:"size-3.5"})}):null,e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Close review",onClick:()=>F(!1),className:"size-6",children:e.jsx(z,{name:"close",className:"size-3.5"})})]})]}),e.jsx(_s,{repo:s,number:n,verdicts:i,summary:b,verdict:C,pendingCount:L,busy:T,textareaRef:g,onSubmit:()=>{N()}})]})})})]})},ye=(t,s)=>`${t}#${s}`,_e=50,Us=Object.freeze([]),Ue=(t,s)=>{const n=Object.keys(t);if(n.length<=_e)return t;const a={};for(const l of n.slice(n.length-_e))a[l]=t[l];if(!(s in a)&&s in t){const l=Object.keys(a)[0];delete a[l],a[s]=t[s]}return a},pe=Es()(Fs((t,s)=>({entries:{},setViewed:(n,a,l,d)=>{const c=ye(n,a);(s().entries[c]?.viewed.includes(l)??!1)!==d&&t(p=>{const k=p.entries[c]??{viewed:[],headSha:null},m=d?[...k.viewed,l]:k.viewed.filter(b=>b!==l);return{entries:Ue({...p.entries,[c]:{...k,viewed:m}},c)}})},syncHeadSha:(n,a,l)=>{const d=ye(n,a),c=s().entries[d];c&&c.headSha===(l??null)||t(r=>({entries:Ue({...r.entries,[d]:{viewed:[],headSha:l??null}},d)}))},resetForRuntimeSwitch:()=>t({entries:{}})}),{name:"pichamber:github-viewed-files",version:1,storage:ks(),partialize:t=>({entries:t.entries})}));typeof window<"u"&&Cs(()=>{pe.getState().resetForRuntimeSwitch()});const Vs=(t,s)=>pe(n=>n.entries[ye(t,s)]?.viewed??Us),Ks=(t,s)=>pe(n=>n.entries[ye(t,s)]?.viewed.length??0),Ve=20,Js=[],Ws=[],Ke=t=>`pr-file-${encodeURIComponent(t)}`,ut=o.memo(({file:t,viewed:s,threadCount:n,pendingCount:a,showDir:l,onSelectFile:d})=>{const c=lt(t.status),{dir:r,base:x}=it(t.filename);return e.jsxs("button",{type:"button",onClick:()=>d(t.filename),title:t.filename,"aria-label":`Go to ${t.filename}`,className:"flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-left hover:bg-interactive-hover",children:[e.jsx(z,{name:ot(c),className:xe("size-3.5 shrink-0",Re(c)),"aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono typography-micro",children:[l&&r?e.jsxs("span",{className:"text-muted-foreground",children:[r,"/"]}):null,e.jsx("span",{className:"text-foreground",children:x})]}),e.jsx(ge,{additions:t.additions,deletions:t.deletions,className:"typography-micro"}),n>0?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 typography-micro text-muted-foreground",title:`${n} ${n===1?"conversation":"conversations"}`,children:[e.jsx(z,{name:"chat-1",className:"size-3","aria-hidden":"true"}),e.jsx("span",{className:"tabular-nums",children:n})]}):null,a>0?e.jsxs("span",{className:"shrink-0 tabular-nums typography-micro text-muted-foreground",title:`${a} pending`,children:["+",a]}):null,s?e.jsx(z,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]","aria-label":"Viewed"}):null]})});ut.displayName="FileJumpRow";const mt=({files:t,viewedPaths:s,threadCounts:n,pendingCounts:a,onSelectFile:l})=>{const[d,c]=o.useState(""),r=o.useMemo(()=>zs(t),[t]),x=o.useMemo(()=>new Set(s),[s]),p=d.trim().toLowerCase(),k=o.useMemo(()=>p?r.map(m=>({...m,files:m.files.filter(b=>b.filename.toLowerCase().includes(p))})).filter(m=>m.files.length>0):r,[r,p]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-1",children:[e.jsx(st,{value:d,onChange:m=>c(m.target.value),placeholder:"Filter files","aria-label":"Filter files",className:"h-7 shrink-0 typography-micro"}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",role:"list","aria-label":"Changed files",children:k.length===0?e.jsx("p",{className:"px-1.5 py-2 typography-micro text-muted-foreground",children:t.length===0?"No changed files":"No files match"}):k.map(m=>e.jsxs("div",{role:"group","aria-label":m.folder||"Repository root",children:[r.length>1?e.jsx("p",{className:"truncate px-1.5 pt-1.5 pb-0.5 typography-micro text-muted-foreground",title:m.folder||"/",children:m.folder||"/"}):null,m.files.map(b=>e.jsx(ut,{file:b,viewed:x.has(b.filename),threadCount:n.get(b.filename)??0,pendingCount:a.get(b.filename)??0,showDir:r.length<=1,onSelectFile:l},b.filename))]},m.folder))})]})},Ys=t=>{const[s,n]=o.useState(!1),{onSelectFile:a}=t,l=o.useCallback(d=>{n(!1),a(d)},[a]);return e.jsxs(Ye,{open:s,onOpenChange:n,children:[e.jsxs(Qe,{render:e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0","aria-label":`Jump to file, ${t.files.length} ${t.files.length===1?"file":"files"}`,title:"Jump to file"}),children:[e.jsx(z,{name:"file",className:"size-3.5","aria-hidden":"true"}),"Files"]}),e.jsx(Xe,{children:e.jsx(Ze,{className:"z-50",side:"bottom",align:"start",sideOffset:4,collisionPadding:8,children:e.jsx(et,{"aria-label":"Jump to file",className:"flex max-h-[min(28rem,calc(100dvh-4rem))] w-[min(22rem,calc(100vw-2rem))] flex-col rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-1.5 shadow-lg",children:e.jsx(mt,{...t,onSelectFile:l})})})})]})},Qs=48,Xs=(t,s)=>{const[n,a]=o.useState(null);return o.useLayoutEffect(()=>{if(!s)return;const l=t.current?.closest("[data-diff-virtual-root]");if(!(l instanceof HTMLElement))return;const d=()=>{const r=Math.max(160,Math.floor(l.clientHeight-Qs));a(x=>x===r?x:r)};if(d(),typeof ResizeObserver>"u")return;const c=new ResizeObserver(d);return c.observe(l),()=>c.disconnect()},[t,s]),n},Zs=t=>{const{directory:s,repo:n,number:a,github:l,access:d,headSha:c=null}=t,r=t.files?.files??Js,x=Vs(n,a),p=Ks(n,a),k=Le(n,a);o.useEffect(()=>{pe.getState().syncHeadSha(n,a,c)},[n,a,c]);const m=o.useMemo(()=>Ds(r),[r]),b=o.useRef(m);b.current=m;const h=o.useRef(r);h.current=r;const[A,F]=o.useState({}),[T,j]=o.useState(Ve),g=o.useMemo(()=>As(r),[r]),i=o.useMemo(()=>{const R=new Map;for(const I of t.threads){if(!I.path)continue;const y=R.get(I.path)??[];y.push(I),R.set(I.path,y)}return R},[t.threads]),C=o.useMemo(()=>{const R=new Map;for(const[I,y]of i)R.set(I,y.length);return R},[i]),L=o.useMemo(()=>{const R=new Map;for(const I of k)R.set(I.path,(R.get(I.path)??0)+1);return R},[k]),f=o.useCallback(R=>{F(I=>({...I,[R]:!(I[R]??b.current[R]??!1)}))},[]),N=o.useCallback(()=>{F(Object.fromEntries(h.current.map(R=>[R.filename,!1])))},[]),E=o.useCallback(()=>{F(Object.fromEntries(h.current.map(R=>[R.filename,!0])))},[]),M=o.useCallback((R,I)=>{pe.getState().setViewed(n,a,R,I),F(y=>({...y,[R]:I}))},[n,a]),B=o.useCallback(R=>{F(y=>y[R]??b.current[R]??!1?{...y,[R]:!1}:y);const I=h.current.findIndex(y=>y.filename===R);I>=0&&j(y=>I<y?y:I+1),requestAnimationFrame(()=>{document.getElementById(Ke(R))?.scrollIntoView({block:"start"})})},[]),V=o.useMemo(()=>r.slice(0,T),[r,T]),S=o.useRef(null),$=Xs(S,V.length>0),K=o.useMemo(()=>new Set(x),[x]),_=r.length===1?"1 file":`${r.length} files`,X=r.length===0?"Nothing viewed yet":`${p}/${r.length} viewed`;return e.jsxs("section",{"aria-label":"Changed files",className:"@container flex flex-col gap-2","data-diff-virtual-content":!0,children:[e.jsx(ve,{error:t.filesError,onRetry:t.onRetryFiles,label:"Changed files"}),e.jsx(ve,{error:t.threadsError,onRetry:t.onRetryDetail,label:"Review threads"}),e.jsxs("div",{className:"sticky top-0 z-10 flex h-8 shrink-0 items-center gap-2 border-b border-border/60 bg-[var(--surface-background)] px-1 text-[12px]",children:[e.jsx("span",{className:"shrink-0 text-muted-foreground",children:_}),e.jsx(ge,{additions:g.additions,deletions:g.deletions}),e.jsxs("span",{className:"shrink-0 tabular-nums text-muted-foreground","aria-label":X,children:[p,"/",r.length," viewed"]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[e.jsx(dt,{directory:s,repo:n,number:a,github:l,access:d,size:"xs",onReviewSubmitted:t.onReviewSubmitted}),e.jsx("span",{className:"@4xl:hidden",children:e.jsx(Ys,{files:r,viewedPaths:x,threadCounts:C,pendingCounts:L,onSelectFile:B})}),e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:N,"aria-label":"Expand all files",title:"Expand all files",className:"size-7",children:e.jsx(z,{name:"expand-up-down",className:"size-3.5"})}),e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:E,"aria-label":"Collapse all files",title:"Collapse all files",className:"size-7",children:e.jsx(z,{name:"collapse-vertical",className:"size-3.5"})})]})]}),t.filesLoading&&V.length===0?e.jsx(Rs,{rows:5,label:"Loading changed files"}):null,!t.filesLoading&&V.length===0?e.jsx("p",{className:"px-1 py-4 typography-micro text-muted-foreground",children:"No changed files"}):null,V.length>0?e.jsxs("div",{className:"flex min-h-0 items-start gap-3",children:[e.jsx("aside",{ref:S,"aria-label":"Changed files",style:$!=null?{height:$}:void 0,className:"sticky top-10 hidden max-h-[calc(100dvh-10rem)] w-60 shrink-0 flex-col @4xl:flex",children:e.jsx(mt,{files:r,viewedPaths:x,threadCounts:C,pendingCounts:L,onSelectFile:B})}),e.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:V.map(R=>e.jsx("div",{id:Ke(R.filename),className:"scroll-mt-12",children:e.jsx(Is,{file:R,collapsed:A[R.filename]??m[R.filename]??!1,onToggleCollapse:f,viewed:K.has(R.filename),onToggleViewed:M,blobUrl:$s(n,c,R.filename),threads:i.get(R.filename)??Ws,directory:s,repo:n,number:a,github:l,access:d,onThreadsChanged:t.onRetryDetail})},R.filename))})]}):null,r.length>T?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>j(T+Ve),children:"Show more files"})}):null,t.filesHasMore?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:t.onLoadMoreFiles,children:"Load more files"})}):null]})},en=({directory:t,repo:s,number:n,github:a,checks:l,checksError:d,checksLoading:c,onRetryChecks:r,onOpenFilesAtLine:x})=>{const[p,k]=o.useState({}),[m,b]=o.useState({}),{send:h,sendingKey:A}=Fe(),F=os(l);return e.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-1 py-1",children:[e.jsx("p",{className:"min-w-0 flex-1 typography-micro text-muted-foreground","aria-live":"polite",children:F?F.text:c?"Loading checks…":"No checks reported for this pull request."}),F&&F.failed>0?e.jsxs(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{h({key:`pr-${n}-failed-checks`,kind:"checks",directory:t,repo:s,number:n,contextType:"checks"})},disabled:A===`pr-${n}-failed-checks`,"aria-label":"Send failed checks to agent",title:"Send failed checks to agent",children:[e.jsx(z,{name:"send-plane-2",className:"size-3.5"}),"Send failures to agent"]}):null,e.jsxs(P,{type:"button",variant:"ghost",size:"xs",onClick:r,"aria-label":"Refresh checks",title:"Refresh checks",children:[e.jsx(z,{name:"refresh",className:xe("size-3.5",c&&"animate-spin")}),"Refresh"]})]}),e.jsx(ve,{error:d,onRetry:r,label:"Checks"}),l?e.jsx(tn,{checks:l,directory:t,repo:s,number:n,github:a,expandedJobs:p,onToggleJob:T=>k(j=>({...j,[T]:!j[T]})),jobSteps:m,setJobSteps:b,sendingKey:A,send:h,onOpenFilesAtLine:x}):null]})},tn=({checks:t,directory:s,repo:n,number:a,github:l,expandedJobs:d,onToggleJob:c,jobSteps:r,setJobSteps:x,sendingKey:p,send:k,onOpenFilesAtLine:m})=>{const b=O(i=>i.rerunFailedChecks),[h,A]=o.useState({}),F=async i=>{const C=`run-${i.id??i.name}`;if(c(C),!(d[C]||r[C]||i.id==null)){x(L=>({...L,[C]:{steps:[],loading:!0}}));try{const f=(await l.checkJobs(s,n,i.runId??null,i.id)).jobs[0];x(E=>({...E,[C]:{steps:f?.steps??[],loading:!1}}));const N=await l.checkAnnotations(s,n,i.id).catch(()=>null);N&&A(E=>({...E,[i.id]:{loading:!1,items:N.annotations}}))}catch{x(L=>({...L,[C]:{steps:[],loading:!1}}))}}},T=async i=>{(await b(s,n,i,l)).ok?H.success("Re-run requested"):H.error("Re-run failed")},j=i=>{const C=`run-${i.id??i.name}`,L=d[C]??!1,f=r[C],N=is(i);return e.jsxs("div",{className:"rounded-md px-2 py-2 hover:bg-interactive-hover",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(fe,{state:i.conclusion??i.status}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui text-foreground",title:i.name,children:i.name}),i.conclusion?e.jsx("span",{className:"typography-micro text-muted-foreground",children:i.conclusion}):null,e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{F(i)},"aria-expanded":L,"aria-label":`${L?"Collapse":"Expand"} ${i.name}`,children:"Details"}),N&&i.runId!=null?e.jsx(P,{type:"button",variant:"outline",size:"xs",onClick:()=>{T(i.runId)},children:"Re-run"}):null,N?e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{k({key:`${C}-agent`,kind:"check",directory:s,repo:n,number:a,contextType:"checks",detail:i.name})},disabled:p===`${C}-agent`,"aria-label":`Send ${i.name} to agent`,children:"Send to agent"}):null]}),L?e.jsxs("div",{className:"mt-1.5 flex flex-col gap-1 border-t border-border/60 pt-1.5",children:[f?.loading?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Loading steps…"}):null,(f?.steps??[]).map((E,M)=>e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(fe,{state:E.conclusion??E.status}),e.jsx("span",{className:"truncate",children:E.name}),E.conclusion?e.jsxs("span",{children:["· ",E.conclusion]}):null]},`${E.name}-${M}`)),i.id!=null&&h[i.id]?.items?.length?e.jsx("div",{className:"flex flex-col gap-1",children:h[i.id]?.items.map((E,M)=>e.jsxs("div",{className:"typography-micro text-muted-foreground",children:[E.path&&E.startLine&&m?e.jsxs("button",{type:"button",className:"font-mono underline",onClick:()=>m(E.path,E.startLine),children:[E.path,":",E.startLine]}):e.jsxs("span",{className:"font-mono",children:[E.path,E.startLine?`:${E.startLine}`:""]})," ",E.title?e.jsxs("span",{className:"text-foreground",children:[E.title," — "]}):null,E.message]},M))}):null]}):null]},C)},g=(i,C)=>e.jsxs("div",{className:"flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-interactive-hover",children:[e.jsx(fe,{state:i.state}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui text-foreground",title:i.context,children:i.context}),i.description?e.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:i.description}):null]},`${i.context}-${C}`);return e.jsxs("div",{className:"flex flex-col gap-1",children:[t.sectionErrors?.runs||t.sectionErrors?.statuses?e.jsx("div",{className:"rounded-md border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-2 py-1 typography-micro text-foreground",role:"alert",children:"Some check sources failed to load; counts below are partial, not empty."}):null,t.runs.length>0?e.jsx("div",{className:"flex flex-col","aria-label":"Check runs",children:t.runs.map(j)}):null,t.statuses.length>0?e.jsx("div",{className:"flex flex-col","aria-label":"Commit statuses",children:t.statuses.map(g)}):null,t.runs.length===0&&t.statuses.length===0?e.jsx("p",{className:"typography-ui text-muted-foreground",children:"No checks reported for this pull request."}):null]})},Je=({pr:t})=>e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(at,{login:t.author?.login,avatarUrl:t.author?.avatarUrl,size:"xs"}),t.author?.login??"ghost"]}),t.updatedAt?` · updated ${bs(t.updatedAt)}`:"",t.draft?" · Draft":""]}),We=({pr:t,filesCount:s})=>e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"shrink-0 truncate",title:t.base,children:t.base}),e.jsx("span",{className:"shrink-0","aria-label":"receives changes from",children:"←"}),e.jsx("code",{className:"min-w-0 flex-1 truncate",title:t.head,children:t.head}),typeof s=="number"?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 tabular-nums",children:[e.jsx(z,{name:"file-code",className:"size-3 shrink-0","aria-hidden":"true"}),s," ",s===1?"file":"files"]}):null,e.jsx(ge,{additions:t.additions,deletions:t.deletions})]}),sn=({repo:t,pr:s,access:n,acting:a,mergeMethod:l,onMergeMethodChange:d,onRun:c,checkingOut:r,onCheckout:x,onCopyLink:p,askSending:k,onAskAgent:m})=>{const b=O(N=>N.setMergeMethod),h=s.state==="open",A=be.filter(N=>te(N.id,s,n).allowed),F=A.some(N=>N.id===l)?l:A[0]?.id??l,T=te(F,s,n),j=te("ready",s,n),g=te("draft",s,n),i=te("close",s,n),C=te("reopen",s,n),L=be.find(N=>N.id===F)??be[0],f=A.length===0||a;return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pt-1 pb-2","aria-label":"Pull request actions",children:[h&&!s.draft?e.jsxs("span",{role:"group","aria-label":"Merge pull request",className:"inline-flex shrink-0 items-center gap-1",children:[e.jsx(ce,{copy:he(F,s.base,s.head),busy:a,disabled:!T.allowed,disabledReason:T.reason??`Merge via ${L.label}`,label:F==="merge"?"Merge pull request":L.label,icon:e.jsx(z,{name:"git-merge",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c(F)}),e.jsxs(Me,{modal:!1,children:[e.jsx(ze,{asChild:!0,children:e.jsx(P,{type:"button",variant:"default",size:"xs",className:"shrink-0 px-1.5",title:"Merge options","aria-label":"Merge options",disabled:f,children:e.jsx(z,{name:"arrow-down-s",className:"size-3.5"})})}),e.jsx(Ae,{align:"start",className:"w-72",children:e.jsx(Ft,{value:F,onValueChange:N=>{const E=N;d(E),b(t,E)},children:be.map(N=>{const E=te(N.id,s,n);return e.jsx(Pt,{value:N.id,disabled:!E.allowed,title:E.reason??N.description,children:e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"truncate",children:N.label}),e.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:N.description})]})},N.id)})})})]})]}):null,h&&s.draft?e.jsx(ce,{copy:he("ready",s.base,s.head),busy:a,disabled:!j.allowed,disabledReason:j.reason??"Ready for review",label:"Ready for review",icon:e.jsx(z,{name:"git-pull-request",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("ready")}):null,h&&!s.draft?e.jsx(ce,{copy:he("draft",s.base,s.head),busy:a,variant:"outline",disabled:!g.allowed,disabledReason:g.reason??"Convert to draft",label:"Convert to draft",icon:e.jsx(z,{name:"pencil",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("draft")}):null,h?e.jsx(ce,{copy:he("close",s.base,s.head),busy:a,destructive:!0,variant:"outline",disabled:!i.allowed,disabledReason:i.reason??"Close pull request",label:"Close",icon:e.jsx(z,{name:"close",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("close")}):e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>c("reopen"),disabled:!C.allowed||a,title:C.reason??"Reopen pull request","aria-label":"Reopen pull request",children:[e.jsx(z,{name:"history",className:"size-3.5","aria-hidden":"true"}),"Reopen"]}),e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>x("worktree"),disabled:r,title:"Check out in a new worktree","aria-label":"Check out in a new worktree",children:[e.jsx(z,{name:"git-branch",className:"size-3.5","aria-hidden":"true"}),r?"Checking out…":"Check out"]}),e.jsx(ce,{copy:{title:"Check out this branch here?",detail:"This switches your current checkout to the PR branch. Uncommitted work may be disrupted.",confirm:"Check out here",progress:"Checking out…"},busy:r,variant:"outline",label:"Check out here",icon:e.jsx(z,{name:"git-branch",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>x("current")}),e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:m,disabled:k,title:"Send pull request context to the agent composer","aria-label":"Ask agent about this pull request",children:[e.jsx(z,{name:"send-plane-2",className:"size-3.5","aria-hidden":"true"}),k?"Asking…":"Ask agent"]}),e.jsxs(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{Se(s.url)},title:"Review on GitHub","aria-label":"Review on GitHub",children:[e.jsx(z,{name:"external-link",className:"size-3.5","aria-hidden":"true"}),"Review on GitHub"]}),e.jsxs(Me,{modal:!1,children:[e.jsx(ze,{asChild:!0,children:e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 px-1.5","aria-label":"More pull request actions",title:"More pull request actions",children:e.jsx(z,{name:"more-2",className:"size-4"})})}),e.jsxs(Ae,{align:"end",className:"w-60",children:[e.jsxs(we,{onClick:()=>{Se(s.url)},children:[e.jsx(z,{name:"external-link",className:"size-3.5"}),"Open on GitHub"]}),e.jsxs(we,{onClick:p,children:[e.jsx(z,{name:"file-copy",className:"size-3.5"}),"Copy link"]}),e.jsx(Tt,{}),e.jsxs(we,{onClick:()=>x("worktree"),disabled:r,children:[e.jsx(z,{name:"git-branch",className:"size-3.5"}),"Check out in new worktree"]})]})]})]})},nn=({pr:t,access:s,acting:n,onRun:a})=>{const l=vs(t);if(!l)return null;const d=te("update-branch",t,s),c=l.tone==="error"?"border-[var(--status-error-border)] bg-[var(--status-error-background)] text-foreground":"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-foreground",r=l.tone==="error"?"text-[var(--status-error)]":"text-[var(--status-warning)]";return e.jsxs("div",{className:`mx-3 mb-2 flex flex-wrap items-center gap-x-2 gap-y-1.5 rounded-md border px-2.5 py-2 ${c}`,role:"status",children:[e.jsx(z,{name:l.icon,className:`size-4 shrink-0 ${r}`,"aria-hidden":"true"}),e.jsxs("p",{className:"min-w-0 flex-1 basis-48",children:[e.jsxs("span",{className:"typography-ui-label font-medium",children:[l.title," ",e.jsx("code",{className:"font-mono",children:t.base})]}),e.jsx("span",{className:"block typography-micro text-muted-foreground",children:l.detail})]}),l.canUpdate?e.jsx(ce,{copy:he("update-branch",t.base,t.head),busy:n,variant:"outline",disabled:!d.allowed,disabledReason:d.reason??"Update branch",label:"Update branch",icon:e.jsx(z,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>a("update-branch")}):e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{Se(t.url)},title:"Resolve conflicts on GitHub","aria-label":"Resolve conflicts on GitHub",children:[e.jsx(z,{name:"external-link",className:"size-3.5","aria-hidden":"true"}),"Resolve on GitHub"]})]})},an=t=>{const{directory:s,repo:n,number:a,github:l,detail:d}=t,c=O(u=>u.performAction),r=O(u=>u.updateTitleBody),x=O(u=>u.checkout),[p,k]=o.useState("summary"),[m,b]=o.useState(!1),[h,A]=o.useState(()=>At(n)??"merge"),[F,T]=o.useState(!1),[j,g]=o.useState(""),[i,C]=o.useState(!1),[L,f]=o.useState(""),[N,E]=o.useState("newest"),[M,B]=o.useState(1),[V,S]=o.useState(!1),[$,K]=o.useState(null),_=bt(n,a),{send:X,sendingKey:R}=Fe(),I=rs(s,n),y=d?.pr??null,de=d?.sectionErrors??null,Q=o.useMemo(()=>({capabilities:d?.capabilities??null,isAuthor:cs(y?.author?.login,d?.viewerLogin),permissionFallback:d?.viewerPermission?.fallback===!0}),[d?.capabilities,d?.viewerLogin,d?.viewerPermission?.fallback,y?.author?.login]),ee=ds(y,Q);o.useEffect(()=>{k("summary"),T(!1),C(!1),B(1),K(null)},[n,a]);const Z=o.useCallback(async u=>{b(!0);try{const Y=await c(s,n,a,u,l);if(!Y.ok){H.error(Y.error?.kind==="failed"?Y.error.message:"Action failed");return}u==="close"?H.success("Pull request closed"):u==="reopen"?H.success("Pull request reopened"):u==="update-branch"?H.success("Branch update requested"):u==="ready"?H.success("Marked as ready for review"):u==="draft"?H.success("Converted to draft"):H.success("Pull request merged")}finally{b(!1)}},[s,n,a,l,c]),se=o.useCallback(()=>{X({key:`pr-${a}-ask`,kind:"pr",directory:s,repo:n,number:a,contextType:"pr"})},[X,s,n,a]),ne=o.useCallback(async()=>{if(!j.trim()){H.error("Enter a title");return}const u=await r(s,n,a,{title:j.trim()},l);u.ok?(H.success("Title updated"),T(!1)):H.error(u.error?.kind==="failed"?u.error.message:"Failed to update title")},[j,s,n,a,l,r]),oe=o.useCallback(async()=>{const u=await r(s,n,a,{body:L},l);u.ok?(H.success("Description updated"),C(!1)):H.error(u.error?.kind==="failed"?u.error.message:"Failed to update description")},[L,s,n,a,l,r]),ae=Ee().git,ue=o.useCallback(async u=>{if(u==="current"){const Y=await Ne(()=>import("./useAppFontEffects-Bfw_d5eB.js").then(re=>re.ee),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(re=>re.useGitStore.getState().directories.get(s)?.status??null).catch(()=>null);if(Y&&!Y.isClean){H.error("Working tree has uncommitted changes. Commit or stash first, or use New worktree.");return}}S(!0);try{const Y=await x(s,n,a,u,l);Y.ok?(await vt(s,ae),K({path:Y.path??null,branch:Y.branch??""}),H.success(u==="worktree"?"Worktree created":"Branch checked out")):H.error(Y.error?.kind==="failed"?Y.error.message:"Checkout failed")}finally{S(!1)}},[s,n,a,l,ae,x]),w=o.useCallback(()=>{$?.path&&Ne(async()=>{const{useSessionUIStore:u}=await import("./useAppFontEffects-Bfw_d5eB.js").then(Y=>Y.eb);return{useSessionUIStore:u}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({useSessionUIStore:u})=>{u.getState().openNewSessionDraft({directoryOverride:$.path}),Ns.getState().setActiveMainTab("chat")})},[$]),G=us(y?.url),q=o.useMemo(()=>{const u=[...t.comments];return u.sort((Y,je)=>{const re=Y.createdAt?Date.parse(Y.createdAt):0,Te=je.createdAt?Date.parse(je.createdAt):0;return N==="newest"?Te-re:re-Te}),u},[t.comments,N]),D=q.slice(0,M*20),U=D.filter(u=>!$e(u.author?.login)),W=D.filter(u=>$e(u.author?.login));if(t.detailError&&!d)return e.jsx(ke,{header:e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:I,number:a,openLabel:`Open pull request #${a} on GitHub`,title:`Pull request #${a}`}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(tt,{info:yt(t.detailError),onRetry:t.onRetryDetail})});if(!y){const u=t.seed&&t.seed.number===a?t.seed:null;return e.jsx(ke,{header:e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:I,number:a,url:u?.url??null,numberTintClass:u?He("pr",u.state,u.draft):void 0,statePill:u?e.jsx(Ge,{kind:"pr",state:u.state,draft:u.draft}):void 0,openLabel:`Open pull request #${a} on GitHub`,title:u?.title??null,meta:u?e.jsx(Je,{pr:u}):void 0,branches:u?e.jsx(We,{pr:u,filesCount:u.changedFiles??null}):void 0}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(ms,{label:"Loading pull request"})})}const J=t.checks?.summary??null,me=t.files?.files.length??y.changedFiles??0,v=_>0&&!t.hideFilesTab?`${me} · ${_} pending`:String(me);return e.jsx(ke,{header:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:I,number:y.number,url:y.url,numberTintClass:He("pr",y.state,y.draft),statePill:e.jsx(Ge,{kind:"pr",state:y.state,draft:y.draft}),openLabel:`Open pull request #${y.number} on GitHub`,title:y.title,onEditTitle:()=>{g(y.title),T(!0)},editTitleLabel:"Edit pull request title",editTitleDisabledReason:ee.allowed?null:ee.reason,meta:e.jsx(Je,{pr:y}),branches:e.jsx(We,{pr:y,filesCount:me})}),e.jsx(sn,{directory:s,repo:n,number:a,github:l,pr:y,access:Q,acting:m,mergeMethod:h,onMergeMethodChange:A,onRun:u=>{Z(u)},checkingOut:V,onCheckout:u=>{ue(u)},onCopyLink:G,askSending:R===`pr-${a}-ask`,onAskAgent:se}),e.jsx(nn,{pr:y,access:Q,acting:m,onRun:u=>{Z(u)}})]}),tabs:[{id:"summary",label:"Summary"},...t.hideFilesTab?[]:[{id:"files",label:"Code",hint:v}],{id:"checks",label:"Checks",hint:J?`${J.success}/${J.total}`:void 0,glyph:J?e.jsx(fe,{state:J.state}):void 0}],activeTab:p,onTabChange:u=>k(u),children:e.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2",children:[t.detailStale?e.jsxs("p",{className:"typography-micro text-muted-foreground",role:"note",children:["Showing saved details — last refresh failed."," ",e.jsx("button",{type:"button",className:"underline",onClick:t.onRetryDetail,children:"Retry"})]}):null,Q.permissionFallback?e.jsx("p",{className:"typography-micro text-muted-foreground",role:"note",children:"Permissions could not be loaded — actions stay enabled and any failure will be shown after you act."}):null,F?e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 py-1",children:[e.jsx(st,{value:j,onChange:u=>g(u.target.value),"aria-label":"Pull request title",className:"h-7"}),e.jsx(P,{type:"button",variant:"default",size:"xs",onClick:()=>{ne()},children:"Save"}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>T(!1),children:"Cancel"})]}):null,$?e.jsxs("p",{className:"flex flex-wrap items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(z,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]"}),e.jsxs("span",{children:["Ready on ",$.branch,$.path?` at ${$.path}`:"","."]}),$.path?e.jsx(P,{type:"button",variant:"default",size:"xs",onClick:w,children:"Open session here"}):null,e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>K(null),"aria-label":"Dismiss checkout result",children:"Dismiss"})]}):null,p==="summary"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-1.5 py-1",children:[e.jsx(qe,{icon:"user",label:"Reviewers",children:e.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",children:[y.requestedReviewers.length===0?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):y.requestedReviewers.map(u=>e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",children:[e.jsx(at,{login:u.login,avatarUrl:u.avatarUrl,size:"xs"}),e.jsx("span",{className:"truncate",children:u.login})]},u.login)),e.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[y.reviewSummary.approvals," approvals · ",y.reviewSummary.changesRequested," changes requested ·"," ",y.reviewSummary.commented," commented"]})]})}),e.jsx(qe,{icon:"list-unordered",label:"Labels",children:e.jsx("span",{className:"flex min-w-0 flex-wrap items-center gap-1",children:y.labels.length===0?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):y.labels.map(u=>e.jsx(hs,{name:u.name,color:u.color},u.name))})})]}),e.jsx(Ie,{id:`pr-${a}-description`,title:"Description",action:i?void 0:e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{f(y.body??""),C(!0)},"aria-label":"Edit description",title:ee.reason??"Edit description",disabled:!ee.allowed,children:"Edit"}),children:i?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("textarea",{value:L,onChange:u=>f(u.target.value),rows:6,"aria-label":"Pull request description",className:"min-h-24 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(P,{type:"button",variant:"default",size:"sm",onClick:()=>{oe()},children:"Save"}),e.jsx(P,{type:"button",variant:"ghost",size:"sm",onClick:()=>C(!1),children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(fs,{markdown:y.body??"",html:y.bodyHtml??null,fallbackUrl:y.url,label:"pull request description"}),y.body?.trim()?null:e.jsx("p",{className:"typography-micro text-muted-foreground",children:"No description provided."})]})}),e.jsx(Ie,{id:`pr-${a}-comments`,title:`Comments${q.length?` (${q.length})`:""}`,action:e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",children:[t.hideFilesTab?e.jsx(dt,{directory:s,repo:n,number:a,github:l,access:Q,size:"xs",onReviewSubmitted:t.onRetryDetail}):null,e.jsx(gs,{order:N,onToggle:()=>E(N==="newest"?"oldest":"newest")})]}),children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ve,{error:t.commentsError,onRetry:t.onRetryComments,label:"Comments"}),U.map(u=>e.jsx(xs,{comment:u},u.id)),e.jsx(ps,{comments:W}),t.commentsLoading&&q.length===0&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Loading comments…"}):null,q.length===0&&!t.commentsLoading&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"No comments yet."}):null,q.length>D.length?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>B(M+1),children:"Show older comments"})}):t.commentsHasMore?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:t.onLoadMoreComments,disabled:t.commentsLoading,children:t.commentsLoading?"Loading…":"Load older comments"})}):null,e.jsx(Os,{directory:s,repo:n,number:a,github:l,pr:y,access:Q,onCommented:()=>{t.onRetryComments(),t.onRetryDetail()}})]})})]}):null,p==="files"&&!t.hideFilesTab?e.jsx(Zs,{files:t.files,filesLoading:t.filesLoading,filesError:t.filesError,filesHasMore:t.filesHasMore,onLoadMoreFiles:t.onLoadMoreFiles,onRetryFiles:t.onRetryFiles,threads:t.threads,threadsError:de?.threads??null,onRetryDetail:t.onRetryDetail,directory:s,repo:n,number:a,github:l,access:Q,headSha:y.headSha??null,onReviewSubmitted:t.onRetryDetail},`${n}#${a}`):null,p==="checks"?e.jsx(en,{directory:s,repo:n,number:a,github:l,checks:t.checks,checksError:t.checksError,checksLoading:t.checksLoading,onRetryChecks:t.onRetryChecks,onOpenFilesAtLine:t.onOpenFilesAtLine}):null]})})},ln=({items:t,hasMore:s,isLoadingMore:n,isLoading:a,isRefreshing:l,stale:d,error:c,filters:r,checksByUrl:x,countComplete:p=!0,incompleteNotice:k=null,remote:m=null,numberJump:b=null,onFiltersChange:h,onClearFilters:A,onLoadMore:F,onRetry:T,onOpen:j,headerActionsSlot:g=null,headerActionsPresentation:i="drawer"})=>{const C=r.state==="open"&&r.involvement==="all"&&!r.search.trim(),L=o.useCallback(f=>e.jsx("li",{role:"listitem",children:e.jsx(jt,{glyph:e.jsx(ys,{kind:"pr",state:f.state,draft:f.draft}),glyphBelow:e.jsx(fe,{state:(f.url?x[f.url]:void 0)??null}),number:`#${f.number}`,title:f.title,status:e.jsx(ge,{additions:f.additions,deletions:f.deletions,className:"typography-micro"}),meta:e.jsxs(e.Fragment,{children:[e.jsx(wt,{login:f.author?.login,avatarUrl:f.author?.avatarUrl}),e.jsx(kt,{head:f.head,base:f.base}),f.draft?e.jsx("span",{className:"shrink-0 rounded bg-[var(--surface-muted)] px-1 typography-micro text-muted-foreground",children:"Draft"}):null]}),updatedAt:f.updatedAt,onOpen:()=>j(f.number),ariaLabel:`Open pull request #${f.number} ${f.title}`})},f.number),[x,j]);return e.jsx(Ct,{items:t,renderRow:L,hasMore:s,isLoadingMore:n,isLoading:a,isRefreshing:l,stale:d,error:c,searchValue:r.search,onSearchChange:f=>h({search:f}),searchPlaceholder:"Search pull requests, or label:bug",searchAriaLabel:"Search pull requests",toolbarControls:e.jsx(Nt,{stateValue:r.state,stateOptions:Oe.map(f=>({id:f.id,label:f.label})),onStateChange:f=>h({state:f}),involvementValue:r.involvement,involvementOptions:ws.map(f=>({id:f.id,label:f.label})),onInvolvementChange:f=>h({involvement:f}),sortValue:r.sort,sortOptions:js.map(f=>({id:f.id,label:f.label})),onSortChange:f=>h({sort:f}),sortAriaLabel:"Sort pull requests"}),headerActionsSlot:g,headerActionsPresentation:i,isDefaultFilters:C,stateLabel:Oe.find(f=>f.id===r.state)?.label??r.state,kindSingular:"pull request",kindPlural:"pull requests",noItemsTitle:r.state==="open"?"No open pull requests":"No pull requests yet",noItemsBody:"Pull requests for this repository appear here.",noItemsIcon:"git-pull-request",listAriaLabel:"Pull requests",skeletonLabel:"Loading pull requests",updatedAtOf:f=>f.updatedAt,countComplete:p,incompleteNotice:k,remote:m,numberJump:b,numberJumpKind:"pull request",onClearFilters:A,onLoadMore:F,onRetry:T,onOpen:j})},on=t=>{const s=Dt(n=>n.results);return o.useMemo(()=>{const n=$t(s),a={};for(const l of t){if(!l.url)continue;const d=n.get(l.url);d!==void 0&&(a[l.url]=d)}return a},[t,s])},da=({hideFilesTab:t=!1,headerActionsSlot:s=null,headerActionsPresentation:n="drawer"})=>{const a=Mt()??"";return a?e.jsx(rn,{directory:a,hideFilesTab:t,headerActionsSlot:s,headerActionsPresentation:n}):e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center",children:e.jsx("p",{className:"typography-ui text-muted-foreground",children:"Open a project to browse pull requests."})})},rn=({directory:t,hideFilesTab:s,headerActionsSlot:n=null,headerActionsPresentation:a="drawer"})=>{const d=Ee().github??null,[c,r]=o.useState(!1),[x,p]=o.useState(!1),k=o.useRef(null);return o.useEffect(()=>Gt(),[]),e.jsx(St,{directory:t,isRefreshing:c,onRefresh:()=>k.current?.(),children:({repo:m,directory:b})=>e.jsx(cn,{directory:b,repo:m,github:d,refreshing:c,setRefreshing:r,loadingMore:x,setLoadingMore:p,refreshRef:k,hideFilesTab:s,headerActionsSlot:n,headerActionsPresentation:a},m)})},cn=({directory:t,repo:s,github:n,refreshing:a,setRefreshing:l,loadingMore:d,setLoadingMore:c,refreshRef:r,hideFilesTab:x,headerActionsSlot:p=null,headerActionsPresentation:k="drawer"})=>{const m=O(v=>v.ensureCollectionsFresh),b=O(v=>v.searchRemote),h=O(v=>v.loadMoreRemote),A=O(v=>v.loadMoreCollection),F=O(v=>v.refreshAllForScope),T=O(v=>v.selectPullRequest),j=O(v=>v.setFilters),g=O(v=>v.resetFilters),i=Ht(t,s),C=qt(t),L=It(),f=C.repo===s?C.number:null,N=i.state==="open"?"open":i.state==="all"?"both":"closed";o.useEffect(()=>{if(!n)return;let v=!1;return l(!0),m(t,s,N,n).then(()=>{v||l(!1)}).catch(()=>{v||l(!1)}),()=>{v=!0}},[t,s,n,N]),o.useEffect(()=>{if(!n)return;const v=()=>{typeof document<"u"&&document.hidden||m(t,s,N,n).catch(()=>{})};return window.addEventListener("focus",v),document.addEventListener("visibilitychange",v),()=>{window.removeEventListener("focus",v),document.removeEventListener("visibilitychange",v)}},[t,s,n,N]);const E=De(s,"open"),M=De(s,"closed"),B=o.useMemo(()=>Ot(s),[s,E?.data,M?.data]),V=o.useMemo(()=>new Set(B.map(v=>v.number)),[B]),S=o.useMemo(()=>Bt(B,{state:i.state,involvement:i.involvement,search:i.search,sort:i.sort,viewerLogin:L}),[B,i.state,i.involvement,i.search,i.sort,L]),$=on(S),K=N==="both"?[E,M]:[N==="open"?E:M],_=K.some(v=>v?.data!=null),X=_&&K.every(v=>v?.data?.nextCursor==null),R=K.reduce((v,u)=>v+(u?.data?.items.length??0),0),I=K.find(v=>v?.error)?.error??null,y=K.some(v=>v?.isLoading),de=K.some(v=>v?.stale),Q=i.search.trim(),ee=i.involvement!=="all"&&!L,Z=Q.length>0||i.involvement!=="all",se=o.useMemo(()=>({state:i.state,involvement:i.involvement,q:Q}),[i.state,i.involvement,Q]),ne=`${se.state}|${se.involvement}|${se.q}`,oe=!X&&_&&S.length===0&&(Q.length>0||ee),ae=o.useCallback(v=>n?b(t,s,v,n):Promise.resolve(null),[t,s,n,b]),ue=o.useCallback(v=>n?h(t,s,v,n):Promise.resolve(null),[t,s,n,h]),{remoteView:w,numberJump:G,remotePending:q,handleSearchAll:ie}=Rt({repo:s,query:se,queryKey:ne,autoRemote:oe,indexNumbers:V,visibleItems:S,searchText:Q,useRemoteEntry:Wt,runSearch:ae,runLoadMore:ue}),D=o.useMemo(()=>{if(X||!_||!Z)return null;const v=S.length===1?"1 match":`${S.length} matches`,u=R===1?"1 most recent loaded pull request":`${R} most recent loaded pull requests`;return`Showing ${v} from the ${u}`},[X,_,Z,S.length,R]),U=o.useCallback(()=>{n&&(l(!0),F(t,s,n).then(()=>{l(!1)}).catch(()=>l(!1)))},[t,s,n,F,l]);o.useEffect(()=>(r.current=U,()=>{r.current===U&&(r.current=null)}),[r,U]);const W=o.useCallback(()=>{if(!n)return;c(!0);const v=N==="both"?["open","closed"]:[N];Promise.all(v.map(u=>A(t,s,u,n))).then(()=>c(!1)).catch(()=>c(!1))},[t,s,N,n,A,c]),J=o.useCallback(v=>{T(t,s,v)},[t,s,T]),me=o.useCallback(()=>{T(t,null,null)},[t,T]);return n?f!=null?e.jsx(dn,{directory:t,repo:s,number:f,github:n,onBack:me,hideFilesTab:x,seed:_t(s,f)}):e.jsx(ln,{items:S,headerActionsSlot:p,headerActionsPresentation:k,hasMore:K.some(v=>v?.data?.nextCursor!=null),isLoadingMore:d,isLoading:y,isRefreshing:a&&_,stale:de,error:I,filters:i,checksByUrl:$,countComplete:X,incompleteNotice:D?{summary:D,searching:q,onSearchAll:ie}:null,remote:w,numberJump:G,onFiltersChange:v=>j(t,s,v),onClearFilters:()=>g(t,s),onLoadMore:W,onRetry:U,onOpen:J}):e.jsx(tt,{info:{reason:"failed",message:"GitHub is not available in this runtime."}})},dn=({directory:t,repo:s,number:n,github:a,onBack:l,hideFilesTab:d,seed:c})=>{const r=O(S=>S.ensureDetail),x=O(S=>S.ensureComments),p=O(S=>S.ensureFiles),k=O(S=>S.ensureChecks),m=O(S=>S.loadMoreFiles),b=O(S=>S.loadMoreComments),h=O(S=>S.refreshComments),A=O(S=>S.refreshDetail),F=O(S=>S.refreshChecks);o.useEffect(()=>{r(t,s,n,a).catch(()=>{}),x(t,s,n,a).catch(()=>{}),d||p(t,s,n,a).catch(()=>{}),k(t,s,n,a).catch(()=>{})},[t,s,n,d]);const T=Ut(s,n),j=Vt(s,n),g=Kt(s,n),i=Jt(s,n),C=T?.data?.detail??null,L=o.useCallback((S,$)=>{const K=Ss(t);Ne(async()=>{const{useUIStore:_}=await import("./index-DWSrsQWl.js").then(X=>X.cD);return{useUIStore:_}},__vite__mapDeps([1,2,3,4,5,6,7,8])).then(({useUIStore:_})=>{_.getState().openContextFileAtLine(K,S,$)}).catch(()=>{})},[t]),f=o.useCallback(()=>{m(t,s,n,a).catch(()=>{})},[t,s,n,a,m]),N=o.useCallback(()=>{b(t,s,n,a).catch(()=>{})},[t,s,n,a,b]),E=o.useCallback(()=>{h(t,s,n,a).catch(()=>{})},[t,s,n,a,h]),M=o.useCallback(()=>{A(t,s,n,a).catch(()=>{})},[t,s,n,a,A]),B=o.useCallback(()=>{p(t,s,n,a).catch(()=>{})},[t,s,n,a,p]),V=o.useCallback(()=>{F(t,s,n,a).catch(()=>{})},[t,s,n,a,F]);return e.jsx(an,{hideFilesTab:d,seed:c,directory:t,repo:s,number:n,github:a,detail:C,detailError:T?.error??null,detailStale:T?.stale??!1,files:g?.data??null,filesError:g?.error??null,filesLoading:g?.isLoading??!1,filesHasMore:g?.data?.nextCursor!=null,onLoadMoreFiles:f,checks:i?.data??null,checksError:i?.error??null,checksLoading:i?.isLoading??!1,reviews:C?.reviews??[],threads:C?.threads??[],comments:j?.data?.comments??[],commentsError:j?.error??null,commentsLoading:j?.isLoading??!1,commentsHasMore:j?.data?.nextCursor!=null,onLoadMoreComments:N,onRetryComments:E,onBack:l,onRetryDetail:M,onRetryFiles:B,onRetryChecks:V,onOpenFilesAtLine:L})};export{da as PullRequestsSurface};
@@ -0,0 +1 @@
1
+ import{k as e,bh as k}from"./vendor-boot-EC6IyLt1.js";import{R as f}from"./vendor-react-DASdDPIk.js";import{h as w,I as x,i as E,j as M,k as G,v as q,m as B,n as F,r as H,q as z}from"./useAppFontEffects-Bfw_d5eB.js";import{u as J}from"./useSwitcherItems-yHSMduoo.js";import{f as K,e as C}from"./index-DWSrsQWl.js";import{a as O,S as Q,f as V}from"./SessionUnreadDot-B9bHMy5q.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-Der4qUnI.js";import"./nativeFileSave-CFuugNKV.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";function le({onSelect:s,variant:p,scopeProjectId:d}){const i=J(!0,{scopeProjectId:d}),o=w(t=>t.openNewSessionDraft),a=K(t=>t.setActiveMainTab),l=f.useCallback(()=>{a("chat"),s(),o()},[s,o,a]),[c,m]=f.useState(new Set),u=f.useCallback(t=>{m(h=>{const r=new Set(h);return r.has(t)?r.delete(t):r.add(t),r})},[]);return e.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(k,{onClick:l,className:C("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),children:[e.jsx(x,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate typography-ui-label font-normal leading-tight text-foreground",children:"New session"})]}),i.length===0?e.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:"No recent sessions"}):i.map(t=>e.jsx(D,{item:t,depth:0,variant:p,expandedParents:c,toggleParent:u,closeDropdown:s},t.node.session.id))]})})}function D({item:s,depth:p,variant:d,expandedParents:i,toggleParent:o,closeDropdown:a}){const{node:l,secondaryMeta:c}=s,m=l.session,u=l.children.length>0,t=i.has(m.id);return e.jsxs(e.Fragment,{children:[e.jsx(W,{session:m,depth:p,variant:d,secondaryMeta:c,hasChildren:u,isExpanded:t,onToggleExpand:u?()=>o(m.id):void 0,closeDropdown:a}),u&&t?l.children.map(h=>e.jsx(D,{item:{node:h,projectId:s.projectId,groupDirectory:s.groupDirectory,secondaryMeta:c},depth:p+1,variant:d,expandedParents:i,toggleParent:o,closeDropdown:a},h.session.id)):null]})}function W({session:s,depth:p,variant:d,secondaryMeta:i,hasChildren:o,isExpanded:a,onToggleExpand:l,closeDropdown:c}){const m=w(n=>n.currentSessionId),u=w(n=>n.setCurrentSession),t=E(s.id),h=M(s.id),r=G(s.id),g=m===s.id,L=q(s),N=t?.type??"idle",b=N==="busy"||N==="retry",S=B({pendingInput:r,isStreaming:b,unseenCount:h,isActive:g}),v=S==="needs-input",A=v&&r?F(r.kind,r.count):null,T=S==="unread",U=s.time?.updated||s.time?.created||Date.now(),P=V(U),y=i?.projectLabel?.trim()||null,j=i?.branchLabel?.trim()||null,I=j&&j!=="HEAD"?j:null,R=f.useCallback(()=>{if(g){c();return}const n=H(s);u(s.id,n??null),c()},[c,g,s,u]);return e.jsxs(k,{onClick:n=>{if(n.target?.closest("[data-switcher-expand]")){n.preventDefault();return}R()},"data-slot":"session-switcher-item",className:C("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),style:{paddingLeft:8+p*12},children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[d==="compact"&&o?e.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:n=>{n.preventDefault(),n.stopPropagation(),l?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":a?"Collapse subsessions":"Expand subsessions",children:a?e.jsx(x,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):e.jsx(x,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e.jsx("span",{className:"truncate typography-ui-label font-normal leading-tight text-foreground",children:L})]}),d==="default"?e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight typography-micro",children:[o?e.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:n=>{n.preventDefault(),n.stopPropagation(),l?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":a?"Collapse subsessions":"Expand subsessions",children:a?e.jsx(x,{name:"arrow-down-s",className:"h-3 w-3"}):e.jsx(x,{name:"arrow-right-s",className:"h-3 w-3"})}):null,e.jsx("span",{className:"flex-shrink-0",children:b?e.jsx(O,{sessionId:s.id,running:!0}):T?e.jsx(Q,{label:"Session complete"}):P}),y?e.jsx("span",{className:"truncate",children:y}):null,I?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[e.jsx(x,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),e.jsx("span",{className:"truncate",children:I})]}):null]}):null]}),v?e.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:e.jsx(z,{label:A??"Needs input"})}):b?e.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":"Session active",title:"Session active"})}):null]})}export{le as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionSwitcherContent-CCljxAZb.js","assets/vendor-boot-EC6IyLt1.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js","assets/useAppFontEffects-Bfw_d5eB.js","assets/index-DWSrsQWl.js","assets/vendor-zustand-CUi8eEds.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-DsQIBAWK.css","assets/runtimeSurface-Der4qUnI.js","assets/nativeFileSave-CFuugNKV.js","assets/useSwitcherItems-yHSMduoo.js","assets/SessionUnreadDot-B9bHMy5q.js"])))=>i.map(i=>d[i]);
2
+ import{_ as m}from"./vendor-vite-runtime-DD1OZmLC.js";import{k as e}from"./vendor-boot-EC6IyLt1.js";import{a as l,R as c}from"./vendor-react-DASdDPIk.js";import{ai as d,al as x,an as f}from"./useAppFontEffects-Bfw_d5eB.js";import{f as n,e as u}from"./index-DWSrsQWl.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./runtimeSurface-Der4qUnI.js";import"./nativeFileSave-CFuugNKV.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";const w=c.lazy(()=>m(()=>import("./SessionSwitcherContent-CCljxAZb.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])));function R({children:p,variant:t="default",scopeProjectId:a=null,align:i="start"}){const r=n(o=>o.isSessionDropdownOpen),s=n(o=>o.setSessionDropdownOpen);return e.jsxs(d,{open:r,onOpenChange:s,modal:!1,children:[e.jsx(x,{asChild:!0,children:p}),e.jsx(f,{align:i,sideOffset:6,className:u("overflow-hidden p-1 max-w-[calc(100vw-32px)]",t==="compact"?"w-[280px]":"w-[360px]"),children:r?e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:"Loading…"}),children:e.jsx(w,{onSelect:()=>s(!1),variant:t,scopeProjectId:a})}):null})]})}export{R as SessionSwitcherDropdown};
@@ -0,0 +1 @@
1
+ import{p as m,a1 as M,e as h}from"./index-DWSrsQWl.js";import{k as g}from"./vendor-boot-EC6IyLt1.js";import"./vendor-react-DASdDPIk.js";import{dw as b,dx as p,dy as w}from"./useAppFontEffects-Bfw_d5eB.js";const F=(e,t,o)=>{const s=`${o}:`,a=new Set([...t].filter(r=>r.startsWith(s)));return e.size===a.size&&[...a].every(r=>e.has(r))?e:a},I=(e,t)=>{const o=new Set(e);return o.has(t)?o.delete(t):o.add(t),o},S=e=>{const t=new Date(e),o=new Date,s=(n,i)=>n.getFullYear()===i.getFullYear()&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate(),a=new Date(o);return a.setDate(o.getDate()-1),s(t,o)?"Today":s(t,a)?"Yesterday":t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}).replace(",","")},P=e=>{const t=new Date,o=new Date(e);if(((a,r)=>a.getFullYear()===r.getFullYear()&&a.getMonth()===r.getMonth()&&a.getDate()===r.getDate())(o,t)){const a=Date.now()-e;return a<6e4?"Just now":a<36e5?`${Math.floor(a/6e4)}min ago`:`${Math.floor(a/36e5)}h ago`}return S(e)},E=e=>{const t=Math.max(0,Date.now()-e),o=6e4,s=60*o,a=24*s,r=7*a,n=30*a,i=365*a;return t<s?`${Math.max(1,Math.floor(t/o))}m`:t<a?`${Math.floor(t/s)}h`:t<r?`${Math.floor(t/a)}d ago`:t<5*r?`${Math.floor(t/r)}w ago`:t<i?`${Math.floor(t/n)}mo`:`${Math.floor(t/i)}y ago`},d=e=>e.toLowerCase().replace(/[-_]/g,"").trim(),R=(e,t)=>e?d(e)!==d(t):!1,U=e=>{const t=new Map;return e.forEach(o=>{t.set(o.id,o)}),Array.from(t.values())},Y=e=>`__archived__:${e}`,B=(e,t)=>{const o=m(e.directory??null),s=m(e.project?.worktree??null),a=o??s;if(!a)return"unassigned";if(t&&a===t)return"project root";const n=(t&&a.startsWith(`${t}/`)?a.slice(t.length+1):a).split("/").filter(Boolean);return n[n.length-1]??"unassigned"},x=e=>e.replace(/[-_]/g," ").replace(/\b\w/g,t=>t.toUpperCase()),K=(e,t)=>x(e.label?.trim()||M(e.normalizedPath,t)||e.normalizedPath),T="calc(1.25rem * var(--padding-scale, 1))",y="size-4 shrink-0",D="min-w-0 truncate typography-ui-label font-normal",v=y,$=D,C="group relative my-0.5 flex w-full cursor-pointer items-center gap-1.5 rounded-xl px-3 py-2 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",j=C,W=e=>e?v:y,O=e=>e?$:D,u=1e3,l=60*u,c=60*l,N=e=>{const t=Math.max(0,e);return t<l?`${Math.floor(t/u)}s`:t<c?`${Math.floor(t/l)}m ${Math.floor(t%l/u)}s`:`${Math.floor(t/c)}h ${Math.floor(t%c/l)}m`},L=1e3,H=({sessionId:e,running:t,className:o})=>{const s=b(e),a=p(e),r=w(t,L),n=t?Math.max(0,r-(s??r)):a;if(n===void 0)return null;const i=N(n),f=t?`Active for ${i}`:`Last turn took ${i}`;return g.jsx("span",{className:h("shrink-0 tabular-nums",t?"text-primary":"text-[var(--status-info)]",o),"aria-label":f,title:f,children:i})};function J({label:e,className:t}){return g.jsx("span",{className:h("size-1.5 shrink-0 rounded-full bg-foreground",t),"aria-label":e,title:e})}export{J as S,H as a,P as b,D as c,U as d,W as e,E as f,Y as g,O as h,j as i,C as j,R as k,T as l,x as m,K as n,F as o,B as r,y as s,I as t};