agentic-diff 0.1.1 → 0.1.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.
|
@@ -56,7 +56,7 @@ Error generating stack: `+e.message+`
|
|
|
56
56
|
`)[0]]})]}),(i||l)&&(0,_.jsxs)(_.Fragment,{children:[p&&t.anchorText&&t.anchorText.length>0&&(0,_.jsx)(`pre`,{className:`thread-snippet`,children:t.anchorText.join(`
|
|
57
57
|
`)}),t.comments.map(r=>(0,_.jsx)(H_,{repoId:e,comment:r,actions:n,applicable:t.side===`R`&&!t.detached,pending:h&&!r.published},r.id)),l&&(0,_.jsx)(Fg,{run:l}),u&&(0,_.jsx)(`div`,{className:`flash flash-danger thread-flash`,role:`alert`,children:u}),o?(0,_.jsx)(z_,{repoId:e,draftKey:`reply:${t.id}`,submitLabel:`Reply`,onSubmit:e=>n.reply(t.id,e).then(()=>{s(!1),c.startIfMentioned(t.id,e)}),onCancel:()=>s(!1)}):(0,_.jsxs)(`div`,{className:`thread-footer`,children:[(0,_.jsx)(`button`,{type:`button`,className:`reply-box`,onClick:()=>s(!0),children:`Reply…`}),(0,_.jsxs)(`button`,{type:`button`,className:`button`,disabled:l?.status===`running`||c.agents.length===0,title:`Ask the agent for its view on this conversation. Mentioning @agent in a comment does the same.`,onClick:()=>c.start({threadId:t.id,message:`Please look at this conversation and the code it is about, and give your view.`}),children:[(0,_.jsx)(xr,{size:16}),` Ask agent`]}),!t.github&&(0,_.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>{a(d),n.setState(t.id,d?`open`:`resolved`)},children:d?`Unresolve conversation`:`Resolve conversation`})]})]})]})}function G_({items:e}){let[t,n]=(0,f.useState)(void 0),r=(0,f.useRef)(null),i=(0,f.useRef)(null),a=t!==void 0;return(0,f.useEffect)(()=>{if(!a)return;let e=()=>n(void 0),t=t=>{let n=t.target;!i.current?.contains(n)&&!r.current?.contains(n)&&e()},o=t=>{t.key===`Escape`&&(e(),r.current?.focus())};return document.addEventListener(`mousedown`,t),document.addEventListener(`keydown`,o),window.addEventListener(`scroll`,e,{passive:!0}),window.addEventListener(`resize`,e),i.current?.querySelector(`button`)?.focus(),()=>{document.removeEventListener(`mousedown`,t),document.removeEventListener(`keydown`,o),window.removeEventListener(`scroll`,e),window.removeEventListener(`resize`,e)}},[a]),(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`button`,{ref:r,type:`button`,className:`icon-button`,"aria-haspopup":`menu`,"aria-expanded":a,"aria-label":`More actions for this file`,title:`More actions`,onClick:()=>{if(a||!r.current){n(void 0);return}let e=r.current.getBoundingClientRect();n({top:e.bottom+4,right:Math.max(8,window.innerWidth-e.right)})},children:(0,_.jsx)(Ii,{size:16})}),t&&(0,co.createPortal)((0,_.jsx)(`div`,{ref:i,className:`file-menu-list`,role:`menu`,style:t,children:e.map(e=>(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`danger`:void 0,onClick:()=>{n(void 0),e.run()},children:e.label},e.label))}),document.body)]})}var K_,q_=1,J_=new Map;function Y_(){return K_||(K_=new Worker(new URL(`/assets/highlight.worker-DsmjLvrc.js`,``+import.meta.url),{type:`module`}),K_.addEventListener(`message`,e=>{let t=J_.get(e.data.id);t&&(J_.delete(e.data.id),`error`in e.data?t.reject(Error(e.data.error)):t.resolve(e.data.lines))}),K_.addEventListener(`error`,()=>{for(let e of J_.values())e.reject(Error(`Highlighting failed`));J_.clear(),K_?.terminate(),K_=void 0}),K_)}function X_(e,t){return new Promise((n,r)=>{let i=q_++;J_.set(i,{resolve:n,reject:r}),Y_().postMessage({id:i,language:e,code:t.join(`
|
|
58
58
|
`)})})}function Z_(e,t){return e.length>0&&e.length<=15e3&&t<=4e5}var Q_=`modulepreload`,$_=function(e){return`/`+e},e1={},t1={},n1=function(e){return e.pathname.endsWith(`.css`)},r1=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw delete e[t],n});return e[t]=i,i},i1=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=$_(t,n);let r=s(t),i=n1(r);return r1(e1,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}let t=i?e.styles:e.all,n=i?t1[r.href]:void 0;if(!n&&t.has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:Q_,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),n&&delete t1[r.href],n?.isConnected?n.replaceWith(o):document.head.appendChild(o),i)return new Promise((e,t)=>{let n=i=>{o.removeEventListener(`load`,n),o.removeEventListener(`error`,n),i.type===`error`?(t1[r.href]=o,t(Error(`Unable to preload CSS for ${r}`))):e(i)};o.addEventListener(`load`,n),o.addEventListener(`error`,n)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},a1={c:`c`,h:`c`,cc:`cpp`,cpp:`cpp`,cxx:`cpp`,hpp:`cpp`,hh:`cpp`,cs:`csharp`,css:`css`,diff:`diff`,patch:`diff`,go:`go`,graphql:`graphql`,gql:`graphql`,html:`html`,htm:`html`,ini:`ini`,cfg:`ini`,conf:`ini`,properties:`ini`,editorconfig:`ini`,java:`java`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,map:`json`,webmanifest:`json`,jsonc:`jsonc`,json5:`jsonc`,jsx:`jsx`,kt:`kotlin`,kts:`kotlin`,less:`less`,lua:`lua`,mk:`make`,md:`markdown`,markdown:`markdown`,mdx:`markdown`,php:`php`,py:`python`,pyi:`python`,rb:`ruby`,rake:`ruby`,gemspec:`ruby`,rs:`rust`,scss:`scss`,sh:`shellscript`,bash:`shellscript`,zsh:`shellscript`,fish:`shellscript`,sql:`sql`,svelte:`svelte`,swift:`swift`,toml:`toml`,tsx:`tsx`,ts:`typescript`,mts:`typescript`,cts:`typescript`,vue:`vue`,xml:`xml`,svg:`xml`,xsd:`xml`,plist:`xml`,csproj:`xml`,yaml:`yaml`,yml:`yaml`},o1={dockerfile:`docker`,makefile:`make`,gnumakefile:`make`,gemfile:`ruby`,rakefile:`ruby`,".bashrc":`shellscript`,".zshrc":`shellscript`,".gitconfig":`ini`,".npmrc":`ini`,"tsconfig.json":`jsonc`,"jsconfig.json":`jsonc`};function s1(e){let t=e.slice(e.lastIndexOf(`/`)+1).toLowerCase(),n=o1[t]??(t.startsWith(`dockerfile.`)?`docker`:void 0);if(n)return n;let r=t.lastIndexOf(`.`);return r>0||r===0&&t.length>1?a1[t.slice(r+1)]:void 0}var c1=/^ {0,3}(`{3,}|~{3,})/;function l1(e){let t=[],n=[],r,i=()=>{n.length>0&&t.push(n.join(`
|
|
59
|
-
`)),n=[]};for(let t of e){let e=c1.exec(t)?.[1];r?(n.push(t),e&&e[0]===r[0]&&e.length>=r.length&&t.trim()===e&&(r=void 0,i())):e?(i(),r=e,n.push(t)):t.trim()===``?i():n.push(t)}return i(),t}function u1(e,t){let n=[];for(let r of bn(l1(e),l1(t))){let e=r.added?`added`:r.removed?`removed`:`same`;for(let t of r.value)n.push({kind:e,text:t})}return n}var d1={added:`Added`,removed:`Removed`},f1=(0,f.memo)(function({oldLines:e,newLines:t}){let n=(0,f.useMemo)(()=>u1(e,t),[e,t]);return(0,_.jsx)(`div`,{className:`rich-diff`,"aria-label":`Rendered document with changes marked`,children:n.map((e,t)=>e.kind===`same`?(0,_.jsx)(`div`,{className:`rich-block`,children:(0,_.jsx)(Ng,{text:e.text})},t):(0,_.jsxs)(`div`,{className:`rich-block rich-${e.kind}`,"aria-label":d1[e.kind],children:[(0,_.jsx)(`span`,{className:`rich-mark`,"aria-hidden":`true`,children:e.kind===`added`?`+`:`−`}),(0,_.jsx)(Ng,{text:e.text})]},t))})});function p1({src:e,label:t,tone:n}){let[r,i]=(0,f.useState)(void 0),[a,o]=(0,f.useState)(!1);return(0,_.jsxs)(`figure`,{className:`image-side image-${n}`,children:[(0,_.jsxs)(`figcaption`,{children:[(0,_.jsx)(`strong`,{children:t}),r&&(0,_.jsx)(`span`,{className:`image-size`,children:r})]}),a?(0,_.jsx)(`p`,{className:`image-failed`,children:`This image could not be shown.`}):(0,_.jsx)(`img`,{src:e,alt:t,onLoad:e=>i(`${e.currentTarget.naturalWidth} × ${e.currentTarget.naturalHeight}`),onError:()=>o(!0)})]})}function m1({before:e,after:t}){return(0,_.jsxs)(`div`,{className:`image-diff`,children:[e&&(0,_.jsx)(p1,{src:e,label:t?`Before`:`Deleted`,tone:`removed`}),t&&(0,_.jsx)(p1,{src:t,label:e?`After`:`Added`,tone:`added`})]})}function h1(e){return e===0?[]:[{oldStart:0,oldLines:0,newStart:1,newLines:e,section:``,rows:Array.from({length:e},(e,t)=>({t:`add`,new:t+1}))}]}var g1=e=>e.oldLines===0?e.oldStart+1:e.oldStart,_1=e=>e.newLines===0?e.newStart+1:e.newStart;function v1(e,t){let n=1,r=1,i=e.map(e=>{let t={oldStart:n,newStart:r,length:Math.max(0,_1(e)-r)};return n=g1(e)+e.oldLines,r=_1(e)+e.newLines,t});return i.push({oldStart:n,newStart:r,length:Math.max(0,t-r+1)}),i}function y1(e,t,n){let r=e.findIndex(e=>{let r=t===`L`?e.oldStart:e.newStart;return n>=r&&n<r+e.length});return r<0?void 0:r}function b1(e,t,n){let r=e;for(let{side:e,line:i}of n){let n=y1(t,e,i);if(n===void 0)continue;let a=t[n],o=r[n]??{top:0,bottom:0},s=i-(e===`L`?a.oldStart:a.newStart);s<o.top||s>=a.length-o.bottom||(r=x1(r,n,`all`,a.length))}return r}function x1(e,t,n,r){let i=e[t]??{top:0,bottom:0},a=n===`all`?{top:r,bottom:0}:n===`down`?{...i,top:i.top+20}:{...i,bottom:i.bottom+20};return{...e,[t]:a}}var S1=e=>`${e.t}:${`old`in e?e.old:``}:${`new`in e?e.new:``}`;function C1(e,t,n){let r=[];for(let i=t;i<n;i+=1){let t={t:`ctx`,old:e.oldStart+i,new:e.newStart+i};r.push({kind:`row`,key:S1(t),row:t})}return r}function w1(e,t,n){let r=[];if(e.forEach((e,i)=>{let a=t[i],o=n[i]??{top:0,bottom:0},s=Math.min(o.top,a.length),c=Math.min(o.bottom,a.length-s),l=a.length-s-c;if(r.push(...C1(a,0,s)),l>0||a.length===0){let t=l===0?[]:l<=20?[`all`]:i===0?[`up`]:[`down`,`up`];r.push({kind:`hunk`,key:`hunk:${i}`,gap:i,gapLength:a.length,hunk:e,actions:t})}r.push(...C1(a,a.length-c,a.length));for(let t of e.rows)r.push({kind:`row`,key:S1(t),row:t})}),e.length>0){let i=e.length,a=t[i],o=Math.min(n[i]?.top??0,a.length),s=a.length-o;r.push(...C1(a,0,o)),s>0&&r.push({kind:`tail`,key:`tail`,gap:i,gapLength:a.length,actions:[s<=20?`all`:`down`]})}return r}function T1(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.t===`ctx`){t.push({ctx:r}),n+=1;continue}let i=[],a=[];for(;e[n]?.t===`del`;)i.push(e[n++]);for(;e[n]?.t===`add`;)a.push(e[n++]);t.push({dels:i,adds:a})}return t}function E1(e){let t=[];for(let n of T1(e)){if(`ctx`in n){t.push({key:S1(n.ctx),left:n.ctx,right:n.ctx});continue}let e=Math.max(n.dels.length,n.adds.length);for(let r=0;r<e;r+=1){let e=n.dels[r],i=n.adds[r];t.push({key:`${e?S1(e):``}|${i?S1(i):``}`,left:e,right:i})}}return t}function D1(e){let t=new Map;for(let n of T1(e))`ctx`in n||n.dels.length!==n.adds.length||n.dels.forEach((e,r)=>{let i=n.adds[r];t.set(e,i),t.set(i,e)});return t}function O1(e){let t=`@@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@`;return e.section?`${t} ${e.section}`:t}var k1=new Set([`text`,`search`,`url`,`tel`,`email`,`password`,`number`,`date`,`datetime-local`,`month`,`time`,`week`]);function A1(e){return e instanceof HTMLElement?e.closest(`[role="dialog"], [role="menu"]`)?!0:e instanceof HTMLInputElement?k1.has(e.type):e.isContentEditable||e.closest(`textarea, select, [contenteditable="true"], .cm-editor`)!==null:!1}function j1(e){let{key:t}=e;if(/^[A-Za-z]$/.test(t))return e.shiftKey?t:t.toLowerCase();let n=/^Key([A-Z])$/.exec(e.code)?.[1],r=[...t].length===1&&(t.codePointAt(0)??0)>127;return n&&r&&!e.shiftKey?n.toLowerCase():t}function M1(e){let t=(0,f.useRef)(e);t.current=e,(0,f.useEffect)(()=>{let e=e=>{if(e.ctrlKey||e.metaKey||e.altKey||e.defaultPrevented||e.isComposing||A1(e.target)||document.querySelector(`[aria-modal="true"], [role="menu"]`))return;let n=t.current[j1(e)];n&&(e.preventDefault(),n())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[])}function N1(){return document.activeElement?.closest(`section.file-card`)||[...document.querySelectorAll(`section.file-card`)].find(e=>e.getBoundingClientRect().bottom>80)}var P1=`focusRows`;function F1(e){let t=[...document.querySelectorAll(`section.file-card`)],n=N1(),r=n?t.indexOf(n):-1,i=n!==void 0&&(document.activeElement?.closest(`section.file-card`)===n||n.getBoundingClientRect().top<0),a=t[r<0?0:e===1&&!i?r:r+e];if(!a)return;for(let e of t)delete e.dataset[P1];a.scrollIntoView({block:`start`});let o=a.querySelector(`.diff-rows`);o?o.focus({preventScroll:!0}):(a.dataset[P1]=``,a.querySelector(`.file-header button`)?.focus({preventScroll:!0}))}function I1(e){let t=e.closest(`section.file-card`);t&&t.dataset[P1]!==void 0&&(delete t.dataset[P1],t.querySelector(`.file-header`)?.contains(document.activeElement)&&e.focus({preventScroll:!0}))}var L1=[{title:`Anywhere on the page`,keys:[[`?`,`Show this list`],[`n / p`,`Go to the next / previous file`],[`t`,`Find a file: focus the filter of the file tree`],[`f`,`Find a function, class or type by name`],[`Alt + click`,`On a name in the code: go to its definition`],[`v`,`Mark the current file as viewed, or take the mark off`],[`s`,`Stage or unstage the current file (when comparing with the working tree)`]]},{title:`Inside a file’s diff`,keys:[[`↑ ↓ or j k`,`Move the line cursor`],[`← →`,`In the split view: move the cursor to the other side`],[`Shift + ↑ ↓`,`Select several lines`],[`c`,`Comment on the line or the selection`],[`Enter`,`Put a link to the line into the address bar`],[`Esc`,`Take the cursor away`]]},{title:`While writing`,keys:[[`Ctrl/Cmd + Enter`,`Send the comment, or commit`],[`Esc`,`Close an empty comment form, or a dialog`]]}];function R1({onClose:e}){let t=(0,f.useRef)(null);return Ua(t),(0,f.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),(0,_.jsx)(`div`,{className:`modal-backdrop`,onClick:t=>t.target===t.currentTarget&&e(),children:(0,_.jsxs)(`div`,{ref:t,className:`dialog modal shortcuts-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`shortcuts-title`,children:[(0,_.jsx)(`h2`,{id:`shortcuts-title`,className:`dialog-title`,children:`Keyboard shortcuts`}),L1.map(e=>(0,_.jsxs)(`section`,{children:[(0,_.jsx)(`h3`,{className:`shortcuts-group`,children:e.title}),(0,_.jsx)(`dl`,{className:`shortcuts-list`,children:e.keys.map(([e,t])=>(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`dt`,{children:(0,_.jsx)(`kbd`,{children:e})}),(0,_.jsx)(`dd`,{children:t})]},e))})]},e.title)),(0,_.jsx)(`div`,{className:`dialog-actions`,children:(0,_.jsx)(`button`,{type:`button`,className:`button`,autoFocus:!0,onClick:e,children:`Close`})})]})})}var z1=500,B1=e=>e.reduce((e,[t,n])=>e+(n-t),0);function V1(e,t){let n=[];for(let r of t){let t=n.at(-1);t&&e.slice(t[1],r[0]).trim()===``?n[n.length-1]=[t[0],r[1]]:n.push(r)}return n}function H1(e,t){if(e.length>z1||t.length>z1)return;let n=[],r=[],i=0,a=0,o=0;for(let s of hn(e,t)){let e=s.value.length;s.removed?(n.push([i,i+e]),i+=e):s.added?(r.push([a,a+e]),a+=e):(o+=s.value.trim().length,i+=e,a+=e)}if((n.length!==0||r.length!==0)&&o!==0&&!(B1(n)>=e.length&&B1(r)>=t.length))return{old:V1(e,n),new:V1(t,r)}}function U1(e,t,n){let r=t&&t.length>0?t:[[e]];if(!n||n.length===0)return r.map(([e,t,n])=>({text:e,color:t,italic:n,mark:!1}));let i=[],a=0,o=0;for(let[e,t,s]of r){let r=0;for(;r<e.length;){for(;o<n.length&&n[o][1]<=a+r;)o+=1;let c=n[o],l=a+r,u=c!==void 0&&l>=c[0],d=c===void 0?1/0:u?c[1]:c[0],f=Math.min(e.length,d-a);i.push({text:e.slice(r,f),color:t,italic:s,mark:u}),r=f}a+=e.length}return i}var W1=3e3,G1=`agentic-diff:first-rows`,K1=(0,f.memo)(function({text:e,tokens:t,ranges:n,noEol:r}){return(0,_.jsxs)(_.Fragment,{children:[U1(e,t,n).map((e,t)=>e.mark||e.color||e.italic?(0,_.jsx)(`span`,{className:e.mark?`word`:void 0,style:e.color||e.italic?{color:e.color,fontStyle:e.italic?`italic`:void 0}:void 0,children:e.text},t):e.text),r&&(0,_.jsx)(`span`,{className:`no-eol`,title:`No newline at end of file`,children:(0,_.jsx)(Ji,{size:12,"aria-label":`No newline at end of file`})})]})}),q1=800,J1=250,Y1=20;function X1({rows:e,pinned:t,children:n}){let r=(0,f.useRef)(null),[i,a]=(0,f.useState)(!1),o=(0,f.useRef)(void 0),s=t||i;return(0,f.useEffect)(()=>{let e=r.current;if(!e)return;let t=new IntersectionObserver(e=>a(e.some(e=>e.isIntersecting)),{rootMargin:`1500px 0px`});return t.observe(e),()=>t.disconnect()},[]),(0,f.useLayoutEffect)(()=>{s&&r.current&&(o.current=r.current.offsetHeight)}),(0,_.jsx)(`div`,{ref:r,style:s?void 0:{height:o.current??e*Y1},children:s?n:null})}var Z1={all:{icon:Ra,label:`Expand all`},down:{icon:oi,label:`Expand down`},up:{icon:li,label:`Expand up`}};function Q1({item:e,onExpand:t}){return(0,_.jsx)(`div`,{className:`expander`,children:e.actions.map(n=>{let{icon:r,label:i}=Z1[n];return(0,_.jsx)(`button`,{type:`button`,className:`expander-button`,"aria-label":i,title:i,onClick:()=>t(e.gap,n,e.gapLength),children:(0,_.jsx)(r,{size:16})},n)})})}function $1(e,t,n){return e!==void 0&&e.side===t&&e.line===n}var e0=(e,t,n)=>n!==void 0&&e.some(e=>e.side===t&&n>=e.startLine&&n<=e.endLine),t0=[];function n0(e){let t=e?.closest(`.code[data-line]`),n=t?.dataset.side;if(!(!t||n!==`L`&&n!==`R`))return{side:n,line:Number(t.dataset.line),cell:t}}function r0({items:e,view:t,anchor:n,old:r,next:i,pairs:a,target:o,inserts:s,highlights:c=t0,label:l,onExpand:u,onSelectLine:d,onComment:p}){let m=(0,f.useRef)(null);(0,f.useEffect)(()=>{performance.getEntriesByName(G1).length===0&&performance.mark(G1),m.current&&I1(m.current)},[]);let h=(0,f.useMemo)(()=>{let e=new Map;if(a.size/2>W1)return e;for(let[t,n]of a){if(t.t!==`del`||n.t!==`add`)continue;let a=H1(r.lines[t.old-1]??``,i.lines[n.new-1]??``);a&&(e.set(t,a.old),e.set(n,a.new))}return e},[a,r.lines,i.lines]),g=(0,f.useRef)(null),v=(0,f.useRef)(void 0),[y,b]=(0,f.useState)(void 0),[x,S]=(0,f.useState)(void 0),C=e=>({side:e.side,startLine:Math.min(e.from,e.to),endLine:Math.max(e.from,e.to)}),w=y?C(y):x&&x.from!==x.to?C(x):void 0,T=w?[...c,w]:c,E=(e,t)=>x!==void 0&&x.side===e&&x.to===t;(0,f.useEffect)(()=>{if(!y)return;let e=e=>{let t=n0(document.elementFromPoint(e.clientX,e.clientY));t&&t.side===y.side&&m.current?.contains(t.cell)&&t.line!==y.to&&b({...y,to:t.line})},t=()=>{b(void 0),p?.({side:y.side,startLine:Math.min(y.from,y.to),endLine:Math.max(y.from,y.to)})};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[y,p]),(0,f.useEffect)(()=>{g.current&&(g.current.hidden=!0)},[e,s,t]);let D=(e,t)=>`diff-${n}${e}${t}`,O=(e,t,n=``)=>(0,_.jsx)(`div`,{className:`num ${n}`,id:t===void 0?void 0:D(e,t),"data-side":e,"data-line":t,children:t}),ee=e=>(0,_.jsx)(K1,{text:r.lines[e.old-1]??``,tokens:r.tokens?.[e.old-1],ranges:h.get(e),noEol:e.noEol}),k=e=>(0,_.jsx)(K1,{text:i.lines[e.new-1]??``,tokens:i.tokens?.[e.new-1],ranges:h.get(e),noEol:e.noEol}),te=[],ne=[],A=(e,t=!1)=>{te.push(e),ne.push(t)},j=(e,n)=>{let r=e===void 0?void 0:s?.get(`L${e}`),i=n===void 0?void 0:s?.get(`R${n}`);if(!r&&!i)return;let a=`insert:${r?`L${e}`:``}:${i?`R${n}`:``}`;A(t===`split`?(0,_.jsxs)(`div`,{className:`diff-insert split-insert`,children:[(0,_.jsx)(`div`,{className:`insert-half`,children:r}),(0,_.jsx)(`div`,{className:`insert-half`,children:i})]},a):(0,_.jsxs)(`div`,{className:`diff-insert`,children:[r,i]},a),!0)},M=(e,t)=>{let n=t.t===`add`?void 0:t.old,r=t.t===`del`?void 0:t.new,i=$1(o,`L`,n)||$1(o,`R`,r),a=t.t===`del`?`L`:`R`,s=t.t===`del`?t.old:t.new,c=e0(T,a,s);A((0,_.jsxs)(`div`,{className:`diff-row ${t.t}${i?` selected`:``}${c?` commenting`:``}${E(a,s)?` cursor`:``}`,children:[O(`L`,n),O(`R`,r),(0,_.jsx)(`div`,{className:`code`,"data-marker":t.t===`add`?`+`:t.t===`del`?`-`:` `,"data-side":a,"data-line":s,children:t.t===`del`?ee(t):k(t)})]},e),i||c||E(a,s)),j(n,r)},N=(e,t,n)=>{let r=t&&t.t!==`add`?t:void 0,i=n&&n.t!==`del`?n:void 0,a=r?r.t:`empty`,s=i?i.t:`empty`,c=e0(T,`L`,r?.old)?` commenting`:``,l=e0(T,`R`,i?.new)?` commenting`:``;A((0,_.jsxs)(`div`,{className:`diff-row`,children:[O(`L`,r?.old,`${a}${$1(o,`L`,r?.old)?` selected`:``}${c}`),(0,_.jsx)(`div`,{className:`code side-left ${a}${c}${E(`L`,r?.old)?` cursor`:``}`,"data-marker":r?.t===`del`?`-`:` `,"data-side":`L`,"data-line":r?.old,children:r&&ee(r)}),O(`R`,i?.new,`${s}${$1(o,`R`,i?.new)?` selected`:``}${l}`),(0,_.jsx)(`div`,{className:`code side-right ${s}${l}${E(`R`,i?.new)?` cursor`:``}`,"data-marker":i?.t===`add`?`+`:` `,"data-side":`R`,"data-line":i?.new,children:i&&k(i)})]},e),c!==``||l!==``||$1(o,`L`,r?.old)||$1(o,`R`,i?.new)||E(`L`,r?.old)||E(`R`,i?.new)),j(r?.old,i?.new)},P=[],re=()=>{if(P.length!==0){if(t===`unified`)for(let e of P)M(e.key,e.row);else for(let e of E1(P.map(e=>e.row)))N(e.key,e.left,e.right);P=[]}};for(let t of e)t.kind===`row`?P.push(t):(re(),A((0,_.jsxs)(`div`,{className:`diff-row hunk`,children:[(0,_.jsx)(Q1,{item:t,onExpand:u}),(0,_.jsx)(`div`,{className:`code hunk-text`,children:t.kind===`hunk`?O1(t.hunk):``})]},t.key)));re();let ie=te;if(te.length>q1){let e=[];for(let t=0;t<te.length;t+=J1){let n=Math.min(t+J1,te.length);e.push((0,_.jsx)(X1,{rows:n-t,pinned:ne.slice(t,n).some(Boolean),children:te.slice(t,n)},t))}ie=e}return(0,_.jsxs)(`div`,{ref:m,className:`diff-rows ${t}`,tabIndex:0,role:`group`,"aria-label":l,onClick:e=>{let t=e.target.closest(`.num[data-line]`),n=t?.dataset.side;t?.dataset.line&&(n===`L`||n===`R`)&&d(n,Number(t.dataset.line))},onMouseDown:e=>{let t=e.target.closest(`.code`);e.currentTarget.dataset.selecting=t?.classList.contains(`side-left`)?`left`:t?.classList.contains(`side-right`)?`right`:``},onMouseOver:e=>{let t=g.current;if(!t||y||t.contains(e.target))return;let n=n0(e.target);if(!n||!m.current)return;v.current={side:n.side,line:n.line};let r=m.current.getBoundingClientRect(),i=n.cell.getBoundingClientRect();t.style.top=`${i.top-r.top}px`,t.style.left=`${i.left-r.left}px`,t.hidden=!1,t.setAttribute(`aria-label`,`Add a comment on line ${n.side}${n.line}`)},onMouseLeave:()=>{g.current&&!y&&(g.current.hidden=!0)},onKeyDown:e=>{if(e.target!==e.currentTarget||e.metaKey||e.ctrlKey||e.altKey)return;let n=j1(e),r=n===`ArrowDown`||n===`j`?1:n===`ArrowUp`||n===`k`?-1:0,i=t!==`split`||e.shiftKey?void 0:n===`ArrowLeft`?`L`:n===`ArrowRight`?`R`:void 0;if(r!==0||i&&x&&x.side!==i){let n=Array.from(e.currentTarget.querySelectorAll(`.code[data-line]`));if(n.length===0)return;e.preventDefault();let a=x?n.findIndex(e=>e.dataset.side===x.side&&Number(e.dataset.line)===x.to):-1,o;if(a<0){let e=n.findIndex(e=>e.getBoundingClientRect().bottom>0);o=n[Math.max(0,e)]}else if(i){let e=n[a],t=e=>e?.dataset.side===i;o=[n[a-1],n[a+1]].find(n=>t(n)&&n?.parentElement===e.parentElement)??n.slice(a+1).find(t)??n.slice(0,a).reverse().find(t)}else{let i=a+r;if((t===`split`||e.shiftKey)&&x)for(;n[i]&&n[i]?.dataset.side!==x.side;)i+=r;o=n[i]}if(!o)return;let s=o.dataset.side,c=Number(o.dataset.line);S(e.shiftKey&&x&&x.side===s?{...x,to:c}:{side:s,from:c,to:c}),o.scrollIntoView({block:`nearest`})}else x&&(n===`c`&&p?(e.preventDefault(),p(C(x))):n===`Enter`?(e.preventDefault(),d(x.side,x.to)):n===`Escape`&&S(void 0))},children:[ie,p&&(0,_.jsx)(`button`,{ref:g,type:`button`,hidden:!0,className:`add-comment`,title:`Add a comment. Drag to select several lines.`,onMouseDown:e=>{v.current&&e.button===0&&(e.preventDefault(),b({side:v.current.side,from:v.current.line,to:v.current.line}))},children:(0,_.jsx)(H,{size:16})})]})}var i0=(0,f.lazy)(()=>i1(()=>import(`./FileEditor-B0Fp6d7u.js`),[])),a0=2e3,o0=`:worktree`;function s0(e){let[t,n]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let r=e.current;if(!r||t)return;let i=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&n(!0)},{rootMargin:`1200px 0px`});return i.observe(r),()=>i.disconnect()},[e,t]),t}function c0(e){let[t,n]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=e.current;if(!t)return;let r=new IntersectionObserver(e=>n(e.some(e=>e.isIntersecting)),{rootMargin:`3000px 0px`});return r.observe(t),()=>r.disconnect()},[e]),t}function l0(e,t,n){let r=(0,f.useMemo)(()=>e?.text===void 0?void 0:It(e.text),[e]),i=s1(t),a=et({queryKey:[`tokens`,e?.oid,i],queryFn:()=>X_(i,r),enabled:n&&i!==void 0&&r!==void 0&&Z_(r,e?.text?.length??0),staleTime:1/0,retry:!1});return(0,f.useMemo)(()=>r?{lines:r,tokens:a.data}:void 0,[r,a.data])}function u0({children:e}){return(0,_.jsx)(`div`,{className:`diff-message`,children:e})}function d0({path:e}){let[t,n]=(0,f.useState)(!1);return(0,_.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":t?`Copied`:`Copy file path`,title:`Copy file path`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1500)})},children:t?(0,_.jsx)(er,{size:16}):(0,_.jsx)(wr,{size:16})})}var f0=e=>`${(e/1024/1024).toFixed(1)} MB`,p0={borderBottom:0,borderRadius:`var(--borderRadius-medium)`},m0=e=>e.side===`file`?`file`:`${e.side}${e.startLine}-${e.endLine}`,h0=(0,f.memo)(function({repoId:e,comparison:t,file:n,view:r,target:i,scrollToTarget:a,threads:o,scope:s,viewed:c=!1,onViewed:l,readOnly:u=!1,staging:d,onStage:p,onSelectLine:m,isSettling:h,listedAt:g}){let v=(0,f.useRef)(null),y=s0(v),b=c0(v),x=(0,f.useRef)(null),S=(0,f.useRef)(void 0),C=a&&i?.line!==void 0,w=C?`${i?.side??``}${i?.line??``}`:void 0,[T,E]=(0,f.useState)(C),[D,O]=(0,f.useState)(c&&!C);(0,f.useEffect)(()=>{if(!(c&&T)){if(c){let e=v.current,t=document.activeElement,n=e?.querySelector(`.file-header`);e&&n&&t&&e.contains(t)&&!n.contains(t)&&n.querySelector(`button`)?.focus({preventScroll:!0})}O(c)}},[c]);let[ee,k]=(0,f.useState)(!1),[te,ne]=(0,f.useState)({}),[A,j]=(0,f.useState)([]),[M,N]=(0,f.useState)(!1),[P,re]=(0,f.useState)(void 0),[ie,ae]=(0,f.useState)(!1),[oe,se]=(0,f.useState)(!1),[ce,le]=(0,f.useState)(void 0),ue=b_(),de=B_(e),fe=Za(),pe=n.kind===`text`,F=En(n.path)===void 0?pe&&Dn(n.path)?`markdown`:void 0:`image`,I=F!==void 0&&(oe||n.kind===`binary`),me=n.additions+n.deletions>a0,he=(y||i!==void 0||M)&&!D&&pe&&(!me||ee||M),{diffFrom:ge,diffTo:_e,ignoreWhitespace:ve}=t,L=n.status!==`deleted`,ye=L&&!n.newOid&&_e===o0,be=`${n.oldOid??``}..${_e===o0?o0:n.newOid??``}`,[xe,Se]=(0,f.useState)({versions:be,ignoreWhitespace:ve});(xe.versions!==be||xe.ignoreWhitespace!==ve)&&(Se({versions:be,ignoreWhitespace:ve}),ne({}),xe.versions!==be&&(k(C),se(!1),ae(!1),le(void 0),O(c&&!T)));let Ce=et({queryKey:[`diff`,e,ge,_e,n.path,n.oldPath,ve],queryFn:()=>z.diff(e,ge,_e,n.path,n.oldPath,ve),enabled:he&&!n.untracked}),R=et({queryKey:[`blob`,e,n.oldOid],queryFn:()=>z.blob(e,n.oldOid),enabled:he&&n.oldOid!==void 0,staleTime:1/0}),we=et({queryKey:[`blob`,e,n.newOid],queryFn:()=>z.blob(e,n.newOid),enabled:he&&L&&n.newOid!==void 0,staleTime:1/0}),Te=et({queryKey:[`worktree-file`,e,n.path],queryFn:()=>z.worktreeFile(e,n.path),enabled:he&&(ye||M&&L)}),Ee=ye?Te:we,De=n.oldOid!==void 0&&R.isPending,Oe=L&&(n.newOid!==void 0||ye)&&Ee.isPending,ke=he&&(!n.untracked&&Ce.isPending||De||Oe),Ae=Ce.error??R.error??Ee.error,je=he&&!ke&&!Ae,Me=(0,f.useMemo)(()=>je?{diff:Ce.data,oldBlob:R.data,newBlob:Ee.data}:void 0,[je,Ce.data,R.data,Ee.data]),Ne=(0,f.useRef)(void 0);Me&&(Ne.current=Me);let Pe=Me??(Ae?void 0:Ne.current),Fe=Pe!==void 0,Ie=l0(Pe?.oldBlob,n.oldPath??n.path,he),Le=l0(Pe?.newBlob,n.path,he),Re=(0,f.useMemo)(()=>n.untracked?h1(Le?.lines.length??0):Pe?.diff?.hunks??[],[n.untracked,Le,Pe]),ze=(0,f.useMemo)(()=>({lines:[]}),[]),Be=Ie??ze,Ve=Le??ze,He=(0,f.useMemo)(()=>v1(Re,Ve.lines.length),[Re,Ve.lines.length]),Ue=(0,f.useMemo)(()=>w1(Re,He,te),[Re,He,te]),We=(0,f.useMemo)(()=>D1(Re.flatMap(e=>e.rows)),[Re]),Ge=(0,f.useCallback)((e,t,n)=>{ne(r=>x1(r,e,t,n))},[]),Ke=(0,f.useCallback)((e,t)=>m(n.anchor,e,t),[m,n.anchor]),qe=M&&P===void 0&&!Te.isFetching?Te.data:void 0;qe?.text!==void 0&&!qe.lossy&&!De&&re(qe),!M&&P!==void 0&&re(void 0);let Je=M&&P!==void 0,Ye=M&&P===void 0&&Te.isError?Te.error.message:qe?.lossy?`it is not UTF-8 text, and saving it from here would damage it`:void 0;(0,f.useEffect)(()=>{Ye!==void 0&&(N(!1),le(`Could not open the file for editing: ${Ye}`))},[Ye]);let Xe=(0,f.useMemo)(()=>ie?[]:o.filter(e=>e.side!==`file`&&!e.outdated&&e.endLine!==void 0),[o,ie]),Ze=(0,f.useMemo)(()=>ie?[]:o.filter(e=>e.side===`file`||e.outdated),[o,ie]),Qe=e=>e===`L`?n.oldPath??n.path:n.path,$e=e=>e.side===`file`?`${s}|${n.path}|file`:`${s}|${Qe(e.side)}|${e.side}|${e.startLine}-${e.endLine}`,tt=(0,f.useMemo)(()=>A.filter(e=>e.side!==`file`),[A]),nt=A.find(e=>e.side===`file`),rt=e=>Fe&&e.endLine>(e.side===`L`?Be:Ve).lines.length,it=e=>{let t=m0(e);j(n=>n.some(e=>m0(e)===t)?n:[...n,e]);let n=$e(e);[...v.current?.querySelectorAll(`form.comment-form`)??[]].find(e=>e.dataset.draft===n)?.querySelector(`textarea`)?.focus()},at=e=>{let t=m0(e);j(e=>e.filter(e=>m0(e)!==t))},ot=(0,f.useRef)(it);ot.current=it;let st=(0,f.useCallback)(e=>ot.current(e),[]);(0,f.useEffect)(()=>{if(Re.length===0)return;let e=Xe.map(e=>({side:e.side,line:e.endLine}));for(let t of tt)e.push({side:t.side,line:t.endLine});i?.side&&i.line&&e.push({side:i.side,line:i.line}),e.length>0&&ne(t=>b1(t,He,e))},[Xe,tt,i,He,Re.length]);let ct=(e,t)=>h?.()?Promise.reject(Error(`The comparison is still loading. Send the comment again in a moment.`)):de.create({scope:s,from:ge,to:_e,path:Qe(e.side),side:e.side,startLine:e.side===`file`?void 0:e.startLine,endLine:e.side===`file`?void 0:e.endLine,body:t}).then(n=>{at(e),fe.startIfMentioned(n.id,t)}),lt=(t,n)=>{let{side:r,startLine:i,endLine:a}=t,o=r===`L`?Be.lines:Ve.lines,s=i===a?`line ${r}${i}`:`lines ${r}${i} to ${r}${a}`;return(0,_.jsx)(z_,{repoId:e,draftKey:$e(t),title:n?`Add a comment on ${s} (no longer in this file)`:`Add a comment on ${s}`,submitLabel:`Comment`,suggestionSeed:r===`R`&&!n?o.slice(i-1,a).join(`
|
|
59
|
+
`)),n=[]};for(let t of e){let e=c1.exec(t)?.[1];r?(n.push(t),e&&e[0]===r[0]&&e.length>=r.length&&t.trim()===e&&(r=void 0,i())):e?(i(),r=e,n.push(t)):t.trim()===``?i():n.push(t)}return i(),t}function u1(e,t){let n=[];for(let r of bn(l1(e),l1(t))){let e=r.added?`added`:r.removed?`removed`:`same`;for(let t of r.value)n.push({kind:e,text:t})}return n}var d1={added:`Added`,removed:`Removed`},f1=(0,f.memo)(function({oldLines:e,newLines:t}){let n=(0,f.useMemo)(()=>u1(e,t),[e,t]);return(0,_.jsx)(`div`,{className:`rich-diff`,"aria-label":`Rendered document with changes marked`,children:n.map((e,t)=>e.kind===`same`?(0,_.jsx)(`div`,{className:`rich-block`,children:(0,_.jsx)(Ng,{text:e.text})},t):(0,_.jsxs)(`div`,{className:`rich-block rich-${e.kind}`,"aria-label":d1[e.kind],children:[(0,_.jsx)(`span`,{className:`rich-mark`,"aria-hidden":`true`,children:e.kind===`added`?`+`:`−`}),(0,_.jsx)(Ng,{text:e.text})]},t))})});function p1({src:e,label:t,tone:n}){let[r,i]=(0,f.useState)(void 0),[a,o]=(0,f.useState)(!1);return(0,_.jsxs)(`figure`,{className:`image-side image-${n}`,children:[(0,_.jsxs)(`figcaption`,{children:[(0,_.jsx)(`strong`,{children:t}),r&&(0,_.jsx)(`span`,{className:`image-size`,children:r})]}),a?(0,_.jsx)(`p`,{className:`image-failed`,children:`This image could not be shown.`}):(0,_.jsx)(`img`,{src:e,alt:t,onLoad:e=>i(`${e.currentTarget.naturalWidth} × ${e.currentTarget.naturalHeight}`),onError:()=>o(!0)})]})}function m1({before:e,after:t}){return(0,_.jsxs)(`div`,{className:`image-diff`,children:[e&&(0,_.jsx)(p1,{src:e,label:t?`Before`:`Deleted`,tone:`removed`}),t&&(0,_.jsx)(p1,{src:t,label:e?`After`:`Added`,tone:`added`})]})}function h1(e){return e===0?[]:[{oldStart:0,oldLines:0,newStart:1,newLines:e,section:``,rows:Array.from({length:e},(e,t)=>({t:`add`,new:t+1}))}]}var g1=e=>e.oldLines===0?e.oldStart+1:e.oldStart,_1=e=>e.newLines===0?e.newStart+1:e.newStart;function v1(e,t){let n=1,r=1,i=e.map(e=>{let t={oldStart:n,newStart:r,length:Math.max(0,_1(e)-r)};return n=g1(e)+e.oldLines,r=_1(e)+e.newLines,t});return i.push({oldStart:n,newStart:r,length:Math.max(0,t-r+1)}),i}function y1(e,t,n){let r=e.findIndex(e=>{let r=t===`L`?e.oldStart:e.newStart;return n>=r&&n<r+e.length});return r<0?void 0:r}function b1(e,t,n){let r=e;for(let{side:e,line:i}of n){let n=y1(t,e,i);if(n===void 0)continue;let a=t[n],o=r[n]??{top:0,bottom:0},s=i-(e===`L`?a.oldStart:a.newStart);s<o.top||s>=a.length-o.bottom||(r=x1(r,n,`all`,a.length))}return r}function x1(e,t,n,r){let i=e[t]??{top:0,bottom:0},a=n===`all`?{top:r,bottom:0}:n===`down`?{...i,top:i.top+20}:{...i,bottom:i.bottom+20};return{...e,[t]:a}}var S1=e=>`${e.t}:${`old`in e?e.old:``}:${`new`in e?e.new:``}`;function C1(e,t,n){let r=[];for(let i=t;i<n;i+=1){let t={t:`ctx`,old:e.oldStart+i,new:e.newStart+i};r.push({kind:`row`,key:S1(t),row:t})}return r}function w1(e,t,n){let r=[];if(e.forEach((e,i)=>{let a=t[i],o=n[i]??{top:0,bottom:0},s=Math.min(o.top,a.length),c=Math.min(o.bottom,a.length-s),l=a.length-s-c;if(r.push(...C1(a,0,s)),l>0||a.length===0){let t=l===0?[]:l<=20?[`all`]:i===0?[`up`]:[`down`,`up`];r.push({kind:`hunk`,key:`hunk:${i}`,gap:i,gapLength:a.length,hunk:e,actions:t})}r.push(...C1(a,a.length-c,a.length));for(let t of e.rows)r.push({kind:`row`,key:S1(t),row:t})}),e.length>0){let i=e.length,a=t[i],o=Math.min(n[i]?.top??0,a.length),s=a.length-o;r.push(...C1(a,0,o)),s>0&&r.push({kind:`tail`,key:`tail`,gap:i,gapLength:a.length,actions:[s<=20?`all`:`down`]})}return r}function T1(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.t===`ctx`){t.push({ctx:r}),n+=1;continue}let i=[],a=[];for(;e[n]?.t===`del`;)i.push(e[n++]);for(;e[n]?.t===`add`;)a.push(e[n++]);t.push({dels:i,adds:a})}return t}function E1(e){let t=[];for(let n of T1(e)){if(`ctx`in n){t.push({key:S1(n.ctx),left:n.ctx,right:n.ctx});continue}let e=Math.max(n.dels.length,n.adds.length);for(let r=0;r<e;r+=1){let e=n.dels[r],i=n.adds[r];t.push({key:`${e?S1(e):``}|${i?S1(i):``}`,left:e,right:i})}}return t}function D1(e){let t=new Map;for(let n of T1(e))`ctx`in n||n.dels.length!==n.adds.length||n.dels.forEach((e,r)=>{let i=n.adds[r];t.set(e,i),t.set(i,e)});return t}function O1(e){let t=`@@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@`;return e.section?`${t} ${e.section}`:t}var k1=new Set([`text`,`search`,`url`,`tel`,`email`,`password`,`number`,`date`,`datetime-local`,`month`,`time`,`week`]);function A1(e){return e instanceof HTMLElement?e.closest(`[role="dialog"], [role="menu"]`)?!0:e instanceof HTMLInputElement?k1.has(e.type):e.isContentEditable||e.closest(`textarea, select, [contenteditable="true"], .cm-editor`)!==null:!1}function j1(e){let{key:t}=e;if(/^[A-Za-z]$/.test(t))return e.shiftKey?t:t.toLowerCase();let n=/^Key([A-Z])$/.exec(e.code)?.[1],r=[...t].length===1&&(t.codePointAt(0)??0)>127;return n&&r&&!e.shiftKey?n.toLowerCase():t}function M1(e){let t=(0,f.useRef)(e);t.current=e,(0,f.useEffect)(()=>{let e=e=>{if(e.ctrlKey||e.metaKey||e.altKey||e.defaultPrevented||e.isComposing||A1(e.target)||document.querySelector(`[aria-modal="true"], [role="menu"]`))return;let n=t.current[j1(e)];n&&(e.preventDefault(),n())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[])}function N1(){return document.activeElement?.closest(`section.file-card`)||[...document.querySelectorAll(`section.file-card`)].find(e=>e.getBoundingClientRect().bottom>80)}var P1=`focusRows`;function F1(e){let t=[...document.querySelectorAll(`section.file-card`)],n=N1(),r=n?t.indexOf(n):-1,i=n!==void 0&&(document.activeElement?.closest(`section.file-card`)===n||n.getBoundingClientRect().top<0),a=t[r<0?0:e===1&&!i?r:r+e];if(!a)return;for(let e of t)delete e.dataset[P1];a.scrollIntoView({block:`start`});let o=a.querySelector(`.diff-rows`);o?o.focus({preventScroll:!0}):(a.dataset[P1]=``,a.querySelector(`.file-header button`)?.focus({preventScroll:!0}))}function I1(e){let t=e.closest(`section.file-card`);t&&t.dataset[P1]!==void 0&&(delete t.dataset[P1],t.querySelector(`.file-header`)?.contains(document.activeElement)&&e.focus({preventScroll:!0}))}var L1=[{title:`Anywhere on the page`,keys:[[`?`,`Show this list`],[`n / p`,`Go to the next / previous file`],[`t`,`Find a file: focus the filter of the file tree`],[`f`,`Find a function, class or type by name`],[`Alt + click`,`On a name in the code: go to its definition`],[`v`,`Mark the current file as viewed, or take the mark off`],[`s`,`Stage or unstage the current file (when comparing with the working tree)`]]},{title:`Inside a file’s diff`,keys:[[`↑ ↓ or j k`,`Move the line cursor`],[`← →`,`In the split view: move the cursor to the other side`],[`Shift + ↑ ↓`,`Select several lines`],[`c`,`Comment on the line or the selection`],[`Enter`,`Put a link to the line into the address bar`],[`Esc`,`Take the cursor away`]]},{title:`While writing`,keys:[[`Ctrl/Cmd + Enter`,`Send the comment, or commit`],[`Esc`,`Close an empty comment form, or a dialog`]]}];function R1({onClose:e}){let t=(0,f.useRef)(null);return Ua(t),(0,f.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),(0,_.jsx)(`div`,{className:`modal-backdrop`,onClick:t=>t.target===t.currentTarget&&e(),children:(0,_.jsxs)(`div`,{ref:t,className:`dialog modal shortcuts-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`shortcuts-title`,children:[(0,_.jsx)(`h2`,{id:`shortcuts-title`,className:`dialog-title`,children:`Keyboard shortcuts`}),L1.map(e=>(0,_.jsxs)(`section`,{children:[(0,_.jsx)(`h3`,{className:`shortcuts-group`,children:e.title}),(0,_.jsx)(`dl`,{className:`shortcuts-list`,children:e.keys.map(([e,t])=>(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`dt`,{children:(0,_.jsx)(`kbd`,{children:e})}),(0,_.jsx)(`dd`,{children:t})]},e))})]},e.title)),(0,_.jsx)(`div`,{className:`dialog-actions`,children:(0,_.jsx)(`button`,{type:`button`,className:`button`,autoFocus:!0,onClick:e,children:`Close`})})]})})}var z1=500,B1=e=>e.reduce((e,[t,n])=>e+(n-t),0);function V1(e,t){let n=[];for(let r of t){let t=n.at(-1);t&&e.slice(t[1],r[0]).trim()===``?n[n.length-1]=[t[0],r[1]]:n.push(r)}return n}function H1(e,t){if(e.length>z1||t.length>z1)return;let n=[],r=[],i=0,a=0,o=0;for(let s of hn(e,t)){let e=s.value.length;s.removed?(n.push([i,i+e]),i+=e):s.added?(r.push([a,a+e]),a+=e):(o+=s.value.trim().length,i+=e,a+=e)}if((n.length!==0||r.length!==0)&&o!==0&&!(B1(n)>=e.length&&B1(r)>=t.length))return{old:V1(e,n),new:V1(t,r)}}function U1(e,t,n){let r=t&&t.length>0?t:[[e]];if(!n||n.length===0)return r.map(([e,t,n])=>({text:e,color:t,italic:n,mark:!1}));let i=[],a=0,o=0;for(let[e,t,s]of r){let r=0;for(;r<e.length;){for(;o<n.length&&n[o][1]<=a+r;)o+=1;let c=n[o],l=a+r,u=c!==void 0&&l>=c[0],d=c===void 0?1/0:u?c[1]:c[0],f=Math.min(e.length,d-a);i.push({text:e.slice(r,f),color:t,italic:s,mark:u}),r=f}a+=e.length}return i}var W1=3e3,G1=`agentic-diff:first-rows`,K1=(0,f.memo)(function({text:e,tokens:t,ranges:n,noEol:r}){return(0,_.jsxs)(_.Fragment,{children:[U1(e,t,n).map((e,t)=>e.mark||e.color||e.italic?(0,_.jsx)(`span`,{className:e.mark?`word`:void 0,style:e.color||e.italic?{color:e.color,fontStyle:e.italic?`italic`:void 0}:void 0,children:e.text},t):e.text),r&&(0,_.jsx)(`span`,{className:`no-eol`,title:`No newline at end of file`,children:(0,_.jsx)(Ji,{size:12,"aria-label":`No newline at end of file`})})]})}),q1=800,J1=250,Y1=20;function X1({rows:e,pinned:t,children:n}){let r=(0,f.useRef)(null),[i,a]=(0,f.useState)(!1),o=(0,f.useRef)(void 0),s=t||i;return(0,f.useEffect)(()=>{let e=r.current;if(!e)return;let t=new IntersectionObserver(e=>a(e.some(e=>e.isIntersecting)),{rootMargin:`1500px 0px`});return t.observe(e),()=>t.disconnect()},[]),(0,f.useLayoutEffect)(()=>{s&&r.current&&(o.current=r.current.offsetHeight)}),(0,_.jsx)(`div`,{ref:r,style:s?void 0:{height:o.current??e*Y1},children:s?n:null})}var Z1={all:{icon:Ra,label:`Expand all`},down:{icon:oi,label:`Expand down`},up:{icon:li,label:`Expand up`}};function Q1({item:e,onExpand:t}){return(0,_.jsx)(`div`,{className:`expander`,children:e.actions.map(n=>{let{icon:r,label:i}=Z1[n];return(0,_.jsx)(`button`,{type:`button`,className:`expander-button`,"aria-label":i,title:i,onClick:()=>t(e.gap,n,e.gapLength),children:(0,_.jsx)(r,{size:16})},n)})})}function $1(e,t,n){return e!==void 0&&e.side===t&&e.line===n}var e0=(e,t,n)=>n!==void 0&&e.some(e=>e.side===t&&n>=e.startLine&&n<=e.endLine),t0=[];function n0(e){let t=e?.closest(`.code[data-line]`),n=t?.dataset.side;if(!(!t||n!==`L`&&n!==`R`))return{side:n,line:Number(t.dataset.line),cell:t}}function r0({items:e,view:t,anchor:n,old:r,next:i,pairs:a,target:o,inserts:s,highlights:c=t0,label:l,onExpand:u,onSelectLine:d,onComment:p}){let m=(0,f.useRef)(null);(0,f.useEffect)(()=>{performance.getEntriesByName(G1).length===0&&performance.mark(G1),m.current&&I1(m.current)},[]);let h=(0,f.useMemo)(()=>{let e=new Map;if(a.size/2>W1)return e;for(let[t,n]of a){if(t.t!==`del`||n.t!==`add`)continue;let a=H1(r.lines[t.old-1]??``,i.lines[n.new-1]??``);a&&(e.set(t,a.old),e.set(n,a.new))}return e},[a,r.lines,i.lines]),g=(0,f.useRef)(null),v=(0,f.useRef)(void 0),[y,b]=(0,f.useState)(void 0),[x,S]=(0,f.useState)(void 0),C=e=>({side:e.side,startLine:Math.min(e.from,e.to),endLine:Math.max(e.from,e.to)}),w=y?C(y):x&&x.from!==x.to?C(x):void 0,T=w?[...c,w]:c,E=(e,t)=>x!==void 0&&x.side===e&&x.to===t;(0,f.useEffect)(()=>{if(!y)return;let e=e=>{let t=n0(document.elementFromPoint(e.clientX,e.clientY));t&&t.side===y.side&&m.current?.contains(t.cell)&&t.line!==y.to&&b({...y,to:t.line})},t=()=>{b(void 0),p?.({side:y.side,startLine:Math.min(y.from,y.to),endLine:Math.max(y.from,y.to)})};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[y,p]),(0,f.useEffect)(()=>{g.current&&(g.current.hidden=!0)},[e,s,t]);let D=(e,t)=>`diff-${n}${e}${t}`,O=(e,t,n=``)=>(0,_.jsx)(`div`,{className:`num ${n}`,id:t===void 0?void 0:D(e,t),"data-side":e,"data-line":t,children:t}),ee=e=>(0,_.jsx)(K1,{text:r.lines[e.old-1]??``,tokens:r.tokens?.[e.old-1],ranges:h.get(e),noEol:e.noEol}),k=e=>(0,_.jsx)(K1,{text:i.lines[e.new-1]??``,tokens:i.tokens?.[e.new-1],ranges:h.get(e),noEol:e.noEol}),te=[],ne=[],A=(e,t=!1)=>{te.push(e),ne.push(t)},j=(e,n)=>{let r=e===void 0?void 0:s?.get(`L${e}`),i=n===void 0?void 0:s?.get(`R${n}`);if(!r&&!i)return;let a=`insert:${r?`L${e}`:``}:${i?`R${n}`:``}`;A(t===`split`?(0,_.jsxs)(`div`,{className:`diff-insert split-insert`,children:[(0,_.jsx)(`div`,{className:`insert-half`,children:r}),(0,_.jsx)(`div`,{className:`insert-half`,children:i})]},a):(0,_.jsxs)(`div`,{className:`diff-insert`,children:[r,i]},a),!0)},M=(e,t)=>{let n=t.t===`add`?void 0:t.old,r=t.t===`del`?void 0:t.new,i=$1(o,`L`,n)||$1(o,`R`,r),a=t.t===`del`?`L`:`R`,s=t.t===`del`?t.old:t.new,c=e0(T,a,s);A((0,_.jsxs)(`div`,{className:`diff-row ${t.t}${i?` selected`:``}${c?` commenting`:``}${E(a,s)?` cursor`:``}`,children:[O(`L`,n),O(`R`,r),(0,_.jsx)(`div`,{className:`code`,"data-marker":t.t===`add`?`+`:t.t===`del`?`-`:` `,"data-side":a,"data-line":s,children:t.t===`del`?ee(t):k(t)})]},e),i||c||E(a,s)),j(n,r)},N=(e,t,n)=>{let r=t&&t.t!==`add`?t:void 0,i=n&&n.t!==`del`?n:void 0,a=r?r.t:`empty`,s=i?i.t:`empty`,c=e0(T,`L`,r?.old)?` commenting`:``,l=e0(T,`R`,i?.new)?` commenting`:``;A((0,_.jsxs)(`div`,{className:`diff-row`,children:[O(`L`,r?.old,`${a}${$1(o,`L`,r?.old)?` selected`:``}${c}`),(0,_.jsx)(`div`,{className:`code side-left ${a}${c}${E(`L`,r?.old)?` cursor`:``}`,"data-marker":r?.t===`del`?`-`:` `,"data-side":`L`,"data-line":r?.old,children:r&&ee(r)}),O(`R`,i?.new,`${s}${$1(o,`R`,i?.new)?` selected`:``}${l}`),(0,_.jsx)(`div`,{className:`code side-right ${s}${l}${E(`R`,i?.new)?` cursor`:``}`,"data-marker":i?.t===`add`?`+`:` `,"data-side":`R`,"data-line":i?.new,children:i&&k(i)})]},e),c!==``||l!==``||$1(o,`L`,r?.old)||$1(o,`R`,i?.new)||E(`L`,r?.old)||E(`R`,i?.new)),j(r?.old,i?.new)},P=[],re=()=>{if(P.length!==0){if(t===`unified`)for(let e of P)M(e.key,e.row);else for(let e of E1(P.map(e=>e.row)))N(e.key,e.left,e.right);P=[]}};for(let t of e)t.kind===`row`?P.push(t):(re(),A((0,_.jsxs)(`div`,{className:`diff-row hunk`,children:[(0,_.jsx)(Q1,{item:t,onExpand:u}),(0,_.jsx)(`div`,{className:`code hunk-text`,children:t.kind===`hunk`?O1(t.hunk):``})]},t.key)));re();let ie=te;if(te.length>q1){let e=[];for(let t=0;t<te.length;t+=J1){let n=Math.min(t+J1,te.length);e.push((0,_.jsx)(X1,{rows:n-t,pinned:ne.slice(t,n).some(Boolean),children:te.slice(t,n)},t))}ie=e}return(0,_.jsxs)(`div`,{ref:m,className:`diff-rows ${t}`,tabIndex:0,role:`group`,"aria-label":l,onClick:e=>{let t=e.target.closest(`.num[data-line]`),n=t?.dataset.side;t?.dataset.line&&(n===`L`||n===`R`)&&d(n,Number(t.dataset.line))},onMouseDown:e=>{let t=e.target.closest(`.code`);e.currentTarget.dataset.selecting=t?.classList.contains(`side-left`)?`left`:t?.classList.contains(`side-right`)?`right`:``},onMouseOver:e=>{let t=g.current;if(!t||y||t.contains(e.target))return;let n=n0(e.target);if(!n||!m.current)return;v.current={side:n.side,line:n.line};let r=m.current.getBoundingClientRect(),i=n.cell.getBoundingClientRect();t.style.top=`${i.top-r.top}px`,t.style.left=`${i.left-r.left}px`,t.hidden=!1,t.setAttribute(`aria-label`,`Add a comment on line ${n.side}${n.line}`)},onMouseLeave:()=>{g.current&&!y&&(g.current.hidden=!0)},onKeyDown:e=>{if(e.target!==e.currentTarget||e.metaKey||e.ctrlKey||e.altKey)return;let n=j1(e),r=n===`ArrowDown`||n===`j`?1:n===`ArrowUp`||n===`k`?-1:0,i=t!==`split`||e.shiftKey?void 0:n===`ArrowLeft`?`L`:n===`ArrowRight`?`R`:void 0;if(r!==0||i&&x&&x.side!==i){let n=Array.from(e.currentTarget.querySelectorAll(`.code[data-line]`));if(n.length===0)return;e.preventDefault();let a=x?n.findIndex(e=>e.dataset.side===x.side&&Number(e.dataset.line)===x.to):-1,o;if(a<0){let e=n.findIndex(e=>e.getBoundingClientRect().bottom>0);o=n[Math.max(0,e)]}else if(i){let e=n[a],t=e=>e?.dataset.side===i;o=[n[a-1],n[a+1]].find(n=>t(n)&&n?.parentElement===e.parentElement)??n.slice(a+1).find(t)??n.slice(0,a).reverse().find(t)}else{let i=a+r;if((t===`split`||e.shiftKey)&&x)for(;n[i]&&n[i]?.dataset.side!==x.side;)i+=r;o=n[i]}if(!o)return;let s=o.dataset.side,c=Number(o.dataset.line);S(e.shiftKey&&x&&x.side===s?{...x,to:c}:{side:s,from:c,to:c}),o.scrollIntoView({block:`nearest`})}else x&&(n===`c`&&p?(e.preventDefault(),p(C(x))):n===`Enter`?(e.preventDefault(),d(x.side,x.to)):n===`Escape`&&S(void 0))},children:[ie,p&&(0,_.jsx)(`button`,{ref:g,type:`button`,hidden:!0,className:`add-comment`,title:`Add a comment. Drag to select several lines.`,onMouseDown:e=>{v.current&&e.button===0&&(e.preventDefault(),b({side:v.current.side,from:v.current.line,to:v.current.line}))},children:(0,_.jsx)(H,{size:16})})]})}var i0=(0,f.lazy)(()=>i1(()=>import(`./FileEditor-D1ppFIWH.js`),[])),a0=2e3,o0=`:worktree`;function s0(e){let[t,n]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let r=e.current;if(!r||t)return;let i=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&n(!0)},{rootMargin:`1200px 0px`});return i.observe(r),()=>i.disconnect()},[e,t]),t}function c0(e){let[t,n]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=e.current;if(!t)return;let r=new IntersectionObserver(e=>n(e.some(e=>e.isIntersecting)),{rootMargin:`3000px 0px`});return r.observe(t),()=>r.disconnect()},[e]),t}function l0(e,t,n){let r=(0,f.useMemo)(()=>e?.text===void 0?void 0:It(e.text),[e]),i=s1(t),a=et({queryKey:[`tokens`,e?.oid,i],queryFn:()=>X_(i,r),enabled:n&&i!==void 0&&r!==void 0&&Z_(r,e?.text?.length??0),staleTime:1/0,retry:!1});return(0,f.useMemo)(()=>r?{lines:r,tokens:a.data}:void 0,[r,a.data])}function u0({children:e}){return(0,_.jsx)(`div`,{className:`diff-message`,children:e})}function d0({path:e}){let[t,n]=(0,f.useState)(!1);return(0,_.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":t?`Copied`:`Copy file path`,title:`Copy file path`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1500)})},children:t?(0,_.jsx)(er,{size:16}):(0,_.jsx)(wr,{size:16})})}var f0=e=>`${(e/1024/1024).toFixed(1)} MB`,p0={borderBottom:0,borderRadius:`var(--borderRadius-medium)`},m0=e=>e.side===`file`?`file`:`${e.side}${e.startLine}-${e.endLine}`,h0=(0,f.memo)(function({repoId:e,comparison:t,file:n,view:r,target:i,scrollToTarget:a,threads:o,scope:s,viewed:c=!1,onViewed:l,readOnly:u=!1,staging:d,onStage:p,onSelectLine:m,isSettling:h,listedAt:g}){let v=(0,f.useRef)(null),y=s0(v),b=c0(v),x=(0,f.useRef)(null),S=(0,f.useRef)(void 0),C=a&&i?.line!==void 0,w=C?`${i?.side??``}${i?.line??``}`:void 0,[T,E]=(0,f.useState)(C),[D,O]=(0,f.useState)(c&&!C);(0,f.useEffect)(()=>{if(!(c&&T)){if(c){let e=v.current,t=document.activeElement,n=e?.querySelector(`.file-header`);e&&n&&t&&e.contains(t)&&!n.contains(t)&&n.querySelector(`button`)?.focus({preventScroll:!0})}O(c)}},[c]);let[ee,k]=(0,f.useState)(!1),[te,ne]=(0,f.useState)({}),[A,j]=(0,f.useState)([]),[M,N]=(0,f.useState)(!1),[P,re]=(0,f.useState)(void 0),[ie,ae]=(0,f.useState)(!1),[oe,se]=(0,f.useState)(!1),[ce,le]=(0,f.useState)(void 0),ue=b_(),de=B_(e),fe=Za(),pe=n.kind===`text`,F=En(n.path)===void 0?pe&&Dn(n.path)?`markdown`:void 0:`image`,I=F!==void 0&&(oe||n.kind===`binary`),me=n.additions+n.deletions>a0,he=(y||i!==void 0||M)&&!D&&pe&&(!me||ee||M),{diffFrom:ge,diffTo:_e,ignoreWhitespace:ve}=t,L=n.status!==`deleted`,ye=L&&!n.newOid&&_e===o0,be=`${n.oldOid??``}..${_e===o0?o0:n.newOid??``}`,[xe,Se]=(0,f.useState)({versions:be,ignoreWhitespace:ve});(xe.versions!==be||xe.ignoreWhitespace!==ve)&&(Se({versions:be,ignoreWhitespace:ve}),ne({}),xe.versions!==be&&(k(C),se(!1),ae(!1),le(void 0),O(c&&!T)));let Ce=et({queryKey:[`diff`,e,ge,_e,n.path,n.oldPath,ve],queryFn:()=>z.diff(e,ge,_e,n.path,n.oldPath,ve),enabled:he&&!n.untracked}),R=et({queryKey:[`blob`,e,n.oldOid],queryFn:()=>z.blob(e,n.oldOid),enabled:he&&n.oldOid!==void 0,staleTime:1/0}),we=et({queryKey:[`blob`,e,n.newOid],queryFn:()=>z.blob(e,n.newOid),enabled:he&&L&&n.newOid!==void 0,staleTime:1/0}),Te=et({queryKey:[`worktree-file`,e,n.path],queryFn:()=>z.worktreeFile(e,n.path),enabled:he&&(ye||M&&L)}),Ee=ye?Te:we,De=n.oldOid!==void 0&&R.isPending,Oe=L&&(n.newOid!==void 0||ye)&&Ee.isPending,ke=he&&(!n.untracked&&Ce.isPending||De||Oe),Ae=Ce.error??R.error??Ee.error,je=he&&!ke&&!Ae,Me=(0,f.useMemo)(()=>je?{diff:Ce.data,oldBlob:R.data,newBlob:Ee.data}:void 0,[je,Ce.data,R.data,Ee.data]),Ne=(0,f.useRef)(void 0);Me&&(Ne.current=Me);let Pe=Me??(Ae?void 0:Ne.current),Fe=Pe!==void 0,Ie=l0(Pe?.oldBlob,n.oldPath??n.path,he),Le=l0(Pe?.newBlob,n.path,he),Re=(0,f.useMemo)(()=>n.untracked?h1(Le?.lines.length??0):Pe?.diff?.hunks??[],[n.untracked,Le,Pe]),ze=(0,f.useMemo)(()=>({lines:[]}),[]),Be=Ie??ze,Ve=Le??ze,He=(0,f.useMemo)(()=>v1(Re,Ve.lines.length),[Re,Ve.lines.length]),Ue=(0,f.useMemo)(()=>w1(Re,He,te),[Re,He,te]),We=(0,f.useMemo)(()=>D1(Re.flatMap(e=>e.rows)),[Re]),Ge=(0,f.useCallback)((e,t,n)=>{ne(r=>x1(r,e,t,n))},[]),Ke=(0,f.useCallback)((e,t)=>m(n.anchor,e,t),[m,n.anchor]),qe=M&&P===void 0&&!Te.isFetching?Te.data:void 0;qe?.text!==void 0&&!qe.lossy&&!De&&re(qe),!M&&P!==void 0&&re(void 0);let Je=M&&P!==void 0,Ye=M&&P===void 0&&Te.isError?Te.error.message:qe?.lossy?`it is not UTF-8 text, and saving it from here would damage it`:void 0;(0,f.useEffect)(()=>{Ye!==void 0&&(N(!1),le(`Could not open the file for editing: ${Ye}`))},[Ye]);let Xe=(0,f.useMemo)(()=>ie?[]:o.filter(e=>e.side!==`file`&&!e.outdated&&e.endLine!==void 0),[o,ie]),Ze=(0,f.useMemo)(()=>ie?[]:o.filter(e=>e.side===`file`||e.outdated),[o,ie]),Qe=e=>e===`L`?n.oldPath??n.path:n.path,$e=e=>e.side===`file`?`${s}|${n.path}|file`:`${s}|${Qe(e.side)}|${e.side}|${e.startLine}-${e.endLine}`,tt=(0,f.useMemo)(()=>A.filter(e=>e.side!==`file`),[A]),nt=A.find(e=>e.side===`file`),rt=e=>Fe&&e.endLine>(e.side===`L`?Be:Ve).lines.length,it=e=>{let t=m0(e);j(n=>n.some(e=>m0(e)===t)?n:[...n,e]);let n=$e(e);[...v.current?.querySelectorAll(`form.comment-form`)??[]].find(e=>e.dataset.draft===n)?.querySelector(`textarea`)?.focus()},at=e=>{let t=m0(e);j(e=>e.filter(e=>m0(e)!==t))},ot=(0,f.useRef)(it);ot.current=it;let st=(0,f.useCallback)(e=>ot.current(e),[]);(0,f.useEffect)(()=>{if(Re.length===0)return;let e=Xe.map(e=>({side:e.side,line:e.endLine}));for(let t of tt)e.push({side:t.side,line:t.endLine});i?.side&&i.line&&e.push({side:i.side,line:i.line}),e.length>0&&ne(t=>b1(t,He,e))},[Xe,tt,i,He,Re.length]);let ct=(e,t)=>h?.()?Promise.reject(Error(`The comparison is still loading. Send the comment again in a moment.`)):de.create({scope:s,from:ge,to:_e,path:Qe(e.side),side:e.side,startLine:e.side===`file`?void 0:e.startLine,endLine:e.side===`file`?void 0:e.endLine,body:t}).then(n=>{at(e),fe.startIfMentioned(n.id,t)}),lt=(t,n)=>{let{side:r,startLine:i,endLine:a}=t,o=r===`L`?Be.lines:Ve.lines,s=i===a?`line ${r}${i}`:`lines ${r}${i} to ${r}${a}`;return(0,_.jsx)(z_,{repoId:e,draftKey:$e(t),title:n?`Add a comment on ${s} (no longer in this file)`:`Add a comment on ${s}`,submitLabel:`Comment`,suggestionSeed:r===`R`&&!n?o.slice(i-1,a).join(`
|
|
60
60
|
`):void 0,onSubmit:e=>ct(t,e),onCancel:()=>at(t)},`composer:${m0(t)}`)},ut=(0,f.useMemo)(()=>{let t=new Map,n=(e,n)=>t.set(e,[...t.get(e)??[],n]);for(let t of Xe)n(`${t.side}${t.endLine}`,(0,_.jsx)(W_,{repoId:e,thread:t,actions:de},t.id));for(let e of tt)rt(e)||n(`${e.side}${e.endLine}`,lt(e,!1));return t},[Xe,tt,e,de,fe,s,Fe,Be.lines,Ve.lines,n.path,n.oldPath,ge,_e,h]);(0,f.useEffect)(()=>{if(w===void 0)return;E(!0),O(!1),k(!0),se(!1);let e=()=>E(!1);return window.addEventListener(`keydown`,e,!0),window.addEventListener(`pointerdown`,e,!0),()=>{window.removeEventListener(`keydown`,e,!0),window.removeEventListener(`pointerdown`,e,!0),e()}},[w]);let dt=(0,f.useRef)(void 0),ft=pe&&!Ae&&!Fe;(0,f.useEffect)(()=>{if(!i||!a)return;let e=`${i.side??``}${i.line??``}`;if(dt.current===e)return;let t=null;if(i.side&&i.line){t=document.getElementById(`diff-${n.anchor}${i.side}${i.line}`);let e=Re.length>0&&y1(He,i.side,i.line)!==void 0;if(!t&&(ft||e))return}dt.current=e,(t??v.current)?.scrollIntoView({block:t?`center`:`start`})},[i,a,ft,Ue,He,Re.length,n.anchor]),(0,f.useLayoutEffect)(()=>{x.current&&(S.current=x.current.offsetHeight)});let pt=M||A.length>0||i!==void 0||(v.current?.contains(document.activeElement)??!1),gt=!b&&!pt&&S.current!==void 0,_t=[Pe?.oldBlob,Pe?.newBlob].find(e=>e?.tooLarge),vt=D_(n),yt=Math.min(n.additions+n.deletions+6,60)*20,bt=Pe?.newBlob?.lossy===!0,xt=L&&_e===o0,St=ue.canEdit&&pe&&xt&&!u&&!bt,Ct=He.some((e,t)=>e.length>(te[t]?.top??0)+(te[t]?.bottom??0)),wt=Fe&&!D&&!M&&!gt&&Re.length>0&&Ct,Tt=()=>ne(Object.fromEntries(He.map((e,t)=>[t,{top:e.length,bottom:0}]))),Et=()=>{window.confirm(`Delete ${n.path} from your working tree?\n\nIts content is kept, and "Undo" in the list of changes at the top of the page brings it back.`)&&(le(void 0),(async()=>{let t=Te.data??await z.worktreeFile(e,n.path);await ue.remove(n.path,t.oid)})().catch(e=>le(e instanceof Error?e.message:`Could not delete the file`)))},Dt=()=>{le(void 0),O(!1),N(!0)},Ot=[...wt?[{label:`Show the whole file`,run:Tt}]:[],...o.length>0?[{label:ie?`Show comments`:`Hide comments`,run:()=>ae(e=>!e)}]:[],...St&&!M?[{label:`Edit file`,run:Dt},{label:`Delete file…`,danger:!0,run:Et}]:[]],kt=F===`image`&&n.oldOid?mt(e,n.oldOid,n.oldPath??n.path):void 0,At=F!==`image`||!L?void 0:n.newOid?mt(e,n.newOid,n.path):_e===o0?ht(e,n.path,g??0):void 0,jt,Mt=!1;I&&F===`image`&&!M?jt=(0,_.jsx)(m1,{before:kt,after:At}):n.kind===`binary`?jt=(0,_.jsx)(u0,{children:`Binary file not shown.`}):n.kind===`submodule`?jt=(0,_.jsxs)(u0,{children:[`Submodule `,n.oldOid?(0,_.jsx)(`code`,{children:n.oldOid.slice(0,7)}):`added`,n.oldOid&&n.newOid?` → `:` `,n.newOid?(0,_.jsx)(`code`,{children:n.newOid.slice(0,7)}):n.status===`deleted`?`removed`:`another commit in the working tree`]}):me&&!ee?jt=(0,_.jsxs)(u0,{children:[(0,_.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>k(!0),children:`Load diff`}),(0,_.jsx)(`span`,{children:`Large diffs are not rendered by default.`})]}):Ae?jt=(0,_.jsxs)(u0,{children:[(0,_.jsxs)(`span`,{children:[`Could not load this file: `,Ae.message]}),(0,_.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>void Promise.all([Ce.refetch(),R.refetch(),Ee.refetch()]),children:`Retry`})]}):Fe?_t?jt=(0,_.jsxs)(u0,{children:[`This file is too large to show (`,f0(_t.size),`).`]}):Pe.oldBlob?.binary||Pe.newBlob?.binary||Pe.diff?.binary?jt=(0,_.jsx)(u0,{children:`Binary file not shown.`}):Re.length===0?jt=(0,_.jsx)(u0,{children:vt?`File mode changed.`:n.status===`renamed`?`File renamed without changes.`:n.untracked||n.status===`added`?`Empty file.`:`No changes to show.`}):I&&F===`markdown`?jt=(0,_.jsx)(f1,{oldLines:Be.lines,newLines:Ve.lines}):gt?jt=(0,_.jsx)(`div`,{className:`diff-placeholder`,style:{height:S.current}}):(Mt=!0,jt=(0,_.jsx)(`div`,{ref:x,children:(0,_.jsx)(r0,{items:Ue,view:r,anchor:n.anchor,old:Be,next:Ve,pairs:We,target:i,inserts:ut,highlights:tt,label:`Diff of ${n.path}. Arrow keys move between lines, Shift with arrows selects several, C comments, Enter links to the line.`,onExpand:Ge,onSelectLine:Ke,onComment:u?void 0:st})})):jt=(0,_.jsx)(`div`,{className:`diff-placeholder`,style:{height:yt},"aria-busy":`true`});let Nt=Mt&&!Je&&!D,Pt=tt.filter(e=>!Nt||rt(e));return(0,_.jsxs)(`section`,{ref:v,className:`file-card`,id:`diff-${n.anchor}`,"aria-label":n.path,children:[(0,_.jsxs)(`header`,{className:`file-header`,style:D&&Je?p0:void 0,children:[(0,_.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-expanded":!D,"aria-label":D?`Expand file`:`Collapse file`,onClick:()=>O(e=>!e),children:D?(0,_.jsx)(lr,{size:16}):(0,_.jsx)(or,{size:16})}),pe&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`file-header-count`,title:`${n.additions} additions, ${n.deletions} deletions`,children:n.additions+n.deletions}),(0,_.jsx)(E_,{additions:n.additions,deletions:n.deletions})]}),(0,_.jsx)(`a`,{className:`file-header-path`,href:`#diff-${n.anchor}`,children:(0,_.jsx)(O_,{file:n})}),(0,_.jsx)(d0,{path:n.path}),n.untracked&&(0,_.jsx)(`span`,{className:`label`,children:`Untracked`}),vt&&(0,_.jsx)(`span`,{className:`label`,children:vt}),n.status===`deleted`&&(0,_.jsx)(`span`,{className:`label`,children:`Deleted`}),M&&D&&(0,_.jsx)(`span`,{className:`label label-attention`,title:`The editor is still open in this file, with everything typed in it. Unfold the file to go on.`,children:`Editing`}),(0,_.jsxs)(`span`,{className:`file-header-end`,children:[o.length>0&&(0,_.jsx)(`span`,{className:`file-header-threads`,title:`${o.length} ${o.length===1?`conversation`:`conversations`}`,children:o.length}),F&&pe&&!M&&(0,_.jsxs)(`span`,{className:`segmented rich-toggle`,role:`group`,"aria-label":`How to show this file`,children:[(0,_.jsx)(`button`,{type:`button`,className:`segmented-button`,"aria-pressed":!oe,"aria-label":`Source diff`,title:`Show the source diff`,onClick:()=>se(!1),children:(0,_.jsx)(fr,{size:16})}),(0,_.jsx)(`button`,{type:`button`,className:`segmented-button`,"aria-pressed":oe,"aria-label":`Rich diff`,title:F===`markdown`?`Show the rendered document with changes marked`:`Show the two pictures`,onClick:()=>{O(!1),se(!0)},children:(0,_.jsx)(Hr,{size:16})})]}),p&&d&&(0,_.jsxs)(`label`,{className:`viewed-toggle stage-toggle`,title:d===`partial`?`Part of this file's changes is staged. Check to stage the rest.`:`Stage this file for the next commit`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:d===`staged`,ref:e=>{e&&(e.indeterminate=d===`partial`)},onChange:()=>p(n,d!==`staged`)}),`Staged`]}),l&&(0,_.jsxs)(`label`,{className:`viewed-toggle`,title:`Mark this file as viewed. The mark is dropped when the file changes.`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(n.path,e.target.checked)}),`Viewed`]}),pe&&L&&!u&&(0,_.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":`Edit file`,"aria-pressed":M,disabled:!St||M,title:St?`Edit this file in place`:bt?`This file is not UTF-8 text: editing it here would damage it`:ue.canEdit?`This file cannot be edited here`:`Compare with the working tree to edit files in place`,onClick:Dt,children:(0,_.jsx)(Zi,{size:16})}),!u&&(0,_.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":`Comment on this file`,title:`Comment on this file`,onClick:()=>{O(!1),it({side:`file`})},children:(0,_.jsx)(vr,{size:16})}),Ot.length>0&&(0,_.jsx)(G_,{items:Ot})]})]}),ce&&(0,_.jsx)(`div`,{className:`flash flash-danger file-editor-flash`,role:`alert`,children:ce}),!D&&(nt||Pt.length>0||Ze.length>0)&&(0,_.jsxs)(`div`,{className:`card-threads`,children:[nt&&(0,_.jsx)(z_,{repoId:e,draftKey:$e(nt),title:`Add a comment on this file`,submitLabel:`Comment`,onSubmit:e=>ct(nt,e),onCancel:()=>at(nt)},`composer:file`),Pt.map(e=>lt(e,rt(e))),Ze.map(t=>(0,_.jsx)(W_,{repoId:e,thread:t,actions:de},t.id))]}),Je&&(0,_.jsx)(`div`,{hidden:D,children:(0,_.jsx)(f.Suspense,{fallback:(0,_.jsx)(`div`,{className:`diff-placeholder`,style:{height:yt},"aria-busy":`true`}),children:(0,_.jsx)(i0,{file:n,old:Be,initial:P,view:r,onClose:()=>N(!1)})})}),!D&&!Je&&jt]})});function g0({status:e,onStage:t,onUnstage:n,onCommit:r}){let[i,a]=(0,f.useState)(``),[o,s]=(0,f.useState)(!1),[c,l]=(0,f.useState)(void 0),[u,d]=(0,f.useState)(void 0),p=e.files.length,m=e=>{s(!0),l(void 0),e().catch(e=>l(e instanceof Error?e.message:`git refused`)).finally(()=>s(!1))},h=()=>{e.staged===0||i.trim()===``||o||m(()=>r(i).then(e=>{d(e),a(``)}))};return p===0&&!u?null:(0,_.jsxs)(`section`,{className:`commit-panel`,"aria-label":`Commit`,children:[(0,_.jsxs)(`div`,{className:`commit-panel-head`,children:[(0,_.jsx)(fi,{size:16,className:`range-icon`}),(0,_.jsxs)(`span`,{children:[(0,_.jsxs)(`strong`,{children:[e.staged,` of `,p]}),` `,`changed `,p===1?`file`:`files`,` staged for a commit to `,e.branch?(0,_.jsx)(`code`,{children:e.branch}):`a detached HEAD`]}),(0,_.jsxs)(`span`,{className:`commit-panel-actions`,children:[(0,_.jsx)(`button`,{type:`button`,className:`button button-small`,disabled:o||e.staged===p,onClick:()=>m(()=>t()),children:`Stage all`}),(0,_.jsx)(`button`,{type:`button`,className:`button button-small`,disabled:o||e.staged===0,onClick:()=>m(()=>n()),children:`Unstage all`})]})]}),(0,_.jsxs)(`div`,{className:`commit-panel-form`,children:[(0,_.jsx)(`textarea`,{className:`commit-message`,"aria-label":`Commit message`,placeholder:`Commit message: a short summary, then details after an empty line`,rows:i.includes(`
|
|
61
61
|
`)?4:1,value:i,disabled:o,onChange:e=>{a(e.target.value),d(void 0)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&h()}}),(0,_.jsx)(`button`,{type:`button`,className:`button button-primary`,disabled:o||e.staged===0||i.trim()===``,title:e.staged===0?`Stage the files this commit should contain`:`Runs git commit with your hooks and signing settings`,onClick:h,children:o?`Working…`:`Commit`})]}),u&&(0,_.jsxs)(`p`,{className:`commit-done`,role:`status`,children:[(0,_.jsx)(er,{size:16,className:`tone-success`}),` Committed `,(0,_.jsx)(`code`,{children:u.oid.slice(0,7)}),` `,u.subject]}),c&&(0,_.jsxs)(`div`,{className:`flash flash-danger`,role:`alert`,children:[(0,_.jsx)(`strong`,{children:`git did not do that`}),(0,_.jsx)(`pre`,{className:`commit-error`,children:c})]})]})}function _0(e){let t={name:``,path:``,directories:[],files:[]},n=new Map([[``,t]]);for(let r of e){let e=r.path.split(`/`),i=t;for(let t=0;t<e.length-1;t+=1){let r=e.slice(0,t+1).join(`/`),a=n.get(r);a||(a={name:e[t],path:r,directories:[],files:[]},n.set(r,a),i.directories.push(a)),i=a}i.files.push(r)}let r=e=>{let n=e;for(;n!==t&&n.files.length===0&&n.directories.length===1;){let e=n.directories[0];n={...e,name:`${n.name}/${e.name}`}}return{...n,directories:n.directories.map(r)}};return r(t)}var v0=e=>e.slice(e.lastIndexOf(`/`)+1),y0=(0,f.memo)(function({files:e,viewed:t,threadCounts:n,activeAnchor:r}){let[i,a]=(0,f.useState)(``),[o,s]=(0,f.useState)(new Set),c=i.trim().toLowerCase(),l=(0,f.useMemo)(()=>c===``?e:e.filter(e=>e.path.toLowerCase().includes(c)),[e,c]),u=(0,f.useMemo)(()=>_0(l),[l]),d=e=>s(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),p=(e,i)=>{let{Icon:a,tone:o,label:s}=k_(e),c=n.get(e.path)??0,l=t.has(e.path);return(0,_.jsx)(`li`,{children:(0,_.jsxs)(`a`,{className:`tree-row tree-file${l?` viewed`:``}`,href:`#diff-${e.anchor}`,"aria-current":e.anchor===r?`location`:void 0,style:{paddingLeft:i*12+8},title:e.oldPath?`${e.oldPath} → ${e.path}`:e.path,children:[(0,_.jsx)(`span`,{className:`tree-icon tone-${o}`,children:(0,_.jsx)(a,{size:16,"aria-label":s})}),(0,_.jsx)(`span`,{className:`tree-name`,children:v0(e.path)}),c>0&&(0,_.jsx)(`span`,{className:`tree-count`,title:`${c} ${c===1?`conversation`:`conversations`}`,children:c}),l&&(0,_.jsx)(er,{size:12,className:`tree-viewed`,"aria-label":`Viewed`})]})},e.path)},m=(e,t)=>{let n=c!==``||!o.has(e.path);return(0,_.jsxs)(`li`,{children:[(0,_.jsxs)(`button`,{type:`button`,className:`tree-row tree-directory`,"aria-expanded":n,style:{paddingLeft:t*12+8},onClick:()=>d(e.path),children:[n?(0,_.jsx)(or,{size:12}):(0,_.jsx)(lr,{size:12}),(0,_.jsx)(`span`,{className:`tree-icon tree-folder`,children:n?(0,_.jsx)(ei,{size:16}):(0,_.jsx)(Zr,{size:16})}),(0,_.jsx)(`span`,{className:`tree-name`,children:e.name})]}),n&&(0,_.jsxs)(`ul`,{children:[e.directories.map(e=>m(e,t+1)),e.files.map(e=>p(e,t+1))]})]},e.path)};return(0,_.jsxs)(`nav`,{className:`file-tree`,"aria-label":`File tree`,children:[(0,_.jsxs)(`label`,{className:`tree-filter`,children:[(0,_.jsx)(ma,{size:16}),(0,_.jsx)(`input`,{type:`search`,placeholder:`Filter changed files`,"aria-label":`Filter changed files`,value:i,onChange:e=>a(e.target.value)})]}),l.length===0?(0,_.jsx)(`p`,{className:`tree-empty`,children:`No files match.`}):(0,_.jsxs)(`ul`,{className:`tree-root`,children:[u.directories.map(e=>m(e,0)),u.files.map(e=>p(e,0))]})]})});function b0({repoId:e,spec:t,onClose:n,onOpen:r}){let i=et({queryKey:[`pull-proposal`,e,t],queryFn:()=>z.pullProposal(e,t),retry:!1,staleTime:0,gcTime:0}),[a,o]=(0,f.useState)(void 0),[s,c]=(0,f.useState)(void 0),[l,u]=(0,f.useState)(!1),[d,p]=(0,f.useState)(!1),[m,h]=(0,f.useState)(void 0),[g,v]=(0,f.useState)(!1),y=(0,f.useRef)(null);Ua(y);let b=i.data,x=a??b?.title??``,S=s??b?.body??``,C=x!==(b?.title??``)||S!==(b?.body??``);(0,f.useEffect)(()=>{let e=e=>{e.key!==`Escape`||e.isComposing||d||C||n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,d,C]);let w=b!==void 0&&!b.blockedBy&&!b.existing;return(0,_.jsx)(`div`,{className:`modal-backdrop`,children:(0,_.jsxs)(`div`,{ref:y,className:`dialog modal create-pull-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`create-pull-title`,children:[(0,_.jsx)(`h2`,{id:`create-pull-title`,className:`dialog-title`,children:`Open a pull request`}),i.isPending&&(0,_.jsx)(`p`,{className:`loading`,children:`Asking the remote and GitHub…`}),i.isError&&(0,_.jsx)(`div`,{className:`flash flash-danger`,role:`alert`,children:i.error.message}),b&&(b.base||b.head)&&(0,_.jsxs)(`p`,{className:`create-pull-branches`,children:[(0,_.jsx)(xi,{size:16,className:`range-icon`}),` `,(0,_.jsx)(`code`,{children:b.head}),` into `,(0,_.jsx)(`code`,{children:b.base}),b.repository&&(0,_.jsxs)(_.Fragment,{children:[` `,`on `,(0,_.jsx)(`strong`,{children:b.repository})]})]}),b?.existing&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`flash flash-attention`,role:`status`,children:[`Pull request #`,b.existing.number,` is already open for these branches.`]}),(0,_.jsxs)(`div`,{className:`dialog-actions`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`button button-primary`,autoFocus:!0,onClick:()=>r(b.existing.number),children:[`Open pull request #`,b.existing.number]}),(0,_.jsx)(`button`,{type:`button`,className:`button`,onClick:n,children:`Close`})]})]}),b?.blockedBy&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`flash flash-attention`,role:`status`,children:[(0,_.jsx)(`strong`,{children:`A pull request cannot be opened yet`}),(0,_.jsx)(`span`,{children:b.blockedBy})]}),b.hint&&(0,_.jsxs)(`div`,{className:`share-row create-pull-hint`,children:[(0,_.jsx)(`input`,{className:`text-input`,readOnly:!0,value:b.hint,"aria-label":`Command to run`,onFocus:e=>e.target.select()}),(0,_.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":`Copy command`,onClick:()=>void navigator.clipboard.writeText(b.hint??``).then(()=>{v(!0),window.setTimeout(()=>v(!1),1500)}),children:(0,_.jsx)(wr,{size:16})}),g&&(0,_.jsx)(`span`,{role:`status`,children:`Copied`})]}),(0,_.jsxs)(`div`,{className:`dialog-actions`,children:[(0,_.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>void i.refetch(),disabled:i.isFetching,children:i.isFetching?`Checking…`:`Check again`}),(0,_.jsx)(`button`,{type:`button`,className:`button`,onClick:n,children:`Close`})]})]}),w&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`label`,{className:`create-pull-field`,children:[(0,_.jsx)(`span`,{children:`Title`}),(0,_.jsx)(`input`,{className:`text-input`,value:x,autoFocus:!0,disabled:d,onChange:e=>o(e.target.value)})]}),(0,_.jsxs)(`label`,{className:`create-pull-field`,children:[(0,_.jsx)(`span`,{children:`Description`}),(0,_.jsx)(`textarea`,{className:`review-summary`,value:S,disabled:d,placeholder:`What does this change, and why? Markdown is supported.`,onChange:e=>c(e.target.value)})]}),(0,_.jsxs)(`label`,{className:`checkbox create-pull-draft`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:l,disabled:d,onChange:e=>u(e.target.checked)}),`Open as a draft: not ready for review yet`]}),m&&(0,_.jsxs)(`div`,{className:`flash flash-danger`,role:`alert`,children:[(0,_.jsx)(`strong`,{children:`Not created`}),(0,_.jsx)(`span`,{children:m})]}),(0,_.jsxs)(`p`,{className:`dialog-note`,children:[`This opens a pull request on GitHub`,b?.viewer?(0,_.jsxs)(_.Fragment,{children:[` `,`as `,(0,_.jsx)(`strong`,{children:b.viewer})]}):null,`, where everyone with access to the repository sees it and may be notified. It can be closed on GitHub, not taken back from here.`]}),(0,_.jsxs)(`div`,{className:`dialog-actions`,children:[(0,_.jsx)(`button`,{type:`button`,className:`button button-primary`,disabled:d||x.trim()===``,onClick:()=>{p(!0),h(void 0),z.createPull(e,{spec:t,title:x,body:S,draft:l}).then(e=>r(e.number)).catch(e=>{p(!1),h(e instanceof Error?e.message:`Could not create the pull request`)})},children:d?`Creating…`:l?`Create draft pull request`:`Create pull request`}),(0,_.jsx)(`button`,{type:`button`,className:`button`,disabled:d,onClick:n,children:`Cancel`})]})]})]})})}var x0={open:{label:`Open`,tone:`open`,icon:xi,verb:`wants to merge`},closed:{label:`Closed`,tone:`closed`,icon:wi,verb:`wanted to merge`},merged:{label:`Merged`,tone:`merged`,icon:vi,verb:`merged`},unknown:{label:`Pull request`,tone:`unknown`,icon:xi,verb:`wants to merge`}},S0=new Intl.RelativeTimeFormat(`en-US`,{numeric:`auto`});function C0(e){let t=Math.round((new Date(e).getTime()-Date.now())/1e3);return Math.abs(t)<60?`just now`:Math.abs(t)<3600?S0.format(Math.round(t/60),`minute`):Math.abs(t)<86400?S0.format(Math.round(t/3600),`hour`):S0.format(Math.round(t/86400),`day`)}function w0({pull:e,commits:t,refreshing:n,refreshError:r,onRefresh:i,action:a}){let o=e.draft&&e.state===`open`,s=x0[e.state],c=o?Di:s.icon,l=t===void 0?``:` ${t.toLocaleString(`en-US`)} ${t===1?`commit`:`commits`}`;return(0,_.jsxs)(`div`,{className:`pull-header`,children:[(0,_.jsxs)(`h1`,{className:`page-title`,children:[e.title,` `,(0,_.jsxs)(`span`,{className:`pull-number`,children:[`#`,e.number]})]}),(0,_.jsxs)(`div`,{className:`pull-meta`,children:[(0,_.jsxs)(`span`,{className:`state-badge state-${o?`draft`:s.tone}`,children:[(0,_.jsx)(c,{size:16}),` `,o?`Draft`:s.label]}),(0,_.jsxs)(`span`,{className:`pull-merge-line`,children:[e.author?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`strong`,{children:e.author}),` `,s.verb]}):`To merge`,l,` into `,(0,_.jsx)(`code`,{children:e.baseRef}),e.headRef&&(0,_.jsxs)(_.Fragment,{children:[` `,`from `,(0,_.jsx)(`code`,{children:e.headRef})]})]}),(0,_.jsxs)(`span`,{className:`pull-meta-end`,children:[e.url&&(0,_.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,children:[`View on GitHub `,(0,_.jsx)(Hi,{size:12})]}),(0,_.jsxs)(`span`,{className:`pull-imported`,title:new Date(e.importedAt).toLocaleString(`en-US`),children:[`Imported `,C0(e.importedAt)]}),(0,_.jsxs)(`button`,{type:`button`,className:`button button-small`,disabled:n,onClick:i,title:`Fetch the pull request and its conversations again`,children:[(0,_.jsx)(Ea,{size:16}),` `,n?`Refreshing…`:`Refresh`]}),a]})]}),e.notice&&(0,_.jsx)(`div`,{className:`flash flash-attention`,role:`status`,children:e.notice}),r&&(0,_.jsxs)(`div`,{className:`flash flash-danger`,role:`alert`,children:[(0,_.jsx)(`strong`,{children:`Could not refresh`}),(0,_.jsx)(`span`,{children:r})]}),e.body.trim()!==``&&(0,_.jsxs)(`details`,{className:`pull-body`,children:[(0,_.jsx)(`summary`,{children:`Description`}),(0,_.jsx)(Ng,{text:e.body})]})]})}var T0=[{value:`comment`,label:`Comment`,note:`General feedback without explicit approval.`},{value:`approve`,label:`Approve`,note:`Feedback, and approval to merge these changes.`},{value:`request_changes`,label:`Request changes`,note:`Feedback that must be addressed before merging.`}];function E0(e){if(e.placement===`reply`)return`Reply in the conversation on ${e.path}`;if(e.placement===`summary`)return`In the review summary: ${e.path} is not part of this pull request`;if(e.placement===`file`)return`${e.path}, on the file`;let t=e.startLine===e.endLine?`line ${e.side}${e.endLine}`:`lines ${e.side}${e.startLine}–${e.side}${e.endLine}`;return`${e.path}, ${t}`}function D0({repoId:e,pull:t,onClose:n}){let[r,i]=(0,f.useState)(``),[a,o]=(0,f.useState)(`comment`),[s,c]=(0,f.useState)(void 0),[l,u]=(0,f.useState)(!1),[d,p]=(0,f.useState)(void 0),[m,h]=(0,f.useState)(void 0),g=et({queryKey:[`review-draft`,e,t.number,s],queryFn:()=>z.draftReview(e,t.number,s),placeholderData:pe,enabled:m===void 0}),v=(0,f.useRef)(null);Ua(v);let y=r.trim()!==``&&m===void 0;(0,f.useEffect)(()=>{let e=e=>{e.key!==`Escape`||e.isComposing||l||y||n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,l,y]);let b=g.data?.items??[],x=e=>s?s.includes(e.commentId):e.selected,S=b.filter(x).map(e=>e.commentId),C=e=>c(S.includes(e)?S.filter(t=>t!==e):[...S,e]),w=g.data?.blockedBy,T=g.data?.ownPull===!0,E=S.length===0&&r.trim()===``&&a===`comment`&&d===void 0;return(0,_.jsx)(`div`,{className:`modal-backdrop`,children:(0,_.jsxs)(`div`,{ref:v,className:`dialog modal review-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`review-dialog-title`,children:[(0,_.jsxs)(`h2`,{id:`review-dialog-title`,className:`dialog-title`,children:[`Review pull request #`,t.number]}),m?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`p`,{className:`review-done`,role:`status`,children:[(0,_.jsx)(rr,{size:16,className:`tone-success`}),` Published to GitHub`,m.comments>0?` with ${m.comments} ${m.comments===1?`comment`:`comments`}`:``,`.`]}),(0,_.jsxs)(`div`,{className:`dialog-actions`,children:[m.url&&(0,_.jsxs)(`a`,{className:`button`,href:m.url,target:`_blank`,rel:`noreferrer noopener`,children:[`View the review on GitHub `,(0,_.jsx)(Hi,{size:12})]}),(0,_.jsx)(`button`,{type:`button`,className:`button button-primary`,autoFocus:!0,onClick:n,children:`Done`})]})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`textarea`,{className:`review-summary`,"aria-label":`Review summary`,placeholder:`Leave a summary (optional)`,value:r,autoFocus:!0,disabled:l,onChange:e=>i(e.target.value)}),(0,_.jsxs)(`fieldset`,{className:`review-verdicts`,disabled:l,children:[(0,_.jsx)(`legend`,{className:`sr-only`,children:`Verdict`}),T0.map(e=>(0,_.jsxs)(`label`,{className:`review-verdict`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`review-verdict`,value:e.value,checked:a===e.value,disabled:T&&e.value!==`comment`,onChange:()=>o(e.value)}),(0,_.jsxs)(`span`,{children:[(0,_.jsx)(`strong`,{children:e.label}),(0,_.jsx)(`span`,{className:`review-verdict-note`,children:e.note})]})]},e.value)),T&&(0,_.jsx)(`p`,{className:`dialog-note`,children:`This is your own pull request: GitHub accepts only a comment on it.`})]}),(0,_.jsx)(`h3`,{className:`review-items-title`,children:b.length===0?`No unpublished comments`:`Comments to publish: ${S.length} of ${b.length}`}),g.isPending&&(0,_.jsx)(`p`,{className:`loading`,children:`Loading…`}),g.isError&&(0,_.jsx)(`div`,{className:`flash flash-danger`,role:`alert`,children:g.error.message}),b.length===0&&g.data&&(0,_.jsx)(`p`,{className:`dialog-note`,children:`Comments you write on this pull request wait here until you publish them. A summary or a verdict can be published on its own.`}),(0,_.jsx)(`ul`,{className:`review-items`,children:b.map(e=>(0,_.jsxs)(`li`,{className:`review-item${x(e)?``:` excluded`}`,children:[(0,_.jsxs)(`label`,{className:`review-item-head`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:x(e),disabled:l,onChange:()=>C(e.commentId)}),(0,_.jsx)(`span`,{className:`review-item-where`,children:E0(e)}),e.authorKind===`agent`&&(0,_.jsx)(`span`,{className:`label`,children:`Agent`}),e.displaced&&(0,_.jsx)(`span`,{className:`label label-attention`,children:`Not on its line`})]}),(0,_.jsx)(`div`,{className:`review-item-body`,children:(0,_.jsx)(Ng,{text:e.body})})]},e.commentId))}),w&&(0,_.jsxs)(`div`,{className:`flash flash-attention`,role:`status`,children:[(0,_.jsx)(`strong`,{children:`Publishing is not available`}),(0,_.jsx)(`span`,{children:w})]}),d&&(0,_.jsxs)(`div`,{className:`flash flash-danger`,role:`alert`,children:[(0,_.jsx)(`strong`,{children:`Not published`}),(0,_.jsx)(`span`,{children:d})]}),(0,_.jsxs)(`p`,{className:`dialog-note`,children:[`Publishing posts this to GitHub`,t.viewer?(0,_.jsxs)(_.Fragment,{children:[` `,`as `,(0,_.jsx)(`strong`,{children:t.viewer})]}):null,`, where everyone with access to the pull request can read it. It cannot be taken back from here. Each comment ends with an invisible marker, so publishing again never posts it twice.`]}),(0,_.jsxs)(`div`,{className:`dialog-actions`,children:[(0,_.jsx)(`button`,{type:`button`,className:`button button-primary`,disabled:l||w!==void 0||E||g.isFetching,onClick:()=>{u(!0),p(void 0),z.publishReview(e,t.number,{body:r,verdict:a,commentIds:S}).then(h).catch(e=>p(e instanceof Error?e.message:`Could not publish the review`)).finally(()=>u(!1))},children:l?`Publishing…`:`Publish to GitHub`}),(0,_.jsx)(`button`,{type:`button`,className:`button`,disabled:l,onClick:n,children:`Cancel`})]})]})]})})}var O0=100,k0=[{key:_t,value:_t,text:`Working tree`,note:`uncommitted`},{key:vt,value:vt,text:`Staged`,note:`index`}];function A0(e){return{key:`${e.kind}:${e.name}`,value:e.name,text:e.name,note:e.isDefault?`default`:void 0}}var j0=e=>/^(?:HEAD|[A-Z_]+_HEAD)$/.test(e)||/[~^@]/.test(e)||/^[0-9a-f]{7,64}$/i.test(e),M0=(e,t)=>t===``||e.toLowerCase()===t?0:e.toLowerCase().startsWith(t)?1:2;function N0({role:e,label:t,title:n,selected:r,refs:i,offerLocalChanges:a,onSelect:o}){let[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(``),[d,p]=(0,f.useState)(`branches`),[m,h]=(0,f.useState)(0),g=(0,f.useRef)(null),v=(0,f.useRef)(null),y=(0,f.useId)(),{options:b,hidden:x}=(0,f.useMemo)(()=>{let e=l.trim().toLowerCase(),t=t=>e===``||t.toLowerCase().includes(e),n=(d===`branches`?i?.branches??[]:i?.tags??[]).filter(e=>t(e.name)).map((t,n)=>({ref:t,index:n,rank:M0(t.name,e)})).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.ref),r=[];a&&d===`branches`&&r.push(...k0.filter(e=>t(e.text))),r.push(...n.slice(0,O0).map(A0));let o=l.trim();if(o!==``&&!n.some(e=>e.name===o)){let t=jt(o),i={key:`typed`,value:o,text:t===void 0?o:`Pull request #${t}`,note:t===void 0?`use this revision`:`fetch and open`},a=n.some(t=>t.name.toLowerCase().startsWith(e));t!==void 0||j0(o)&&!a?r.unshift(i):r.push(i)}return{options:r,hidden:Math.max(0,n.length-O0)}},[l,d,i,a]);(0,f.useEffect)(()=>h(0),[l,d]);let S=e=>`${y}-option-${e}`;(0,f.useEffect)(()=>{s&&document.getElementById(`${y}-option-${m}`)?.scrollIntoView({block:`nearest`})},[s,m,y]);let C=e=>{c(!1),u(``),e&&v.current?.focus()};(0,f.useEffect)(()=>{if(!s)return;let e=e=>{g.current?.contains(e.target)||C(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[s]);let w=e=>{e&&(C(!0),e.value!==r&&o(e.value))},T=e=>{e.key===`Escape`?(e.preventDefault(),C(!0)):e.key===`ArrowDown`?(e.preventDefault(),h(e=>Math.min(e+1,b.length-1))):e.key===`ArrowUp`?(e.preventDefault(),h(e=>Math.max(e-1,0))):e.key===`Enter`&&e.target instanceof HTMLInputElement&&(e.preventDefault(),w(b[m]))},E=e===`base`?`Choose a base ref`:`Choose a head ref`;return(0,_.jsxs)(`div`,{className:`picker`,ref:g,children:[(0,_.jsxs)(`button`,{ref:v,type:`button`,className:`ref-pill`,title:n,"aria-haspopup":`dialog`,"aria-expanded":s,onClick:()=>s?C(!1):c(!0),children:[(0,_.jsxs)(`span`,{className:`ref-pill-role`,children:[e,`:`]}),` `,(0,_.jsx)(`strong`,{children:t}),(0,_.jsx)(Fa,{size:16,className:`ref-pill-caret`})]}),s&&(0,_.jsxs)(`div`,{className:`picker-panel`,role:`dialog`,"aria-label":E,onKeyDown:T,children:[(0,_.jsxs)(`div`,{className:`picker-header`,children:[(0,_.jsx)(`span`,{children:E}),(0,_.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":`Close`,onClick:()=>C(!0),children:(0,_.jsx)(Va,{size:16})})]}),(0,_.jsx)(`div`,{className:`picker-search`,children:(0,_.jsx)(`input`,{autoFocus:!0,type:`text`,className:`text-input`,placeholder:d===`branches`?`Find a branch or type a revision`:`Find a tag`,"aria-label":`Filter refs`,role:`combobox`,"aria-expanded":`true`,"aria-autocomplete":`list`,"aria-controls":y,"aria-activedescendant":b.length>0?S(m):void 0,value:l,onChange:e=>u(e.target.value)})}),(0,_.jsx)(`div`,{className:`picker-tabs`,role:`tablist`,children:[`branches`,`tags`].map(e=>(0,_.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":d===e,className:`picker-tab`,onClick:()=>p(e),children:e===`branches`?`Branches`:`Tags`},e))}),(0,_.jsxs)(`ul`,{className:`picker-list`,id:y,role:`listbox`,"aria-label":E,children:[b.map((e,t)=>(0,_.jsxs)(`li`,{id:S(t),role:`option`,"aria-selected":e.value===r,className:`picker-option${t===m?` active`:``}`,onMouseEnter:()=>h(t),onClick:()=>w(e),children:[(0,_.jsx)(`span`,{className:`picker-check`,children:e.value===r&&(0,_.jsx)(er,{size:16})}),(0,_.jsx)(`span`,{className:`picker-option-text`,children:e.text}),e.note&&(0,_.jsx)(`span`,{className:`label`,children:e.note})]},e.key)),i===void 0&&(0,_.jsx)(`li`,{className:`picker-empty`,children:`Loading…`}),i!==void 0&&b.length===0&&(0,_.jsx)(`li`,{className:`picker-empty`,children:`Nothing to show.`}),x>0&&(0,_.jsxs)(`li`,{className:`picker-empty`,children:[x.toLocaleString(`en-US`),` more. Keep typing to narrow the list.`]})]})]})]})}var P0=[],F0=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`,I0=e=>/^[0-9a-f]{40}$|^[0-9a-f]{64}$/.test(e);function L0(e){return e.kind===`worktree`?_t:e.kind===`index`?vt:e.expr}function R0(e){return e.kind===`worktree`?`Working tree`:e.kind===`index`?`Staged`:I0(e.expr)?e.expr.slice(0,7):e.expr.replace(/^refs\/agentic-diff\/(?:shared\/|pr\/(\d+)\/(head|base)$)/,(e,t,n)=>t?n===`base`?`base of pull request #${t}`:`pull request #${t}`:``)}function z0(e){return e===`:worktree`?{kind:`worktree`}:e===`:staged`?{kind:`index`}:{kind:`rev`,expr:e}}var B0=e=>e?.kind===`rev`?e.oid:void 0;function V0({status:e}){return e.state===`clean`?(0,_.jsxs)(`span`,{className:`merge-note`,children:[(0,_.jsx)(er,{size:16,className:`tone-success`}),(0,_.jsx)(`strong`,{className:`tone-success`,children:`Able to merge.`}),` These branches can be automatically merged.`]}):e.state===`unrelated`?(0,_.jsxs)(`span`,{className:`merge-note`,children:[(0,_.jsx)(Va,{size:16,className:`tone-danger`}),(0,_.jsx)(`strong`,{className:`tone-danger`,children:`Nothing in common.`}),` These histories share no commit, so they cannot be merged as they are.`]}):(0,_.jsxs)(`span`,{className:`merge-note`,title:e.files.join(`
|
|
62
|
-
`),children:[(0,_.jsx)(Va,{size:16,className:`tone-danger`}),(0,_.jsx)(`strong`,{className:`tone-danger`,children:`Can’t automatically merge.`}),` `,F0(e.files.length,`file`),` would conflict.`]})}function H0({error:e,pull:t}){let n=e instanceof Error?e.message:`Something went wrong`,r=(e instanceof ct?e.code:void 0)===`rev_not_found`?`Revision not found`:t===void 0?`Cannot show this comparison`:`Cannot show pull request #${t}`;return(0,_.jsxs)(`div`,{className:`flash flash-danger`,role:`alert`,children:[(0,_.jsx)(`strong`,{children:r}),(0,_.jsx)(`span`,{children:n})]})}function U0({view:e,onChange:t}){return(0,_.jsx)(`div`,{className:`segmented`,role:`group`,"aria-label":`Diff view`,children:[`split`,`unified`].map(n=>(0,_.jsx)(`button`,{type:`button`,className:`segmented-button`,"aria-pressed":e===n,onClick:()=>t(n),children:n===`split`?`Split`:`Unified`},n))})}function W0({label:e,text:t}){let[n,r]=(0,f.useState)(!1);return(0,_.jsxs)(`div`,{className:`share-row`,children:[(0,_.jsx)(`span`,{className:`share-label`,children:e}),(0,_.jsx)(`input`,{className:`text-input`,readOnly:!0,value:t,"aria-label":e,onFocus:e=>e.target.select()}),(0,_.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":`Copy ${e.toLowerCase()}`,onClick:()=>{navigator.clipboard.writeText(t).then(()=>{r(!0),window.setTimeout(()=>r(!1),1500)})},children:n?(0,_.jsx)(er,{size:16}):(0,_.jsx)(wr,{size:16})})]})}function G0({route:e,pull:t}){let[n,r]=(0,f.useState)(!1),i=et({queryKey:[`share`,e.repoId,e.spec,e.view,e.ignoreWhitespace],queryFn:()=>z.share(e.repoId,e.spec,e.view,e.ignoreWhitespace),enabled:n&&e.pull===void 0});return e.pull===void 0?(0,_.jsxs)(`details`,{className:`share`,onToggle:e=>r(e.currentTarget.open),children:[(0,_.jsxs)(`summary`,{className:`button`,children:[(0,_.jsx)(zi,{size:16}),` Copy link`]}),(0,_.jsxs)(`div`,{className:`share-panel`,children:[i.isPending&&(0,_.jsx)(`p`,{className:`loading`,children:`Loading…`}),i.isError&&(0,_.jsx)(`p`,{children:i.error.message}),i.data?.available===!1&&(0,_.jsx)(`p`,{children:i.data.reason}),i.data?.available&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(W0,{label:`Command`,text:i.data.command}),(0,_.jsx)(W0,{label:`Link`,text:i.data.link}),(0,_.jsx)(`p`,{className:`share-note`,children:`The command works anywhere. The link works when the other person already has agentic-diff running. Both carry the repository address and the commits, never code or comments.`})]})]})]}):t?.url?(0,_.jsxs)(`details`,{className:`share`,children:[(0,_.jsxs)(`summary`,{className:`button`,children:[(0,_.jsx)(zi,{size:16}),` Copy link`]}),(0,_.jsxs)(`div`,{className:`share-panel`,children:[(0,_.jsx)(W0,{label:`Command`,text:Ft(t.url)}),(0,_.jsx)(W0,{label:`Link`,text:t.url}),(0,_.jsx)(`p`,{className:`share-note`,children:`The command opens this pull request in agentic-diff on another machine. Comments that are not published stay on this one.`})]})]}):null}var K0=`agentic-diff.tree`;function q0(){try{return window.localStorage.getItem(K0)!==`closed`}catch{return!0}}var J0=new Set;function Y0(){let e=(0,f.useRef)(Promise.resolve());return(0,f.useCallback)(t=>{let n=e.current.then(t,t);return e.current=n.catch(()=>void 0),n},[])}function X0({route:e,hash:t}){let{repoId:n,spec:r,ignoreWhitespace:i,view:a,pull:o,range:s}=e;Ja(n);let c=y(),[l]=(0,f.useState)(()=>({spec:r,pull:o,list:f_()})),u=l.spec===r&&l.pull===o?l.list:[],d=et({queryKey:[`pull`,n,o],queryFn:async()=>{try{return await z.pull(n,o)}catch(t){if(t instanceof ct&&t.code===`pull_not_imported`)return z.importPull(n,o,e.remote);throw t}},enabled:o!==void 0,retry:!1}),p=tt({mutationFn:t=>z.importPull(n,t,e.remote),onSuccess:e=>c.setQueryData([`pull`,n,e.number],e)}),m=p.variables===o,h=(0,f.useMemo)(()=>{try{return St(r)}catch{return}},[r]),g=et({queryKey:[`repo`,n],queryFn:()=>z.repo(n)}),v=et({queryKey:[`refs`,n],queryFn:()=>z.refs(n)}),b=et({queryKey:[`resolve`,n,r,i,s],queryFn:()=>z.resolve(n,r,i,s),enabled:o===void 0||d.data!==void 0,placeholderData:pe}),x=b.data,S=et({queryKey:[`files`,n,x?.diffFrom,x?.diffTo,i],queryFn:()=>z.files(n,x.diffFrom,x.diffTo,i),enabled:x!==void 0,placeholderData:pe}),C=b.isPlaceholderData||S.isPlaceholderData,w=(0,f.useRef)(void 0);x&&S.data&&!C&&(w.current={sides:x,list:S.data});let T=!b.isError&&!(o!==void 0&&d.isError),E=C?T?w.current?.sides??x:void 0:x,D=C?T?w.current?.list:void 0:S.data,O=(0,f.useRef)(C);O.current=C;let ee=(0,f.useCallback)(()=>O.current,[]),k=B0(E?.base),te=B0(E?.head)??(E?g.data?.head.oid:void 0),ne=et({queryKey:[`commits`,n,k,te],queryFn:()=>z.commits(n,k,te),enabled:k!==void 0&&te!==void 0,staleTime:1/0,placeholderData:pe}),A={data:k!==void 0&&te!==void 0?ne.data:void 0},j=E?.mode===`merge-base`&&k!==void 0&&B0(E.head)!==void 0,M=et({queryKey:[`merge-status`,n,k,B0(E?.head)],queryFn:()=>z.mergeStatus(n,k,B0(E?.head)),enabled:j,staleTime:1/0}),N=E?Mt(E):void 0,P=E?.range!==void 0,re=et({queryKey:[`threads`,n,N,E?.diffFrom,E?.diffTo],queryFn:()=>z.syncThreads(n,N,E.diffFrom,E.diffTo),enabled:N!==void 0&&D!==void 0&&!P,placeholderData:pe}),ie=P?void 0:re.data?.threads,ae=B_(n),{threadsByFile:oe,threadCounts:se,detached:ce,unresolved:le,unpublished:ue}=(0,f.useMemo)(()=>{let e=new Map,t=[],n=ie??[];for(let r of n){let n=r.detached?void 0:D?.files.find(e=>(r.side===`L`?e.oldPath??e.path:e.path)===r.path);n?e.set(n.path,[...e.get(n.path)??[],r]):t.push(r)}return{threadsByFile:e,threadCounts:new Map([...e].map(([e,t])=>[e,t.length])),detached:t,unresolved:n.filter(e=>e.state===`open`).length,unpublished:n.reduce((e,t)=>e+t.comments.filter(e=>!e.published).length,0)}},[ie,D]),de=Y0(),fe=(0,f.useMemo)(()=>[`viewed`,n,N,E?.diffFrom,E?.diffTo],[n,N,E?.diffFrom,E?.diffTo]),F=et({queryKey:fe,queryFn:()=>z.viewed(n,N,E.diffFrom,E.diffTo),enabled:N!==void 0&&E!==void 0&&!P,placeholderData:pe}),I=(0,f.useMemo)(()=>P||!F.data?J0:new Set(F.data.paths),[P,F.data]),me=(0,f.useCallback)((e,t)=>{if(!N||!E||O.current)return;c.setQueryData(fe,n=>{let r=new Set(n?.paths);return t?r.add(e):r.delete(e),{paths:[...r]}});let r={scope:N,from:E.diffFrom,to:E.diffTo,path:e,viewed:t};de(()=>z.setViewed(n,r)).then(e=>c.setQueryData(fe,e),()=>c.invalidateQueries({queryKey:fe}))},[c,de,n,N,E,fe]),he=E!==void 0&&!P&&(E.diffTo===`:worktree`||E.diffTo===`:staged`),ge=(0,f.useMemo)(()=>[`staging`,n],[n]),_e=et({queryKey:ge,queryFn:()=>z.staging(n),enabled:he}),[ve,L]=(0,f.useState)(void 0),ye=ve?.spec===r?ve.message:void 0,be=(0,f.useCallback)(e=>{c.setQueryData(ge,e),Ka(c,[`index`])},[c,ge]),xe=(0,f.useMemo)(()=>new Map((_e.data?.files??[]).map(e=>[e.path,e])),[_e.data]),Se=E!==void 0&&E.diffFrom===g.data?.head.oid,Ce=e=>{if(!he||!_e.data)return;let t=xe.get(e.path);return t?t.staged?t.unstaged?`partial`:`staged`:`unstaged`:Se?E?.diffTo===`:staged`?`staged`:`unstaged`:void 0},R=(0,f.useCallback)((e,t)=>{let i=e.oldPath?[e.path,e.oldPath]:[e.path];L(void 0),de(()=>t?z.stage(n,i):z.unstage(n,i)).then(be,e=>L({spec:r,message:e instanceof Error?e.message:`git refused`}))},[de,n,be,r]),[we,Te]=(0,f.useState)(void 0),Ee=(0,f.useRef)(void 0),De=t!==Ee.current,Oe=De?e_(t):we;(0,f.useEffect)(()=>{De&&Te(void 0)},[De]);let ke=(0,f.useCallback)((e,t,n)=>{let r={anchor:e,side:t,line:n};Ee.current=t_(r),Te(r),s_(`${window.location.pathname}${window.location.search}${Ee.current}`,{replace:!0})},[]),Ae=t=>s_(Zg({...e,pull:void 0,remote:void 0,range:void 0,spec:wt(t)})),je=e=>t=>{let r=jt(t);r===void 0?Ae(e(z0(t))):s_(Qg(n,r,a))},Me=(0,f.useCallback)(t=>`${Zg({...e,range:t})}`,[e]),Ne=t=>{Yg(t),s_(`${Zg({...e,view:t})}${window.location.hash}`,{replace:!0})},Pe=t=>{s_(`${Zg({...e,ignoreWhitespace:t})}${window.location.hash}`,{replace:!0})},[Fe,Ie]=(0,f.useState)(!1),[Le,Re]=(0,f.useState)(!1),[ze,Be]=(0,f.useState)(!1),[Ve,He]=(0,f.useState)(!1),[Ue,We]=(0,f.useState)(!1),[Ge,Ke]=(0,f.useState)(!1),[qe,Je]=(0,f.useState)(q0),Ye=()=>Je(e=>{try{window.localStorage.setItem(K0,e?`closed`:`open`)}catch{}return!e});M1({"?":()=>We(!0),f:()=>Be(!0),n:()=>F1(1),p:()=>F1(-1),t:()=>{qe||Ye(),window.setTimeout(()=>document.querySelector(`.tree-filter input`)?.focus(),0)},v:()=>{let e=N1()?.getAttribute(`aria-label`);e&&!P&&me(e,!I.has(e))},s:()=>{let e=N1()?.getAttribute(`aria-label`),t=D?.files.find(t=>t.path===e),n=t?Ce(t):void 0;t&&n&&R(t,n!==`staged`)}});let Xe=B0(E?.head),Ze=E?.diffTo===`:worktree`&&!P,Qe=E!==void 0&&!P&&(Xe===void 0||Xe===g.data?.head.oid),$e=Qe||!E?void 0:`Check out ${R0(h?.head??{kind:`worktree`})} to apply suggestions to it.`,nt=d.error??g.error??b.error??S.error,rt=S.dataUpdatedAt,it=(0,f.useMemo)(()=>{let e=E?.range,t=A.data?.commits;if(!e||!t)return;let n=t.findIndex(t=>t.oid===e.to),r=t.findIndex(t=>t.oid===e.from);return n<0||r<n?void 0:t.slice(n,r+1)},[E?.range,A.data]),at=D?.totals,ot=h?.base.kind===`rev`&&h.head.kind===`rev`,st=h?.mode===`merge-base`;return(0,_.jsx)(oo,{repoId:n,repoRoot:g.data?.root,spec:r,scope:N,scratch:E?.head.kind===`rev`,children:(0,_.jsxs)(x_,{repoId:n,canEdit:Ze,canApply:Qe,applyBlockedBy:$e,children:[(0,_.jsxs)(`header`,{className:`app-header`,children:[(0,_.jsx)(`span`,{className:`app-name`,children:`agentic-diff`}),g.data&&(0,_.jsxs)(`span`,{className:`app-repo`,title:g.data.root,children:[(0,_.jsx)(da,{size:16}),` `,g.data.name]}),(0,_.jsx)(`button`,{type:`button`,className:`icon-button app-header-end`,"aria-label":`Keyboard shortcuts`,title:`Keyboard shortcuts (?)`,onClick:()=>We(!0),children:(0,_.jsx)(aa,{size:16})}),(0,_.jsxs)(`button`,{type:`button`,className:`button`,"aria-pressed":Le,disabled:N===void 0,onClick:()=>Re(e=>!e),children:[(0,_.jsx)(xr,{size:16}),` Agent`]})]}),(0,_.jsxs)(`main`,{className:`page${Le?` with-chat`:``}`,children:[(0,_.jsxs)(`div`,{className:`page-narrow`,children:[o===void 0?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`h1`,{className:`page-title`,children:`Comparing changes`}),(0,_.jsx)(`p`,{className:`page-subtitle`,children:`Choose two branches, tags or commits to see what changed, or compare with your uncommitted work.`})]}):d.data?(0,_.jsx)(w0,{pull:d.data,commits:A.data?.total,refreshing:p.isPending&&m,refreshError:m?p.error?.message:void 0,onRefresh:()=>p.mutate(o),action:s===void 0&&(0,_.jsxs)(`button`,{type:`button`,className:`button button-small button-primary`,onClick:()=>He(!0),title:`See what would be published to GitHub, then publish it`,children:[(0,_.jsx)(hr,{size:16}),` Review changes`,ue>0&&(0,_.jsx)(`span`,{className:`counter`,children:ue})]})}):!d.error&&(0,_.jsxs)(`p`,{className:`loading`,children:[`Fetching pull request #`,o,`…`]}),u.map(e=>(0,_.jsx)(`div`,{className:`flash flash-attention`,role:`status`,children:e},e)),o!==void 0&&j&&M.data&&d.data?.state!==`merged`&&d.data?.state!==`closed`&&(0,_.jsx)(`div`,{className:`range-bar`,children:(0,_.jsx)(V0,{status:M.data})}),h&&o===void 0&&(0,_.jsxs)(`div`,{className:`range-bar`,children:[(0,_.jsx)(hi,{size:16,className:`range-icon`}),(0,_.jsx)(N0,{role:`base`,label:R0(h.base),title:B0(E?.base),selected:L0(h.base),refs:v.data,offerLocalChanges:!1,onSelect:je(e=>({...h,base:e}))}),(0,_.jsxs)(`button`,{type:`button`,className:`mode-toggle`,disabled:h.base.kind!==`rev`,"aria-label":st?`Three-dot comparison. Switch to two-dot.`:`Two-dot comparison. Switch to three-dot.`,title:st?`Three dots: what the compare side changed since it branched off. Click for a direct two-dot diff.`:`Two dots: the direct difference between the two sides. Click for a three-dot comparison.`,onClick:()=>Ae({...h,mode:st?`direct`:`merge-base`}),children:[(0,_.jsx)(Gn,{size:16}),(0,_.jsx)(`span`,{"aria-hidden":`true`,children:st?`...`:`..`})]}),(0,_.jsx)(N0,{role:`compare`,label:R0(h.head),title:B0(E?.head),selected:L0(h.head),refs:v.data,offerLocalChanges:!0,onSelect:je(e=>({...h,head:e}))}),ot&&(0,_.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":`Swap base and compare`,title:`Swap base and compare`,onClick:()=>Ae({...h,base:h.head,head:h.base}),children:(0,_.jsx)(Jn,{size:16})}),j&&M.data&&(0,_.jsx)(V0,{status:M.data}),E&&!j&&(0,_.jsx)(`span`,{className:`range-note`,children:E.mode===`merge-base`&&E.mergeBase?(0,_.jsxs)(_.Fragment,{children:[`Changes since the merge base `,(0,_.jsx)(`code`,{children:E.mergeBase.slice(0,7)})]}):`Direct comparison of the two sides`}),ot&&E&&(at?.files??0)>0&&(0,_.jsxs)(`button`,{type:`button`,className:`button range-bar-end`,onClick:()=>Ke(!0),title:`Open a pull request on GitHub for these two branches`,children:[(0,_.jsx)(xi,{size:16}),` Create pull request`]})]}),nt?(0,_.jsx)(H0,{error:nt,pull:o}):null,(0,_.jsx)(Ig,{}),(0,_.jsx)(w_,{}),he&&_e.data&&(0,_.jsx)(g0,{status:_e.data,onStage:e=>de(()=>z.stage(n,e)).then(be),onUnstage:e=>de(()=>z.unstage(n,e)).then(be),onCommit:e=>de(()=>z.commit(n,e)).then(e=>(Ka(c,[`refs`,`index`]),e))}),ye&&(0,_.jsxs)(`div`,{className:`flash flash-danger`,role:`alert`,children:[(0,_.jsx)(`strong`,{children:`git did not do that`}),(0,_.jsx)(`span`,{children:ye})]}),at&&A.data&&(0,_.jsxs)(`div`,{className:`stats-bar`,children:[(0,_.jsxs)(`span`,{children:[(0,_.jsx)(fi,{size:16,className:`range-icon`}),` `,(0,_.jsx)(`strong`,{children:A.data.total.toLocaleString(`en-US`)}),` `,A.data.total===1?`commit`:`commits`]}),(0,_.jsxs)(`span`,{children:[(0,_.jsx)(Jr,{size:16,className:`range-icon`}),` `,(0,_.jsx)(`strong`,{children:at.files.toLocaleString(`en-US`)}),` `,at.files===1?`file`:`files`,` changed`]}),(0,_.jsxs)(`span`,{children:[(0,_.jsx)(ea,{size:16,className:`range-icon`}),` `,(0,_.jsxs)(`strong`,{children:[A.data.contributors.toLocaleString(`en-US`),A.data.truncated?`+`:``]}),` `,A.data.contributors===1?`contributor`:`contributors`]})]}),A.data&&(0,_.jsx)(v_,{list:A.data,range:E?.range,hrefFor:E?.head.kind===`rev`?Me:void 0}),E?.range&&(0,_.jsxs)(`div`,{className:`flash flash-attention range-flash`,role:`status`,children:[(0,_.jsxs)(`span`,{children:[it?.length===1?(0,_.jsxs)(_.Fragment,{children:[`Showing only the changes of commit `,(0,_.jsx)(`code`,{children:E.range.to.slice(0,7)}),` `,(0,_.jsx)(`em`,{children:it[0]?.subject}),`.`]}):(0,_.jsxs)(_.Fragment,{children:[`Showing only the changes of `,it?`${it.length} commits`:`the commits`,`, `,(0,_.jsx)(`code`,{children:E.range.from.slice(0,7)}),` to`,` `,(0,_.jsx)(`code`,{children:E.range.to.slice(0,7)}),`.`]}),` `,`Conversations, viewed marks and editing belong to the whole comparison and are hidden here.`]}),(0,_.jsx)(`a`,{href:Me(void 0),onClick:e=>{e.metaKey||e.ctrlKey||e.shiftKey||e.button!==0||(e.preventDefault(),s_(Me(void 0)))},children:`Show all changes`})]})]}),at&&D&&E&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`toolbar`,children:[(0,_.jsx)(`button`,{type:`button`,className:`icon-button tree-toggle`,"aria-pressed":qe,"aria-label":qe?`Hide file tree`:`Show file tree`,title:qe?`Hide file tree`:`Show file tree`,onClick:Ye,children:qe?(0,_.jsx)(ba,{size:16}):(0,_.jsx)(_a,{size:16})}),(0,_.jsxs)(`details`,{className:`toc`,onToggle:e=>Ie(e.currentTarget.open),children:[(0,_.jsxs)(`summary`,{"aria-live":`polite`,children:[(0,_.jsx)(Jr,{size:16,className:`range-icon`}),(0,_.jsxs)(`span`,{children:[`Showing `,(0,_.jsx)(`strong`,{className:`toc-link`,children:F0(at.files,`changed file`)}),` with`,` `,(0,_.jsx)(`strong`,{children:F0(at.additions,`addition`)}),` and`,` `,(0,_.jsx)(`strong`,{children:F0(at.deletions,`deletion`)}),`.`]})]}),Fe&&(0,_.jsx)(j_,{files:D.files})]}),ie&&ie.length>0&&(0,_.jsxs)(`span`,{className:`conversation-count`,children:[F0(ie.length,`conversation`),le>0?`, ${le} unresolved`:`, all resolved`]}),!P&&at.files>0&&(0,_.jsxs)(`span`,{className:`viewed-count`,title:`Files you have marked as viewed`,children:[(0,_.jsx)(`progress`,{max:at.files,value:I.size,"aria-hidden":`true`}),I.size,` / `,at.files,` viewed`]}),(0,_.jsxs)(`label`,{className:`checkbox`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>Pe(e.target.checked)}),`Hide whitespace`]}),(0,_.jsx)(G0,{route:e,pull:d.data}),(0,_.jsx)(U0,{view:a,onChange:Ne})]}),at.files===0?(0,_.jsxs)(`div`,{className:`blankslate`,children:[(0,_.jsx)(`h2`,{className:`blankslate-title`,children:`There isn’t anything to compare.`}),(0,_.jsx)(`div`,{className:`blankslate-body`,children:(0,_.jsx)(`p`,{children:`The two sides are identical. Pick different revisions or make a change.`})})]}):(0,_.jsxs)(`div`,{className:`diff-layout${qe?` with-tree`:``}`,children:[qe&&(0,_.jsx)(y0,{files:D.files,viewed:I,threadCounts:se,activeAnchor:Oe?.anchor}),(0,_.jsx)(`div`,{className:`file-cards`,children:D.files.map(e=>(0,_.jsx)(h0,{repoId:n,comparison:E,file:e,view:a,target:Oe?.anchor===e.anchor?Oe:void 0,scrollToTarget:De,threads:oe.get(e.path)??P0,scope:N,viewed:I.has(e.path),onViewed:P?void 0:me,readOnly:P,staging:Ce(e),onStage:he?R:void 0,onSelectLine:ke,isSettling:ee,listedAt:E.diffTo===`:worktree`&&!e.newOid&&En(e.path)!==void 0?rt:void 0},e.path))})]}),ce.length>0&&(0,_.jsxs)(`section`,{className:`detached-threads`,"aria-label":`Conversations on files no longer in this comparison`,children:[(0,_.jsx)(`h2`,{className:`detached-title`,children:`Conversations on files that are no longer part of this comparison`}),ce.map(e=>(0,_.jsx)(W_,{repoId:n,thread:e,actions:ae,showPath:!0},e.id))]})]}),!nt&&(o===void 0||d.data)&&(b.isPending||S.isPending)&&(0,_.jsx)(`p`,{className:`loading`,children:`Loading…`})]}),Ge&&(0,_.jsx)(b0,{repoId:n,spec:r,onClose:()=>Ke(!1),onOpen:e=>{Ke(!1),s_(Qg(n,e,a)),window.scrollTo(0,0)}}),Ue&&(0,_.jsx)(R1,{onClose:()=>We(!1)}),(0,_.jsx)(Bg,{repoId:n,rev:E?.diffTo,searchOpen:ze,onSearchClose:()=>Be(!1)}),Ve&&d.data&&(0,_.jsx)(D0,{repoId:n,pull:d.data,onClose:()=>He(!1)}),Le&&N&&(0,_.jsx)(Rg,{repoId:n,scope:N,onClose:()=>Re(!1)})]})})}function Z0({input:e}){let t=et({queryKey:[`link`,e],queryFn:()=>z.resolveLink(e),retry:!1,refetchOnWindowFocus:!1}),n=tt({mutationFn:e=>z.cloneForLink(e),onSuccess:()=>t.refetch()}),r=t.data;return(0,f.useEffect)(()=>{r?.status===`ready`&&(d_(r.notices),s_(r.path,{replace:!0}))},[r]),t.isError?(0,_.jsx)(`main`,{className:`page`,children:(0,_.jsx)(`div`,{className:`page-narrow`,children:(0,_.jsxs)(`div`,{className:`flash flash-danger`,role:`alert`,children:[(0,_.jsx)(`strong`,{children:`Cannot open this link`}),(0,_.jsx)(`span`,{children:t.error.message})]})})}):r?.status===`needs-clone`?(0,_.jsx)(`main`,{className:`page`,children:(0,_.jsxs)(`div`,{className:`dialog`,role:`dialog`,"aria-labelledby":`clone-title`,children:[(0,_.jsx)(`h1`,{id:`clone-title`,className:`dialog-title`,children:`Clone this repository?`}),(0,_.jsx)(`p`,{children:`This link points to a repository that is not on this machine yet.`}),(0,_.jsxs)(`dl`,{className:`dialog-facts`,children:[(0,_.jsx)(`dt`,{children:`Repository`}),(0,_.jsx)(`dd`,{children:(0,_.jsx)(`code`,{children:r.repoUrl})}),(0,_.jsx)(`dt`,{children:`Will be cloned to`}),(0,_.jsx)(`dd`,{children:(0,_.jsx)(`code`,{children:r.destination})})]}),(0,_.jsx)(`p`,{className:`dialog-note`,children:`Only clone repositories you expect. Nothing in it is run: agentic-diff reads the files and shows the comparison.`}),n.isError&&(0,_.jsx)(`div`,{className:`flash flash-danger`,role:`alert`,children:(0,_.jsx)(`span`,{children:n.error.message})}),(0,_.jsxs)(`div`,{className:`dialog-actions`,children:[(0,_.jsx)(`button`,{type:`button`,className:`button button-primary`,disabled:n.isPending,onClick:()=>n.mutate(r.repoUrl),children:n.isPending?`Cloning…`:`Clone and open`}),(0,_.jsx)(`button`,{type:`button`,className:`button`,disabled:n.isPending,onClick:()=>s_(`/`,{replace:!0}),children:`Cancel`})]}),n.isPending&&(0,_.jsx)(`p`,{className:`dialog-note`,children:`Large repositories can take a few minutes.`})]})}):(0,_.jsx)(`main`,{className:`page`,children:(0,_.jsx)(`p`,{className:`loading`,children:`Opening the link…`})})}function Q0({title:e,children:t}){return(0,_.jsx)(`main`,{className:`page`,children:(0,_.jsxs)(`div`,{className:`blankslate`,children:[(0,_.jsx)(`h1`,{className:`blankslate-title`,children:e}),(0,_.jsx)(`div`,{className:`blankslate-body`,children:t})]})})}var $0=()=>(0,_.jsxs)(`p`,{children:[`Run `,(0,_.jsx)(`code`,{children:`agentic-diff`}),` in a git repository to open a comparison.`]});function ev(){let e=o_(),t=Xg(e.pathname,e.search,Jg()),n=et({queryKey:[`session`],queryFn:async()=>{let e=l_();if(e)try{return await z.signIn(e)}catch{}return z.session()},staleTime:1/0});return n.isPending?null:n.isError?(0,_.jsx)(Q0,{title:`Cannot reach agentic-diff`,children:`The local server did not answer. Start it again from the terminal.`}):n.data.authenticated?t.name===`open`?(0,_.jsx)(Z0,{input:t.input}):t.name===`compare`?(0,_.jsx)(X0,{route:t,hash:e.hash}):t.name===`home`?(0,_.jsx)(Q0,{title:`agentic-diff`,children:(0,_.jsx)($0,{})}):(0,_.jsx)(Q0,{title:`Page not found`,children:`This address does not match any agentic-diff page.`}):(0,_.jsxs)(Q0,{title:`Not signed in`,children:[(0,_.jsx)(`p`,{children:`This browser has no session with your local agentic-diff server.`}),t.name===`open`?(0,_.jsxs)(`p`,{children:[`To open this link, run `,(0,_.jsx)(`code`,{children:Ft(t.input)})]}):(0,_.jsx)($0,{})]})}var tv=new Ke({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:(e,t)=>!(t instanceof ct&&t.status<500)&&e<2}}});(0,st.createRoot)(document.getElementById(`root`)).render((0,_.jsx)(f.StrictMode,{children:(0,_.jsx)(b,{client:tv,children:(0,_.jsx)(ev,{})})}));export{D1 as a,It as c,d,l as f,x1 as i,ct as l,w1 as n,b_ as o,v1 as r,Cn as s,r0 as t,g as u};
|
|
62
|
+
`),children:[(0,_.jsx)(Va,{size:16,className:`tone-danger`}),(0,_.jsx)(`strong`,{className:`tone-danger`,children:`Can’t automatically merge.`}),` `,F0(e.files.length,`file`),` would conflict.`]})}function H0({error:e,pull:t}){let n=e instanceof Error?e.message:`Something went wrong`,r=(e instanceof ct?e.code:void 0)===`rev_not_found`?`Revision not found`:t===void 0?`Cannot show this comparison`:`Cannot show pull request #${t}`;return(0,_.jsxs)(`div`,{className:`flash flash-danger`,role:`alert`,children:[(0,_.jsx)(`strong`,{children:r}),(0,_.jsx)(`span`,{children:n})]})}function U0({view:e,onChange:t}){return(0,_.jsx)(`div`,{className:`segmented`,role:`group`,"aria-label":`Diff view`,children:[`split`,`unified`].map(n=>(0,_.jsx)(`button`,{type:`button`,className:`segmented-button`,"aria-pressed":e===n,onClick:()=>t(n),children:n===`split`?`Split`:`Unified`},n))})}function W0({label:e,text:t}){let[n,r]=(0,f.useState)(!1);return(0,_.jsxs)(`div`,{className:`share-row`,children:[(0,_.jsx)(`span`,{className:`share-label`,children:e}),(0,_.jsx)(`input`,{className:`text-input`,readOnly:!0,value:t,"aria-label":e,onFocus:e=>e.target.select()}),(0,_.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":`Copy ${e.toLowerCase()}`,onClick:()=>{navigator.clipboard.writeText(t).then(()=>{r(!0),window.setTimeout(()=>r(!1),1500)})},children:n?(0,_.jsx)(er,{size:16}):(0,_.jsx)(wr,{size:16})})]})}function G0({route:e,pull:t}){let[n,r]=(0,f.useState)(!1),i=et({queryKey:[`share`,e.repoId,e.spec,e.view,e.ignoreWhitespace],queryFn:()=>z.share(e.repoId,e.spec,e.view,e.ignoreWhitespace),enabled:n&&e.pull===void 0});return e.pull===void 0?(0,_.jsxs)(`details`,{className:`share`,onToggle:e=>r(e.currentTarget.open),children:[(0,_.jsxs)(`summary`,{className:`button`,children:[(0,_.jsx)(zi,{size:16}),` Copy link`]}),(0,_.jsxs)(`div`,{className:`share-panel`,children:[i.isPending&&(0,_.jsx)(`p`,{className:`loading`,children:`Loading…`}),i.isError&&(0,_.jsx)(`p`,{children:i.error.message}),i.data?.available===!1&&(0,_.jsx)(`p`,{children:i.data.reason}),i.data?.available&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(W0,{label:`Command`,text:i.data.command}),(0,_.jsx)(W0,{label:`Link`,text:i.data.link}),(0,_.jsx)(`p`,{className:`share-note`,children:`The command works anywhere. The link works when the other person already has agentic-diff running. Both carry the repository address and the commits, never code or comments.`})]})]})]}):t?.url?(0,_.jsxs)(`details`,{className:`share`,children:[(0,_.jsxs)(`summary`,{className:`button`,children:[(0,_.jsx)(zi,{size:16}),` Copy link`]}),(0,_.jsxs)(`div`,{className:`share-panel`,children:[(0,_.jsx)(W0,{label:`Command`,text:Ft(t.url)}),(0,_.jsx)(W0,{label:`Link`,text:t.url}),(0,_.jsx)(`p`,{className:`share-note`,children:`The command opens this pull request in agentic-diff on another machine. Comments that are not published stay on this one.`})]})]}):null}var K0=`agentic-diff.tree`;function q0(){try{return window.localStorage.getItem(K0)!==`closed`}catch{return!0}}var J0=new Set;function Y0(){let e=(0,f.useRef)(Promise.resolve());return(0,f.useCallback)(t=>{let n=e.current.then(t,t);return e.current=n.catch(()=>void 0),n},[])}function X0({route:e,hash:t}){let{repoId:n,spec:r,ignoreWhitespace:i,view:a,pull:o,range:s}=e;Ja(n);let c=y(),[l]=(0,f.useState)(()=>({spec:r,pull:o,list:f_()})),u=l.spec===r&&l.pull===o?l.list:[],d=et({queryKey:[`pull`,n,o],queryFn:async()=>{try{return await z.pull(n,o)}catch(t){if(t instanceof ct&&t.code===`pull_not_imported`)return z.importPull(n,o,e.remote);throw t}},enabled:o!==void 0,retry:!1}),p=tt({mutationFn:t=>z.importPull(n,t,e.remote),onSuccess:e=>c.setQueryData([`pull`,n,e.number],e)}),m=p.variables===o,h=(0,f.useMemo)(()=>{try{return St(r)}catch{return}},[r]),g=et({queryKey:[`repo`,n],queryFn:()=>z.repo(n)}),v=et({queryKey:[`refs`,n],queryFn:()=>z.refs(n)}),b=et({queryKey:[`resolve`,n,r,i,s],queryFn:()=>z.resolve(n,r,i,s),enabled:o===void 0||d.data!==void 0,placeholderData:pe}),x=b.data,S=et({queryKey:[`files`,n,x?.diffFrom,x?.diffTo,i],queryFn:()=>z.files(n,x.diffFrom,x.diffTo,i),enabled:x!==void 0,placeholderData:pe}),C=b.isPlaceholderData||S.isPlaceholderData,w=(0,f.useRef)(void 0);x&&S.data&&!C&&(w.current={sides:x,list:S.data});let T=!b.isError&&!(o!==void 0&&d.isError),E=C?T?w.current?.sides??x:void 0:x,D=C?T?w.current?.list:void 0:S.data,O=(0,f.useRef)(C);O.current=C;let ee=(0,f.useCallback)(()=>O.current,[]),k=B0(E?.base),te=B0(E?.head)??(E?g.data?.head.oid:void 0),ne=et({queryKey:[`commits`,n,k,te],queryFn:()=>z.commits(n,k,te),enabled:k!==void 0&&te!==void 0,staleTime:1/0,placeholderData:pe}),A={data:k!==void 0&&te!==void 0?ne.data:void 0},j=E?.mode===`merge-base`&&k!==void 0&&B0(E.head)!==void 0,M=et({queryKey:[`merge-status`,n,k,B0(E?.head)],queryFn:()=>z.mergeStatus(n,k,B0(E?.head)),enabled:j,staleTime:1/0}),N=E?Mt(E):void 0,P=E?.range!==void 0,re=et({queryKey:[`threads`,n,N,E?.diffFrom,E?.diffTo],queryFn:()=>z.syncThreads(n,N,E.diffFrom,E.diffTo),enabled:N!==void 0&&D!==void 0&&!P,placeholderData:pe}),ie=P?void 0:re.data?.threads,ae=B_(n),{threadsByFile:oe,threadCounts:se,detached:ce,unresolved:le,unpublished:ue}=(0,f.useMemo)(()=>{let e=new Map,t=[],n=ie??[];for(let r of n){let n=r.detached?void 0:D?.files.find(e=>(r.side===`L`?e.oldPath??e.path:e.path)===r.path);n?e.set(n.path,[...e.get(n.path)??[],r]):t.push(r)}return{threadsByFile:e,threadCounts:new Map([...e].map(([e,t])=>[e,t.length])),detached:t,unresolved:n.filter(e=>e.state===`open`).length,unpublished:n.reduce((e,t)=>e+t.comments.filter(e=>!e.published).length,0)}},[ie,D]),de=Y0(),fe=(0,f.useMemo)(()=>[`viewed`,n,N,E?.diffFrom,E?.diffTo],[n,N,E?.diffFrom,E?.diffTo]),F=et({queryKey:fe,queryFn:()=>z.viewed(n,N,E.diffFrom,E.diffTo),enabled:N!==void 0&&E!==void 0&&!P,placeholderData:pe}),I=(0,f.useMemo)(()=>P||!F.data?J0:new Set(F.data.paths),[P,F.data]),me=(0,f.useCallback)((e,t)=>{if(!N||!E||O.current)return;c.setQueryData(fe,n=>{let r=new Set(n?.paths);return t?r.add(e):r.delete(e),{paths:[...r]}});let r={scope:N,from:E.diffFrom,to:E.diffTo,path:e,viewed:t};de(()=>z.setViewed(n,r)).then(e=>c.setQueryData(fe,e),()=>c.invalidateQueries({queryKey:fe}))},[c,de,n,N,E,fe]),he=E!==void 0&&!P&&(E.diffTo===`:worktree`||E.diffTo===`:staged`),ge=(0,f.useMemo)(()=>[`staging`,n],[n]),_e=et({queryKey:ge,queryFn:()=>z.staging(n),enabled:he}),[ve,L]=(0,f.useState)(void 0),ye=ve?.spec===r?ve.message:void 0,be=(0,f.useCallback)(e=>{c.setQueryData(ge,e),Ka(c,[`index`])},[c,ge]),xe=(0,f.useMemo)(()=>new Map((_e.data?.files??[]).map(e=>[e.path,e])),[_e.data]),Se=E!==void 0&&E.diffFrom===g.data?.head.oid,Ce=e=>{if(!he||!_e.data)return;let t=xe.get(e.path);return t?t.staged?t.unstaged?`partial`:`staged`:`unstaged`:Se?E?.diffTo===`:staged`?`staged`:`unstaged`:void 0},R=(0,f.useCallback)((e,t)=>{let i=e.oldPath?[e.path,e.oldPath]:[e.path];L(void 0),de(()=>t?z.stage(n,i):z.unstage(n,i)).then(be,e=>L({spec:r,message:e instanceof Error?e.message:`git refused`}))},[de,n,be,r]),[we,Te]=(0,f.useState)(void 0),Ee=(0,f.useRef)(void 0),De=t!==Ee.current,Oe=De?e_(t):we;(0,f.useEffect)(()=>{De&&Te(void 0)},[De]);let ke=(0,f.useCallback)((e,t,n)=>{let r={anchor:e,side:t,line:n};Ee.current=t_(r),Te(r),s_(`${window.location.pathname}${window.location.search}${Ee.current}`,{replace:!0})},[]),Ae=t=>s_(Zg({...e,pull:void 0,remote:void 0,range:void 0,spec:wt(t)})),je=e=>t=>{let r=jt(t);r===void 0?Ae(e(z0(t))):s_(Qg(n,r,a))},Me=(0,f.useCallback)(t=>`${Zg({...e,range:t})}`,[e]),Ne=t=>{Yg(t),s_(`${Zg({...e,view:t})}${window.location.hash}`,{replace:!0})},Pe=t=>{s_(`${Zg({...e,ignoreWhitespace:t})}${window.location.hash}`,{replace:!0})},[Fe,Ie]=(0,f.useState)(!1),[Le,Re]=(0,f.useState)(!1),[ze,Be]=(0,f.useState)(!1),[Ve,He]=(0,f.useState)(!1),[Ue,We]=(0,f.useState)(!1),[Ge,Ke]=(0,f.useState)(!1),[qe,Je]=(0,f.useState)(q0),Ye=()=>Je(e=>{try{window.localStorage.setItem(K0,e?`closed`:`open`)}catch{}return!e});M1({"?":()=>We(!0),f:()=>Be(!0),n:()=>F1(1),p:()=>F1(-1),t:()=>{qe||Ye(),window.setTimeout(()=>document.querySelector(`.tree-filter input`)?.focus(),0)},v:()=>{let e=N1()?.getAttribute(`aria-label`);e&&!P&&me(e,!I.has(e))},s:()=>{let e=N1()?.getAttribute(`aria-label`),t=D?.files.find(t=>t.path===e),n=t?Ce(t):void 0;t&&n&&R(t,n!==`staged`)}});let Xe=B0(E?.head),Ze=E?.diffTo===`:worktree`&&!P,Qe=E!==void 0&&!P&&(Xe===void 0||Xe===g.data?.head.oid),$e=Qe||!E?void 0:`Check out ${R0(h?.head??{kind:`worktree`})} to apply suggestions to it.`,nt=d.error??g.error??b.error??S.error,rt=S.dataUpdatedAt,it=(0,f.useMemo)(()=>{let e=E?.range,t=A.data?.commits;if(!e||!t)return;let n=t.findIndex(t=>t.oid===e.to),r=t.findIndex(t=>t.oid===e.from);return n<0||r<n?void 0:t.slice(n,r+1)},[E?.range,A.data]),at=D?.totals,ot=h?.base.kind===`rev`&&h.head.kind===`rev`,st=h?.mode===`merge-base`;return(0,_.jsx)(oo,{repoId:n,repoRoot:g.data?.root,spec:r,scope:N,scratch:E?.head.kind===`rev`,children:(0,_.jsxs)(x_,{repoId:n,canEdit:Ze,canApply:Qe,applyBlockedBy:$e,children:[(0,_.jsxs)(`header`,{className:`app-header`,children:[(0,_.jsx)(`span`,{className:`app-name`,children:`agentic-diff`}),g.data&&(0,_.jsxs)(`span`,{className:`app-repo`,title:g.data.root,children:[(0,_.jsx)(da,{size:16}),` `,g.data.name]}),(0,_.jsx)(`button`,{type:`button`,className:`icon-button app-header-end`,"aria-label":`Keyboard shortcuts`,title:`Keyboard shortcuts (?)`,onClick:()=>We(!0),children:(0,_.jsx)(aa,{size:16})}),(0,_.jsxs)(`button`,{type:`button`,className:`button`,"aria-pressed":Le,disabled:N===void 0,onClick:()=>Re(e=>!e),children:[(0,_.jsx)(xr,{size:16}),` Agent`]})]}),(0,_.jsxs)(`main`,{className:`page${Le?` with-chat`:``}`,children:[(0,_.jsxs)(`div`,{className:`page-narrow`,children:[o===void 0?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`h1`,{className:`page-title`,children:`Comparing changes`}),(0,_.jsx)(`p`,{className:`page-subtitle`,children:`Choose two branches, tags or commits to see what changed, or compare with your uncommitted work.`})]}):d.data?(0,_.jsx)(w0,{pull:d.data,commits:A.data?.total,refreshing:p.isPending&&m,refreshError:m?p.error?.message:void 0,onRefresh:()=>p.mutate(o),action:s===void 0&&(0,_.jsxs)(`button`,{type:`button`,className:`button button-small button-primary`,onClick:()=>He(!0),title:`See what would be published to GitHub, then publish it`,children:[(0,_.jsx)(hr,{size:16}),` Review changes`,ue>0&&(0,_.jsx)(`span`,{className:`counter`,children:ue})]})}):!d.error&&(0,_.jsxs)(`p`,{className:`loading`,children:[`Fetching pull request #`,o,`…`]}),u.map(e=>(0,_.jsx)(`div`,{className:`flash flash-attention`,role:`status`,children:e},e)),o!==void 0&&j&&M.data&&d.data?.state!==`merged`&&d.data?.state!==`closed`&&(0,_.jsx)(`div`,{className:`range-bar`,children:(0,_.jsx)(V0,{status:M.data})}),h&&o===void 0&&(0,_.jsxs)(`div`,{className:`range-bar`,children:[(0,_.jsx)(hi,{size:16,className:`range-icon`}),(0,_.jsx)(N0,{role:`base`,label:R0(h.base),title:B0(E?.base),selected:L0(h.base),refs:v.data,offerLocalChanges:!1,onSelect:je(e=>({...h,base:e}))}),(0,_.jsxs)(`button`,{type:`button`,className:`mode-toggle`,disabled:h.base.kind!==`rev`,"aria-label":st?`Three-dot comparison. Switch to two-dot.`:`Two-dot comparison. Switch to three-dot.`,title:st?`Three dots: what the compare side changed since it branched off. Click for a direct two-dot diff.`:`Two dots: the direct difference between the two sides. Click for a three-dot comparison.`,onClick:()=>Ae({...h,mode:st?`direct`:`merge-base`}),children:[(0,_.jsx)(Gn,{size:16}),(0,_.jsx)(`span`,{"aria-hidden":`true`,children:st?`...`:`..`})]}),(0,_.jsx)(N0,{role:`compare`,label:R0(h.head),title:B0(E?.head),selected:L0(h.head),refs:v.data,offerLocalChanges:!0,onSelect:je(e=>({...h,head:e}))}),ot&&(0,_.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":`Swap base and compare`,title:`Swap base and compare`,onClick:()=>Ae({...h,base:h.head,head:h.base}),children:(0,_.jsx)(Jn,{size:16})}),j&&M.data&&(0,_.jsx)(V0,{status:M.data}),E&&!j&&(0,_.jsx)(`span`,{className:`range-note`,children:E.mode===`merge-base`&&E.mergeBase?(0,_.jsxs)(_.Fragment,{children:[`Changes since the merge base `,(0,_.jsx)(`code`,{children:E.mergeBase.slice(0,7)})]}):`Direct comparison of the two sides`}),ot&&E&&(at?.files??0)>0&&(0,_.jsxs)(`button`,{type:`button`,className:`button range-bar-end`,onClick:()=>Ke(!0),title:`Open a pull request on GitHub for these two branches`,children:[(0,_.jsx)(xi,{size:16}),` Create pull request`]})]}),nt?(0,_.jsx)(H0,{error:nt,pull:o}):null,(0,_.jsx)(Ig,{}),(0,_.jsx)(w_,{}),he&&_e.data&&(0,_.jsx)(g0,{status:_e.data,onStage:e=>de(()=>z.stage(n,e)).then(be),onUnstage:e=>de(()=>z.unstage(n,e)).then(be),onCommit:e=>de(()=>z.commit(n,e)).then(e=>(Ka(c,[`refs`,`index`]),e))}),ye&&(0,_.jsxs)(`div`,{className:`flash flash-danger`,role:`alert`,children:[(0,_.jsx)(`strong`,{children:`git did not do that`}),(0,_.jsx)(`span`,{children:ye})]}),at&&A.data&&(0,_.jsxs)(`div`,{className:`stats-bar`,children:[(0,_.jsxs)(`span`,{children:[(0,_.jsx)(fi,{size:16,className:`range-icon`}),` `,(0,_.jsx)(`strong`,{children:A.data.total.toLocaleString(`en-US`)}),` `,A.data.total===1?`commit`:`commits`]}),(0,_.jsxs)(`span`,{children:[(0,_.jsx)(Jr,{size:16,className:`range-icon`}),` `,(0,_.jsx)(`strong`,{children:at.files.toLocaleString(`en-US`)}),` `,at.files===1?`file`:`files`,` changed`]}),(0,_.jsxs)(`span`,{children:[(0,_.jsx)(ea,{size:16,className:`range-icon`}),` `,(0,_.jsxs)(`strong`,{children:[A.data.contributors.toLocaleString(`en-US`),A.data.truncated?`+`:``]}),` `,A.data.contributors===1?`contributor`:`contributors`]})]}),A.data&&(0,_.jsx)(v_,{list:A.data,range:E?.range,hrefFor:E?.head.kind===`rev`?Me:void 0}),E?.range&&(0,_.jsxs)(`div`,{className:`flash flash-attention range-flash`,role:`status`,children:[(0,_.jsxs)(`span`,{children:[it?.length===1?(0,_.jsxs)(_.Fragment,{children:[`Showing only the changes of commit `,(0,_.jsx)(`code`,{children:E.range.to.slice(0,7)}),` `,(0,_.jsx)(`em`,{children:it[0]?.subject}),`.`]}):(0,_.jsxs)(_.Fragment,{children:[`Showing only the changes of `,it?`${it.length} commits`:`the commits`,`, `,(0,_.jsx)(`code`,{children:E.range.from.slice(0,7)}),` to`,` `,(0,_.jsx)(`code`,{children:E.range.to.slice(0,7)}),`.`]}),` `,`Conversations, viewed marks and editing belong to the whole comparison and are hidden here.`]}),(0,_.jsx)(`a`,{href:Me(void 0),onClick:e=>{e.metaKey||e.ctrlKey||e.shiftKey||e.button!==0||(e.preventDefault(),s_(Me(void 0)))},children:`Show all changes`})]})]}),at&&D&&E&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`toolbar`,children:[(0,_.jsx)(`button`,{type:`button`,className:`icon-button tree-toggle`,"aria-pressed":qe,"aria-label":qe?`Hide file tree`:`Show file tree`,title:qe?`Hide file tree`:`Show file tree`,onClick:Ye,children:qe?(0,_.jsx)(ba,{size:16}):(0,_.jsx)(_a,{size:16})}),(0,_.jsxs)(`details`,{className:`toc`,onToggle:e=>Ie(e.currentTarget.open),children:[(0,_.jsxs)(`summary`,{"aria-live":`polite`,children:[(0,_.jsx)(Jr,{size:16,className:`range-icon`}),(0,_.jsxs)(`span`,{children:[`Showing `,(0,_.jsx)(`strong`,{className:`toc-link`,children:F0(at.files,`changed file`)}),` with`,` `,(0,_.jsx)(`strong`,{children:F0(at.additions,`addition`)}),` and`,` `,(0,_.jsx)(`strong`,{children:F0(at.deletions,`deletion`)}),`.`]})]}),Fe&&(0,_.jsx)(j_,{files:D.files})]}),ie&&ie.length>0&&(0,_.jsxs)(`span`,{className:`conversation-count`,children:[F0(ie.length,`conversation`),le>0?`, ${le} unresolved`:`, all resolved`]}),!P&&at.files>0&&(0,_.jsxs)(`span`,{className:`viewed-count`,title:`Files you have marked as viewed`,children:[(0,_.jsx)(`progress`,{max:at.files,value:I.size,"aria-hidden":`true`}),I.size,` / `,at.files,` viewed`]}),(0,_.jsxs)(`label`,{className:`checkbox`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>Pe(e.target.checked)}),`Hide whitespace`]}),(0,_.jsx)(G0,{route:e,pull:d.data}),(0,_.jsx)(U0,{view:a,onChange:Ne})]}),at.files===0?(0,_.jsxs)(`div`,{className:`blankslate`,children:[(0,_.jsx)(`h2`,{className:`blankslate-title`,children:`There isn’t anything to compare.`}),(0,_.jsx)(`div`,{className:`blankslate-body`,children:(0,_.jsx)(`p`,{children:`The two sides are identical. Pick different revisions or make a change.`})})]}):(0,_.jsxs)(`div`,{className:`diff-layout${qe?` with-tree`:``}`,children:[qe&&(0,_.jsx)(y0,{files:D.files,viewed:I,threadCounts:se,activeAnchor:Oe?.anchor}),(0,_.jsx)(`div`,{className:`file-cards`,children:D.files.map(e=>(0,_.jsx)(h0,{repoId:n,comparison:E,file:e,view:a,target:Oe?.anchor===e.anchor?Oe:void 0,scrollToTarget:De,threads:oe.get(e.path)??P0,scope:N,viewed:I.has(e.path),onViewed:P?void 0:me,readOnly:P,staging:Ce(e),onStage:he?R:void 0,onSelectLine:ke,isSettling:ee,listedAt:E.diffTo===`:worktree`&&!e.newOid&&En(e.path)!==void 0?rt:void 0},e.path))})]}),ce.length>0&&(0,_.jsxs)(`section`,{className:`detached-threads`,"aria-label":`Conversations on files no longer in this comparison`,children:[(0,_.jsx)(`h2`,{className:`detached-title`,children:`Conversations on files that are no longer part of this comparison`}),ce.map(e=>(0,_.jsx)(W_,{repoId:n,thread:e,actions:ae,showPath:!0},e.id))]})]}),!nt&&(o===void 0||d.data)&&(b.isPending||S.isPending)&&(0,_.jsx)(`p`,{className:`loading`,children:`Loading…`})]}),Ge&&(0,_.jsx)(b0,{repoId:n,spec:r,onClose:()=>Ke(!1),onOpen:e=>{Ke(!1),s_(Qg(n,e,a)),window.scrollTo(0,0)}}),Ue&&(0,_.jsx)(R1,{onClose:()=>We(!1)}),(0,_.jsx)(Bg,{repoId:n,rev:E?.diffTo,searchOpen:ze,onSearchClose:()=>Be(!1)}),Ve&&d.data&&(0,_.jsx)(D0,{repoId:n,pull:d.data,onClose:()=>He(!1)}),Le&&N&&(0,_.jsx)(Rg,{repoId:n,scope:N,onClose:()=>Re(!1)})]})})}function Z0({input:e}){let t=et({queryKey:[`link`,e],queryFn:()=>z.resolveLink(e),retry:!1,refetchOnWindowFocus:!1}),n=tt({mutationFn:e=>z.cloneForLink(e),onSuccess:()=>t.refetch()}),r=t.data;return(0,f.useEffect)(()=>{r?.status===`ready`&&(d_(r.notices),s_(r.path,{replace:!0}))},[r]),t.isError?(0,_.jsx)(`main`,{className:`page`,children:(0,_.jsx)(`div`,{className:`page-narrow`,children:(0,_.jsxs)(`div`,{className:`flash flash-danger`,role:`alert`,children:[(0,_.jsx)(`strong`,{children:`Cannot open this link`}),(0,_.jsx)(`span`,{children:t.error.message})]})})}):r?.status===`needs-clone`?(0,_.jsx)(`main`,{className:`page`,children:(0,_.jsxs)(`div`,{className:`dialog`,role:`dialog`,"aria-labelledby":`clone-title`,children:[(0,_.jsx)(`h1`,{id:`clone-title`,className:`dialog-title`,children:`Clone this repository?`}),(0,_.jsx)(`p`,{children:`This link points to a repository that is not on this machine yet.`}),(0,_.jsxs)(`dl`,{className:`dialog-facts`,children:[(0,_.jsx)(`dt`,{children:`Repository`}),(0,_.jsx)(`dd`,{children:(0,_.jsx)(`code`,{children:r.repoUrl})}),(0,_.jsx)(`dt`,{children:`Will be cloned to`}),(0,_.jsx)(`dd`,{children:(0,_.jsx)(`code`,{children:r.destination})})]}),(0,_.jsx)(`p`,{className:`dialog-note`,children:`Only clone repositories you expect. Nothing in it is run: agentic-diff reads the files and shows the comparison.`}),n.isError&&(0,_.jsx)(`div`,{className:`flash flash-danger`,role:`alert`,children:(0,_.jsx)(`span`,{children:n.error.message})}),(0,_.jsxs)(`div`,{className:`dialog-actions`,children:[(0,_.jsx)(`button`,{type:`button`,className:`button button-primary`,disabled:n.isPending,onClick:()=>n.mutate(r.repoUrl),children:n.isPending?`Cloning…`:`Clone and open`}),(0,_.jsx)(`button`,{type:`button`,className:`button`,disabled:n.isPending,onClick:()=>s_(`/`,{replace:!0}),children:`Cancel`})]}),n.isPending&&(0,_.jsx)(`p`,{className:`dialog-note`,children:`Large repositories can take a few minutes.`})]})}):(0,_.jsx)(`main`,{className:`page`,children:(0,_.jsx)(`p`,{className:`loading`,children:`Opening the link…`})})}function Q0({title:e,children:t}){return(0,_.jsx)(`main`,{className:`page`,children:(0,_.jsxs)(`div`,{className:`blankslate`,children:[(0,_.jsx)(`h1`,{className:`blankslate-title`,children:e}),(0,_.jsx)(`div`,{className:`blankslate-body`,children:t})]})})}var $0=()=>(0,_.jsxs)(`p`,{children:[`Run `,(0,_.jsx)(`code`,{children:`agentic-diff`}),` in a git repository to open a comparison.`]});function ev(){let e=o_(),t=Xg(e.pathname,e.search,Jg()),n=et({queryKey:[`session`],queryFn:async()=>{let e=l_();if(e)try{return await z.signIn(e)}catch{}return z.session()},staleTime:1/0});return n.isPending?null:n.isError?(0,_.jsx)(Q0,{title:`Cannot reach agentic-diff`,children:`The local server did not answer. Start it again from the terminal.`}):n.data.authenticated?t.name===`open`?(0,_.jsx)(Z0,{input:t.input}):t.name===`compare`?(0,_.jsx)(X0,{route:t,hash:e.hash}):t.name===`home`?(0,_.jsx)(Q0,{title:`agentic-diff`,children:(0,_.jsx)($0,{})}):(0,_.jsx)(Q0,{title:`Page not found`,children:`This address does not match any agentic-diff page.`}):(0,_.jsxs)(Q0,{title:`Not signed in`,children:[(0,_.jsx)(`p`,{children:`This browser has no session with your local agentic-diff server.`}),t.name===`open`?(0,_.jsxs)(`p`,{children:[`To open this link, run `,(0,_.jsx)(`code`,{children:Ft(t.input)})]}):(0,_.jsx)($0,{})]})}var tv=new Ke({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:(e,t)=>!(t instanceof ct&&t.status<500)&&e<2}}});(0,st.createRoot)(document.getElementById(`root`)).render((0,_.jsx)(f.StrictMode,{children:(0,_.jsx)(b,{client:tv,children:(0,_.jsx)(ev,{})})}));export{D1 as a,X_ as c,It as d,ct as f,l as h,x1 as i,b_ as l,d as m,w1 as n,s1 as o,g as p,v1 as r,Z_ as s,r0 as t,Cn as u};
|
package/dist/web/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<meta name="color-scheme" content="dark" />
|
|
7
7
|
<title>agentic-diff</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-D8b82WVL.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-DPhBN0Cd.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|