@pi-chamber/web 1.0.8-rc.1 → 1.0.8-rc.2
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.
- package/dist/assets/{AgentsSurface-BmHImX8m.js → AgentsSurface-CcWBqAWV.js} +1 -1
- package/dist/assets/{ChoicesArtifact-C71fGOm2.js → ChoicesArtifact-Kk-qvrSB.js} +1 -1
- package/dist/assets/{DiagramView-BZQxoiZu.js → DiagramView-DZUBo1uP.js} +1 -1
- package/dist/assets/{DiffView-C70pbgk-.js → DiffView-CiZy4jFA.js} +1 -1
- package/dist/assets/{FileSaveConflictDialog-Cu8c3gBV.js → FileSaveConflictDialog-DZ9NDwOO.js} +1 -1
- package/dist/assets/{FilesView-nFJYEdRw.js → FilesView-DqiZ9kw9.js} +1 -1
- package/dist/assets/{GitHubDetailScaffold-Jvv_tgbl.js → GitHubDetailScaffold-DM2DH7o8.js} +1 -1
- package/dist/assets/{GitHubLinkPicker-BXD2ODRi.js → GitHubLinkPicker-ChB8NZ1h.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-BWI706F0.js → GitHubListPrimitives-CibDiJGq.js} +1 -1
- package/dist/assets/{GitView-MIDG5RYW.js → GitView--EaZQrBr.js} +5 -5
- package/dist/assets/{IssuesSurface-uNlozeu0.js → IssuesSurface-CySTpaD1.js} +3 -3
- package/dist/assets/{JsonTreeView-CSLsTriz.js → JsonTreeView-_yMHKKQZ.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-Cs-7BfWi.js → MarkdownRendererImpl-D_-2fQw0.js} +1 -1
- package/dist/assets/{PatchDiff-axbsnbTJ.js → PatchDiff-bHObDlhD.js} +1 -1
- package/dist/assets/{PierreDiffViewer-lwn6w_5w.js → PierreDiffViewer-UY7Cse-s.js} +1 -1
- package/dist/assets/{PullRequestsSurface-o_AXDjbO.js → PullRequestsSurface-iXy6chwc.js} +2 -2
- package/dist/assets/{SessionSwitcherContent-C4CMlcbv.js → SessionSwitcherContent-DJGCa_wN.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-DCBVuCoo.js → SessionSwitcherDropdown-CDOX-5Y2.js} +2 -2
- package/dist/assets/{SessionUnreadDot-DyeIrsro.js → SessionUnreadDot-Dwc3MdvA.js} +1 -1
- package/dist/assets/SettingsView-DA-U9lsj.js +11 -0
- package/dist/assets/{SettingsWindow-Cb4st5y5.js → SettingsWindow-CUg49Mfh.js} +1 -1
- package/dist/assets/{SubagentsArtifact-BzeMEoFP.js → SubagentsArtifact-DUZX9tDe.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BP2mOWdV.js → ToolOutputDialog-BuZZaRw4.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-D49XBR9b.js → ToolPartDiffPreview-CKncG6i2.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-CLgDONEQ.js → VirtualizedFileDiff-BGZiLPe_.js} +1 -1
- package/dist/assets/VisualFrame-DBZkHFnG.js +22 -0
- package/dist/assets/VisualsArtifact-Bq0vMO-i.js +1 -0
- package/dist/assets/{collapsible-BeyKtQGB.js → collapsible-Bro9KrfM.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-DmO6H8u6.js → computeVirtualFileMetrics-DJQqK49u.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-DOK251YW.js → contextFileOpenGuard-ByWK3Sru.js} +1 -1
- package/dist/assets/{fileTreeStatus-CnzR7kxA.js → fileTreeStatus-CyJ3TOYD.js} +1 -1
- package/dist/assets/{gitStatusPredicates-4kPg2t6j.js → gitStatusPredicates-BsXrwngT.js} +1 -1
- package/dist/assets/{githubLink-QvaLfNNT.js → githubLink-g2bmC0qi.js} +1 -1
- package/dist/assets/index-B_L9GVYw.css +1 -0
- package/dist/assets/{index-DMX9wT1Z.js → index-C9rUUQ_Y.js} +1 -1
- package/dist/assets/index-CKKWVoND.js +11 -0
- package/dist/assets/{main-BW9J3Y72.js → main-DT-4_fhe.js} +2 -2
- package/dist/assets/{main-BirYxac2.js → main-DsLMU9CT.js} +4 -4
- package/dist/assets/{markdownCore-CxmcPur8.js → markdownCore-QmM_aOnZ.js} +1 -1
- package/dist/assets/{miniChat-BRB11eEs.js → miniChat-BqGslD2z.js} +2 -2
- package/dist/assets/{mobile-DJZYYCuB.js → mobile-C5JOcDIC.js} +2 -2
- package/dist/assets/{nativeFileSave-B6QpoPRn.js → nativeFileSave-DSMsJqXM.js} +1 -1
- package/dist/assets/{pi-session-focus-preference-PWoh3LNA.js → pi-session-focus-preference-Cc_S4zi1.js} +1 -1
- package/dist/assets/{renderDiffWithHighlighter-C48T6YFJ.js → renderDiffWithHighlighter-BXhnIAHg.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-N-BQdJl0.js → renderElectronMiniChatApp-CiSkecEE.js} +2 -2
- package/dist/assets/{renderFileWithHighlighter-8Kt2MyTN.js → renderFileWithHighlighter-CK29YZtC.js} +1 -1
- package/dist/assets/renderMobileApp-C4JuoxsZ.js +11 -0
- package/dist/assets/runtimeEndpointReset-Dwj-jCDS.js +66 -0
- package/dist/assets/{runtimeSurface-kIEoYsPP.js → runtimeSurface-0K7vuUpd.js} +1 -1
- package/dist/assets/{selection-BTEdLRVK.js → selection-CnYkEsu_.js} +1 -1
- package/dist/assets/useAppFontEffects-CV5UyTRw.js +226 -0
- package/dist/assets/{useGitHubRemoteSearch-DIBHNu8r.js → useGitHubRemoteSearch-CgP-zEBj.js} +1 -1
- package/dist/assets/{useSwitcherItems-DfLbfX37.js → useSwitcherItems-C8G5F0hs.js} +1 -1
- package/dist/assets/{web-components-C_DsTJis.js → web-components-BpncHjnV.js} +1 -1
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/plugins/featured.json +12 -0
- package/plugins/subagents/package.json +1 -1
- package/plugins/visuals/extension.js +7 -4
- package/plugins/visuals/package.json +1 -1
- package/server/index.js +86 -27
- package/server/lib/git/DOCUMENTATION.md +4 -0
- package/server/lib/git/service.js +70 -5
- package/server/lib/git/service.test.js +179 -0
- package/server/lib/github/DOCUMENTATION.md +2 -0
- package/server/lib/marketplace/DOCUMENTATION.md +95 -0
- package/server/lib/marketplace/featured.js +176 -0
- package/server/lib/marketplace/featured.test.js +207 -0
- package/server/lib/marketplace/npm-registry.js +255 -0
- package/server/lib/marketplace/npm-registry.test.js +227 -0
- package/server/lib/marketplace/routes.js +64 -0
- package/server/lib/marketplace/routes.test.js +119 -0
- package/server/lib/marketplace/service.js +225 -0
- package/server/lib/marketplace/service.test.js +174 -0
- package/server/lib/notifications/DOCUMENTATION.md +10 -4
- package/server/lib/notifications/pi-notification-watcher.js +92 -33
- package/server/lib/notifications/pi-notification-watcher.test.js +79 -0
- package/server/lib/open-url/DOCUMENTATION.md +1 -0
- package/server/lib/pi/merged-event-stream.js +316 -0
- package/server/lib/pi/merged-event-stream.test.js +95 -0
- package/server/lib/pi/routes-daemon-pool.test.js +348 -0
- package/server/lib/pi/routes-merged-events.test.js +327 -0
- package/server/lib/pi/routes-sandbox.test.js +1684 -0
- package/server/lib/pi/routes.js +491 -90
- package/server/lib/pi/routes.test.js +87 -2
- package/server/lib/pi/sandbox/DOCUMENTATION.md +68 -0
- package/server/lib/pi/sandbox/launcher.js +122 -0
- package/server/lib/pi/sandbox/launcher.test.js +91 -0
- package/server/lib/pi/sandbox/nono-launcher.js +455 -0
- package/server/lib/pi/sandbox/nono-launcher.test.js +371 -0
- package/server/lib/pi/sandbox/nono-profile-macos.json +20 -0
- package/server/lib/pi/sandbox/nono-profile-wsl2.json +21 -0
- package/server/lib/pi/sandbox/nono-profile.json +22 -0
- package/server/lib/pi/sandbox/project-sandbox-manager.js +1461 -0
- package/server/lib/pi/sandbox/project-sandbox-setting.js +166 -0
- package/server/lib/pi/sandbox/project-sandbox.js +207 -0
- package/server/lib/pi/sandbox/sandbox-routes.js +110 -0
- package/server/lib/pi/sandbox/sandboxed-folders.js +100 -0
- package/server/lib/pi/sandbox/sandboxed-folders.test.js +65 -0
- package/server/lib/pi/sandbox/trust-ask.js +135 -0
- package/server/lib/pi/sandbox/trust-ask.test.js +54 -0
- package/server/lib/pi/sandbox/worktree-ids.js +96 -0
- package/server/lib/pi/sandbox/worktree-ids.test.js +73 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +26 -6
- package/server/lib/pi/session-daemon/daemon-pool.js +157 -0
- package/server/lib/pi/session-daemon/daemon-process.js +10 -1
- package/server/lib/pi/session-daemon/extension-config.js +206 -23
- package/server/lib/pi/session-daemon/extension-config.test.js +180 -0
- package/server/lib/pi/session-daemon/session-daemon-read-persisted.test.js +167 -0
- package/server/lib/pi/session-daemon/session-daemon.js +368 -56
- package/server/lib/pi/session-daemon/session-daemon.test.js +227 -0
- package/server/lib/pi/session-daemon/session-idle-residency.test.js +98 -1
- package/server/lib/pi/session-daemon/session-jsonl.js +49 -10
- package/server/lib/pi/session-daemon/session-jsonl.test.js +11 -0
- package/server/lib/pi/session-daemon/session-lease.js +93 -15
- package/server/lib/pi/session-daemon/session-lease.test.js +107 -1
- package/server/lib/pi/session-daemon/supervisor-launcher-stop.test.js +295 -0
- package/server/lib/pi/session-daemon/supervisor-sandbox-nono.e2e.test.js +301 -0
- package/server/lib/pi/session-daemon/supervisor-sandbox.test.js +444 -0
- package/server/lib/pi/session-daemon/supervisor.js +386 -35
- package/server/lib/pi/session-daemon/supervisor.test.js +28 -0
- package/server/lib/pi/ui-settings-store.js +88 -2
- package/server/lib/pi/ui-settings-store.test.js +118 -0
- package/server/lib/plugins/DOCUMENTATION.md +17 -5
- package/server/lib/plugins/daemon-sync.js +16 -6
- package/server/lib/plugins/daemon-sync.test.js +12 -0
- package/server/lib/plugins/impact.test.js +2 -1
- package/server/lib/plugins/manifest.js +25 -0
- package/server/lib/plugins/manifest.test.js +9 -0
- package/server/lib/plugins/routes.test.js +28 -0
- package/server/lib/plugins/service.js +24 -2
- package/server/lib/server/cross-process-lock.js +28 -3
- package/dist/assets/SettingsView-BHBpt2Um.js +0 -7
- package/dist/assets/VisualFrame-CJrAvWSo.js +0 -22
- package/dist/assets/VisualsArtifact-DqLGgU-Q.js +0 -1
- package/dist/assets/index-B2v0_mez.js +0 -11
- package/dist/assets/index-D3F4JrPN.css +0 -1
- package/dist/assets/renderMobileApp-B7cT7m5b.js +0 -11
- package/dist/assets/runtimeEndpointReset-BC6yGnxN.js +0 -62
- package/dist/assets/useAppFontEffects-EcTZ_I_I.js +0 -225
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aX as Se,j as z}from"./vendor-boot-D-KEJjsM.js";import{a as f,R as ae}from"./vendor-react-Bz1tRBxM.js";import{a as Ee}from"./web-components-C_DsTJis.js";import{e as ce}from"./computeVirtualFileMetrics-DmO6H8u6.js";import{V as ke,F as xe}from"./VirtualizedFileDiff-CLgDONEQ.js";import{v as Te,aj as Oe}from"./useAppFontEffects-EcTZ_I_I.js";import{P as ze,S as De}from"./StickyHorizontalScrollbar-CMbTn5WQ.js";import{u as Ce}from"./runtimeEndpointReset-BC6yGnxN.js";import{ensurePierreThemeRegistered as ue,getResolvedShikiTheme as he}from"./appThemeRegistry-Ca8eGRB9.js";import{a as de,c as fe}from"./index-B2v0_mez.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 pe({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 p=Math.max(n-i,0),y=Math.min(n+d,e);return{top:p,bottom:Math.max(y,p)}}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 X=0,Le=-1;var _e=class x{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=()=>{x.__STOP?(x.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:x.__lastScrollPosition}),E(this.computeRenderRangeAndEmit)):(x.__lastScrollPosition=this.getScrollTop(),x.__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=pe({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-X,newSize:i}),X=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-X,newSize:i}),X=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=()=>{x.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,E(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{x.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{x.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(x.__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=pe({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 p=U(m,t);if(p!==i){const y=p-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,p;if(h>0&&s<e)for(const w of i.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(w instanceof HTMLElement))continue;const W=w.dataset.lineIndex;if(W==null)continue;const D=U(w,t);if(!(D<0)){m=W,p=D;break}}if(r?.lineOffset!=null&&p==null)continue;let y=!1;(r==null||p!=null&&(r.lineOffset==null||p<r.lineOffset)||p==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:p})}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 ge=5e5,Fe=`
|
|
1
|
+
import{aX as Se,j as z}from"./vendor-boot-D-KEJjsM.js";import{a as f,R as ae}from"./vendor-react-Bz1tRBxM.js";import{a as Ee}from"./web-components-BpncHjnV.js";import{e as ce}from"./computeVirtualFileMetrics-DJQqK49u.js";import{V as ke,F as xe}from"./VirtualizedFileDiff-BGZiLPe_.js";import{v as Te,aj as Oe}from"./useAppFontEffects-CV5UyTRw.js";import{P as ze,S as De}from"./StickyHorizontalScrollbar-CMbTn5WQ.js";import{u as Ce}from"./runtimeEndpointReset-Dwj-jCDS.js";import{ensurePierreThemeRegistered as ue,getResolvedShikiTheme as he}from"./appThemeRegistry-Ca8eGRB9.js";import{a as de,c as fe}from"./index-CKKWVoND.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 pe({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 p=Math.max(n-i,0),y=Math.min(n+d,e);return{top:p,bottom:Math.max(y,p)}}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 X=0,Le=-1;var _e=class x{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=()=>{x.__STOP?(x.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:x.__lastScrollPosition}),E(this.computeRenderRangeAndEmit)):(x.__lastScrollPosition=this.getScrollTop(),x.__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=pe({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-X,newSize:i}),X=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-X,newSize:i}),X=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=()=>{x.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,E(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{x.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{x.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(x.__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=pe({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 p=U(m,t);if(p!==i){const y=p-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,p;if(h>0&&s<e)for(const w of i.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(w instanceof HTMLElement))continue;const W=w.dataset.lineIndex;if(W==null)continue;const D=U(w,t);if(!(D<0)){m=W,p=D;break}}if(r?.lineOffset!=null&&p==null)continue;let y=!1;(r==null||p!=null&&(r.lineOffset==null||p<r.lineOffset)||p==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:p})}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 ge=5e5,Fe=`
|
|
2
2
|
:host {
|
|
3
3
|
font-family: var(--font-mono);
|
|
4
4
|
font-size: var(--text-code);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useAppFontEffects-
|
|
2
|
-
import{_ as Ne}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as e,aY as We,aZ as Ye,a_ as Qe,a$ as Xe,b0 as Ze}from"./vendor-boot-D-KEJjsM.js";import{R as o}from"./vendor-react-Bz1tRBxM.js";import{h as le,k as Le,u as mt,e as ht,f as ft,l as xt,m as pt,n as gt,r as bt,o as et,t as vt,g as ce,G as yt,a as jt,p as wt,c as kt,d as Ct,i as Nt,j as St}from"./useGitHubRemoteSearch-DIBHNu8r.js";import{j as Ee,t as G,N as Rt,B as P,I as M,bi as Lt,f as tt,D as Me,h as ze,i as Ae,V as Et,W as Ft,af as Se,a1 as we,aY as Pt,aZ as Tt}from"./useAppFontEffects-EcTZ_I_I.js";import{i as I,T as Mt,r as zt,j as At,k as Dt,g as $t,l as Gt,m as Ht,f as qt,n as De,p as It,q as Ot,t as Bt,v as _t,w as Ut,x as Vt,y as Kt,z as Jt}from"./runtimeEndpointReset-BC6yGnxN.js";import{z as Wt,A as Yt,B as Qt,C as Xt,D as st,E as Zt,F as es,H as ge,I as ts,q as ss,J as te,K as ns,L as as,M as ls,N as os,O as fe,u as is,i as rs,P as cs,b as ds,c as $e,j as ke,e as Ce,k as us,f as Ge,h as He,l as qe,m as nt,n as ms,p as Ie,Q as hs,v as fs,w as xs,x as ps,y as gs,R as be,S as he,T as bs,G as vs,U as ys,V as js,W as ws}from"./GitHubDetailScaffold-Jvv_tgbl.js";import{c as xe,E as ks,s as Cs,u as Ns,A as Ss}from"./index-B2v0_mez.js";import{S as ve,d as Rs}from"./GitHubListPrimitives-BWI706F0.js";import{P as Ls}from"./PierreDiffViewer-lwn6w_5w.js";import{c as Es,p as Fs}from"./vendor-zustand-CXhN0IMY.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-kIEoYsPP.js";import"./nativeFileSave-B6QpoPRn.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./SessionUnreadDot-DyeIrsro.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./vendor-dompurify-BGCr_sdL.js";import"./web-components-C_DsTJis.js";import"./computeVirtualFileMetrics-DmO6H8u6.js";import"./vendor-shiki-BEwTOAFg.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.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-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-engine-javascript-DL394yyj.js";import"./vendor-oniguruma-to-es-DgwFOwdE.js";import"./vendor-oniguruma-parser-BrbMHgHx.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-CLgDONEQ.js";import"./renderDiffWithHighlighter-C48T6YFJ.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-CMbTn5WQ.js";import"./appThemeRegistry-Ca8eGRB9.js";import"./registerCustomTheme-C-h6lsYW.js";const Fe=()=>{const t=Ee(),[s,n]=o.useState(null);return{send:o.useCallback(async l=>{const d=t.github;if(!d)return G.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=Wt({kind:l.kind,repo:l.repo,number:l.number,detail:l.detail}),f=Yt({kind:l.kind,repo:l.repo,number:l.number,contextText:c.text}),x=Rt.getState();x.setPendingInputText(r,"append");const k=x.pendingSyntheticParts??[];return x.setPendingSyntheticParts([...k,{text:f,synthetic:!0}]),G.success("Added to composer"),!0}catch(c){return G.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"}},at=t=>{switch((t??"").toLowerCase()){case"added":return"added";case"removed":return"removed";case"modified":return"modified";case"renamed":return"renamed";default:return"other"}},lt=t=>Pe[t].icon,Ms=t=>Pe[t].letter,Re=t=>Pe[t].tint,ot=t=>{const s=t.lastIndexOf("/");return s<0?{dir:"",base:t}:{dir:t.slice(0,s),base:t.slice(s+1)}},it=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},rt=t=>it(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||rt(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(M,{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(M,{name:"delete-bin",className:"size-3.5"})})]}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap break-words",children:t.body})]}),Oe=({thread:t,replyAllowed:s,replyDisabledReason:n,resolveAllowed:a,resolveDisabledReason:l,busy:d,onReply:c,onToggleResolved:r})=>{const[f,x]=o.useState(!t.resolved),[k,m]=o.useState(!1),[g,p]=o.useState(""),[z,F]=o.useState(!1),L=t.comments.length,j=async()=>{const b=g.trim();if(!(b.length===0||z||d)){F(!0);try{await c(b)&&(p(""),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:b=>b.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(M,{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":f,onClick:()=>x(b=>!b),children:[t.resolved?"Resolved":"Open"," · ",L," ",L===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"})]}),f?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 flex flex-col gap-2",children:t.comments.map((b,i)=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"typography-micro text-muted-foreground",children:b.author?.login??"ghost"}),e.jsx(ss,{markdown:b.body,html:b.bodyHtml??null,fallbackUrl:b.url})]},b.id??`${t.id}-${i}`))}),s?k?e.jsxs("div",{className:"mt-2",children:[e.jsx("textarea",{autoFocus:!0,value:g,rows:2,placeholder:"Reply","aria-label":"Reply to this conversation",disabled:z||d,onChange:b=>p(b.target.value),onKeyDown:b=>{b.nativeEvent.isComposing||(b.key==="Escape"&&(b.preventDefault(),m(!1)),b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&!b.shiftKey&&!b.altKey&&!b.repeat&&(b.preventDefault(),b.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:z||d||g.trim().length===0,onClick:()=>{j()},children:z?"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(""),f=o.useRef(null),x=c.trim();o.useLayoutEffect(()=>{const m=window.requestAnimationFrame(()=>{f.current?.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(m)},[]);const k=()=>{x&&l(x)};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:f,value:c,rows:3,placeholder:"Add a comment…","aria-label":`Comment on ${t} line ${s}`,onChange:m=>r(m.target.value),onFocus:m=>{const g=m.currentTarget.value.length;m.currentTarget.setSelectionRange(g,g)},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:!x||n,title:"Send this line to the agent",onClick:()=>d(x),children:n?"Sending…":"Send to agent"}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:!x,onClick:k,children:"Add to review"})]})]})},qs=({file:t,collapsed:s,onToggleCollapse:n,viewed:a,onToggleViewed:l,blobUrl:d,threads:c,directory:r,repo:f,number:x,github:k,access:m,onThreadsChanged:g})=>{const p=I(w=>w.threadAction),z=le(w=>w.removeComment),F=le(w=>w.addComment),L=Le(f,x),[j,b]=o.useState(null),[i,C]=o.useState(!1),{send:h,sendingKey:O}=Fe(),{original:N,modified:E}=o.useMemo(()=>Qt(t.patch),[t.patch]),T=o.useMemo(()=>Xt(t.patch),[t.patch]),B=`pr-${x}-file-${t.filename}`,V=st(m),S=Zt(m),D=es(m),K=o.useCallback(w=>{if(!w||!V.allowed)return;const H=(w.endSide??w.side??"additions")==="deletions"?"deletions":"additions",ie=H==="deletions"?T.syntheticToOld.get(w.end):T.syntheticToNew.get(w.end);if(ie==null){G.error("That line is outside the rendered hunks");return}b({synthLine:w.end,side:H,realLine:ie,realSide:H==="deletions"?"LEFT":"RIGHT"})},[V.allowed,T]),_=at(t.status),{dir:X,base:R}=ot(t.filename),q=rt(t),[y,de]=o.useState(!1),Q=q&&!y&&!a&&t.patch!=null,ee=c.filter(w=>!w.resolved).length,Z=o.useMemo(()=>L.filter(w=>w.path===t.filename),[L,t.filename]),{annotations:se,orphans:ne}=o.useMemo(()=>{const w=new Map,$=[],H=(A,U)=>{const W=`${A}:${U}`;let J=w.get(W);return J||(J={side:A,synthLine:U,threads:[],pendings:[]},w.set(W,J)),J};for(const A of c){const U=A.line??A.originalLine??null;if(U==null){$.push(A);continue}let W,J;if(A.diffSide==="LEFT"?(J="deletions",W=T.oldToSynthetic.get(U)):A.diffSide==="RIGHT"?(J="additions",W=T.newToSynthetic.get(U)):(W=T.newToSynthetic.get(U),J="additions",W==null&&(W=T.oldToSynthetic.get(U),J="deletions")),W==null){$.push(A);continue}H(J,W).threads.push(A)}for(const A of Z){if(A.line==null)continue;const U=A.side==="LEFT"?"deletions":"additions",W=U==="deletions"?T.oldToSynthetic.get(A.line):T.newToSynthetic.get(A.line);W!=null&&H(U,W).pendings.push(A)}return j&&H(j.side,j.synthLine),{annotations:[...w.values()].sort((A,U)=>A.synthLine-U.synthLine).map(A=>({side:A.side,lineNumber:A.synthLine,metadata:{threads:A.threads,pendings:A.pendings,draft:j&&j.side===A.side&&j.synthLine===A.synthLine?{realLine:j.realLine,realSide:j.realSide}:null}})),orphans:$}},[c,Z,j,T]),oe=o.useCallback(async(w,$)=>{const H=w.comments[w.comments.length-1]?.id??null;if(typeof H!="number")return G.error("Cannot reply to this thread yet"),!1;if(i)return!1;C(!0);try{return(await p(r,f,x,w.id,{action:"reply",body:$,commentId:H},k)).ok?(G.success("Reply posted"),g(),!0):(G.error("Failed to post reply"),!1)}finally{C(!1)}},[r,f,x,k,p,i,g]),ae=o.useCallback(w=>{i||(C(!0),p(r,f,x,w.id,w.resolved?{action:"unresolve"}:{action:"resolve"},k).then($=>{$.ok?(G.success(w.resolved?"Thread reopened":"Thread resolved"),g()):G.error("Failed to update thread")}).finally(()=>C(!1)))},[r,f,x,k,p,i,g]),ue=o.useCallback(w=>e.jsxs("div",{className:"flex flex-col gap-1.5 px-3 py-2",contentEditable:!1,onPointerDown:$=>$.stopPropagation(),children:[w.metadata.threads.map($=>e.jsx(Oe,{thread:$,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:D.allowed,resolveDisabledReason:D.reason,busy:i,onReply:H=>oe($,H),onToggleResolved:()=>ae($)},$.id)),w.metadata.pendings.map($=>e.jsx(Gs,{comment:$,onRemove:()=>z(f,x,$.id)},$.id)),w.metadata.draft?e.jsx(Hs,{path:t.filename,line:w.metadata.draft.realLine,sendingToAgent:O===`${B}-draft-agent`,onCancel:()=>b(null),onAddToReview:$=>{const H=w.metadata.draft;H&&(F(f,x,{path:t.filename,body:$,line:H.realLine,side:H.realSide}),b(null),G.success("Added to review"))},onSendToAgent:$=>{const H=w.metadata.draft;H&&h({key:`${B}-draft-agent`,kind:"lines",directory:r,repo:f,number:x,contextType:"pr",contextOptions:{includeDiff:!0},detail:`${t.filename} line ${H.realLine} ("${$.trim()}")`})}}):null]}),[S.allowed,S.reason,D.allowed,D.reason,i,oe,ae,z,F,f,x,t.filename,B,O,r,h]);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(M,{name:s?"arrow-right-s":"arrow-down-s",className:"size-4"})}),e.jsx(M,{name:lt(_),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(M,{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(Lt,{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:()=>{h({key:`${B}-agent`,kind:"file",directory:r,repo:f,number:x,contextType:"pr",contextOptions:{includeDiff:!0},detail:t.filename})},disabled:O===`${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(Oe,{thread:w,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:D.allowed,resolveDisabledReason:D.reason,busy:i,onReply:$=>oe(w,$),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(M,{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 — ",it(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:ts(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(M,{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=I(i=>i.addComment),f=I(i=>i.performAction),x=le(i=>i.clearCommentDraft),{draft:k,onDraftChange:m,flushDraft:g}=mt(s,n),{busy:p,error:z,submit:F}=ht({postComment:i=>r(t,s,n,i,a),runFollowUp:i=>f(t,s,n,i,a),verbs:{close:"close",reopen:"reopen"},doneLabels:{close:"Closed with comment",reopen:"Reopened with comment"},afterPost:()=>{m(""),x(s,n),c()}}),L=st(d),j=l.state==="open"?"close":l.state==="closed"?"reopen":null,b=j?te(j,l,d):null;return L.allowed?e.jsx(ft,{draft:k,onDraftChange:m,onDraftBlur:g,ariaLabel:"Leave a comment on this pull request",busy:p,error:z,disabledReason:L.reason,followUp:j?{id:j,label:j==="close"?"Close with comment":"Reopen with comment",busyLabel:j==="close"?"Closing…":"Reopening…",onRun:()=>{F(j,k)},allowed:b?.allowed===!0,reason:b?.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:f})=>{const x=le(p=>p.setSummary),k=le(p=>p.setVerdict),m=n.includes(l)?l:n[0]??"comment",g=as({verdict:m,summary:a,pendingCount:d});return e.jsxs("div",{children:[e.jsx(Mt,{ref:r,rows:3,value:a,placeholder:"Summarize your review (optional)","aria-label":"Review summary",disabled:c,onChange:p=>x(t,s,p.target.value),onKeyDown:p=>{p.nativeEvent.isComposing||p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&!p.shiftKey&&!p.altKey&&!p.repeat&&(p.preventDefault(),p.stopPropagation(),g&&!c&&f())}}),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:p=>k(t,s,p.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(p=>e.jsx("option",{value:p,children:Bs[p]},p))})]}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:c||!g,title:g?`Submit review${d>0?` with ${d} ${d===1?"line comment":"line comments"}`:""}`:"Add a summary or a line comment first",onClick:f,children:c?"Submitting…":"Submit review"})]})]})},ct=({directory:t,repo:s,number:n,github:a,access:l,size:d="sm",onReviewSubmitted:c})=>{const r=I(T=>T.submitReview),f=le(T=>T.removeComments),x=le(T=>T.clearSummary),k=le(T=>T.clearComments),m=Le(s,n),g=xt(s,n),p=pt(s,n),[z,F]=o.useState(!1),[L,j]=o.useState(!1),b=o.useRef(null),i=o.useMemo(()=>ns(l),[l]),C=i.includes(p)?p:i[0]??"comment",h=m.length,O=h>0||g.trim().length>0;if(o.useEffect(()=>{if(!z)return;const T=window.requestAnimationFrame(()=>b.current?.focus({preventScroll:!0}));return()=>window.cancelAnimationFrame(T)},[z]),i.length===0)return null;const N=async()=>{if(L)return;const T=g,B=[...m];j(!0);try{const V=B.map(D=>({path:D.path,body:D.body,...D.line!=null?{line:D.line}:{},...D.side?{side:D.side}:{}})),S=await r(t,s,n,{event:C,body:T.trim()?T:void 0,comments:V},a);if(!S.ok){G.error(S.error?.kind==="failed"?S.error.message:"Failed to submit review");return}f(s,n,B.map(D=>D.id)),x(s,n,T),G.success(C==="approve"?"Pull request approved":C==="request-changes"?"Changes requested":"Review submitted"),F(!1),c?.()}finally{j(!1)}},E=h>0?`Review · ${h}`:"Review";return e.jsxs(We,{open:z,onOpenChange:F,children:[e.jsxs(Ye,{render:e.jsx(P,{type:"button",variant:h>0?"default":"outline",size:d,className:"shrink-0","aria-label":h>0?`Review pull request, ${h} ${h===1?"line comment":"line comments"} pending`:"Review pull request",title:O?"Finish your review":"Approve, request changes, or comment with a review"}),children:[e.jsx(M,{name:"file-check",className:"size-3.5","aria-hidden":"true"}),E]}),e.jsx(Qe,{children:e.jsx(Xe,{className:"z-50",side:"top",align:"end",sideOffset:8,collisionPadding:8,children:e.jsxs(Ze,{"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:h>0?`Review · ${h} ${h===1?"line comment":"line comments"}`:"Review pull request"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[h>0?e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Discard pending line comments",title:"Discard pending line comments",disabled:L,onClick:()=>k(s,n),className:"size-6",children:e.jsx(M,{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(M,{name:"close",className:"size-3.5"})})]})]}),e.jsx(_s,{repo:s,number:n,verdicts:i,summary:g,verdict:C,pendingCount:h,busy:L,textareaRef:b,onSubmit:()=>{N()}})]})})})]})},ye=(t,s)=>`${t}#${s}`,Be=50,Us=Object.freeze([]),_e=(t,s)=>{const n=Object.keys(t);if(n.length<=Be)return t;const a={};for(const l of n.slice(n.length-Be))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(x=>{const k=x.entries[c]??{viewed:[],headSha:null},m=d?[...k.viewed,l]:k.viewed.filter(g=>g!==l);return{entries:_e({...x.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:_e({...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),Ue=20,Js=[],Ws=[],Ve=t=>`pr-file-${encodeURIComponent(t)}`,dt=o.memo(({file:t,viewed:s,threadCount:n,pendingCount:a,showDir:l,onSelectFile:d})=>{const c=at(t.status),{dir:r,base:f}=ot(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(M,{name:lt(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:f})]}),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(M,{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(M,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]","aria-label":"Viewed"}):null]})});dt.displayName="FileJumpRow";const ut=({files:t,viewedPaths:s,threadCounts:n,pendingCounts:a,onSelectFile:l})=>{const[d,c]=o.useState(""),r=o.useMemo(()=>zs(t),[t]),f=o.useMemo(()=>new Set(s),[s]),x=d.trim().toLowerCase(),k=o.useMemo(()=>x?r.map(m=>({...m,files:m.files.filter(g=>g.filename.toLowerCase().includes(x))})).filter(m=>m.files.length>0):r,[r,x]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-1",children:[e.jsx(tt,{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(g=>e.jsx(dt,{file:g,viewed:f.has(g.filename),threadCount:n.get(g.filename)??0,pendingCount:a.get(g.filename)??0,showDir:r.length<=1,onSelectFile:l},g.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(We,{open:s,onOpenChange:n,children:[e.jsxs(Ye,{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(M,{name:"file",className:"size-3.5","aria-hidden":"true"}),"Files"]}),e.jsx(Qe,{children:e.jsx(Xe,{className:"z-50",side:"bottom",align:"start",sideOffset:4,collisionPadding:8,children:e.jsx(Ze,{"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(ut,{...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(f=>f===r?f: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,f=Vs(n,a),x=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]),g=o.useRef(m);g.current=m;const p=o.useRef(r);p.current=r;const[z,F]=o.useState({}),[L,j]=o.useState(Ue),b=o.useMemo(()=>As(r),[r]),i=o.useMemo(()=>{const R=new Map;for(const q of t.threads){if(!q.path)continue;const y=R.get(q.path)??[];y.push(q),R.set(q.path,y)}return R},[t.threads]),C=o.useMemo(()=>{const R=new Map;for(const[q,y]of i)R.set(q,y.length);return R},[i]),h=o.useMemo(()=>{const R=new Map;for(const q of k)R.set(q.path,(R.get(q.path)??0)+1);return R},[k]),O=o.useCallback(R=>{F(q=>({...q,[R]:!(q[R]??g.current[R]??!1)}))},[]),N=o.useCallback(()=>{F(Object.fromEntries(p.current.map(R=>[R.filename,!1])))},[]),E=o.useCallback(()=>{F(Object.fromEntries(p.current.map(R=>[R.filename,!0])))},[]),T=o.useCallback((R,q)=>{pe.getState().setViewed(n,a,R,q),F(y=>({...y,[R]:q}))},[n,a]),B=o.useCallback(R=>{F(y=>y[R]??g.current[R]??!1?{...y,[R]:!1}:y);const q=p.current.findIndex(y=>y.filename===R);q>=0&&j(y=>q<y?y:q+1),requestAnimationFrame(()=>{document.getElementById(Ve(R))?.scrollIntoView({block:"start"})})},[]),V=o.useMemo(()=>r.slice(0,L),[r,L]),S=o.useRef(null),D=Xs(S,V.length>0),K=o.useMemo(()=>new Set(f),[f]),_=r.length===1?"1 file":`${r.length} files`,X=r.length===0?"Nothing viewed yet":`${x}/${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:b.additions,deletions:b.deletions}),e.jsxs("span",{className:"shrink-0 tabular-nums text-muted-foreground","aria-label":X,children:[x,"/",r.length," viewed"]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[e.jsx(ct,{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:f,threadCounts:C,pendingCounts:h,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(M,{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(M,{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:D!=null?{height:D}:void 0,className:"sticky top-10 hidden max-h-[calc(100dvh-10rem)] w-60 shrink-0 flex-col @4xl:flex",children:e.jsx(ut,{files:r,viewedPaths:f,threadCounts:C,pendingCounts:h,onSelectFile:B})}),e.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:V.map(R=>e.jsx("div",{id:Ve(R.filename),className:"scroll-mt-12",children:e.jsx(Is,{file:R,collapsed:z[R.filename]??m[R.filename]??!1,onToggleCollapse:O,viewed:K.has(R.filename),onToggleViewed:T,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>L?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>j(L+Ue),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:f})=>{const[x,k]=o.useState({}),[m,g]=o.useState({}),{send:p,sendingKey:z}=Fe(),F=ls(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:()=>{p({key:`pr-${n}-failed-checks`,kind:"checks",directory:t,repo:s,number:n,contextType:"checks"})},disabled:z===`pr-${n}-failed-checks`,"aria-label":"Send failed checks to agent",title:"Send failed checks to agent",children:[e.jsx(M,{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(M,{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:x,onToggleJob:L=>k(j=>({...j,[L]:!j[L]})),jobSteps:m,setJobSteps:g,sendingKey:z,send:p,onOpenFilesAtLine:f}):null]})},tn=({checks:t,directory:s,repo:n,number:a,github:l,expandedJobs:d,onToggleJob:c,jobSteps:r,setJobSteps:f,sendingKey:x,send:k,onOpenFilesAtLine:m})=>{const g=I(i=>i.rerunFailedChecks),[p,z]=o.useState({}),F=async i=>{const C=`run-${i.id??i.name}`;if(c(C),!(d[C]||r[C]||i.id==null)){f(h=>({...h,[C]:{steps:[],loading:!0}}));try{const O=(await l.checkJobs(s,n,i.runId??null,i.id)).jobs[0];f(E=>({...E,[C]:{steps:O?.steps??[],loading:!1}}));const N=await l.checkAnnotations(s,n,i.id).catch(()=>null);N&&z(E=>({...E,[i.id]:{loading:!1,items:N.annotations}}))}catch{f(h=>({...h,[C]:{steps:[],loading:!1}}))}}},L=async i=>{(await g(s,n,i,l)).ok?G.success("Re-run requested"):G.error("Re-run failed")},j=i=>{const C=`run-${i.id??i.name}`,h=d[C]??!1,O=r[C],N=os(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":h,"aria-label":`${h?"Collapse":"Expand"} ${i.name}`,children:"Details"}),N&&i.runId!=null?e.jsx(P,{type:"button",variant:"outline",size:"xs",onClick:()=>{L(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:x===`${C}-agent`,"aria-label":`Send ${i.name} to agent`,children:"Send to agent"}):null]}),h?e.jsxs("div",{className:"mt-1.5 flex flex-col gap-1 border-t border-border/60 pt-1.5",children:[O?.loading?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Loading steps…"}):null,(O?.steps??[]).map((E,T)=>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}-${T}`)),i.id!=null&&p[i.id]?.items?.length?e.jsx("div",{className:"flex flex-col gap-1",children:p[i.id]?.items.map((E,T)=>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]},T))}):null]}):null]},C)},b=(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(b)}):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]})},Ke=({pr:t})=>e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(nt,{login:t.author?.login,avatarUrl:t.author?.avatarUrl,size:"xs"}),t.author?.login??"ghost"]}),t.updatedAt?` · updated ${gs(t.updatedAt)}`:"",t.draft?" · Draft":""]}),Je=({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(M,{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:f,onCopyLink:x,askSending:k,onAskAgent:m})=>{const g=I(N=>N.setMergeMethod),p=s.state==="open",z=be.filter(N=>te(N.id,s,n).allowed),F=z.some(N=>N.id===l)?l:z[0]?.id??l,L=te(F,s,n),j=te("ready",s,n),b=te("draft",s,n),i=te("close",s,n),C=te("reopen",s,n),h=be.find(N=>N.id===F)??be[0],O=z.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:[p&&!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:!L.allowed,disabledReason:L.reason??`Merge via ${h.label}`,label:F==="merge"?"Merge pull request":h.label,icon:e.jsx(M,{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:O,children:e.jsx(M,{name:"arrow-down-s",className:"size-3.5"})})}),e.jsx(Ae,{align:"start",className:"w-72",children:e.jsx(Et,{value:F,onValueChange:N=>{const E=N;d(E),g(t,E)},children:be.map(N=>{const E=te(N.id,s,n);return e.jsx(Ft,{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,p&&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(M,{name:"git-pull-request",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("ready")}):null,p&&!s.draft?e.jsx(ce,{copy:he("draft",s.base,s.head),busy:a,variant:"outline",disabled:!b.allowed,disabledReason:b.reason??"Convert to draft",label:"Convert to draft",icon:e.jsx(M,{name:"pencil",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("draft")}):null,p?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(M,{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(M,{name:"history",className:"size-3.5","aria-hidden":"true"}),"Reopen"]}),e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>f("worktree"),disabled:r,title:"Check out in a new worktree","aria-label":"Check out in a new worktree",children:[e.jsx(M,{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(M,{name:"git-branch",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>f("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(M,{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(M,{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(M,{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(M,{name:"external-link",className:"size-3.5"}),"Open on GitHub"]}),e.jsxs(we,{onClick:x,children:[e.jsx(M,{name:"file-copy",className:"size-3.5"}),"Copy link"]}),e.jsx(Pt,{}),e.jsxs(we,{onClick:()=>f("worktree"),disabled:r,children:[e.jsx(M,{name:"git-branch",className:"size-3.5"}),"Check out in new worktree"]})]})]})]})},nn=({pr:t,access:s,acting:n,onRun:a})=>{const l=bs(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(M,{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(M,{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(M,{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=I(u=>u.performAction),r=I(u=>u.updateTitleBody),f=I(u=>u.checkout),[x,k]=o.useState("summary"),[m,g]=o.useState(!1),[p,z]=o.useState(()=>zt(n)??"merge"),[F,L]=o.useState(!1),[j,b]=o.useState(""),[i,C]=o.useState(!1),[h,O]=o.useState(""),[N,E]=o.useState("newest"),[T,B]=o.useState(1),[V,S]=o.useState(!1),[D,K]=o.useState(null),_=gt(n,a),{send:X,sendingKey:R}=Fe(),q=is(s,n),y=d?.pr??null,de=d?.sectionErrors??null,Q=o.useMemo(()=>({capabilities:d?.capabilities??null,isAuthor:rs(y?.author?.login,d?.viewerLogin),permissionFallback:d?.viewerPermission?.fallback===!0}),[d?.capabilities,d?.viewerLogin,d?.viewerPermission?.fallback,y?.author?.login]),ee=cs(y,Q);o.useEffect(()=>{k("summary"),L(!1),C(!1),B(1),K(null)},[n,a]);const Z=o.useCallback(async u=>{g(!0);try{const Y=await c(s,n,a,u,l);if(!Y.ok){G.error(Y.error?.kind==="failed"?Y.error.message:"Action failed");return}u==="close"?G.success("Pull request closed"):u==="reopen"?G.success("Pull request reopened"):u==="update-branch"?G.success("Branch update requested"):u==="ready"?G.success("Marked as ready for review"):u==="draft"?G.success("Converted to draft"):G.success("Pull request merged")}finally{g(!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()){G.error("Enter a title");return}const u=await r(s,n,a,{title:j.trim()},l);u.ok?(G.success("Title updated"),L(!1)):G.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:h},l);u.ok?(G.success("Description updated"),C(!1)):G.error(u.error?.kind==="failed"?u.error.message:"Failed to update description")},[h,s,n,a,l,r]),ae=Ee().git,ue=o.useCallback(async u=>{if(u==="current"){const Y=await Ne(()=>import("./useAppFontEffects-EcTZ_I_I.js").then(re=>re.eQ),__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){G.error("Working tree has uncommitted changes. Commit or stash first, or use New worktree.");return}}S(!0);try{const Y=await f(s,n,a,u,l);Y.ok?(await bt(s,ae),K({path:Y.path??null,branch:Y.branch??""}),G.success(u==="worktree"?"Worktree created":"Branch checked out")):G.error(Y.error?.kind==="failed"?Y.error.message:"Checkout failed")}finally{S(!1)}},[s,n,a,l,ae,f]),w=o.useCallback(()=>{D?.path&&Ne(async()=>{const{useSessionUIStore:u}=await import("./useAppFontEffects-EcTZ_I_I.js").then(Y=>Y.eN);return{useSessionUIStore:u}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({useSessionUIStore:u})=>{u.getState().openNewSessionDraft({directoryOverride:D.path}),Ns.getState().setActiveMainTab("chat")})},[D]),$=ds(y?.url),H=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]),A=H.slice(0,T*20),U=A.filter(u=>!$e(u.author?.login)),W=A.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:q,number:a,openLabel:`Open pull request #${a} on GitHub`,title:`Pull request #${a}`}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(et,{info:vt(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:q,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(Ke,{pr:u}):void 0,branches:u?e.jsx(Je,{pr:u,filesCount:u.changedFiles??null}):void 0}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(us,{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:q,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:()=>{b(y.title),L(!0)},editTitleLabel:"Edit pull request title",editTitleDisabledReason:ee.allowed?null:ee.reason,meta:e.jsx(Ke,{pr:y}),branches:e.jsx(Je,{pr:y,filesCount:me})}),e.jsx(sn,{directory:s,repo:n,number:a,github:l,pr:y,access:Q,acting:m,mergeMethod:p,onMergeMethodChange:z,onRun:u=>{Z(u)},checkingOut:V,onCheckout:u=>{ue(u)},onCopyLink:$,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:x,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(tt,{value:j,onChange:u=>b(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:()=>L(!1),children:"Cancel"})]}):null,D?e.jsxs("p",{className:"flex flex-wrap items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(M,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]"}),e.jsxs("span",{children:["Ready on ",D.branch,D.path?` at ${D.path}`:"","."]}),D.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,x==="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(nt,{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(ms,{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:()=>{O(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:h,onChange:u=>O(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(hs,{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${H.length?` (${H.length})`:""}`,action:e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",children:[t.hideFilesTab?e.jsx(ct,{directory:s,repo:n,number:a,github:l,access:Q,size:"xs",onReviewSubmitted:t.onRetryDetail}):null,e.jsx(ps,{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(fs,{comment:u},u.id)),e.jsx(xs,{comments:W}),t.commentsLoading&&H.length===0&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Loading comments…"}):null,H.length===0&&!t.commentsLoading&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"No comments yet."}):null,H.length>A.length?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>B(T+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,x==="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,x==="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:f,incompleteNotice:x=null,remote:k=null,numberJump:m=null,onFiltersChange:g,onClearFilters:p,onLoadMore:z,onRetry:F,onOpen:L,headerActionsSlot:j=null,headerActionsPresentation:b="drawer"})=>{const i=r.state==="open"&&r.involvement==="all"&&!r.search.trim(),C=o.useCallback(h=>e.jsx("li",{role:"listitem",children:e.jsx(yt,{glyph:e.jsx(vs,{kind:"pr",state:h.state,draft:h.draft}),glyphBelow:e.jsx(fe,{state:(h.url?f[h.url]:void 0)??null}),number:`#${h.number}`,title:h.title,status:e.jsx(ge,{additions:h.additions,deletions:h.deletions,className:"typography-micro"}),meta:e.jsxs(e.Fragment,{children:[e.jsx(jt,{login:h.author?.login,avatarUrl:h.author?.avatarUrl}),e.jsx(wt,{head:h.head,base:h.base}),h.draft?e.jsx("span",{className:"shrink-0 rounded bg-[var(--surface-muted)] px-1 typography-micro text-muted-foreground",children:"Draft"}):null]}),updatedAt:h.updatedAt,onOpen:()=>L(h.number),ariaLabel:`Open pull request #${h.number} ${h.title}`})},h.number),[f,L]);return e.jsx(kt,{items:t,renderRow:C,hasMore:s,isLoadingMore:n,isLoading:a,isRefreshing:l,stale:d,error:c,searchValue:r.search,onSearchChange:h=>g({search:h}),searchPlaceholder:"Search pull requests, or label:bug",searchAriaLabel:"Search pull requests",toolbarControls:e.jsx(Ct,{stateValue:r.state,stateOptions:ws.map(h=>({id:h.id,label:h.label})),onStateChange:h=>g({state:h}),involvementValue:r.involvement,involvementOptions:js.map(h=>({id:h.id,label:h.label})),onInvolvementChange:h=>g({involvement:h}),sortValue:r.sort,sortOptions:ys.map(h=>({id:h.id,label:h.label})),onSortChange:h=>g({sort:h}),sortAriaLabel:"Sort pull requests"}),headerActionsSlot:j,headerActionsPresentation:b,isDefaultFilters:i,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",incompleteNotice:x,remote:k,numberJump:m,numberJumpKind:"pull request",onClearFilters:p,onLoadMore:z,onRetry:F,onOpen:L})},on=t=>{const s=At(n=>n.results);return o.useMemo(()=>{const n=Dt(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=Tt()??"";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),[f,x]=o.useState(!1),k=o.useRef(null);return o.useEffect(()=>$t(),[]),e.jsx(Nt,{directory:t,isRefreshing:c,onRefresh:()=>k.current?.(),children:({repo:m,directory:g})=>e.jsx(cn,{directory:g,repo:m,github:d,refreshing:c,setRefreshing:r,loadingMore:f,setLoadingMore:x,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:f,headerActionsSlot:x=null,headerActionsPresentation:k="drawer"})=>{const m=I(v=>v.ensureCollectionsFresh),g=I(v=>v.searchRemote),p=I(v=>v.loadMoreRemote),z=I(v=>v.loadMoreCollection),F=I(v=>v.refreshAllForScope),L=I(v=>v.selectPullRequest),j=I(v=>v.setFilters),b=I(v=>v.resetFilters),i=Gt(t,s),C=Ht(t),h=qt(),O=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"),T=De(s,"closed"),B=o.useMemo(()=>It(s),[s,E?.data,T?.data]),V=o.useMemo(()=>new Set(B.map(v=>v.number)),[B]),S=o.useMemo(()=>Ot(B,{state:i.state,involvement:i.involvement,search:i.search,sort:i.sort,viewerLogin:h}),[B,i.state,i.involvement,i.search,i.sort,h]),D=on(S),K=N==="both"?[E,T]:[N==="open"?E:T],_=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),q=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"&&!h,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?g(t,s,v,n):Promise.resolve(null),[t,s,n,g]),ue=o.useCallback(v=>n?p(t,s,v,n):Promise.resolve(null),[t,s,n,p]),{remoteView:w,numberJump:$,remotePending:H,handleSearchAll:ie}=St({repo:s,query:se,queryKey:ne,autoRemote:oe,indexNumbers:V,visibleItems:S,searchText:Q,useRemoteEntry:Jt,runSearch:ae,runLoadMore:ue}),A=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=>z(t,s,u,n))).then(()=>c(!1)).catch(()=>c(!1))},[t,s,N,n,z,c]),J=o.useCallback(v=>{L(t,s,v)},[t,s,L]),me=o.useCallback(()=>{L(t,null,null)},[t,L]);return n?O!=null?e.jsx(dn,{directory:t,repo:s,number:O,github:n,onBack:me,hideFilesTab:f,seed:Bt(s,O)}):e.jsx(ln,{items:S,headerActionsSlot:x,headerActionsPresentation:k,hasMore:K.some(v=>v?.data?.nextCursor!=null),isLoadingMore:d,isLoading:y,isRefreshing:a&&_,stale:de,error:q,filters:i,checksByUrl:D,incompleteNotice:A?{summary:A,searching:H,onSearchAll:ie}:null,remote:w,numberJump:$,onFiltersChange:v=>j(t,s,v),onClearFilters:()=>b(t,s),onLoadMore:W,onRetry:U,onOpen:J}):e.jsx(et,{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=I(S=>S.ensureDetail),f=I(S=>S.ensureComments),x=I(S=>S.ensureFiles),k=I(S=>S.ensureChecks),m=I(S=>S.loadMoreFiles),g=I(S=>S.loadMoreComments),p=I(S=>S.refreshComments),z=I(S=>S.refreshDetail),F=I(S=>S.refreshChecks);o.useEffect(()=>{r(t,s,n,a).catch(()=>{}),f(t,s,n,a).catch(()=>{}),d||x(t,s,n,a).catch(()=>{}),k(t,s,n,a).catch(()=>{})},[t,s,n,d]);const L=_t(s,n),j=Ut(s,n),b=Vt(s,n),i=Kt(s,n),C=L?.data?.detail??null,h=o.useCallback((S,D)=>{const K=Ss(t);Ne(async()=>{const{useUIStore:_}=await import("./index-B2v0_mez.js").then(X=>X.cM);return{useUIStore:_}},__vite__mapDeps([1,2,3,4,5,6,7,8])).then(({useUIStore:_})=>{_.getState().openContextFileAtLine(K,S,D)}).catch(()=>{})},[t]),O=o.useCallback(()=>{m(t,s,n,a).catch(()=>{})},[t,s,n,a,m]),N=o.useCallback(()=>{g(t,s,n,a).catch(()=>{})},[t,s,n,a,g]),E=o.useCallback(()=>{p(t,s,n,a).catch(()=>{})},[t,s,n,a,p]),T=o.useCallback(()=>{z(t,s,n,a).catch(()=>{})},[t,s,n,a,z]),B=o.useCallback(()=>{x(t,s,n,a).catch(()=>{})},[t,s,n,a,x]),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:L?.error??null,detailStale:L?.stale??!1,files:b?.data??null,filesError:b?.error??null,filesLoading:b?.isLoading??!1,filesHasMore:b?.data?.nextCursor!=null,onLoadMoreFiles:O,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:T,onRetryFiles:B,onRetryChecks:V,onOpenFilesAtLine:h})};export{da as PullRequestsSurface};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useAppFontEffects-CV5UyTRw.js","assets/index-CKKWVoND.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js","assets/index-B_L9GVYw.css","assets/vendor-boot-D-KEJjsM.js","assets/runtimeSurface-0K7vuUpd.js","assets/nativeFileSave-DSMsJqXM.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as Ne}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as e,aY as We,aZ as Ye,a_ as Ze,a$ as Qe,b0 as Xe}from"./vendor-boot-D-KEJjsM.js";import{R as o}from"./vendor-react-Bz1tRBxM.js";import{h as le,k as Le,u as mt,e as ht,f as ft,l as xt,m as pt,n as gt,r as bt,o as et,t as vt,g as ce,G as yt,a as jt,p as wt,c as kt,d as Ct,i as Nt,j as St}from"./useGitHubRemoteSearch-CgP-zEBj.js";import{j as Ee,t as G,N as Rt,B as P,I as M,bi as Lt,f as tt,D as Me,h as ze,i as Ae,V as Et,W as Ft,af as Se,a0 as we,aY as Pt,aZ as Tt}from"./useAppFontEffects-CV5UyTRw.js";import{i as I,T as Mt,r as zt,j as At,k as Dt,g as $t,l as Gt,m as Ht,f as qt,n as De,p as It,q as Ot,t as Bt,v as _t,w as Ut,x as Vt,y as Kt,z as Jt}from"./runtimeEndpointReset-Dwj-jCDS.js";import{z as Wt,A as Yt,B as Zt,C as Qt,D as st,E as Xt,F as es,H as ge,I as ts,q as ss,J as te,K as ns,L as as,M as ls,N as os,O as fe,u as is,i as rs,P as cs,b as ds,c as $e,j as ke,e as Ce,k as us,f as Ge,h as He,l as qe,m as nt,n as ms,p as Ie,Q as hs,v as fs,w as xs,x as ps,y as gs,R as be,S as he,T as bs,G as vs,U as ys,V as js,W as ws}from"./GitHubDetailScaffold-DM2DH7o8.js";import{c as xe,E as ks,s as Cs,u as Ns,A as Ss}from"./index-CKKWVoND.js";import{S as ve,d as Rs}from"./GitHubListPrimitives-CibDiJGq.js";import{P as Ls}from"./PierreDiffViewer-UY7Cse-s.js";import{c as Es,p as Fs}from"./vendor-zustand-CXhN0IMY.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-0K7vuUpd.js";import"./nativeFileSave-DSMsJqXM.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./SessionUnreadDot-Dwc3MdvA.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./vendor-dompurify-BGCr_sdL.js";import"./web-components-BpncHjnV.js";import"./computeVirtualFileMetrics-DJQqK49u.js";import"./vendor-shiki-BEwTOAFg.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.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-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-engine-javascript-DL394yyj.js";import"./vendor-oniguruma-to-es-DgwFOwdE.js";import"./vendor-oniguruma-parser-BrbMHgHx.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-BGZiLPe_.js";import"./renderDiffWithHighlighter-BXhnIAHg.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-CMbTn5WQ.js";import"./appThemeRegistry-Ca8eGRB9.js";import"./registerCustomTheme-C-h6lsYW.js";const Fe=()=>{const t=Ee(),[s,n]=o.useState(null);return{send:o.useCallback(async l=>{const d=t.github;if(!d)return G.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=Wt({kind:l.kind,repo:l.repo,number:l.number,detail:l.detail}),f=Yt({kind:l.kind,repo:l.repo,number:l.number,contextText:c.text}),x=Rt.getState();x.setPendingInputText(r,"append");const k=x.pendingSyntheticParts??[];return x.setPendingSyntheticParts([...k,{text:f,synthetic:!0}]),G.success("Added to composer"),!0}catch(c){return G.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"}},at=t=>{switch((t??"").toLowerCase()){case"added":return"added";case"removed":return"removed";case"modified":return"modified";case"renamed":return"renamed";default:return"other"}},lt=t=>Pe[t].icon,Ms=t=>Pe[t].letter,Re=t=>Pe[t].tint,ot=t=>{const s=t.lastIndexOf("/");return s<0?{dir:"",base:t}:{dir:t.slice(0,s),base:t.slice(s+1)}},it=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},rt=t=>it(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||rt(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(M,{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(M,{name:"delete-bin",className:"size-3.5"})})]}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap break-words",children:t.body})]}),Oe=({thread:t,replyAllowed:s,replyDisabledReason:n,resolveAllowed:a,resolveDisabledReason:l,busy:d,onReply:c,onToggleResolved:r})=>{const[f,x]=o.useState(!t.resolved),[k,m]=o.useState(!1),[g,p]=o.useState(""),[z,F]=o.useState(!1),L=t.comments.length,j=async()=>{const b=g.trim();if(!(b.length===0||z||d)){F(!0);try{await c(b)&&(p(""),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:b=>b.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(M,{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":f,onClick:()=>x(b=>!b),children:[t.resolved?"Resolved":"Open"," · ",L," ",L===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"})]}),f?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 flex flex-col gap-2",children:t.comments.map((b,i)=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"typography-micro text-muted-foreground",children:b.author?.login??"ghost"}),e.jsx(ss,{markdown:b.body,html:b.bodyHtml??null,fallbackUrl:b.url})]},b.id??`${t.id}-${i}`))}),s?k?e.jsxs("div",{className:"mt-2",children:[e.jsx("textarea",{autoFocus:!0,value:g,rows:2,placeholder:"Reply","aria-label":"Reply to this conversation",disabled:z||d,onChange:b=>p(b.target.value),onKeyDown:b=>{b.nativeEvent.isComposing||(b.key==="Escape"&&(b.preventDefault(),m(!1)),b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&!b.shiftKey&&!b.altKey&&!b.repeat&&(b.preventDefault(),b.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:z||d||g.trim().length===0,onClick:()=>{j()},children:z?"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(""),f=o.useRef(null),x=c.trim();o.useLayoutEffect(()=>{const m=window.requestAnimationFrame(()=>{f.current?.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(m)},[]);const k=()=>{x&&l(x)};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:f,value:c,rows:3,placeholder:"Add a comment…","aria-label":`Comment on ${t} line ${s}`,onChange:m=>r(m.target.value),onFocus:m=>{const g=m.currentTarget.value.length;m.currentTarget.setSelectionRange(g,g)},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:!x||n,title:"Send this line to the agent",onClick:()=>d(x),children:n?"Sending…":"Send to agent"}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:!x,onClick:k,children:"Add to review"})]})]})},qs=({file:t,collapsed:s,onToggleCollapse:n,viewed:a,onToggleViewed:l,blobUrl:d,threads:c,directory:r,repo:f,number:x,github:k,access:m,onThreadsChanged:g})=>{const p=I(w=>w.threadAction),z=le(w=>w.removeComment),F=le(w=>w.addComment),L=Le(f,x),[j,b]=o.useState(null),[i,C]=o.useState(!1),{send:h,sendingKey:O}=Fe(),{original:N,modified:E}=o.useMemo(()=>Zt(t.patch),[t.patch]),T=o.useMemo(()=>Qt(t.patch),[t.patch]),B=`pr-${x}-file-${t.filename}`,V=st(m),S=Xt(m),D=es(m),K=o.useCallback(w=>{if(!w||!V.allowed)return;const H=(w.endSide??w.side??"additions")==="deletions"?"deletions":"additions",ie=H==="deletions"?T.syntheticToOld.get(w.end):T.syntheticToNew.get(w.end);if(ie==null){G.error("That line is outside the rendered hunks");return}b({synthLine:w.end,side:H,realLine:ie,realSide:H==="deletions"?"LEFT":"RIGHT"})},[V.allowed,T]),_=at(t.status),{dir:Q,base:R}=ot(t.filename),q=rt(t),[y,de]=o.useState(!1),Z=q&&!y&&!a&&t.patch!=null,ee=c.filter(w=>!w.resolved).length,X=o.useMemo(()=>L.filter(w=>w.path===t.filename),[L,t.filename]),{annotations:se,orphans:ne}=o.useMemo(()=>{const w=new Map,$=[],H=(A,U)=>{const W=`${A}:${U}`;let J=w.get(W);return J||(J={side:A,synthLine:U,threads:[],pendings:[]},w.set(W,J)),J};for(const A of c){const U=A.line??A.originalLine??null;if(U==null){$.push(A);continue}let W,J;if(A.diffSide==="LEFT"?(J="deletions",W=T.oldToSynthetic.get(U)):A.diffSide==="RIGHT"?(J="additions",W=T.newToSynthetic.get(U)):(W=T.newToSynthetic.get(U),J="additions",W==null&&(W=T.oldToSynthetic.get(U),J="deletions")),W==null){$.push(A);continue}H(J,W).threads.push(A)}for(const A of X){if(A.line==null)continue;const U=A.side==="LEFT"?"deletions":"additions",W=U==="deletions"?T.oldToSynthetic.get(A.line):T.newToSynthetic.get(A.line);W!=null&&H(U,W).pendings.push(A)}return j&&H(j.side,j.synthLine),{annotations:[...w.values()].sort((A,U)=>A.synthLine-U.synthLine).map(A=>({side:A.side,lineNumber:A.synthLine,metadata:{threads:A.threads,pendings:A.pendings,draft:j&&j.side===A.side&&j.synthLine===A.synthLine?{realLine:j.realLine,realSide:j.realSide}:null}})),orphans:$}},[c,X,j,T]),oe=o.useCallback(async(w,$)=>{const H=w.comments[w.comments.length-1]?.id??null;if(typeof H!="number")return G.error("Cannot reply to this thread yet"),!1;if(i)return!1;C(!0);try{return(await p(r,f,x,w.id,{action:"reply",body:$,commentId:H},k)).ok?(G.success("Reply posted"),g(),!0):(G.error("Failed to post reply"),!1)}finally{C(!1)}},[r,f,x,k,p,i,g]),ae=o.useCallback(w=>{i||(C(!0),p(r,f,x,w.id,w.resolved?{action:"unresolve"}:{action:"resolve"},k).then($=>{$.ok?(G.success(w.resolved?"Thread reopened":"Thread resolved"),g()):G.error("Failed to update thread")}).finally(()=>C(!1)))},[r,f,x,k,p,i,g]),ue=o.useCallback(w=>e.jsxs("div",{className:"flex flex-col gap-1.5 px-3 py-2",contentEditable:!1,onPointerDown:$=>$.stopPropagation(),children:[w.metadata.threads.map($=>e.jsx(Oe,{thread:$,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:D.allowed,resolveDisabledReason:D.reason,busy:i,onReply:H=>oe($,H),onToggleResolved:()=>ae($)},$.id)),w.metadata.pendings.map($=>e.jsx(Gs,{comment:$,onRemove:()=>z(f,x,$.id)},$.id)),w.metadata.draft?e.jsx(Hs,{path:t.filename,line:w.metadata.draft.realLine,sendingToAgent:O===`${B}-draft-agent`,onCancel:()=>b(null),onAddToReview:$=>{const H=w.metadata.draft;H&&(F(f,x,{path:t.filename,body:$,line:H.realLine,side:H.realSide}),b(null),G.success("Added to review"))},onSendToAgent:$=>{const H=w.metadata.draft;H&&h({key:`${B}-draft-agent`,kind:"lines",directory:r,repo:f,number:x,contextType:"pr",contextOptions:{includeDiff:!0},detail:`${t.filename} line ${H.realLine} ("${$.trim()}")`})}}):null]}),[S.allowed,S.reason,D.allowed,D.reason,i,oe,ae,z,F,f,x,t.filename,B,O,r,h]);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(M,{name:s?"arrow-right-s":"arrow-down-s",className:"size-4"})}),e.jsx(M,{name:lt(_),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:[Q?e.jsxs("span",{className:"text-muted-foreground",children:[Q,"/"]}):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||X.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"}${X.length>0?`, ${X.length} pending`:""}`,children:[e.jsx(M,{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,X.length>0?e.jsxs("span",{className:"tabular-nums",children:["+",X.length]}):null]}):null,e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",onClick:w=>w.stopPropagation(),children:[e.jsx(Lt,{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:()=>{h({key:`${B}-agent`,kind:"file",directory:r,repo:f,number:x,contextType:"pr",contextOptions:{includeDiff:!0},detail:t.filename})},disabled:O===`${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(Oe,{thread:w,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:D.allowed,resolveDisabledReason:D.reason,busy:i,onReply:$=>oe(w,$),onToggleResolved:()=>ae(w)},w.id))]}):null,Z?e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-[var(--surface-muted)] px-3 py-3 typography-ui",children:[e.jsx(M,{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 — ",it(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:ts(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(M,{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=I(i=>i.addComment),f=I(i=>i.performAction),x=le(i=>i.clearCommentDraft),{draft:k,onDraftChange:m,flushDraft:g}=mt(s,n),{busy:p,error:z,submit:F}=ht({postComment:i=>r(t,s,n,i,a),runFollowUp:i=>f(t,s,n,i,a),verbs:{close:"close",reopen:"reopen"},doneLabels:{close:"Closed with comment",reopen:"Reopened with comment"},afterPost:()=>{m(""),x(s,n),c()}}),L=st(d),j=l.state==="open"?"close":l.state==="closed"?"reopen":null,b=j?te(j,l,d):null;return L.allowed?e.jsx(ft,{draft:k,onDraftChange:m,onDraftBlur:g,ariaLabel:"Leave a comment on this pull request",busy:p,error:z,disabledReason:L.reason,followUp:j?{id:j,label:j==="close"?"Close with comment":"Reopen with comment",busyLabel:j==="close"?"Closing…":"Reopening…",onRun:()=>{F(j,k)},allowed:b?.allowed===!0,reason:b?.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:f})=>{const x=le(p=>p.setSummary),k=le(p=>p.setVerdict),m=n.includes(l)?l:n[0]??"comment",g=as({verdict:m,summary:a,pendingCount:d});return e.jsxs("div",{children:[e.jsx(Mt,{ref:r,rows:3,value:a,placeholder:"Summarize your review (optional)","aria-label":"Review summary",disabled:c,onChange:p=>x(t,s,p.target.value),onKeyDown:p=>{p.nativeEvent.isComposing||p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&!p.shiftKey&&!p.altKey&&!p.repeat&&(p.preventDefault(),p.stopPropagation(),g&&!c&&f())}}),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:p=>k(t,s,p.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(p=>e.jsx("option",{value:p,children:Bs[p]},p))})]}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:c||!g,title:g?`Submit review${d>0?` with ${d} ${d===1?"line comment":"line comments"}`:""}`:"Add a summary or a line comment first",onClick:f,children:c?"Submitting…":"Submit review"})]})]})},ct=({directory:t,repo:s,number:n,github:a,access:l,size:d="sm",onReviewSubmitted:c})=>{const r=I(T=>T.submitReview),f=le(T=>T.removeComments),x=le(T=>T.clearSummary),k=le(T=>T.clearComments),m=Le(s,n),g=xt(s,n),p=pt(s,n),[z,F]=o.useState(!1),[L,j]=o.useState(!1),b=o.useRef(null),i=o.useMemo(()=>ns(l),[l]),C=i.includes(p)?p:i[0]??"comment",h=m.length,O=h>0||g.trim().length>0;if(o.useEffect(()=>{if(!z)return;const T=window.requestAnimationFrame(()=>b.current?.focus({preventScroll:!0}));return()=>window.cancelAnimationFrame(T)},[z]),i.length===0)return null;const N=async()=>{if(L)return;const T=g,B=[...m];j(!0);try{const V=B.map(D=>({path:D.path,body:D.body,...D.line!=null?{line:D.line}:{},...D.side?{side:D.side}:{}})),S=await r(t,s,n,{event:C,body:T.trim()?T:void 0,comments:V},a);if(!S.ok){G.error(S.error?.kind==="failed"?S.error.message:"Failed to submit review");return}f(s,n,B.map(D=>D.id)),x(s,n,T),G.success(C==="approve"?"Pull request approved":C==="request-changes"?"Changes requested":"Review submitted"),F(!1),c?.()}finally{j(!1)}},E=h>0?`Review · ${h}`:"Review";return e.jsxs(We,{open:z,onOpenChange:F,children:[e.jsxs(Ye,{render:e.jsx(P,{type:"button",variant:h>0?"default":"outline",size:d,className:"shrink-0","aria-label":h>0?`Review pull request, ${h} ${h===1?"line comment":"line comments"} pending`:"Review pull request",title:O?"Finish your review":"Approve, request changes, or comment with a review"}),children:[e.jsx(M,{name:"file-check",className:"size-3.5","aria-hidden":"true"}),E]}),e.jsx(Ze,{children:e.jsx(Qe,{className:"z-50",side:"top",align:"end",sideOffset:8,collisionPadding:8,children:e.jsxs(Xe,{"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:h>0?`Review · ${h} ${h===1?"line comment":"line comments"}`:"Review pull request"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[h>0?e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Discard pending line comments",title:"Discard pending line comments",disabled:L,onClick:()=>k(s,n),className:"size-6",children:e.jsx(M,{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(M,{name:"close",className:"size-3.5"})})]})]}),e.jsx(_s,{repo:s,number:n,verdicts:i,summary:g,verdict:C,pendingCount:h,busy:L,textareaRef:b,onSubmit:()=>{N()}})]})})})]})},ye=(t,s)=>`${t}#${s}`,Be=50,Us=Object.freeze([]),_e=(t,s)=>{const n=Object.keys(t);if(n.length<=Be)return t;const a={};for(const l of n.slice(n.length-Be))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(x=>{const k=x.entries[c]??{viewed:[],headSha:null},m=d?[...k.viewed,l]:k.viewed.filter(g=>g!==l);return{entries:_e({...x.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:_e({...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),Ue=20,Js=[],Ws=[],Ve=t=>`pr-file-${encodeURIComponent(t)}`,dt=o.memo(({file:t,viewed:s,threadCount:n,pendingCount:a,showDir:l,onSelectFile:d})=>{const c=at(t.status),{dir:r,base:f}=ot(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(M,{name:lt(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:f})]}),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(M,{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(M,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]","aria-label":"Viewed"}):null]})});dt.displayName="FileJumpRow";const ut=({files:t,viewedPaths:s,threadCounts:n,pendingCounts:a,onSelectFile:l})=>{const[d,c]=o.useState(""),r=o.useMemo(()=>zs(t),[t]),f=o.useMemo(()=>new Set(s),[s]),x=d.trim().toLowerCase(),k=o.useMemo(()=>x?r.map(m=>({...m,files:m.files.filter(g=>g.filename.toLowerCase().includes(x))})).filter(m=>m.files.length>0):r,[r,x]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-1",children:[e.jsx(tt,{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(g=>e.jsx(dt,{file:g,viewed:f.has(g.filename),threadCount:n.get(g.filename)??0,pendingCount:a.get(g.filename)??0,showDir:r.length<=1,onSelectFile:l},g.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(We,{open:s,onOpenChange:n,children:[e.jsxs(Ye,{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(M,{name:"file",className:"size-3.5","aria-hidden":"true"}),"Files"]}),e.jsx(Ze,{children:e.jsx(Qe,{className:"z-50",side:"bottom",align:"start",sideOffset:4,collisionPadding:8,children:e.jsx(Xe,{"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(ut,{...t,onSelectFile:l})})})})]})},Zs=48,Qs=(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-Zs));a(f=>f===r?f:r)};if(d(),typeof ResizeObserver>"u")return;const c=new ResizeObserver(d);return c.observe(l),()=>c.disconnect()},[t,s]),n},Xs=t=>{const{directory:s,repo:n,number:a,github:l,access:d,headSha:c=null}=t,r=t.files?.files??Js,f=Vs(n,a),x=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]),g=o.useRef(m);g.current=m;const p=o.useRef(r);p.current=r;const[z,F]=o.useState({}),[L,j]=o.useState(Ue),b=o.useMemo(()=>As(r),[r]),i=o.useMemo(()=>{const R=new Map;for(const q of t.threads){if(!q.path)continue;const y=R.get(q.path)??[];y.push(q),R.set(q.path,y)}return R},[t.threads]),C=o.useMemo(()=>{const R=new Map;for(const[q,y]of i)R.set(q,y.length);return R},[i]),h=o.useMemo(()=>{const R=new Map;for(const q of k)R.set(q.path,(R.get(q.path)??0)+1);return R},[k]),O=o.useCallback(R=>{F(q=>({...q,[R]:!(q[R]??g.current[R]??!1)}))},[]),N=o.useCallback(()=>{F(Object.fromEntries(p.current.map(R=>[R.filename,!1])))},[]),E=o.useCallback(()=>{F(Object.fromEntries(p.current.map(R=>[R.filename,!0])))},[]),T=o.useCallback((R,q)=>{pe.getState().setViewed(n,a,R,q),F(y=>({...y,[R]:q}))},[n,a]),B=o.useCallback(R=>{F(y=>y[R]??g.current[R]??!1?{...y,[R]:!1}:y);const q=p.current.findIndex(y=>y.filename===R);q>=0&&j(y=>q<y?y:q+1),requestAnimationFrame(()=>{document.getElementById(Ve(R))?.scrollIntoView({block:"start"})})},[]),V=o.useMemo(()=>r.slice(0,L),[r,L]),S=o.useRef(null),D=Qs(S,V.length>0),K=o.useMemo(()=>new Set(f),[f]),_=r.length===1?"1 file":`${r.length} files`,Q=r.length===0?"Nothing viewed yet":`${x}/${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:b.additions,deletions:b.deletions}),e.jsxs("span",{className:"shrink-0 tabular-nums text-muted-foreground","aria-label":Q,children:[x,"/",r.length," viewed"]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[e.jsx(ct,{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:f,threadCounts:C,pendingCounts:h,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(M,{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(M,{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:D!=null?{height:D}:void 0,className:"sticky top-10 hidden max-h-[calc(100dvh-10rem)] w-60 shrink-0 flex-col @4xl:flex",children:e.jsx(ut,{files:r,viewedPaths:f,threadCounts:C,pendingCounts:h,onSelectFile:B})}),e.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:V.map(R=>e.jsx("div",{id:Ve(R.filename),className:"scroll-mt-12",children:e.jsx(Is,{file:R,collapsed:z[R.filename]??m[R.filename]??!1,onToggleCollapse:O,viewed:K.has(R.filename),onToggleViewed:T,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>L?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>j(L+Ue),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:f})=>{const[x,k]=o.useState({}),[m,g]=o.useState({}),{send:p,sendingKey:z}=Fe(),F=ls(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:()=>{p({key:`pr-${n}-failed-checks`,kind:"checks",directory:t,repo:s,number:n,contextType:"checks"})},disabled:z===`pr-${n}-failed-checks`,"aria-label":"Send failed checks to agent",title:"Send failed checks to agent",children:[e.jsx(M,{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(M,{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:x,onToggleJob:L=>k(j=>({...j,[L]:!j[L]})),jobSteps:m,setJobSteps:g,sendingKey:z,send:p,onOpenFilesAtLine:f}):null]})},tn=({checks:t,directory:s,repo:n,number:a,github:l,expandedJobs:d,onToggleJob:c,jobSteps:r,setJobSteps:f,sendingKey:x,send:k,onOpenFilesAtLine:m})=>{const g=I(i=>i.rerunFailedChecks),[p,z]=o.useState({}),F=async i=>{const C=`run-${i.id??i.name}`;if(c(C),!(d[C]||r[C]||i.id==null)){f(h=>({...h,[C]:{steps:[],loading:!0}}));try{const O=(await l.checkJobs(s,n,i.runId??null,i.id)).jobs[0];f(E=>({...E,[C]:{steps:O?.steps??[],loading:!1}}));const N=await l.checkAnnotations(s,n,i.id).catch(()=>null);N&&z(E=>({...E,[i.id]:{loading:!1,items:N.annotations}}))}catch{f(h=>({...h,[C]:{steps:[],loading:!1}}))}}},L=async i=>{(await g(s,n,i,l)).ok?G.success("Re-run requested"):G.error("Re-run failed")},j=i=>{const C=`run-${i.id??i.name}`,h=d[C]??!1,O=r[C],N=os(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":h,"aria-label":`${h?"Collapse":"Expand"} ${i.name}`,children:"Details"}),N&&i.runId!=null?e.jsx(P,{type:"button",variant:"outline",size:"xs",onClick:()=>{L(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:x===`${C}-agent`,"aria-label":`Send ${i.name} to agent`,children:"Send to agent"}):null]}),h?e.jsxs("div",{className:"mt-1.5 flex flex-col gap-1 border-t border-border/60 pt-1.5",children:[O?.loading?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Loading steps…"}):null,(O?.steps??[]).map((E,T)=>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}-${T}`)),i.id!=null&&p[i.id]?.items?.length?e.jsx("div",{className:"flex flex-col gap-1",children:p[i.id]?.items.map((E,T)=>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]},T))}):null]}):null]},C)},b=(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(b)}):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]})},Ke=({pr:t})=>e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(nt,{login:t.author?.login,avatarUrl:t.author?.avatarUrl,size:"xs"}),t.author?.login??"ghost"]}),t.updatedAt?` · updated ${gs(t.updatedAt)}`:"",t.draft?" · Draft":""]}),Je=({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(M,{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:f,onCopyLink:x,askSending:k,onAskAgent:m})=>{const g=I(N=>N.setMergeMethod),p=s.state==="open",z=be.filter(N=>te(N.id,s,n).allowed),F=z.some(N=>N.id===l)?l:z[0]?.id??l,L=te(F,s,n),j=te("ready",s,n),b=te("draft",s,n),i=te("close",s,n),C=te("reopen",s,n),h=be.find(N=>N.id===F)??be[0],O=z.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:[p&&!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:!L.allowed,disabledReason:L.reason??`Merge via ${h.label}`,label:F==="merge"?"Merge pull request":h.label,icon:e.jsx(M,{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:O,children:e.jsx(M,{name:"arrow-down-s",className:"size-3.5"})})}),e.jsx(Ae,{align:"start",className:"w-72",children:e.jsx(Et,{value:F,onValueChange:N=>{const E=N;d(E),g(t,E)},children:be.map(N=>{const E=te(N.id,s,n);return e.jsx(Ft,{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,p&&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(M,{name:"git-pull-request",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("ready")}):null,p&&!s.draft?e.jsx(ce,{copy:he("draft",s.base,s.head),busy:a,variant:"outline",disabled:!b.allowed,disabledReason:b.reason??"Convert to draft",label:"Convert to draft",icon:e.jsx(M,{name:"pencil",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("draft")}):null,p?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(M,{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(M,{name:"history",className:"size-3.5","aria-hidden":"true"}),"Reopen"]}),e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>f("worktree"),disabled:r,title:"Check out in a new worktree","aria-label":"Check out in a new worktree",children:[e.jsx(M,{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(M,{name:"git-branch",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>f("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(M,{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(M,{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(M,{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(M,{name:"external-link",className:"size-3.5"}),"Open on GitHub"]}),e.jsxs(we,{onClick:x,children:[e.jsx(M,{name:"file-copy",className:"size-3.5"}),"Copy link"]}),e.jsx(Pt,{}),e.jsxs(we,{onClick:()=>f("worktree"),disabled:r,children:[e.jsx(M,{name:"git-branch",className:"size-3.5"}),"Check out in new worktree"]})]})]})]})},nn=({pr:t,access:s,acting:n,onRun:a})=>{const l=bs(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(M,{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(M,{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(M,{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=I(u=>u.performAction),r=I(u=>u.updateTitleBody),f=I(u=>u.checkout),[x,k]=o.useState("summary"),[m,g]=o.useState(!1),[p,z]=o.useState(()=>zt(n)??"merge"),[F,L]=o.useState(!1),[j,b]=o.useState(""),[i,C]=o.useState(!1),[h,O]=o.useState(""),[N,E]=o.useState("newest"),[T,B]=o.useState(1),[V,S]=o.useState(!1),[D,K]=o.useState(null),_=gt(n,a),{send:Q,sendingKey:R}=Fe(),q=is(s,n),y=d?.pr??null,de=d?.sectionErrors??null,Z=o.useMemo(()=>({capabilities:d?.capabilities??null,isAuthor:rs(y?.author?.login,d?.viewerLogin),permissionFallback:d?.viewerPermission?.fallback===!0}),[d?.capabilities,d?.viewerLogin,d?.viewerPermission?.fallback,y?.author?.login]),ee=cs(y,Z);o.useEffect(()=>{k("summary"),L(!1),C(!1),B(1),K(null)},[n,a]);const X=o.useCallback(async u=>{g(!0);try{const Y=await c(s,n,a,u,l);if(!Y.ok){G.error(Y.error?.kind==="failed"?Y.error.message:"Action failed");return}u==="close"?G.success("Pull request closed"):u==="reopen"?G.success("Pull request reopened"):u==="update-branch"?G.success("Branch update requested"):u==="ready"?G.success("Marked as ready for review"):u==="draft"?G.success("Converted to draft"):G.success("Pull request merged")}finally{g(!1)}},[s,n,a,l,c]),se=o.useCallback(()=>{Q({key:`pr-${a}-ask`,kind:"pr",directory:s,repo:n,number:a,contextType:"pr"})},[Q,s,n,a]),ne=o.useCallback(async()=>{if(!j.trim()){G.error("Enter a title");return}const u=await r(s,n,a,{title:j.trim()},l);u.ok?(G.success("Title updated"),L(!1)):G.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:h},l);u.ok?(G.success("Description updated"),C(!1)):G.error(u.error?.kind==="failed"?u.error.message:"Failed to update description")},[h,s,n,a,l,r]),ae=Ee().git,ue=o.useCallback(async u=>{if(u==="current"){const Y=await Ne(()=>import("./useAppFontEffects-CV5UyTRw.js").then(re=>re.f0),__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){G.error("Working tree has uncommitted changes. Commit or stash first, or use New worktree.");return}}S(!0);try{const Y=await f(s,n,a,u,l);Y.ok?(await bt(s,ae),K({path:Y.path??null,branch:Y.branch??""}),G.success(u==="worktree"?"Worktree created":"Branch checked out")):G.error(Y.error?.kind==="failed"?Y.error.message:"Checkout failed")}finally{S(!1)}},[s,n,a,l,ae,f]),w=o.useCallback(()=>{D?.path&&Ne(async()=>{const{useSessionUIStore:u}=await import("./useAppFontEffects-CV5UyTRw.js").then(Y=>Y.eZ);return{useSessionUIStore:u}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({useSessionUIStore:u})=>{u.getState().openNewSessionDraft({directoryOverride:D.path}),Ns.getState().setActiveMainTab("chat")})},[D]),$=ds(y?.url),H=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]),A=H.slice(0,T*20),U=A.filter(u=>!$e(u.author?.login)),W=A.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:q,number:a,openLabel:`Open pull request #${a} on GitHub`,title:`Pull request #${a}`}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(et,{info:vt(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:q,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(Ke,{pr:u}):void 0,branches:u?e.jsx(Je,{pr:u,filesCount:u.changedFiles??null}):void 0}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(us,{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:q,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:()=>{b(y.title),L(!0)},editTitleLabel:"Edit pull request title",editTitleDisabledReason:ee.allowed?null:ee.reason,meta:e.jsx(Ke,{pr:y}),branches:e.jsx(Je,{pr:y,filesCount:me})}),e.jsx(sn,{directory:s,repo:n,number:a,github:l,pr:y,access:Z,acting:m,mergeMethod:p,onMergeMethodChange:z,onRun:u=>{X(u)},checkingOut:V,onCheckout:u=>{ue(u)},onCopyLink:$,askSending:R===`pr-${a}-ask`,onAskAgent:se}),e.jsx(nn,{pr:y,access:Z,acting:m,onRun:u=>{X(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:x,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,Z.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(tt,{value:j,onChange:u=>b(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:()=>L(!1),children:"Cancel"})]}):null,D?e.jsxs("p",{className:"flex flex-wrap items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(M,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]"}),e.jsxs("span",{children:["Ready on ",D.branch,D.path?` at ${D.path}`:"","."]}),D.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,x==="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(nt,{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(ms,{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:()=>{O(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:h,onChange:u=>O(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(hs,{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${H.length?` (${H.length})`:""}`,action:e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",children:[t.hideFilesTab?e.jsx(ct,{directory:s,repo:n,number:a,github:l,access:Z,size:"xs",onReviewSubmitted:t.onRetryDetail}):null,e.jsx(ps,{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(fs,{comment:u},u.id)),e.jsx(xs,{comments:W}),t.commentsLoading&&H.length===0&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Loading comments…"}):null,H.length===0&&!t.commentsLoading&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"No comments yet."}):null,H.length>A.length?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>B(T+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:Z,onCommented:()=>{t.onRetryComments(),t.onRetryDetail()}})]})})]}):null,x==="files"&&!t.hideFilesTab?e.jsx(Xs,{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:Z,headSha:y.headSha??null,onReviewSubmitted:t.onRetryDetail},`${n}#${a}`):null,x==="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:f,incompleteNotice:x=null,remote:k=null,numberJump:m=null,onFiltersChange:g,onClearFilters:p,onLoadMore:z,onRetry:F,onOpen:L,headerActionsSlot:j=null,headerActionsPresentation:b="drawer"})=>{const i=r.state==="open"&&r.involvement==="all"&&!r.search.trim(),C=o.useCallback(h=>e.jsx("li",{role:"listitem",children:e.jsx(yt,{glyph:e.jsx(vs,{kind:"pr",state:h.state,draft:h.draft}),glyphBelow:e.jsx(fe,{state:(h.url?f[h.url]:void 0)??null}),number:`#${h.number}`,title:h.title,status:e.jsx(ge,{additions:h.additions,deletions:h.deletions,className:"typography-micro"}),meta:e.jsxs(e.Fragment,{children:[e.jsx(jt,{login:h.author?.login,avatarUrl:h.author?.avatarUrl}),e.jsx(wt,{head:h.head,base:h.base}),h.draft?e.jsx("span",{className:"shrink-0 rounded bg-[var(--surface-muted)] px-1 typography-micro text-muted-foreground",children:"Draft"}):null]}),updatedAt:h.updatedAt,onOpen:()=>L(h.number),ariaLabel:`Open pull request #${h.number} ${h.title}`})},h.number),[f,L]);return e.jsx(kt,{items:t,renderRow:C,hasMore:s,isLoadingMore:n,isLoading:a,isRefreshing:l,stale:d,error:c,searchValue:r.search,onSearchChange:h=>g({search:h}),searchPlaceholder:"Search pull requests, or label:bug",searchAriaLabel:"Search pull requests",toolbarControls:e.jsx(Ct,{stateValue:r.state,stateOptions:ws.map(h=>({id:h.id,label:h.label})),onStateChange:h=>g({state:h}),involvementValue:r.involvement,involvementOptions:js.map(h=>({id:h.id,label:h.label})),onInvolvementChange:h=>g({involvement:h}),sortValue:r.sort,sortOptions:ys.map(h=>({id:h.id,label:h.label})),onSortChange:h=>g({sort:h}),sortAriaLabel:"Sort pull requests"}),headerActionsSlot:j,headerActionsPresentation:b,isDefaultFilters:i,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",incompleteNotice:x,remote:k,numberJump:m,numberJumpKind:"pull request",onClearFilters:p,onLoadMore:z,onRetry:F,onOpen:L})},on=t=>{const s=At(n=>n.results);return o.useMemo(()=>{const n=Dt(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=Tt()??"";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),[f,x]=o.useState(!1),k=o.useRef(null);return o.useEffect(()=>$t(),[]),e.jsx(Nt,{directory:t,isRefreshing:c,onRefresh:()=>k.current?.(),children:({repo:m,directory:g})=>e.jsx(cn,{directory:g,repo:m,github:d,refreshing:c,setRefreshing:r,loadingMore:f,setLoadingMore:x,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:f,headerActionsSlot:x=null,headerActionsPresentation:k="drawer"})=>{const m=I(v=>v.ensureCollectionsFresh),g=I(v=>v.searchRemote),p=I(v=>v.loadMoreRemote),z=I(v=>v.loadMoreCollection),F=I(v=>v.refreshAllForScope),L=I(v=>v.selectPullRequest),j=I(v=>v.setFilters),b=I(v=>v.resetFilters),i=Gt(t,s),C=Ht(t),h=qt(),O=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"),T=De(s,"closed"),B=o.useMemo(()=>It(s),[s,E?.data,T?.data]),V=o.useMemo(()=>new Set(B.map(v=>v.number)),[B]),S=o.useMemo(()=>Ot(B,{state:i.state,involvement:i.involvement,search:i.search,sort:i.sort,viewerLogin:h}),[B,i.state,i.involvement,i.search,i.sort,h]),D=on(S),K=N==="both"?[E,T]:[N==="open"?E:T],_=K.some(v=>v?.data!=null),Q=_&&K.every(v=>v?.data?.nextCursor==null),R=K.reduce((v,u)=>v+(u?.data?.items.length??0),0),q=K.find(v=>v?.error)?.error??null,y=K.some(v=>v?.isLoading),de=K.some(v=>v?.stale),Z=i.search.trim(),ee=i.involvement!=="all"&&!h,X=Z.length>0||i.involvement!=="all",se=o.useMemo(()=>({state:i.state,involvement:i.involvement,q:Z}),[i.state,i.involvement,Z]),ne=`${se.state}|${se.involvement}|${se.q}`,oe=!Q&&_&&S.length===0&&(Z.length>0||ee),ae=o.useCallback(v=>n?g(t,s,v,n):Promise.resolve(null),[t,s,n,g]),ue=o.useCallback(v=>n?p(t,s,v,n):Promise.resolve(null),[t,s,n,p]),{remoteView:w,numberJump:$,remotePending:H,handleSearchAll:ie}=St({repo:s,query:se,queryKey:ne,autoRemote:oe,indexNumbers:V,visibleItems:S,searchText:Z,useRemoteEntry:Jt,runSearch:ae,runLoadMore:ue}),A=o.useMemo(()=>{if(Q||!_||!X)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}`},[Q,_,X,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=>z(t,s,u,n))).then(()=>c(!1)).catch(()=>c(!1))},[t,s,N,n,z,c]),J=o.useCallback(v=>{L(t,s,v)},[t,s,L]),me=o.useCallback(()=>{L(t,null,null)},[t,L]);return n?O!=null?e.jsx(dn,{directory:t,repo:s,number:O,github:n,onBack:me,hideFilesTab:f,seed:Bt(s,O)}):e.jsx(ln,{items:S,headerActionsSlot:x,headerActionsPresentation:k,hasMore:K.some(v=>v?.data?.nextCursor!=null),isLoadingMore:d,isLoading:y,isRefreshing:a&&_,stale:de,error:q,filters:i,checksByUrl:D,incompleteNotice:A?{summary:A,searching:H,onSearchAll:ie}:null,remote:w,numberJump:$,onFiltersChange:v=>j(t,s,v),onClearFilters:()=>b(t,s),onLoadMore:W,onRetry:U,onOpen:J}):e.jsx(et,{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=I(S=>S.ensureDetail),f=I(S=>S.ensureComments),x=I(S=>S.ensureFiles),k=I(S=>S.ensureChecks),m=I(S=>S.loadMoreFiles),g=I(S=>S.loadMoreComments),p=I(S=>S.refreshComments),z=I(S=>S.refreshDetail),F=I(S=>S.refreshChecks);o.useEffect(()=>{r(t,s,n,a).catch(()=>{}),f(t,s,n,a).catch(()=>{}),d||x(t,s,n,a).catch(()=>{}),k(t,s,n,a).catch(()=>{})},[t,s,n,d]);const L=_t(s,n),j=Ut(s,n),b=Vt(s,n),i=Kt(s,n),C=L?.data?.detail??null,h=o.useCallback((S,D)=>{const K=Ss(t);Ne(async()=>{const{useUIStore:_}=await import("./index-CKKWVoND.js").then(Q=>Q.cN);return{useUIStore:_}},__vite__mapDeps([1,2,3,4,5,6,7,8])).then(({useUIStore:_})=>{_.getState().openContextFileAtLine(K,S,D)}).catch(()=>{})},[t]),O=o.useCallback(()=>{m(t,s,n,a).catch(()=>{})},[t,s,n,a,m]),N=o.useCallback(()=>{g(t,s,n,a).catch(()=>{})},[t,s,n,a,g]),E=o.useCallback(()=>{p(t,s,n,a).catch(()=>{})},[t,s,n,a,p]),T=o.useCallback(()=>{z(t,s,n,a).catch(()=>{})},[t,s,n,a,z]),B=o.useCallback(()=>{x(t,s,n,a).catch(()=>{})},[t,s,n,a,x]),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:L?.error??null,detailStale:L?.stale??!1,files:b?.data??null,filesError:b?.error??null,filesLoading:b?.isLoading??!1,filesHasMore:b?.data?.nextCursor!=null,onLoadMoreFiles:O,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:T,onRetryFiles:B,onRetryChecks:V,onOpenFilesAtLine:h})};export{da as PullRequestsSurface};
|
package/dist/assets/{SessionSwitcherContent-C4CMlcbv.js → SessionSwitcherContent-DJGCa_wN.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,aW as C}from"./vendor-boot-D-KEJjsM.js";import{R as f}from"./vendor-react-Bz1tRBxM.js";import{x as w,I as x,y as R,z as G,A as M,C as F,E as z,F as B,r as H,G as W}from"./useAppFontEffects-
|
|
1
|
+
import{j as e,aW as C}from"./vendor-boot-D-KEJjsM.js";import{R as f}from"./vendor-react-Bz1tRBxM.js";import{x as w,I as x,y as R,z as G,A as M,C as F,E as z,F as B,r as H,G as W}from"./useAppFontEffects-CV5UyTRw.js";import{u as q}from"./useSwitcherItems-C8G5F0hs.js";import{u as J,c as k}from"./index-CKKWVoND.js";import{S as K,a as O,f as Q}from"./SessionUnreadDot-Dwc3MdvA.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-0K7vuUpd.js";import"./nativeFileSave-DSMsJqXM.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";function le({onSelect:s,variant:m,scopeProjectId:d}){const i=q(!0,{scopeProjectId:d}),o=w(t=>t.openNewSessionDraft),a=J(t=>t.setActiveMainTab),l=f.useCallback(()=>{a("chat"),s(),o()},[s,o,a]),[c,p]=f.useState(new Set),u=f.useCallback(t=>{p(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(C,{onClick:l,className:k("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:m,expandedParents:c,toggleParent:u,closeDropdown:s},t.node.session.id))]})})}function D({item:s,depth:m,variant:d,expandedParents:i,toggleParent:o,closeDropdown:a}){const{node:l,secondaryMeta:c}=s,p=l.session,u=l.children.length>0,t=i.has(p.id);return e.jsxs(e.Fragment,{children:[e.jsx(V,{session:p,depth:m,variant:d,secondaryMeta:c,hasChildren:u,isExpanded:t,onToggleExpand:u?()=>o(p.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:m+1,variant:d,expandedParents:i,toggleParent:o,closeDropdown:a},h.session.id)):null]})}function V({session:s,depth:m,variant:d,secondaryMeta:i,hasChildren:o,isExpanded:a,onToggleExpand:l,closeDropdown:c}){const p=w(n=>n.currentSessionId),u=w(n=>n.setCurrentSession),t=R(s.id),h=G(s.id),r=M(s.id),g=p===s.id,L=F(s),N=t?.type??"idle",b=N==="busy"||N==="retry",S=z({pendingInput:r,isStreaming:b,unseenCount:h,isActive:g}),y=S==="needs-input",A=y&&r?B(r.kind,r.count):null,T=S==="unread",U=s.time?.updated||s.time?.created||Date.now(),E=Q(U),v=i?.projectLabel?.trim()||null,j=i?.branchLabel?.trim()||null,I=j&&j!=="HEAD"?j:null,P=f.useCallback(()=>{if(g){c();return}const n=H(s);u(s.id,n??null),c()},[c,g,s,u]);return e.jsxs(C,{onClick:n=>{if(n.target?.closest("[data-switcher-expand]")){n.preventDefault();return}P()},"data-slot":"session-switcher-item",className:k("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+m*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-subtle-foreground 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-subtle-foreground 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-subtle-foreground 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(K,{sessionId:s.id,running:!0}):T?e.jsx(O,{label:"Session complete"}):E}),v?e.jsx("span",{className:"truncate",children:v}):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-subtle-foreground"}),e.jsx("span",{className:"truncate",children:I})]}):null]}):null]}),y?e.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:e.jsx(W,{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};
|
package/dist/assets/{SessionSwitcherDropdown-DCBVuCoo.js → SessionSwitcherDropdown-CDOX-5Y2.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionSwitcherContent-
|
|
2
|
-
import{_ as m}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as e}from"./vendor-boot-D-KEJjsM.js";import{a as c,R as d}from"./vendor-react-Bz1tRBxM.js";import{D as l,h as x,i as u}from"./useAppFontEffects-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionSwitcherContent-DJGCa_wN.js","assets/vendor-boot-D-KEJjsM.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-clsx-B-dksMZM.js","assets/useAppFontEffects-CV5UyTRw.js","assets/index-CKKWVoND.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js","assets/index-B_L9GVYw.css","assets/runtimeSurface-0K7vuUpd.js","assets/nativeFileSave-DSMsJqXM.js","assets/useSwitcherItems-C8G5F0hs.js","assets/SessionUnreadDot-Dwc3MdvA.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as m}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as e}from"./vendor-boot-D-KEJjsM.js";import{a as c,R as d}from"./vendor-react-Bz1tRBxM.js";import{D as l,h as x,i as u}from"./useAppFontEffects-CV5UyTRw.js";import{u as n,c as f}from"./index-CKKWVoND.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./runtimeSurface-0K7vuUpd.js";import"./nativeFileSave-DSMsJqXM.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";const w=d.lazy(()=>m(()=>import("./SessionSwitcherContent-DJGCa_wN.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:i=null,align:a="start"}){const r=n(o=>o.isSessionDropdownOpen),s=n(o=>o.setSessionDropdownOpen);return e.jsxs(l,{open:r,onOpenChange:s,modal:!1,children:[e.jsx(x,{asChild:!0,children:p}),e.jsx(u,{align:a,sideOffset:6,className:f("overflow-hidden p-1 max-w-[calc(100vw-32px)]",t==="compact"?"w-[280px]":"w-[360px]"),children:r?e.jsx(c.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:i})}):null})]})}export{R as SessionSwitcherDropdown};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as D,X as b,Y as y,Z as p}from"./useAppFontEffects-
|
|
1
|
+
import{g as D,X as b,Y as y,Z as p}from"./useAppFontEffects-CV5UyTRw.js";import{j as d}from"./vendor-boot-D-KEJjsM.js";import"./vendor-react-Bz1tRBxM.js";import{c as h}from"./index-CKKWVoND.js";const F=(e,t,o)=>{const r=`${o}:`,a=new Set([...t].filter(s=>s.startsWith(r)));return e.size===a.size&&[...a].every(s=>e.has(s))?e:a},I=(e,t)=>{const o=new Set(e);return o.has(t)?o.delete(t):o.add(t),o},w=e=>{const t=new Date(e),o=new Date,r=(i,n)=>i.getFullYear()===n.getFullYear()&&i.getMonth()===n.getMonth()&&i.getDate()===n.getDate(),a=new Date(o);return a.setDate(o.getDate()-1),r(t,o)?"Today":r(t,a)?"Yesterday":t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}).replace(",","")},j=e=>{const t=new Date,o=new Date(e);if(((a,s)=>a.getFullYear()===s.getFullYear()&&a.getMonth()===s.getMonth()&&a.getDate()===s.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 w(e)},z=e=>{const t=Math.max(0,Date.now()-e),o=6e4,r=60*o,a=24*r,s=7*a,i=30*a,n=365*a;return t<r?`${Math.max(1,Math.floor(t/o))}m`:t<a?`${Math.floor(t/r)}h`:t<s?`${Math.floor(t/a)}d ago`:t<5*s?`${Math.floor(t/s)}w ago`:t<n?`${Math.floor(t/i)}mo`:`${Math.floor(t/n)}y ago`},m=e=>e.toLowerCase().replace(/[-_]/g,"").trim(),E=(e,t)=>e?m(e)!==m(t):!1,Y=e=>{const t=new Map;return e.forEach(o=>{t.set(o.id,o)}),Array.from(t.values())},k=(e,t)=>D({label:e.label,path:e.normalizedPath},t),P="calc(1.25rem * var(--padding-scale, 1))",g="size-4 shrink-0",M="min-w-0 truncate typography-ui-label font-normal",S=g,x=M,$="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",_=$,T=e=>e?S:g,U=e=>e?x:M,f=1e3,l=60*f,c=60*l,C=e=>{const t=Math.max(0,e);return t<l?`${Math.floor(t/f)}s`:t<c?`${Math.floor(t/l)}m ${Math.floor(t%l/f)}s`:`${Math.floor(t/c)}h ${Math.floor(t%c/l)}m`},v=1e3,B=({sessionId:e,running:t,className:o})=>{const r=b(e),a=y(e),s=p(t,v),i=t?Math.max(0,s-(r??s)):a;if(i===void 0)return null;const n=C(i),u=t?`Active for ${n}`:`Last turn took ${n}`;return d.jsx("span",{className:h("shrink-0 tabular-nums",t?"text-primary":"text-[var(--status-info)]",o),"aria-label":u,title:u,children:n})};function K({label:e,className:t}){return d.jsx("span",{className:h("size-1.5 shrink-0 rounded-full bg-foreground",t),"aria-label":e,title:e})}export{B as S,K as a,U as b,_ as c,j as d,Y as e,z as f,k as g,g as h,M as i,$ as j,E as k,P as l,F as m,T as s,I as t};
|