@knpkv/codecommit-web 0.14.0 → 0.15.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-Ds8Muxxv.css +1 -0
- package/dist/client/assets/index-eLkbewLN.js +90 -0
- package/dist/client/assets/pr-review-workspace-CgczAXj_.js +22 -0
- package/dist/client/index.html +2 -2
- package/dist/pull-request-coordinates.d.ts +22 -0
- package/dist/pull-request-coordinates.d.ts.map +1 -0
- package/dist/pull-request-coordinates.js +88 -0
- package/dist/pull-request-coordinates.js.map +1 -0
- package/dist/server/Api.d.ts +188 -102
- package/dist/server/Api.d.ts.map +1 -1
- package/dist/server/Api.js +37 -7
- package/dist/server/Api.js.map +1 -1
- package/dist/server/Server.d.ts.map +1 -1
- package/dist/server/Server.js +6 -1
- package/dist/server/Server.js.map +1 -1
- package/dist/server/handlers/prs-live.d.ts +17 -3
- package/dist/server/handlers/prs-live.d.ts.map +1 -1
- package/dist/server/handlers/prs-live.js +104 -22
- package/dist/server/handlers/prs-live.js.map +1 -1
- package/dist/server/handlers/sandbox-live.d.ts.map +1 -1
- package/dist/server/handlers/sandbox-live.js +1 -0
- package/dist/server/handlers/sandbox-live.js.map +1 -1
- package/dist/server/handlers/subscriptions-live.d.ts +2 -2
- package/dist/server/handlers/subscriptions-live.d.ts.map +1 -1
- package/dist/server/handlers/subscriptions-live.js +25 -4
- package/dist/server/handlers/subscriptions-live.js.map +1 -1
- package/dist/server/review/PullRequestReview.d.ts +1 -0
- package/dist/server/review/PullRequestReview.d.ts.map +1 -1
- package/package.json +6 -5
- package/dist/client/assets/index-DQUoxciG.js +0 -90
- package/dist/client/assets/index-NJaNHeOS.css +0 -1
- package/dist/client/assets/pr-review-workspace-C0TVEp1y.js +0 -22
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as ee,S as v,U as y,V as b,W as x,X as te,Y as ne,Z as S,_ as re,a as ie,at as ae,b as oe,c as se,ct as ce,d as C,et as le,f as ue,g as de,h as fe,i as w,it as pe,j as T,k as me,l as E,lt as he,m as ge,n as _e,nt as ve,o as D,ot as O,p as ye,q as k,r as be,rt as A,s as xe,st as j,t as Se,tt as M,u as N,ut as Ce,v as we,w as P,x as Te,y as Ee,z as F}from"./index-eLkbewLN.js";var De=O(`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`}]]),Oe=O(`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`}]]),I=O(`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`}]]),ke=O(`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`}]]),Ae=O(`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`}]]),je=O(`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`}]]),Me=O(`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`}]]),Ne=O(`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`}]]),L=Ce(he(),1),R=j(),z=/(?=^diff --git)/gm,Pe=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Fe=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,Ie=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,Le=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i;Object.freeze({fromStart:0,fromEnd:0});function B(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}var Re=new TextEncoder,ze=new TextDecoder(`utf-8`,{ignoreBOM:!0}),Be=/[\uD800-\uDFFF]/,V=1024,H=new Uint8Array(V);function Ve(){H.length!==V&&(H=new Uint8Array(V))}function U(e){if(e.length===0)return e;if(Be.test(e))return JSON.parse(JSON.stringify(e));let t=e.length*3;H.length<t&&(H=new Uint8Array(t));let{written:n}=Re.encodeInto(e,H);return ze.decode(H.subarray(0,n))}function W(e,t){return e-(t===0?0:1)}function He(e,t){return W(e,t)+t}var G=4096,K=.5;function Ue(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=q(e,r);i!=null&&(t.hunkContent.splice(n,1,...i),n+=i.length-1)}We(t,e)}}function We(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 q(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)>G)return null;let c=[];for(let t=0;t<n;t++)c.push(J(e.deletionLines[i+t]??``));let l=[];for(let t=0;t<r;t++)l.push(J(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+=Ke(c[n+(u?0:e)],l[n+(u?e:0)]);e===0?f=t+o*K: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 Ge=/\s+/g;function J(e){return e.replace(Ge,``)}function Ke(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 qe(e,t){try{return Je(e,t)}finally{Ve()}}function Je(e,{cacheKey:t,isGitDiff:n=z.test(e),oldFile:r,newFile:i,throwOnError:a=!1}={}){let o=0,s=nt(e,`@@ `),c,l=r==null||i==null,u=0,d=0;for(let e of s){let s=Xe(e),f=s[0];if(f==null){if(a)throw Error(`parsePatchContent: invalid hunk`);console.error(`parsePatchContent: invalid hunk`,e);continue}let p=$e(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?Ye(i.contents):[],deletionLines:!l&&r!=null&&i!=null?Ye(r.contents):[],cacheKey:Y(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(Ie),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=U(r.trim()),n!==r&&(c.prevName=U(n.trim()));continue}let t=e.startsWith(`---`)||e.startsWith(`+++`)?e.match(n?Fe:Pe):null;if(t!=null){let[,e,n]=t;if(e===`---`&&n!==`/dev/null`){let e=U(n.trim());c.prevName=e,c.name=e}else e===`+++`&&n!==`/dev/null`&&(c.name=U(n.trim()))}else if(n){if(e.startsWith(`new mode `)&&(c.mode=U(e.slice(8).trim())),e.startsWith(`old mode `)&&(c.prevMode=U(e.slice(8).trim())),e.startsWith(`new file mode`)&&(c.type=`new`,c.mode=U(e.slice(13).trim())),e.startsWith(`deleted file mode`)&&(c.type=`deleted`,c.mode=U(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(Le)??[];t!=null&&(c.prevObjectId=U(t)),n!=null&&(c.newObjectId=U(n)),r!=null&&(c.mode=U(r))}e.startsWith(`rename from `)&&(c.prevName=U(e.slice(12).trim())),e.startsWith(`rename to `)&&(c.name=U(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:ee,deletionStart:v}=p;u=l?u:v-1,d=l?d:ee-1;let y={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:p.additionCount,additionStart:ee,additionLines:m,deletionCount:p.deletionCount,deletionStart:v,deletionLines:h,deletionLineIndex:u,additionLineIndex:d,hunkContent:[],hunkContext:Y(p.hunkContext),hunkSpecs:U(f),noEOFCRAdditions:!1,noEOFCRDeletions:!1},b=0,x=0;for(let e=1;e<s.length;e++){let t=s[e];if(b>=y.additionCount&&x>=y.deletionCount&&!t.startsWith(`\\`)){if(a&&Ze(t)&&!Qe(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=it(n);if(r===`addition`){if(a&&b>=y.additionCount)throw Error(`parsePatchContent: hunk has too many addition lines`);let e=at(t);(g==null||g.type!==`change`)&&(g=ot(`change`,u,d),y.hunkContent.push(g)),d++,b++,l&&c.additionLines.push(e),g.additions++,m++,_=`addition`}else if(r===`deletion`){if(a&&x>=y.deletionCount)throw Error(`parsePatchContent: hunk has too many deletion lines`);let e=at(t);(g==null||g.type!==`change`)&&(g=ot(`change`,u,d),y.hunkContent.push(g)),u++,x++,l&&c.deletionLines.push(e),g.deletions++,h++,_=`deletion`}else if(r===`context`){if(a&&(x>=y.deletionCount||b>=y.additionCount))throw Error(`parsePatchContent: hunk has too many context lines`);let e=at(t);(g==null||g.type!==`context`)&&(g=ot(`context`,u,d),y.hunkContent.push(g)),d++,u++,b++,x++,l&&(c.deletionLines.push(e),c.additionLines.push(e)),g.lines++,_=`context`}else if(r===`metadata`&&g!=null){if(g.type===`context`?(y.noEOFCRAdditions=!0,y.noEOFCRDeletions=!0):_===`deletion`?y.noEOFCRDeletions=!0:_===`addition`&&(y.noEOFCRAdditions=!0),l&&(_===`addition`||_===`context`)){let e=c.additionLines.length-1;e>=0&&(c.additionLines[e]=B(c.additionLines[e]))}if(l&&(_===`deletion`||_===`context`)){let e=c.deletionLines.length-1;e>=0&&(c.deletionLines[e]=B(c.deletionLines[e]))}}}if(a&&(b!==y.additionCount||x!==y.deletionCount))throw Error(`parsePatchContent: hunk line count mismatch`);y.additionLines=m,y.deletionLines=h,y.collapsedBefore=Math.max(W(y.additionStart,y.additionCount)-o,0),c.hunks.push(y),o=He(y.additionStart,y.additionCount);for(let e of y.hunkContent)e.type===`context`?(y.splitLineCount+=e.lines,y.unifiedLineCount+=e.lines):(y.splitLineCount+=Math.max(e.additions,e.deletions),y.unifiedLineCount+=e.deletions+e.additions);y.splitLineStart=c.splitLineCount+y.collapsedBefore,y.unifiedLineStart=c.unifiedLineCount+y.collapsedBefore,c.splitLineCount+=y.collapsedBefore+y.splitLineCount,c.unifiedLineCount+=y.collapsedBefore+y.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=He(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),Ue(c),c}}function Ye(e){let t=Xe(e);for(let e=0;e<t.length;e++)t[e]=U(t[e]);return t}function Xe(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 Ze(e){let t=e[0];return t===`+`||t===`-`||t===` `}function Qe(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 $e(e){if(!e.startsWith(`@@ -`))return;let t=4,n=et(e,t);if(n==null)return;let r=n.value;t=n.endIndex;let i=1;if(e[t]===`,`){let n=et(e,t+1);if(n==null)return;i=n.value,t=n.endIndex}if(e[t]!==` `||e[t+1]!==`+`)return;t+=2;let a=et(e,t);if(a==null)return;let o=a.value;t=a.endIndex;let s=1;if(e[t]===`,`){let n=et(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=tt(e.slice(l+1))),{additionCount:s,additionStart:o,deletionCount:i,deletionStart:r,hunkContext:c}}function et(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 tt(e){return e.endsWith(`\r
|
|
6
|
+
`)?e.slice(0,-2):e.endsWith(`
|
|
7
|
+
`)?e.slice(0,-1):e}function nt(e,t){if(e.length===0)return[``];let n=`\n${t}`,r=e.startsWith(t)?0:rt(e,n,0);if(r===-1)return[e];let i=[];r>0&&i.push(e.slice(0,r));let a=r;for(;;){let t=rt(e,n,a+1);if(t===-1)break;i.push(e.slice(a,t)),a=t}return i.push(e.slice(a)),i}function rt(e,t,n){let r=e.indexOf(t,n);return r===-1?-1:r+1}function Y(e){return e==null?e:U(e)}function it(e){return e===` `?`context`:e===`\\`?`metadata`:e===`+`?`addition`:`deletion`}function at(e){let t=e.slice(1);return U(t===``?`
|
|
8
|
+
`:t)}function ot(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 st=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 st{};function ct(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 lt(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 ut(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 dt(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 ft(e,t){return ut(e,t,``)}function pt(e,t){return dt(e,t,``)}function mt(e,t){return t.slice(0,ht(e,t))}function ht(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 gt(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 _t(e,t){if(t)return yt(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function vt(e,t){if(t)return yt(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function yt(e,t){if(!t)return[vt(e),_t(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=gt(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var bt=`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}`,xt=RegExp(`[${bt}]+|\\s+|[^${bt}]`,`ug`);new class extends st{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=gt(e,r)}else n=e.match(xt)||[];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)&&St(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&St(n,i,r,null,t.intlSegmenter),e}};function St(e,t,n,r,i){if(t&&n){let[a,o]=yt(t.value,i),[s,c]=yt(n.value,i);if(e){let r=ct(a,s);e.value=dt(e.value,s,r),t.value=ft(t.value,r),n.value=ft(n.value,r)}if(r){let e=lt(o,c);r.value=ut(r.value,c,e),t.value=pt(t.value,e),n.value=pt(n.value,e)}}else if(n){if(e){let e=vt(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=vt(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=vt(r.value,i),[a,o]=yt(t.value,i),s=ct(n,a);t.value=ft(t.value,s);let c=lt(ft(n,s),o);t.value=pt(t.value,c),r.value=ut(r.value,n,c),e.value=dt(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=vt(r.value,i),n=mt(_t(t.value,i),e);t.value=pt(t.value,n)}else if(e){let n=mt(_t(e.value,i),vt(t.value,i));t.value=ft(t.value,n)}}new class extends st{tokenize(e){let t=RegExp(`(\\r?\\n)|[${bt}]+|[^\\S\\n\\r]+|[^${bt}]`,`ug`);return e.match(t)||[]}};var Ct=new class extends st{constructor(){super(...arguments),this.tokenize=Tt}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 wt(e,t,n){return Ct.diff(e,t,n)}function Tt(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 Et(e){return e==`.`||e==`!`||e==`?`}new class extends st{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(Et(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 st{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends st{constructor(){super(...arguments),this.tokenize=Tt}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(Dt(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 Dt(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]=Dt(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]=Dt(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends st{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};function Ot(e){for(let t=0;t<e.length;t++)if(e[t]<` `||e[t]>`~`||e[t]===`"`||e[t]===`\\`)return!0;return!1}function kt(e){if(!Ot(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 At={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function jt(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;wt(n,r,Object.assign(Object.assign({},s),{callback:t=>{let n=l(t);e(n)}}))}else return l(wt(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||Pt(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 Mt(e,t){if(t||=At,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=>Mt(e,t)).join(`
|
|
15
|
+
`)}let n=[];if(e.isGit){if(t=At,!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 `+kt(r)+` `+kt(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 `+kt((e.oldFileName??``).replace(/^a\//,``))),n.push(`rename to `+kt((e.newFileName??``).replace(/^b\//,``)))),e.isCopy&&(n.push(`copy from `+kt((e.oldFileName??``).replace(/^a\//,``))),n.push(`copy to `+kt((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(`--- `+kt(e.oldFileName)+(e.oldHeader?` `+e.oldHeader:``)),n.push(`+++ `+kt(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 Nt(e,t,n,r,i,a,o){if(typeof o==`function`&&(o={callback:o}),o?.callback){let{callback:s}=o;jt(e,t,n,r,i,a,Object.assign(Object.assign({},o),{callback:e=>{s(e?Mt(e,o.headerOptions):void 0)}}))}else{let s=jt(e,t,n,r,i,a,o);return s?Mt(s,o?.headerOptions):void 0}}function Pt(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 Ft=`/dev/null`;function It(e,t,n,r=!1){if(e===null&&t===null)throw Error(`parseDiffFromFile: You must pass oldFile, newFile, or both`);let i=e??Lt(),a=t??Lt(),o=qe(Nt(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 Lt(){return{name:Ft,contents:``}}var Rt=(e,t)=>{let n=e[t];if(n===void 0)throw Error(`Missing CSS Module class: ${t}`);return n},zt=(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}"]`)},Bt=(e,t)=>{let n=e.closest(`diffs-container`);return n===null?null:zt(n,t)},Vt=(e,t)=>{let n=Bt(e,t);n!==null&&(n.tabIndex=-1,n.focus({preventScroll:!0}))},Ht=({annotation:e,className:t,returnFocus:n})=>{let r=(0,L.useRef)(null),i=()=>{if(n!==void 0){n();return}r.current!==null&&Vt(r.current,e.location)};return(0,L.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}))},Ut=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`},Wt=(e,t)=>({lineNumber:e,side:t}),Gt=(e,t)=>e[t]?.replace(/\r?\n$/,``)??``,Kt=e=>e.hunkSpecs?.trim()??`@@ -${e.deletionStart},${e.deletionCount} +${e.additionStart},${e.additionCount} @@`,qt=e=>{if(e.before.contents!==e.after.contents)return It({...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)},Jt=(e,t)=>Array.from({length:t.lines},(n,r)=>({addition:{content:Gt(e.additionLines,t.additionLineIndex+r),number:t.additionLineIndex+r+1},deletion:{content:Gt(e.deletionLines,t.deletionLineIndex+r),number:t.deletionLineIndex+r+1},kind:`context`})),Yt=(e,t)=>Array.from({length:Math.max(t.deletions,t.additions)},(n,r)=>({...r<t.additions&&{addition:{content:Gt(e.additionLines,t.additionLineIndex+r),number:t.additionLineIndex+r+1}},...r<t.deletions&&{deletion:{content:Gt(e.deletionLines,t.deletionLineIndex+r),number:t.deletionLineIndex+r+1}},kind:`change`})),Xt=e=>e.hunks.flatMap(t=>[{kind:`hunk`,label:Kt(t)},...t.hunkContent.flatMap(t=>t.type===`context`?Jt(e,t):Yt(e,t))]),Zt=e=>e.hunks.flatMap(t=>[{kind:`hunk`,label:Kt(t)},...t.hunkContent.flatMap(t=>t.type===`context`?Array.from({length:t.lines},(n,r)=>({additionNumber:t.additionLineIndex+r+1,content:Gt(e.additionLines,t.additionLineIndex+r),deletionNumber:t.deletionLineIndex+r+1,kind:`context`})):[...Array.from({length:t.deletions},(n,r)=>({content:Gt(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:Gt(e.additionLines,t.additionLineIndex+r),kind:`addition`}))])]),Qt=(e,t,n,r,i,a)=>(0,R.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}),$t=(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})},en=(e,t,n,r)=>n===void 0?[]:e.filter(e=>e.location.itemId===t&&e.location.lineNumber===n&&e.location.side===r),tn=(e,t,n,r)=>[...en(e,t,n.deletion?.number,`deletions`).map(e=>(0,R.jsxs)(`tr`,{className:X.annotationRow,children:[(0,R.jsx)(`td`,{className:X.annotationCell,colSpan:2,children:(0,R.jsx)(Ht,{annotation:e,className:Rt(X,`annotation`),returnFocus:()=>$t(r(),t,e.location.lineNumber,e.location.side)})}),(0,R.jsx)(`td`,{colSpan:2})]},e.id)),...en(e,t,n.addition?.number,`additions`).map(e=>(0,R.jsxs)(`tr`,{className:X.annotationRow,children:[(0,R.jsx)(`td`,{colSpan:2}),(0,R.jsx)(`td`,{className:X.annotationCell,colSpan:2,children:(0,R.jsx)(Ht,{annotation:e,className:Rt(X,`annotation`),returnFocus:()=>$t(r(),t,e.location.lineNumber,e.location.side)})})]},e.id))],nn=(e,t,n,r,i)=>(0,R.jsx)(`table`,{"aria-label":`Changes in ${e.name}`,className:X.table,children:(0,R.jsx)(`tbody`,{children:Xt(e).map((e,a)=>e.kind===`hunk`?(0,R.jsx)(`tr`,{className:X.hunk,children:(0,R.jsx)(`td`,{colSpan:4,children:e.label})},`${a}:${e.label}`):(0,R.jsxs)(L.Fragment,{children:[(0,R.jsxs)(`tr`,{className:X[e.kind],children:[(0,R.jsx)(`td`,{className:X.lineNumber,children:e.deletion?.number}),(0,R.jsx)(`td`,{className:X.deletionCode,children:e.deletion===void 0?null:Qt(e.deletion.content,t,e.deletion.number,`deletions`,i)}),(0,R.jsx)(`td`,{className:X.lineNumber,children:e.addition?.number}),(0,R.jsx)(`td`,{className:X.additionCode,children:e.addition===void 0?null:Qt(e.addition.content,t,e.addition.number,`additions`,i)})]}),tn(n,t,e,r)]},`${a}:${e.deletion?.number??``}:${e.addition?.number??``}`))})}),rn=(e,t,n,r)=>[...n.deletionNumber===void 0?[]:[Wt(n.deletionNumber,`deletions`)],...n.additionNumber===void 0?[]:[Wt(n.additionNumber,`additions`)]].flatMap(({lineNumber:n,side:i})=>en(e,t,n,i).map(e=>(0,R.jsx)(`tr`,{className:X.annotationRow,children:(0,R.jsx)(`td`,{className:X.annotationCell,colSpan:4,children:(0,R.jsx)(Ht,{annotation:e,className:Rt(X,`annotation`),returnFocus:()=>$t(r(),t,n,i)})})},e.id))),an=(e,t,n,r,i)=>(0,R.jsx)(`table`,{"aria-label":`Changes in ${e.name}`,className:X.table,children:(0,R.jsx)(`tbody`,{children:Zt(e).map((e,a)=>e.kind===`hunk`?(0,R.jsx)(`tr`,{className:X.hunk,children:(0,R.jsx)(`td`,{colSpan:4,children:e.label})},`${a}:${e.label}`):(0,R.jsxs)(L.Fragment,{children:[(0,R.jsxs)(`tr`,{className:X[e.kind],children:[(0,R.jsx)(`td`,{className:X.lineNumber,children:e.deletionNumber}),(0,R.jsx)(`td`,{className:X.lineNumber,children:e.additionNumber}),(0,R.jsx)(`td`,{className:X.marker,children:e.kind===`addition`?`+`:e.kind===`deletion`?`−`:` `}),(0,R.jsx)(`td`,{children:Qt(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)})]}),rn(n,t,e,r)]},`${a}:${e.deletionNumber??``}:${e.additionNumber??``}`))})}),on=({annotations:e=[],className:t,empty:n=`No renderable source changes.`,initialItems:r,mode:i=`split`,wrap:a=!1})=>{Ut(e);let o=(0,L.useRef)(null);return r.length===0?(0,R.jsx)(`p`,{className:t,children:n}):(0,R.jsx)(`div`,{ref:o,className:t===void 0?Rt(X,`root`):`${Rt(X,`root`)} ${t}`,"data-rly-diff-code-view":``,"data-rly-diff-mode":i,children:r.map(t=>{let n=qt(t);return n===void 0?(0,R.jsx)(`p`,{className:X.noChanges,children:`No textual changes in this file.`},t.id):(0,R.jsxs)(`section`,{className:X.file,children:[r.length>1?(0,R.jsx)(`h3`,{className:X.fileName,children:n.name}):null,(0,R.jsx)(`div`,{className:X.scroller,children:i===`split`?nn(n,t.id,e,()=>o.current,a):an(n,t.id,e,()=>o.current,a)})]},t.id)})})},sn={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`},Z=e=>ue(sn,e),cn=e=>e.state===`ready`?`Ready`:e.state===`loading`?C(e.label,`DiffFileTree loading label`):`${e.state}: ${C(e.reason,`DiffFileTree ${e.state} reason`)}`,ln=e=>e.split(`/`).map(e=>e!==e.trim()||/[\t\n\v\f\r]/u.test(e)?JSON.stringify(e):e).join(`/`),un=(e,t)=>{if(e.length===0)throw Error(`${t} must not be empty`);return e},dn={added:I,deleted:je,modified:Oe,renamed:Ae},fn=e=>{let t=new Set;for(let n of e.files){let e=C(n.id,`DiffFileTree file id`);if(t.has(e))throw Error(`DiffFileTree file ids must be unique: ${e}`);t.add(e);let r=un(n.path,`DiffFileTree path for ${e}`);if(n.change===`renamed`&&un(n.previousPath,`DiffFileTree previousPath for ${e}`)===r)throw Error(`DiffFileTree renamed paths must differ: ${e}`);cn(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`&&C(e.label,`DiffFileTree loading label`),e.state===`error`&&(C(e.title,`DiffFileTree error title`),C(e.description,`DiffFileTree error description`))}},pn=e=>{if(e.children.length!==1||e.children[0]?.kind!==`directory`)return e;let t=e.children[0];return pn({...t,name:`${e.name}/${t.name}`})},mn=(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])=>pn({children:mn(n,t+1),fileCount:n.length,kind:`directory`,name:e,path:n[0].segments.slice(0,t+1).join(`/`)})),...n]},hn=e=>{let t=e.split(`/`);return new Set(t.slice(0,-1).map((e,n)=>t.slice(0,n+1).join(`/`)))},gn=({className:e,data:t,heading:n,onSelectedFileChange:r,selectedFileId:i,...a})=>{let o=C(n,`DiffFileTree heading`);if(fn(t),i!==void 0&&!t.files.some(e=>e.id===i))throw Error(`DiffFileTree selectedFileId is not in the visible inventory: ${i}`);let s=`rly-diff-file-tree-${(0,L.useId)()}`,c=t.state===`ready`?t.files.length:t.indexedCount,l=t.state===`ready`?t.files.length:t.totalCount,u=(0,L.useMemo)(()=>mn(t.files.map(e=>({file:e,segments:e.path.split(`/`)}))),[t.files]),[d,f]=(0,L.useState)(()=>new Set),p=t.files.find(({id:e})=>e===i)?.path;(0,L.useEffect)(()=>{if(p===void 0)return;let e=hn(p);f(t=>[...t].some(t=>e.has(t))?new Set([...t].filter(t=>!e.has(t))):t)},[p]);let m=e=>e.map(e=>{if(e.kind===`file`){let t=i===e.file.id,n=dn[e.file.change],a=e.file.content.state===`ready`?null:cn(e.file.content);return(0,R.jsx)(`li`,{"data-rly-diff-file-id":e.file.id,children:(0,R.jsxs)(`button`,{"aria-current":t?`true`:void 0,"aria-label":`${ln(e.file.path)}, ${e.file.change}, ${cn(e.file.content)}`,className:Z(`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,R.jsxs)(`span`,{className:Z(`pathBlock`),style:{paddingInlineStart:`var(--rly-space-20)`},children:[e.file.change===`renamed`?(0,R.jsx)(`span`,{className:Z(`previousPath`),children:ln(e.file.previousPath)}):null,(0,R.jsx)(`code`,{className:Z(`path`),children:ln(e.name)})]}),(0,R.jsxs)(`span`,{className:Z(`statusIcons`),children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:Z(`statusIcon`),title:e.file.change,children:(0,R.jsx)(n,{})}),a===null?null:(0,R.jsx)(`span`,{"aria-hidden":`true`,className:Z(`statusIcon`),title:a,children:e.file.content.state===`loading`?(0,R.jsx)(le,{className:Z(`loadingIcon`)}):(0,R.jsx)(A,{})})]})]})},e.file.id)}let t=!d.has(e.path);return(0,R.jsxs)(`li`,{className:Z(`directory`),"data-rly-diff-directory":e.path,children:[(0,R.jsxs)(`button`,{"aria-expanded":t,"aria-label":`${ln(e.name)}, directory, ${e.fileCount} changed ${e.fileCount===1?`file`:`files`}`,className:Z(`directoryButton`),onClick:()=>f(n=>{let r=new Set(n);return t?r.add(e.path):r.delete(e.path),r}),type:`button`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:Z(`chevron`)}),(0,R.jsx)(`code`,{className:Z(`directoryName`),children:ln(e.name)}),(0,R.jsx)(`span`,{className:Z(`directoryCount`),children:e.fileCount})]}),t?(0,R.jsx)(`ol`,{className:Z(`group`),style:{marginInlineStart:`var(--rly-space-16)`},children:m(e.children)}):null]},`directory:${e.path}`)});return(0,R.jsxs)(`nav`,{...a,"aria-busy":t.state===`loading`?`true`:void 0,"aria-labelledby":s,className:N(Z(`root`),e),"data-rly-diff-inventory-state":t.state,children:[(0,R.jsxs)(`header`,{className:Z(`header`),children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:Z(`eyebrow`),children:`Changed files`}),(0,R.jsx)(`h2`,{id:s,children:o})]}),(0,R.jsxs)(`strong`,{"aria-label":`${c} of ${l} files indexed`,className:Z(`count`),children:[c,`/`,l]})]}),t.state===`loading`?(0,R.jsx)(`p`,{className:Z(`notice`),role:`status`,children:t.label}):null,t.state===`error`?(0,R.jsxs)(`section`,{className:Z(`error`),role:`alert`,children:[(0,R.jsx)(`strong`,{children:t.title}),(0,R.jsx)(`span`,{children:t.description})]}):null,t.files.length===0?(0,R.jsx)(`p`,{className:Z(`empty`),children:`No changed files.`}):(0,R.jsx)(`ol`,{className:Z(`list`),children:m(u)})]})},_n=m([`pending`,`posting`,`posted`,`posted-stale`,`acknowledged`,`rejected`,`failed`]),vn=(e,t)=>({...t,turns:e}),yn=(e,t,n)=>{if(e===null)return n;let r=new Map(t.result.findings.map(e=>[e.id,Sn(e)])),i=new Map(e.result.findings.map(e=>[e.id,Sn(e)]));return n.filter(({findingId:e})=>{if(e===`PR`)return!0;let t=i.get(e);return t!==void 0&&t===r.get(e)})},bn=(e,t,n)=>{let r=e[t];return r===`posting`||r===`posted`||r===`posted-stale`?e:{...e,[t]:n}},xn=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}},wn=(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()},Tn=(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]}))},En=class extends d(`RelayReviewTransportError`){},Dn=ee(n(P)),On=async(e,t,n,r)=>{let i=await we;if(i._tag===`Failed`)throw new En({message:i.message});let a=Ee(),o={method:`POST`,credentials:`same-origin`,headers:a===null?{"content-type":`application/json`}:{"content-type":`application/json`,"x-csrf-token":a},body:JSON.stringify(t)};r!==void 0&&(o.signal=r);let s=await window.fetch(e,o);if(!s.ok){let e=(await s.text()).slice(0,2e3).trim();throw new En({message:e.length===0?`Relay request failed with status ${s.status}`:e})}if(s.body===null)throw new En({message:`Relay returned no progress stream`});let c=s.body.getReader(),l=new TextDecoder,u=``,d=!1,f=async e=>{if(e.trim().length!==0)try{let t=await Dn(e);if(d)throw new En({message:`Relay returned frames after the terminal event`});d=t.type===`complete`||t.type===`error`,n(t)}catch(e){throw _(e,`RelayReviewTransportError`)?e:new En({message:S(e)?e.message:`Relay returned malformed progress`})}};try{for(;;){let e=await c.read();u+=l.decode(e.value,{stream:!e.done});let t=u.split(`
|
|
21
|
+
`);u=t.pop()??``;for(let e of t)await f(e);if(e.done)break}if(await f(u),!d)throw new En({message:`Relay progress stream ended before a terminal event`})}finally{await c.cancel().catch(()=>void 0),c.releaseLock()}},kn=l({accountKind:s(m([`credential`,`repository`])),accountId:o.check(x(),y()),pullRequestId:o.check(x(),y()),region:o.check(x(),y()),repositoryName:o.check(x(),y())}),An=l({identity:o,resource:kn,review:oe,skillIds:r,turns:v,dispositions:g(o,_n),version:p.check(c(0))}),jn=F(n(An)),Q=class extends d(`RelayReviewSessionStorageUnavailable`){},Mn=class extends d(`RelayReviewSessionInvalid`){},Nn=class extends d(`RelayReviewSessionResourceMismatch`){},Pn=class extends d(`RelayReviewSessionMigrationAmbiguous`){},Fn=e=>Object.entries(e).reduce((e,[t,n])=>({...e,[t]:n===`posting`?`failed`:n}),{}),In=e=>Object.values(e.dispositions).some(e=>e===`posting`),Ln=(e,t)=>e.accountId===t.accountId&&e.pullRequestId===t.pullRequestId&&e.region===t.region&&e.repositoryName===t.repositoryName,Rn=e=>{switch(e){case`pending`:return 0;case`acknowledged`:case`failed`:case`rejected`:return 1;case`posting`:return 2;case`posted-stale`:return 3;case`posted`:return 4}},zn=(e,t)=>Object.entries(t).reduce((e,[t,n])=>{let r=e[t];return r!==void 0&&Rn(r)>Rn(n)?e:{...e,[t]:n}},e),Bn=(e,t)=>{let n=new Set(e.map(Vn));return t.reduce((e,t)=>{let r=Vn(t);return n.has(r)?e:(n.add(r),wn(e,t))},e)},Vn=e=>e.id??JSON.stringify(e),Hn=(e,t)=>Bn(yn(e.review,t.review,e.turns),yn(t.review,e.review,t.turns)),Un=(e,t)=>{let n=yn(t.review,e.review,t.turns),r=new Set(e.turns.map(Vn)),i=new Set(t.turns.map(Vn)),a=e.turns.at(-1),o=t.turns.at(-1),s=t.turns.some(e=>r.has(Vn(e))),c=o!==void 0&&r.has(Vn(o)),l=a!==void 0&&i.has(Vn(a)),u=s&&c&&!l;if(!s&&e.turns.length>0&&t.turns.length>0){let r=new Set(t.appendedTurnIds??[]);return n.filter(e=>r.has(Vn(e))).reduce((e,t)=>wn(e,t),e.turns)}return u?[]:n},Wn=(e,t)=>{let n=new Map(e.review.result.findings.map(e=>[e.id,JSON.stringify(e)])),r=new Map(t.review.result.findings.map(e=>[e.id,JSON.stringify(e)]));return Object.entries(t.dispositions).reduce((e,[t,i])=>{let a=n.get(t),o=r.get(t);return a!==void 0&&a===o?{...e,[t]:i}:e},{})},Gn=(e,t,n)=>({dispositions:e.dispositions,identity:e.identity,resource:e.resource,review:e.review,skillIds:e.skillIds,turns:t,version:n}),Kn=`codecommit:relay-review-session`,qn=f(`RelayReviewSessionRedirect`,{targetIdentity:o,targetKey:o,targetResource:kn}),Jn=e=>`${e}:redirect`,Yn=(e,t)=>{let r=te({try:()=>e.getItem(Jn(t)),catch:()=>new Q({operation:`read`})});if(u(r))return k(r.failure);if(r.success===null)return ne(null);let i=F(n(qn))(r.success);return u(i)?k(new Mn):ne(i.success)},Xn=(e,t,n)=>{let r=er(e,t,n.resource);if(u(r))return k(r.failure);let i=r.success===null?{_tag:`stored`,session:Gn(n,n.turns,1)}:Zn(r.success,n),a=JSON.stringify(i.session),o=te({try:()=>{e.setItem(t,a)},catch:()=>new Q({operation:`write`})});if(u(o))return k(o.failure);let s=te({try:()=>e.getItem(t),catch:()=>new Q({operation:`write`})});return u(s)?k(s.failure):s.success===a?ne(i):k(new Q({operation:`write`}))},Zn=(e,t)=>{if(t.expectedVersion!==e.version){let n=zn(e.dispositions,Wn(e,t));return{_tag:`stale-review-preserved`,session:{...e,dispositions:n,turns:Bn(e.turns,Un(e,t)),version:e.version+1}}}let n=e.identity===t.identity,r=e.identity===t.expectedIdentity;if(n||r)return{_tag:`stored`,session:Gn(t,Hn(e,t),e.version+1)};let i=zn(e.dispositions,Wn(e,t));return{_tag:`stale-review-preserved`,session:{...e,dispositions:i,turns:Bn(e.turns,Un(e,t)),version:e.version+1}}},Qn=e=>`codecommit:relay-review-session:${encodeURIComponent(e.accountId)}:${encodeURIComponent(e.repositoryName)}:${encodeURIComponent(e.region)}:${encodeURIComponent(e.pullRequestId)}`,$n=(e,t)=>`${e.accountId}:${e.repositoryName}:${e.region}:${e.pullRequestId}:${t.revisionId}:${t.baseCommit}:${t.headCommit}`,er=(e,t,n)=>{let r=te({try:()=>e.getItem(t),catch:()=>new Q({operation:`read`})});if(u(r))return k(r.failure);if(r.success===null)return ne(null);let i=jn(r.success);return u(i)?k(new Mn):Ln(i.success.resource,n)?ne({...i.success,dispositions:i.success.dispositions}):k(new Nn)},tr=(e,t)=>`${Kn}:publication:${encodeURIComponent(e)}:${encodeURIComponent(t)}`,nr=async(e,t,n,r)=>{let i=er(e,t,n);if(u(i)||i.success===null||!In(i.success))return i;let a=Object.entries(i.success.dispositions).filter(([,e])=>e===`posting`).map(([e])=>e).sort().reduceRight((e,n)=>()=>r.request(tr(t,n),e),()=>r.request(Kn,async()=>{let r=er(e,t,n);if(u(r)||r.success===null||!In(r.success))return r;let i=Xn(e,t,{dispositions:Fn(r.success.dispositions),expectedIdentity:r.success.identity,expectedVersion:r.success.version,identity:r.success.identity,resource:n,review:r.success.review,skillIds:r.success.skillIds,turns:r.success.turns});return u(i)?k(i.failure):ne(i.success.session)}));try{return await a()}catch{return k(new Q({operation:`write`}))}},rr=async(e,t,n,r)=>{try{return await r.request(Kn,async()=>{let r=Yn(e,t);return u(r)?k(r.failure):r.success===null?Xn(e,t,n):Xn(e,r.success.targetKey,{...n,resource:r.success.targetResource})})}catch{return k(new Q({operation:`write`}))}},ir=async(e,t,n,r,i,a)=>{try{return await a.request(Kn,async()=>{let a=er(e,t,n);if(u(a)||a.success===null)return a;if(a.success.resource.accountKind!==`credential`||i.accountKind!==`repository`)return k(new Pn);let o=er(e,r,i);if(u(o))return k(o.failure);let s=$n(i,a.success.review),c=Xn(e,r,{dispositions:a.success.dispositions,expectedIdentity:s,expectedVersion:o.success===null?0:Math.max(0,o.success.version-1),identity:s,resource:i,review:a.success.review,skillIds:a.success.skillIds,turns:a.success.turns});if(u(c))return k(c.failure);let l={_tag:`RelayReviewSessionRedirect`,targetIdentity:s,targetKey:r,targetResource:i},d=te({try:()=>e.setItem(Jn(t),JSON.stringify(l)),catch:()=>new Q({operation:`write`})});return u(d)?k(d.failure):ne(c.success.session)})}catch{return k(new Q({operation:`write`}))}},$={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`},ar=[{kind:`review`,label:`Full review`,description:`Correctness, security, and maintainability`,icon:De},{kind:`security`,label:`Security`,description:`Trust boundaries and unsafe inputs`,icon:e},{kind:`tests`,label:`Tests`,description:`Missing behavioral guardrails`,icon:Ne},{kind:`explain`,label:`Explain`,description:`Architecture and merge risks`,icon:ke}],or=5e3,sr=4e6,cr=524288,lr=new TextEncoder,ur=e=>`?repositoryName=${encodeURIComponent(String(e.repositoryName))}®ion=${encodeURIComponent(String(e.account.region))}`,dr=()=>`locks`in window.navigator?{request:(e,t)=>window.navigator.locks.request(e,()=>t())}:null,fr=(e,t,n)=>JSON.stringify({completedReview:e,dispositions:n,turns:t}),pr=e=>Object.values(e).some(e=>e===`posting`),mr=e=>{if(e.length===0)return 0;let t=1;for(let n of e)n===`
|
|
22
|
+
`&&t++;return t},hr=(e,t)=>{if(lr.encode(e).byteLength+lr.encode(t).byteLength>cr)return!0;let n=mr(e),r=mr(t);return n+r>or||n*r>sr},gr=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,_r=e=>e===`P1`||e===`P2`?`critical`:e===`P3`?`caution`:`neutral`,vr=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}`}},yr=l({message:o}),br=b(yr);function xr(e,t){return br(e)?e.message:t}var Sr=(e,t)=>t?`Previous result retained. The latest rerun failed. ${e}`:e,Cr=(e,t,n)=>t===null?n:e.find(({id:e})=>e===t),wr=(e,t,n,r,i)=>`${e}:${n}:${r}:${t}:${i.revisionId}:${i.baseCommit}:${i.headCommit}`,Tr=e=>e.repoAccountId!==void 0&&e.repoAccountId.length>0?e.repoAccountId:e.awsAccountId!==void 0&&e.awsAccountId.length>0?e.awsAccountId:e.profile,Er=(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},Dr=(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},Or=(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,R.jsxs)(`aside`,{className:$.lineFinding,children:[(0,R.jsxs)(`strong`,{children:[e.priority,` · `,e.title]}),(0,R.jsx)(`span`,{children:e.summary})]})}]:[]}),kr=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)}…`},Ar=({active:e,onNavigateToComment:t,target:n})=>{let r=(0,L.useRef)(null);return(0,L.useEffect)(()=>{!e||r.current===null||(r.current.scrollIntoView({behavior:`smooth`,block:`center`}),r.current.focus({preventScroll:!0}))},[e]),(0,R.jsxs)(`aside`,{className:$.lineComment,"data-active":e?`true`:void 0,ref:r,tabIndex:-1,children:[(0,R.jsxs)(`span`,{className:$.lineCommentMeta,children:[(0,R.jsx)(Me,{"aria-hidden":`true`}),(0,R.jsx)(`strong`,{children:n.author}),(0,R.jsx)(`span`,{children:`CodeCommit comment`})]}),(0,R.jsx)(`span`,{children:kr(n.content)}),(0,R.jsx)(`button`,{onClick:()=>t(n),type:`button`,children:`View in comments`})]})},jr=(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,R.jsx)(Ar,{active:n===e.commentId,onNavigateToComment:r,target:e})}]:[]}),Mr=({accountId:e,activeCommentId:n,baseCommit:r,comments:a,file:o,findings:s,headCommit:c,layout:l,onContentStateChange:u,onNavigateToComment:d,pullRequestId:f,region:p,repositoryName:m,revisionId:g,wrap:_})=>{let ee=(0,L.useMemo)(()=>re.query(`prs`,`diffContent`,{params:{awsAccountId:e,prId:f,fileIndex:o.index},query:{baseCommit:r,headCommit:c,region:p,repositoryName:m,revisionId:g},timeToLive:`10 seconds`}),[e,r,o.index,c,f,p,m,g]),v=i(ee),y=h(v)?`error`:t(v)?v.value.state===`text`?v.value.before!==null&&v.value.after!==null&&hr(v.value.before,v.value.after)?`complexity`:`ready`:v.value.state:null;if((0,L.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]),me(v)||T(v))return(0,R.jsx)(E,{announce:`polite`,description:`Reading both immutable sides of ${o.path}.`,title:`Loading file diff`,tone:`progress`});if(h(v))return(0,R.jsx)(E,{announce:`polite`,description:xr(v.cause,`Reload the pull request to retry this exact file.`),title:`File diff unavailable`,tone:`critical`});if(!t(v))return(0,R.jsx)(E,{description:`Reload the pull request to retry.`,title:`File diff unavailable`,tone:`critical`});if(v.value.state!==`text`||v.value.before===null||v.value.after===null)return(0,R.jsx)(E,{description:v.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:v.value.state===`binary`?`Binary change`:`File too large`,tone:`neutral`});if(hr(v.value.before,v.value.after))return(0,R.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:`${g}:${String(o.index)}:before`,contents:v.value.before,name:o.previousPath??o.path},after:{cacheKey:`${g}:${String(o.index)}:after`,contents:v.value.after,name:o.path}};return(0,R.jsx)(on,{annotations:[...Or(s,o),...jr(a,o,n,d)],className:$.codeView??``,initialItems:[b],mode:l,wrap:_})},Nr=({canPost:e,dispositions:t,isReviewing:n,onAcknowledge:r,onPost:i,onReject:a,onSelect:o,review:s,selectedFindingId:c})=>n?(0,R.jsxs)(`div`,{"aria-live":`polite`,className:$.agentEmpty,children:[(0,R.jsx)(le,{"aria-hidden":`true`,className:$.agentSpinner}),(0,R.jsx)(D,{as:`h3`,variant:`card-title`,children:`Relay is reviewing`}),(0,R.jsx)(D,{tone:`secondary`,children:`Live stages are updating above. Findings will appear here when the run completes.`})]}):s===null?(0,R.jsxs)(`div`,{className:$.agentEmpty,children:[(0,R.jsx)(De,{"aria-hidden":`true`}),(0,R.jsx)(D,{as:`h3`,variant:`card-title`,children:`Relay is ready`}),(0,R.jsx)(D,{tone:`secondary`,children:`Choose a focus, then run a prompt-only review over this exact CodeCommit revision.`})]}):s.kind===`explain`&&s.result.explanation!==void 0?(0,R.jsxs)(`div`,{className:$.agentEmpty,children:[(0,R.jsx)(ke,{"aria-hidden":`true`}),(0,R.jsx)(D,{as:`h3`,variant:`card-title`,children:`Change explanation`}),(0,R.jsx)(D,{children:s.result.explanation}),(0,R.jsx)(D,{tone:`secondary`,children:s.result.verdict})]}):s.result.findings.length===0?(0,R.jsxs)(`div`,{className:$.agentEmpty,children:[(0,R.jsx)(ve,{"aria-hidden":`true`}),(0,R.jsx)(D,{as:`h3`,variant:`card-title`,children:`No actionable findings`}),(0,R.jsx)(D,{tone:`secondary`,children:s.result.verdict})]}):(0,R.jsxs)(`section`,{"aria-label":`Findings`,className:$.findingDeck,children:[(0,R.jsx)(D,{as:`p`,className:$.verdictCopy,children:s.result.verdict}),(0,R.jsx)(`ol`,{children:s.result.findings.map(n=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(`article`,{className:$.findingCard,"data-selected":c===n.id?`true`:void 0,children:[(0,R.jsxs)(`button`,{className:$.findingBody,onClick:()=>o(n),type:`button`,children:[(0,R.jsxs)(`span`,{className:$.findingMeta,children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(se,{label:n.priority,size:`compact`,tone:_r(n.priority)}),(0,R.jsx)(`code`,{children:vr(n)})]}),(0,R.jsx)(se,{label:t[n.id]??`pending`,size:`compact`,tone:t[n.id]===`failed`||t[n.id]===`posted-stale`?`caution`:`neutral`})]}),(0,R.jsx)(`strong`,{children:n.title}),(0,R.jsx)(`span`,{children:n.summary})]}),(0,R.jsxs)(`details`,{className:$.findingDetails,children:[(0,R.jsx)(`summary`,{children:`Evidence & recommendation`}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`b`,{children:`Evidence`}),n.details]}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`b`,{children:`Recommendation`}),n.recommendation]}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`b`,{children:`Verification`}),n.verification]})]})]}),(0,R.jsxs)(`div`,{className:$.findingActions,children:[(0,R.jsx)(xe,{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,R.jsxs)(`button`,{disabled:t[n.id]===`posting`||t[n.id]===`posted`||t[n.id]===`posted-stale`,onClick:()=>r(n),type:`button`,children:[(0,R.jsx)(ve,{}),` Ack`]}),(0,R.jsxs)(`button`,{disabled:t[n.id]===`posting`||t[n.id]===`posted`||t[n.id]===`posted-stale`,onClick:()=>a(n),type:`button`,children:[(0,R.jsx)(M,{}),` Reject`]})]})]})},n.id))})]}),Pr=({accountId:e,commentNavigation:n,comments:r,diff:o,diffFailure:s,onFindingPosted:c,onNavigateToComment:l,pullRequest:d})=>{let f=ce(),[p,m]=(0,L.useState)(o.files[0]?.index??null),[g,_]=(0,L.useState)(null),[ee,v]=(0,L.useState)(null),[y,x]=(0,L.useState)(`split`),[te,ne]=(0,L.useState)(!1),S=i(de),[oe,C]=(0,L.useState)(null),le=(0,L.useMemo)(()=>re.mutation(`prs`,`postRelayFinding`),[]),ue=a(le,{mode:`promise`}),w=wr(Tr(d.account),d.id,String(d.repositoryName),String(d.account.region),o),T=(0,L.useMemo)(()=>{let e=(d.account.repoAccountId!==void 0&&d.account.repoAccountId.length>0?d.account.repoAccountId:void 0)??(d.account.awsAccountId!==void 0&&d.account.awsAccountId.length>0?d.account.awsAccountId:void 0);return e===void 0?null:{accountKind:ge(d.account),accountId:e,pullRequestId:String(d.id),region:String(d.account.region),repositoryName:String(d.repositoryName)}},[d.account.awsAccountId,d.account.region,d.account.repoAccountId,d.id,d.repositoryName]),me=(0,L.useMemo)(()=>{let e=d.account.awsAccountId,t=d.account.repoAccountId;return e===void 0||t===void 0||e===t?null:{accountKind:`credential`,accountId:e,pullRequestId:String(d.id),region:String(d.account.region),repositoryName:String(d.repositoryName)}},[d.account.awsAccountId,d.account.repoAccountId,d.account.region,d.id,d.repositoryName]),[he,ve]=(0,L.useState)(()=>({identity:w,values:new Map})),O=T===null?null:Qn(T),k=me===null?null:Qn(me),be=(0,L.useRef)(O);be.current=O;let A=(0,L.useRef)(`idle`),j=(0,L.useRef)(0),M=(0,L.useRef)(null),N=(0,L.useRef)(null),Ce=(0,L.useRef)(null),we=(0,L.useRef)(void 0),[P,Ee]=(0,L.useState)(null),F=(0,L.useRef)(P);F.current=P;let[Oe,I]=(0,L.useState)(null),[ke,Ae]=(0,L.useState)(null),[je,Ne]=(0,L.useState)(null),[z,Pe]=(0,L.useState)(!1),[Fe,Ie]=(0,L.useState)([]),[Le,B]=(0,L.useState)([]),Re=(0,L.useRef)([]);Re.current=Le;let[ze,Be]=(0,L.useState)(``),[V,H]=(0,L.useState)({}),[Ve,U]=(0,L.useState)(!0),W=(0,L.useRef)(V);W.current=V;let He=(0,L.useRef)(null),G=P?.value??null,K=P!==null&&P.identity!==w,Ue=t(S)?S.value.review.profiles:[],We=!t(S)&&!h(S),q=Cr(Ue,oe,t(S)?Ue.find(e=>e.id===S.value.review.defaultProfileId)??Ue[0]:void 0),Ge=ee??q?.kind??`review`,J=o.files.find(({index:e})=>e===p)??o.files[0],Ke=J===void 0?null:gr(J),qe=he.identity===w?he.values:new Map,Je={files:o.files.map(e=>Dr(e,qe.get(e.index)??{state:`ready`})),state:`ready`},Ye=(0,L.useCallback)(async e=>{let t=F.current;if(t===null||T===null||O===null)return!0;let n=dr();if(n===null)return!0;let r=await rr(window.localStorage,O,{dispositions:e,expectedIdentity:t.expectedIdentity,expectedVersion:j.current,identity:t.identity,resource:T,review:t.value,skillIds:t.skillIds,turns:Re.current},n);return u(r)?(I({description:`Local storage is unavailable. Relay could not durably retain this PR conversation.`,title:`PR conversation not saved`}),!1):(j.current=r.success.session.version,!0)},[T,O]),Xe=(0,L.useCallback)(async()=>{let e=F.current;if(e===null||T===null||O===null)return!0;let t=dr();if(t===null)return I({description:`This browser cannot coordinate Relay writes across tabs. Relay did not save this PR conversation.`,title:`PR conversation not saved`}),!1;let n=await rr(window.localStorage,O,{dispositions:W.current,expectedIdentity:e.expectedIdentity,expectedVersion:j.current,identity:e.identity,resource:T,review:e.value,skillIds:e.skillIds,turns:Re.current},t);return u(n)?(I({description:`Local storage is unavailable. Relay could not durably retain this PR conversation.`,title:`PR conversation not saved`}),!1):(j.current=n.success.session.version,N.current={fingerprint:fr(e,Re.current,W.current),key:O,pendingInitialPass:!1},n.success._tag===`stale-review-preserved`&&n.success.session.identity!==e.identity?(I({description:`A newer exact-head review remains current. This tab's conversation turn was retained there.`,title:`Newer PR review preserved`}),!1):!0)},[T,O]);(0,L.useEffect)(()=>{if(O!==null&&Ce.current===O){Ce.current=null;return}if(!t(S)||oe!==null)return;let e=S.value.review.profiles.find(({id:e})=>e===S.value.review.defaultProfileId)??S.value.review.profiles[0];e!==void 0&&C(e.id)},[S,O,oe]),(0,L.useEffect)(()=>()=>He.current?.abort(),[]),(0,L.useEffect)(()=>{if(n?.destination!==`diff`)return;if(!_e(n.target,o)){Ne(`This comment belongs to an older CodeCommit revision and cannot be placed on the current diff.`);return}let e=Se(o.files,n.target);if(e===void 0){Ne(`The comment's file is not present in the current changed-file inventory.`);return}Ne(null),m(e),_(null)},[n,o]),(0,L.useEffect)(()=>{if(A.current=`idle`,Ae(null),T===null||O===null){Ce.current=null,M.current=null,N.current=null,j.current=0,I({description:`CodeCommit has not resolved a stable AWS account identity for this pull request.`,title:`PR conversation unavailable`});return}Ce.current=null;let e=er(window.localStorage,O,T);if(u(e)){M.current=null,N.current=null,j.current=0,I({description:e.failure._tag===`RelayReviewSessionInvalid`?`The saved PR conversation is invalid. Clear this site's local data before starting a new review.`:`Local storage is unavailable. Relay cannot durably retain this PR conversation.`,title:`PR conversation unavailable`});return}let t=e.success,n=!1;if(t===null&&me!==null&&k!==null){let e=er(window.localStorage,k,me);if(u(e)){I({description:e.failure._tag===`RelayReviewSessionInvalid`?`The saved PR conversation is invalid. Clear this site's local data before starting a new review.`:`Local storage is unavailable. Relay cannot durably retain this PR conversation.`,title:`PR conversation unavailable`});return}if(t=e.success,n=t!==null,t!==null){if(t.resource.accountKind!==`credential`){A.current=`failed`,Ae({key:O,status:`failed`}),I({description:`Relay cannot safely migrate this legacy PR conversation because its account provenance is ambiguous.`,title:`PR conversation migration unavailable`});return}let e=dr();if(e===null)A.current=`failed`,Ae({key:O,status:`failed`}),I({description:`This browser cannot coordinate Relay writes across tabs. Relay did not migrate this PR conversation.`,title:`PR conversation not saved`});else{A.current=`pending`,Ae({key:O,status:`pending`});let n=$n(T,t.review);ir(window.localStorage,k,me,O,T,e).then(e=>{if(u(e))be.current===O&&(A.current=`failed`,Ae({key:O,status:`failed`}),I({description:`Local storage is unavailable. Relay could not migrate this PR conversation.`,title:`PR conversation not saved`}));else if(e.success!==null){if(be.current===O){if(e.success.identity!==n){let t=vn(e.success.turns,{expectedIdentity:e.success.identity,identity:e.success.identity,skillIds:e.success.skillIds,value:e.success.review});F.current=t,Ee(t),W.current=e.success.dispositions,H(e.success.dispositions),C(e.success.review.profile.id),B(e.success.turns),_(e.success.turns.at(-1)?.findingId??e.success.review.result.findings[0]?.id??null),N.current={fingerprint:fr(t,e.success.turns,e.success.dispositions),key:O,pendingInitialPass:!1}}A.current=`idle`,j.current=e.success.version,Ae(e=>e?.key===O?null:e)}}else be.current===O&&(A.current=`idle`,Ae(e=>e?.key===O?null:e))})}}}if(t===null){if(M.current=O,N.current={fingerprint:fr(null,[],{}),key:O,pendingInitialPass:!0},j.current=0,F.current!==null)return;Ee(null),C(null),B([]),H({}),_(null);return}Ce.current=O,M.current=O,j.current=t.version;let r=n&&T!==null?$n(T,t.review):t.identity,i=vn(t.turns,{expectedIdentity:r,identity:r,skillIds:t.skillIds,value:t.review});F.current=i,W.current=t.dispositions,Ee(i),C(t.review.profile.id),B(t.turns),H(t.dispositions),_(t.turns.at(-1)?.findingId??t.review.result.findings[0]?.id??null),N.current={fingerprint:fr(i,t.turns,t.dispositions),key:O,pendingInitialPass:!0};let a=dr();a!==null&&pr(t.dispositions)&&nr(window.localStorage,O,T??t.resource,a).then(e=>{be.current!==O||u(e)||e.success===null||(j.current=e.success.version,W.current=e.success.dispositions,H(e.success.dispositions),N.current={fingerprint:fr(i,t.turns,e.success.dispositions),key:O,pendingInitialPass:!1})})},[me,k,w,T,O]),(0,L.useEffect)(()=>{let e=N.current;if(e?.key===O){if(e.pendingInitialPass){e.pendingInitialPass=!1;return}if(e.fingerprint===fr(P,Le,V)){N.current=null,M.current===O&&(M.current=null);return}N.current=null}if(O!==null&&M.current===O){M.current=null;return}if(A.current!==`idle`||ke!==null)return;let t=F.current,n=Re.current;if(t===null||t.identity!==w||T===null||O===null)return;let r=dr();if(r===null){I({description:`This browser cannot coordinate Relay writes across tabs. Relay did not save this PR conversation.`,title:`PR conversation not saved`});return}let i=!0,a=we.current,o={expectedIdentity:t.expectedIdentity,expectedVersion:j.current,identity:t.identity,resource:T,review:t.value,skillIds:t.skillIds,turns:n,dispositions:V},s=a===void 0?o:{...o,appendedTurnIds:a};return rr(window.localStorage,O,s,r).then(e=>{if(i){if(we.current===a&&(we.current=void 0),u(e)){I({description:`Local storage is unavailable. Relay could not durably retain this PR conversation.`,title:`PR conversation not saved`});return}if(j.current=e.success.session.version,e.success._tag===`stale-review-preserved`){let n=e.success.session.identity!==t.identity;M.current=O;let r=vn(e.success.session.turns,{expectedIdentity:e.success.session.identity,identity:e.success.session.identity,skillIds:e.success.session.skillIds,value:e.success.session.review});F.current=r,Ee(r),W.current=e.success.session.dispositions,B(e.success.session.turns),H(e.success.session.dispositions),n&&I({description:`A newer exact-head review remains current. This tab's conversation turn was retained there.`,title:`Newer PR review preserved`})}}}),()=>{i=!1}},[P,V,w,T,O,ke,Le]),(0,L.useEffect)(()=>{p!==null&&o.files.some(({index:e})=>e===p)||m(o.files[0]?.index??null)},[o.files,p]);let Ze=(0,L.useCallback)((e,t)=>{ve(n=>{let r=n.identity===w?n.values:new Map,i=r.get(e);return n.identity===w&&i?.state===t.state?n:{identity:w,values:new Map(r).set(e,t)}})},[w]),Qe=(0,L.useCallback)(async(e,t)=>{He.current?.abort();let n=new AbortController;He.current=n,Pe(!0),I(null),Ie([]);let r=Re.current,i=null,a={};try{if(await On(e,t,e=>{if(e.type===`progress`){Ie(t=>[...t,e].slice(-12));return}if(e.type===`error`){i=e.message,I({description:Sr(e.message,F.current!==null),title:`Relay review failed`});return}a.event=e},n.signal),i!==null)return I({description:Sr(i,F.current!==null),title:`Relay review failed`}),{completed:!1};let o=a.event;if(o===void 0)return{completed:!1};let s=F.current?.value.result.findings??[],c=s.length===0?xn(o.review.result.findings):Tn(s,o.review.result.findings,W.current);W.current=c,H(c);let l=vn(yn(F.current?.value??null,o.review,r),{expectedIdentity:F.current?.identity??w,identity:w,skillIds:t.profile.skillIds,value:o.review});return F.current=l,Ee(l),_(e=>e??o.review.result.findings[0]?.id??null),o.reply===void 0?{completed:!0}:{completed:!0,reply:o.reply}}catch(e){return n.signal.aborted||I({description:Sr(xr(e,`Relay could not complete this review.`),F.current!==null),title:`Relay review failed`}),{completed:!1}}finally{He.current===n&&(He.current=null,Pe(!1))}},[w]),$e=(0,L.useCallback)(async()=>{q!==void 0&&(await Qe(`/api/prs/${encodeURIComponent(e)}/${encodeURIComponent(d.id)}/relay-review/stream${ur(d)}`,{revisionId:o.revisionId,baseCommit:o.baseCommit,headCommit:o.headCommit,profile:{...q,kind:Ge}})).completed&&await Xe()&&Be(``)},[e,o.baseCommit,o.headCommit,o.revisionId,d,Xe,Qe,Ge,q]),et=(0,L.useCallback)(async(t,n)=>{if(G===null||K)return K&&I({description:`Re-run Relay against the current exact revision before continuing this conversation.`,title:`Stale PR review`}),{_tag:`failed`};let r=window.crypto.randomUUID(),i={id:r,findingId:t,role:`user`,message:n};if(!b(Te)(i))return I({description:`Shorten the message so it can be retained in this review conversation.`,title:`Message is too large`}),{_tag:`failed`};let a=Re.current,s=await Qe(`/api/prs/${encodeURIComponent(e)}/${encodeURIComponent(d.id)}/relay-review/continue${ur(d)}`,{revisionId:o.revisionId,baseCommit:o.baseCommit,headCommit:o.headCommit,profile:G.profile,currentReview:G.result,turns:a,findingId:t,message:n});if(!s.completed)return{_tag:`failed`};let c=F.current?.turns??a,l=s.reply===void 0?void 0:window.crypto.randomUUID(),u=wn(c,i);if(l===void 0||s.reply===void 0)we.current=[r],B(u);else{let e={id:l,findingId:t,role:`assistant`,message:s.reply};we.current=[r,l],B(wn(u,e))}return Be(``),{_tag:`completed`}},[e,o.baseCommit,o.headCommit,o.revisionId,d,G,K,Qe]),tt=(0,L.useCallback)(async t=>{if(G===null||K)return;let n=async()=>{I(null);let n={...W.current,[t.id]:`posting`};if(W.current=n,H(n),await Ye(n))try{c((await ue({params:{awsAccountId:e,findingId:t.id,prId:d.id},query:{region:d.account.region,repositoryName:d.repositoryName},payload:{revisionId:G.revisionId,baseCommit:G.baseCommit,headCommit:G.headCommit,finding:t}})).operationId);let n=Cn(F.current?.value.result.findings??[],t,W.current,`posted`);W.current=n.dispositions,H(n.dispositions),n.stale&&I({description:`CodeCommit received an older finding snapshot. Re-review before relying on it.`,title:`Finding post needs review`}),await Ye(n.dispositions)}catch(e){let n=Cn(F.current?.value.result.findings??[],t,W.current,`failed`);W.current=n.dispositions,H(n.dispositions),I({description:xr(e,`CodeCommit did not accept this finding.`),title:`Finding post failed`}),await Ye(n.dispositions)}},r=dr();if(r===null||O===null){await n();return}await r.request(tr(O,t.id),n)},[e,c,Ye,ue,d,G,K,O]),nt=(0,L.useCallback)(e=>{_(e.id),U(!1);let t=Er(o.files,e);t!==void 0&&m(t)},[o.files]),rt=G?.result.findings.find(({id:e})=>e===g)??null,Y=rt?.id??(g!==null&&Le.some(({findingId:e})=>e===g)?g:null),it=Y===null?[]:Le.filter(({findingId:e})=>e===Y),at=Fe.slice(-4);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(ye,{accountId:e,continueReview:et,diff:o,isReviewing:z,profile:fe(G,q),pullRequest:d,review:G,reviewIsStale:K,selectedFindingId:Y,turns:Le}),(0,R.jsxs)(ie,{as:`section`,className:$.workspace,padding:`none`,form:`grouped`,children:[(0,R.jsx)(`header`,{className:$.workspaceHeader,children:(0,R.jsxs)(`div`,{children:[(0,R.jsx)(D,{tone:`secondary`,variant:`label`,children:`Exact-revision review`}),(0,R.jsx)(D,{as:`h2`,variant:`section-title`,children:`Diff`}),(0,R.jsxs)(D,{tone:`secondary`,variant:`meta`,children:[o.files.length,` changed `,o.files.length===1?`file`:`files`,` · head`,` `,o.headCommit.slice(0,12)]})]})}),s===null?null:(0,R.jsx)(`div`,{className:$.reviewFailure,children:(0,R.jsx)(E,{announce:`polite`,description:`${s} Showing the last successfully loaded exact revision.`,title:`Latest diff unavailable`,tone:`caution`})}),(0,R.jsxs)(`div`,{className:$.workbench,children:[(0,R.jsx)(gn,{className:$.fileTree,data:Je,heading:`PR ${d.id}`,onSelectedFileChange:e=>{m(Number(e)),_(null)},...J===void 0?{}:{selectedFileId:String(J.index)}}),(0,R.jsxs)(`section`,{"aria-label":`Selected file diff`,className:$.diffPane,children:[(0,R.jsxs)(`header`,{className:$.diffToolbar,children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`code`,{children:J?.path??`No changed file`}),Ke===null?null:(0,R.jsx)(`small`,{children:Ke})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`button`,{"aria-pressed":y===`split`,onClick:()=>x(`split`),type:`button`,children:`Split`}),(0,R.jsx)(`button`,{"aria-pressed":y===`stacked`,onClick:()=>x(`stacked`),type:`button`,children:`Stacked`}),(0,R.jsx)(`button`,{"aria-pressed":te,onClick:()=>ne(e=>!e),type:`button`,children:`Wrap`})]})]}),(0,R.jsx)(`div`,{className:$.diffViewport,children:J===void 0?(0,R.jsx)(E,{description:`CodeCommit reports no changed files for this revision.`,title:`Empty diff`,tone:`neutral`}):(0,R.jsx)(Mr,{activeCommentId:n?.destination===`diff`?n.target.commentId:null,accountId:e,baseCommit:o.baseCommit,comments:r,file:J,findings:K?[]:G?.result.findings??[],headCommit:o.headCommit,layout:y,onContentStateChange:Ze,onNavigateToComment:l,pullRequestId:d.id,region:d.account.region,repositoryName:d.repositoryName,revisionId:o.revisionId,wrap:te},`${o.revisionId}:${o.baseCommit}:${o.headCommit}:${String(J.index)}:${y}:${String(te)}`)})]}),(0,R.jsxs)(`aside`,{"aria-label":`Relay findings`,className:$.agentPane,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`div`,{className:$.agentTitle,children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(De,{"aria-hidden":`true`}),(0,R.jsx)(D,{as:`h2`,variant:`section-title`,children:`Relay`})]}),(0,R.jsx)(`small`,{children:z?`Reviewing the exact revision`:G===null?`Review findings and discuss evidence`:`${String(G.result.findings.length)} actionable ${G.result.findings.length===1?`finding`:`findings`}`})]}),z?(0,R.jsx)(se,{label:`running`,size:`compact`,tone:`progress`}):G===null?null:(0,R.jsx)(se,{label:G.kind,size:`compact`,tone:`progress`})]}),(0,R.jsxs)(`section`,{"aria-label":`Relay controls`,className:$.relayControls,children:[(0,R.jsxs)(`label`,{className:$.profileChoice,children:[(0,R.jsx)(`span`,{children:`Profile`}),(0,R.jsxs)(`select`,{disabled:z||!t(S),onChange:e=>{let t=Ue.find(({id:t})=>t===e.target.value);C(e.target.value),t!==void 0&&v(t.kind)},value:q?.id??``,children:[t(S)&&q===void 0&&oe!==null?(0,R.jsx)(`option`,{value:``,children:`Selected profile unavailable`}):t(S)?null:(0,R.jsx)(`option`,{value:``,children:h(S)?`Profiles unavailable`:`Loading profiles…`}),Ue.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,R.jsx)(xe,{disabled:z||o.files.length===0||q===void 0,loading:z,onClick:()=>void $e(),size:`compact`,variant:`primary`,children:z?`Relay reviewing…`:G===null?`Run Relay`:`Run again`}),z?null:(0,R.jsx)(`div`,{"aria-label":`Relay review focus`,className:$.focusChoices,role:`group`,children:ar.map(e=>{let t=e.icon;return(0,R.jsxs)(`button`,{"aria-pressed":Ge===e.kind,onClick:()=>v(e.kind),title:e.description,type:`button`,children:[(0,R.jsx)(t,{"aria-hidden":`true`}),e.label]},e.kind)})})]}),h(S)?(0,R.jsx)(`div`,{className:$.reviewFailure,children:(0,R.jsx)(E,{action:(0,R.jsx)(xe,{onClick:()=>void f(0),size:`compact`,variant:`secondary`,children:`Reload`}),announce:`assertive`,description:xr(S.cause,`Check the server connection, then reload this page to retry.`),title:`Relay profiles unavailable`,tone:`critical`})}):We?(0,R.jsx)(`div`,{className:$.reviewFailure,children:(0,R.jsx)(E,{announce:`polite`,description:`Loading the configured review methodology before Relay can run.`,title:`Loading Relay profiles`,tone:`progress`})}):null,at.length===0?null:(0,R.jsx)(`ol`,{"aria-label":`Relay progress`,"aria-live":`polite`,className:$.progressRail,children:at.map((e,t)=>(0,R.jsxs)(`li`,{"aria-current":t===at.length-1?`step`:void 0,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`}),(0,R.jsx)(`small`,{children:e.phase}),(0,R.jsx)(`strong`,{children:e.message}),e.detail===void 0?null:(0,R.jsx)(`em`,{children:e.detail})]},`${e.phase}:${String(t)}`))}),K?(0,R.jsxs)(`div`,{className:$.staleReview,children:[(0,R.jsxs)(`span`,{children:[`This finding deck reviewed `,P?.value.headCommit.slice(0,12),`; current head is`,` `,o.headCommit.slice(0,12),`.`]}),(0,R.jsx)(xe,{disabled:z||q===void 0,onClick:()=>void $e(),size:`compact`,variant:`secondary`,children:`Re-review latest`})]}):null,Oe===null?null:(0,R.jsxs)(`div`,{className:$.reviewFailure,children:[Oe.description.startsWith(`Previous result retained.`)?(0,R.jsx)(D,{tone:`secondary`,variant:`label`,children:`Previous result`}):null,(0,R.jsx)(E,{announce:`polite`,description:Oe.description,title:Oe.title,tone:`critical`})]}),je===null?null:(0,R.jsx)(`div`,{className:$.reviewFailure,children:(0,R.jsx)(E,{announce:`polite`,description:je,title:`Comment link unavailable`,tone:`caution`})}),(0,R.jsx)(Nr,{canPost:!K,dispositions:V,isReviewing:z,onAcknowledge:e=>H(t=>bn(t,e.id,`acknowledged`)),onPost:e=>void tt(e),onReject:e=>H(t=>bn(t,e.id,`rejected`)),onSelect:nt,review:G,selectedFindingId:g}),Y===null?null:(0,R.jsxs)(`section`,{"aria-label":`Conversation about ${Y}`,className:$.conversation,"data-collapsed":Ve?`true`:void 0,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(Me,{"aria-hidden":`true`}),(0,R.jsxs)(`span`,{className:$.conversationTitle,children:[(0,R.jsx)(`strong`,{children:rt===null?`Discuss withdrawn finding`:`Discuss finding`}),(0,R.jsx)(`small`,{children:rt===null?`${Y} is no longer in the current deck`:rt.title})]})]}),(0,R.jsxs)(`button`,{"aria-expanded":!Ve,onClick:()=>U(e=>!e),type:`button`,children:[Ve?(0,R.jsx)(pe,{"aria-hidden":`true`}):(0,R.jsx)(ae,{"aria-hidden":`true`}),Ve?`Open`:`Collapse`]})]}),Ve?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{"aria-label":`Conversation history about ${Y}`,"aria-live":`polite`,className:$.conversationHistory,role:`log`,children:it.length===0?(0,R.jsx)(`small`,{children:`Ask Relay to verify, refine, or withdraw this finding.`}):(0,R.jsx)(`ol`,{children:it.map((e,t)=>(0,R.jsxs)(`li`,{"data-role":e.role,children:[(0,R.jsx)(`b`,{children:e.role===`user`?`You`:`Relay`}),e.message]},`${e.role}:${String(t)}`))})}),(0,R.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=ze.trim();t.length>0&&!z&&!K&&et(Y,t)},children:[(0,R.jsx)(`textarea`,{"aria-label":`Message Relay`,disabled:z||K,maxLength:8e3,onChange:e=>Be(e.target.value),placeholder:`Ask Relay about this finding…`,rows:2,value:ze}),(0,R.jsx)(xe,{disabled:z||K||ze.trim().length===0,size:`compact`,type:`submit`,variant:`secondary`,children:`Send`})]})]})]})]})]}),(0,R.jsx)(`footer`,{className:$.workspaceFooter,children:`Relay is advisory. Accept posts immediately; acknowledge and reject stay local to this review session.`})]})]})},Fr=({accountId:e,commentNavigation:n,commentsRefreshGeneration:r,onFindingPosted:a,onNavigateToComment:o,pullRequest:s,refreshGeneration:c})=>{let l=w({pullRequestId:s.id,repositoryName:s.repositoryName,profile:s.account.profile,region:s.account.region,refreshGeneration:r}),u=t(l)?l.value.flatMap(e=>e.comments.flatMap(t=>{if(t.root.deleted)return[];let n=be(e,t.root);return n===null?[]:[n]})):[],d=(0,L.useMemo)(()=>re.query(`prs`,`diff`,{params:{awsAccountId:e,prId:s.id},query:{region:s.account.region,repositoryName:s.repositoryName},serializationKey:`${e}:${s.account.region}:${s.repositoryName}:${s.id}:${s.lastModifiedDate.toISOString()}:${String(c)}`,timeToLive:`30 seconds`}),[e,s.account.region,s.id,s.lastModifiedDate,s.repositoryName,c]),f=i(d),p=`${Tr(s.account)}:${String(s.repositoryName)}:${String(s.account.region)}:${String(s.id)}`,m=(0,L.useRef)(null);t(f)&&(m.current={identity:p,value:f.value});let g=m.current?.identity===p?m.current.value:null,_=t(f)?f.value:g;if((me(f)||T(f))&&_===null)return(0,R.jsx)(E,{announce:`polite`,description:`Indexing every changed file.`,title:`Loading exact diff`,tone:`progress`});let ee=h(f)?xr(f.cause,`Refresh this pull request to retry the CodeCommit diff read.`):null;return h(f)&&_===null?(0,R.jsx)(E,{announce:`polite`,description:xr(f.cause,`Refresh this pull request to retry the CodeCommit diff read.`),title:`Exact diff unavailable`,tone:`critical`}):_===null?(0,R.jsx)(E,{description:`Refresh this pull request to retry.`,title:`Exact diff unavailable`,tone:`critical`}):(0,R.jsx)(Pr,{accountId:e,commentNavigation:n,comments:u.filter(e=>_e(e,_)),diff:_,diffFailure:ee,onFindingPosted:a,onNavigateToComment:o,pullRequest:s},p)};export{Fr as PullRequestReviewWorkspace};
|
package/dist/client/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>codecommit</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-eLkbewLN.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Ds8Muxxv.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="root"></div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Effect, Option, Schema } from "effect";
|
|
2
|
+
export declare const coordinateRouterMaxParamLength = 1024;
|
|
3
|
+
export declare const PullRequestCoordinates: Schema.Struct<{
|
|
4
|
+
readonly accountId: Schema.Trim;
|
|
5
|
+
readonly pullRequestId: Schema.brand<Schema.String, "PullRequestId">;
|
|
6
|
+
readonly repositoryName: Schema.brand<Schema.String, "RepositoryName">;
|
|
7
|
+
readonly region: Schema.brand<Schema.String, "AwsRegion">;
|
|
8
|
+
}>;
|
|
9
|
+
export type PullRequestCoordinates = typeof PullRequestCoordinates.Type;
|
|
10
|
+
declare const PullRequestCoordinateDecodeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
11
|
+
readonly _tag: "PullRequestCoordinateDecodeError";
|
|
12
|
+
} & Readonly<A>;
|
|
13
|
+
export declare class PullRequestCoordinateDecodeError extends PullRequestCoordinateDecodeError_base<{
|
|
14
|
+
readonly message: string;
|
|
15
|
+
}> {
|
|
16
|
+
}
|
|
17
|
+
/** Encode coordinates into a compact URL-safe token for the existing review API path. */
|
|
18
|
+
export declare const encodePullRequestCoordinates: (coordinates: PullRequestCoordinates) => string;
|
|
19
|
+
/** Decode an exact-coordinate token; ordinary account paths remain legacy routes. */
|
|
20
|
+
export declare const decodePullRequestCoordinates: (value: string) => Effect.Effect<Option.Option<PullRequestCoordinates>, PullRequestCoordinateDecodeError>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=pull-request-coordinates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pull-request-coordinates.d.ts","sourceRoot":"","sources":["../src/pull-request-coordinates.ts"],"names":[],"mappings":"AAEA,OAAO,EAAQ,MAAM,EAAY,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAM/D,eAAO,MAAM,8BAA8B,OAAO,CAAA;AAElD,eAAO,MAAM,sBAAsB;;;;;EAiBlC,CAAA;AACD,MAAM,MAAM,sBAAsB,GAAG,OAAO,sBAAsB,CAAC,IAAI,CAAA;;;;AA4BvE,qBAAa,gCAAiC,SAAQ,sCAEpD;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;CAAG;AAElC,yFAAyF;AACzF,eAAO,MAAM,4BAA4B,gBAAiB,sBAAsB,KAAG,MAUlF,CAAA;AAED,qFAAqF;AACrF,eAAO,MAAM,4BAA4B,UAChC,MAAM,KACZ,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,EAAE,gCAAgC,CA8CvF,CAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** Exact CodeCommit PR coordinates carried through browser review requests. @module */
|
|
2
|
+
import { AwsRegion, PullRequestId, RepositoryName } from "@knpkv/codecommit-core/Domain.js";
|
|
3
|
+
import { Data, Effect, Encoding, Option, Schema } from "effect";
|
|
4
|
+
const coordinateTokenPrefix = "cc1_";
|
|
5
|
+
const legacyCoordinateTokenPrefix = "ccpr:";
|
|
6
|
+
const coordinatePart = Schema.Trim.check(Schema.isNonEmpty(), Schema.isMaxLength(180));
|
|
7
|
+
const coordinateAccountId = coordinatePart;
|
|
8
|
+
export const coordinateRouterMaxParamLength = 1024;
|
|
9
|
+
export const PullRequestCoordinates = Schema.Struct({
|
|
10
|
+
accountId: coordinateAccountId,
|
|
11
|
+
pullRequestId: PullRequestId,
|
|
12
|
+
repositoryName: RepositoryName,
|
|
13
|
+
region: AwsRegion
|
|
14
|
+
}).check(Schema.makeFilter((coordinates) => {
|
|
15
|
+
const encoded = Encoding.encodeBase64Url(JSON.stringify([
|
|
16
|
+
coordinates.accountId,
|
|
17
|
+
coordinates.pullRequestId,
|
|
18
|
+
coordinates.repositoryName,
|
|
19
|
+
coordinates.region
|
|
20
|
+
]));
|
|
21
|
+
return encoded.length + coordinateTokenPrefix.length <= coordinateRouterMaxParamLength
|
|
22
|
+
? undefined
|
|
23
|
+
: "Pull-request coordinate token exceeds the router parameter limit";
|
|
24
|
+
}));
|
|
25
|
+
const coordinateTuple = Schema.Tuple([
|
|
26
|
+
coordinatePart,
|
|
27
|
+
coordinatePart,
|
|
28
|
+
coordinatePart,
|
|
29
|
+
coordinatePart
|
|
30
|
+
]);
|
|
31
|
+
const coordinateObject = Schema.Struct({
|
|
32
|
+
accountId: coordinatePart,
|
|
33
|
+
pullRequestId: coordinatePart,
|
|
34
|
+
repositoryName: coordinatePart,
|
|
35
|
+
region: coordinatePart
|
|
36
|
+
});
|
|
37
|
+
const toCoordinates = ({ accountId, pullRequestId, region, repositoryName }) => ({
|
|
38
|
+
accountId,
|
|
39
|
+
pullRequestId: PullRequestId.make(pullRequestId),
|
|
40
|
+
repositoryName: RepositoryName.make(repositoryName),
|
|
41
|
+
region: AwsRegion.make(region)
|
|
42
|
+
});
|
|
43
|
+
export class PullRequestCoordinateDecodeError extends Data.TaggedError("PullRequestCoordinateDecodeError") {
|
|
44
|
+
}
|
|
45
|
+
/** Encode coordinates into a compact URL-safe token for the existing review API path. */
|
|
46
|
+
export const encodePullRequestCoordinates = (coordinates) => {
|
|
47
|
+
const validated = Schema.decodeUnknownSync(PullRequestCoordinates)(coordinates);
|
|
48
|
+
return `${coordinateTokenPrefix}${Encoding.encodeBase64Url(JSON.stringify([
|
|
49
|
+
validated.accountId,
|
|
50
|
+
validated.pullRequestId,
|
|
51
|
+
validated.repositoryName,
|
|
52
|
+
validated.region
|
|
53
|
+
]))}`;
|
|
54
|
+
};
|
|
55
|
+
/** Decode an exact-coordinate token; ordinary account paths remain legacy routes. */
|
|
56
|
+
export const decodePullRequestCoordinates = (value) => {
|
|
57
|
+
if (value.startsWith(legacyCoordinateTokenPrefix)) {
|
|
58
|
+
const encoded = value.slice(legacyCoordinateTokenPrefix.length);
|
|
59
|
+
// A plain profile alias may legally use the historical token prefix. Only
|
|
60
|
+
// reserve values that have the encoded JSON shape of a legacy token; all
|
|
61
|
+
// other values remain ordinary account routes.
|
|
62
|
+
if (!/^(?:%7B|%5B|\{|\[)/iu.test(encoded))
|
|
63
|
+
return Effect.succeed(Option.none());
|
|
64
|
+
return Effect.try({
|
|
65
|
+
try: () => decodeURIComponent(encoded),
|
|
66
|
+
catch: () => new PullRequestCoordinateDecodeError({ message: "Invalid pull-request coordinate token" })
|
|
67
|
+
}).pipe(Effect.flatMap((json) => Schema.decodeUnknownEffect(Schema.fromJsonString(coordinateObject))(json).pipe(Effect.map((coordinates) => Option.some(toCoordinates(coordinates))), Effect.mapError(() => new PullRequestCoordinateDecodeError({ message: "Invalid pull-request coordinates" })))));
|
|
68
|
+
}
|
|
69
|
+
if (!value.startsWith(coordinateTokenPrefix))
|
|
70
|
+
return Effect.succeed(Option.none());
|
|
71
|
+
const encoded = value.slice(coordinateTokenPrefix.length);
|
|
72
|
+
return Effect.fromResult(Encoding.decodeBase64UrlString(encoded)).pipe(Effect.matchEffect({
|
|
73
|
+
// Profile aliases may legitimately begin with the token prefix. A value
|
|
74
|
+
// that is not even base64 is therefore still an ordinary account route.
|
|
75
|
+
onFailure: () => Effect.succeed(Option.none()),
|
|
76
|
+
onSuccess: (json) => Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(json).pipe(Effect.matchEffect({
|
|
77
|
+
// A base64-looking profile alias is still an ordinary account route
|
|
78
|
+
// when its payload is not JSON; a JSON payload must satisfy the
|
|
79
|
+
// coordinate tuple contract below.
|
|
80
|
+
onFailure: () => Effect.succeed(Option.none()),
|
|
81
|
+
onSuccess: (value) => Schema.decodeUnknownEffect(coordinateTuple)(value).pipe(Effect.map(([accountId, pullRequestId, repositoryName, region]) => Option.some(toCoordinates({ accountId, pullRequestId, repositoryName, region }))),
|
|
82
|
+
// A profile alias may decode as JSON while still not being a coordinate tuple.
|
|
83
|
+
// Leave it to the ordinary account lookup rather than reserving that alias.
|
|
84
|
+
Effect.catch(() => Effect.succeed(Option.none())))
|
|
85
|
+
}))
|
|
86
|
+
}));
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=pull-request-coordinates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pull-request-coordinates.js","sourceRoot":"","sources":["../src/pull-request-coordinates.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAC3F,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/D,MAAM,qBAAqB,GAAG,MAAM,CAAA;AACpC,MAAM,2BAA2B,GAAG,OAAO,CAAA;AAC3C,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;AACtF,MAAM,mBAAmB,GAAG,cAAc,CAAA;AAC1C,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,CAAA;AAElD,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,CAAC;IAClD,SAAS,EAAE,mBAAmB;IAC9B,aAAa,EAAE,aAAa;IAC5B,cAAc,EAAE,cAAc;IAC9B,MAAM,EAAE,SAAS;CAClB,CAAC,CAAC,KAAK,CACN,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,EAAE;IAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC;QACtD,WAAW,CAAC,SAAS;QACrB,WAAW,CAAC,aAAa;QACzB,WAAW,CAAC,cAAc;QAC1B,WAAW,CAAC,MAAM;KACnB,CAAC,CAAC,CAAA;IACH,OAAO,OAAO,CAAC,MAAM,GAAG,qBAAqB,CAAC,MAAM,IAAI,8BAA8B;QACpF,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,kEAAkE,CAAA;AACxE,CAAC,CAAC,CACH,CAAA;AAGD,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC;IACnC,cAAc;IACd,cAAc;IACd,cAAc;IACd,cAAc;CACf,CAAC,CAAA;AAEF,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,SAAS,EAAE,cAAc;IACzB,aAAa,EAAE,cAAc;IAC7B,cAAc,EAAE,cAAc;IAC9B,MAAM,EAAE,cAAc;CACvB,CAAC,CAAA;AAEF,MAAM,aAAa,GAAG,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAKxE,EAA0B,EAAE,CAAC,CAAC;IAC7B,SAAS;IACT,aAAa,EAAE,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC;IAChD,cAAc,EAAE,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC;IACnD,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;CAC/B,CAAC,CAAA;AAEF,MAAM,OAAO,gCAAiC,SAAQ,IAAI,CAAC,WAAW,CACpE,kCAAkC,CACL;CAAG;AAElC,yFAAyF;AACzF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,WAAmC,EAAU,EAAE;IAC1F,MAAM,SAAS,GAAG,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,CAAC,WAAW,CAAC,CAAA;IAC/E,OAAO,GAAG,qBAAqB,GAC7B,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC;QACtC,SAAS,CAAC,SAAS;QACnB,SAAS,CAAC,aAAa;QACvB,SAAS,CAAC,cAAc;QACxB,SAAS,CAAC,MAAM;KACjB,CAAC,CACJ,EAAE,CAAA;AACJ,CAAC,CAAA;AAED,qFAAqF;AACrF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,KAAa,EAC2E,EAAE;IAC1F,IAAI,KAAK,CAAC,UAAU,CAAC,2BAA2B,CAAC,EAAE,CAAC;QAClD,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAA;QAC/D,0EAA0E;QAC1E,yEAAyE;QACzE,+CAA+C;QAC/C,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC;YAAE,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;QAC/E,OAAO,MAAM,CAAC,GAAG,CAAC;YAChB,GAAG,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC;YACtC,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,gCAAgC,CAAC,EAAE,OAAO,EAAE,uCAAuC,EAAE,CAAC;SACxG,CAAC,CAAC,IAAI,CACL,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CACtB,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAC5E,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,EACpE,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,gCAAgC,CAAC,EAAE,OAAO,EAAE,kCAAkC,EAAE,CAAC,CAAC,CAC7G,CACF,CACF,CAAA;IACH,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,qBAAqB,CAAC;QAAE,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;IAClF,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAA;IACzD,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CACpE,MAAM,CAAC,WAAW,CAAC;QACjB,wEAAwE;QACxE,wEAAwE;QACxE,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC9C,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAC1E,MAAM,CAAC,WAAW,CAAC;YACjB,oEAAoE;YACpE,gEAAgE;YAChE,mCAAmC;YACnC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC9C,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CACnB,MAAM,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CACrD,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,EAAE,CAChE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC,CAAC,CACjF;YACD,+EAA+E;YAC/E,4EAA4E;YAC5E,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAClD;SACJ,CAAC,CACH;KACJ,CAAC,CACH,CAAA;AACH,CAAC,CAAA"}
|