@knpkv/codecommit-web 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/index-DQUoxciG.js +90 -0
- package/dist/client/assets/index-NJaNHeOS.css +1 -0
- package/dist/client/assets/pr-review-workspace-C0TVEp1y.js +22 -0
- package/dist/client/index.html +2 -2
- package/dist/server/Api.d.ts +285 -137
- package/dist/server/Api.d.ts.map +1 -1
- package/dist/server/Api.js +29 -20
- package/dist/server/Api.js.map +1 -1
- package/dist/server/handlers/prs-live.d.ts +58 -2
- package/dist/server/handlers/prs-live.d.ts.map +1 -1
- package/dist/server/handlers/prs-live.js +27 -8
- package/dist/server/handlers/prs-live.js.map +1 -1
- package/dist/server/review/PullRequestReview.d.ts +88 -5
- package/dist/server/review/PullRequestReview.d.ts.map +1 -1
- package/dist/server/review/PullRequestReview.js +31 -14
- package/dist/server/review/PullRequestReview.js.map +1 -1
- package/package.json +7 -5
- package/dist/client/assets/index-DJ8wO4ny.js +0 -90
- package/dist/client/assets/index-KjRfV-r_.css +0 -1
- package/dist/client/assets/pr-review-workspace-DPsfemKB.js +0 -22
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,M as f,N as p,O as m,P as h,Q as g,R as _,T as v,U as y,V as b,W as x,X as S,Y as ee,Z as te,_ as C,a as ne,b as re,c as ie,d as w,f as ae,g as oe,h as T,i as se,j as ce,k as le,l as E,m as ue,n as de,o as D,p as fe,q as pe,r as O,s as me,t as he,u as ge,v as _e,w as ve,x as k,y as ye,z as A}from"./index-DJ8wO4ny.js";var be=l(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),xe=l(`file-pen-line`,[[`path`,{d:`M14.364 13.634a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506l4.013-4.009a1 1 0 0 0-3.004-3.004z`,key:`ukzhwg`}],[`path`,{d:`M14.487 7.858A1 1 0 0 1 14 7V2`,key:`1klhew`}],[`path`,{d:`M20 19.645V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l2.516 2.516`,key:`rxaxab`}],[`path`,{d:`M8 18h1`,key:`13wk12`}]]),Se=l(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),j=l(`file-search`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`11.5`,cy:`14.5`,r:`2.5`,key:`1bq0ko`}],[`path`,{d:`M13.3 16.3 15 18`,key:`2quom7`}]]),Ce=l(`file-symlink`,[[`path`,{d:`M4 11V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7`,key:`huwfnr`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m10 18 3-3-3-3`,key:`18f6ys`}]]),we=l(`file-x-corner`,[[`path`,{d:`M11 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5`,key:`1jo35a`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m15 17 5 5`,key:`36xl1x`}],[`path`,{d:`m20 17-5 5`,key:`vdz27y`}]]),Te=l(`message-square-more`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 11h.01`,key:`z322tv`}],[`path`,{d:`M16 11h.01`,key:`xkw8gn`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}]]),Ee=l(`test-tube-diagonal`,[[`path`,{d:`M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3`,key:`1ub6xw`}],[`path`,{d:`m16 2 6 6`,key:`1gw87d`}],[`path`,{d:`M12 16H4`,key:`1cjfip`}]]),M=g(te(),1),N=ee(),P=/(?=^diff --git)/gm,De=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Oe=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,ke=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,F=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i;Object.freeze({fromStart:0,fromEnd:0});function I(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}var L=new TextEncoder,Ae=new TextDecoder(`utf-8`,{ignoreBOM:!0}),je=/[\uD800-\uDFFF]/,R=1024,z=new Uint8Array(R);function B(){z.length!==R&&(z=new Uint8Array(R))}function V(e){if(e.length===0)return e;if(je.test(e))return JSON.parse(JSON.stringify(e));let t=e.length*3;z.length<t&&(z=new Uint8Array(t));let{written:n}=L.encodeInto(e,z);return Ae.decode(z.subarray(0,n))}function Me(e,t){return e-(t===0?0:1)}function Ne(e,t){return Me(e,t)+t}var H=4096,Pe=.5;function U(e){for(let t of e.hunks){for(let n=0;n<t.hunkContent.length;n++){let r=t.hunkContent[n];if(r.type!==`change`)continue;let i=Ie(e,r);i!=null&&(t.hunkContent.splice(n,1,...i),n+=i.length-1)}Fe(t,e)}}function Fe(e,t){let{hunkContent:n}=e;for(let e=1;e<n.length;e++){let r=n[e],i=n[e-1];if(r.type!==`change`||r.additions>0&&r.deletions>0||i.type!==`context`)continue;let a=r.additions>0,o=a?t.additionLines:t.deletionLines,s=a?r.additionLineIndex:r.deletionLineIndex,c=a?r.additions:r.deletions,l=o[s]??``;if(l.trim()!==``)continue;let u=!0;for(let e=1;e<c;e++)if(o[s+e]!==l){u=!1;break}if(!u)continue;let d=0;for(;d<i.lines&&t.additionLines[i.additionLineIndex+i.lines-1-d]===l;)d++;if(d===0||e===1&&d===i.lines)continue;r.additionLineIndex-=d,r.deletionLineIndex-=d;let f=r.additionLineIndex+r.additions,p=r.deletionLineIndex+r.deletions,m=n[e+1];m?.type===`context`?(m.lines+=d,m.additionLineIndex=f,m.deletionLineIndex=p):n.splice(e+1,0,{type:`context`,lines:d,additionLineIndex:f,deletionLineIndex:p}),i.lines-=d,i.lines===0&&(n.splice(e-1,1),e--)}}function Ie(e,t){let{deletions:n,additions:r,deletionLineIndex:i,additionLineIndex:a}=t,o=Math.min(n,r),s=Math.abs(r-n);if(o===0||s===0||o*(s+1)>H)return null;let c=[];for(let t=0;t<n;t++)c.push(Re(e.deletionLines[i+t]??``));let l=[];for(let t=0;t<r;t++)l.push(Re(e.additionLines[a+t]??``));let u=r>n,d=0,f=-1;for(let e=0;e<=s;e++){let t=0;for(let n=0;n<o;n++)t+=ze(c[n+(u?0:e)],l[n+(u?e:0)]);e===0?f=t+o*Pe:t>f&&(f=t,d=e)}if(d===0)return null;let p=[],m=(e,t,n,r)=>{(e>0||t>0)&&p.push({type:`change`,deletions:e,additions:t,deletionLineIndex:n,additionLineIndex:r})};return u?(m(0,d,i,a),m(o,o,i,a+d),m(0,r-o-d,i+o,a+d+o)):(m(d,0,i,a),m(o,o,i+d,a),m(n-o-d,0,i+d+o,a+o)),p}var Le=/\s+/g;function Re(e){return e.replace(Le,``)}function ze(e,t){if(e===t)return 1;let n=Math.max(e.length,t.length),r=Math.min(e.length,t.length);if(r===0)return 0;let i=0;for(;i<r&&e[i]===t[i];)i++;let a=0;for(;a<r-i&&e[e.length-1-a]===t[t.length-1-a];)a++;return(i+a)/n}function Be(e,t){try{return Ve(e,t)}finally{B()}}function Ve(e,{cacheKey:t,isGitDiff:n=P.test(e),oldFile:r,newFile:i,throwOnError:a=!1}={}){let o=0,s=Ke(e,`@@ `),c,l=r==null||i==null,u=0,d=0;for(let e of s){let s=Ue(e),f=s[0];if(f==null){if(a)throw Error(`parsePatchContent: invalid hunk`);console.error(`parsePatchContent: invalid hunk`,e);continue}let p=We(f),m=0,h=0;if(p==null||c==null){if(c!=null){if(a)throw Error(`parsePatchContent: Invalid hunk`);console.error(`parsePatchContent: Invalid hunk`,e);continue}c={name:``,type:`change`,hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:l,additionLines:!l&&r!=null&&i!=null?He(i.contents):[],deletionLines:!l&&r!=null&&i!=null?He(r.contents):[],cacheKey:Je(t)},c.additionLines.length===1&&i?.contents===``&&(c.additionLines.length=0),c.deletionLines.length===1&&r?.contents===``&&(c.deletionLines.length=0);for(let e of s){if(e.startsWith(`diff --git`)){let t=e.trim().match(ke),n=t?.[1]??t?.[2],r=t?.[3]??t?.[4];if(n==null||r==null){if(a)throw Error(`parsePatchContent: invalid git diff header`);console.error(`parsePatchContent: invalid git diff header`,e);continue}c.name=V(r.trim()),n!==r&&(c.prevName=V(n.trim()));continue}let t=e.startsWith(`---`)||e.startsWith(`+++`)?e.match(n?Oe:De):null;if(t!=null){let[,e,n]=t;if(e===`---`&&n!==`/dev/null`){let e=V(n.trim());c.prevName=e,c.name=e}else e===`+++`&&n!==`/dev/null`&&(c.name=V(n.trim()))}else if(n){if(e.startsWith(`new mode `)&&(c.mode=V(e.slice(8).trim())),e.startsWith(`old mode `)&&(c.prevMode=V(e.slice(8).trim())),e.startsWith(`new file mode`)&&(c.type=`new`,c.mode=V(e.slice(13).trim())),e.startsWith(`deleted file mode`)&&(c.type=`deleted`,c.mode=V(e.slice(17).trim())),e.startsWith(`similarity index`)&&(e.startsWith(`similarity index 100%`)?c.type=`rename-pure`:c.type=`rename-changed`),e.startsWith(`index `)){let[,t,n,r]=e.trim().match(F)??[];t!=null&&(c.prevObjectId=V(t)),n!=null&&(c.newObjectId=V(n)),r!=null&&(c.mode=V(r))}e.startsWith(`rename from `)&&(c.prevName=V(e.slice(12).trim())),e.startsWith(`rename to `)&&(c.name=V(e.slice(10).trim()))}}continue}let g,_;for(;s.length>0&&(s[s.length-1]===`
|
|
2
|
-
`||s[s.length-1]===`\r`||s[s.length-1]===`\r
|
|
3
|
-
`||s[s.length-1]===``);)s.pop();let{additionStart:v,deletionStart:y}=p;u=l?u:y-1,d=l?d:v-1;let b={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:p.additionCount,additionStart:v,additionLines:m,deletionCount:p.deletionCount,deletionStart:y,deletionLines:h,deletionLineIndex:u,additionLineIndex:d,hunkContent:[],hunkContext:Je(p.hunkContext),hunkSpecs:V(f),noEOFCRAdditions:!1,noEOFCRDeletions:!1},x=0,S=0;for(let e=1;e<s.length;e++){let t=s[e];if(x>=b.additionCount&&S>=b.deletionCount&&!t.startsWith(`\\`)){if(a&&W(t)&&!G(t))throw Error(`parsePatchContent: hunk has more lines than expected`);break}let n=t[0];if(n!==`+`&&n!==`-`&&n!==` `&&n!==`\\`){if(a)throw Error(`parsePatchContent: invalid hunk line`);console.error(`parseLineType: Invalid firstChar: "${n}", full line: "${t}"`),console.error(`processFile: invalid rawLine:`,t);continue}let r=Ye(n);if(r===`addition`){if(a&&x>=b.additionCount)throw Error(`parsePatchContent: hunk has too many addition lines`);let e=Xe(t);(g==null||g.type!==`change`)&&(g=Ze(`change`,u,d),b.hunkContent.push(g)),d++,x++,l&&c.additionLines.push(e),g.additions++,m++,_=`addition`}else if(r===`deletion`){if(a&&S>=b.deletionCount)throw Error(`parsePatchContent: hunk has too many deletion lines`);let e=Xe(t);(g==null||g.type!==`change`)&&(g=Ze(`change`,u,d),b.hunkContent.push(g)),u++,S++,l&&c.deletionLines.push(e),g.deletions++,h++,_=`deletion`}else if(r===`context`){if(a&&(S>=b.deletionCount||x>=b.additionCount))throw Error(`parsePatchContent: hunk has too many context lines`);let e=Xe(t);(g==null||g.type!==`context`)&&(g=Ze(`context`,u,d),b.hunkContent.push(g)),d++,u++,x++,S++,l&&(c.deletionLines.push(e),c.additionLines.push(e)),g.lines++,_=`context`}else if(r===`metadata`&&g!=null){if(g.type===`context`?(b.noEOFCRAdditions=!0,b.noEOFCRDeletions=!0):_===`deletion`?b.noEOFCRDeletions=!0:_===`addition`&&(b.noEOFCRAdditions=!0),l&&(_===`addition`||_===`context`)){let e=c.additionLines.length-1;e>=0&&(c.additionLines[e]=I(c.additionLines[e]))}if(l&&(_===`deletion`||_===`context`)){let e=c.deletionLines.length-1;e>=0&&(c.deletionLines[e]=I(c.deletionLines[e]))}}}if(a&&(x!==b.additionCount||S!==b.deletionCount))throw Error(`parsePatchContent: hunk line count mismatch`);b.additionLines=m,b.deletionLines=h,b.collapsedBefore=Math.max(Me(b.additionStart,b.additionCount)-o,0),c.hunks.push(b),o=Ne(b.additionStart,b.additionCount);for(let e of b.hunkContent)e.type===`context`?(b.splitLineCount+=e.lines,b.unifiedLineCount+=e.lines):(b.splitLineCount+=Math.max(e.additions,e.deletions),b.unifiedLineCount+=e.deletions+e.additions);b.splitLineStart=c.splitLineCount+b.collapsedBefore,b.unifiedLineStart=c.unifiedLineCount+b.collapsedBefore,c.splitLineCount+=b.collapsedBefore+b.splitLineCount,c.unifiedLineCount+=b.collapsedBefore+b.unifiedLineCount}if(c!=null){if(a&&l&&!n&&c.hunks.length===0)throw Error(`parsePatchContent: unified file has no hunks`);if(c.hunks.length>0&&!l&&c.additionLines.length>0&&c.deletionLines.length>0){let e=c.hunks[c.hunks.length-1],t=Ne(e.additionStart,e.additionCount),n=c.additionLines.length,r=Math.max(n-t,0);c.splitLineCount+=r,c.unifiedLineCount+=r}return n||(c.prevName!=null&&c.name!==c.prevName?c.hunks.length>0?c.type=`rename-changed`:c.type=`rename-pure`:(r==null||r.contents===``)&&i!=null&&i.contents!==``?c.type=`new`:r!=null&&r.contents!==``&&(i==null||i.contents===``)&&(c.type=`deleted`)),c.type!==`rename-pure`&&c.type!==`rename-changed`&&(c.prevName=void 0),U(c),c}}function He(e){let t=Ue(e);for(let e=0;e<t.length;e++)t[e]=V(t[e]);return t}function Ue(e){if(e.length===0)return[``];let t=[],n=0;for(;;){let r=e.indexOf(`
|
|
4
|
-
`,n);if(r===-1)break;t.push(e.slice(n,r+1)),n=r+1}return n<e.length&&t.push(e.slice(n)),t}function W(e){let t=e[0];return t===`+`||t===`-`||t===` `}function G(e){if(!e.startsWith(`--`))return!1;for(let t=2;t<e.length;t++){let n=e[t];if(n!==` `&&n!==` `&&n!==`
|
|
5
|
-
`&&n!==`\r`)return!1}return!0}function We(e){if(!e.startsWith(`@@ -`))return;let t=4,n=K(e,t);if(n==null)return;let r=n.value;t=n.endIndex;let i=1;if(e[t]===`,`){let n=K(e,t+1);if(n==null)return;i=n.value,t=n.endIndex}if(e[t]!==` `||e[t+1]!==`+`)return;t+=2;let a=K(e,t);if(a==null)return;let o=a.value;t=a.endIndex;let s=1;if(e[t]===`,`){let n=K(e,t+1);if(n==null)return;s=n.value,t=n.endIndex}if(e[t]!==` `||e[t+1]!==`@`||e[t+2]!==`@`)return;let c,l=t+3;return e[l]===` `&&(c=Ge(e.slice(l+1))),{additionCount:s,additionStart:o,deletionCount:i,deletionStart:r,hunkContext:c}}function K(e,t){let n=t,r=0;for(;n<e.length;n++){let t=e.charCodeAt(n)-48;if(t<0||t>9)break;r=r*10+t}if(n!==t)return{value:r,endIndex:n}}function Ge(e){return e.endsWith(`\r
|
|
6
|
-
`)?e.slice(0,-2):e.endsWith(`
|
|
7
|
-
`)?e.slice(0,-1):e}function Ke(e,t){if(e.length===0)return[``];let n=`\n${t}`,r=e.startsWith(t)?0:qe(e,n,0);if(r===-1)return[e];let i=[];r>0&&i.push(e.slice(0,r));let a=r;for(;;){let t=qe(e,n,a+1);if(t===-1)break;i.push(e.slice(a,t)),a=t}return i.push(e.slice(a)),i}function qe(e,t,n){let r=e.indexOf(t,n);return r===-1?-1:r+1}function Je(e){return e==null?e:V(e)}function Ye(e){return e===` `?`context`:e===`\\`?`metadata`:e===`+`?`addition`:`deletion`}function Xe(e){let t=e.slice(1);return V(t===``?`
|
|
8
|
-
`:t)}function Ze(e,t,n){return e===`change`?{type:`change`,additions:0,deletions:0,additionLineIndex:n,deletionLineIndex:t}:{type:`context`,lines:0,additionLineIndex:n,deletionLineIndex:t}}var q=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends q{};function Qe(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function $e(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function et(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function tt(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function nt(e,t){return et(e,t,``)}function rt(e,t){return tt(e,t,``)}function it(e,t){return t.slice(0,at(e,t))}function at(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function ot(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function st(e,t){if(t)return ct(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function J(e,t){if(t)return ct(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function ct(e,t){if(!t)return[J(e),st(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=ot(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var lt=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,ut=RegExp(`[${lt}]+|\\s+|[^${lt}]`,`ug`);new class extends q{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=ot(e,r)}else n=e.match(ut)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&dt(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&dt(n,i,r,null,t.intlSegmenter),e}};function dt(e,t,n,r,i){if(t&&n){let[a,o]=ct(t.value,i),[s,c]=ct(n.value,i);if(e){let r=Qe(a,s);e.value=tt(e.value,s,r),t.value=nt(t.value,r),n.value=nt(n.value,r)}if(r){let e=$e(o,c);r.value=et(r.value,c,e),t.value=rt(t.value,e),n.value=rt(n.value,e)}}else if(n){if(e){let e=J(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=J(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=J(r.value,i),[a,o]=ct(t.value,i),s=Qe(n,a);t.value=nt(t.value,s);let c=$e(nt(n,s),o);t.value=rt(t.value,c),r.value=et(r.value,n,c),e.value=tt(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=J(r.value,i),n=it(st(t.value,i),e);t.value=rt(t.value,n)}else if(e){let n=it(st(e.value,i),J(t.value,i));t.value=nt(t.value,n)}}new class extends q{tokenize(e){let t=RegExp(`(\\r?\\n)|[${lt}]+|[^\\S\\n\\r]+|[^${lt}]`,`ug`);return e.match(t)||[]}};var ft=new class extends q{constructor(){super(...arguments),this.tokenize=mt}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
9
|
-
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
10
|
-
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
11
|
-
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
12
|
-
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function pt(e,t,n){return ft.diff(e,t,n)}function mt(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
13
|
-
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function ht(e){return e==`.`||e==`!`||e==`?`}new class extends q{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(ht(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends q{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends q{constructor(){super(...arguments),this.tokenize=mt}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(gt(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function gt(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a;for(a=0;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=gt(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=gt(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends q{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};function _t(e){for(let t=0;t<e.length;t++)if(e[t]<` `||e[t]>`~`||e[t]===`"`||e[t]===`\\`)return!0;return!1}function Y(e){if(!_t(e))return e;let t=`"`,n=new TextEncoder().encode(e),r=0;for(;r<n.length;){let e=n[r];t+=e===7?`\\a`:e===8?`\\b`:e===9?`\\t`:e===10?`\\n`:e===11?`\\v`:e===12?`\\f`:e===13?`\\r`:e===34?`\\"`:e===92?`\\\\`:e>=32&&e<=126?String.fromCharCode(e):`\\`+e.toString(8).padStart(3,`0`),r++}return t+=`"`,t}var vt={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function yt(e,t,n,r,i,a,o){let s;s=o?typeof o==`function`?{callback:o}:o:{},s.context===void 0&&(s.context=4);let c=s.context;if(s.newlineIsToken)throw Error(`newlineIsToken may not be used with patch-generation functions, only with diffing functions`);if(s.callback){let{callback:e}=s;pt(n,r,Object.assign(Object.assign({},s),{callback:t=>{let n=l(t);e(n)}}))}else return l(pt(n,r,s));function l(n){if(!n)return;n.push({value:``,lines:[]});function r(e){return e.map(function(e){return` `+e})}let o=[],s=0,l=0,u=[],d=1,f=1;for(let e=0;e<n.length;e++){let t=n[e],i=t.lines||St(t.value);if(t.lines=i,t.added||t.removed){if(!s){let t=n[e-1];s=d,l=f,t&&(u=c>0?r(t.lines.slice(-c)):[],s-=u.length,l-=u.length)}for(let e of i)u.push((t.added?`+`:`-`)+e);t.added?f+=i.length:d+=i.length}else{if(s){if(i.length<=c*2&&e<n.length-2)for(let e of r(i))u.push(e);else{let e=Math.min(i.length,c);for(let t of r(i.slice(0,e)))u.push(t);let t={oldStart:s,oldLines:d-s+e,newStart:l,newLines:f-l+e,lines:u};o.push(t),s=0,l=0,u=[]}}d+=i.length,f+=i.length}}for(let e of o)for(let t=0;t<e.lines.length;t++)e.lines[t].endsWith(`
|
|
14
|
-
`)?e.lines[t]=e.lines[t].slice(0,-1):(e.lines.splice(t+1,0,`\`),t++);return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:a,hunks:o}}}function bt(e,t){if(t||=vt,Array.isArray(e)){if(e.length>1&&!t.includeFileHeaders&&!e.every(e=>e.isGit))throw Error(`Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)`);return e.map(e=>bt(e,t)).join(`
|
|
15
|
-
`)}let n=[];if(e.isGit){if(t=vt,!e.oldFileName)throw Error(`oldFileName must be specified for Git patches`);if(!e.newFileName)throw Error(`newFileName must be specified for Git patches`);let r=e.oldFileName,i=e.newFileName;e.isCreate&&r===`/dev/null`?r=i.replace(/^b\//,`a/`):e.isDelete&&i===`/dev/null`&&(i=r.replace(/^a\//,`b/`)),n.push(`diff --git `+Y(r)+` `+Y(i)),e.isDelete&&n.push(`deleted file mode `+(e.oldMode??`100644`)),e.isCreate&&n.push(`new file mode `+(e.newMode??`100644`)),e.oldMode&&e.newMode&&!e.isDelete&&!e.isCreate&&(n.push(`old mode `+e.oldMode),n.push(`new mode `+e.newMode)),e.isRename&&(n.push(`rename from `+Y((e.oldFileName??``).replace(/^a\//,``))),n.push(`rename to `+Y((e.newFileName??``).replace(/^b\//,``)))),e.isCopy&&(n.push(`copy from `+Y((e.oldFileName??``).replace(/^a\//,``))),n.push(`copy to `+Y((e.newFileName??``).replace(/^b\//,``))))}else t.includeIndex&&e.oldFileName==e.newFileName&&e.oldFileName!==void 0&&n.push(`Index: `+e.oldFileName),t.includeUnderline&&n.push(`===================================================================`);let r=e.hunks.length>0;t.includeFileHeaders&&e.oldFileName!==void 0&&e.newFileName!==void 0&&(!e.isGit||r)&&(n.push(`--- `+Y(e.oldFileName)+(e.oldHeader?` `+e.oldHeader:``)),n.push(`+++ `+Y(e.newFileName)+(e.newHeader?` `+e.newHeader:``)));for(let t=0;t<e.hunks.length;t++){let r=e.hunks[t],i=r.oldLines===0?r.oldStart-1:r.oldStart,a=r.newLines===0?r.newStart-1:r.newStart;n.push(`@@ -`+i+`,`+r.oldLines+` +`+a+`,`+r.newLines+` @@`);for(let e of r.lines)n.push(e)}return n.join(`
|
|
16
|
-
`)+`
|
|
17
|
-
`}function xt(e,t,n,r,i,a,o){if(typeof o==`function`&&(o={callback:o}),o?.callback){let{callback:s}=o;yt(e,t,n,r,i,a,Object.assign(Object.assign({},o),{callback:e=>{s(e?bt(e,o.headerOptions):void 0)}}))}else{let s=yt(e,t,n,r,i,a,o);return s?bt(s,o?.headerOptions):void 0}}function St(e){let t=e.endsWith(`
|
|
18
|
-
`),n=e.split(`
|
|
19
|
-
`).map(e=>e+`
|
|
20
|
-
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}var Ct=`/dev/null`;function wt(e,t,n,r=!1){if(e===null&&t===null)throw Error(`parseDiffFromFile: You must pass oldFile, newFile, or both`);let i=e??Tt(),a=t??Tt(),o=Be(xt(i.name,a.name,i.contents,a.contents,i.header,a.header,n),{cacheKey:(()=>{let n=e?.cacheKey??e?.name,r=t?.cacheKey??t?.name;return n!=null&&r!=null?n+`:`+r:n??r})(),oldFile:i,newFile:a,throwOnError:r});if(o==null)throw Error(`parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?`);e===null?(o.type=`new`,o.prevName=void 0):t===null&&(o.type=`deleted`,o.prevName=void 0);let s=t?.lang??(t===null?e?.lang:void 0);return s!=null&&(o.lang=s),o}function Tt(){return{name:Ct,contents:``}}var Et=(e,t)=>{let n=e[t];if(n===void 0)throw Error(`Missing CSS Module class: ${t}`);return n},Dt=(e,t)=>{let n=e.shadowRoot;if(n===null)return null;let r=t.side===`additions`?`data-additions`:`data-deletions`,i=t.side===`additions`?`change-addition`:`change-deletion`,a=t.side===`additions`?`data-line`:`data-alt-line`;return n.querySelector(`[${r}] [data-line="${t.lineNumber}"]`)??n.querySelector(`[data-line="${t.lineNumber}"][data-line-type="${i}"]`)??n.querySelector(`[${a}="${t.lineNumber}"][data-line-type="context"]`)??n.querySelector(`[${a}="${t.lineNumber}"][data-line-type="context-expanded"]`)??n.querySelector(`[${r}] [data-alt-line="${t.lineNumber}"]`)??n.querySelector(`[${r}][data-line="${t.lineNumber}"]`)??n.querySelector(`[${r}][data-alt-line="${t.lineNumber}"]`)},Ot=(e,t)=>{let n=e.closest(`diffs-container`);return n===null?null:Dt(n,t)},kt=(e,t)=>{let n=Ot(e,t);n!==null&&(n.tabIndex=-1,n.focus({preventScroll:!0}))},At=({annotation:e,className:t,returnFocus:n})=>{let r=(0,M.useRef)(null),i=()=>{if(n!==void 0){n();return}r.current!==null&&kt(r.current,e.location)};return(0,M.createElement)(`div`,{ref:r,"aria-label":e.accessibilityLabel,className:t,"data-rly-diff-annotation":e.id,"data-rly-diff-annotation-item":e.location.itemId,"data-rly-diff-annotation-line":e.location.lineNumber,"data-rly-diff-annotation-side":e.location.side,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i())},role:`group`,tabIndex:0},e.render({annotationId:e.id,location:e.location,returnFocus:i}))},jt=e=>{let t=new Set;for(let n of e){if(n.id.trim().length===0||n.accessibilityLabel.trim().length===0)throw Error(`Diff annotation id and accessibility label must not be blank`);if(n.location.itemId.trim().length===0)throw Error(`Diff annotation ${n.id} location item id must not be blank`);if(!Number.isInteger(n.location.lineNumber)||n.location.lineNumber<1)throw Error(`Diff annotation ${n.id} line number must be a positive integer`);if(t.has(n.id))throw Error(`Diff annotation id ${n.id} must be unique`);t.add(n.id)}},X={root:`rly_BoundedDiffCodeView-module__root`,file:`rly_BoundedDiffCodeView-module__file`,noChanges:`rly_BoundedDiffCodeView-module__noChanges`,fileName:`rly_BoundedDiffCodeView-module__fileName`,scroller:`rly_BoundedDiffCodeView-module__scroller`,table:`rly_BoundedDiffCodeView-module__table`,hunk:`rly_BoundedDiffCodeView-module__hunk`,lineNumber:`rly_BoundedDiffCodeView-module__lineNumber`,marker:`rly_BoundedDiffCodeView-module__marker`,code:`rly_BoundedDiffCodeView-module__code`,wrappedCode:`rly_BoundedDiffCodeView-module__wrappedCode`,deletion:`rly_BoundedDiffCodeView-module__deletion`,change:`rly_BoundedDiffCodeView-module__change`,deletionCode:`rly_BoundedDiffCodeView-module__deletionCode`,addition:`rly_BoundedDiffCodeView-module__addition`,additionCode:`rly_BoundedDiffCodeView-module__additionCode`,context:`rly_BoundedDiffCodeView-module__context`,annotationRow:`rly_BoundedDiffCodeView-module__annotationRow`,annotationCell:`rly_BoundedDiffCodeView-module__annotationCell`,annotation:`rly_BoundedDiffCodeView-module__annotation`},Mt=(e,t)=>({lineNumber:e,side:t}),Z=(e,t)=>e[t]?.replace(/\r?\n$/,``)??``,Nt=e=>e.hunkSpecs?.trim()??`@@ -${e.deletionStart},${e.deletionCount} +${e.additionStart},${e.additionCount} @@`,Pt=e=>{if(e.before.contents!==e.after.contents)return wt({...e.before.cacheKey!==void 0&&{cacheKey:e.before.cacheKey},contents:e.before.contents,name:e.before.name},{...e.after.cacheKey!==void 0&&{cacheKey:e.after.cacheKey},contents:e.after.contents,name:e.after.name},void 0,!0)},Ft=(e,t)=>Array.from({length:t.lines},(n,r)=>({addition:{content:Z(e.additionLines,t.additionLineIndex+r),number:t.additionLineIndex+r+1},deletion:{content:Z(e.deletionLines,t.deletionLineIndex+r),number:t.deletionLineIndex+r+1},kind:`context`})),It=(e,t)=>Array.from({length:Math.max(t.deletions,t.additions)},(n,r)=>({...r<t.additions&&{addition:{content:Z(e.additionLines,t.additionLineIndex+r),number:t.additionLineIndex+r+1}},...r<t.deletions&&{deletion:{content:Z(e.deletionLines,t.deletionLineIndex+r),number:t.deletionLineIndex+r+1}},kind:`change`})),Lt=e=>e.hunks.flatMap(t=>[{kind:`hunk`,label:Nt(t)},...t.hunkContent.flatMap(t=>t.type===`context`?Ft(e,t):It(e,t))]),Rt=e=>e.hunks.flatMap(t=>[{kind:`hunk`,label:Nt(t)},...t.hunkContent.flatMap(t=>t.type===`context`?Array.from({length:t.lines},(n,r)=>({additionNumber:t.additionLineIndex+r+1,content:Z(e.additionLines,t.additionLineIndex+r),deletionNumber:t.deletionLineIndex+r+1,kind:`context`})):[...Array.from({length:t.deletions},(n,r)=>({content:Z(e.deletionLines,t.deletionLineIndex+r),deletionNumber:t.deletionLineIndex+r+1,kind:`deletion`})),...Array.from({length:t.additions},(n,r)=>({additionNumber:t.additionLineIndex+r+1,content:Z(e.additionLines,t.additionLineIndex+r),kind:`addition`}))])]),zt=(e,t,n,r,i,a)=>(0,N.jsx)(`code`,{className:i?X.wrappedCode:X.code,"data-rly-diff-item":t,...a===void 0?{}:{"data-rly-diff-line-alternate":a.lineNumber,"data-rly-diff-line-side-alternate":a.side},"data-rly-diff-line":n,"data-rly-diff-line-side":r,tabIndex:-1,children:e.length===0?` `:e}),Bt=(e,t,n,r)=>{let i=`[data-rly-diff-item="${CSS.escape(t)}"]`;(e?.querySelector(`${i}[data-rly-diff-line="${n}"][data-rly-diff-line-side="${r}"]`)??e?.querySelector(`${i}[data-rly-diff-line-alternate="${n}"][data-rly-diff-line-side-alternate="${r}"]`))?.focus({preventScroll:!0})},Vt=(e,t,n,r)=>n===void 0?[]:e.filter(e=>e.location.itemId===t&&e.location.lineNumber===n&&e.location.side===r),Ht=(e,t,n,r)=>[...Vt(e,t,n.deletion?.number,`deletions`).map(e=>(0,N.jsxs)(`tr`,{className:X.annotationRow,children:[(0,N.jsx)(`td`,{className:X.annotationCell,colSpan:2,children:(0,N.jsx)(At,{annotation:e,className:Et(X,`annotation`),returnFocus:()=>Bt(r(),t,e.location.lineNumber,e.location.side)})}),(0,N.jsx)(`td`,{colSpan:2})]},e.id)),...Vt(e,t,n.addition?.number,`additions`).map(e=>(0,N.jsxs)(`tr`,{className:X.annotationRow,children:[(0,N.jsx)(`td`,{colSpan:2}),(0,N.jsx)(`td`,{className:X.annotationCell,colSpan:2,children:(0,N.jsx)(At,{annotation:e,className:Et(X,`annotation`),returnFocus:()=>Bt(r(),t,e.location.lineNumber,e.location.side)})})]},e.id))],Ut=(e,t,n,r,i)=>(0,N.jsx)(`table`,{"aria-label":`Changes in ${e.name}`,className:X.table,children:(0,N.jsx)(`tbody`,{children:Lt(e).map((e,a)=>e.kind===`hunk`?(0,N.jsx)(`tr`,{className:X.hunk,children:(0,N.jsx)(`td`,{colSpan:4,children:e.label})},`${a}:${e.label}`):(0,N.jsxs)(M.Fragment,{children:[(0,N.jsxs)(`tr`,{className:X[e.kind],children:[(0,N.jsx)(`td`,{className:X.lineNumber,children:e.deletion?.number}),(0,N.jsx)(`td`,{className:X.deletionCode,children:e.deletion===void 0?null:zt(e.deletion.content,t,e.deletion.number,`deletions`,i)}),(0,N.jsx)(`td`,{className:X.lineNumber,children:e.addition?.number}),(0,N.jsx)(`td`,{className:X.additionCode,children:e.addition===void 0?null:zt(e.addition.content,t,e.addition.number,`additions`,i)})]}),Ht(n,t,e,r)]},`${a}:${e.deletion?.number??``}:${e.addition?.number??``}`))})}),Wt=(e,t,n,r)=>[...n.deletionNumber===void 0?[]:[Mt(n.deletionNumber,`deletions`)],...n.additionNumber===void 0?[]:[Mt(n.additionNumber,`additions`)]].flatMap(({lineNumber:n,side:i})=>Vt(e,t,n,i).map(e=>(0,N.jsx)(`tr`,{className:X.annotationRow,children:(0,N.jsx)(`td`,{className:X.annotationCell,colSpan:4,children:(0,N.jsx)(At,{annotation:e,className:Et(X,`annotation`),returnFocus:()=>Bt(r(),t,n,i)})})},e.id))),Gt=(e,t,n,r,i)=>(0,N.jsx)(`table`,{"aria-label":`Changes in ${e.name}`,className:X.table,children:(0,N.jsx)(`tbody`,{children:Rt(e).map((e,a)=>e.kind===`hunk`?(0,N.jsx)(`tr`,{className:X.hunk,children:(0,N.jsx)(`td`,{colSpan:4,children:e.label})},`${a}:${e.label}`):(0,N.jsxs)(M.Fragment,{children:[(0,N.jsxs)(`tr`,{className:X[e.kind],children:[(0,N.jsx)(`td`,{className:X.lineNumber,children:e.deletionNumber}),(0,N.jsx)(`td`,{className:X.lineNumber,children:e.additionNumber}),(0,N.jsx)(`td`,{className:X.marker,children:e.kind===`addition`?`+`:e.kind===`deletion`?`−`:` `}),(0,N.jsx)(`td`,{children:zt(e.content,t,e.kind===`deletion`?e.deletionNumber??0:e.additionNumber??0,e.kind===`deletion`?`deletions`:`additions`,i,e.kind===`context`&&e.deletionNumber!==void 0?{lineNumber:e.deletionNumber,side:`deletions`}:void 0)})]}),Wt(n,t,e,r)]},`${a}:${e.deletionNumber??``}:${e.additionNumber??``}`))})}),Kt=({annotations:e=[],className:t,empty:n=`No renderable source changes.`,initialItems:r,mode:i=`split`,wrap:a=!1})=>{jt(e);let o=(0,M.useRef)(null);return r.length===0?(0,N.jsx)(`p`,{className:t,children:n}):(0,N.jsx)(`div`,{ref:o,className:t===void 0?Et(X,`root`):`${Et(X,`root`)} ${t}`,"data-rly-diff-code-view":``,"data-rly-diff-mode":i,children:r.map(t=>{let n=Pt(t);return n===void 0?(0,N.jsx)(`p`,{className:X.noChanges,children:`No textual changes in this file.`},t.id):(0,N.jsxs)(`section`,{className:X.file,children:[r.length>1?(0,N.jsx)(`h3`,{className:X.fileName,children:n.name}):null,(0,N.jsx)(`div`,{className:X.scroller,children:i===`split`?Ut(n,t.id,e,()=>o.current,a):Gt(n,t.id,e,()=>o.current,a)})]},t.id)})})},qt={root:`rly_DiffFileTree-module__root`,header:`rly_DiffFileTree-module__header`,eyebrow:`rly_DiffFileTree-module__eyebrow`,notice:`rly_DiffFileTree-module__notice`,empty:`rly_DiffFileTree-module__empty`,error:`rly_DiffFileTree-module__error`,previousPath:`rly_DiffFileTree-module__previousPath`,count:`rly_DiffFileTree-module__count`,list:`rly_DiffFileTree-module__list`,directory:`rly_DiffFileTree-module__directory`,group:`rly_DiffFileTree-module__group`,directoryButton:`rly_DiffFileTree-module__directoryButton`,chevron:`rly_DiffFileTree-module__chevron`,directoryName:`rly_DiffFileTree-module__directoryName`,directoryCount:`rly_DiffFileTree-module__directoryCount`,file:`rly_DiffFileTree-module__file`,pathBlock:`rly_DiffFileTree-module__pathBlock`,path:`rly_DiffFileTree-module__path`,statusIcons:`rly_DiffFileTree-module__statusIcons`,statusIcon:`rly_DiffFileTree-module__statusIcon`,loadingIcon:`rly_DiffFileTree-module__loadingIcon`,"rly-diff-file-tree-spin":`rly_DiffFileTree-module__rly-diff-file-tree-spin`},Q=e=>ae(qt,e),Jt=e=>e.state===`ready`?`Ready`:e.state===`loading`?w(e.label,`DiffFileTree loading label`):`${e.state}: ${w(e.reason,`DiffFileTree ${e.state} reason`)}`,Yt=e=>e.split(`/`).map(e=>e!==e.trim()||/[\t\n\v\f\r]/u.test(e)?JSON.stringify(e):e).join(`/`),Xt=(e,t)=>{if(e.length===0)throw Error(`${t} must not be empty`);return e},Zt={added:Se,deleted:we,modified:xe,renamed:Ce},Qt=e=>{let t=new Set;for(let n of e.files){let e=w(n.id,`DiffFileTree file id`);if(t.has(e))throw Error(`DiffFileTree file ids must be unique: ${e}`);t.add(e);let r=Xt(n.path,`DiffFileTree path for ${e}`);if(n.change===`renamed`&&Xt(n.previousPath,`DiffFileTree previousPath for ${e}`)===r)throw Error(`DiffFileTree renamed paths must differ: ${e}`);Jt(n.content)}if(e.state===`loading`||e.state===`error`){if(!Number.isInteger(e.indexedCount)||!Number.isInteger(e.totalCount))throw Error(`DiffFileTree counts must be integers`);if(e.indexedCount!==e.files.length||e.totalCount<e.indexedCount)throw Error(`DiffFileTree indexedCount must match visible files and cannot exceed totalCount`);e.state===`loading`&&w(e.label,`DiffFileTree loading label`),e.state===`error`&&(w(e.title,`DiffFileTree error title`),w(e.description,`DiffFileTree error description`))}},$t=e=>{if(e.children.length!==1||e.children[0]?.kind!==`directory`)return e;let t=e.children[0];return $t({...t,name:`${e.name}/${t.name}`})},en=(e,t=0)=>{let n=[],r=new Map;for(let i of e){let e=i.segments[t];if(e===void 0)continue;if(t===i.segments.length-1){n.push({file:i.file,kind:`file`,name:e});continue}let a=r.get(e)??[];a.push(i),r.set(e,a)}return[...Array.from(r,([e,n])=>$t({children:en(n,t+1),fileCount:n.length,kind:`directory`,name:e,path:n[0].segments.slice(0,t+1).join(`/`)})),...n]},tn=e=>{let t=e.split(`/`);return new Set(t.slice(0,-1).map((e,n)=>t.slice(0,n+1).join(`/`)))},nn=({className:e,data:t,heading:n,onSelectedFileChange:r,selectedFileId:i,...a})=>{let c=w(n,`DiffFileTree heading`);if(Qt(t),i!==void 0&&!t.files.some(e=>e.id===i))throw Error(`DiffFileTree selectedFileId is not in the visible inventory: ${i}`);let l=`rly-diff-file-tree-${(0,M.useId)()}`,u=t.state===`ready`?t.files.length:t.indexedCount,d=t.state===`ready`?t.files.length:t.totalCount,f=(0,M.useMemo)(()=>en(t.files.map(e=>({file:e,segments:e.path.split(`/`)}))),[t.files]),[p,m]=(0,M.useState)(()=>new Set),h=t.files.find(({id:e})=>e===i)?.path;(0,M.useEffect)(()=>{if(h===void 0)return;let e=tn(h);m(t=>[...t].some(t=>e.has(t))?new Set([...t].filter(t=>!e.has(t))):t)},[h]);let g=e=>e.map(e=>{if(e.kind===`file`){let t=i===e.file.id,n=Zt[e.file.change],a=e.file.content.state===`ready`?null:Jt(e.file.content);return(0,N.jsx)(`li`,{"data-rly-diff-file-id":e.file.id,children:(0,N.jsxs)(`button`,{"aria-current":t?`true`:void 0,"aria-label":`${Yt(e.file.path)}, ${e.file.change}, ${Jt(e.file.content)}`,className:Q(`file`),"data-rly-diff-content-state":e.file.content.state,"data-rly-diff-file-change":e.file.change,onClick:()=>r(e.file.id),type:`button`,children:[(0,N.jsxs)(`span`,{className:Q(`pathBlock`),style:{paddingInlineStart:`var(--rly-space-20)`},children:[e.file.change===`renamed`?(0,N.jsx)(`span`,{className:Q(`previousPath`),children:Yt(e.file.previousPath)}):null,(0,N.jsx)(`code`,{className:Q(`path`),children:Yt(e.name)})]}),(0,N.jsxs)(`span`,{className:Q(`statusIcons`),children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,className:Q(`statusIcon`),title:e.file.change,children:(0,N.jsx)(n,{})}),a===null?null:(0,N.jsx)(`span`,{"aria-hidden":`true`,className:Q(`statusIcon`),title:a,children:e.file.content.state===`loading`?(0,N.jsx)(s,{className:Q(`loadingIcon`)}):(0,N.jsx)(o,{})})]})]})},e.file.id)}let t=!p.has(e.path);return(0,N.jsxs)(`li`,{className:Q(`directory`),"data-rly-diff-directory":e.path,children:[(0,N.jsxs)(`button`,{"aria-expanded":t,"aria-label":`${Yt(e.name)}, directory, ${e.fileCount} changed ${e.fileCount===1?`file`:`files`}`,className:Q(`directoryButton`),onClick:()=>m(n=>{let r=new Set(n);return t?r.add(e.path):r.delete(e.path),r}),type:`button`,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,className:Q(`chevron`)}),(0,N.jsx)(`code`,{className:Q(`directoryName`),children:Yt(e.name)}),(0,N.jsx)(`span`,{className:Q(`directoryCount`),children:e.fileCount})]}),t?(0,N.jsx)(`ol`,{className:Q(`group`),style:{marginInlineStart:`var(--rly-space-16)`},children:g(e.children)}):null]},`directory:${e.path}`)});return(0,N.jsxs)(`nav`,{...a,"aria-busy":t.state===`loading`?`true`:void 0,"aria-labelledby":l,className:ge(Q(`root`),e),"data-rly-diff-inventory-state":t.state,children:[(0,N.jsxs)(`header`,{className:Q(`header`),children:[(0,N.jsxs)(`span`,{children:[(0,N.jsx)(`span`,{className:Q(`eyebrow`),children:`Changed files`}),(0,N.jsx)(`h2`,{id:l,children:c})]}),(0,N.jsxs)(`strong`,{"aria-label":`${u} of ${d} files indexed`,className:Q(`count`),children:[u,`/`,d]})]}),t.state===`loading`?(0,N.jsx)(`p`,{className:Q(`notice`),role:`status`,children:t.label}):null,t.state===`error`?(0,N.jsxs)(`section`,{className:Q(`error`),role:`alert`,children:[(0,N.jsx)(`strong`,{children:t.title}),(0,N.jsx)(`span`,{children:t.description})]}):null,t.files.length===0?(0,N.jsx)(`p`,{className:Q(`empty`),children:`No changed files.`}):(0,N.jsx)(`ol`,{className:Q(`list`),children:g(f)})]})},rn=le([`pending`,`posting`,`posted`,`posted-stale`,`acknowledged`,`rejected`,`failed`]),an=(e,t,n)=>{let r=e[t];return r===`posting`||r===`posted`||r===`posted-stale`?e:{...e,[t]:n}},on=e=>Object.fromEntries(e.map(e=>[e.id,`pending`])),sn=e=>JSON.stringify(e),cn=(e,t,n,r)=>{let i=e.find(({id:e})=>e===t.id),a=i===void 0||sn(i)!==sn(t);return a&&r===`failed`&&i===void 0?{dispositions:n,stale:!1}:{dispositions:{...n,[t.id]:a&&r===`posted`?`posted-stale`:r},stale:a}},ln=(e,t)=>{let n=[...e,t],r=[],i=new TextEncoder,a=2,o=0;for(let e=n.length-1;e>=0;){let t=n[e];if(t===void 0){--e;continue}let s;if(t.role===`assistant`){let r=n[e-1];if(r?.role!==`user`||r.findingId!==t.findingId){--e;continue}s=[r,t],e-=2}else s=[t],--e;let c=s.reduce((e,t,n)=>e+i.encode(JSON.stringify(t)).byteLength+(o===0&&n===0?0:1),0);if(o+s.length>40||a+c>32768)break;r.push(s),o+=s.length,a+=c}return r.reverse().flat()},un=(e,t,n)=>{let r=new Map(e.map(e=>[e.id,e]));return Object.fromEntries(t.map(e=>{let t=r.get(e.id),i=n[e.id]??`pending`;return t===void 0||sn(t)!==sn(e)?i===`posting`?[e.id,i]:[e.id,i===`posted`||i===`posted-stale`?`posted-stale`:`pending`]:[e.id,i]}))},dn=class extends d(`RelayReviewTransportError`){},fn=h(a(k)),pn=async(e,n,r,i)=>{let a=await T;if(a._tag===`Failed`)throw new dn({message:a.message});let o=oe(),s={method:`POST`,credentials:`same-origin`,headers:o===null?{"content-type":`application/json`}:{"content-type":`application/json`,"x-csrf-token":o},body:JSON.stringify(n)};i!==void 0&&(s.signal=i);let c=await window.fetch(e,s);if(!c.ok){let e=(await c.text()).slice(0,2e3).trim();throw new dn({message:e.length===0?`Relay request failed with status ${c.status}`:e})}if(c.body===null)throw new dn({message:`Relay returned no progress stream`});let l=c.body.getReader(),u=new TextDecoder,d=``,f=!1,p=async e=>{if(e.trim().length!==0)try{let t=await fn(e);if(f)throw new dn({message:`Relay returned frames after the terminal event`});f=t.type===`complete`||t.type===`error`,r(t)}catch(e){throw t(e,`RelayReviewTransportError`)?e:new dn({message:A(e)?e.message:`Relay returned malformed progress`})}};try{for(;;){let e=await l.read();d+=u.decode(e.value,{stream:!e.done});let t=d.split(`
|
|
21
|
-
`);d=t.pop()??``;for(let e of t)await p(e);if(e.done)break}if(await p(d),!f)throw new dn({message:`Relay progress stream ended before a terminal event`})}finally{await l.cancel().catch(()=>void 0),l.releaseLock()}},mn=f({identity:ce,review:C,skillIds:re,turns:ye,dispositions:e(ce,rn)}),hn=p(a(mn)),gn=e=>Object.entries(e).reduce((e,[t,n])=>({...e,[t]:n===`posting`?`failed`:n}),{}),_n=(e,t)=>`codecommit:relay-review-session:${encodeURIComponent(e)}:${encodeURIComponent(t)}`,vn=(e,t,n)=>{try{let r=e.getItem(t);if(r===null)return null;let i=hn(r);return _(i)||i.value.identity!==n?null:{...i.value,dispositions:gn(i.value.dispositions)}}catch{return null}},yn=(e,t,n)=>{try{e.setItem(t,JSON.stringify(n))}catch{}},$={workspace:`_workspace_1j5hk_1`,workspaceHeader:`_workspaceHeader_1j5hk_8`,focusChoices:`_focusChoices_1j5hk_9`,diffToolbar:`_diffToolbar_1j5hk_10`,agentPane:`_agentPane_1j5hk_12`,findingMeta:`_findingMeta_1j5hk_14`,relayControls:`_relayControls_1j5hk_33`,findingBody:`_findingBody_1j5hk_88`,findingActions:`_findingActions_1j5hk_89`,conversation:`_conversation_1j5hk_90`,reviewFailure:`_reviewFailure_1j5hk_95`,workbench:`_workbench_1j5hk_100`,fileTree:`_fileTree_1j5hk_108`,diffPane:`_diffPane_1j5hk_124`,diffViewport:`_diffViewport_1j5hk_168`,codeView:`_codeView_1j5hk_174`,lineFinding:`_lineFinding_1j5hk_179`,lineComment:`_lineComment_1j5hk_194`,lineCommentMeta:`_lineCommentMeta_1j5hk_210`,agentTitle:`_agentTitle_1j5hk_261`,agentEmpty:`_agentEmpty_1j5hk_285`,agentSpinner:`_agentSpinner_1j5hk_299`,"agent-spin":`_agent-spin_1j5hk_1`,findingDeck:`_findingDeck_1j5hk_315`,verdictCopy:`_verdictCopy_1j5hk_324`,findingCard:`_findingCard_1j5hk_343`,findingDetails:`_findingDetails_1j5hk_385`,profileChoice:`_profileChoice_1j5hk_422`,progressRail:`_progressRail_1j5hk_442`,staleReview:`_staleReview_1j5hk_486`,conversationTitle:`_conversationTitle_1j5hk_567`,conversationHistory:`_conversationHistory_1j5hk_604`,workspaceFooter:`_workspaceFooter_1j5hk_670`},bn=[{kind:`review`,label:`Full review`,description:`Correctness, security, and maintainability`,icon:be},{kind:`security`,label:`Security`,description:`Trust boundaries and unsafe inputs`,icon:b},{kind:`tests`,label:`Tests`,description:`Missing behavioral guardrails`,icon:Ee},{kind:`explain`,label:`Explain`,description:`Architecture and merge risks`,icon:j}],xn=5e3,Sn=4e6,Cn=524288,wn=new TextEncoder,Tn=e=>{if(e.length===0)return 0;let t=1;for(let n of e)n===`
|
|
22
|
-
`&&t++;return t},En=(e,t)=>{if(wn.encode(e).byteLength+wn.encode(t).byteLength>Cn)return!0;let n=Tn(e),r=Tn(t);return n+r>xn||n*r>Sn},Dn=e=>e.beforeMode===null&&e.afterMode!==null?`new file mode ${e.afterMode}`:e.beforeMode!==null&&e.afterMode===null?`deleted file mode ${e.beforeMode}`:e.beforeMode!==null&&e.afterMode!==null&&e.beforeMode!==e.afterMode?`mode ${e.beforeMode} → ${e.afterMode}`:null,On=e=>e===`P1`||e===`P2`?`critical`:e===`P3`?`caution`:`neutral`,kn=e=>{switch(e.location.scope){case`general`:return`Whole pull request`;case`file`:return e.location.filePath;case`line`:return`${e.location.filePath}:${e.location.line} · ${e.location.side}`}},An=f({message:ce}),jn=c(An);function Mn(e,t){return jn(e)?e.message:t}var Nn=(e,t,n)=>`${e}:${t}:${n.revisionId}:${n.baseCommit}:${n.headCommit}`,Pn=(e,t)=>{let n=t.location;if(n.scope!==`general`)return e.find(e=>n.scope===`file`?e.path===n.filePath||e.previousPath===n.filePath:n.side===`after`?e.status!==`deleted`&&e.path===n.filePath:e.status!==`added`&&(e.previousPath??e.path)===n.filePath)?.index},Fn=(e,t)=>e.status===`renamed`&&e.previousPath!==null?{id:String(e.index),path:e.path,previousPath:e.previousPath,change:`renamed`,content:t}:{id:String(e.index),path:e.path,change:e.status===`renamed`?`modified`:e.status,content:t},In=(e,t)=>e.flatMap(e=>{if(e.location.scope!==`line`)return[];let n=e.location.side===`before`?t.previousPath??t.path:t.path;return e.location.filePath===n?[{id:e.id,accessibilityLabel:`${e.priority} finding: ${e.title}`,location:{itemId:String(t.index),lineNumber:e.location.line,side:e.location.side===`after`?`additions`:`deletions`},render:()=>(0,N.jsxs)(`aside`,{className:$.lineFinding,children:[(0,N.jsxs)(`strong`,{children:[e.priority,` · `,e.title]}),(0,N.jsx)(`span`,{children:e.summary})]})}]:[]}),Ln=e=>{let t=e.replace(/\[([^\]]+)\]\([^)]*\)/gu,`$1`).replace(/(^|\s)#{1,6}\s+/gu,`$1`).replace(/[*`]/gu,``).replace(/\s+/gu,` `).trim();return t.length<=180?t:`${t.slice(0,177)}…`},Rn=({active:e,onNavigateToComment:t,target:n})=>{let r=(0,M.useRef)(null);return(0,M.useEffect)(()=>{!e||r.current===null||(r.current.scrollIntoView({behavior:`smooth`,block:`center`}),r.current.focus({preventScroll:!0}))},[e]),(0,N.jsxs)(`aside`,{className:$.lineComment,"data-active":e?`true`:void 0,ref:r,tabIndex:-1,children:[(0,N.jsxs)(`span`,{className:$.lineCommentMeta,children:[(0,N.jsx)(Te,{"aria-hidden":`true`}),(0,N.jsx)(`strong`,{children:n.author}),(0,N.jsx)(`span`,{children:`CodeCommit comment`})]}),(0,N.jsx)(`span`,{children:Ln(n.content)}),(0,N.jsx)(`button`,{onClick:()=>t(n),type:`button`,children:`View in comments`})]})},zn=(e,t,n,r)=>e.flatMap(e=>{let i=e.side===`before`?t.previousPath??t.path:t.path;return e.filePath===i?[{id:`comment:${e.commentId}`,accessibilityLabel:`CodeCommit comment by ${e.author}`,location:{itemId:String(t.index),lineNumber:e.lineNumber,side:e.side===`after`?`additions`:`deletions`},render:()=>(0,N.jsx)(Rn,{active:n===e.commentId,onNavigateToComment:r,target:e})}]:[]}),Bn=({accountId:e,activeCommentId:t,baseCommit:n,comments:a,file:o,findings:s,headCommit:c,layout:l,onContentStateChange:u,onNavigateToComment:d,pullRequestId:f,revisionId:p,wrap:h})=>{let g=(0,M.useMemo)(()=>ue.query(`prs`,`diffContent`,{params:{awsAccountId:e,prId:f,fileIndex:o.index},query:{revisionId:p,baseCommit:n,headCommit:c},timeToLive:`10 seconds`}),[e,n,o.index,c,f,p]),_=ve(g),y=v(_)?`error`:r(_)?_.value.state===`text`?_.value.before!==null&&_.value.after!==null&&En(_.value.before,_.value.after)?`complexity`:`ready`:_.value.state:null;if((0,M.useEffect)(()=>{switch(y){case`ready`:u(o.index,{state:`ready`});break;case`binary`:u(o.index,{state:`binary`,reason:`CodeCommit reports binary or non-UTF-8 content.`});break;case`oversized`:u(o.index,{state:`oversized`,reason:`Content exceeds the bounded CodeCommit blob limit.`});break;case`complexity`:u(o.index,{state:`oversized`,reason:`Browser diff complexity safety limit exceeded.`});break;case`error`:u(o.index,{state:`error`,reason:`The exact file content request failed.`})}},[o.index,y,u]),i(_)||m(_))return(0,N.jsx)(E,{announce:`polite`,description:`Reading both immutable sides of ${o.path}.`,title:`Loading file diff`,tone:`progress`});if(v(_))return(0,N.jsx)(E,{announce:`polite`,description:Mn(_.cause,`Reload the pull request to retry this exact file.`),title:`File diff unavailable`,tone:`critical`});if(!r(_))return(0,N.jsx)(E,{description:`Reload the pull request to retry.`,title:`File diff unavailable`,tone:`critical`});if(_.value.state!==`text`||_.value.before===null||_.value.after===null)return(0,N.jsx)(E,{description:_.value.state===`binary`?`CodeCommit reports binary or non-UTF-8 content. The file remains in the complete inventory.`:`One side exceeds the bounded CodeCommit blob limit and cannot be rendered safely.`,title:_.value.state===`binary`?`Binary change`:`File too large`,tone:`neutral`});if(En(_.value.before,_.value.after))return(0,N.jsx)(E,{description:`This file exceeds the browser diff-complexity safety limit.`,title:`Diff too large to render`,tone:`neutral`});let b={id:String(o.index),before:{cacheKey:`${p}:${String(o.index)}:before`,contents:_.value.before,name:o.previousPath??o.path},after:{cacheKey:`${p}:${String(o.index)}:after`,contents:_.value.after,name:o.path}};return(0,N.jsx)(Kt,{annotations:[...In(s,o),...zn(a,o,t,d)],className:$.codeView??``,initialItems:[b],mode:l,wrap:h})},Vn=({canPost:e,dispositions:t,isReviewing:n,onAcknowledge:r,onPost:i,onReject:a,onSelect:o,review:c,selectedFindingId:l})=>n?(0,N.jsxs)(`div`,{"aria-live":`polite`,className:$.agentEmpty,children:[(0,N.jsx)(s,{"aria-hidden":`true`,className:$.agentSpinner}),(0,N.jsx)(D,{as:`h3`,variant:`card-title`,children:`Relay is reviewing`}),(0,N.jsx)(D,{tone:`secondary`,children:`Live stages are updating above. Findings will appear here when the run completes.`})]}):c===null?(0,N.jsxs)(`div`,{className:$.agentEmpty,children:[(0,N.jsx)(be,{"aria-hidden":`true`}),(0,N.jsx)(D,{as:`h3`,variant:`card-title`,children:`Relay is ready`}),(0,N.jsx)(D,{tone:`secondary`,children:`Choose a focus, then run a prompt-only review over this exact CodeCommit revision.`})]}):c.kind===`explain`&&c.result.explanation!==void 0?(0,N.jsxs)(`div`,{className:$.agentEmpty,children:[(0,N.jsx)(j,{"aria-hidden":`true`}),(0,N.jsx)(D,{as:`h3`,variant:`card-title`,children:`Change explanation`}),(0,N.jsx)(D,{children:c.result.explanation}),(0,N.jsx)(D,{tone:`secondary`,children:c.result.verdict})]}):c.result.findings.length===0?(0,N.jsxs)(`div`,{className:$.agentEmpty,children:[(0,N.jsx)(x,{"aria-hidden":`true`}),(0,N.jsx)(D,{as:`h3`,variant:`card-title`,children:`No actionable findings`}),(0,N.jsx)(D,{tone:`secondary`,children:c.result.verdict})]}):(0,N.jsxs)(`section`,{"aria-label":`Findings`,className:$.findingDeck,children:[(0,N.jsx)(D,{as:`p`,className:$.verdictCopy,children:c.result.verdict}),(0,N.jsx)(`ol`,{children:c.result.findings.map(n=>(0,N.jsx)(`li`,{children:(0,N.jsxs)(`article`,{className:$.findingCard,"data-selected":l===n.id?`true`:void 0,children:[(0,N.jsxs)(`button`,{className:$.findingBody,onClick:()=>o(n),type:`button`,children:[(0,N.jsxs)(`span`,{className:$.findingMeta,children:[(0,N.jsxs)(`span`,{children:[(0,N.jsx)(ie,{label:n.priority,size:`compact`,tone:On(n.priority)}),(0,N.jsx)(`code`,{children:kn(n)})]}),(0,N.jsx)(ie,{label:t[n.id]??`pending`,size:`compact`,tone:t[n.id]===`failed`||t[n.id]===`posted-stale`?`caution`:`neutral`})]}),(0,N.jsx)(`strong`,{children:n.title}),(0,N.jsx)(`span`,{children:n.summary})]}),(0,N.jsxs)(`details`,{className:$.findingDetails,children:[(0,N.jsx)(`summary`,{children:`Evidence & recommendation`}),(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`span`,{children:[(0,N.jsx)(`b`,{children:`Evidence`}),n.details]}),(0,N.jsxs)(`span`,{children:[(0,N.jsx)(`b`,{children:`Recommendation`}),n.recommendation]}),(0,N.jsxs)(`span`,{children:[(0,N.jsx)(`b`,{children:`Verification`}),n.verification]})]})]}),(0,N.jsxs)(`div`,{className:$.findingActions,children:[(0,N.jsx)(me,{disabled:!e||t[n.id]===`posting`||t[n.id]===`posted`,loading:t[n.id]===`posting`,onClick:()=>i(n),size:`compact`,variant:`primary`,children:`Accept · post`}),(0,N.jsxs)(`button`,{disabled:t[n.id]===`posting`||t[n.id]===`posted`||t[n.id]===`posted-stale`,onClick:()=>r(n),type:`button`,children:[(0,N.jsx)(x,{}),` Ack`]}),(0,N.jsxs)(`button`,{disabled:t[n.id]===`posting`||t[n.id]===`posted`||t[n.id]===`posted-stale`,onClick:()=>a(n),type:`button`,children:[(0,N.jsx)(y,{}),` Reject`]})]})]})},n.id))})]}),Hn=({accountId:e,commentNavigation:t,comments:i,diff:a,diffFailure:o,onFindingPosted:s,onNavigateToComment:l,pullRequest:d})=>{let f=S(),[p,m]=(0,M.useState)(a.files[0]?.index??null),[h,g]=(0,M.useState)(null),[_,y]=(0,M.useState)(null),[b,x]=(0,M.useState)(`split`),[ee,te]=(0,M.useState)(!1),C=ve(fe),[re,w]=(0,M.useState)(null),ae=(0,M.useMemo)(()=>ue.mutation(`prs`,`postRelayFinding`),[]),oe=n(ae,{mode:`promise`}),T=Nn(e,d.id,a),[se,ce]=(0,M.useState)(()=>({identity:T,values:new Map})),le=_n(e,d.id),[O,ge]=(0,M.useState)(null),k=(0,M.useRef)(O);k.current=O;let[ye,A]=(0,M.useState)(null),[xe,Se]=(0,M.useState)(null),[j,Ce]=(0,M.useState)(!1),[we,Ee]=(0,M.useState)([]),[P,De]=(0,M.useState)([]),[Oe,ke]=(0,M.useState)(``),[F,I]=(0,M.useState)({}),[L,Ae]=(0,M.useState)(!0),je=(0,M.useRef)(F);je.current=F;let R=(0,M.useRef)(null),z=O?.value??null,B=O!==null&&O.identity!==T,V=r(C)?C.value.review.profiles:[],Me=!r(C)&&!v(C),Ne=r(C)?V.find(e=>e.id===C.value.review.defaultProfileId)??V[0]:void 0,H=V.find(e=>e.id===re)??Ne,Pe=_??H?.kind??`review`,U=a.files.find(({index:e})=>e===p)??a.files[0],Fe=U===void 0?null:Dn(U),Ie=se.identity===T?se.values:new Map,Le={files:a.files.map(e=>Fn(e,Ie.get(e.index)??{state:`ready`})),state:`ready`};(0,M.useEffect)(()=>{if(!r(C)||re!==null)return;let e=C.value.review.profiles.find(({id:e})=>e===C.value.review.defaultProfileId)??C.value.review.profiles[0];e!==void 0&&w(e.id)},[C,re]),(0,M.useEffect)(()=>()=>R.current?.abort(),[]),(0,M.useEffect)(()=>{if(t?.destination!==`diff`)return;if(!de(t.target,a)){Se(`This comment belongs to an older CodeCommit revision and cannot be placed on the current diff.`);return}let e=he(a.files,t.target);if(e===void 0){Se(`The comment's file is not present in the current changed-file inventory.`);return}Se(null),m(e),g(null)},[t,a]),(0,M.useEffect)(()=>{let e=vn(window.sessionStorage,le,T);if(e===null){if(k.current!==null)return;ge(null),De([]),I({}),g(null);return}let t={identity:e.identity,skillIds:e.skillIds,value:e.review};k.current=t,je.current=e.dispositions,ge(t),De(e.turns),I(e.dispositions),g(e.turns.at(-1)?.findingId??e.review.result.findings[0]?.id??null)},[T,le]),(0,M.useEffect)(()=>{O!==null&&O.identity===T&&yn(window.sessionStorage,le,{identity:O.identity,review:O.value,skillIds:O.skillIds,turns:P,dispositions:F})},[O,F,T,le,P]),(0,M.useEffect)(()=>{p!==null&&a.files.some(({index:e})=>e===p)||m(a.files[0]?.index??null)},[a.files,p]);let Re=(0,M.useCallback)((e,t)=>{ce(n=>{let r=n.identity===T?n.values:new Map,i=r.get(e);return n.identity===T&&i?.state===t.state?n:{identity:T,values:new Map(r).set(e,t)}})},[T]),ze=(0,M.useCallback)(async(e,t)=>{R.current?.abort();let n=new AbortController;R.current=n,Ce(!0),A(null),Ee([]);let r=null,i={};try{if(await pn(e,t,e=>{if(e.type===`progress`){Ee(t=>[...t,e].slice(-12));return}if(e.type===`error`){r=e.message,A({description:e.message,title:`Relay review failed`});return}i.event=e},n.signal),r!==null)return A({description:r,title:`Relay review failed`}),{completed:!1};let a=i.event;if(a===void 0)return{completed:!1};let o=k.current?.value.result.findings??[],s=o.length===0?on(a.review.result.findings):un(o,a.review.result.findings,je.current);je.current=s,I(s);let c={identity:T,skillIds:t.skillIds,value:a.review};return k.current=c,ge(c),g(e=>e??a.review.result.findings[0]?.id??null),a.reply===void 0?{completed:!0}:{completed:!0,reply:a.reply}}catch(e){return n.signal.aborted||A({description:Mn(e,`Relay could not complete this review.`),title:`Relay review failed`}),{completed:!1}}finally{R.current===n&&(R.current=null,Ce(!1))}},[T]),Be=(0,M.useCallback)(async()=>{H!==void 0&&(await ze(`/api/prs/${encodeURIComponent(e)}/${encodeURIComponent(d.id)}/relay-review/stream`,{revisionId:a.revisionId,baseCommit:a.baseCommit,headCommit:a.headCommit,kind:Pe,skillIds:H.skillIds})).completed&&(De([]),ke(``))},[e,a.baseCommit,a.headCommit,a.revisionId,d.id,ze,Pe,H]),Ve=(0,M.useCallback)(async(t,n)=>{if(z===null)return;let r={findingId:t,role:`user`,message:n};if(!c(_e)(r)){A({description:`Shorten the message so it can be retained in this review conversation.`,title:`Message is too large`});return}let i=ln(P,r),o=await ze(`/api/prs/${encodeURIComponent(e)}/${encodeURIComponent(d.id)}/relay-review/continue`,{revisionId:a.revisionId,baseCommit:a.baseCommit,headCommit:a.headCommit,kind:z.kind,skillIds:O?.skillIds??[],currentReview:z.result,turns:P,findingId:t,message:n});o.completed&&(De(o.reply===void 0?i:ln(i,{findingId:t,role:`assistant`,message:o.reply})),ke(``))},[e,a.baseCommit,a.headCommit,a.revisionId,d.id,z,ze,O,P]),He=(0,M.useCallback)(async t=>{if(!(z===null||B)){A(null),I(e=>({...e,[t.id]:`posting`}));try{s((await oe({params:{awsAccountId:e,prId:d.id,findingId:t.id},payload:{revisionId:z.revisionId,baseCommit:z.baseCommit,headCommit:z.headCommit,finding:t}})).operationId),I(e=>{let n=cn(k.current?.value.result.findings??[],t,e,`posted`);return n.stale&&A({description:`CodeCommit received an older finding snapshot. Re-review before relying on it.`,title:`Finding post needs review`}),n.dispositions})}catch(e){I(e=>cn(k.current?.value.result.findings??[],t,e,`failed`).dispositions),A({description:Mn(e,`CodeCommit did not accept this finding.`),title:`Finding post failed`})}}},[e,s,oe,d.id,z,B]),Ue=(0,M.useCallback)(e=>{g(e.id),Ae(!1);let t=Pn(a.files,e);t!==void 0&&m(t)},[a.files]),W=z?.result.findings.find(({id:e})=>e===h)??null,G=W?.id??(h!==null&&P.some(({findingId:e})=>e===h)?h:null),We=G===null?[]:P.filter(({findingId:e})=>e===G),K=we.slice(-4);return(0,N.jsxs)(ne,{as:`section`,className:$.workspace,padding:`none`,form:`grouped`,children:[(0,N.jsx)(`header`,{className:$.workspaceHeader,children:(0,N.jsxs)(`div`,{children:[(0,N.jsx)(D,{tone:`secondary`,variant:`label`,children:`Exact-revision review`}),(0,N.jsx)(D,{as:`h2`,variant:`section-title`,children:`Diff`}),(0,N.jsxs)(D,{tone:`secondary`,variant:`meta`,children:[a.files.length,` changed `,a.files.length===1?`file`:`files`,` · head`,` `,a.headCommit.slice(0,12)]})]})}),o===null?null:(0,N.jsx)(`div`,{className:$.reviewFailure,children:(0,N.jsx)(E,{announce:`polite`,description:`${o} Showing the last successfully loaded exact revision.`,title:`Latest diff unavailable`,tone:`caution`})}),(0,N.jsxs)(`div`,{className:$.workbench,children:[(0,N.jsx)(nn,{className:$.fileTree,data:Le,heading:`PR ${d.id}`,onSelectedFileChange:e=>{m(Number(e)),g(null)},...U===void 0?{}:{selectedFileId:String(U.index)}}),(0,N.jsxs)(`section`,{"aria-label":`Selected file diff`,className:$.diffPane,children:[(0,N.jsxs)(`header`,{className:$.diffToolbar,children:[(0,N.jsxs)(`span`,{children:[(0,N.jsx)(`code`,{children:U?.path??`No changed file`}),Fe===null?null:(0,N.jsx)(`small`,{children:Fe})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`button`,{"aria-pressed":b===`split`,onClick:()=>x(`split`),type:`button`,children:`Split`}),(0,N.jsx)(`button`,{"aria-pressed":b===`stacked`,onClick:()=>x(`stacked`),type:`button`,children:`Stacked`}),(0,N.jsx)(`button`,{"aria-pressed":ee,onClick:()=>te(e=>!e),type:`button`,children:`Wrap`})]})]}),(0,N.jsx)(`div`,{className:$.diffViewport,children:U===void 0?(0,N.jsx)(E,{description:`CodeCommit reports no changed files for this revision.`,title:`Empty diff`,tone:`neutral`}):(0,N.jsx)(Bn,{activeCommentId:t?.destination===`diff`?t.target.commentId:null,accountId:e,baseCommit:a.baseCommit,comments:i,file:U,findings:B?[]:z?.result.findings??[],headCommit:a.headCommit,layout:b,onContentStateChange:Re,onNavigateToComment:l,pullRequestId:d.id,revisionId:a.revisionId,wrap:ee},`${a.revisionId}:${a.baseCommit}:${a.headCommit}:${String(U.index)}:${b}:${String(ee)}`)})]}),(0,N.jsxs)(`aside`,{"aria-label":`Relay findings`,className:$.agentPane,children:[(0,N.jsxs)(`header`,{children:[(0,N.jsxs)(`div`,{className:$.agentTitle,children:[(0,N.jsxs)(`span`,{children:[(0,N.jsx)(be,{"aria-hidden":`true`}),(0,N.jsx)(D,{as:`h2`,variant:`section-title`,children:`Relay`})]}),(0,N.jsx)(`small`,{children:j?`Reviewing the exact revision`:z===null?`Review findings and discuss evidence`:`${String(z.result.findings.length)} actionable ${z.result.findings.length===1?`finding`:`findings`}`})]}),j?(0,N.jsx)(ie,{label:`running`,size:`compact`,tone:`progress`}):z===null?null:(0,N.jsx)(ie,{label:z.kind,size:`compact`,tone:`progress`})]}),(0,N.jsxs)(`section`,{"aria-label":`Relay controls`,className:$.relayControls,children:[(0,N.jsxs)(`label`,{className:$.profileChoice,children:[(0,N.jsx)(`span`,{children:`Profile`}),(0,N.jsxs)(`select`,{disabled:j||!r(C),onChange:e=>{let t=V.find(({id:t})=>t===e.target.value);w(e.target.value),t!==void 0&&y(t.kind)},value:H?.id??``,children:[r(C)?null:(0,N.jsx)(`option`,{value:``,children:v(C)?`Profiles unavailable`:`Loading profiles…`}),V.map(e=>(0,N.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,N.jsx)(me,{disabled:j||a.files.length===0||H===void 0,loading:j,onClick:()=>void Be(),size:`compact`,variant:`primary`,children:j?`Relay reviewing…`:z===null?`Run Relay`:`Run again`}),(0,N.jsx)(`div`,{"aria-label":`Relay review focus`,className:$.focusChoices,role:`group`,children:bn.map(e=>{let t=e.icon;return(0,N.jsxs)(`button`,{"aria-pressed":Pe===e.kind,disabled:j,onClick:()=>y(e.kind),title:e.description,type:`button`,children:[(0,N.jsx)(t,{"aria-hidden":`true`}),e.label]},e.kind)})})]}),v(C)?(0,N.jsx)(`div`,{className:$.reviewFailure,children:(0,N.jsx)(E,{action:(0,N.jsx)(me,{onClick:()=>void f(0),size:`compact`,variant:`secondary`,children:`Reload`}),announce:`assertive`,description:Mn(C.cause,`Check the server connection, then reload this page to retry.`),title:`Relay profiles unavailable`,tone:`critical`})}):Me?(0,N.jsx)(`div`,{className:$.reviewFailure,children:(0,N.jsx)(E,{announce:`polite`,description:`Loading the configured review methodology before Relay can run.`,title:`Loading Relay profiles`,tone:`progress`})}):null,K.length===0?null:(0,N.jsx)(`ol`,{"aria-label":`Relay progress`,"aria-live":`polite`,className:$.progressRail,children:K.map((e,t)=>(0,N.jsxs)(`li`,{"aria-current":t===K.length-1?`step`:void 0,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`}),(0,N.jsx)(`small`,{children:e.phase}),(0,N.jsx)(`strong`,{children:e.message}),e.detail===void 0?null:(0,N.jsx)(`em`,{children:e.detail})]},`${e.phase}:${String(t)}`))}),B?(0,N.jsxs)(`div`,{className:$.staleReview,children:[(0,N.jsxs)(`span`,{children:[`This finding deck reviewed `,O?.value.headCommit.slice(0,12),`; current head is`,` `,a.headCommit.slice(0,12),`.`]}),(0,N.jsx)(me,{disabled:j||z===null,onClick:()=>z===null?void 0:void Ve(W?.id??z.result.findings[0]?.id??`F1`,`Re-review the complete finding deck against the latest exact revision. Reconcile resolved, changed, and new findings.`),size:`compact`,variant:`secondary`,children:`Re-review latest`})]}):null,ye===null?null:(0,N.jsx)(`div`,{className:$.reviewFailure,children:(0,N.jsx)(E,{announce:`polite`,description:ye.description,title:ye.title,tone:`critical`})}),xe===null?null:(0,N.jsx)(`div`,{className:$.reviewFailure,children:(0,N.jsx)(E,{announce:`polite`,description:xe,title:`Comment link unavailable`,tone:`caution`})}),(0,N.jsx)(Vn,{canPost:!B,dispositions:F,isReviewing:j,onAcknowledge:e=>I(t=>an(t,e.id,`acknowledged`)),onPost:e=>void He(e),onReject:e=>I(t=>an(t,e.id,`rejected`)),onSelect:Ue,review:z,selectedFindingId:h}),G===null?null:(0,N.jsxs)(`section`,{"aria-label":`Conversation about ${G}`,className:$.conversation,"data-collapsed":L?`true`:void 0,children:[(0,N.jsxs)(`header`,{children:[(0,N.jsxs)(`span`,{children:[(0,N.jsx)(Te,{"aria-hidden":`true`}),(0,N.jsxs)(`span`,{className:$.conversationTitle,children:[(0,N.jsx)(`strong`,{children:W===null?`Discuss withdrawn finding`:`Discuss finding`}),(0,N.jsx)(`small`,{children:W===null?`${G} is no longer in the current deck`:W.title})]})]}),(0,N.jsxs)(`button`,{"aria-expanded":!L,onClick:()=>Ae(e=>!e),type:`button`,children:[L?(0,N.jsx)(u,{"aria-hidden":`true`}):(0,N.jsx)(pe,{"aria-hidden":`true`}),L?`Open`:`Collapse`]})]}),L?null:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{"aria-label":`Conversation history about ${G}`,"aria-live":`polite`,className:$.conversationHistory,role:`log`,children:We.length===0?(0,N.jsx)(`small`,{children:`Ask Relay to verify, refine, or withdraw this finding.`}):(0,N.jsx)(`ol`,{children:We.map((e,t)=>(0,N.jsxs)(`li`,{"data-role":e.role,children:[(0,N.jsx)(`b`,{children:e.role===`user`?`You`:`Relay`}),e.message]},`${e.role}:${String(t)}`))})}),(0,N.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=Oe.trim();t.length>0&&!j&&Ve(G,t)},children:[(0,N.jsx)(`textarea`,{"aria-label":`Message Relay`,disabled:j,maxLength:8e3,onChange:e=>ke(e.target.value),placeholder:`Ask Relay about this finding…`,rows:2,value:Oe}),(0,N.jsx)(me,{disabled:j||Oe.trim().length===0,size:`compact`,type:`submit`,variant:`secondary`,children:`Send`})]})]})]})]})]}),(0,N.jsx)(`footer`,{className:$.workspaceFooter,children:`Relay is advisory. Accept posts immediately; acknowledge and reject stay local to this review session.`})]})},Un=({accountId:e,commentNavigation:t,commentsRefreshGeneration:n,onFindingPosted:a,onNavigateToComment:o,pullRequest:s,refreshGeneration:c})=>{let l=se({pullRequestId:s.id,repositoryName:s.repositoryName,profile:s.account.profile,region:s.account.region,refreshGeneration:n}),u=r(l)?l.value.flatMap(e=>e.comments.flatMap(t=>{if(t.root.deleted)return[];let n=O(e,t.root);return n===null?[]:[n]})):[],d=(0,M.useMemo)(()=>ue.query(`prs`,`diff`,{params:{awsAccountId:e,prId:s.id},serializationKey:`${e}:${s.id}:${s.lastModifiedDate.toISOString()}:${String(c)}`,timeToLive:`30 seconds`}),[e,s.id,s.lastModifiedDate,c]),f=ve(d),p=`${e}:${s.id}`,h=(0,M.useRef)(null);r(f)&&(h.current={identity:p,value:f.value});let g=h.current?.identity===p?h.current.value:null,_=r(f)?f.value:g;if((i(f)||m(f))&&_===null)return(0,N.jsx)(E,{announce:`polite`,description:`Indexing every changed file.`,title:`Loading exact diff`,tone:`progress`});let y=v(f)?Mn(f.cause,`Refresh this pull request to retry the CodeCommit diff read.`):null;return v(f)&&_===null?(0,N.jsx)(E,{announce:`polite`,description:Mn(f.cause,`Refresh this pull request to retry the CodeCommit diff read.`),title:`Exact diff unavailable`,tone:`critical`}):_===null?(0,N.jsx)(E,{description:`Refresh this pull request to retry.`,title:`Exact diff unavailable`,tone:`critical`}):(0,N.jsx)(Hn,{accountId:e,commentNavigation:t,comments:u.filter(e=>de(e,_)),diff:_,diffFailure:y,onFindingPosted:a,onNavigateToComment:o,pullRequest:s},`${e}:${s.id}`)};export{Un as PullRequestReviewWorkspace};
|