@p4code/cli 0.4.11 → 0.4.13

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,$c as a,Et as o,Fa as s,Ga as c,Ia as l,Oa as u,Rl as d,Tl as f,Wa as p,b as m,cl as h,dt as g,el as _,eu as v,gt as y,ht as b,il as x,ja as S,ll as C,sl as w,ul as T,vt as E,yt as D,zr as O}from"./previewAssetResource-CVDZ-YAw.js";import{a as k,c as A,n as j,o as M,r as N,s as ee,t as te}from"./toggle-group-BCVKadvc.js";import{B as P,Fr as ne,G as re,Gr as ie,H as ae,Ir as oe,J as se,K as ce,Lr as le,Qr as ue,Rr as de,U as fe,V as pe,W as me,X as F,Xr as he,Yr as ge,_ as _e,ai as ve,ct as ye,ir as be,it as xe,lt as I,nr as Se,nt as Ce,oi as we,ot as Te,q as Ee,rr as De,rt as Oe,st as ke,ut as Ae,vr as L}from"./index-BWxnfRz6.js";var je=T(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Me=T(`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`}]]),R=e(n(),1),Ne=new Set([`pnpm-lock.yaml`,`yarn.lock`,`package-lock.json`,`bun.lockb`,`Cargo.lock`,`go.sum`,`composer.lock`,`Gemfile.lock`]),Pe=new Set([`__snapshots__`,`__generated__`,`dist`,`build`,`vendor`]),z=new Set([`__tests__`,`tests`,`test`]),Fe=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`];function Ie(e){let t=e.split(`/`),n=t.at(-1)??``;return Ne.has(n)||n.endsWith(`.snap`)||n.endsWith(`.min.js`)||n.endsWith(`.min.css`)||/\.generated\./.test(n)||t.slice(0,-1).some(e=>Pe.has(e))?`generated`:/\.(?:test|spec)\./.test(n)||t.slice(0,-1).some(e=>z.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=Fe.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 B(e){return(e.split(`/`).at(-1)??``).replace(/\.(?:test|spec)\..*$/,``).replace(/\.[^.]+$/,``)}function Ue(e){let t=new Map;for(let n of e)t.set(I(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(B(e))??2**53-1)-(l.get(B(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=I(n),i=n.prevName?I({...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 v(a);return a.value},t.cacheKey)}var V=r();function H(e,t,n){return!n&&(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&t.trim().length>0}var U=t();function Ke(e){let t=(0,V.c)(43),{kind:n,rangeLabel:r,text:a,onTextChange:o,onCancel:s,onComment:c,onDelete:l,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,y]=(0,R.useState)(``),b=n===`draft`&&!o?v:a,x;t[0]===b?x=t[1]:(x=b.trim(),t[0]=b,t[1]=x);let S=x;if(n===`comment`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,U.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]===b?n=t[4]:(n=(0,U.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap text-[13px] leading-5`,children:b}),t[3]=b,t[4]=n);let r;t[5]===l?r=t[6]:(r=l?(0,U.jsx)(u,{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:l,children:(0,U.jsx)(oe,{className:`size-3`})}):null,t[5]=l,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,U.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:K,children:[e,n,r]}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}let C=`Comment on lines ${r}`,w;t[10]===o?w=t[11]:(w=e=>(o??y)(e.target.value),t[10]=o,t[11]=w);let T;t[12]!==s||t[13]!==c||t[14]!==_||t[15]!==S?(T=e=>{e.key===`Escape`&&(e.preventDefault(),s()),H(e,S,_)&&(e.preventDefault(),c(S))},t[12]=s,t[13]=c,t[14]=_,t[15]=S,t[16]=T):T=t[16];let E;t[17]!==b||t[18]!==h||t[19]!==C||t[20]!==w||t[21]!==T?(E=(0,U.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:b,placeholder:h,"aria-label":C,onChange:w,onFocus:W,onKeyDown:T}),t[17]=b,t[18]=h,t[19]=C,t[20]=w,t[21]=T,t[22]=E):E=t[22];let D;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,U.jsx)(`span`,{className:`mr-auto text-[10px] text-muted-foreground/70`,children:`⌘/Ctrl Enter to send`}),t[23]=D):D=t[23];let O;t[24]===s?O=t[25]:(O=(0,U.jsx)(u,{className:`text-muted-foreground hover:text-foreground`,variant:`ghost`,size:`xs`,onClick:s,children:`Cancel`}),t[24]=s,t[25]=O);let k;t[26]!==m||t[27]!==S?(k=m?(0,U.jsxs)(u,{size:`xs`,variant:`outline`,disabled:!m.allowEmpty&&!S,onClick:()=>m.onAction(S),children:[m.icon,m.label]}):null,t[26]=m,t[27]=S,t[28]=k):k=t[28];let A=_||!S,j;t[29]!==c||t[30]!==S?(j=()=>c(S),t[29]=c,t[30]=S,t[31]=j):j=t[31];let M;t[32]!==g||t[33]!==A||t[34]!==j?(M=(0,U.jsx)(u,{size:`xs`,disabled:A,onClick:j,children:g}),t[32]=g,t[33]=A,t[34]=j,t[35]=M):M=t[35];let N;t[36]!==O||t[37]!==k||t[38]!==M?(N=(0,U.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1`,children:[D,O,k,M]}),t[36]=O,t[37]=k,t[38]=M,t[39]=N):N=t[39];let ee;return t[40]!==N||t[41]!==E?(ee=(0,U.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`px-3 py-2 font-sans text-foreground`,contentEditable:!1,onPointerDown:G,children:[E,N]}),t[40]=N,t[41]=E,t[42]=ee):ee=t[42],ee}function W(e){let t=e.currentTarget.value.length;e.currentTarget.setSelectionRange(t,t)}function G(e){return e.stopPropagation()}function K(e){return e.stopPropagation()}var q=`${Ce}
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,$c as a,Et as o,Fa as s,Ga as c,Ia as l,Oa as u,Rl as d,Tl as f,Wa as p,b as m,cl as h,dt as g,el as _,eu as v,gt as y,ht as b,il as x,ja as S,ll as C,sl as w,ul as T,vt as E,yt as D,zr as O}from"./previewAssetResource-CVDZ-YAw.js";import{a as k,c as A,n as j,o as M,r as N,s as ee,t as te}from"./toggle-group-U3M0YUkk.js";import{B as P,Fr as ne,G as re,Gr as ie,H as ae,Ir as oe,J as se,K as ce,Lr as le,Qr as ue,Rr as de,U as fe,V as pe,W as me,X as F,Xr as he,Yr as ge,_ as _e,ai as ve,ct as ye,ir as be,it as xe,lt as I,nr as Se,nt as Ce,oi as we,ot as Te,q as Ee,rr as De,rt as Oe,st as ke,ut as Ae,vr as L}from"./index-CBqRo4NV.js";var je=T(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Me=T(`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`}]]),R=e(n(),1),Ne=new Set([`pnpm-lock.yaml`,`yarn.lock`,`package-lock.json`,`bun.lockb`,`Cargo.lock`,`go.sum`,`composer.lock`,`Gemfile.lock`]),Pe=new Set([`__snapshots__`,`__generated__`,`dist`,`build`,`vendor`]),z=new Set([`__tests__`,`tests`,`test`]),Fe=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`];function Ie(e){let t=e.split(`/`),n=t.at(-1)??``;return Ne.has(n)||n.endsWith(`.snap`)||n.endsWith(`.min.js`)||n.endsWith(`.min.css`)||/\.generated\./.test(n)||t.slice(0,-1).some(e=>Pe.has(e))?`generated`:/\.(?:test|spec)\./.test(n)||t.slice(0,-1).some(e=>z.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=Fe.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 B(e){return(e.split(`/`).at(-1)??``).replace(/\.(?:test|spec)\..*$/,``).replace(/\.[^.]+$/,``)}function Ue(e){let t=new Map;for(let n of e)t.set(I(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(B(e))??2**53-1)-(l.get(B(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=I(n),i=n.prevName?I({...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 v(a);return a.value},t.cacheKey)}var V=r();function H(e,t,n){return!n&&(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&t.trim().length>0}var U=t();function Ke(e){let t=(0,V.c)(43),{kind:n,rangeLabel:r,text:a,onTextChange:o,onCancel:s,onComment:c,onDelete:l,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,y]=(0,R.useState)(``),b=n===`draft`&&!o?v:a,x;t[0]===b?x=t[1]:(x=b.trim(),t[0]=b,t[1]=x);let S=x;if(n===`comment`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,U.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]===b?n=t[4]:(n=(0,U.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap text-[13px] leading-5`,children:b}),t[3]=b,t[4]=n);let r;t[5]===l?r=t[6]:(r=l?(0,U.jsx)(u,{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:l,children:(0,U.jsx)(oe,{className:`size-3`})}):null,t[5]=l,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,U.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:K,children:[e,n,r]}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}let C=`Comment on lines ${r}`,w;t[10]===o?w=t[11]:(w=e=>(o??y)(e.target.value),t[10]=o,t[11]=w);let T;t[12]!==s||t[13]!==c||t[14]!==_||t[15]!==S?(T=e=>{e.key===`Escape`&&(e.preventDefault(),s()),H(e,S,_)&&(e.preventDefault(),c(S))},t[12]=s,t[13]=c,t[14]=_,t[15]=S,t[16]=T):T=t[16];let E;t[17]!==b||t[18]!==h||t[19]!==C||t[20]!==w||t[21]!==T?(E=(0,U.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:b,placeholder:h,"aria-label":C,onChange:w,onFocus:W,onKeyDown:T}),t[17]=b,t[18]=h,t[19]=C,t[20]=w,t[21]=T,t[22]=E):E=t[22];let D;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,U.jsx)(`span`,{className:`mr-auto text-[10px] text-muted-foreground/70`,children:`⌘/Ctrl Enter to send`}),t[23]=D):D=t[23];let O;t[24]===s?O=t[25]:(O=(0,U.jsx)(u,{className:`text-muted-foreground hover:text-foreground`,variant:`ghost`,size:`xs`,onClick:s,children:`Cancel`}),t[24]=s,t[25]=O);let k;t[26]!==m||t[27]!==S?(k=m?(0,U.jsxs)(u,{size:`xs`,variant:`outline`,disabled:!m.allowEmpty&&!S,onClick:()=>m.onAction(S),children:[m.icon,m.label]}):null,t[26]=m,t[27]=S,t[28]=k):k=t[28];let A=_||!S,j;t[29]!==c||t[30]!==S?(j=()=>c(S),t[29]=c,t[30]=S,t[31]=j):j=t[31];let M;t[32]!==g||t[33]!==A||t[34]!==j?(M=(0,U.jsx)(u,{size:`xs`,disabled:A,onClick:j,children:g}),t[32]=g,t[33]=A,t[34]=j,t[35]=M):M=t[35];let N;t[36]!==O||t[37]!==k||t[38]!==M?(N=(0,U.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1`,children:[D,O,k,M]}),t[36]=O,t[37]=k,t[38]=M,t[39]=N):N=t[39];let ee;return t[40]!==N||t[41]!==E?(ee=(0,U.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`px-3 py-2 font-sans text-foreground`,contentEditable:!1,onPointerDown:G,children:[E,N]}),t[40]=N,t[41]=E,t[42]=ee):ee=t[42],ee}function W(e){let t=e.currentTarget.value.length;e.currentTarget.setSelectionRange(t,t)}function G(e){return e.stopPropagation()}function K(e){return e.stopPropagation()}var q=`${Ce}
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
  }`,mt=[];function ht(e){return e===`left`?`deletions`:`additions`}function gt(e){return e===`deletions`?`left`:`right`}function X({environmentId:e,reference:t,detail:n,selectedCommitOid:r,onSelectedCommitChange:i,pendingFinding:d,fixFindingLabel:v=`Fix in a thread`,onFixFinding:x,onAskAboutSelection:C,onRefresh:T,refreshToken:k=0}){let{resolvedTheme:P}=m(),re=ne(),[ie,ae]=(0,R.useState)(()=>new Set),[oe,ue]=(0,R.useState)(ft),[pe,he]=(0,R.useState)(null),[ve,Ce]=(0,R.useState)(`stacked`),[L,je]=(0,R.useState)(re.wordWrap),[Ne,Pe]=(0,R.useState)(null),[z,Fe]=(0,R.useState)(null),[Ie,Le]=(0,R.useState)(!1),[Re,ze]=(0,R.useState)(!1),[Be,Ve]=(0,R.useState)(!1),[He,B]=(0,R.useState)({key:``,cursor:null,slices:mt}),We=(0,R.useRef)(new Map),V=et(t),H=r,W=H===null?V:`${V}@${H}`;(0,R.useEffect)(()=>{Fe(null),Pe(null),ae(new Set),he(null),ue(ft),ze(!1),B({key:W,cursor:null,slices:mt}),We.current.clear()},[W]);let G=He.key===W?He.slices:mt,K=He.key===W?He.cursor:null,q=o(F.diff({environmentId:e,input:{...t,...K===null?{}:{cursor:K},...H===null?{}:{commit:H}}}));(0,R.useEffect)(()=>{let e=q.data;e!==null&&B(t=>{let n=t.key===W?t.slices:mt,r={cursor:K,patch:e.patch,truncated:e.truncated,nextCursor:e.nextCursor,omittedFileStats:e.omittedFileStats??[]},i=n.findIndex(e=>e.cursor===K);if(i===-1)return{key:W,cursor:K,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:W,cursor:K,slices:[...n.slice(0,i),r]}})},[K,q.data,W]);let Je=f(F.diff({environmentId:e,input:{...t,...H===null?{}:{commit:H}}})),Ye=(0,R.useRef)(k);(0,R.useEffect)(()=>{Ye.current!==k&&(Ye.current=k,B({key:W,cursor:null,slices:mt}),Je())},[k,W,Je]);let Ze=V,J=nt(t),tt=Y(e=>e.addComment),rt=Y(e=>e.removeComment),at=D(F.replyToThread,{reportFailure:!1}),ot=D(F.setThreadResolution,{reportFailure:!1}),st=D(F.updateComment,{reportFailure:!1}),ct=D(F.diffFileContents),lt=(0,R.useMemo)(()=>Ge(ct,{environmentId:e,reference:t,commit:H,cacheKey:`pull-request:${V}:${n.updatedAt}:${H??`all`}`}),[H,n.updatedAt,e,ct,t,V]),X=(0,R.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]),_t=X.inlineComment&&H===null,vt=(0,R.useMemo)(()=>G.map(e=>{let t=`pull-request:${W}:${P}:${e.cursor??`first`}:${xe(e.patch)}`,n=We.current.get(t);if(n)return n;let r=ke(e.patch,t,{compactPartialHunkOffsets:!0});return r&&We.current.set(t,r),r}),[G,P,W]),Z=(0,R.useMemo)(()=>vt.flatMap(e=>e?.kind===`files`?Ue(e.files):[]),[vt]),Q=G.at(-1)?.nextCursor??null,yt=G.some(e=>e.truncated)||vt.some(e=>e?.kind===`raw`),bt=(0,R.useMemo)(()=>{let e=new Set;if(H!==null)return e;for(let t of Z){let r=I(t);for(let i of n.reviewThreads)i.path===r&&i.line!==null&&ut(t,i.side,i.line)&&e.add(i.id)}return e},[H,n.reviewThreads,Z]),$=(0,R.useMemo)(()=>Z.map(e=>{let t=Oe(e),r=I(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||bt.has(e.id)&&a(e.side,e.line).threads.push(e);if(H===null)for(let e of J)e.path===r&&a(e.side,e.line).pending.push(e);z?.fileKey===t&&(a(z.side,z.line).draft=!0);let o=dt(t,pe,ie),s=[...i.values()].map(e=>({side:ht(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:xe(`${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(`|`)}`)}}),[H,n.reviewThreads,z,Z,pe,J,bt,ie]),xt=(0,R.useMemo)(()=>Te(Z),[Z]),St=(0,R.useMemo)(()=>new Map(G.flatMap(e=>e.omittedFileStats.map(e=>[e.path,e]))),[G]),Ct=(0,R.useMemo)(()=>$.map(e=>e.id),[$]),wt=(0,R.useMemo)(()=>new Set($.filter(e=>e.collapsed===!0).map(e=>e.id)),[$]),Tt=N(Ct,wt),[Et,Dt]=(0,R.useState)(null);(0,R.useEffect)(()=>{if(Et===null||Q===null||Q===K||q.isPending||q.error!==null)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&B(e=>({...e,cursor:Q}))},{rootMargin:`240px`});return e.observe(Et),()=>e.disconnect()},[K,q.error,q.isPending,Q,Et]);let Ot=(0,R.useCallback)(e=>ae(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),kt=()=>{he(N(Ct,wt)?`expanded`:`folded`),ae(new Set)},At=(0,R.useMemo)(()=>n.commits.toSorted((e,t)=>Date.parse(t.committedDate)-Date.parse(e.committedDate)),[n.commits]),jt=(0,R.useCallback)((e,t)=>{if(!e||!_t)return;let n=t.item;if(n.type!==`diff`)return;let r=Z.find(e=>Oe(e)===n.id);if(!r)return;let i=I(r),a=Ae(r);Fe({fileKey:n.id,path:i,oldPath:a===i?null:a,line:e.end,side:gt(e.endSide??e.side),range:e})},[_t,Z]),Mt=(0,R.useCallback)((e,t)=>{let r=Z.find(t=>Oe(t)===e.fileKey),i=r===void 0?null:O({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:r,range:e.range,text:t});Fe(null),Pe(null),!(i===null||!C)&&C({comment:i,question:t})},[n.number,Z,C]),Nt=(0,R.useCallback)(()=>Q===null?null:(0,U.jsx)(`div`,{ref:Dt,className:`flex items-center justify-center gap-2 py-2 text-xs text-muted-foreground`,children:q.error===null?q.isPending?`Loading more files...`:null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{children:`The rest of this diff could not be loaded.`}),(0,U.jsx)(u,{size:`xs`,variant:`outline`,onClick:()=>q.refresh(),children:`Retry`})]})}),[Q,q.error,q.isPending,q.refresh]),Pt=(0,R.useCallback)(e=>{let t=e.collapsed===!0;return(0,U.jsx)(`button`,{type:`button`,"aria-expanded":!t,"aria-label":t?`Expand diff`:`Collapse diff`,className:c(`mr-1 inline-flex size-5 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground`),onClick:t=>{t.stopPropagation(),Ot(e.id)},children:t?(0,U.jsx)(w,{className:`size-4`}):(0,U.jsx)(h,{className:`size-4`})})},[Ot]),Ft=(0,R.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=St.get(I(e.fileDiff));r&&({additions:t,deletions:n}=r)}return(0,U.jsx)(ce,{additions:t,deletions:n,className:`font-mono text-[11px]`})},[St]),It=(0,R.useMemo)(()=>({diffStyle:ve===`split`?`split`:`unified`,lineDiffType:`none`,overflow:L?`wrap`:`scroll`,theme:ye(P),themeType:P,stickyHeaders:!0,loadDiffFiles:lt,enableGutterUtility:_t&&z===null,enableLineSelection:_t&&z===null,onGutterUtilityClick:jt,onLineSelectionEnd:jt}),[ve,L,P,lt,_t,z,jt]),Lt=(0,R.useCallback)(async(e,t)=>{if(Ie)return!1;Le(!0);let n=await t();return Le(!1),n._tag===`Failure`?(g.add({type:`error`,title:e}),!1):(T(),!0)},[T,Ie]),Rt=(0,R.useCallback)(r=>(0,U.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:d===me({kind:`thread`,thread:r}),fixLabel:v,...x?{onFix:()=>x({kind:`thread`,thread:r})}:{},onReply:n=>Lt(`Reply could not be posted`,()=>at({environmentId:e,input:{...t,threadId:r.id,body:n}})),canEditComment:e=>fe(n,{author:e.author,kind:`review-comment`}),onEditComment:(n,r)=>Lt(`The comment could not be saved`,()=>st({environmentId:e,input:{...t,commentId:n,kind:`review-comment`,body:r}})),onToggleResolved:()=>void Lt(`The conversation could not be updated`,()=>ot({environmentId:e,input:{...t,threadId:r.id,resolved:!r.isResolved}})),onReacted:T},`${t.projectId}#${t.number}:${r.id}`),[n,e,v,T,x,d,t,at,X.reply,X.resolve,Lt,ot,Ie,st]),zt=(0,R.useCallback)(e=>(0,U.jsxs)(`div`,{className:`py-1 font-sans text-foreground`,children:[e.metadata.threads.map(Rt),e.metadata.pending.map(e=>(0,U.jsx)(Xe,{comment:e,onRemove:()=>rt(Ze,e.id)},e.id)),e.metadata.draft&&z?(0,U.jsx)(Ke,{kind:`draft`,rangeLabel:`${z.path}:${z.line}`,text:``,submitLabel:`Add to review`,...C?{secondaryAction:{label:`Ask`,icon:(0,U.jsx)(de,{className:`size-3`}),allowEmpty:!0,onAction:e=>Mt(z,e)}}:{},onCancel:()=>{Fe(null),Pe(null)},onComment:e=>{tt(Ze,{id:$e(),path:z.path,...z.oldPath===null?{}:{oldPath:z.oldPath},line:z.line,side:z.side,body:e}),Fe(null),Pe(null)}}):null]}),[tt,Mt,z,C,rt,Rt,Ze]),Bt=X.verdicts.length===0?null:(0,U.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10`,children:Be?(0,U.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,U.jsx)(u,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Close review`,className:`absolute right-2 top-2`,onClick:()=>Ve(!1),children:(0,U.jsx)(a,{className:`size-3.5`})}),(0,U.jsx)(it,{environmentId:e,reference:t,verdicts:X.verdicts,onSubmitted:()=>{T(),Ve(!1)}})]}):(0,U.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,U.jsx)(ge,{className:`size-3.5`}),`Review`,J.length>0?(0,U.jsx)(`span`,{className:`flex size-4 items-center justify-center rounded-full bg-accent text-[10px] tabular-nums text-accent-foreground`,children:J.length}):null]})}),Vt=At.find(e=>e.oid===H);(0,R.useEffect)(()=>{H!==null&&Vt===void 0&&i(null)},[H,i,Vt]);let Ht=Vt?Vt.messageHeadline:`All commits`,Ut=(0,U.jsxs)(`div`,{className:`surface-subheader justify-between gap-2 px-4 text-xs text-muted-foreground`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[At.length>0?(0,U.jsxs)(S,{children:[(0,U.jsxs)(p,{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: ${Ht}`,children:[(0,U.jsx)(`span`,{className:`truncate`,children:Ht}),(0,U.jsx)(h,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,U.jsxs)(l,{align:`start`,className:`w-80`,children:[(0,U.jsx)(s,{className:H===null?`bg-foreground/[0.08]`:void 0,onClick:()=>i(null),children:(0,U.jsx)(`span`,{children:`All commits`})}),At.slice(0,oe).map(e=>(0,U.jsxs)(s,{className:e.oid===H?`bg-foreground/[0.08]`:void 0,onClick:()=>i(e.oid),children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,title:e.messageHeadline,children:e.messageHeadline}),(0,U.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-xs text-muted-foreground`,children:e.oid.slice(0,7)})]},e.oid)),At.length>oe?(0,U.jsx)(s,{closeOnClick:!1,onClick:()=>ue(e=>e+ft),children:(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Show more (`,At.length-oe,` left)`]})}):null]})]}):null,(0,U.jsxs)(Ee,{children:[(0,U.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[Z.length,` `,Z.length===1?`file`:`files`,Q===null?``:`+`]}),yt?(0,U.jsxs)(b,{children:[(0,U.jsx)(E,{render:(0,U.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,U.jsx)(_,{"aria-label":`Some of this diff was not shown`,className:`size-3.5 text-amber-600 dark:text-amber-500`})}),(0,U.jsx)(y,{side:`bottom`,children:`The host withheld part of this diff — a binary file, or a change too large to inline.`})]}):null,H!==null&&X.inlineComment?(0,U.jsxs)(b,{children:[(0,U.jsx)(E,{render:(0,U.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,U.jsx)(Me,{"aria-label":`Line comments are written from the whole change`,className:`size-3.5`})}),(0,U.jsx)(y,{side:`bottom`,children:`A comment is anchored to the whole change, so switch to All commits to write one.`})]}):null]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,U.jsx)(ce,{additions:xt.additions,deletions:xt.deletions,className:`mr-1`}),Ct.length>0?(0,U.jsxs)(b,{children:[(0,U.jsx)(E,{render:(0,U.jsx)(u,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":Tt?`Expand all files`:`Collapse all files`,onClick:kt}),children:Tt?(0,U.jsx)(we,{className:`size-3.5`}):(0,U.jsx)(A,{className:`size-3.5`})}),(0,U.jsx)(y,{side:`top`,children:Tt?`Expand all files`:`Collapse all files`})]}):null,(0,U.jsxs)(j,{className:`shrink-0 gap-1`,size:`sm`,value:[ve],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&Ce(t)},children:[(0,U.jsx)(te,{"aria-label":`Stacked diff view`,value:`stacked`,variant:`ghost`,children:(0,U.jsx)(M,{className:`size-3.5`})}),(0,U.jsx)(te,{"aria-label":`Split diff view`,value:`split`,variant:`ghost`,children:(0,U.jsx)(ee,{className:`size-3.5`})})]}),(0,U.jsxs)(b,{children:[(0,U.jsx)(E,{render:(0,U.jsx)(te,{"aria-label":L?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`ghost`,size:`sm`,pressed:L,onPressedChange:e=>{je(!!e)}}),children:(0,U.jsx)(le,{className:`size-3.5`})}),(0,U.jsx)(y,{side:`top`,children:L?`Disable line wrapping`:`Enable line wrapping`})]})]})]}),Wt=e=>(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ut,(0,U.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`h-full overflow-auto`,children:e}),Bt]})]});if(q.isPending&&G.length===0)return Wt((0,U.jsx)(se,{label:`Loading pull request diff...`}));if(q.error&&G.length===0)return Wt((0,U.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:q.error}));let Gt=Q===null?vt.flatMap(e=>e?.kind===`raw`?[e]:[]):[];if(Z.length===0&&Gt.length>0)return Wt((0,U.jsx)(`div`,{className:`space-y-4 px-4 py-5`,children:Gt.map(e=>(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,U.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 Wt((0,U.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:H===null?`This pull request has no file changes.`:`This commit has no file changes.`}));let Kt=n.reviewThreads.filter(e=>!bt.has(e.id)),qt=new Map;for(let e of Kt){let t=qt.get(e.path);t?t.push(e):qt.set(e.path,[e])}let Jt=Gt.length===0?null:(0,U.jsx)(`div`,{className:`space-y-4 border-t border-border/60 px-4 py-5`,children:Gt.map(e=>(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,U.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))});return(0,U.jsx)(_e,{children:(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ut,qt.size>0?(0,U.jsxs)(Se,{className:`shrink-0 border-b border-border/60`,open:Re,onOpenChange:ze,children:[(0,U.jsx)(`h2`,{children:(0,U.jsxs)(be,{className:`flex w-full items-center gap-1.5 px-4 py-2 text-left text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{children:Q===null?`Conversations not on the current diff`:`Conversations not on the diff loaded so far`}),(0,U.jsx)(w,{"aria-hidden":!0,className:c(`size-3.5 transition-transform`,Re&&`rotate-90`)}),(0,U.jsx)(`span`,{"aria-hidden":!0,className:`tabular-nums`,children:Kt.length}),(0,U.jsx)(`span`,{className:`sr-only`,children:Kt.length===1?`1 conversation`:`${Kt.length} conversations`})]})}),(0,U.jsx)(De,{children:(0,U.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-auto px-4 pb-3`,children:[...qt].map(([e,t])=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`truncate px-3 text-xs text-muted-foreground`,title:e,children:e}),(0,U.jsx)(`div`,{className:`mt-1 space-y-2`,children:t.map(e=>(0,U.jsxs)(`div`,{children:[e.line===null?null:(0,U.jsxs)(`p`,{className:`px-3 text-xs text-muted-foreground`,children:[`Line `,e.line]}),Rt(e)]},e.id))})]},e))})})]}):null,(0,U.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=>I(e.fileDiff)===t);n!==void 0&&Ot(n.id);return}}},children:[(0,U.jsx)(qe,{className:`h-full overflow-auto [scrollbar-gutter:stable]`,items:$,selectedLines:Ne,onSelectedLinesChange:Pe,options:It,renderCodeViewFooter:Nt,renderHeaderPrefix:Pt,renderHeaderMetadata:Ft,renderAnnotation:zt,unsafeCSSExtra:pt}),Bt]}),Jt]})})}export{X as PullRequestCodeTab,X as default};
251
- //# sourceMappingURL=PullRequestCodeTab-BdwnQcgi.js.map
251
+ //# sourceMappingURL=PullRequestCodeTab-cFyorjex.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,Oa as a}from"./previewAssetResource-CVDZ-YAw.js";import{Ir as o,Xr as s}from"./index-BWxnfRz6.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-CxfDb72Y.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,Oa as a}from"./previewAssetResource-CVDZ-YAw.js";import{Ir as o,Xr as s}from"./index-CBqRo4NV.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-Ddmzci4v.js.map