@p4code/cli 0.6.9 → 0.6.10

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.
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$ as i,Dt as a,Fa as o,Ha as s,Hl as c,Kr as l,Qa as u,Ra as d,Sl as f,Ua as p,Za as m,_t as h,b as g,bl as _,bt as v,dl as ee,fl as y,ft as b,gl as x,gt as S,tu as C,vu as w,xl as T,yl as E,yt as D}from"./previewAssetResource-sGNObqz0.js";import{a as O,c as k,n as A,o as j,r as M,s as te,t as ne}from"./toggle-group-Covue-HD.js";import{B as N,Fr as re,G as ie,H as ae,Ir as oe,J as se,K as ce,Lr as le,Qr as ue,U as de,V as fe,W as pe,Wr as me,X as P,Xr as he,Yr as ge,_ as _e,ai as ve,at as ye,dt as be,ft as F,gr as xe,hr as Se,lt as Ce,mr as we,oi as Te,ot as Ee,pt as De,q as Oe,st as ke,ut as Ae,vr as je}from"./index-B2Vr_iKA.js";var Me=f(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ne=f(`message-square-off`,[[`path`,{d:`M19 19H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.7.7 0 0 1 2 21.286V5a2 2 0 0 1 1.184-1.826`,key:`1wyg69`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.656 3H20a2 2 0 0 1 2 2v11.344`,key:`mhl4k6`}]]),I=e(n(),1),Pe=new Set([`pnpm-lock.yaml`,`yarn.lock`,`package-lock.json`,`bun.lockb`,`Cargo.lock`,`go.sum`,`composer.lock`,`Gemfile.lock`]),Fe=new Set([`__snapshots__`,`__generated__`,`dist`,`build`,`vendor`]),L=new Set([`__tests__`,`tests`,`test`]),R=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`];function Ie(e){let t=e.split(`/`),n=t.at(-1)??``;return Pe.has(n)||n.endsWith(`.snap`)||n.endsWith(`.min.js`)||n.endsWith(`.min.css`)||/\.generated\./.test(n)||t.slice(0,-1).some(e=>Fe.has(e))?`generated`:/\.(?:test|spec)\./.test(n)||t.slice(0,-1).some(e=>L.has(e))?`test`:`source`}function Le(e){let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(0,t):e}function Re(e){return Le(e.split(`/`).at(-1)??``)}function ze(e,t){let n=e.split(`/`).slice(0,-1);for(let e of t.split(`/`))e===`.`||e===``||(e===`..`?n.pop():n.push(e));return n.join(`/`)}var Be=/(?:\bfrom|\bimport|\brequire\s*\()\s*\(?\s*["']([^"']+)["']/g;function Ve(e,t,n,r){let i=new Set;for(let a of t){Be.lastIndex=0;let t=Be.exec(a);for(;t!==null;){let o=t[1]??``,s=o.startsWith(`.`)?ze(e,o):o,c=R.find(e=>s.endsWith(e)),l=c===void 0?s:s.slice(0,-c.length),u=n.get(l)??n.get(`${l}/index`)??r.get(Re(l));u!==void 0&&u!==e&&i.add(u),t=Be.exec(a)}}return i}function He(e,t){let n=new Set(e),r=[],i=[...e].sort((e,t)=>e.localeCompare(t));for(;n.size>0;){let e=i.filter(e=>n.has(e)),a=e.find(e=>[...t.get(e)??[]].every(e=>!n.has(e)))??e[0];n.delete(a),r.push(a)}return r}function z(e){return(e.split(`/`).at(-1)??``).replace(/\.(?:test|spec)\..*$/,``).replace(/\.[^.]+$/,``)}function Ue(e){let t=new Map;for(let n of e)t.set(F(n),n);let n=new Map;for(let e of t.keys())n.set(e,Ie(e));let r=[...t.keys()].filter(e=>n.get(e)===`source`),i=new Map,a=new Set,o=new Map;for(let e of r){i.set(Le(e),e);let t=Re(e);o.has(t)&&a.add(t),o.set(t,e)}for(let e of a)o.delete(e);let s=new Map;for(let e of r){let n=t.get(e);s.set(e,Ve(e,[...n.additionLines,...n.deletionLines],i,o))}let c=He(r,s),l=new Map;c.forEach((e,t)=>{let n=Re(e);l.has(n)||l.set(n,t)});let u=[...t.keys()].filter(e=>n.get(e)===`test`).sort((e,t)=>(l.get(z(e))??2**53-1)-(l.get(z(t))??2**53-1)||e.localeCompare(t)),d=[...t.keys()].filter(e=>n.get(e)===`generated`).sort((e,t)=>e.localeCompare(t));return[...c,...u,...d].map(e=>t.get(e))}function We(e,t){return async n=>{let r=F(n),i=n.prevName?F({...n,name:n.prevName}):r,a=await e({changeType:n.type,oldPath:i,newPath:r}),o={name:r,contents:a.newContents,cacheKey:`${t}:new:${r}`};return n.type===`rename-pure`?{oldFile:null,newFile:o}:{oldFile:{name:i,contents:a.oldContents,cacheKey:`${t}:old:${i}`},newFile:o}}}function Ge(e,t){return We(async({changeType:n,oldPath:r,newPath:i})=>{let a=await e({environmentId:t.environmentId,input:{...t.reference,...t.commit===null?{}:{commit:t.commit},changeType:n,oldPath:r,newPath:i}});if(a._tag!==`Success`)throw w(a);return a.value},t.cacheKey)}var B=r();function V(e,t,n){return!n&&(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&t.trim().length>0}var H=t();function Ke(e){let t=(0,B.c)(43),{kind:n,rangeLabel:r,text:a,onTextChange:s,onCancel:c,onComment:l,onDelete:u,placeholder:d,submitLabel:f,pending:p,secondaryAction:m}=e,h=d===void 0?`Add a comment…`:d,g=f===void 0?`Comment`:f,_=p===void 0?!1:p,[v,ee]=(0,I.useState)(``),y=n===`draft`&&!s?v:a,b;t[0]===y?b=t[1]:(b=y.trim(),t[0]=y,t[1]=b);let x=b;if(n===`comment`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(he,{className:`mt-0.5 size-3.5 shrink-0 text-primary/70`,"aria-hidden":`true`}),t[2]=e):e=t[2];let n;t[3]===y?n=t[4]:(n=(0,H.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap text-[13px] leading-5`,children:y}),t[3]=y,t[4]=n);let r;t[5]===u?r=t[6]:(r=u?(0,H.jsx)(o,{className:`-my-1 -mr-1 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/comment:opacity-100 focus-visible:opacity-100 max-sm:opacity-100`,variant:`ghost`,size:`icon-xs`,"aria-label":`Delete comment`,onClick:u,children:(0,H.jsx)(oe,{className:`size-3`})}):null,t[5]=u,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,H.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`group/comment flex min-w-0 items-start gap-2.5 border-s-2 border-primary/55 bg-primary/[0.045] px-3 py-2.5 font-sans text-foreground`,contentEditable:!1,onPointerDown:G,children:[e,n,r]}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}let S=`Comment on lines ${r}`,C;t[10]===s?C=t[11]:(C=e=>(s??ee)(e.target.value),t[10]=s,t[11]=C);let w;t[12]!==c||t[13]!==l||t[14]!==_||t[15]!==x?(w=e=>{e.key===`Escape`&&(e.preventDefault(),c()),V(e,x,_)&&(e.preventDefault(),l(x))},t[12]=c,t[13]=l,t[14]=_,t[15]=x,t[16]=w):w=t[16];let T;t[17]!==y||t[18]!==h||t[19]!==S||t[20]!==C||t[21]!==w?(T=(0,H.jsx)(i,{autoFocus:!0,unstyled:!0,className:`relative inline-flex w-full rounded-md border border-border/50 bg-background/20 font-sans text-foreground transition-colors focus-within:border-border/70 [&_[data-slot=textarea]]:min-h-12 [&_[data-slot=textarea]]:cursor-text [&_[data-slot=textarea]]:px-2.5 [&_[data-slot=textarea]]:py-1.5 [&_[data-slot=textarea]]:font-sans [&_[data-slot=textarea]]:text-xs [&_[data-slot=textarea]]:leading-5 max-sm:[&_[data-slot=textarea]]:min-h-12`,size:`sm`,value:y,placeholder:h,"aria-label":S,onChange:C,onFocus:U,onKeyDown:w}),t[17]=y,t[18]=h,t[19]=S,t[20]=C,t[21]=w,t[22]=T):T=t[22];let E;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,H.jsx)(`span`,{className:`mr-auto text-[10px] text-muted-foreground/70`,children:`⌘/Ctrl Enter to send`}),t[23]=E):E=t[23];let D;t[24]===c?D=t[25]:(D=(0,H.jsx)(o,{className:`text-muted-foreground hover:text-foreground`,variant:`ghost`,size:`xs`,onClick:c,children:`Cancel`}),t[24]=c,t[25]=D);let O;t[26]!==m||t[27]!==x?(O=m?(0,H.jsxs)(o,{size:`xs`,variant:`outline`,disabled:!m.allowEmpty&&!x,onClick:()=>m.onAction(x),children:[m.icon,m.label]}):null,t[26]=m,t[27]=x,t[28]=O):O=t[28];let k=_||!x,A;t[29]!==l||t[30]!==x?(A=()=>l(x),t[29]=l,t[30]=x,t[31]=A):A=t[31];let j;t[32]!==g||t[33]!==k||t[34]!==A?(j=(0,H.jsx)(o,{size:`xs`,disabled:k,onClick:A,children:g}),t[32]=g,t[33]=k,t[34]=A,t[35]=j):j=t[35];let M;t[36]!==D||t[37]!==O||t[38]!==j?(M=(0,H.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1`,children:[E,D,O,j]}),t[36]=D,t[37]=O,t[38]=j,t[39]=M):M=t[39];let te;return t[40]!==M||t[41]!==T?(te=(0,H.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`px-3 py-2 font-sans text-foreground`,contentEditable:!1,onPointerDown:W,children:[T,M]}),t[40]=M,t[41]=T,t[42]=te):te=t[42],te}function U(e){let t=e.currentTarget.value.length;e.currentTarget.setSelectionRange(t,t)}function W(e){return e.stopPropagation()}function G(e){return e.stopPropagation()}var K=`${ye}
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$ as i,Dt as a,Fa as o,Ha as s,Hl as c,Kr as l,Qa as u,Ra as d,Sl as f,Ua as p,Za as m,_t as h,b as g,bl as _,bt as v,dl as ee,fl as y,ft as b,gl as x,gt as S,tu as C,vu as w,xl as T,yl as E,yt as D}from"./previewAssetResource-AzHfcBQJ.js";import{a as O,c as k,n as A,o as j,r as M,s as te,t as ne}from"./toggle-group-BPW-Z2uw.js";import{B as N,Fr as re,G as ie,H as ae,Ir as oe,J as se,K as ce,Lr as le,Qr as ue,U as de,V as fe,W as pe,Wr as me,X as P,Xr as he,Yr as ge,_ as _e,ai as ve,at as ye,dt as be,ft as F,gr as xe,hr as Se,lt as Ce,mr as we,oi as Te,ot as Ee,pt as De,q as Oe,st as ke,ut as Ae,vr as je}from"./index-Bia2x-5A.js";var Me=f(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ne=f(`message-square-off`,[[`path`,{d:`M19 19H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.7.7 0 0 1 2 21.286V5a2 2 0 0 1 1.184-1.826`,key:`1wyg69`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.656 3H20a2 2 0 0 1 2 2v11.344`,key:`mhl4k6`}]]),I=e(n(),1),Pe=new Set([`pnpm-lock.yaml`,`yarn.lock`,`package-lock.json`,`bun.lockb`,`Cargo.lock`,`go.sum`,`composer.lock`,`Gemfile.lock`]),Fe=new Set([`__snapshots__`,`__generated__`,`dist`,`build`,`vendor`]),L=new Set([`__tests__`,`tests`,`test`]),R=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`];function Ie(e){let t=e.split(`/`),n=t.at(-1)??``;return Pe.has(n)||n.endsWith(`.snap`)||n.endsWith(`.min.js`)||n.endsWith(`.min.css`)||/\.generated\./.test(n)||t.slice(0,-1).some(e=>Fe.has(e))?`generated`:/\.(?:test|spec)\./.test(n)||t.slice(0,-1).some(e=>L.has(e))?`test`:`source`}function Le(e){let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(0,t):e}function Re(e){return Le(e.split(`/`).at(-1)??``)}function ze(e,t){let n=e.split(`/`).slice(0,-1);for(let e of t.split(`/`))e===`.`||e===``||(e===`..`?n.pop():n.push(e));return n.join(`/`)}var Be=/(?:\bfrom|\bimport|\brequire\s*\()\s*\(?\s*["']([^"']+)["']/g;function Ve(e,t,n,r){let i=new Set;for(let a of t){Be.lastIndex=0;let t=Be.exec(a);for(;t!==null;){let o=t[1]??``,s=o.startsWith(`.`)?ze(e,o):o,c=R.find(e=>s.endsWith(e)),l=c===void 0?s:s.slice(0,-c.length),u=n.get(l)??n.get(`${l}/index`)??r.get(Re(l));u!==void 0&&u!==e&&i.add(u),t=Be.exec(a)}}return i}function He(e,t){let n=new Set(e),r=[],i=[...e].sort((e,t)=>e.localeCompare(t));for(;n.size>0;){let e=i.filter(e=>n.has(e)),a=e.find(e=>[...t.get(e)??[]].every(e=>!n.has(e)))??e[0];n.delete(a),r.push(a)}return r}function z(e){return(e.split(`/`).at(-1)??``).replace(/\.(?:test|spec)\..*$/,``).replace(/\.[^.]+$/,``)}function Ue(e){let t=new Map;for(let n of e)t.set(F(n),n);let n=new Map;for(let e of t.keys())n.set(e,Ie(e));let r=[...t.keys()].filter(e=>n.get(e)===`source`),i=new Map,a=new Set,o=new Map;for(let e of r){i.set(Le(e),e);let t=Re(e);o.has(t)&&a.add(t),o.set(t,e)}for(let e of a)o.delete(e);let s=new Map;for(let e of r){let n=t.get(e);s.set(e,Ve(e,[...n.additionLines,...n.deletionLines],i,o))}let c=He(r,s),l=new Map;c.forEach((e,t)=>{let n=Re(e);l.has(n)||l.set(n,t)});let u=[...t.keys()].filter(e=>n.get(e)===`test`).sort((e,t)=>(l.get(z(e))??2**53-1)-(l.get(z(t))??2**53-1)||e.localeCompare(t)),d=[...t.keys()].filter(e=>n.get(e)===`generated`).sort((e,t)=>e.localeCompare(t));return[...c,...u,...d].map(e=>t.get(e))}function We(e,t){return async n=>{let r=F(n),i=n.prevName?F({...n,name:n.prevName}):r,a=await e({changeType:n.type,oldPath:i,newPath:r}),o={name:r,contents:a.newContents,cacheKey:`${t}:new:${r}`};return n.type===`rename-pure`?{oldFile:null,newFile:o}:{oldFile:{name:i,contents:a.oldContents,cacheKey:`${t}:old:${i}`},newFile:o}}}function Ge(e,t){return We(async({changeType:n,oldPath:r,newPath:i})=>{let a=await e({environmentId:t.environmentId,input:{...t.reference,...t.commit===null?{}:{commit:t.commit},changeType:n,oldPath:r,newPath:i}});if(a._tag!==`Success`)throw w(a);return a.value},t.cacheKey)}var B=r();function V(e,t,n){return!n&&(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&t.trim().length>0}var H=t();function Ke(e){let t=(0,B.c)(43),{kind:n,rangeLabel:r,text:a,onTextChange:s,onCancel:c,onComment:l,onDelete:u,placeholder:d,submitLabel:f,pending:p,secondaryAction:m}=e,h=d===void 0?`Add a comment…`:d,g=f===void 0?`Comment`:f,_=p===void 0?!1:p,[v,ee]=(0,I.useState)(``),y=n===`draft`&&!s?v:a,b;t[0]===y?b=t[1]:(b=y.trim(),t[0]=y,t[1]=b);let x=b;if(n===`comment`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(he,{className:`mt-0.5 size-3.5 shrink-0 text-primary/70`,"aria-hidden":`true`}),t[2]=e):e=t[2];let n;t[3]===y?n=t[4]:(n=(0,H.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap text-[13px] leading-5`,children:y}),t[3]=y,t[4]=n);let r;t[5]===u?r=t[6]:(r=u?(0,H.jsx)(o,{className:`-my-1 -mr-1 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/comment:opacity-100 focus-visible:opacity-100 max-sm:opacity-100`,variant:`ghost`,size:`icon-xs`,"aria-label":`Delete comment`,onClick:u,children:(0,H.jsx)(oe,{className:`size-3`})}):null,t[5]=u,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,H.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`group/comment flex min-w-0 items-start gap-2.5 border-s-2 border-primary/55 bg-primary/[0.045] px-3 py-2.5 font-sans text-foreground`,contentEditable:!1,onPointerDown:G,children:[e,n,r]}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}let S=`Comment on lines ${r}`,C;t[10]===s?C=t[11]:(C=e=>(s??ee)(e.target.value),t[10]=s,t[11]=C);let w;t[12]!==c||t[13]!==l||t[14]!==_||t[15]!==x?(w=e=>{e.key===`Escape`&&(e.preventDefault(),c()),V(e,x,_)&&(e.preventDefault(),l(x))},t[12]=c,t[13]=l,t[14]=_,t[15]=x,t[16]=w):w=t[16];let T;t[17]!==y||t[18]!==h||t[19]!==S||t[20]!==C||t[21]!==w?(T=(0,H.jsx)(i,{autoFocus:!0,unstyled:!0,className:`relative inline-flex w-full rounded-md border border-border/50 bg-background/20 font-sans text-foreground transition-colors focus-within:border-border/70 [&_[data-slot=textarea]]:min-h-12 [&_[data-slot=textarea]]:cursor-text [&_[data-slot=textarea]]:px-2.5 [&_[data-slot=textarea]]:py-1.5 [&_[data-slot=textarea]]:font-sans [&_[data-slot=textarea]]:text-xs [&_[data-slot=textarea]]:leading-5 max-sm:[&_[data-slot=textarea]]:min-h-12`,size:`sm`,value:y,placeholder:h,"aria-label":S,onChange:C,onFocus:U,onKeyDown:w}),t[17]=y,t[18]=h,t[19]=S,t[20]=C,t[21]=w,t[22]=T):T=t[22];let E;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,H.jsx)(`span`,{className:`mr-auto text-[10px] text-muted-foreground/70`,children:`⌘/Ctrl Enter to send`}),t[23]=E):E=t[23];let D;t[24]===c?D=t[25]:(D=(0,H.jsx)(o,{className:`text-muted-foreground hover:text-foreground`,variant:`ghost`,size:`xs`,onClick:c,children:`Cancel`}),t[24]=c,t[25]=D);let O;t[26]!==m||t[27]!==x?(O=m?(0,H.jsxs)(o,{size:`xs`,variant:`outline`,disabled:!m.allowEmpty&&!x,onClick:()=>m.onAction(x),children:[m.icon,m.label]}):null,t[26]=m,t[27]=x,t[28]=O):O=t[28];let k=_||!x,A;t[29]!==l||t[30]!==x?(A=()=>l(x),t[29]=l,t[30]=x,t[31]=A):A=t[31];let j;t[32]!==g||t[33]!==k||t[34]!==A?(j=(0,H.jsx)(o,{size:`xs`,disabled:k,onClick:A,children:g}),t[32]=g,t[33]=k,t[34]=A,t[35]=j):j=t[35];let M;t[36]!==D||t[37]!==O||t[38]!==j?(M=(0,H.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1`,children:[E,D,O,j]}),t[36]=D,t[37]=O,t[38]=j,t[39]=M):M=t[39];let te;return t[40]!==M||t[41]!==T?(te=(0,H.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`px-3 py-2 font-sans text-foreground`,contentEditable:!1,onPointerDown:W,children:[T,M]}),t[40]=M,t[41]=T,t[42]=te):te=t[42],te}function U(e){let t=e.currentTarget.value.length;e.currentTarget.setSelectionRange(t,t)}function W(e){return e.stopPropagation()}function G(e){return e.stopPropagation()}var K=`${ye}
2
2
  :is(
3
3
  [data-line],
4
4
  [data-line-annotation],
@@ -248,4 +248,4 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}f
248
248
  [data-diffs-header] [data-deletions-count] {
249
249
  display: none !important;
250
250
  }`,pt=[];function mt(e){return e===`left`?`deletions`:`additions`}function ht(e){return e===`deletions`?`left`:`right`}function X({environmentId:e,reference:t,detail:n,selectedCommitOid:r,onSelectedCommitChange:i,pendingFinding:f,fixFindingLabel:x=`Fix in a thread`,onFixFinding:C,onAddToAgentSelection:w,onRefresh:T,refreshToken:O=0}){let{resolvedTheme:N}=g(),ie=re(),[ae,oe]=(0,I.useState)(()=>new Set),[ue,fe]=(0,I.useState)(dt),[me,he]=(0,I.useState)(null),[ve,ye]=(0,I.useState)(`stacked`),[je,Me]=(0,I.useState)(ie.wordWrap),[Pe,Fe]=(0,I.useState)(null),[L,R]=(0,I.useState)(null),[Ie,Le]=(0,I.useState)(!1),[Re,ze]=(0,I.useState)(!1),[Be,Ve]=(0,I.useState)(!1),[He,z]=(0,I.useState)({key:``,cursor:null,slices:pt}),We=(0,I.useRef)(new Map),B=et(t),V=r,U=V===null?B:`${B}@${V}`;(0,I.useEffect)(()=>{R(null),Fe(null),oe(new Set),he(null),fe(dt),ze(!1),z({key:U,cursor:null,slices:pt}),We.current.clear()},[U]);let W=He.key===U?He.slices:pt,G=He.key===U?He.cursor:null,K=a(P.diff({environmentId:e,input:{...t,...G===null?{}:{cursor:G},...V===null?{}:{commit:V}}}));(0,I.useEffect)(()=>{let e=K.data;e!==null&&z(t=>{let n=t.key===U?t.slices:pt,r={cursor:G,patch:e.patch,truncated:e.truncated,nextCursor:e.nextCursor,omittedFileStats:e.omittedFileStats??[]},i=n.findIndex(e=>e.cursor===G);if(i===-1)return{key:U,cursor:G,slices:[...n,r]};let a=n[i];return a!==void 0&&a.patch===r.patch&&a.truncated===r.truncated&&a.nextCursor===r.nextCursor&&a.omittedFileStats.length===r.omittedFileStats.length&&a.omittedFileStats.every((e,t)=>{let n=r.omittedFileStats[t];return n!==void 0&&n.path===e.path&&n.additions===e.additions&&n.deletions===e.deletions})?t:{key:U,cursor:G,slices:[...n.slice(0,i),r]}})},[G,K.data,U]);let Je=c(P.diff({environmentId:e,input:{...t,...V===null?{}:{commit:V}}})),Ye=(0,I.useRef)(O);(0,I.useEffect)(()=>{Ye.current!==O&&(Ye.current=O,z({key:U,cursor:null,slices:pt}),Je())},[O,U,Je]);let Ze=B,q=tt(t),J=Y(e=>e.addComment),nt=Y(e=>e.removeComment),it=v(P.replyToThread,{reportFailure:!1}),at=v(P.setThreadResolution,{reportFailure:!1}),ot=v(P.updateComment,{reportFailure:!1}),st=v(P.diffFileContents),ct=(0,I.useMemo)(()=>Ge(st,{environmentId:e,reference:t,commit:V,cacheKey:`pull-request:${B}:${n.updatedAt}:${V??`all`}`}),[V,n.updatedAt,e,st,t,B]),X=(0,I.useMemo)(()=>{let e=n.capabilities.review,t=n.viewerPermissions;return{inlineComment:e.inlineComment&&t.comment,reply:e.reply&&t.comment,resolve:e.resolve&&t.resolve,verdicts:e.verdicts.filter(e=>t.verdicts.includes(e))}},[n.capabilities.review,n.viewerPermissions]),gt=X.inlineComment&&V===null,_t=(0,I.useMemo)(()=>W.map(e=>{let t=`pull-request:${U}:${N}:${e.cursor??`first`}:${ke(e.patch)}`,n=We.current.get(t);if(n)return n;let r=Ae(e.patch,t,{compactPartialHunkOffsets:!0});return r&&We.current.set(t,r),r}),[W,N,U]),Z=(0,I.useMemo)(()=>_t.flatMap(e=>e?.kind===`files`?Ue(e.files):[]),[_t]),Q=W.at(-1)?.nextCursor??null,vt=W.some(e=>e.truncated)||_t.some(e=>e?.kind===`raw`),yt=(0,I.useMemo)(()=>{let e=new Set;if(V!==null)return e;for(let t of Z){let r=F(t);for(let i of n.reviewThreads)i.path===r&&i.line!==null&&lt(t,i.side,i.line)&&e.add(i.id)}return e},[V,n.reviewThreads,Z]),$=(0,I.useMemo)(()=>Z.map(e=>{let t=Ee(e),r=F(e),i=new Map,a=(e,t)=>{let n=`${e}:${t}`,r=i.get(n);if(r)return r;let a={side:e,line:t,threads:[],pending:[],draft:!1};return i.set(n,a),a};for(let e of n.reviewThreads)e.path!==r||e.line===null||yt.has(e.id)&&a(e.side,e.line).threads.push(e);if(V===null)for(let e of q)e.path===r&&a(e.side,e.line).pending.push(e);L?.fileKey===t&&(a(L.side,L.line).draft=!0);let o=ut(t,me,ae),s=[...i.values()].map(e=>({side:mt(e.side),lineNumber:e.line,metadata:{threads:e.threads,pending:e.pending,draft:e.draft}}));return{id:t,type:`diff`,fileDiff:e,annotations:s,collapsed:o,version:ke(`${o?`1`:`0`}:${s.map(({side:e,lineNumber:t,metadata:n})=>`${e}:${t}:${n.draft?`d`:``}:${n.pending.map(e=>`${e.id}:${e.body}`).join(`,`)}:${n.threads.map(e=>`${e.id}:${e.isResolved?`r`:``}:${e.isOutdated?`o`:``}:${e.comments.map(e=>`${e.id}:${e.author?.login??``}:${e.createdAt}:${e.body}:${(e.reactions??[]).map(e=>`${e.content}:${e.count}:${e.viewerHasReacted?`v`:``}`).join(`,`)}`).join(`;`)}`).join(`,`)}`).join(`|`)}`)}}),[V,n.reviewThreads,L,Z,me,q,yt,ae]),bt=(0,I.useMemo)(()=>Ce(Z),[Z]),xt=(0,I.useMemo)(()=>new Map(W.flatMap(e=>e.omittedFileStats.map(e=>[e.path,e]))),[W]),St=(0,I.useMemo)(()=>$.map(e=>e.id),[$]),Ct=(0,I.useMemo)(()=>new Set($.filter(e=>e.collapsed===!0).map(e=>e.id)),[$]),wt=M(St,Ct),[Tt,Et]=(0,I.useState)(null);(0,I.useEffect)(()=>{if(Tt===null||Q===null||Q===G||K.isPending||K.error!==null)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&z(e=>({...e,cursor:Q}))},{rootMargin:`240px`});return e.observe(Tt),()=>e.disconnect()},[G,K.error,K.isPending,Q,Tt]);let Dt=(0,I.useCallback)(e=>oe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),Ot=()=>{he(M(St,Ct)?`expanded`:`folded`),oe(new Set)},kt=(0,I.useMemo)(()=>n.commits.toSorted((e,t)=>Date.parse(t.committedDate)-Date.parse(e.committedDate)),[n.commits]),At=(0,I.useCallback)((e,t)=>{if(!e||!gt)return;let n=t.item;if(n.type!==`diff`)return;let r=Z.find(e=>Ee(e)===n.id);if(!r)return;let i=F(r),a=De(r);R({fileKey:n.id,path:i,oldPath:a===i?null:a,line:e.end,side:ht(e.endSide??e.side),range:e})},[gt,Z]),jt=(0,I.useCallback)((e,t,r)=>{let i=Z.find(t=>Ee(t)===e.fileKey),a=i===void 0?null:l({id:`pull-request-selection:${e.fileKey}:${e.range.start}:${e.range.end}`,sectionId:`pull-request:${n.number}`,sectionTitle:`PR #${n.number} review`,filePath:e.path,fileDiff:i,range:e.range,text:t});R(null),Fe(null),a!==null&&r(a)},[n.number,Z]),Mt=(0,I.useCallback)(()=>Q===null?null:(0,H.jsx)(`div`,{ref:Et,className:`flex items-center justify-center gap-2 py-2 text-xs text-muted-foreground`,children:K.error===null?K.isPending?`Loading more files...`:null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`The rest of this diff could not be loaded.`}),(0,H.jsx)(o,{size:`xs`,variant:`outline`,onClick:()=>K.refresh(),children:`Retry`})]})}),[Q,K.error,K.isPending,K.refresh]),Nt=(0,I.useCallback)(e=>{let t=e.collapsed===!0;return(0,H.jsx)(`button`,{type:`button`,"aria-expanded":!t,"aria-label":t?`Expand diff`:`Collapse diff`,className:u(`mr-1 inline-flex size-5 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground`),onClick:t=>{t.stopPropagation(),Dt(e.id)},children:t?(0,H.jsx)(E,{className:`size-4`}):(0,H.jsx)(_,{className:`size-4`})})},[Dt]),Pt=(0,I.useCallback)(e=>{if(e.type!==`diff`)return null;let t=0,n=0;for(let r of e.fileDiff.hunks)t+=r.additionLines,n+=r.deletionLines;if(t===0&&n===0){let r=xt.get(F(e.fileDiff));r&&({additions:t,deletions:n}=r)}return(0,H.jsx)(ce,{additions:t,deletions:n,className:`font-mono text-[11px]`})},[xt]),Ft=(0,I.useMemo)(()=>({diffStyle:ve===`split`?`split`:`unified`,lineDiffType:`none`,overflow:je?`wrap`:`scroll`,theme:be(N),themeType:N,stickyHeaders:!0,loadDiffFiles:ct,enableGutterUtility:gt&&L===null,enableLineSelection:gt&&L===null,onGutterUtilityClick:At,onLineSelectionEnd:At}),[ve,je,N,ct,gt,L,At]),It=(0,I.useCallback)(async(e,t)=>{if(Ie)return!1;Le(!0);let n=await t();return Le(!1),n._tag===`Failure`?(b.add({type:`error`,title:e}),!1):(T(),!0)},[T,Ie]),Lt=(0,I.useCallback)(r=>(0,H.jsx)(Qe,{thread:r,workspaceRoot:n.workspaceRoot,canReply:X.reply,canResolve:X.resolve,canReact:n.capabilities.reactions===!0,environmentId:e,reference:t,pending:Ie,fixPending:f===pe({kind:`thread`,thread:r}),fixLabel:x,...C?{onFix:()=>C({kind:`thread`,thread:r})}:{},onReply:n=>It(`Reply could not be posted`,()=>it({environmentId:e,input:{...t,threadId:r.id,body:n}})),canEditComment:e=>de(n,{author:e.author,kind:`review-comment`}),onEditComment:(n,r)=>It(`The comment could not be saved`,()=>ot({environmentId:e,input:{...t,commentId:n,kind:`review-comment`,body:r}})),onToggleResolved:()=>void It(`The conversation could not be updated`,()=>at({environmentId:e,input:{...t,threadId:r.id,resolved:!r.isResolved}})),onReacted:T},`${t.projectId}#${t.number}:${r.id}`),[n,e,x,T,C,f,t,it,X.reply,X.resolve,It,at,Ie,ot]),Rt=(0,I.useCallback)(e=>(0,H.jsxs)(`div`,{className:`py-1 font-sans text-foreground`,children:[e.metadata.threads.map(Lt),e.metadata.pending.map(e=>(0,H.jsx)(Xe,{comment:e,onRemove:()=>nt(Ze,e.id)},e.id)),e.metadata.draft&&L?(0,H.jsx)(Ke,{kind:`draft`,rangeLabel:`${L.path}:${L.line}`,text:``,submitLabel:`Add to review`,...w?{secondaryAction:{label:`Add to agent`,onAction:e=>jt(L,e,t=>w({comment:t,request:e}))}}:{},onCancel:()=>{R(null),Fe(null)},onComment:e=>{J(Ze,{id:$e(),path:L.path,...L.oldPath===null?{}:{oldPath:L.oldPath},line:L.line,side:L.side,body:e}),R(null),Fe(null)}}):null]}),[J,jt,L,w,nt,Lt,Ze]),zt=X.verdicts.length===0?null:(0,H.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10`,children:Be?(0,H.jsxs)(`div`,{className:`chat-composer-glass pointer-events-auto absolute inset-x-3 bottom-3 rounded-xl border border-border/60 shadow-lg`,children:[(0,H.jsx)(o,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Close review`,className:`absolute right-2 top-2`,onClick:()=>Ve(!1),children:(0,H.jsx)(ee,{className:`size-3.5`})}),(0,H.jsx)(rt,{environmentId:e,reference:t,verdicts:X.verdicts,onSubmitted:()=>{T(),Ve(!1)}})]}):(0,H.jsxs)(`button`,{type:`button`,className:`chat-composer-glass pointer-events-auto absolute bottom-3 right-4 flex items-center gap-1.5 rounded-full border border-border/60 px-3 py-1.5 text-xs font-medium shadow-lg`,onClick:()=>Ve(!0),children:[(0,H.jsx)(ge,{className:`size-3.5`}),`Review`,q.length>0?(0,H.jsx)(`span`,{className:`flex size-4 items-center justify-center rounded-full bg-accent text-[10px] tabular-nums text-accent-foreground`,children:q.length}):null]})}),Bt=kt.find(e=>e.oid===V);(0,I.useEffect)(()=>{V!==null&&Bt===void 0&&i(null)},[V,i,Bt]);let Vt=Bt?Bt.messageHeadline:`All commits`,Ht=(0,H.jsxs)(`div`,{className:`surface-subheader justify-between gap-2 px-4 text-xs text-muted-foreground`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[kt.length>0?(0,H.jsxs)(d,{children:[(0,H.jsxs)(m,{className:`inline-flex h-6 max-w-64 items-center gap-1 rounded-md bg-accent px-2 text-xs font-medium text-accent-foreground outline-none transition-colors hover:bg-accent/80 focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Diff scope: ${Vt}`,children:[(0,H.jsx)(`span`,{className:`truncate`,children:Vt}),(0,H.jsx)(_,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,H.jsxs)(p,{align:`start`,className:`w-80`,children:[(0,H.jsx)(s,{className:V===null?`bg-foreground/[0.08]`:void 0,onClick:()=>i(null),children:(0,H.jsx)(`span`,{children:`All commits`})}),kt.slice(0,ue).map(e=>(0,H.jsxs)(s,{className:e.oid===V?`bg-foreground/[0.08]`:void 0,onClick:()=>i(e.oid),children:[(0,H.jsx)(`span`,{className:`min-w-0 truncate`,title:e.messageHeadline,children:e.messageHeadline}),(0,H.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-xs text-muted-foreground`,children:e.oid.slice(0,7)})]},e.oid)),kt.length>ue?(0,H.jsx)(s,{closeOnClick:!1,onClick:()=>fe(e=>e+dt),children:(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Show more (`,kt.length-ue,` left)`]})}):null]})]}):null,(0,H.jsxs)(Oe,{children:[(0,H.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[Z.length,` `,Z.length===1?`file`:`files`,Q===null?``:`+`]}),vt?(0,H.jsxs)(S,{children:[(0,H.jsx)(D,{render:(0,H.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,H.jsx)(y,{"aria-label":`Some of this diff was not shown`,className:`size-3.5 text-amber-600 dark:text-amber-500`})}),(0,H.jsx)(h,{side:`bottom`,children:`The host withheld part of this diff — a binary file, or a change too large to inline.`})]}):null,V!==null&&X.inlineComment?(0,H.jsxs)(S,{children:[(0,H.jsx)(D,{render:(0,H.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,H.jsx)(Ne,{"aria-label":`Line comments are written from the whole change`,className:`size-3.5`})}),(0,H.jsx)(h,{side:`bottom`,children:`A comment is anchored to the whole change, so switch to All commits to write one.`})]}):null]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,H.jsx)(ce,{additions:bt.additions,deletions:bt.deletions,className:`mr-1`}),St.length>0?(0,H.jsxs)(S,{children:[(0,H.jsx)(D,{render:(0,H.jsx)(o,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":wt?`Expand all files`:`Collapse all files`,onClick:Ot}),children:wt?(0,H.jsx)(Te,{className:`size-3.5`}):(0,H.jsx)(k,{className:`size-3.5`})}),(0,H.jsx)(h,{side:`top`,children:wt?`Expand all files`:`Collapse all files`})]}):null,(0,H.jsxs)(A,{className:`shrink-0 gap-1`,size:`sm`,value:[ve],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&ye(t)},children:[(0,H.jsx)(ne,{"aria-label":`Stacked diff view`,value:`stacked`,variant:`ghost`,children:(0,H.jsx)(j,{className:`size-3.5`})}),(0,H.jsx)(ne,{"aria-label":`Split diff view`,value:`split`,variant:`ghost`,children:(0,H.jsx)(te,{className:`size-3.5`})})]}),(0,H.jsxs)(S,{children:[(0,H.jsx)(D,{render:(0,H.jsx)(ne,{"aria-label":je?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`ghost`,size:`sm`,pressed:je,onPressedChange:e=>{Me(!!e)}}),children:(0,H.jsx)(le,{className:`size-3.5`})}),(0,H.jsx)(h,{side:`top`,children:je?`Disable line wrapping`:`Enable line wrapping`})]})]})]}),Ut=e=>(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ht,(0,H.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`h-full overflow-auto`,children:e}),zt]})]});if(K.isPending&&W.length===0)return Ut((0,H.jsx)(se,{label:`Loading pull request diff...`}));if(K.error&&W.length===0)return Ut((0,H.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:K.error}));let Wt=Q===null?_t.flatMap(e=>e?.kind===`raw`?[e]:[]):[];if(Z.length===0&&Wt.length>0)return Ut((0,H.jsx)(`div`,{className:`space-y-4 px-4 py-5`,children:Wt.map(e=>(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,H.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))}));if($.length===0&&Q===null)return Ut((0,H.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:V===null?`This pull request has no file changes.`:`This commit has no file changes.`}));let Gt=n.reviewThreads.filter(e=>!yt.has(e.id)),Kt=new Map;for(let e of Gt){let t=Kt.get(e.path);t?t.push(e):Kt.set(e.path,[e])}let qt=Wt.length===0?null:(0,H.jsx)(`div`,{className:`space-y-4 border-t border-border/60 px-4 py-5`,children:Wt.map(e=>(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,H.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))});return(0,H.jsx)(_e,{children:(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ht,Kt.size>0?(0,H.jsxs)(we,{className:`shrink-0 border-b border-border/60`,open:Re,onOpenChange:ze,children:[(0,H.jsx)(`h2`,{children:(0,H.jsxs)(xe,{className:`flex w-full items-center gap-1.5 px-4 py-2 text-left text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:Q===null?`Conversations not on the current diff`:`Conversations not on the diff loaded so far`}),(0,H.jsx)(E,{"aria-hidden":!0,className:u(`size-3.5 transition-transform`,Re&&`rotate-90`)}),(0,H.jsx)(`span`,{"aria-hidden":!0,className:`tabular-nums`,children:Gt.length}),(0,H.jsx)(`span`,{className:`sr-only`,children:Gt.length===1?`1 conversation`:`${Gt.length} conversations`})]})}),(0,H.jsx)(Se,{children:(0,H.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-auto px-4 pb-3`,children:[...Kt].map(([e,t])=>(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`truncate px-3 text-xs text-muted-foreground`,title:e,children:e}),(0,H.jsx)(`div`,{className:`mt-1 space-y-2`,children:t.map(e=>(0,H.jsxs)(`div`,{children:[e.line===null?null:(0,H.jsxs)(`p`,{className:`px-3 text-xs text-muted-foreground`,children:[`Line `,e.line]}),Lt(e)]},e.id))})]},e))})})]}):null,(0,H.jsxs)(`div`,{className:`relative min-h-0 flex-1`,onClickCapture:e=>{let t=e.nativeEvent.composedPath?.()??[];for(let e of t)if(e instanceof HTMLElement){if(e instanceof HTMLButtonElement||e instanceof HTMLAnchorElement)return;if(e.hasAttribute(`data-diffs-header`)){let t=e.querySelector(`[data-title]`)?.textContent?.trim();if(t===void 0||t===``)return;let n=$.find(e=>F(e.fileDiff)===t);n!==void 0&&Dt(n.id);return}}},children:[(0,H.jsx)(qe,{className:`h-full overflow-auto [scrollbar-gutter:stable]`,items:$,selectedLines:Pe,onSelectedLinesChange:Fe,options:Ft,renderCodeViewFooter:Mt,renderHeaderPrefix:Nt,renderHeaderMetadata:Pt,renderAnnotation:Rt,unsafeCSSExtra:ft}),zt]}),qt]})})}export{X as PullRequestCodeTab,X as default};
251
- //# sourceMappingURL=PullRequestCodeTab-Ca0WHYhk.js.map
251
+ //# sourceMappingURL=PullRequestCodeTab-BeEliDpc.js.map
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$ as i,Fa as a}from"./previewAssetResource-sGNObqz0.js";import{Ir as o,Xr as s}from"./index-B2Vr_iKA.js";var c=r(),l=e(n(),1),u=t();function d(e){let t=(0,c.c)(44),{kind:n,rangeLabel:r,text:d,onCancel:m,onComment:h,onDelete:g}=e,[_,v]=(0,l.useState)(``);if(n===`comment`){let e,n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,u.jsx)(s,{className:`size-4 text-muted-foreground`}),n=(0,u.jsx)(`span`,{className:`text-xs font-medium`,children:`Local comment`}),t[0]=e,t[1]=n):(e=t[0],n=t[1]);let i;t[2]===r?i=t[3]:(i=(0,u.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:r}),t[2]=r,t[3]=i);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,u.jsx)(o,{className:`size-3.5`}),t[4]=c):c=t[4];let l;t[5]===g?l=t[6]:(l=(0,u.jsx)(a,{variant:`ghost`,size:`icon-xs`,"aria-label":`Delete comment`,onClick:g,children:c}),t[5]=g,t[6]=l);let f;t[7]!==i||t[8]!==l?(f=(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e,n,i,l]}),t[7]=i,t[8]=l,t[9]=f):f=t[9];let m;t[10]===d?m=t[11]:(m=(0,u.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:d}),t[10]=d,t[11]=m);let h;return t[12]!==f||t[13]!==m?(h=(0,u.jsxs)(`div`,{"data-file-comment-annotation":!0,className:`mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 shadow-sm`,contentEditable:!1,onPointerDown:p,children:[f,m]}),t[12]=f,t[13]=m,t[14]=h):h=t[14],h}let y;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(s,{className:`size-4 text-muted-foreground`}),(0,u.jsx)(`span`,{className:`text-sm font-medium`,children:`Local comment`})]}),t[15]=y):y=t[15];let b;t[16]===r?b=t[17]:(b=(0,u.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Comment on lines `,r]}),t[16]=r,t[17]=b);let x=`Comment on lines ${r}`,S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>v(e.target.value),t[18]=S):S=t[18];let C;t[19]!==m||t[20]!==h||t[21]!==_?(C=e=>{e.key===`Escape`&&(e.preventDefault(),m()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&_.trim()&&(e.preventDefault(),h(_.trim()))},t[19]=m,t[20]=h,t[21]=_,t[22]=C):C=t[22];let w;t[23]!==x||t[24]!==C||t[25]!==_?(w=(0,u.jsx)(i,{autoFocus:!0,className:`mt-3`,size:`sm`,value:_,placeholder:`Request change`,"aria-label":x,onChange:S,onKeyDown:C}),t[23]=x,t[24]=C,t[25]=_,t[26]=w):w=t[26];let T;t[27]===m?T=t[28]:(T=(0,u.jsx)(a,{variant:`ghost`,size:`sm`,onClick:m,children:`Cancel`}),t[27]=m,t[28]=T);let E;t[29]===_?E=t[30]:(E=_.trim(),t[29]=_,t[30]=E);let D=!E,O;t[31]!==h||t[32]!==_?(O=()=>h(_.trim()),t[31]=h,t[32]=_,t[33]=O):O=t[33];let k;t[34]!==O||t[35]!==D?(k=(0,u.jsx)(a,{size:`sm`,disabled:D,onClick:O,children:`Comment`}),t[34]=O,t[35]=D,t[36]=k):k=t[36];let A;t[37]!==k||t[38]!==T?(A=(0,u.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[T,k]}),t[37]=k,t[38]=T,t[39]=A):A=t[39];let j;return t[40]!==A||t[41]!==b||t[42]!==w?(j=(0,u.jsxs)(`div`,{"data-file-comment-annotation":!0,className:`mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 shadow-lg`,contentEditable:!1,onPointerDown:f,children:[y,b,w,A]}),t[40]=A,t[41]=b,t[42]=w,t[43]=j):j=t[43],j}function f(e){return e.stopPropagation()}function p(e){return e.stopPropagation()}var m=0;function h(){return m+=1,`file-comment-${Date.now()}-${m}`}function g(e){return{startLine:Math.min(e.start,e.end),endLine:Math.max(e.start,e.end)}}function _(e,t){return e===t?`L${e}`:`L${e} to L${t}`}function v(e){return e.map(e=>({...e,metadata:{entries:e.metadata.entries.map(t=>{let n=t.endLine-t.startLine;return{...t,endLine:e.lineNumber,startLine:Math.max(1,e.lineNumber-n)}})}}))}export{d as a,v as i,h as n,g as r,_ as t};
2
- //# sourceMappingURL=fileCommentAnnotations-CVK__goc.js.map
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$ as i,Fa as a}from"./previewAssetResource-AzHfcBQJ.js";import{Ir as o,Xr as s}from"./index-Bia2x-5A.js";var c=r(),l=e(n(),1),u=t();function d(e){let t=(0,c.c)(44),{kind:n,rangeLabel:r,text:d,onCancel:m,onComment:h,onDelete:g}=e,[_,v]=(0,l.useState)(``);if(n===`comment`){let e,n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,u.jsx)(s,{className:`size-4 text-muted-foreground`}),n=(0,u.jsx)(`span`,{className:`text-xs font-medium`,children:`Local comment`}),t[0]=e,t[1]=n):(e=t[0],n=t[1]);let i;t[2]===r?i=t[3]:(i=(0,u.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:r}),t[2]=r,t[3]=i);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,u.jsx)(o,{className:`size-3.5`}),t[4]=c):c=t[4];let l;t[5]===g?l=t[6]:(l=(0,u.jsx)(a,{variant:`ghost`,size:`icon-xs`,"aria-label":`Delete comment`,onClick:g,children:c}),t[5]=g,t[6]=l);let f;t[7]!==i||t[8]!==l?(f=(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e,n,i,l]}),t[7]=i,t[8]=l,t[9]=f):f=t[9];let m;t[10]===d?m=t[11]:(m=(0,u.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:d}),t[10]=d,t[11]=m);let h;return t[12]!==f||t[13]!==m?(h=(0,u.jsxs)(`div`,{"data-file-comment-annotation":!0,className:`mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 shadow-sm`,contentEditable:!1,onPointerDown:p,children:[f,m]}),t[12]=f,t[13]=m,t[14]=h):h=t[14],h}let y;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(s,{className:`size-4 text-muted-foreground`}),(0,u.jsx)(`span`,{className:`text-sm font-medium`,children:`Local comment`})]}),t[15]=y):y=t[15];let b;t[16]===r?b=t[17]:(b=(0,u.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Comment on lines `,r]}),t[16]=r,t[17]=b);let x=`Comment on lines ${r}`,S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>v(e.target.value),t[18]=S):S=t[18];let C;t[19]!==m||t[20]!==h||t[21]!==_?(C=e=>{e.key===`Escape`&&(e.preventDefault(),m()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&_.trim()&&(e.preventDefault(),h(_.trim()))},t[19]=m,t[20]=h,t[21]=_,t[22]=C):C=t[22];let w;t[23]!==x||t[24]!==C||t[25]!==_?(w=(0,u.jsx)(i,{autoFocus:!0,className:`mt-3`,size:`sm`,value:_,placeholder:`Request change`,"aria-label":x,onChange:S,onKeyDown:C}),t[23]=x,t[24]=C,t[25]=_,t[26]=w):w=t[26];let T;t[27]===m?T=t[28]:(T=(0,u.jsx)(a,{variant:`ghost`,size:`sm`,onClick:m,children:`Cancel`}),t[27]=m,t[28]=T);let E;t[29]===_?E=t[30]:(E=_.trim(),t[29]=_,t[30]=E);let D=!E,O;t[31]!==h||t[32]!==_?(O=()=>h(_.trim()),t[31]=h,t[32]=_,t[33]=O):O=t[33];let k;t[34]!==O||t[35]!==D?(k=(0,u.jsx)(a,{size:`sm`,disabled:D,onClick:O,children:`Comment`}),t[34]=O,t[35]=D,t[36]=k):k=t[36];let A;t[37]!==k||t[38]!==T?(A=(0,u.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[T,k]}),t[37]=k,t[38]=T,t[39]=A):A=t[39];let j;return t[40]!==A||t[41]!==b||t[42]!==w?(j=(0,u.jsxs)(`div`,{"data-file-comment-annotation":!0,className:`mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 shadow-lg`,contentEditable:!1,onPointerDown:f,children:[y,b,w,A]}),t[40]=A,t[41]=b,t[42]=w,t[43]=j):j=t[43],j}function f(e){return e.stopPropagation()}function p(e){return e.stopPropagation()}var m=0;function h(){return m+=1,`file-comment-${Date.now()}-${m}`}function g(e){return{startLine:Math.min(e.start,e.end),endLine:Math.max(e.start,e.end)}}function _(e,t){return e===t?`L${e}`:`L${e} to L${t}`}function v(e){return e.map(e=>({...e,metadata:{entries:e.metadata.entries.map(t=>{let n=t.endLine-t.startLine;return{...t,endLine:e.lineNumber,startLine:Math.max(1,e.lineNumber-n)}})}}))}export{d as a,v as i,h as n,g as r,_ as t};
2
+ //# sourceMappingURL=fileCommentAnnotations-frlpWfv_.js.map