@p4code/cli 0.1.42 → 0.1.43
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/bin.mjs +192 -5
- package/dist/client/assets/{DiffPanel-Fkx320pf.js → DiffPanel-DxLjTzhm.js} +3 -3
- package/dist/client/assets/{FilePreviewPanel-C2yNJGyo.js → FilePreviewPanel-BU7Mk4RS.js} +5 -5
- package/dist/client/assets/PreviewPanel-CXo-rO6p.js +2 -0
- package/dist/client/assets/{PullRequestCodeTab-Dfo7dBea.js → PullRequestCodeTab-DZ21ejVE.js} +4 -4
- package/dist/client/assets/arrow-right-D65fEYm2.js +2 -0
- package/dist/client/assets/{fileCommentAnnotations-BlpdYBe1.js → fileCommentAnnotations-BYDMZrEt.js} +2 -2
- package/dist/client/assets/index-B_53grxr.css +1 -0
- package/dist/client/assets/{index-CtyxZK6c.js → index-JhM5IhMk.js} +229 -223
- package/dist/client/assets/{renderFileChildren-CP7za9_L.js → renderFileChildren-D1Bb4hre.js} +2 -2
- package/dist/client/assets/terminal-links-94yCfJ0N.js +46 -0
- package/dist/client/assets/{toggle-group-M7OekiUB.js → toggle-group-C7yP6sy7.js} +2 -2
- package/dist/client/index.html +3 -3
- package/package.json +1 -1
- package/dist/client/assets/PreviewPanel-1ZLXoIEg.js +0 -2
- package/dist/client/assets/arrow-right-D8Wjnujk.js +0 -2
- package/dist/client/assets/index-aHlWbnM4.css +0 -1
- package/dist/client/assets/terminal-links-C80Bdiy3.js +0 -46
|
@@ -0,0 +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{$r as i,E as a,Ic as o,Js as s,Mc as c,P as l,Qu as u,S as d,Sc as f,T as p,Yr as m,ai as h,b as g,ci as _,di as v,ed as y,en as b,fi as x,ii as S,js as C,kc as w,li as T,ni as E,oi as D,ri as O,u as k,uc as ee,ui as A,v as te,vl as ne,w as j,wc as M,xc as N,xi as P,y as re,yc as ie}from"./terminal-links-94yCfJ0N.js";import{t as F}from"./arrow-right-D65fEYm2.js";import{A as I,Ar as L,Cr as ae,Dr as R,Er as z,Gn as B,Gr as oe,Jr as se,Kn as V,Kr as ce,M as le,N as H,O as ue,Or as U,P as W,Qr as de,R as G,Sr as fe,Tr as K,Un as q,Wn as J,Yr as pe,Zr as me,_r as he,a as ge,ai as _e,br as ve,c as ye,ci as be,g as xe,gr as Se,hr as Ce,i as we,j as Te,jr as Y,k as X,kr as Ee,mi as De,n as Oe,nt as ke,o as Ae,qn as je,r as Me,s as Ne,t as Pe,vr as Fe,wr as Ie,xr as Le,yr as Re}from"./index-JhM5IhMk.js";var ze=C(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),Be=C(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Ve=C(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),He=C(`radio-tower`,[[`path`,{d:`M4.9 16.1C1 12.2 1 5.8 4.9 1.9`,key:`s0qx1y`}],[`path`,{d:`M7.8 4.7a6.14 6.14 0 0 0-.8 7.5`,key:`1idnkw`}],[`circle`,{cx:`12`,cy:`9`,r:`2`,key:`1092wv`}],[`path`,{d:`M16.2 4.8c2 2 2.26 5.11.8 7.47`,key:`ojru2q`}],[`path`,{d:`M19.1 1.9a9.96 9.96 0 0 1 0 14.1`,key:`rhi7fg`}],[`path`,{d:`M9.5 18h5`,key:`mfy3pd`}],[`path`,{d:`m8 22 4-11 4 11`,key:`25yftu`}]]),Z=e(n(),1),Q=r(),$=t();function Ue(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=x(`relative inline-flex w-full min-w-0 items-center rounded-lg border border-input bg-background not-dark:bg-clip-padding text-base text-foreground shadow-xs/5 ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_1px_--theme(--color-black/4%)] has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/64 has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/16 has-[textarea]:h-auto has-data-[align=block-end]:h-auto has-data-[align=block-start]:h-auto has-data-[align=block-end]:flex-col has-data-[align=block-start]:flex-col has-[input:focus-visible,textarea:focus-visible]:border-ring has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/36 has-autofill:bg-foreground/4 has-[input:disabled,textarea:disabled]:opacity-64 has-[input:disabled,textarea:disabled,input:focus-visible,textarea:focus-visible,input[aria-invalid],textarea[aria-invalid]]:shadow-none has-[input:focus-visible,textarea:focus-visible]:ring-[3px] sm:text-sm dark:bg-input/32 dark:has-autofill:bg-foreground/8 dark:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/24 dark:not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_-1px_--theme(--color-white/6%)] has-data-[align=inline-start]:**:[[data-size=sm]_input]:ps-1.5 has-data-[align=inline-end]:**:[[data-size=sm]_input]:pe-1.5 *:[[data-slot=input-control],[data-slot=textarea-control]]:contents *:[[data-slot=input-control],[data-slot=textarea-control]]:before:hidden has-[[data-align=block-start],[data-align=block-end]]:**:[input]:h-auto has-data-[align=inline-start]:**:[input]:ps-2 has-data-[align=inline-end]:**:[input]:pe-2 has-data-[align=block-end]:**:[input]:pt-1.5 has-data-[align=block-start]:**:[input]:pb-1.5 **:[textarea]:min-h-20.5 **:[textarea]:resize-none **:[textarea]:py-[calc(--spacing(3)-1px)] **:[textarea]:max-sm:min-h-23.5 **:[textarea_button]:rounded-[calc(var(--radius-md)-1px)]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{className:i,"data-slot":`input-group`,role:`group`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var We=P(`[&_svg]:-mx-0.5 flex h-auto cursor-text select-none items-center justify-center gap-2 leading-none [&>kbd]:rounded-[calc(var(--radius)-5px)] in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4.5 sm:in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4 not-has-[button]:**:[svg:not([class*='opacity-'])]:opacity-80`,{defaultVariants:{align:`inline-start`},variants:{align:{"block-end":`order-last w-full justify-start px-[calc(--spacing(3)-1px)] pb-[calc(--spacing(3)-1px)] [.border-t]:pt-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]`,"block-start":`order-first w-full justify-start px-[calc(--spacing(3)-1px)] pt-[calc(--spacing(3)-1px)] [.border-b]:pb-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]`,"inline-end":`has-[>:last-child[data-slot=badge]]:-me-1.5 has-[>button]:-me-2 order-last pe-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:me-[-0.35rem] [[data-size=sm]+&]:pe-[calc(--spacing(2.5)-1px)]`,"inline-start":`has-[>:last-child[data-slot=badge]]:-ms-1.5 has-[>button]:-ms-2 order-first ps-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:ms-[-0.35rem] [[data-size=sm]+&]:ps-[calc(--spacing(2.5)-1px)]`}}});function Ge(e){let t=(0,Q.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,o;t[4]!==a||t[5]!==n?(o=x(We({align:a}),n),t[4]=a,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,$.jsx)(`div`,{className:o,"data-align":a,"data-slot":`input-group-addon`,onMouseDown:Ke,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function Ke(e){if(e.target.closest(`button, a, input, select, textarea, [role='button'], [role='combobox'], [role='listbox'], [data-slot='select-trigger']`))return;e.preventDefault();let t=e.currentTarget.parentElement,n=t?.querySelector(`input, textarea`);n&&!t?.querySelector(`input:focus, textarea:focus`)&&n.focus()}function qe(e){let t=(0,Q.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,$.jsx)(Ce,{className:n,unstyled:!0,...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}var Je=()=>{};function Ye(e){let t=(0,Q.c)(98),{url:n,displayUrl:r,loading:i,loadProgress:a,canGoBack:o,canGoForward:s,refreshDisabled:c,inputDisabled:l,focusUrlNonce:u,onBack:f,onForward:p,onRefresh:h,onSubmit:_,onOpenInBrowser:v,onCapture:y,captureDisabled:b,recording:S,onPictureInPicture:C,pictureInPicture:w,pictureInPictureDisabled:T,onPickElement:E,pickActive:D,pickDisabled:O,pickDisabledReason:k,trailingActions:ee}=e,A=(0,Z.useRef)(null),[te,ne]=(0,Z.useState)(n),[j,M]=(0,Z.useState)(!1),N,P;t[0]===u?(N=t[1],P=t[2]):(N=()=>{if(u==null)return;let e=A.current;e&&e.focus()},P=[u],t[0]=u,t[1]=N,t[2]=P),(0,Z.useEffect)(N,P);let ie;t[3]!==te||t[4]!==_?(ie=e=>{e?.preventDefault();let t=te.trim();t.length!==0&&(_(t),A.current?.blur())},t[3]=te,t[4]=_,t[5]=ie):ie=t[5];let I=ie,L=o?f:Je,ae=!o,R;t[6]!==L||t[7]!==ae?(R=(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,onClick:L,disabled:ae,"aria-label":`Back`,type:`button`}),t[6]=L,t[7]=ae,t[8]=R):R=t[8];let z;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(De,{}),t[9]=z):z=t[9];let B;t[10]===R?B=t[11]:(B=(0,$.jsx)(d,{render:R,children:z}),t[10]=R,t[11]=B);let se;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(g,{children:`Back`}),t[12]=se):se=t[12];let V;t[13]===B?V=t[14]:(V=(0,$.jsxs)(re,{children:[B,se]}),t[13]=B,t[14]=V);let ce=s?p:Je,le=!s,H;t[15]!==ce||t[16]!==le?(H=(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,onClick:ce,disabled:le,"aria-label":`Forward`,type:`button`}),t[15]=ce,t[16]=le,t[17]=H):H=t[17];let ue;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(F,{}),t[18]=ue):ue=t[18];let U;t[19]===H?U=t[20]:(U=(0,$.jsx)(d,{render:H,children:ue}),t[19]=H,t[20]=U);let W;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(g,{children:`Forward`}),t[21]=W):W=t[21];let de;t[22]===U?de=t[23]:(de=(0,$.jsxs)(re,{children:[U,W]}),t[22]=U,t[23]=de);let G=c?Je:h,fe=i?`Stop`:`Refresh`,K;t[24]!==c||t[25]!==G||t[26]!==fe?(K=(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,onClick:G,disabled:c,"aria-label":fe,type:`button`}),t[24]=c,t[25]=G,t[26]=fe,t[27]=K):K=t[27];let q=i&&`animate-spin`,J;t[28]===q?J=t[29]:(J=x(q),t[28]=q,t[29]=J);let he;t[30]===J?he=t[31]:(he=(0,$.jsx)(oe,{className:J}),t[30]=J,t[31]=he);let ge;t[32]!==K||t[33]!==he?(ge=(0,$.jsx)(d,{render:K,children:he}),t[32]=K,t[33]=he,t[34]=ge):ge=t[34];let _e=i?`Loading…`:`Refresh`,ve;t[35]===_e?ve=t[36]:(ve=(0,$.jsx)(g,{children:_e}),t[35]=_e,t[36]=ve);let ye;t[37]!==ge||t[38]!==ve?(ye=(0,$.jsxs)(re,{children:[ge,ve]}),t[37]=ge,t[38]=ve,t[39]=ye):ye=t[39];let xe;t[40]!==V||t[41]!==de||t[42]!==ye?(xe=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[V,de,ye]}),t[40]=V,t[41]=de,t[42]=ye,t[43]=xe):xe=t[43];let Se=j?te:r??n,Ce=v&&!j&&`group-hover/address:pe-7 transition-[padding]`,we;t[44]===Ce?we=t[45]:(we=x(Ce),t[44]=Ce,t[45]=we);let Te;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>ne(e.target.value),t[46]=Te):Te=t[46];let Y;t[47]===n?Y=t[48]:(Y=()=>{ne(n),M(!0),queueMicrotask(()=>A.current?.select())},t[47]=n,t[48]=Y);let X;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(X=()=>{M(!1)},t[49]=X):X=t[49];let Ee;t[50]!==I||t[51]!==n?(Ee=e=>{e.key===`Enter`&&I(e),e.key===`Escape`&&(e.preventDefault(),ne(n),A.current?.blur())},t[50]=I,t[51]=n,t[52]=Ee):Ee=t[52];let Oe;t[53]!==l||t[54]!==Se||t[55]!==we||t[56]!==Y||t[57]!==Ee?(Oe=(0,$.jsx)(d,{render:(0,$.jsx)(qe,{ref:A,value:Se,className:we,onChange:Te,onFocus:Y,onBlur:X,onKeyDown:Ee,placeholder:`Search or enter URL`,spellCheck:!1,disabled:l,"data-preview-url-input":!0,size:`sm`})}),t[53]=l,t[54]=Se,t[55]=we,t[56]=Y,t[57]=Ee,t[58]=Oe):Oe=t[58];let ke;t[59]!==r||t[60]!==j||t[61]!==n?(ke=!j&&r?(0,$.jsx)(g,{children:n}):null,t[59]=r,t[60]=j,t[61]=n,t[62]=ke):ke=t[62];let Ae;t[63]!==Oe||t[64]!==ke?(Ae=(0,$.jsxs)(re,{children:[Oe,ke]}),t[63]=Oe,t[64]=ke,t[65]=Ae):Ae=t[65];let je;t[66]!==j||t[67]!==v?(je=v&&!j?(0,$.jsx)(Ge,{align:`inline-end`,className:`pointer-events-none absolute inset-y-0 right-0 opacity-0 transition-opacity group-hover/address:pointer-events-auto group-hover/address:opacity-100`,children:(0,$.jsxs)(re,{children:[(0,$.jsx)(d,{render:(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,onClick:v,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(be,{})}),(0,$.jsx)(g,{children:`Open in system browser`})]})}):null,t[66]=j,t[67]=v,t[68]=je):je=t[68];let Me;t[69]!==Ae||t[70]!==je?(Me=(0,$.jsxs)(Ue,{className:`group/address h-7 flex-1 rounded-md border-transparent bg-transparent shadow-none before:shadow-none hover:bg-muted/40 focus-within:bg-background`,children:[Ae,je]}),t[69]=Ae,t[70]=je,t[71]=Me):Me=t[71];let Ne;t[72]!==E||t[73]!==D||t[74]!==O||t[75]!==k?(Ne=E?(0,$.jsxs)(re,{children:[(0,$.jsx)(d,{render:(0,$.jsx)(m,{variant:D?`secondary`:`ghost`,size:`icon-xs`,onClick:E,disabled:O,"aria-label":D?`Cancel annotation`:`Annotate preview`,"aria-pressed":D?`true`:`false`,type:`button`}),children:(0,$.jsx)(me,{className:x(D&&`text-primary`)})}),(0,$.jsx)(g,{children:O&&k?k:D?`Cancel annotation (Esc)`:`Annotate elements, regions, and drawings`})]}):null,t[72]=E,t[73]=D,t[74]=O,t[75]=k,t[76]=Ne):Ne=t[76];let Pe;t[77]!==b||t[78]!==y||t[79]!==S?(Pe=y?(0,$.jsxs)(re,{children:[(0,$.jsxs)(d,{render:(0,$.jsx)(m,{variant:S?`secondary`:`ghost`,size:`icon-xs`,onClick:e=>y(e.shiftKey),"aria-label":S?`Stop recording`:`Capture screenshot`,type:`button`,className:`relative`,disabled:b}),children:[(0,$.jsx)(ze,{className:x(S&&`text-destructive`)}),S?(0,$.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 animate-status-pulse rounded-full bg-destructive`}):null]}),(0,$.jsx)(g,{children:S?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[77]=b,t[78]=y,t[79]=S,t[80]=Pe):Pe=t[80];let Fe;t[81]!==C||t[82]!==w||t[83]!==T?(Fe=C?(0,$.jsxs)(re,{children:[(0,$.jsx)(d,{render:(0,$.jsx)(m,{variant:w?`secondary`:`ghost`,size:`icon-xs`,onClick:C,"aria-label":w?`Close floating preview`:`Float preview over chat`,"aria-pressed":w?`true`:`false`,type:`button`,disabled:T}),children:(0,$.jsx)(pe,{className:x(w&&`text-primary`)})}),(0,$.jsx)(g,{children:w?`Close floating preview`:`Float preview over chat`})]}):null,t[81]=C,t[82]=w,t[83]=T,t[84]=Fe):Fe=t[84];let Ie;t[85]!==I||t[86]!==xe||t[87]!==Me||t[88]!==Ne||t[89]!==Pe||t[90]!==Fe||t[91]!==ee?(Ie=(0,$.jsxs)(`form`,{onSubmit:I,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[xe,Me,Ne,Pe,Fe,ee]}),t[85]=I,t[86]=xe,t[87]=Me,t[88]=Ne,t[89]=Pe,t[90]=Fe,t[91]=ee,t[92]=Ie):Ie=t[92];let Le;t[93]===a?Le=t[94]:(Le=a>0?(0,$.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute bottom-0 left-0 z-10 h-0.5 rounded-r-full bg-primary transition-all duration-150 ease-out`,style:{width:`${a}%`,boxShadow:`0 0 6px 1px var(--color-ring)`}}):null,t[93]=a,t[94]=Le);let Re;return t[95]!==Ie||t[96]!==Le?(Re=(0,$.jsxs)(`div`,{className:`relative`,children:[Ie,Le]}),t[95]=Ie,t[96]=Le,t[97]=Re):Re=t[97],Re}function Xe(e){try{let t=new URL(e.url),n=new URL(e.environmentHttpBaseUrl);if(t.origin===n.origin&&t.pathname.startsWith(`/api/assets/`)){let n=t.pathname.split(`/`).at(-1);if(!n)return null;let r=decodeURIComponent(n);return!r||r===`.`||r===`..`?null:`${e.environmentLabel} · ${r}`}return t.protocol===`http:`||t.protocol===`https:`?t.host:null}catch{return null}}function Ze(e){let t=(0,Q.c)(6),{className:n}=e,r;t[0]===n?r=t[1]:(r=x(`relative flex flex-col gap-0.5 overflow-hidden rounded-[5px] border border-border/60 bg-card p-1 shadow-xs/5`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-destructive/80`}),(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-warning/80`}),(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-success/80`})]}),t[2]=i):i=t[2];let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(`div`,{className:`mt-[1px] flex flex-1 flex-col gap-[2px]`,children:[(0,$.jsx)(`span`,{className:`h-[2px] w-full rounded-full bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-[2px] w-3/5 rounded-full bg-muted-foreground/20`})]}),t[3]=a):a=t[3];let o;return t[4]===r?o=t[5]:(o=(0,$.jsxs)(`div`,{"aria-hidden":!0,className:r,children:[i,a]}),t[4]=r,t[5]=o),o}function Qe(e){let t=(0,Q.c)(17),{server:n,onOpen:r}=e,i;t[0]===n?i=t[1]:(i=$e(n),t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Ze,{className:`size-7 shrink-0`}),t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:a}),t[3]=a,t[4]=s);let c;t[5]!==n.host||t[6]!==n.port?(c=(0,$.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[n.host,`:`,n.port]}),t[5]=n.host,t[6]=n.port,t[7]=c):c=t[7];let l;t[8]!==s||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[s,c]}),t[8]=s,t[9]=c,t[10]=l):l=t[10];let u;t[11]===n.listening?u=t[12]:(u=n.listening?(0,$.jsx)(et,{}):(0,$.jsx)(tt,{}),t[11]=n.listening,t[12]=u);let d;return t[13]!==r||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex w-full items-center gap-3 px-3 py-3 text-left hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[o,l,u]}),t[13]=r,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function $e(e){return e.processName?e.processName:e.listening?`Listening`:e.source===`configured`?`Configured`:`Recently seen`}function et(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`span`,{"aria-label":`Listening`,className:`relative inline-flex size-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inset-0 animate-status-ping rounded-full bg-success opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-success`})]}),e[0]=t):t=e[0],t}function tt(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`span`,{"aria-label":`Not currently listening`,className:`size-2 shrink-0 rounded-full bg-muted-foreground/40`}),e[0]=t):t=e[0],t}function nt(e){let t=(0,Q.c)(7),n=U(e.environmentId),r;if(t[0]!==e.configuredUrls||t[1]!==e.environmentId||t[2]!==e.recentlySeenUrls||t[3]!==n){let i;t[5]===e.environmentId?i=t[6]:(i=t=>({...t,url:K(e.environmentId,t.url)}),t[5]=e.environmentId,t[6]=i),r=rt({scanner:n.map(i),configuredUrls:e.configuredUrls??[],recentlySeenUrls:e.recentlySeenUrls??[]}),t[0]=e.configuredUrls,t[1]=e.environmentId,t[2]=e.recentlySeenUrls,t[3]=n,t[4]=r}else r=t[4];return r}function rt(e){let t=new Map;for(let n of e.configuredUrls){let e=at(n);if(!e)continue;let r=it(e.host,e.port);t.has(r)||t.set(r,{host:e.host,port:e.port,url:e.url,processName:null,pid:null,terminal:null,source:`configured`,listening:!1})}for(let n of e.scanner){let e=it(n.host,n.port),r=t.get(e);if(r){t.set(e,{...r,processName:n.processName??r.processName,pid:n.pid??r.pid,terminal:n.terminal??r.terminal,listening:!0});continue}t.set(e,{...n,source:`scanner`,listening:!0})}for(let n of e.recentlySeenUrls){let e=at(n);if(!e)continue;let r=it(e.host,e.port);t.has(r)||t.set(r,{host:e.host,port:e.port,url:e.url,processName:null,pid:null,terminal:null,source:`recent`,listening:!1})}return Array.from(t.values()).toSorted((e,t)=>{let n={configured:0,scanner:1,recent:2};return n[e.source]===n[t.source]?e.port-t.port:n[e.source]-n[t.source]})}function it(e,t){return`${e.toLowerCase()}:${t}`}function at(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`||!z(t.hostname))return null;let n=t.port?Number.parseInt(t.port,10):t.protocol===`http:`?80:443;return!Number.isFinite(n)||n<=0?null:{host:t.hostname,port:n,url:t.href}}catch{return null}}function ot(e){let t=(0,Q.c)(16),{environmentId:n,configuredUrls:r,recentlySeenUrls:i,onOpenUrl:a}=e,o;t[0]!==r||t[1]!==n||t[2]!==i?(o={environmentId:n,configuredUrls:r,recentlySeenUrls:i},t[0]=r,t[1]=n,t[2]=i,t[3]=o):o=t[3];let s=nt(o);if(s.length===0){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(q,{children:[(0,$.jsx)(B,{variant:`icon`,children:(0,$.jsx)(_e,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(V,{children:`No preview yet`}),(0,$.jsx)(J,{children:`Type a URL above, or run a dev script. Listening localhost ports will show up here automatically.`})]}),t[4]=e):e=t[4],e}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(He,{className:`size-4 shrink-0`}),(0,$.jsx)(`h2`,{className:`font-medium`,children:`Local servers`})]}),t[5]=c):c=t[5];let l;if(t[6]!==a||t[7]!==s){let e;t[9]===a?e=t[10]:(e=e=>(0,$.jsx)(Qe,{server:e,onOpen:()=>a(e.url)},`${e.host}:${e.port}`),t[9]=a,t[10]=e),l=s.map(e),t[6]=a,t[7]=s,t[8]=l}else l=t[8];let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60 overflow-hidden rounded-xl border border-border/70 bg-background`,children:l}),t[11]=l,t[12]=u);let d;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:`Select a listening port to open it in this browser tab.`}),t[13]=d):d=t[13];let f;return t[14]===u?f=t[15]:(f=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 overflow-y-auto px-5 py-8`,children:(0,$.jsxs)(`div`,{className:`m-auto flex w-full max-w-xl flex-col gap-3`,children:[c,u,d]})}),t[14]=u,t[15]=f),f}var st=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function ct(e){let t=(0,Q.c)(74),{tabId:n,hasWebContents:r,zoomFactor:a,colorScheme:o,deviceToolbarVisible:s,onToggleDeviceToolbar:c,nativePictureInPicture:l,onNativePictureInPicture:u}=e;if(!X)return null;let f=!n||!r,p;t[0]===n?p=t[1]:(p=e=>()=>{n&&e(n).catch(gt)},t[0]=n,t[1]=p);let h=p,y;t[2]===a?y=t[3]:(y=Math.round(a*100),t[2]=a,t[3]=y);let b=`${y}%`,x;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsxs)(re,{children:[(0,$.jsx)(d,{render:(0,$.jsx)(v,{render:(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(Be,{})}),(0,$.jsx)(g,{children:`More`})]}),t[4]=x):x=t[4];let C;t[5]===h?C=t[6]:(C=h(X.hardReload),t[5]=h,t[6]=C);let w;t[7]!==C||t[8]!==f?(w=(0,$.jsx)(E,{onClick:C,disabled:f,children:`Hard reload`}),t[7]=C,t[8]=f,t[9]=w):w=t[9];let k;t[10]===h?k=t[11]:(k=h(X.openDevTools),t[10]=h,t[11]=k);let ee;t[12]!==k||t[13]!==f?(ee=(0,$.jsx)(E,{onClick:k,disabled:f,children:`Open DevTools`}),t[12]=k,t[13]=f,t[14]=ee):ee=t[14];let te=l?`Close separate preview window`:`Open separate preview window`,ne;t[15]!==u||t[16]!==te||t[17]!==f?(ne=(0,$.jsx)(E,{onClick:u,disabled:f,children:te}),t[15]=u,t[16]=te,t[17]=f,t[18]=ne):ne=t[18];let j=s?`Hide device toolbar`:`Show device toolbar`,M;t[19]!==c||t[20]!==j||t[21]!==f?(M=(0,$.jsx)(E,{onClick:c,disabled:f,children:j}),t[19]=c,t[20]=j,t[21]=f,t[22]=M):M=t[22];let N;t[23]===f?N=t[24]:(N=(0,$.jsx)(A,{disabled:f,children:`Appearance`}),t[23]=f,t[24]=N);let P;t[25]===n?P=t[26]:(P=e=>{n&&X.setColorScheme(n,e).catch(ht)},t[25]=n,t[26]=P);let ie;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ie=st.map(mt),t[27]=ie):ie=t[27];let F;t[28]!==o||t[29]!==P?(F=(0,$.jsx)(T,{className:`min-w-32`,children:(0,$.jsx)(S,{value:o,onValueChange:P,children:ie})}),t[28]=o,t[29]=P,t[30]=F):F=t[30];let I;t[31]!==N||t[32]!==F?(I=(0,$.jsxs)(_,{children:[N,F]}),t[31]=N,t[32]=F,t[33]=I):I=t[33];let L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(D,{}),t[34]=L):L=t[34];let ae;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(`span`,{children:`Zoom`}),t[35]=ae):ae=t[35];let R;t[36]===h?R=t[37]:(R=h(X.zoomOut),t[36]=h,t[37]=R);let z;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(de,{}),t[38]=z):z=t[38];let B;t[39]!==R||t[40]!==f?(B=(0,$.jsx)(m,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:R,"aria-label":`Zoom out`,disabled:f,children:z}),t[39]=R,t[40]=f,t[41]=B):B=t[41];let oe;t[42]===b?oe=t[43]:(oe=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:b}),t[42]=b,t[43]=oe);let V;t[44]===h?V=t[45]:(V=h(X.zoomIn),t[44]=h,t[45]=V);let le;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(se,{}),t[46]=le):le=t[46];let H;t[47]!==V||t[48]!==f?(H=(0,$.jsx)(m,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:V,"aria-label":`Zoom in`,disabled:f,children:le}),t[47]=V,t[48]=f,t[49]=H):H=t[49];let ue;t[50]===h?ue=t[51]:(ue=h(X.resetZoom),t[50]=h,t[51]=ue);let U;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(ce,{}),t[52]=U):U=t[52];let W;t[53]!==ue||t[54]!==f?(W=(0,$.jsx)(m,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:ue,"aria-label":`Reset zoom`,disabled:f,children:U}),t[53]=ue,t[54]=f,t[55]=W):W=t[55];let G;t[56]!==B||t[57]!==oe||t[58]!==H||t[59]!==W?(G=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[B,oe,H,W]}),t[56]=B,t[57]=oe,t[58]=H,t[59]=W,t[60]=G):G=t[60];let fe;t[61]!==G||t[62]!==f?(fe=(0,$.jsxs)(E,{closeOnClick:!1,onClick:pt,className:`justify-between`,disabled:f,children:[ae,G]}),t[61]=G,t[62]=f,t[63]=fe):fe=t[63];let K,q,J;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(D,{}),q=(0,$.jsx)(E,{onClick:dt,children:`Clear cookies`}),J=(0,$.jsx)(E,{onClick:lt,children:`Clear cache`}),t[64]=K,t[65]=q,t[66]=J):(K=t[64],q=t[65],J=t[66]);let pe;return t[67]!==M||t[68]!==I||t[69]!==fe||t[70]!==w||t[71]!==ee||t[72]!==ne?(pe=(0,$.jsxs)(i,{children:[x,(0,$.jsxs)(O,{align:`end`,sideOffset:6,className:`min-w-56`,children:[w,ee,ne,M,I,L,fe,K,q,J]})]}),t[67]=M,t[68]=I,t[69]=fe,t[70]=w,t[71]=ee,t[72]=ne,t[73]=pe):pe=t[73],pe}function lt(){X.clearCache().catch(ut)}function ut(){}function dt(){X.clearCookies().catch(ft)}function ft(){}function pt(e){return e.preventDefault()}function mt(e){return(0,$.jsx)(h,{value:e.value,children:e.label},e.value)}function ht(){}function gt(){}function _t(e){return Ie[e]||(e.length>0?e:`Network error`)}function vt(e){let t=(0,Q.c)(32),{url:n,code:r,description:i,onReload:a}=e,[o,s]=(0,Z.useState)(!1),c;t[0]===n?c=t[1]:(c=xt(n)??n,t[0]=n,t[1]=c);let l=c,u;t[2]===i?u=t[3]:(u=_t(i),t[2]=i,t[3]=u);let d=u,f;t[4]!==r||t[5]!==i?(f=i.length>0?i:`ERR_${Math.abs(r)||`FAILED`}`,t[4]=r,t[5]=i,t[6]=f):f=t[6];let p=f,h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(bt,{className:`mb-6 size-12 text-muted-foreground/70`}),g=(0,$.jsx)(`h1`,{className:`mb-3 text-2xl font-semibold leading-tight text-foreground`,children:`This site can’t be reached`}),t[7]=h,t[8]=g):(h=t[7],g=t[8]);let _;t[9]===l?_=t[10]:(_=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:l}),t[9]=l,t[10]=_);let v;t[11]!==d||t[12]!==_?(v=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[_,`: `,d,`.`]}),t[11]=d,t[12]=_,t[13]=v):v=t[13];let y;t[14]===o?y=t[15]:(y=o?(0,$.jsxs)(`div`,{className:`mt-6 rounded-lg border border-border bg-muted/40 p-4 text-sm`,children:[(0,$.jsx)(`p`,{className:`mb-2 font-medium text-foreground`,children:`Try:`}),(0,$.jsxs)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:[(0,$.jsx)(`li`,{children:`Checking your connection`}),(0,$.jsx)(`li`,{children:`Confirming the dev server is running`}),(0,$.jsx)(`li`,{children:`Checking the proxy and the firewall`})]})]}):null,t[14]=o,t[15]=y);let b;t[16]===p?b=t[17]:(b=(0,$.jsx)(`div`,{className:`mt-8 text-xs uppercase tracking-wide text-muted-foreground/70`,children:p}),t[16]=p,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>s(yt),t[18]=x):x=t[18];let S=o?`Hide details`:`Details`,C;t[19]===S?C=t[20]:(C=(0,$.jsx)(m,{type:`button`,variant:`outline`,size:`sm`,onClick:x,children:S}),t[19]=S,t[20]=C);let w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`div`,{className:`flex-1`}),t[21]=w):w=t[21];let T;t[22]===a?T=t[23]:(T=(0,$.jsx)(m,{type:`button`,size:`sm`,onClick:a,children:`Reload`}),t[22]=a,t[23]=T);let E;t[24]!==C||t[25]!==T?(E=(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-8`,children:[C,w,T]}),t[24]=C,t[25]=T,t[26]=E):E=t[26];let D;return t[27]!==E||t[28]!==v||t[29]!==y||t[30]!==b?(D=(0,$.jsx)(`div`,{className:`relative flex h-full min-h-0 w-full overflow-y-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-1 flex-col px-8 py-12 sm:py-16`,children:[h,g,v,y,b,E]})}),t[27]=E,t[28]=v,t[29]=y,t[30]=b,t[31]=D):D=t[31],D}function yt(e){return!e}function bt(e){let t=(0,Q.c)(5),{className:n}=e,r,i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`path`,{d:`M16 12 L48 12 L48 52 L16 52 Z`}),i=(0,$.jsx)(`path`,{d:`M22 22 L42 22 M22 30 L36 30 M22 38 L40 38`,strokeLinecap:`round`}),a=(0,$.jsx)(`path`,{d:`M52 8 L12 56`,strokeLinecap:`round`}),t[0]=r,t[1]=i,t[2]=a):(r=t[0],i=t[1],a=t[2]);let o;return t[3]===n?o=t[4]:(o=(0,$.jsxs)(`svg`,{viewBox:`0 0 64 64`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,className:n,children:[r,i,a]}),t[3]=n,t[4]=o),o}function xt(e){try{return new URL(e).host}catch{return null}}function St(e){let t=e.toLowerCase();return t.includes(`mac`)?`Reveal in Finder`:t.includes(`win`)?`Reveal in File Explorer`:`Reveal in Files`}var Ct=120,wt=220,Tt=4,Et=90,Dt=.08,Ot=.5;function kt(e){let[t,n]=(0,Z.useState)(0),r=(0,Z.useRef)(0);return r.current=t,(0,Z.useEffect)(()=>{if(!e){if(r.current===0)return;n(100);let e=window.setTimeout(()=>n(0),wt);return()=>window.clearTimeout(e)}n(e=>e>0&&e<95?e:Tt);let t=window.setInterval(()=>{let e=r.current;if(e>=Et)return;let t=Et-e,i=Math.max(Ot,t*Dt);n(Math.min(Et,e+i))},Ct);return()=>window.clearInterval(t)},[e]),t}var At=class extends y()(`PreviewSessionThreadKeyParseError`,{threadKey:u}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},jt=ie(e=>{let t=c(e);if(t===null)throw new At({threadKey:e});let n=Ee.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=Ee.events({environmentId:t.environmentId,input:{}});return N(e=>{let i=!1,a=0,o=e=>{w(e)&&ve(t,e.value)},s=r=>{if(!w(r)||r.value.threadId!==t.threadId)return;let i=Re(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}he(t,r.value)};e.addFinalizer(()=>{i=!0});let c=e.once(r);e.subscribe(n,e=>{o(e)}),e.subscribe(r,e=>{a+=1,s(e)}),queueMicrotask(()=>{i||(e.refresh(n),a===0&&s(c))})}).pipe(f(1e3),M(`preview:session-sync:${e}`))});function Mt(e){let t=(0,Q.c)(2),n;t[0]===e?n=t[1]:(n=jt(o(e)),t[0]=e,t[1]=n),s(n)}var Nt=1500,Pt=.001;function Ft(e){let t=(0,Q.c)(11),{zoomFactor:n}=e,[r,i]=(0,Z.useState)(!1),a=(0,Z.useRef)(n),o=(0,Z.useRef)(null),s,c;t[0]===n?(s=t[1],c=t[2]):(s=()=>{if(!(Math.abs(a.current-n)<Pt))return a.current=n,i(!0),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{i(!1),o.current=null},Nt),()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)}},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,Z.useEffect)(s,c);let l;t[3]===n?l=t[4]:(l=Math.round(n*100),t[3]=n,t[4]=l);let u=`${l}%`,d=!r,f=r?`opacity-100 translate-y-0`:`opacity-0 -translate-y-1`,p;t[5]===f?p=t[6]:(p=x(`pointer-events-none absolute top-3 right-3 z-20 select-none rounded-full border border-border/70 bg-popover/95 px-2.5 py-1 text-xs font-medium text-foreground shadow-md/10 backdrop-blur transition-all duration-200 ease-out`,f),t[5]=f,t[6]=p);let m;return t[7]!==u||t[8]!==d||t[9]!==p?(m=(0,$.jsx)(`div`,{"aria-hidden":d,className:p,children:u}),t[7]=u,t[8]=d,t[9]=p,t[10]=m):m=t[10],m}function It(e,t){return e?1:t===`human`?.18:.35}var Lt=700;function Rt(e){let t=(0,Q.c)(9),{tabId:n,zoomFactor:r,controller:i}=e,a;t[0]===n?a=t[1]:(a=e=>e.byTabId[n]??null,t[0]=n,t[1]=a);let o=ye(a),s;t[2]===n?s=t[3]:(s=e=>e.byTabId[n]?.content??null,t[2]=n,t[3]=s);let c=W(s);if(!o)return null;let l;return t[4]!==c||t[5]!==i||t[6]!==o||t[7]!==r?(l=(0,$.jsx)(zt,{event:o,content:c,zoomFactor:r,controller:i},o.sequence),t[4]=c,t[5]=i,t[6]=o,t[7]=r,t[8]=l):l=t[8],l}function zt(e){let t=(0,Q.c)(15),{event:n,content:r,zoomFactor:i,controller:a}=e,[o,s]=(0,Z.useState)(!0),c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=window.setTimeout(()=>s(!1),Lt);return()=>window.clearTimeout(e)},l=[],t[0]=c,t[1]=l):(c=t[0],l=t[1]),(0,Z.useEffect)(c,l);let u;t[2]!==o||t[3]!==a?(u=It(o,a),t[2]=o,t[3]=a,t[4]=u):u=t[4];let d=`translate3d(${n.x*i*(r?.scale??1)+(r?.x??0)-(r?.scrollLeft??0)}px, ${n.y*i*(r?.scale??1)+(r?.y??0)-(r?.scrollTop??0)}px, 0)`,f;t[5]!==u||t[6]!==d?(f={opacity:u,transform:d},t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;t[8]!==n.phase||t[9]!==n.sequence?(p=n.phase===`click`?(0,$.jsx)(`span`,{className:`absolute left-0.5 top-0.5 size-4 animate-status-ping rounded-full bg-primary/25 motion-reduce:animate-none`},n.sequence):null,t[8]=n.phase,t[9]=n.sequence,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Ve,{className:`relative size-5 -translate-x-0.5 -translate-y-0.5 fill-background text-primary drop-shadow-sm`,strokeWidth:2}),t[11]=m):m=t[11];let h;return t[12]!==f||t[13]!==p?(h=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute left-0 top-0 z-40 transition-[transform,opacity] duration-150 ease-out motion-reduce:transition-none`,style:f,"aria-hidden":`true`,"data-agent-browser-cursor":!0,children:[p,m]}),t[12]=f,t[13]=p,t[14]=h):h=t[14],h}var Bt=typeof window>`u`?null:l();function Vt({threadRef:e,tabId:t,configuredUrls:n,visible:r}){let[i,s]=(0,Z.useState)(void 0),[c,l]=(0,Z.useState)(!1),u=Ae(),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(!0),m=ae(e),h=Te(t=>I(t.byThreadKey,e)),g=b(e=>e.addPreviewAnnotation),_=b(e=>e.addImage),v=p(e.environmentId),y=a(e.environmentId),x=j(Ee.open),S=j(Ee.resize,`preview viewport resize`),{resolvedTheme:C}=k();Mt(e),(0,Z.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let w=t??m.activeTabId,T=w?le(e,m.serverEpoch,w):null,E=w&&T?u.has(T)?T:Me(e,w):null,D=w?m.sessions[w]??null:null,O=w?m.desktopByTabId[w]??null:null,A=D?.navStatus??{_tag:`Idle`},M=A._tag===`Idle`?``:A.url,N=O?.loading??A._tag===`Loading`,P=O?.canGoBack??D?.canGoBack??!1,re=O?.canGoForward??D?.canGoForward??!1,ie=A._tag===`Idle`,F=A._tag===`LoadFailed`,z=ue(D),B=O?.controller??`none`,oe=kt(N),se=M&&v&&y?Xe({url:M,environmentLabel:v.label,environmentHttpBaseUrl:y})??void 0:void 0,V=D?.viewport??ne,ce=W(e=>T?e.byTabId[T]?.rect??null:null),U=(0,Z.useCallback)(async t=>{T&&X?(await X.navigate(T,t),Le(e,t)):await Se({openPreview:x,threadRef:e,url:t})},[x,T,e]),de=(0,Z.useCallback)(async e=>{try{await U(R(e))}catch{}},[U]),G=(0,Z.useCallback)(async t=>{try{await U(K(e.environmentId,t))}catch{}},[U,e.environmentId]),q=(0,Z.useCallback)(()=>{X&&T&&X.refresh(T)},[T]),J=(0,Z.useCallback)(()=>{X&&T&&X.zoomIn(T)},[T]),pe=(0,Z.useCallback)(()=>{X&&T&&X.zoomOut(T)},[T]),me=(0,Z.useCallback)(()=>{X&&T&&X.resetZoom(T)},[T]),he=(0,Z.useCallback)(async t=>{if(!w)return;let n=await S({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:w,viewport:t}});if(n._tag===`Failure`){let e=ee(n);throw L.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}fe(e,n.value)},[S,w,e]),_e=()=>{if(!T)return;if(V._tag!==`fill`){Pe(T,ne).catch(()=>void 0);return}let e=ce?Ne(ce,O?.zoomFactor):{width:1024,height:768};Pe(T,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Z.useEffect)(()=>{if(T)return Oe(T,he)},[he,T]);let ve=(0,Z.useCallback)(()=>{X&&T&&X.goBack(T)},[T]),ye=(0,Z.useCallback)(()=>{X&&T&&X.goForward(T)},[T]),be=(0,Z.useCallback)(()=>{!Bt||!M||Bt.shell.openExternal(M).catch(()=>void 0)},[M]),Ce=(0,Z.useCallback)(()=>{if(w){if(h?.tabId===w){Te.getState().close(e);return}Te.getState().open(e,w),te.getState().close(e)}},[h?.tabId,w,e]),De=(0,Z.useCallback)(()=>{!X||!T||(O?.pictureInPicture?X.pictureInPicture.close:X.pictureInPicture.open)(T).catch(e=>{L.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[O?.pictureInPicture,T]),Fe=(0,Z.useCallback)(t=>{if(!X||!T||!w)return;let n=X;if(E){ge(E).then(e=>{if(!e)return;let t=!1,r,i=()=>{if(!navigator.clipboard?.writeText){L.update(r,Y({type:`error`,title:`Unable to copy recording path`,description:`Clipboard API unavailable.`,actionProps:a}));return}navigator.clipboard.writeText(e.path).then(()=>{t=!0,o(),window.setTimeout(()=>{t=!1,o()},2e3)},e=>{L.update(r,Y({type:`error`,title:`Unable to copy recording path`,description:e instanceof Error?e.message:`An error occurred.`,actionProps:a}))})},a={children:St(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},o=()=>{L.update(r,Y({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:t?`Copied!`:`Copy path`,disabled:t,onClick:i},secondaryActionVariant:`outline`}}))};r=L.add(Y({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:`Copy path`,onClick:i},secondaryActionVariant:`outline`}}))},e=>{L.add({type:`error`,title:`Unable to stop recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}if(t){we(T,e,w).catch(e=>{L.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}n.captureScreenshot(T).then(e=>{let t={children:St(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,n=`Screenshot saved`,o)=>{L.update(a,Y({type:e,title:n,description:o,actionProps:{children:i?`Copied!`:`Copy image`,disabled:i,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:r?`Copied!`:`Copy path`,disabled:r,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},s=()=>{if(!navigator.clipboard?.writeText){o(`error`,`Unable to copy screenshot path`,`Clipboard API unavailable.`);return}navigator.clipboard.writeText(e.path).then(()=>{r=!0,o(),window.setTimeout(()=>{r=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot path`,e instanceof Error?e.message:`An error occurred.`)})},c=()=>{n.copyArtifactToClipboard(e.path).then(()=>{i=!0,o(),window.setTimeout(()=>{i=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot`,e instanceof Error?e.message:`An error occurred.`)})};a=L.add(Y({type:`success`,title:`Screenshot saved`,actionProps:{children:`Copy image`,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:`Copy path`,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},e=>{L.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[E,T,w,e]),Ie=(0,Z.useCallback)(()=>{if(!X||!T)return;if(d.current){X.cancelPickElement(T).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;d.current=!0,l(!0),(async()=>{try{let t=await X.pickElement(T);if(!t)return;g(e,t);let n=await xe(t);n&&t.screenshot&&_(e,{type:`image`,id:t.id,name:n.name,mimeType:n.type,sizeBytes:n.size,previewUrl:t.screenshot.dataUrl,file:n})}catch{}finally{if(d.current=!1,f.current&&l(!1),t&&t.isConnected&&typeof t.focus==`function`)try{t.focus({preventScroll:!0})}catch{}}})()},[_,g,T,e]);return(0,Z.useEffect)(()=>{let e=ke(M,C);e&&U(e).catch(()=>void 0)},[U,C,M]),(0,Z.useEffect)(()=>()=>{d.current&&(d.current=!1,X&&T&&X.cancelPickElement(T).catch(()=>void 0),f.current&&l(!1))},[T]),(0,Z.useEffect)(()=>{if(r)return je(e=>{switch(e){case`refresh`:q();return;case`focus-url`:s(e=>(e??0)+1);return;case`zoom-in`:J();return;case`zoom-out`:pe();return;case`reset-zoom`:me();return;case`toggle-panel`:return}})},[q,me,J,pe,r]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":o(e),children:[(0,$.jsx)(Ye,{url:M,displayUrl:se,loading:N,loadProgress:oe,canGoBack:P,canGoForward:re,refreshDisabled:ie,focusUrlNonce:i,onBack:ve,onForward:ye,onRefresh:q,onSubmit:e=>void de(e),onOpenInBrowser:w?be:void 0,onCapture:X&&w?Fe:void 0,captureDisabled:!O||F,recording:E!==null,onPictureInPicture:X&&w?Ce:void 0,pictureInPicture:h?.tabId===w,pictureInPictureDisabled:!O?.hasWebContents||F,onPickElement:X&&w?Ie:void 0,pickActive:c,pickDisabled:!w||F,pickDisabledReason:F?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:X?(0,$.jsx)(ct,{tabId:T,hasWebContents:O?.hasWebContents??!1,zoomFactor:O?.zoomFactor??1,colorScheme:O?.colorScheme??`system`,deviceToolbarVisible:V._tag!==`fill`,onToggleDeviceToolbar:_e,nativePictureInPicture:O?.pictureInPicture??!1,onNativePictureInPicture:De}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[T&&D&&!z?(0,$.jsx)(H,{tabId:T,visible:r&&!F,className:`absolute inset-0 h-full w-full`},T):null,z?(0,$.jsx)(ot,{environmentId:e.environmentId,configuredUrls:n,recentlySeenUrls:m.recentlySeenUrls,onOpenUrl:e=>void G(e)}):null,D&&O?(0,$.jsx)(Ft,{zoomFactor:O.zoomFactor}):null,T&&O&&!z&&!F?(0,$.jsx)(Rt,{tabId:T,zoomFactor:O.zoomFactor,controller:B}):null,B===`none`?null:(0,$.jsx)(`div`,{className:`pointer-events-none absolute left-3 top-3 z-40 rounded-full border border-border/70 bg-background/90 px-2.5 py-1 text-[11px] font-medium shadow-sm backdrop-blur`,children:B===`agent`?`Agent controlling browser`:`Human control`}),A._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(vt,{url:A.url,code:A.code,description:A.description,onReload:q})}):null]})]})}function Ht(e){let t=(0,Q.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!Fe()){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:(0,$.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:`Preview is only available in the P4Code desktop app.`})}),t[0]=e):e=t[0];let r;return t[1]===n?r=t[2]:(r=(0,$.jsx)(G,{mode:n,children:e}),t[1]=n,t[2]=r),r}let s;t[3]===i?s=t[4]:(s=i===void 0?{}:{tabId:i},t[3]=i,t[4]=s);let c;t[5]!==a||t[6]!==s||t[7]!==r||t[8]!==o?(c=(0,$.jsx)(Vt,{threadRef:r,...s,configuredUrls:a,visible:o}),t[5]=a,t[6]=s,t[7]=r,t[8]=o,t[9]=c):c=t[9];let l;return t[10]!==n||t[11]!==c?(l=(0,$.jsx)(G,{mode:n,children:c}),t[10]=n,t[11]=c,t[12]=l):l=t[12],l}export{Ht as PreviewPanel};
|
|
2
|
+
//# sourceMappingURL=PreviewPanel-CXo-rO6p.js.map
|
package/dist/client/assets/{PullRequestCodeTab-Dfo7dBea.js → PullRequestCodeTab-DZ21ejVE.js}
RENAMED
|
@@ -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{$r as i,As as a,Es as o,Ks as s,Os as c,S as l,Yr as u,an as d,b as f,c as p,di as m,fi as h,j as g,js as _,ks as v,ni as y,ri as b,u as x,uc as S,vn as C,w,y as T}from"./terminal-links-
|
|
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{$r as i,As as a,Es as o,Ks as s,Os as c,S as l,Yr as u,an as d,b as f,c as p,di as m,fi as h,j as g,js as _,ks as v,ni as y,ri as b,u as x,uc as S,vn as C,w,y as T}from"./terminal-links-94yCfJ0N.js";import{a as E,n as D,o as O,r as k,s as A,t as j}from"./toggle-group-C7yP6sy7.js";import{Ar as M,B as N,Br as ee,G as te,H as ne,Hr as re,Jn as ie,K as ae,U as oe,Ur as se,V as P,Vr as ce,W as le,Xn as ue,Xr as de,Y as F,Yn as fe,_ as pe,at as me,ct as he,di as ge,dt as I,ei as _e,fi as ve,fr as ye,ft as be,ii as xe,it as Se,lt as Ce,ot as we,pi as Te,q as Ee,ti as De,ui as Oe,ut as ke,z as L,zr as Ae}from"./index-JhM5IhMk.js";var je=_(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Me=_(`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`]),z=new Set([`__snapshots__`,`__generated__`,`dist`,`build`,`vendor`]),B=new Set([`__tests__`,`tests`,`test`]),V=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`];function Pe(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=>z.has(e))?`generated`:/\.(?:test|spec)\./.test(n)||t.slice(0,-1).some(e=>B.has(e))?`test`:`source`}function Fe(e){let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(0,t):e}function Ie(e){return Fe(e.split(`/`).at(-1)??``)}function Le(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 Re=/(?:\bfrom|\bimport|\brequire\s*\()\s*\(?\s*["']([^"']+)["']/g;function ze(e,t,n,r){let i=new Set;for(let a of t){Re.lastIndex=0;let t=Re.exec(a);for(;t!==null;){let o=t[1]??``,s=o.startsWith(`.`)?Le(e,o):o,c=V.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(Ie(l));u!==void 0&&u!==e&&i.add(u),t=Re.exec(a)}}return i}function Be(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 Ve(e){return(e.split(`/`).at(-1)??``).replace(/\.(?:test|spec)\..*$/,``).replace(/\.[^.]+$/,``)}function He(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,Pe(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(Fe(e),e);let t=Ie(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,ze(e,[...n.additionLines,...n.deletionLines],i,o))}let c=Be(r,s),l=new Map;c.forEach((e,t)=>{let n=Ie(e);l.has(n)||l.set(n,t)});let u=[...t.keys()].filter(e=>n.get(e)===`test`).sort((e,t)=>(l.get(Ve(e))??2**53-1)-(l.get(Ve(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 Ue(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 We(e,t){return Ue(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 S(a);return a.value},t.cacheKey)}var H=r();function U(e,t,n){return!n&&(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&t.trim().length>0}var W=t();function Ge(e){let t=(0,H.c)(43),{kind:n,rangeLabel:r,text:i,onTextChange:a,onCancel:o,onComment:s,onDelete:c,placeholder:l,submitLabel:d,pending:f,secondaryAction:m}=e,h=l===void 0?`Add a comment…`:l,g=d===void 0?`Comment`:d,_=f===void 0?!1:f,[v,y]=(0,R.useState)(``),b=n===`draft`&&!a?v:i,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,W.jsx)(De,{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,W.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]===c?r=t[6]:(r=c?(0,W.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:c,children:(0,W.jsx)(ce,{className:`size-3`})}):null,t[5]=c,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,W.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:q,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]===a?w=t[11]:(w=e=>(a??y)(e.target.value),t[10]=a,t[11]=w);let T;t[12]!==o||t[13]!==s||t[14]!==_||t[15]!==S?(T=e=>{e.key===`Escape`&&(e.preventDefault(),o()),U(e,S,_)&&(e.preventDefault(),s(S))},t[12]=o,t[13]=s,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,W.jsx)(p,{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:G,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,W.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]===o?O=t[25]:(O=(0,W.jsx)(u,{className:`text-muted-foreground hover:text-foreground`,variant:`ghost`,size:`xs`,onClick:o,children:`Cancel`}),t[24]=o,t[25]=O);let k;t[26]!==m||t[27]!==S?(k=m?(0,W.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]!==s||t[30]!==S?(j=()=>s(S),t[29]=s,t[30]=S,t[31]=j):j=t[31];let M;t[32]!==g||t[33]!==A||t[34]!==j?(M=(0,W.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,W.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,W.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`px-3 py-2 font-sans text-foreground`,contentEditable:!1,onPointerDown:K,children:[E,N]}),t[40]=N,t[41]=E,t[42]=ee):ee=t[42],ee}function G(e){let t=e.currentTarget.value.length;e.currentTarget.setSelectionRange(t,t)}function K(e){return e.stopPropagation()}function q(e){return e.stopPropagation()}var J=`${Se}
|
|
2
2
|
:is(
|
|
3
3
|
[data-line],
|
|
4
4
|
[data-line-annotation],
|
|
@@ -243,9 +243,9 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}f
|
|
|
243
243
|
transition: none;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
`;function Ke(e){let t=(0,H.c)(18),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({options:r,viewerRef:o,className:n,unsafeCSSExtra:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===o?s=t[7]:(s=o?{ref:o}:{},t[6]=o,t[7]=s);let c=n?`diff-render-surface outline-none ${n}`:`diff-render-surface outline-none`,l=a?`${J}\n${a}`:J,u,d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u={diffHeaderHeight:32,hunkSeparatorHeight:24,spacing:0,paddingTop:0,paddingBottom:0},d={paddingTop:0,paddingBottom:0,gap:0},t[8]=u,t[9]=d):(u=t[8],d=t[9]);let f;t[10]!==r||t[11]!==l?(f={...r,unsafeCSS:l,itemMetrics:u,layout:d},t[10]=r,t[11]=l,t[12]=f):f=t[12];let p;return t[13]!==i||t[14]!==s||t[15]!==c||t[16]!==f?(p=(0,W.jsx)(E,{...i,...s,className:c,options:f}),t[13]=i,t[14]=s,t[15]=c,t[16]=f,t[17]=p):p=t[17],p}var qe=`mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 text-sm shadow-sm`;function Je(e){return t=>{t.key===`Escape`&&e.onCancel&&(t.preventDefault(),e.onCancel()),U(t,e.value,e.pending)&&(t.preventDefault(),e.onSubmit())}}function Ye(e){let t=(0,H.c)(11),{comment:n,onRemove:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=h(qe,`border-dashed`),t[0]=i):i=t[0];let a,o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,W.jsx)(_e,{className:`size-3.5`}),o=(0,W.jsx)(`span`,{children:`Pending — sent when you submit the review`}),t[1]=a,t[2]=o):(a=t[1],o=t[2]);let s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,W.jsx)(ce,{className:`size-3.5`}),t[3]=s):s=t[3];let c;t[4]===r?c=t[5]:(c=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[a,o,(0,W.jsx)(u,{size:`icon-xs`,variant:`ghost`,className:`ml-auto`,"aria-label":`Discard this comment`,onClick:r,children:s})]}),t[4]=r,t[5]=c);let l;t[6]===n.body?l=t[7]:(l=(0,W.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap leading-relaxed`,children:n.body}),t[6]=n.body,t[7]=l);let d;return t[8]!==c||t[9]!==l?(d=(0,W.jsxs)(`div`,{className:i,contentEditable:!1,onPointerDown:Xe,children:[c,l]}),t[8]=c,t[9]=l,t[10]=d):d=t[10],d}function Xe(e){return e.stopPropagation()}function Ze({thread:e,workspaceRoot:t,canReply:n,canResolve:r,canReact:i,environmentId:a,reference:o,pending:s,fixPending:c,fixLabel:l=`Fix in a thread`,onFix:d,onReply:f,canEditComment:m,onEditComment:h,onToggleResolved:g,onReacted:_}){let[v,y]=(0,R.useState)(!e.isResolved),[b,x]=(0,R.useState)(!1),[S,C]=(0,R.useState)(``),[w,T]=(0,R.useState)(null),[E,D]=(0,R.useState)(!1),O=(0,R.useRef)(!1),k=async(e,t)=>{if(E)return;D(!0);let n=await h(e,t);D(!1),n&&T(null)},A=async()=>{let e=S.trim();if(!(e.length===0||s||O.current)){O.current=!0;try{await f(e)&&(C(``),x(!1))}finally{O.current=!1}}};return(0,W.jsxs)(`div`,{className:qe,contentEditable:!1,onPointerDown:e=>e.stopPropagation(),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.isResolved?(0,W.jsx)(ge,{className:`size-3.5 text-emerald-600 dark:text-emerald-500`}):(0,W.jsx)(je,{className:`size-3.5`}),(0,W.jsxs)(`button`,{type:`button`,className:`hover:text-foreground`,"aria-expanded":v,onClick:()=>y(e=>!e),children:[e.isResolved?`Resolved`:`Open`,` · `,e.comments.length,` `,e.comments.length===1?`comment`:`comments`]}),e.isOutdated?(0,W.jsx)(`span`,{children:`outdated`}):null,d?(0,W.jsxs)(u,{size:`xs`,variant:`ghost`,className:`ml-auto`,disabled:s||c,onClick:d,children:[(0,W.jsx)(
|
|
246
|
+
`;function Ke(e){let t=(0,H.c)(18),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({options:r,viewerRef:o,className:n,unsafeCSSExtra:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===o?s=t[7]:(s=o?{ref:o}:{},t[6]=o,t[7]=s);let c=n?`diff-render-surface outline-none ${n}`:`diff-render-surface outline-none`,l=a?`${J}\n${a}`:J,u,d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u={diffHeaderHeight:32,hunkSeparatorHeight:24,spacing:0,paddingTop:0,paddingBottom:0},d={paddingTop:0,paddingBottom:0,gap:0},t[8]=u,t[9]=d):(u=t[8],d=t[9]);let f;t[10]!==r||t[11]!==l?(f={...r,unsafeCSS:l,itemMetrics:u,layout:d},t[10]=r,t[11]=l,t[12]=f):f=t[12];let p;return t[13]!==i||t[14]!==s||t[15]!==c||t[16]!==f?(p=(0,W.jsx)(E,{...i,...s,className:c,options:f}),t[13]=i,t[14]=s,t[15]=c,t[16]=f,t[17]=p):p=t[17],p}var qe=`mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 text-sm shadow-sm`;function Je(e){return t=>{t.key===`Escape`&&e.onCancel&&(t.preventDefault(),e.onCancel()),U(t,e.value,e.pending)&&(t.preventDefault(),e.onSubmit())}}function Ye(e){let t=(0,H.c)(11),{comment:n,onRemove:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=h(qe,`border-dashed`),t[0]=i):i=t[0];let a,o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,W.jsx)(_e,{className:`size-3.5`}),o=(0,W.jsx)(`span`,{children:`Pending — sent when you submit the review`}),t[1]=a,t[2]=o):(a=t[1],o=t[2]);let s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,W.jsx)(ce,{className:`size-3.5`}),t[3]=s):s=t[3];let c;t[4]===r?c=t[5]:(c=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[a,o,(0,W.jsx)(u,{size:`icon-xs`,variant:`ghost`,className:`ml-auto`,"aria-label":`Discard this comment`,onClick:r,children:s})]}),t[4]=r,t[5]=c);let l;t[6]===n.body?l=t[7]:(l=(0,W.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap leading-relaxed`,children:n.body}),t[6]=n.body,t[7]=l);let d;return t[8]!==c||t[9]!==l?(d=(0,W.jsxs)(`div`,{className:i,contentEditable:!1,onPointerDown:Xe,children:[c,l]}),t[8]=c,t[9]=l,t[10]=d):d=t[10],d}function Xe(e){return e.stopPropagation()}function Ze({thread:e,workspaceRoot:t,canReply:n,canResolve:r,canReact:i,environmentId:a,reference:o,pending:s,fixPending:c,fixLabel:l=`Fix in a thread`,onFix:d,onReply:f,canEditComment:m,onEditComment:h,onToggleResolved:g,onReacted:_}){let[v,y]=(0,R.useState)(!e.isResolved),[b,x]=(0,R.useState)(!1),[S,C]=(0,R.useState)(``),[w,T]=(0,R.useState)(null),[E,D]=(0,R.useState)(!1),O=(0,R.useRef)(!1),k=async(e,t)=>{if(E)return;D(!0);let n=await h(e,t);D(!1),n&&T(null)},A=async()=>{let e=S.trim();if(!(e.length===0||s||O.current)){O.current=!0;try{await f(e)&&(C(``),x(!1))}finally{O.current=!1}}};return(0,W.jsxs)(`div`,{className:qe,contentEditable:!1,onPointerDown:e=>e.stopPropagation(),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.isResolved?(0,W.jsx)(ge,{className:`size-3.5 text-emerald-600 dark:text-emerald-500`}):(0,W.jsx)(je,{className:`size-3.5`}),(0,W.jsxs)(`button`,{type:`button`,className:`hover:text-foreground`,"aria-expanded":v,onClick:()=>y(e=>!e),children:[e.isResolved?`Resolved`:`Open`,` · `,e.comments.length,` `,e.comments.length===1?`comment`:`comments`]}),e.isOutdated?(0,W.jsx)(`span`,{children:`outdated`}):null,d?(0,W.jsxs)(u,{size:`xs`,variant:`ghost`,className:`ml-auto`,disabled:s||c,onClick:d,children:[(0,W.jsx)(xe,{className:`size-3`}),c?`Preparing...`:l]}):null,r?(0,W.jsx)(u,{size:`xs`,variant:`ghost`,className:d?void 0:`ml-auto`,disabled:s,onClick:g,children:e.isResolved?`Unresolve`:`Resolve`}):null]}),v?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mt-2 space-y-3`,children:e.comments.map(e=>(0,W.jsxs)(`article`,{className:`group min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,W.jsx)(le,{actor:e.author,className:`text-foreground`}),(0,W.jsx)(`span`,{children:ye(e.createdAt)})]}),w===e.id?(0,W.jsx)(N,{className:`mt-1`,value:e.body,cwd:t,label:`Edit comment`,saving:E,onSave:t=>void k(e.id,t),onCancel:()=>T(null)}):(0,W.jsxs)(`div`,{className:`mt-1 flex items-start gap-1`,children:[(0,W.jsx)(P,{className:`min-w-0 flex-1 text-sm`,text:e.body,cwd:t}),m(e)?(0,W.jsx)(u,{size:`icon-xs`,variant:`ghost`,className:`shrink-0 text-muted-foreground opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 focus-visible:opacity-100`,"aria-label":`Edit comment`,onClick:()=>T(e.id),children:(0,W.jsx)(de,{className:`size-3`})}):null]}),(0,W.jsx)(L,{className:`mt-1.5`,reactions:e.reactions??[],canReact:i,subjectId:e.id,environmentId:a,reference:o,onRefresh:_})]},e.id))}),n?b?(0,W.jsxs)(`div`,{className:`mt-2`,children:[(0,W.jsx)(p,{autoFocus:!0,size:`sm`,value:S,placeholder:`Reply`,"aria-label":`Reply to this conversation`,onChange:e=>C(e.target.value),onKeyDown:Je({value:S,pending:s,onSubmit:()=>void A(),onCancel:()=>x(!1)})}),(0,W.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,W.jsx)(u,{size:`xs`,variant:`ghost`,onClick:()=>x(!1),children:`Cancel`}),(0,W.jsx)(u,{size:`xs`,disabled:s||S.trim().length===0,onClick:()=>void A(),children:`Reply`})]})]}):(0,W.jsx)(u,{size:`xs`,variant:`ghost`,className:`mt-2 px-1`,onClick:()=>x(!0),children:`Reply`}):null]}):null]})}var Qe=0;function $e(){return Qe+=1,`pending-review-comment-${Qe}`}function et(e){return`${e.projectId}/${e.repository}#${e.number}`}var tt=[],Y=C()(e=>({drafts:{},summaries:{},addComment:(t,n)=>e(e=>({drafts:{...e.drafts,[t]:[...e.drafts[t]??tt,n]}})),removeComment:(t,n)=>e(e=>{let r=(e.drafts[t]??tt).filter(e=>e.id!==n);if(r.length>0)return{drafts:{...e.drafts,[t]:r}};let{[t]:i,...a}=e.drafts;return{drafts:a}}),removeComments:(t,n)=>e(e=>{let r=new Set(n),i=(e.drafts[t]??tt).filter(e=>!r.has(e.id));if(i.length>0)return{drafts:{...e.drafts,[t]:i}};let{[t]:a,...o}=e.drafts;return{drafts:o}}),clear:t=>e(e=>{let{[t]:n,...r}=e.drafts;return{drafts:r}}),setSummary:(t,n)=>e(e=>({summaries:{...e.summaries,[t]:n}})),clearSummary:(t,n)=>e(e=>{if(e.summaries[t]!==n)return e;let{[t]:r,...i}=e.summaries;return{summaries:i}})}));function nt(e){let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>t.drafts[et(e)]??tt,t[0]=e,t[1]=n),Y(n)}var rt=[{value:`comment`,label:`Comment`,sent:`Review submitted`,icon:(0,W.jsx)(_e,{className:`size-3`})},{value:`approve`,label:`Approve`,sent:`Pull request approved`,icon:(0,W.jsx)(a,{className:`size-3`})},{value:`request-changes`,label:`Request changes`,sent:`Changes requested`,icon:(0,W.jsx)(Oe,{className:`size-3`})}];function it(e){let t=(0,H.c)(13),{environmentId:n,reference:r,verdicts:i,onSubmitted:a}=e,[o,s]=(0,R.useState)(!1),c=nt(r),l=et(r),d=Y(e=>e.summaries[l]??``),f=Y(lt),m=Y(ct),h=Y(st),g=Y(ot),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_={reportFailure:!1},t[0]=_):_=t[0];let v=w(F.submitReview,_),y;t[1]===i?y=t[2]:(y=e=>i.includes(e.value),t[1]=i,t[2]=y);let b=rt.filter(y);if(b.length===0)return null;let x=async e=>{if(o)return;let t=d,i=c;s(!0);let u=await v({environmentId:n,input:{...r,verdict:e.value,body:t,comments:i}});if(s(!1),u._tag===`Failure`){M.add({type:`error`,title:`The review could not be submitted`});return}m(l,i.map(at)),g(l,t),M.add({type:`success`,title:e.sent}),a()},S;t[3]!==d||t[4]!==c.length?(S=e=>e===`approve`||d.trim().length>0||c.length>0,t[3]=d,t[4]=c.length,t[5]=S):S=t[5];let C=S,T=c.length===0?`No line comments yet`:`${c.length} ${c.length===1?`comment`:`comments`} pending`,E;t[6]===T?E=t[7]:(E=(0,W.jsx)(`span`,{children:T}),t[6]=T,t[7]=E);let D=c.length>0?(0,W.jsx)(u,{size:`xs`,variant:`ghost`,disabled:o,onClick:()=>f(l),children:`Discard`}):null,O;t[8]!==E||t[9]!==D?(O=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[E,D]}),t[8]=E,t[9]=D,t[10]=O):O=t[10];let k=b.map(e=>(0,W.jsx)(u,{size:`xs`,variant:e.value===`comment`?`outline`:`default`,disabled:o||!C(e.value),onClick:()=>void x(e),children:(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e.icon,e.label]})},e.value)),A;return t[11]===k?A=t[12]:(A=(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:k}),t[11]=k,t[12]=A),(0,W.jsxs)(`div`,{className:`px-4 py-3`,children:[O,(0,W.jsx)(p,{size:`sm`,className:`mt-2`,value:d,placeholder:`Summarize your review (optional)`,"aria-label":`Review summary`,onChange:e=>h(l,e.target.value)}),A]})}function at(e){return e.id}function ot(e){return e.clearSummary}function st(e){return e.setSummary}function ct(e){return e.removeComments}function lt(e){return e.clear}function ut(e,t,n){return e.hunks.some(e=>t===`left`?n>=e.deletionStart&&n<e.deletionStart+e.deletionCount:n>=e.additionStart&&n<e.additionStart+e.additionCount)}function dt(e,t,n){let r=t!==`expanded`;return n.has(e)?!r:r}var ft=10,pt=`
|
|
247
247
|
[data-diffs-header] [data-additions-count],
|
|
248
248
|
[data-diffs-header] [data-deletions-count] {
|
|
249
249
|
display: none !important;
|
|
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:a,pendingFinding:p,fixFindingLabel:_=`Fix in a thread`,onFixFinding:S,onAskAboutSelection:C,onRefresh:E,refreshToken:N=0}){let{resolvedTheme:P}=x(),ce=Ae(),[le,de]=(0,R.useState)(()=>new Set),[ge,be]=(0,R.useState)(ft),[xe,Ce]=(0,R.useState)(null),[De,Oe]=(0,R.useState)(`stacked`),[L,je]=(0,R.useState)(ce.wordWrap),[Ne,z]=(0,R.useState)(null),[B,V]=(0,R.useState)(null),[Pe,Fe]=(0,R.useState)(!1),[Ie,Le]=(0,R.useState)(!1),[Re,ze]=(0,R.useState)(!1),[Be,Ve]=(0,R.useState)({key:``,cursor:null,slices:mt}),Ue=(0,R.useRef)(new Map),H=et(t),U=r,G=U===null?H:`${H}@${U}`;(0,R.useEffect)(()=>{V(null),z(null),de(new Set),Ce(null),be(ft),Le(!1),Ve({key:G,cursor:null,slices:mt}),Ue.current.clear()},[G]);let K=Be.key===G?Be.slices:mt,q=Be.key===G?Be.cursor:null,J=g(F.diff({environmentId:e,input:{...t,...q===null?{}:{cursor:q},...U===null?{}:{commit:U}}}));(0,R.useEffect)(()=>{let e=J.data;e!==null&&Ve(t=>{let n=t.key===G?t.slices:mt,r={cursor:q,patch:e.patch,truncated:e.truncated,nextCursor:e.nextCursor,omittedFileStats:e.omittedFileStats??[]},i=n.findIndex(e=>e.cursor===q);if(i===-1)return{key:G,cursor:q,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:G,cursor:q,slices:[...n.slice(0,i),r]}})},[q,J.data,G]);let qe=s(F.diff({environmentId:e,input:{...t,...U===null?{}:{commit:U}}})),Je=(0,R.useRef)(N);(0,R.useEffect)(()=>{Je.current!==N&&(Je.current=N,Ve({key:G,cursor:null,slices:mt}),qe())},[N,G,qe]);let Xe=H,Qe=nt(t),tt=Y(e=>e.addComment),rt=Y(e=>e.removeComment),at=w(F.replyToThread,{reportFailure:!1}),ot=w(F.setThreadResolution,{reportFailure:!1}),st=w(F.updateComment,{reportFailure:!1}),ct=w(F.diffFileContents),lt=(0,R.useMemo)(()=>We(ct,{environmentId:e,reference:t,commit:U,cacheKey:`pull-request:${H}:${n.updatedAt}:${U??`all`}`}),[U,n.updatedAt,e,ct,t,H]),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&&U===null,vt=(0,R.useMemo)(()=>K.map(e=>{let t=`pull-request:${G}:${P}:${e.cursor??`first`}:${we(e.patch)}`,n=Ue.current.get(t);if(n)return n;let r=Se(e.patch,t,{compactPartialHunkOffsets:!0});return r&&Ue.current.set(t,r),r}),[K,P,G]),Z=(0,R.useMemo)(()=>vt.flatMap(e=>e?.kind===`files`?He(e.files):[]),[vt]),Q=K.at(-1)?.nextCursor??null,yt=K.some(e=>e.truncated)||vt.some(e=>e?.kind===`raw`),bt=(0,R.useMemo)(()=>{let e=new Set;if(U!==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},[U,n.reviewThreads,Z]),$=(0,R.useMemo)(()=>Z.map(e=>{let t=me(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(U===null)for(let e of Qe)e.path===r&&a(e.side,e.line).pending.push(e);B?.fileKey===t&&(a(B.side,B.line).draft=!0);let o=dt(t,xe,le),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:we(`${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(`|`)}`)}}),[U,n.reviewThreads,B,Z,xe,Qe,bt,le]),xt=(0,R.useMemo)(()=>he(Z),[Z]),St=(0,R.useMemo)(()=>new Map(K.flatMap(e=>e.omittedFileStats.map(e=>[e.path,e]))),[K]),Ct=(0,R.useMemo)(()=>$.map(e=>e.id),[$]),wt=(0,R.useMemo)(()=>new Set($.filter(e=>e.collapsed===!0).map(e=>e.id)),[$]),Tt=k(Ct,wt),[Et,Dt]=(0,R.useState)(null);(0,R.useEffect)(()=>{if(Et===null||Q===null||Q===q||J.isPending||J.error!==null)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&Ve(e=>({...e,cursor:Q}))},{rootMargin:`240px`});return e.observe(Et),()=>e.disconnect()},[q,J.error,J.isPending,Q,Et]);let Ot=(0,R.useCallback)(e=>de(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),kt=()=>{Ce(k(Ct,wt)?`expanded`:`folded`),de(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=>me(e)===n.id);if(!r)return;let i=I(r),a=ye(r);V({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=>me(t)===e.fileKey),i=r===void 0?null:d({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});V(null),z(null),!(i===null||!C)&&C({comment:i,question:t})},[n.number,Z,C]),Nt=(0,R.useCallback)(()=>Q===null?null:(0,W.jsx)(`div`,{ref:Dt,className:`flex items-center justify-center gap-2 py-2 text-xs text-muted-foreground`,children:J.error===null?J.isPending?`Loading more files...`:null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{children:`The rest of this diff could not be loaded.`}),(0,W.jsx)(u,{size:`xs`,variant:`outline`,onClick:()=>J.refresh(),children:`Retry`})]})}),[Q,J.error,J.isPending,J.refresh]),Pt=(0,R.useCallback)(e=>{let t=e.collapsed===!0;return(0,W.jsx)(`button`,{type:`button`,"aria-expanded":!t,"aria-label":t?`Expand diff`:`Collapse diff`,className:h(`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,W.jsx)(c,{className:`size-4`}):(0,W.jsx)(v,{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,W.jsx)(te,{additions:t,deletions:n,className:`font-mono text-[11px]`})},[St]),It=(0,R.useMemo)(()=>({diffStyle:De===`split`?`split`:`unified`,lineDiffType:`none`,overflow:L?`wrap`:`scroll`,theme:ke(P),themeType:P,stickyHeaders:!0,loadDiffFiles:lt,enableGutterUtility:_t&&B===null,enableLineSelection:_t&&B===null,onGutterUtilityClick:jt,onLineSelectionEnd:jt}),[De,L,P,lt,_t,B,jt]),Lt=(0,R.useCallback)(async(e,t)=>{if(Pe)return!1;Fe(!0);let n=await t();return Fe(!1),n._tag===`Failure`?(M.add({type:`error`,title:e}),!1):(E(),!0)},[E,Pe]),Rt=(0,R.useCallback)(r=>(0,W.jsx)(Ze,{thread:r,workspaceRoot:n.workspaceRoot,canReply:X.reply,canResolve:X.resolve,canReact:n.capabilities.reactions===!0,environmentId:e,reference:t,pending:Pe,fixPending:p===oe({kind:`thread`,thread:r}),fixLabel:_,...S?{onFix:()=>S({kind:`thread`,thread:r})}:{},onReply:n=>Lt(`Reply could not be posted`,()=>at({environmentId:e,input:{...t,threadId:r.id,body:n}})),canEditComment:e=>ne(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:E},`${t.projectId}#${t.number}:${r.id}`),[n,e,_,E,S,p,t,at,X.reply,X.resolve,Lt,ot,Pe,st]),zt=(0,R.useCallback)(e=>(0,W.jsxs)(`div`,{className:`py-1 font-sans text-foreground`,children:[e.metadata.threads.map(Rt),e.metadata.pending.map(e=>(0,W.jsx)(Ye,{comment:e,onRemove:()=>rt(Xe,e.id)},e.id)),e.metadata.draft&&B?(0,W.jsx)(Ge,{kind:`draft`,rangeLabel:`${B.path}:${B.line}`,text:``,submitLabel:`Add to review`,...C?{secondaryAction:{label:`Ask`,icon:(0,W.jsx)(se,{className:`size-3`}),allowEmpty:!0,onAction:e=>Mt(B,e)}}:{},onCancel:()=>{V(null),z(null)},onComment:e=>{tt(Xe,{id:$e(),path:B.path,...B.oldPath===null?{}:{oldPath:B.oldPath},line:B.line,side:B.side,body:e}),V(null),z(null)}}):null]}),[tt,Mt,B,C,rt,Rt,Xe]),Bt=X.verdicts.length===0?null:(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10`,children:Re?(0,W.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,W.jsx)(u,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Close review`,className:`absolute right-2 top-2`,onClick:()=>ze(!1),children:(0,W.jsx)(o,{className:`size-3.5`})}),(0,W.jsx)(it,{environmentId:e,reference:t,verdicts:X.verdicts,onSubmitted:()=>{E(),ze(!1)}})]}):(0,W.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:()=>ze(!0),children:[(0,W.jsx)(_e,{className:`size-3.5`}),`Review`,Qe.length>0?(0,W.jsx)(`span`,{className:`flex size-4 items-center justify-center rounded-full bg-accent text-[10px] tabular-nums text-accent-foreground`,children:Qe.length}):null]})}),Vt=At.find(e=>e.oid===U);(0,R.useEffect)(()=>{U!==null&&Vt===void 0&&a(null)},[U,a,Vt]);let Ht=Vt?Vt.messageHeadline:`All commits`,Ut=(0,W.jsxs)(`div`,{className:`surface-subheader justify-between gap-2 px-4 text-xs text-muted-foreground`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[At.length>0?(0,W.jsxs)(i,{children:[(0,W.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: ${Ht}`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:Ht}),(0,W.jsx)(v,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,W.jsxs)(b,{align:`start`,className:`w-80`,children:[(0,W.jsx)(y,{className:U===null?`bg-foreground/[0.08]`:void 0,onClick:()=>a(null),children:(0,W.jsx)(`span`,{children:`All commits`})}),At.slice(0,ge).map(e=>(0,W.jsxs)(y,{className:e.oid===U?`bg-foreground/[0.08]`:void 0,onClick:()=>a(e.oid),children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate`,title:e.messageHeadline,children:e.messageHeadline}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-xs text-muted-foreground`,children:e.oid.slice(0,7)})]},e.oid)),At.length>ge?(0,W.jsx)(y,{closeOnClick:!1,onClick:()=>be(e=>e+ft),children:(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Show more (`,At.length-ge,` left)`]})}):null]})]}):null,(0,W.jsxs)(ae,{children:[(0,W.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[Z.length,` `,Z.length===1?`file`:`files`,Q===null?``:`+`]}),yt?(0,W.jsxs)(T,{children:[(0,W.jsx)(l,{render:(0,W.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,W.jsx)(ee,{"aria-label":`Some of this diff was not shown`,className:`size-3.5 text-amber-600 dark:text-amber-500`})}),(0,W.jsx)(f,{side:`bottom`,children:`The host withheld part of this diff — a binary file, or a change too large to inline.`})]}):null,U!==null&&X.inlineComment?(0,W.jsxs)(T,{children:[(0,W.jsx)(l,{render:(0,W.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,W.jsx)(Me,{"aria-label":`Line comments are written from the whole change`,className:`size-3.5`})}),(0,W.jsx)(f,{side:`bottom`,children:`A comment is anchored to the whole change, so switch to All commits to write one.`})]}):null]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.jsx)(te,{additions:xt.additions,deletions:xt.deletions,className:`mr-1`}),Ct.length>0?(0,W.jsxs)(T,{children:[(0,W.jsx)(l,{render:(0,W.jsx)(u,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":Tt?`Expand all files`:`Collapse all files`,onClick:kt}),children:Tt?(0,W.jsx)(ve,{className:`size-3.5`}):(0,W.jsx)(Te,{className:`size-3.5`})}),(0,W.jsx)(f,{side:`top`,children:Tt?`Expand all files`:`Collapse all files`})]}):null,(0,W.jsxs)(D,{className:`shrink-0 gap-1`,size:`sm`,value:[De],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&Oe(t)},children:[(0,W.jsx)(j,{"aria-label":`Stacked diff view`,value:`stacked`,variant:`ghost`,children:(0,W.jsx)(O,{className:`size-3.5`})}),(0,W.jsx)(j,{"aria-label":`Split diff view`,value:`split`,variant:`ghost`,children:(0,W.jsx)(A,{className:`size-3.5`})})]}),(0,W.jsxs)(T,{children:[(0,W.jsx)(l,{render:(0,W.jsx)(j,{"aria-label":L?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`ghost`,size:`sm`,pressed:L,onPressedChange:e=>{je(!!e)}}),children:(0,W.jsx)(re,{className:`size-3.5`})}),(0,W.jsx)(f,{side:`top`,children:L?`Disable line wrapping`:`Enable line wrapping`})]})]})]}),Wt=e=>(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ut,(0,W.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`h-full overflow-auto`,children:e}),Bt]})]});if(J.isPending&&K.length===0)return Wt((0,W.jsx)(Ee,{label:`Loading pull request diff...`}));if(J.error&&K.length===0)return Wt((0,W.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:J.error}));let Gt=Q===null?vt.flatMap(e=>e?.kind===`raw`?[e]:[]):[];if(Z.length===0&&Gt.length>0)return Wt((0,W.jsx)(`div`,{className:`space-y-4 px-4 py-5`,children:Gt.map(e=>(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,W.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,W.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:U===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,W.jsx)(`div`,{className:`space-y-4 border-t border-border/60 px-4 py-5`,children:Gt.map(e=>(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))});return(0,W.jsx)(pe,{children:(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ut,qt.size>0?(0,W.jsxs)(ie,{className:`shrink-0 border-b border-border/60`,open:Ie,onOpenChange:Le,children:[(0,W.jsx)(`h2`,{children:(0,W.jsxs)(ue,{className:`flex w-full items-center gap-1.5 px-4 py-2 text-left text-xs text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:Q===null?`Conversations not on the current diff`:`Conversations not on the diff loaded so far`}),(0,W.jsx)(c,{"aria-hidden":!0,className:h(`size-3.5 transition-transform`,Ie&&`rotate-90`)}),(0,W.jsx)(`span`,{"aria-hidden":!0,className:`tabular-nums`,children:Kt.length}),(0,W.jsx)(`span`,{className:`sr-only`,children:Kt.length===1?`1 conversation`:`${Kt.length} conversations`})]})}),(0,W.jsx)(fe,{children:(0,W.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-auto px-4 pb-3`,children:[...qt].map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`truncate px-3 text-xs text-muted-foreground`,title:e,children:e}),(0,W.jsx)(`div`,{className:`mt-1 space-y-2`,children:t.map(e=>(0,W.jsxs)(`div`,{children:[e.line===null?null:(0,W.jsxs)(`p`,{className:`px-3 text-xs text-muted-foreground`,children:[`Line `,e.line]}),Rt(e)]},e.id))})]},e))})})]}):null,(0,W.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,W.jsx)(Ke,{className:`h-full overflow-auto [scrollbar-gutter:stable]`,items:$,selectedLines:Ne,onSelectedLinesChange:z,options:It,renderCodeViewFooter:Nt,renderHeaderPrefix:Pt,renderHeaderMetadata:Ft,renderAnnotation:zt,unsafeCSSExtra:pt}),Bt]}),Jt]})})}export{X as PullRequestCodeTab,X as default};
|
|
251
|
-
//# sourceMappingURL=PullRequestCodeTab-
|
|
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:a,pendingFinding:p,fixFindingLabel:_=`Fix in a thread`,onFixFinding:S,onAskAboutSelection:C,onRefresh:E,refreshToken:N=0}){let{resolvedTheme:P}=x(),ce=Ae(),[le,de]=(0,R.useState)(()=>new Set),[ge,ye]=(0,R.useState)(ft),[xe,Se]=(0,R.useState)(null),[De,Oe]=(0,R.useState)(`stacked`),[L,je]=(0,R.useState)(ce.wordWrap),[Ne,z]=(0,R.useState)(null),[B,V]=(0,R.useState)(null),[Pe,Fe]=(0,R.useState)(!1),[Ie,Le]=(0,R.useState)(!1),[Re,ze]=(0,R.useState)(!1),[Be,Ve]=(0,R.useState)({key:``,cursor:null,slices:mt}),Ue=(0,R.useRef)(new Map),H=et(t),U=r,G=U===null?H:`${H}@${U}`;(0,R.useEffect)(()=>{V(null),z(null),de(new Set),Se(null),ye(ft),Le(!1),Ve({key:G,cursor:null,slices:mt}),Ue.current.clear()},[G]);let K=Be.key===G?Be.slices:mt,q=Be.key===G?Be.cursor:null,J=g(F.diff({environmentId:e,input:{...t,...q===null?{}:{cursor:q},...U===null?{}:{commit:U}}}));(0,R.useEffect)(()=>{let e=J.data;e!==null&&Ve(t=>{let n=t.key===G?t.slices:mt,r={cursor:q,patch:e.patch,truncated:e.truncated,nextCursor:e.nextCursor,omittedFileStats:e.omittedFileStats??[]},i=n.findIndex(e=>e.cursor===q);if(i===-1)return{key:G,cursor:q,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:G,cursor:q,slices:[...n.slice(0,i),r]}})},[q,J.data,G]);let qe=s(F.diff({environmentId:e,input:{...t,...U===null?{}:{commit:U}}})),Je=(0,R.useRef)(N);(0,R.useEffect)(()=>{Je.current!==N&&(Je.current=N,Ve({key:G,cursor:null,slices:mt}),qe())},[N,G,qe]);let Xe=H,Qe=nt(t),tt=Y(e=>e.addComment),rt=Y(e=>e.removeComment),at=w(F.replyToThread,{reportFailure:!1}),ot=w(F.setThreadResolution,{reportFailure:!1}),st=w(F.updateComment,{reportFailure:!1}),ct=w(F.diffFileContents),lt=(0,R.useMemo)(()=>We(ct,{environmentId:e,reference:t,commit:U,cacheKey:`pull-request:${H}:${n.updatedAt}:${U??`all`}`}),[U,n.updatedAt,e,ct,t,H]),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&&U===null,vt=(0,R.useMemo)(()=>K.map(e=>{let t=`pull-request:${G}:${P}:${e.cursor??`first`}:${we(e.patch)}`,n=Ue.current.get(t);if(n)return n;let r=Ce(e.patch,t,{compactPartialHunkOffsets:!0});return r&&Ue.current.set(t,r),r}),[K,P,G]),Z=(0,R.useMemo)(()=>vt.flatMap(e=>e?.kind===`files`?He(e.files):[]),[vt]),Q=K.at(-1)?.nextCursor??null,yt=K.some(e=>e.truncated)||vt.some(e=>e?.kind===`raw`),bt=(0,R.useMemo)(()=>{let e=new Set;if(U!==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},[U,n.reviewThreads,Z]),$=(0,R.useMemo)(()=>Z.map(e=>{let t=me(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(U===null)for(let e of Qe)e.path===r&&a(e.side,e.line).pending.push(e);B?.fileKey===t&&(a(B.side,B.line).draft=!0);let o=dt(t,xe,le),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:we(`${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(`|`)}`)}}),[U,n.reviewThreads,B,Z,xe,Qe,bt,le]),xt=(0,R.useMemo)(()=>he(Z),[Z]),St=(0,R.useMemo)(()=>new Map(K.flatMap(e=>e.omittedFileStats.map(e=>[e.path,e]))),[K]),Ct=(0,R.useMemo)(()=>$.map(e=>e.id),[$]),wt=(0,R.useMemo)(()=>new Set($.filter(e=>e.collapsed===!0).map(e=>e.id)),[$]),Tt=k(Ct,wt),[Et,Dt]=(0,R.useState)(null);(0,R.useEffect)(()=>{if(Et===null||Q===null||Q===q||J.isPending||J.error!==null)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&Ve(e=>({...e,cursor:Q}))},{rootMargin:`240px`});return e.observe(Et),()=>e.disconnect()},[q,J.error,J.isPending,Q,Et]);let Ot=(0,R.useCallback)(e=>de(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),kt=()=>{Se(k(Ct,wt)?`expanded`:`folded`),de(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=>me(e)===n.id);if(!r)return;let i=I(r),a=be(r);V({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=>me(t)===e.fileKey),i=r===void 0?null:d({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});V(null),z(null),!(i===null||!C)&&C({comment:i,question:t})},[n.number,Z,C]),Nt=(0,R.useCallback)(()=>Q===null?null:(0,W.jsx)(`div`,{ref:Dt,className:`flex items-center justify-center gap-2 py-2 text-xs text-muted-foreground`,children:J.error===null?J.isPending?`Loading more files...`:null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{children:`The rest of this diff could not be loaded.`}),(0,W.jsx)(u,{size:`xs`,variant:`outline`,onClick:()=>J.refresh(),children:`Retry`})]})}),[Q,J.error,J.isPending,J.refresh]),Pt=(0,R.useCallback)(e=>{let t=e.collapsed===!0;return(0,W.jsx)(`button`,{type:`button`,"aria-expanded":!t,"aria-label":t?`Expand diff`:`Collapse diff`,className:h(`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,W.jsx)(c,{className:`size-4`}):(0,W.jsx)(v,{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,W.jsx)(te,{additions:t,deletions:n,className:`font-mono text-[11px]`})},[St]),It=(0,R.useMemo)(()=>({diffStyle:De===`split`?`split`:`unified`,lineDiffType:`none`,overflow:L?`wrap`:`scroll`,theme:ke(P),themeType:P,stickyHeaders:!0,loadDiffFiles:lt,enableGutterUtility:_t&&B===null,enableLineSelection:_t&&B===null,onGutterUtilityClick:jt,onLineSelectionEnd:jt}),[De,L,P,lt,_t,B,jt]),Lt=(0,R.useCallback)(async(e,t)=>{if(Pe)return!1;Fe(!0);let n=await t();return Fe(!1),n._tag===`Failure`?(M.add({type:`error`,title:e}),!1):(E(),!0)},[E,Pe]),Rt=(0,R.useCallback)(r=>(0,W.jsx)(Ze,{thread:r,workspaceRoot:n.workspaceRoot,canReply:X.reply,canResolve:X.resolve,canReact:n.capabilities.reactions===!0,environmentId:e,reference:t,pending:Pe,fixPending:p===oe({kind:`thread`,thread:r}),fixLabel:_,...S?{onFix:()=>S({kind:`thread`,thread:r})}:{},onReply:n=>Lt(`Reply could not be posted`,()=>at({environmentId:e,input:{...t,threadId:r.id,body:n}})),canEditComment:e=>ne(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:E},`${t.projectId}#${t.number}:${r.id}`),[n,e,_,E,S,p,t,at,X.reply,X.resolve,Lt,ot,Pe,st]),zt=(0,R.useCallback)(e=>(0,W.jsxs)(`div`,{className:`py-1 font-sans text-foreground`,children:[e.metadata.threads.map(Rt),e.metadata.pending.map(e=>(0,W.jsx)(Ye,{comment:e,onRemove:()=>rt(Xe,e.id)},e.id)),e.metadata.draft&&B?(0,W.jsx)(Ge,{kind:`draft`,rangeLabel:`${B.path}:${B.line}`,text:``,submitLabel:`Add to review`,...C?{secondaryAction:{label:`Ask`,icon:(0,W.jsx)(se,{className:`size-3`}),allowEmpty:!0,onAction:e=>Mt(B,e)}}:{},onCancel:()=>{V(null),z(null)},onComment:e=>{tt(Xe,{id:$e(),path:B.path,...B.oldPath===null?{}:{oldPath:B.oldPath},line:B.line,side:B.side,body:e}),V(null),z(null)}}):null]}),[tt,Mt,B,C,rt,Rt,Xe]),Bt=X.verdicts.length===0?null:(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10`,children:Re?(0,W.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,W.jsx)(u,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Close review`,className:`absolute right-2 top-2`,onClick:()=>ze(!1),children:(0,W.jsx)(o,{className:`size-3.5`})}),(0,W.jsx)(it,{environmentId:e,reference:t,verdicts:X.verdicts,onSubmitted:()=>{E(),ze(!1)}})]}):(0,W.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:()=>ze(!0),children:[(0,W.jsx)(_e,{className:`size-3.5`}),`Review`,Qe.length>0?(0,W.jsx)(`span`,{className:`flex size-4 items-center justify-center rounded-full bg-accent text-[10px] tabular-nums text-accent-foreground`,children:Qe.length}):null]})}),Vt=At.find(e=>e.oid===U);(0,R.useEffect)(()=>{U!==null&&Vt===void 0&&a(null)},[U,a,Vt]);let Ht=Vt?Vt.messageHeadline:`All commits`,Ut=(0,W.jsxs)(`div`,{className:`surface-subheader justify-between gap-2 px-4 text-xs text-muted-foreground`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[At.length>0?(0,W.jsxs)(i,{children:[(0,W.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: ${Ht}`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:Ht}),(0,W.jsx)(v,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,W.jsxs)(b,{align:`start`,className:`w-80`,children:[(0,W.jsx)(y,{className:U===null?`bg-foreground/[0.08]`:void 0,onClick:()=>a(null),children:(0,W.jsx)(`span`,{children:`All commits`})}),At.slice(0,ge).map(e=>(0,W.jsxs)(y,{className:e.oid===U?`bg-foreground/[0.08]`:void 0,onClick:()=>a(e.oid),children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate`,title:e.messageHeadline,children:e.messageHeadline}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-xs text-muted-foreground`,children:e.oid.slice(0,7)})]},e.oid)),At.length>ge?(0,W.jsx)(y,{closeOnClick:!1,onClick:()=>ye(e=>e+ft),children:(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Show more (`,At.length-ge,` left)`]})}):null]})]}):null,(0,W.jsxs)(ae,{children:[(0,W.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[Z.length,` `,Z.length===1?`file`:`files`,Q===null?``:`+`]}),yt?(0,W.jsxs)(T,{children:[(0,W.jsx)(l,{render:(0,W.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,W.jsx)(ee,{"aria-label":`Some of this diff was not shown`,className:`size-3.5 text-amber-600 dark:text-amber-500`})}),(0,W.jsx)(f,{side:`bottom`,children:`The host withheld part of this diff — a binary file, or a change too large to inline.`})]}):null,U!==null&&X.inlineComment?(0,W.jsxs)(T,{children:[(0,W.jsx)(l,{render:(0,W.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,W.jsx)(Me,{"aria-label":`Line comments are written from the whole change`,className:`size-3.5`})}),(0,W.jsx)(f,{side:`bottom`,children:`A comment is anchored to the whole change, so switch to All commits to write one.`})]}):null]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.jsx)(te,{additions:xt.additions,deletions:xt.deletions,className:`mr-1`}),Ct.length>0?(0,W.jsxs)(T,{children:[(0,W.jsx)(l,{render:(0,W.jsx)(u,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":Tt?`Expand all files`:`Collapse all files`,onClick:kt}),children:Tt?(0,W.jsx)(ve,{className:`size-3.5`}):(0,W.jsx)(Te,{className:`size-3.5`})}),(0,W.jsx)(f,{side:`top`,children:Tt?`Expand all files`:`Collapse all files`})]}):null,(0,W.jsxs)(D,{className:`shrink-0 gap-1`,size:`sm`,value:[De],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&Oe(t)},children:[(0,W.jsx)(j,{"aria-label":`Stacked diff view`,value:`stacked`,variant:`ghost`,children:(0,W.jsx)(O,{className:`size-3.5`})}),(0,W.jsx)(j,{"aria-label":`Split diff view`,value:`split`,variant:`ghost`,children:(0,W.jsx)(A,{className:`size-3.5`})})]}),(0,W.jsxs)(T,{children:[(0,W.jsx)(l,{render:(0,W.jsx)(j,{"aria-label":L?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`ghost`,size:`sm`,pressed:L,onPressedChange:e=>{je(!!e)}}),children:(0,W.jsx)(re,{className:`size-3.5`})}),(0,W.jsx)(f,{side:`top`,children:L?`Disable line wrapping`:`Enable line wrapping`})]})]})]}),Wt=e=>(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ut,(0,W.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`h-full overflow-auto`,children:e}),Bt]})]});if(J.isPending&&K.length===0)return Wt((0,W.jsx)(Ee,{label:`Loading pull request diff...`}));if(J.error&&K.length===0)return Wt((0,W.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:J.error}));let Gt=Q===null?vt.flatMap(e=>e?.kind===`raw`?[e]:[]):[];if(Z.length===0&&Gt.length>0)return Wt((0,W.jsx)(`div`,{className:`space-y-4 px-4 py-5`,children:Gt.map(e=>(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,W.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,W.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:U===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,W.jsx)(`div`,{className:`space-y-4 border-t border-border/60 px-4 py-5`,children:Gt.map(e=>(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))});return(0,W.jsx)(pe,{children:(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ut,qt.size>0?(0,W.jsxs)(ie,{className:`shrink-0 border-b border-border/60`,open:Ie,onOpenChange:Le,children:[(0,W.jsx)(`h2`,{children:(0,W.jsxs)(ue,{className:`flex w-full items-center gap-1.5 px-4 py-2 text-left text-xs text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:Q===null?`Conversations not on the current diff`:`Conversations not on the diff loaded so far`}),(0,W.jsx)(c,{"aria-hidden":!0,className:h(`size-3.5 transition-transform`,Ie&&`rotate-90`)}),(0,W.jsx)(`span`,{"aria-hidden":!0,className:`tabular-nums`,children:Kt.length}),(0,W.jsx)(`span`,{className:`sr-only`,children:Kt.length===1?`1 conversation`:`${Kt.length} conversations`})]})}),(0,W.jsx)(fe,{children:(0,W.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-auto px-4 pb-3`,children:[...qt].map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`truncate px-3 text-xs text-muted-foreground`,title:e,children:e}),(0,W.jsx)(`div`,{className:`mt-1 space-y-2`,children:t.map(e=>(0,W.jsxs)(`div`,{children:[e.line===null?null:(0,W.jsxs)(`p`,{className:`px-3 text-xs text-muted-foreground`,children:[`Line `,e.line]}),Rt(e)]},e.id))})]},e))})})]}):null,(0,W.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,W.jsx)(Ke,{className:`h-full overflow-auto [scrollbar-gutter:stable]`,items:$,selectedLines:Ne,onSelectedLinesChange:z,options:It,renderCodeViewFooter:Nt,renderHeaderPrefix:Pt,renderHeaderMetadata:Ft,renderAnnotation:zt,unsafeCSSExtra:pt}),Bt]}),Jt]})})}export{X as PullRequestCodeTab,X as default};
|
|
251
|
+
//# sourceMappingURL=PullRequestCodeTab-DZ21ejVE.js.map
|
package/dist/client/assets/{fileCommentAnnotations-BlpdYBe1.js → fileCommentAnnotations-BYDMZrEt.js}
RENAMED
|
@@ -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{Yr as i,c as a}from"./terminal-links-
|
|
2
|
-
//# sourceMappingURL=fileCommentAnnotations-
|
|
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{Yr as i,c as a}from"./terminal-links-94yCfJ0N.js";import{Vr as o,ti as s}from"./index-JhM5IhMk.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 a;t[2]===r?a=t[3]:(a=(0,u.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:r}),t[2]=r,t[3]=a);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)(i,{variant:`ghost`,size:`icon-xs`,"aria-label":`Delete comment`,onClick:g,children:c}),t[5]=g,t[6]=l);let f;t[7]!==a||t[8]!==l?(f=(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e,n,a,l]}),t[7]=a,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)(a,{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)(i,{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)(i,{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-BYDMZrEt.js.map
|