@fabiofiorita/porcelain 0.82.1 → 0.82.2
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/README.md +1 -1
- package/package.json +1 -1
- package/web/dist/assets/{_-zpr_A3xj.js → _-b1prKmSp.js} +1 -1
- package/web/dist/assets/{_paired-0bvkZvM3.js → _paired--LzhIV8q.js} +1 -1
- package/web/dist/assets/{_paired-D4wY2wvW.js → _paired-CqcR1ikJ.js} +1 -1
- package/web/dist/assets/{_section-CU7nja2f.js → _section-C3rzCQs1.js} +1 -1
- package/web/dist/assets/{_worktreeId-DOiIn1nf.js → _worktreeId-BDJbQ5Cn.js} +1 -1
- package/web/dist/assets/{_worktreeId-QDdVFP66.js → _worktreeId-D1NaqSVx.js} +1 -1
- package/web/dist/assets/connected-workspace-DcS6e5zB.js +1 -0
- package/web/dist/assets/{desktop-actions-D0SKWMXm.js → desktop-actions-WJQHB849.js} +22 -22
- package/web/dist/assets/{index-CAnBdCQi.js → index-Bk8Ig0Ne.js} +3 -3
- package/web/dist/assets/{pair-Dk6l6cw_.js → pair-CqLMCfsc.js} +1 -1
- package/web/dist/assets/{settings-page-DiniwPDM.js → settings-page-RYnO3e6i.js} +1 -1
- package/web/dist/index.html +2 -2
- package/web/dist/assets/connected-workspace-D-2S8JMu.js +0 -1
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$c as t,$n as n,$r as r,Aa as i,Ao as a,B as o,Bn as s,Bo as c,Br as l,Bs as u,Bt as d,Ca as f,Cc as p,Ci as m,Da as h,Ea as g,Eo as _,Fn as v,Fo as y,Fr as b,Fs as x,G as S,Ga as C,Gc as w,Gi as T,Gn as E,Go as D,Gs as O,Gt as k,Ha as A,Hc as j,Hn as M,Ho as N,Ht as P,Ia as F,In as I,Io as L,Ir as R,Is as z,J as B,Jc as V,Ji as H,Jn as U,Jt as W,K as G,Kn as ee,Kt as te,Lc as ne,Ln as re,Lo as ie,Lr as ae,Ls as K,M as oe,Ma as q,Ms as se,Nc as ce,Nn as le,Nr as ue,Ns as de,Oa as J,On as fe,Oo as pe,P as me,Pa as he,Pc as ge,Pn as _e,Po as ve,Ps as ye,Qa as be,Qn as xe,Qr as Se,R as Ce,Rn as we,Ro as Te,Rs as Ee,Sa as De,Si as Oe,So as ke,Ta as Ae,Un as je,Ur as Me,Ut as Ne,Vi as Pe,Vn as Fe,Vr as Ie,Vs as Le,Vt as Re,W as ze,Wa as Be,Wc as Ve,Wn as He,Wo as Ue,Wt as We,X as Ge,Xn as Ke,Y as qe,Yc as Je,Yn as Ye,Yo as Xe,Yt as Ze,Z as Qe,Zc as $e,Zn as et,Zr as tt,Zt as nt,_ as rt,_a as it,_c as at,a as ot,al as st,ao as ct,ar as lt,b as ut,ba as dt,bc as ft,bl as pt,bn as mt,ca as ht,cc as gt,cl as _t,ct as vt,da as yt,dc as bt,di as xt,dt as St,eo as Ct,er as wt,fc as Tt,fn as Et,ft as Dt,g as Ot,gl as kt,h as At,ha as jt,hc as Mt,hl as Nt,i as Pt,il as Ft,io as It,ir as Lt,j as Rt,ja as zt,jn as Bt,ka as Y,ko as Vt,ll as Ht,ln as Ut,lt as Wt,ma as Gt,mo as Kt,n as qt,ni as Jt,no as Yt,nr as Xt,o as Zt,oc as Qt,ol as $t,or as en,ot as tn,pa as nn,pc as rn,pl as an,pt as on,q as sn,qc as cn,qi as ln,qn as un,qo as dn,qt as fn,r as pn,ra as mn,ri as hn,rr as gn,s as _n,sc as vn,sl as yn,tc as bn,to as xn,tr as Sn,ts as Cn,ua as wn,uc as Tn,ul as En,ut as Dn,v as On,vl as kn,wa as An,wc as jn,x as Mn,xc as Nn,xn as X,y as Pn,ya as Fn,yc as In,yl as Ln,z as Rn,zc as zn,zn as Bn,zo as Vn,zs as Hn}from"./access-WT1uwdZk.js";import{$ as Un,$t as Wn,A as Gn,An as Kn,At as qn,B as Jn,Bn as Yn,Bt as Xn,C as Zn,Cn as Qn,Ct as $n,D as er,Dn as tr,Dt as nr,E as rr,En as ir,Et as ar,F as or,Ft as sr,G as cr,Gt as lr,H as ur,Hn as dr,Ht as fr,I as pr,In as mr,It as hr,J as gr,Jt as _r,K as vr,Kt as yr,Ln as br,Lt as xr,M as Sr,Mn as Cr,Mt as wr,N as Tr,Nn as Er,Nt as Dr,O as Or,On as kr,Ot as Ar,P as jr,Pn as Mr,Pt as Nr,Q as Pr,Qt as Fr,R as Ir,Rn as Lr,Rt as Rr,S as zr,Sn as Br,St as Vr,T as Hr,Tn as Ur,Tt as Wr,U as Gr,Un as Kr,Ut as qr,Vn as Jr,Vt as Yr,W as Xr,Wt as Zr,X as Qr,Xt as $r,Y as ei,Yt as ti,Z as ni,Zt as ri,_ as ii,_n as ai,_t as oi,a as si,an as ci,at as li,bn as ui,bt as di,c as fi,cn as pi,ct as mi,dn as hi,dt as gi,en as _i,et as vi,f as yi,ft as bi,g as xi,gn as Si,gt as Ci,hn as wi,ht as Ti,i as Ei,in as Di,it as Oi,j as ki,jn as Ai,jt as ji,k as Mi,kn as Ni,kt as Pi,l as Fi,ln as Ii,lt as Li,mn as Ri,mt as zi,n as Bi,nn as Vi,nt as Hi,on as Ui,ot as Wi,pn as Gi,pt as Ki,q as qi,qt as Ji,rn as Yi,rt as Xi,sn as Zi,st as Qi,tn as $i,tt as ea,u as ta,un as na,ut as ra,v as ia,vn as aa,vt as oa,w as sa,wn as ca,wt as la,xn as ua,xt as da,yn as fa,yt as pa,z as ma,zn as ha,zt as ga}from"./settings-page-DiniwPDM.js";import{$ as _a,$n as va,$t as ya,A as ba,An as xa,At as Sa,Bn as Ca,Bt as wa,C as Ta,Cr as Ea,Ct as Da,D as Oa,Dn as ka,Dt as Aa,E as ja,Et as Ma,Fn as Na,Ft as Pa,Gn as Fa,Gt as Ia,Hn as La,Ht as Ra,In as za,It as Ba,J as Va,Jn as Ha,Jr as Ua,Kn as Wa,Kr as Ga,Kt as Ka,Lt as qa,M as Ja,Mn as Ya,Mt as Xa,N as Za,Nn as Qa,Nt as $a,O as eo,On as to,Ot as no,P as ro,Pn as io,Pt as ao,Q as oo,Qt as so,Rn as co,Rt as lo,S as uo,T as fo,Tn as po,Tt as mo,Un as ho,Vn as go,Vt as _o,W as vo,Wn as yo,Wr as bo,Xn as xo,Xr as So,Xt as Co,Y as wo,Yn as To,Yr as Eo,Yt as Do,Z as Oo,Zr as ko,_t as Ao,at as jo,b as Mo,bt as No,cn as Po,ct as Fo,ei as Io,en as Lo,er as Ro,et as zo,ft as Bo,gt as Vo,ht as Ho,in as Uo,it as Wo,j as Go,jn as Ko,jt as qo,k as Jo,kn as Yo,kt as Xo,ln as Zo,mn as Qo,mt as $o,nn as es,nt as ts,on as ns,ot as rs,p as is,pt as as,qn as os,qr as ss,qt as cs,r as ls,rn as us,rr as ds,rt as fs,st as ps,tn as ms,tr as hs,tt as gs,un as _s,ut as vs,v as ys,vt as bs,w as xs,wr as Ss,wt as Cs,x as ws,xr as Ts,y as Es,yt as Ds,zn as Os,zt as ks}from"./edit-file-CG3WhqLS.js";import{a as As,c as js,i as Ms,l as Ns,m as Ps,o as Fs,s as Is,t as Ls}from"./hastToHtml-yWaxTNYJ.js";import{n as Rs,r as zs,t as Bs}from"./cloneFileDiffMetadata-OfK4h7R8.js";var Vs={name:`archive-restore`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]};Vs.node;var Hs=J(Vs),Us={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};Us.node;var Ws=J(Us),Gs={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};Gs.node;var Ks=J(Gs),qs={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};qs.node;var Js=J(qs),Ys={name:`chevrons-down-up`,size:24,node:[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]};Ys.node;var Xs=J(Ys),Zs={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};Zs.node;var Qs=J(Zs),$s={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};$s.node;var ec=J($s),tc={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};tc.node;var nc=J(tc),rc={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};rc.node;var ic=J(rc),ac={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};ac.node;var oc=J(ac),sc={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};sc.node;var cc=J(sc),lc={name:`flask-conical`,size:24,node:[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]};lc.node;var uc=J(lc),dc={name:`git-commit-horizontal`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]],aliases:[`git-commit`]};dc.node;var fc=J(dc),pc={name:`git-graph`,size:24,node:[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v6`,key:`158jrl`}],[`circle`,{cx:`5`,cy:`18`,r:`3`,key:`104gr9`}],[`path`,{d:`M12 3v18`,key:`108xh3`}],[`circle`,{cx:`19`,cy:`6`,r:`3`,key:`108a5v`}],[`path`,{d:`M16 15.7A9 9 0 0 0 19 9`,key:`1e3vqb`}]]};pc.node;var mc=J(pc),hc={name:`git-merge`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]};hc.node;var gc=J(hc),_c={name:`git-pull-request-closed`,size:24,node:[[`path`,{d:`m15.5 3.5 5 5`,key:`1kmx7t`}],[`path`,{d:`m15.5 8.5 5-5`,key:`saftza`}],[`path`,{d:`M18 11.62V15`,key:`1greaj`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}]]};_c.node;var vc=J(_c),yc={name:`git-pull-request`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]};yc.node;var bc=J(yc),xc={name:`git-pull-request-draft`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M18 6V5`,key:`1oao2s`}],[`path`,{d:`M18 11v-1`,key:`11c8tz`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]};xc.node;var Sc=J(xc),Cc={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};Cc.node;var wc=J(Cc),Tc={name:`list-x`,size:24,node:[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`m15.5 9.5 5 5`,key:`ytk86i`}],[`path`,{d:`m20.5 9.5-5 5`,key:`17o44f`}]]};Tc.node;var Ec=J(Tc),Dc={name:`panel-right`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]};Dc.node;var Oc=J(Dc),kc={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};kc.node;var Ac=J(kc),jc={name:`square-x`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-square`]};jc.node;var Mc=J(jc),Nc={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Nc.node;var Pc=J(Nc),Fc={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};Fc.node;var Ic=J(Fc),Lc={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};Lc.node;var Rc=J(Lc),zc={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};zc.node;var Bc=J(zc);function Vc(e){switch(e){case`size-limit`:return`Too large to show`;case`unsupported-submodule`:return`Submodule change`;case`unsupported-encoding`:return`Unsupported text encoding`}}function Hc(e){switch(e.kind){case`binary`:return`Binary change`;case`metadata-only`:return`No code change`;case`omitted`:return Vc(e.reason);case`text`:return}}function Uc(e,t,n){return kr(e)?`Submodule change`:t===void 0?n?`The patch could not be read`:`Reading the patch`:Hc(t)}function Wc(e){return e.scope===`staged`||e.scope===`unstaged`?{scope:e.scope,oldPath:e.oldPath,newPath:e.newPath}:void 0}var Gc=/(?=^From [a-f0-9]+ .+$)/m,Kc=/(?=^diff --git)/gm,qc=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Jc=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i;Object.freeze({fromStart:0,fromEnd:0}),Object.freeze([]);function Yc(e,t){return e-(t===0?0:1)}function Xc(e,t){return Yc(e,t)+t}var Zc=1;function Qc(e,...t){return`ck${Zc}:${JSON.stringify([e,...t])}`}function $c(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}var el=new TextEncoder,tl=new TextDecoder(`utf-8`,{ignoreBOM:!0}),nl=/[\uD800-\uDFFF]/,rl=1024,il=new Uint8Array(rl);function al(){il.length!==rl&&(il=new Uint8Array(rl))}function ol(e){if(e.length===0)return e;if(nl.test(e))return JSON.parse(JSON.stringify(e));let t=e.length*3;il.length<t&&(il=new Uint8Array(t));let{written:n}=el.encodeInto(e,il);return tl.decode(il.subarray(0,n))}var sl=new TextDecoder(`utf-8`,{ignoreBOM:!0}),cl={'"':`"`,"\\":`\\`,a:`\x07`,b:`\b`,t:` `,n:`
|
|
2
|
-
`,v:`\v`,f:`\f`,r:`\r`};function
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$c as t,$n as n,$r as r,Aa as i,Ao as a,B as o,Bn as s,Bo as c,Br as l,Bs as u,Bt as d,Ca as f,Cc as p,Ci as m,Da as h,Ea as g,Eo as _,Fn as v,Fo as y,Fr as b,Fs as x,G as S,Ga as C,Gc as w,Gi as T,Gn as E,Go as D,Gs as O,Gt as k,Ha as A,Hc as j,Hn as M,Ho as N,Ht as P,Ia as F,In as I,Io as L,Ir as R,Is as z,J as B,Jc as V,Ji as H,Jn as U,Jt as W,K as G,Kn as ee,Kt as te,Lc as ne,Ln as re,Lo as ie,Lr as ae,Ls as K,M as oe,Ma as q,Ms as se,Nc as ce,Nn as le,Nr as ue,Ns as de,Oa as J,On as fe,Oo as pe,P as me,Pa as he,Pc as ge,Pn as _e,Po as ve,Ps as ye,Qa as be,Qn as xe,Qr as Se,R as Ce,Rn as we,Ro as Te,Rs as Ee,Sa as De,Si as Oe,So as ke,Ta as Ae,Un as je,Ur as Me,Ut as Ne,Vi as Pe,Vn as Fe,Vr as Ie,Vs as Le,Vt as Re,W as ze,Wa as Be,Wc as Ve,Wn as He,Wo as Ue,Wt as We,X as Ge,Xn as Ke,Y as qe,Yc as Je,Yn as Ye,Yo as Xe,Yt as Ze,Z as Qe,Zc as $e,Zn as et,Zr as tt,Zt as nt,_ as rt,_a as it,_c as at,a as ot,al as st,ao as ct,ar as lt,b as ut,ba as dt,bc as ft,bl as pt,bn as mt,ca as ht,cc as gt,cl as _t,cn as vt,ct as yt,da as bt,dc as xt,di as St,dt as Ct,eo as wt,er as Tt,fc as Et,fn as Dt,ft as Ot,g as kt,gl as At,h as jt,ha as Mt,hc as Nt,hl as Pt,i as Ft,il as It,io as Lt,ir as Rt,j as zt,ja as Bt,jn as Vt,ka as Y,ko as Ht,ll as Ut,ln as Wt,lt as Gt,ma as Kt,mo as qt,n as Jt,ni as Yt,no as Xt,nr as Zt,o as Qt,oc as $t,ol as en,or as tn,ot as nn,pa as rn,pc as an,pl as on,pt as sn,q as cn,qc as ln,qi as un,qn as dn,qo as fn,qt as pn,r as mn,ra as hn,ri as gn,rr as _n,s as vn,sc as yn,sl as bn,tc as xn,to as Sn,tr as Cn,ts as wn,ua as Tn,uc as En,ul as Dn,ut as On,v as kn,vl as An,wa as jn,wc as Mn,x as Nn,xc as Pn,xn as X,y as Fn,ya as In,yc as Ln,yl as Rn,z as zn,zc as Bn,zn as Vn,zo as Hn,zs as Un}from"./access-WT1uwdZk.js";import{$ as Wn,$t as Gn,A as Kn,An as qn,At as Jn,B as Yn,Bn as Xn,Bt as Zn,C as Qn,Cn as $n,Ct as er,D as tr,Dn as nr,Dt as rr,E as ir,En as ar,Et as or,F as sr,Ft as cr,G as lr,Gt as ur,H as dr,Hn as fr,Ht as pr,I as mr,In as hr,It as gr,J as _r,Jt as vr,K as yr,Kt as br,Ln as xr,Lt as Sr,M as Cr,Mn as wr,Mt as Tr,N as Er,Nn as Dr,Nt as Or,O as kr,On as Ar,Ot as jr,P as Mr,Pn as Nr,Pt as Pr,Q as Fr,Qt as Ir,R as Lr,Rn as Rr,Rt as zr,S as Br,Sn as Vr,St as Hr,T as Ur,Tn as Wr,Tt as Gr,U as Kr,Un as qr,Ut as Jr,Vn as Yr,Vt as Xr,W as Zr,Wt as Qr,X as $r,Xt as ei,Y as ti,Yt as ni,Z as ri,Zt as ii,_ as ai,_n as oi,_t as si,a as ci,an as li,at as ui,bn as di,bt as fi,c as pi,cn as mi,ct as hi,dn as gi,dt as _i,en as vi,et as yi,f as bi,ft as xi,g as Si,gn as Ci,gt as wi,hn as Ti,ht as Ei,i as Di,in as Oi,it as ki,j as Ai,jn as ji,jt as Mi,k as Ni,kn as Pi,kt as Fi,l as Ii,ln as Li,lt as Ri,mn as zi,mt as Bi,n as Vi,nn as Hi,nt as Ui,on as Wi,ot as Gi,pn as Ki,pt as qi,q as Ji,qt as Yi,rn as Xi,rt as Zi,sn as Qi,st as $i,tn as ea,tt as ta,u as na,un as ra,ut as ia,v as aa,vn as oa,vt as sa,w as ca,wn as la,wt as ua,xn as da,xt as fa,yn as pa,yt as ma,z as ha,zn as ga,zt as _a}from"./settings-page-RYnO3e6i.js";import{$ as va,$n as ya,$t as ba,A as xa,An as Sa,At as Ca,Bn as wa,Bt as Ta,C as Ea,Cr as Da,Ct as Oa,D as ka,Dn as Aa,Dt as ja,E as Ma,Et as Na,Fn as Pa,Ft as Fa,Gn as Ia,Gt as La,Hn as Ra,Ht as za,In as Ba,It as Va,J as Ha,Jn as Ua,Jr as Wa,Kn as Ga,Kr as Ka,Kt as qa,Lt as Ja,M as Ya,Mn as Xa,Mt as Za,N as Qa,Nn as $a,Nt as eo,O as to,On as no,Ot as ro,P as io,Pn as ao,Pt as oo,Q as so,Qt as co,Rn as lo,Rt as uo,S as fo,T as po,Tn as mo,Tt as ho,Un as go,Vn as _o,Vt as vo,W as yo,Wn as bo,Wr as xo,Xn as So,Xr as Co,Xt as wo,Y as To,Yn as Eo,Yr as Do,Yt as Oo,Z as ko,Zr as Ao,_t as jo,at as Mo,b as No,bt as Po,cn as Fo,ct as Io,ei as Lo,en as Ro,er as zo,et as Bo,ft as Vo,gt as Ho,ht as Uo,in as Wo,it as Go,j as Ko,jn as qo,jt as Jo,k as Yo,kn as Xo,kt as Zo,ln as Qo,mn as $o,mt as es,nn as ts,nt as ns,on as rs,ot as is,p as as,pt as os,qn as ss,qr as cs,qt as ls,r as us,rn as ds,rr as fs,rt as ps,st as ms,tn as hs,tr as gs,tt as _s,un as vs,ut as ys,v as bs,vt as xs,w as Ss,wr as Cs,wt as ws,x as Ts,xr as Es,y as Ds,yt as Os,zn as ks,zt as As}from"./edit-file-CG3WhqLS.js";import{a as js,c as Ms,i as Ns,l as Ps,m as Fs,o as Is,s as Ls,t as Rs}from"./hastToHtml-yWaxTNYJ.js";import{n as zs,r as Bs,t as Vs}from"./cloneFileDiffMetadata-OfK4h7R8.js";var Hs={name:`archive-restore`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]};Hs.node;var Us=J(Hs),Ws={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};Ws.node;var Gs=J(Ws),Ks={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};Ks.node;var qs=J(Ks),Js={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};Js.node;var Ys=J(Js),Xs={name:`chevrons-down-up`,size:24,node:[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]};Xs.node;var Zs=J(Xs),Qs={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};Qs.node;var $s=J(Qs),ec={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};ec.node;var tc=J(ec),nc={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};nc.node;var rc=J(nc),ic={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};ic.node;var ac=J(ic),oc={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};oc.node;var sc=J(oc),cc={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};cc.node;var lc=J(cc),uc={name:`flask-conical`,size:24,node:[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]};uc.node;var dc=J(uc),fc={name:`git-commit-horizontal`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]],aliases:[`git-commit`]};fc.node;var pc=J(fc),mc={name:`git-graph`,size:24,node:[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v6`,key:`158jrl`}],[`circle`,{cx:`5`,cy:`18`,r:`3`,key:`104gr9`}],[`path`,{d:`M12 3v18`,key:`108xh3`}],[`circle`,{cx:`19`,cy:`6`,r:`3`,key:`108a5v`}],[`path`,{d:`M16 15.7A9 9 0 0 0 19 9`,key:`1e3vqb`}]]};mc.node;var hc=J(mc),gc={name:`git-merge`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]};gc.node;var _c=J(gc),vc={name:`git-pull-request-closed`,size:24,node:[[`path`,{d:`m15.5 3.5 5 5`,key:`1kmx7t`}],[`path`,{d:`m15.5 8.5 5-5`,key:`saftza`}],[`path`,{d:`M18 11.62V15`,key:`1greaj`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}]]};vc.node;var yc=J(vc),bc={name:`git-pull-request`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]};bc.node;var xc=J(bc),Sc={name:`git-pull-request-draft`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M18 6V5`,key:`1oao2s`}],[`path`,{d:`M18 11v-1`,key:`11c8tz`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]};Sc.node;var Cc=J(Sc),wc={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};wc.node;var Tc=J(wc),Ec={name:`list-x`,size:24,node:[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`m15.5 9.5 5 5`,key:`ytk86i`}],[`path`,{d:`m20.5 9.5-5 5`,key:`17o44f`}]]};Ec.node;var Dc=J(Ec),Oc={name:`panel-right`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]};Oc.node;var kc=J(Oc),Ac={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};Ac.node;var jc=J(Ac),Mc={name:`square-x`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-square`]};Mc.node;var Nc=J(Mc),Pc={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Pc.node;var Fc=J(Pc),Ic={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};Ic.node;var Lc=J(Ic),Rc={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};Rc.node;var zc=J(Rc),Bc={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};Bc.node;var Vc=J(Bc);function Hc(e){switch(e){case`size-limit`:return`Too large to show`;case`unsupported-submodule`:return`Submodule change`;case`unsupported-encoding`:return`Unsupported text encoding`}}function Uc(e){switch(e.kind){case`binary`:return`Binary change`;case`metadata-only`:return`No code change`;case`omitted`:return Hc(e.reason);case`text`:return}}function Wc(e,t,n){return Ar(e)?`Submodule change`:t===void 0?n?`The patch could not be read`:`Reading the patch`:Uc(t)}function Gc(e){return e.scope===`staged`||e.scope===`unstaged`?{scope:e.scope,oldPath:e.oldPath,newPath:e.newPath}:void 0}var Kc=/(?=^From [a-f0-9]+ .+$)/m,qc=/(?=^diff --git)/gm,Jc=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Yc=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i;Object.freeze({fromStart:0,fromEnd:0}),Object.freeze([]);function Xc(e,t){return e-(t===0?0:1)}function Zc(e,t){return Xc(e,t)+t}var Qc=1;function $c(e,...t){return`ck${Qc}:${JSON.stringify([e,...t])}`}function el(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}var tl=new TextEncoder,nl=new TextDecoder(`utf-8`,{ignoreBOM:!0}),rl=/[\uD800-\uDFFF]/,il=1024,al=new Uint8Array(il);function ol(){al.length!==il&&(al=new Uint8Array(il))}function sl(e){if(e.length===0)return e;if(rl.test(e))return JSON.parse(JSON.stringify(e));let t=e.length*3;al.length<t&&(al=new Uint8Array(t));let{written:n}=tl.encodeInto(e,al);return nl.decode(al.subarray(0,n))}var cl=new TextDecoder(`utf-8`,{ignoreBOM:!0}),ll={'"':`"`,"\\":`\\`,a:`\x07`,b:`\b`,t:` `,n:`
|
|
2
|
+
`,v:`\v`,f:`\f`,r:`\r`};function ul(e){if(e[0]!==`"`)return;let t=``,n=1;for(;n<e.length;){let r=e[n];if(r===`"`)return{fileName:t,rawLength:n+1};if(r!==`\\`){t+=r,n++;continue}let i=ll[e[n+1]];if(i!=null){t+=i,n+=2;continue}let a=[];do{let t=dl(e,n+1);if(t==null)return;a.push(t),n+=4}while(e[n]===`\\`&&e[n+1]>=`0`&&e[n+1]<=`7`);t+=cl.decode(new Uint8Array(a))}}function dl(e,t){let n=e.charCodeAt(t)-48,r=e.charCodeAt(t+1)-48,i=e.charCodeAt(t+2)-48;if(n>=0&&n<=3&&r>=0&&r<=7&&i>=0&&i<=7)return n*64+r*8+i}var fl=4096,pl=.5;function ml(e){for(let t of e.hunks)for(let n=0;n<t.hunkContent.length;n++){let r=t.hunkContent[n];if(r.type!==`change`)continue;let i=hl(e,r);i!=null&&(t.hunkContent.splice(n,1,...i),n+=i.length-1)}}function hl(e,t){let{deletions:n,additions:r,deletionLineIndex:i,additionLineIndex:a}=t,o=Math.min(n,r),s=Math.abs(r-n);if(o===0||s===0||o*(s+1)>fl)return null;let c=[];for(let t=0;t<n;t++)c.push(_l(e.deletionLines[i+t]??``));let l=[];for(let t=0;t<r;t++)l.push(_l(e.additionLines[a+t]??``));let u=r>n,d=0,f=-1;for(let e=0;e<=s;e++){let t=0;for(let n=0;n<o;n++)t+=vl(c[n+(u?0:e)],l[n+(u?e:0)]);e===0?f=t+o*pl:t>f&&(f=t,d=e)}if(d===0)return null;let p=[],m=(e,t,n,r)=>{(e>0||t>0)&&p.push({type:`change`,deletions:e,additions:t,deletionLineIndex:n,additionLineIndex:r})};return u?(m(0,d,i,a),m(o,o,i,a+d),m(0,r-o-d,i+o,a+d+o)):(m(d,0,i,a),m(o,o,i+d,a),m(n-o-d,0,i+d+o,a+o)),p}var gl=/\s+/g;function _l(e){return e.replace(gl,``)}function vl(e,t){if(e===t)return 1;let n=Math.max(e.length,t.length),r=Math.min(e.length,t.length);if(r===0)return 0;let i=0;for(;i<r&&e[i]===t[i];)i++;let a=0;for(;a<r-i&&e[e.length-1-a]===t[t.length-1-a];)a++;return(i+a)/n}var yl=/^diff --git ("a\/(?:[^"\\]|\\.)*"|a\/.+?) ("b\/(?:[^"\\]|\\.)*"|b\/.+?)$/;function bl(e,{cacheKeyPrefix:t,disableLineMatching:n,throwOnError:r=!1}={},i){let a=Rl(e),o=a?Dl(e):Ol(e),s=n===!0?`patch-file-raw`:`patch-file`,c,l=[];for(let e of o){if(a&&!qc.test(e)||!a&&!kl(e)){if(c==null)c=sl(e);else if(r)throw Error(`parsePatchContent: unknown file blob`);else console.error(`parsePatchContent: unknown file blob:`,e);continue}let o=xl(e,{cacheKey:t==null?void 0:i==null?$c(s,t,String(l.length)):$c(s,t,String(i),String(l.length)),isGitDiff:a,disableLineMatching:n,throwOnError:r});o!=null&&l.push(o)}return{patchMetadata:c,files:l}}function xl(e,{cacheKey:t,disableLineMatching:n=!1,isGitDiff:r=qc.test(e),oldFile:i,newFile:a,throwOnError:o=!1}={}){let s=0,c=zl(e,`@@ `),l,u=i==null||a==null,d=0,f=0;for(let e of c){let n=El(e),c=n[0];if(c==null){if(o)throw Error(`parsePatchContent: invalid hunk`);console.error(`parsePatchContent: invalid hunk`,e);continue}let p=Fl(c),m=0,h=0;if(p==null||l==null){if(l!=null){if(o)throw Error(`parsePatchContent: Invalid hunk`);console.error(`parsePatchContent: Invalid hunk`,e);continue}l={name:``,type:`change`,hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:u,additionLines:!u&&i!=null&&a!=null?Tl(a.contents):[],deletionLines:!u&&i!=null&&a!=null?Tl(i.contents):[],additionCharacterCount:!u&&i!=null&&a!=null?a.contents.length:0,deletionCharacterCount:!u&&i!=null&&a!=null?i.contents.length:0,cacheKey:Vl(t)},l.additionLines.length===1&&a?.contents===``&&(l.additionLines.length=0),l.deletionLines.length===1&&i?.contents===``&&(l.deletionLines.length=0);for(let e of n){if(e.startsWith(`diff --git`)){let t=e.trim().match(yl);if(t==null){if(o)throw Error(`parsePatchContent: invalid git diff header`);console.error(`parsePatchContent: invalid git diff header`,e);continue}let n=Cl(t[1],!0),r=Cl(t[2],!0);l.name=sl(r),n!==r&&(l.prevName=sl(n));continue}let t=e.startsWith(`---`)||e.startsWith(`+++`)?e.match(Jc):null;if(t!=null){let[,e,n]=t,i=Cl(n,r);if(e===`---`&&i!==`/dev/null`){let e=sl(i);l.prevName=e,l.name=e}else e===`+++`&&i!==`/dev/null`&&(l.name=sl(i))}else if(r){if(e.startsWith(`new mode `)&&(l.mode=sl(e.slice(8).trim())),e.startsWith(`old mode `)&&(l.prevMode=sl(e.slice(8).trim())),e.startsWith(`new file mode`)&&(l.type=`new`,l.mode=sl(e.slice(13).trim())),e.startsWith(`deleted file mode`)&&(l.type=`deleted`,l.mode=sl(e.slice(17).trim())),e.startsWith(`similarity index`)&&(e.startsWith(`similarity index 100%`)?l.type=`rename-pure`:l.type=`rename-changed`),e.startsWith(`index `)){let[,t,n,r]=e.trim().match(Yc)??[];t!=null&&(l.prevObjectId=sl(t)),n!=null&&(l.newObjectId=sl(n)),r!=null&&(l.mode=sl(r))}(e.startsWith(`rename from `)||e.startsWith(`copy from `))&&(l.prevName=sl(Cl(e.slice(e.startsWith(`rename`)?12:10)))),(e.startsWith(`rename to `)||e.startsWith(`copy to `))&&(l.name=sl(Cl(e.slice(e.startsWith(`rename`)?10:8))))}}continue}let g,_;for(;n.length>0&&(n[n.length-1]===`
|
|
3
3
|
`||n[n.length-1]===`\r`||n[n.length-1]===`\r
|
|
4
|
-
`||n[n.length-1]===``);)n.pop();let{additionStart:v,deletionStart:y}=p;d=u?d:y-1,f=u?f:v-1;let b={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:p.additionCount,additionStart:v,additionLines:m,deletionCount:p.deletionCount,deletionStart:y,deletionLines:h,deletionLineIndex:d,additionLineIndex:f,hunkContent:[],hunkContext:
|
|
5
|
-
From `)}function
|
|
6
|
-
`,n);if(r===-1)break;t.push(e.slice(n,r+1)),n=r+1}return n<e.length&&t.push(e.slice(n)),t}function
|
|
7
|
-
`||t===`\r`)break;if(t!==` `&&t!==` `)return!0}return!1}function
|
|
8
|
-
`,t);return n===-1?e.length:n+1}function
|
|
9
|
-
`&&n!==`\r`)return!1}return!0}function
|
|
4
|
+
`||n[n.length-1]===``);)n.pop();let{additionStart:v,deletionStart:y}=p;d=u?d:y-1,f=u?f:v-1;let b={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:p.additionCount,additionStart:v,additionLines:m,deletionCount:p.deletionCount,deletionStart:y,deletionLines:h,deletionLineIndex:d,additionLineIndex:f,hunkContent:[],hunkContext:Vl(p.hunkContext),hunkSpecs:sl(c),noEOFCRAdditions:!1,noEOFCRDeletions:!1},x=0,S=0;for(let e=1;e<n.length;e++){let t=n[e];if(x>=b.additionCount&&S>=b.deletionCount&&!t.startsWith(`\\`)){if(!Nl(t)||Pl(t))break;if(o)throw Error(`parsePatchContent: hunk has more lines than expected`)}let r=t[0];if(r!==`+`&&r!==`-`&&r!==` `&&r!==`\\`){if(o)throw Error(`parsePatchContent: invalid hunk line`);console.error(`parseLineType: Invalid firstChar: "${r}", full line: "${t}"`),console.error(`processFile: invalid rawLine:`,t);continue}let i=Hl(r);if(i===`addition`){if(o&&x>=b.additionCount)throw Error(`parsePatchContent: hunk has too many addition lines`);let e=Ul(t);(g==null||g.type!==`change`)&&(g=Wl(`change`,d,f),b.hunkContent.push(g)),f++,x++,u&&(l.additionLines.push(e),l.additionCharacterCount+=e.length),g.additions++,m++,_=`addition`}else if(i===`deletion`){if(o&&S>=b.deletionCount)throw Error(`parsePatchContent: hunk has too many deletion lines`);let e=Ul(t);(g==null||g.type!==`change`)&&(g=Wl(`change`,d,f),b.hunkContent.push(g)),d++,S++,u&&(l.deletionLines.push(e),l.deletionCharacterCount+=e.length),g.deletions++,h++,_=`deletion`}else if(i===`context`){if(o&&(S>=b.deletionCount||x>=b.additionCount))throw Error(`parsePatchContent: hunk has too many context lines`);let e=Ul(t);(g==null||g.type!==`context`)&&(g=Wl(`context`,d,f),b.hunkContent.push(g)),f++,d++,x++,S++,u&&(l.deletionLines.push(e),l.additionLines.push(e),l.deletionCharacterCount+=e.length,l.additionCharacterCount+=e.length),g.lines++,_=`context`}else if(i===`metadata`&&g!=null){if(g.type===`context`?(b.noEOFCRAdditions=!0,b.noEOFCRDeletions=!0):_===`deletion`?b.noEOFCRDeletions=!0:_===`addition`&&(b.noEOFCRAdditions=!0),u&&(_===`addition`||_===`context`)){let e=l.additionLines.length-1;if(e>=0){let t=l.additionLines[e],n=el(t);l.additionLines[e]=n,l.additionCharacterCount+=n.length-t.length}}if(u&&(_===`deletion`||_===`context`)){let e=l.deletionLines.length-1;if(e>=0){let t=l.deletionLines[e],n=el(t);l.deletionLines[e]=n,l.deletionCharacterCount+=n.length-t.length}}}}if(x!==b.additionCount||S!==b.deletionCount){if(o)throw Error(`parsePatchContent: hunk line count mismatch`);console.error(`parsePatchContent: hunk line count mismatch: "${c.trimEnd()}", declared old/new ${b.deletionCount}/${b.additionCount}, parsed old/new ${S}/${x}`);let e=Xc(b.additionStart,b.additionCount)+(x===0?0:1),t=Xc(b.deletionStart,b.deletionCount)+(S===0?0:1);if(!u){let n=e-b.additionStart,r=t-b.deletionStart;b.additionLineIndex+=n,b.deletionLineIndex+=r;for(let e of b.hunkContent)e.additionLineIndex+=n,e.deletionLineIndex+=r}b.additionStart=e,b.deletionStart=t,b.additionCount=x,b.deletionCount=S}b.additionLines=m,b.deletionLines=h,b.collapsedBefore=Math.max(Xc(b.additionStart,b.additionCount)-s,0),l.hunks.push(b),s=Zc(b.additionStart,b.additionCount);for(let e of b.hunkContent)e.type===`context`?(b.splitLineCount+=e.lines,b.unifiedLineCount+=e.lines):(b.splitLineCount+=Math.max(e.additions,e.deletions),b.unifiedLineCount+=e.deletions+e.additions);b.splitLineStart=l.splitLineCount+b.collapsedBefore,b.unifiedLineStart=l.unifiedLineCount+b.collapsedBefore,l.splitLineCount+=b.collapsedBefore+b.splitLineCount,l.unifiedLineCount+=b.collapsedBefore+b.unifiedLineCount}if(l!=null){if(o&&u&&!r&&l.hunks.length===0)throw Error(`parsePatchContent: unified file has no hunks`);if(l.hunks.length>0&&!u&&l.additionLines.length>0&&l.deletionLines.length>0){let e=l.hunks[l.hunks.length-1],t=Zc(e.additionStart,e.additionCount),n=l.additionLines.length,r=Math.max(n-t,0);l.splitLineCount+=r,l.unifiedLineCount+=r}return r||(l.prevName!=null&&l.name!==l.prevName?l.hunks.length>0?l.type=`rename-changed`:l.type=`rename-pure`:(i==null||i.contents===``)&&a!=null&&a.contents!==``?l.type=`new`:i!=null&&i.contents!==``&&(a==null||a.contents===``)&&(l.type=`deleted`)),l.type!==`rename-pure`&&l.type!==`rename-changed`&&(l.prevName=void 0),n||ml(l),l}}function Sl(e,t={}){let{cacheKeyPrefix:n,throwOnError:r=!1}=t,i=[],a=wl(e)?e.split(Kc):[e];for(let e of a)try{i.push(bl(e,t,n==null?void 0:i.length))}catch(e){if(r)throw e;console.error(e)}finally{ol()}return i}function Cl(e,t=!1){let n=e.trim(),r=n.startsWith(`"`)?ul(n)?.fileName??n:n;return t&&(r.startsWith(`a/`)||r.startsWith(`b/`))?r.slice(2):r}function wl(e){return e.startsWith(`From `)||e.includes(`
|
|
5
|
+
From `)}function Tl(e){let t=El(e);for(let e=0;e<t.length;e++)t[e]=sl(t[e]);return t}function El(e){if(e.length===0)return[``];let t=[],n=0;for(;;){let r=e.indexOf(`
|
|
6
|
+
`,n);if(r===-1)break;t.push(e.slice(n,r+1)),n=r+1}return n<e.length&&t.push(e.slice(n)),t}function Dl(e){return zl(e,`diff --git`)}function Ol(e){if(e.length===0)return[``];let t=[],n=0,r=0,i=0,a=0,o=!1;for(;r<e.length;){let s=Ml(e,r);if(i<=0&&a<=0){if(Al(e,r)){r>n&&t.push(e.slice(n,r)),n=r,o=!0,r=Ml(e,s);continue}if(o&&e.startsWith(`@@ -`,r)){let t=Fl(e.slice(r,s));t!=null&&(i=t.deletionCount,a=t.additionCount)}r=s;continue}let c=e[r];c===`\\`||(c===` `?(i=Math.max(i-1,0),a=Math.max(a-1,0)):c===`-`?i=Math.max(i-1,0):c===`+`&&(a=Math.max(a-1,0))),r=s}return t.push(e.slice(n)),t}function kl(e){return Al(e,0)}function Al(e,t){let n=Ml(e,t);return jl(e,t,`---`)&&jl(e,n,`+++`)}function jl(e,t,n){if(!e.startsWith(n,t))return!1;let r=e[t+n.length];if(r!==` `&&r!==` `)return!1;for(let r=t+n.length+1;r<e.length;r++){let t=e[r];if(t===`
|
|
7
|
+
`||t===`\r`)break;if(t!==` `&&t!==` `)return!0}return!1}function Ml(e,t){let n=e.indexOf(`
|
|
8
|
+
`,t);return n===-1?e.length:n+1}function Nl(e){let t=e[0];return t===`+`||t===`-`||t===` `}function Pl(e){if(!e.startsWith(`--`))return!1;for(let t=2;t<e.length;t++){let n=e[t];if(n!==` `&&n!==` `&&n!==`
|
|
9
|
+
`&&n!==`\r`)return!1}return!0}function Fl(e){if(!e.startsWith(`@@ -`))return;let t=4,n=Il(e,t);if(n==null)return;let r=n.value;t=n.endIndex;let i=1;if(e[t]===`,`){let n=Il(e,t+1);if(n==null)return;i=n.value,t=n.endIndex}if(e[t]!==` `||e[t+1]!==`+`)return;t+=2;let a=Il(e,t);if(a==null)return;let o=a.value;t=a.endIndex;let s=1;if(e[t]===`,`){let n=Il(e,t+1);if(n==null)return;s=n.value,t=n.endIndex}if(e[t]!==` `||e[t+1]!==`@`||e[t+2]!==`@`)return;let c,l=t+3;return e[l]===` `&&(c=Ll(e.slice(l+1))),{additionCount:s,additionStart:o,deletionCount:i,deletionStart:r,hunkContext:c}}function Il(e,t){let n=t,r=0;for(;n<e.length;n++){let t=e.charCodeAt(n)-48;if(t<0||t>9)break;r=r*10+t}if(n!==t)return{value:r,endIndex:n}}function Ll(e){return e.endsWith(`\r
|
|
10
10
|
`)?e.slice(0,-2):e.endsWith(`
|
|
11
|
-
`)?e.slice(0,-1):e}function
|
|
12
|
-
diff --git`)}function
|
|
13
|
-
`:t)}function
|
|
14
|
-
`:n,type:t===` `?`context`:t===`\\`?`metadata`:t===`+`?`addition`:`deletion`}}function
|
|
15
|
-
`);t.at(-1)===``&&t.pop();let n=t.findIndex(e=>e.startsWith(`@@`));if(n<0)return{kind:`invalid`};try{let r=
|
|
16
|
-
`)}\n`}function Yl(e){return e.mergeBaseOid===null||e.mergeBaseOid===void 0?null:{baseOid:e.mergeBaseOid,headOid:e.head.oid}}function Xl(e){return e instanceof Error&&(e.name===`RequestError`||e.name===`ConnectionError`)?e.message:`The branch could not be compared. Try again.`}function Zl(e){let t=new Map;for(let n of e){let e=ir(n);t.has(e)||t.set(e,{path:e,paths:[e],kind:`kind`in n?n.kind:`changed`})}return[...t.values()]}var Ql=new Set([`spec`,`specs`,`__tests__`,`tests`]);function $l(e){let t=e.slice(e.lastIndexOf(`/`)+1);return/\.(?:spec|test|browser)\.[^.]+$/.test(t)||/_(?:test|spec)\.[^.]+$/.test(t)||/^test_.+\.py$/.test(t)||/(?:Test|Tests|Spec)\.(?:java|kt|cs|swift|scala)$/.test(t)?!0:e.split(`/`).slice(0,-1).some(e=>Ql.has(e))}function eu(e,t){if(!t)return e;let n=[],r=[];for(let t of e)$l(t.path)?r.push(t):n.push(t);return[...n,...r]}function tu(e,t){return e?`Unmark as reviewed`:t?`Mark as reviewed again`:`Mark as reviewed`}function nu(e){switch(e.kind){case`file`:return[{id:`review`,label:tu(e.status===`reviewed`,e.status===`stale`),disabled:!e.canReview},{id:`open`,label:`Open diff`},{id:`open-to-side`,label:e.sideLabel},{id:`open-file`,label:`Open file`},{id:`timeline`,label:`Show timeline`},{id:`copy-relative`,label:`Copy relative path`},...e.canDiscard?[{id:`discard`,label:`Discard`,destructive:!0}]:[]];case`section`:return[{id:`open`,label:`Open`}];case`group`:return[{id:`expand-all`,label:`Expand all`},{id:`collapse-all`,label:`Collapse all`}];default:return e}}var Z=Cn(),ru=e(D(),1),Q=e(se(),1),iu=Q.createContext({disabled:!1});function au(){return Q.useContext(iu)}var ou=e=>/\.(png|jpe?g|gif|webp|avif|svg|ico)$/i.test(e);function su({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function cu(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:lu(n,e.startContentIndex)}}function lu(e,t){let n=e.unifiedLineStart;for(let r=0;r<t;r++){let t=e.hunkContent[r];n+=t.type===`context`?t.lines:t.deletions+t.additions}return n}function uu({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:c,lineAnnotations:l,getHoveredLine:u,getInstance:d,getAnnotationSlotName:f=io}){let p=n?.(e),m=r?.(e),h=i?.(e),g=a?.(e);return(0,Z.jsxs)(Z.Fragment,{children:[p==null?(0,Z.jsxs)(Z.Fragment,{children:[m!=null&&(0,Z.jsx)(`div`,{slot:`header-prefix`,children:m}),h!=null&&(0,Z.jsx)(`div`,{slot:`header-filename-suffix`,children:h}),g!=null&&(0,Z.jsx)(`div`,{slot:`header-metadata`,children:g})]}):(0,Z.jsx)(`div`,{slot:co,children:p}),o!=null&&l?.map((t,n)=>(0,Z.jsx)(`div`,{slot:f(t),children:o(t,e)},n)),t!=null&&c!=null&&d!=null&&t.map(t=>{if(t==null)return;let n=du(t,e);return(0,Z.jsx)(`div`,{slot:n,style:Zi,children:c(t,d)},n)}),s!=null&&(0,Z.jsx)(`div`,{slot:`gutter-utility-slot`,style:Ui,children:s(u)})]})}function du(e,t){let n=cu(e,t);return n==null?void 0:su({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}function fu(e){if(e.type===`diff`){let{instance:t,item:n}=e;return t.__getNextRenderData({fileDiff:t.fileDiff??n.fileDiff,lineAnnotations:void 0})}let{instance:t,item:n}=e;return t.__getNextRenderData({file:t.file??n.file,lineAnnotations:void 0})}function pu(e,t){return e==null||t==null?e===t:e.header!==t.header||e.footer!==t.footer?!1:mu(e.items,t.items)}function mu(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r==null||i==null||r.id!==i.id||r.type!==i.type||r.element!==i.element||r.instance!==i.instance||r.version!==i.version)return!1}return!0}function hu(e,t,n){let r=document.createElement(`div`);return r.style.display=`flow-root`,e===`header`?(r.setAttribute(za,``),t.before(r)):(r.setAttribute(Na,``),t.after(r)),n?.observe(r),r}function gu(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function _u(e){let t=window.devicePixelRatio??1;return Math.round(e*t)/t}async function vu(e,t=300){let n;try{await Promise.race([e(),new Promise(e=>{n=setTimeout(e,t)})])}finally{n!=null&&clearTimeout(n)}}function yu({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o,canHydratePartialDiff:s}){let c=Zo(t,n),l=c,u=i?!0:a,d=e.hunks.length-1;for(let n=0;n<e.hunks.length;n++){let i=e.hunks[n];if(i==null)throw Error(`computeEstimatedDiffHeights: invalid hunk index`);let a=Zr({isPartial:e.isPartial,rangeSize:i.collapsedBefore,expandedHunks:u,hunkIndex:n,collapsedContextThreshold:o}),f=(a.fromStart+a.fromEnd)*t.lineHeight;if(c+=f,l+=f,a.collapsedLines>0){let e=yr({type:r,metrics:t,hunkIndex:n,hunkSpecs:i.hunkSpecs})?.totalHeight??0;c+=e,l+=e}c+=i.splitLineCount*t.lineHeight,l+=i.unifiedLineCount*t.lineHeight;let p=bu(i);c+=p.split*t.lineHeight,l+=p.unified*t.lineHeight;let m=n===d?ti({fileDiff:e,hunkIndex:n,expandedHunks:u,collapsedContextThreshold:o,errorPrefix:`computeEstimatedDiffHeights`}):void 0;if(m!=null){let e=(m.fromStart+m.fromEnd)*t.lineHeight;if(c+=e,l+=e,m.collapsedLines>0){let e=$r({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}else if(n===d&&e.isPartial&&s){let e=$r({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}if(e.hunks.length>0){let e=_s(t);c+=e,l+=e}return{splitHeight:c,unifiedHeight:l}}function bu(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};let t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type===`context`){let e=+(t.lines>0);return{split:e,unified:e}}return xu(e,t)}function xu(e,t){let n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),r=t.deletions>0&&e.noEOFCRDeletions,i=t.additions>0&&e.noEOFCRAdditions;return{split:r||i?1:0,unified:n}}function Su({oldFile:e,newFile:t},n){if(e!==void 0||t!==void 0){if(e===void 0||t===void 0)throw Error(`${n}: Pass null for an intentionally missing oldFile or newFile side`);if(e===null){if(t===null)throw Error(`${n}: You must pass oldFile, newFile, or both`);return{oldFile:e,newFile:t}}return{oldFile:e,newFile:t}}}function Cu(e){return e===``?[]:e.split(ds)}function wu(e,t,n,r={}){let i=e===`clone`?Bs(t):t;if(!i.isPartial)throw Error(`hydratePartialDiff: fileDiff must be partial`);switch(i.type){case`change`:case`rename-changed`:return Tu(i,Du(i,n),Ou(i,n),r);case`rename-pure`:{let e=Ou(i,n);ku(i,n);let t=Cu(e.contents);return i.isPartial=!1,i.deletionLines=t,i.additionLines=t,i.deletionCharacterCount=e.contents.length,i.additionCharacterCount=e.contents.length,ju(i,null,e,r),i}}throw Error(`hydratePartialDiff: ${i.type} diffs cannot be hydrated from loaded files`)}function Tu(e,t,n,r){let i=Cu(t.contents),a=Cu(n.contents),{hunks:o,splitLineCount:s,unifiedLineCount:c}=Eu(e.hunks,a.length);return e.hunks=o,e.splitLineCount=s,e.unifiedLineCount=c,e.isPartial=!1,e.deletionLines=i,e.additionLines=a,e.deletionCharacterCount=t.contents.length,e.additionCharacterCount=n.contents.length,ju(e,t,n,r),e}function Eu(e,t){let n=0,r=0,i=0,a=[];for(let t of e){let e=Math.max(t.additionStart-1,0),o=Math.max(t.deletionStart-1,0),s=e,c=o,l=0,u=0,d=0,f=0,p=[];for(let e of t.hunkContent)e.type===`context`?(p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.lines,c+=e.lines,d+=e.lines,f+=e.lines):(p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.additions,c+=e.deletions,l+=e.additions,u+=e.deletions,d+=Math.max(e.additions,e.deletions),f+=e.additions+e.deletions);let m=Math.max(ci(t.additionStart,t.additionCount)-i,0);a.push({...t,collapsedBefore:m,additionLineIndex:e,deletionLineIndex:o,additionLines:l,deletionLines:u,hunkContent:p,splitLineStart:n+m,unifiedLineStart:r+m,splitLineCount:d,unifiedLineCount:f}),n+=m+d,r+=m+f,i=Di(t.additionStart,t.additionCount)}if(a.length>0){let e=a[a.length-1],i=Di(e.additionStart,e.additionCount),o=Math.max(t-i,0);n+=o,r+=o}return{hunks:a,splitLineCount:n,unifiedLineCount:r}}function Du(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function Ou(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function ku(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function Au(e,t,n,r){return e.cacheKey==null?Mu(t,n,r):`${e.cacheKey}:hydrated`}function ju(e,t,n,r){let i=Au(e,t,n,r);i==null?delete e.cacheKey:e.cacheKey=i}function Mu(e,t,n){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?xr(n.disableLineMatching===!0?`hydrated-files-raw`:`hydrated-files`,e.cacheKey,t.cacheKey):void 0:e?.cacheKey??t?.cacheKey}var Nu=`/dev/null`;function Pu(e,t,{disableLineMatching:n,...r}={},i=!1){if(e===null&&t===null)throw Error(`parseDiffFromFile: You must pass oldFile, newFile, or both`);let a=e??Fu(),o=t??Fu(),s=Yr(a.name,o.name,a.contents,o.contents,a.header,o.header,r),c=sr(s,{cacheKey:(()=>{let r=e?.cacheKey,i=t?.cacheKey;return r!=null&&i!=null?xr(n===!0?`diff-raw`:`diff`,r,i):void 0})(),oldFile:a,newFile:o,disableLineMatching:n,throwOnError:i});if(c==null)throw Error(`parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?`);e===null?(c.type=`new`,c.prevName=void 0):t===null&&(c.type=`deleted`,c.prevName=void 0);let l=t?.lang??(t===null?e?.lang:void 0);return l!=null&&(c.lang=l),c}function Fu(){return{name:Nu,contents:``}}var Iu=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){this.enabled&&=(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,!1)}setup(e,t,n){if(t==null||n==null)for(let r of e.children??[])r instanceof HTMLElement&&(`deletions`in r.dataset?t=r:`additions`in r.dataset&&(n=r));n==null||t==null?this.cleanUp():(this.codeDeletions!==t&&(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener(`scroll`,this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&(this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener(`scroll`,this.handleAdditionsScroll,{passive:!0})),this.enabled=!0)}handleDeletionsScroll=()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))};handleAdditionsScroll=()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))}};function Lu(e,t){let n=Pu({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t);return{hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,additionLines:n.additionLines,deletionLines:n.deletionLines,additionCharacterCount:n.additionCharacterCount,deletionCharacterCount:n.deletionCharacterCount,type:n.type}}function Ru(e,t){let n=Math.max(e,1),r=Array.from({length:n},(e,t)=>`${` `.repeat(t+1)}\n`).join(``);return r===t&&(r=Array.from({length:n},(e,t)=>`\u0000${` `.repeat(t)}\n`).join(``)),r}function zu(e){for(let t of e)if(t.trim().length>0)return!1;return!0}function Bu(e,t){return t.length>0&&t.length<e.deletionLines.length&&zu(t)}function Vu(e,t,n,r){let i=e.deletionLines.join(``),a=Ru(t.length,i),o=Pu({name:e.prevName??e.name,contents:i},{name:e.name,contents:a,lang:e.lang},r);return{hunks:o.hunks,splitLineCount:o.splitLineCount,unifiedLineCount:o.unifiedLineCount,additionLines:t,deletionLines:o.deletionLines,additionCharacterCount:n,deletionCharacterCount:o.deletionCharacterCount,type:o.type}}function Hu(e,t){return Vu(e,[``],0,t)}function Uu(e,t){if(e.additionLines.length===0)return Hu(e,t);if(Bu(e,e.additionLines))return Vu(e,e.additionLines,e.additionCharacterCount,t);let n=e.additionLines,r=Lu(e,t);return Gu(r,n),r}function Wu(e){return e.length>1&&e.at(-1)===``}function Gu(e,t){if(!Wu(t))return;let n=t.length-e.additionLines.length;if(n<=0)return;let r=e.additionLines.length,i=e.hunks.at(-1);if(i!=null&&Di(i.additionStart,i.additionCount)===r){for(let a of i.hunkContent)if(a.type===`change`&&a.additions<a.deletions&&a.additionLineIndex+a.additions===r){e.additionLines=t,a.additions+=n,i.additionCount+=n,i.additionLines+=n,td(e);return}}}function Ku(e,t,n){if(e.isPartial||e.deletionLines.length!==e.additionLines.length)return qu(e,Lu(e,n));let r=Array.from(t);if(r.length===0)return qu(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type});for(let t of r){let r=e.additionLines[t],i=e.deletionLines[t];if(r==null||i==null||fr(r)===fr(i))return qu(e,Lu(e,n))}let i=Ju(e,r);if(i.size===0)return qu(e,Lu(e,n));for(let t of i)if(!Xu(e,t,n))return qu(e,Lu(e,n));return td(e),ri(e)?qu(e,Lu(e,n)):qu(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type})}function qu(e,t){return Object.assign(e,t),t}function Ju(e,t){let n=new Set;for(let r of t){let t=Yu(e,r);if(t==null)return new Set;n.add(t)}return n}function Yu(e,t){for(let[n,r]of e.hunks.entries()){let e=r.additionLineIndex+r.additionCount;if(t>=r.additionLineIndex&&t<e)return n}}function Xu(e,t,n){let r=e.hunks[t];if(r==null)return!1;let i=e.deletionLines.slice(r.deletionLineIndex,r.deletionLineIndex+r.deletionCount),a=e.additionLines.slice(r.additionLineIndex,r.additionLineIndex+r.additionCount),o=Pu({name:e.prevName??e.name,contents:i.join(``)},{name:e.name,contents:a.join(``),lang:e.lang},{...n,context:0}),s=o.hunks[0];return s==null||o.hunks.length!==1?!1:(Qu(r,s),Zu(e,t),!0)}function Zu(e,t){let n=e.hunks[t];if(n==null)return;if(t!==e.hunks.length-1){n.noEOFCRAdditions=!1,n.noEOFCRDeletions=!1;return}let r=e.additionLines.at(-1),i=e.deletionLines.at(-1);n.noEOFCRAdditions=r!=null&&r!==``&&!r.endsWith(`
|
|
11
|
+
`)?e.slice(0,-1):e}function Rl(e){return e.startsWith(`diff --git`)||e.includes(`
|
|
12
|
+
diff --git`)}function zl(e,t){if(e.length===0)return[``];let n=`\n${t}`,r=e.startsWith(t)?0:Bl(e,n,0);if(r===-1)return[e];let i=[];r>0&&i.push(e.slice(0,r));let a=r;for(;;){let t=Bl(e,n,a+1);if(t===-1)break;i.push(e.slice(a,t)),a=t}return i.push(e.slice(a)),i}function Bl(e,t,n){let r=e.indexOf(t,n);return r===-1?-1:r+1}function Vl(e){return e==null?e:sl(e)}function Hl(e){return e===` `?`context`:e===`\\`?`metadata`:e===`+`?`addition`:`deletion`}function Ul(e){let t=e.slice(1);return sl(t===``?`
|
|
13
|
+
`:t)}function Wl(e,t,n){return e===`change`?{type:`change`,additions:0,deletions:0,additionLineIndex:n,deletionLineIndex:t}:{type:`context`,lines:0,additionLineIndex:n,deletionLineIndex:t}}function Gl(e){let t=e[0];if(t!==`+`&&t!==`-`&&t!==` `&&t!==`\\`){console.error(`parseLineType: Invalid firstChar: "${t}", full line: "${e}"`);return}let n=e.substring(1);return{line:n===``?`
|
|
14
|
+
`:n,type:t===` `?`context`:t===`\\`?`metadata`:t===`+`?`addition`:`deletion`}}function Kl(e){if(e.trim()===``)return{kind:`empty`};let t=e.split(`
|
|
15
|
+
`);t.at(-1)===``&&t.pop();let n=t.findIndex(e=>e.startsWith(`@@`));if(n<0)return{kind:`invalid`};try{let r=Sl(t[0]?.startsWith(`@@`)?`diff --git a/excerpt b/excerpt\n${e}`:e,{throwOnError:!0}).flatMap(e=>e.files),i=r[0];if(r.length!==1||!i?.hunks.length)return{kind:`invalid`};let a=n,o=0,s=[];for(let e of i.hunks){if(t[a]!==e.hunkSpecs?.replace(/\n$/,``))return{kind:`invalid`};let n={id:`patch:${a}`,text:t[a++]??``},r=[],i=e.deletionStart||1,c=e.additionStart||1,l=e=>{let n=t[a]??``,s=Gl(n),l=e===`removed`?`deletion`:e===`added`?`addition`:`context`;if(s?.type!==l)return!1;let u={source:n,line:{id:`patch:${a++}`,text:n.slice(1),kind:e,...e===`added`?{}:{oldLine:i},...e===`removed`?{}:{newLine:c}},oldLine:i,newLine:c,position:c};return r.push(u),e!==`added`&&i++,e!==`removed`&&c++,e!==`context`&&o++,t[a]===`\`&&r.push({...u,source:`\`,line:{id:`patch:${a++}`,text:`\`}}),!0};for(let n of e.hunkContent)if(n.type===`context`){for(let e=0;e<n.lines;e++)if(!l(`context`))return{kind:`invalid`}}else for(let e=0;e<n.deletions+n.additions;e++){let e=Gl(t[a]??``)?.type;if(!l(e===`deletion`?`removed`:`added`))return{kind:`invalid`}}s.push({header:n,lines:r})}return a===t.length?{kind:`valid`,header:t.slice(0,n),hunks:s,changes:o}:{kind:`invalid`}}catch{return{kind:`invalid`}}}var ql=(e,t,n,r)=>`@@ -${t===0?e-1:e},${t} +${r===0?n-1:n},${r} @@`;function Jl(e){let t=e[0];if(t==null)return[];let n=e.filter(e=>e.text.startsWith(` `)||e.text.startsWith(`-`)).length,r=e.filter(e=>e.text.startsWith(` `)||e.text.startsWith(`+`)).length;return[ql(t.oldLine,n,t.newLine,r),...e.map(e=>e.text)]}function Yl(e,t,n=3){let r=Kl(e);if(r.kind!==`valid`)return r.kind===`empty`?e:null;let{header:i,hunks:a}=r,o=e=>t.some(t=>e>=t.startLine-n&&e<=t.endLine+n),s=[...i];for(let e of a){let t=[];for(let n of e.lines){let e={...n,text:n.source};(e.text.startsWith(`\\`)?t.length>0:o(e.position))?t.push(e):t.length>0&&(s.push(...Jl(t)),t=[])}t.length>0&&s.push(...Jl(t))}return s.length===i.length?null:`${s.join(`
|
|
16
|
+
`)}\n`}function Xl(e){return e.mergeBaseOid===null||e.mergeBaseOid===void 0?null:{baseOid:e.mergeBaseOid,headOid:e.head.oid}}function Zl(e){return e instanceof Error&&(e.name===`RequestError`||e.name===`ConnectionError`)?e.message:`The branch could not be compared. Try again.`}function Ql(e){let t=new Map;for(let n of e){let e=ar(n);t.has(e)||t.set(e,{path:e,paths:[e],kind:`kind`in n?n.kind:`changed`})}return[...t.values()]}var $l=new Set([`spec`,`specs`,`__tests__`,`tests`]);function eu(e){let t=e.slice(e.lastIndexOf(`/`)+1);return/\.(?:spec|test|browser)\.[^.]+$/.test(t)||/_(?:test|spec)\.[^.]+$/.test(t)||/^test_.+\.py$/.test(t)||/(?:Test|Tests|Spec)\.(?:java|kt|cs|swift|scala)$/.test(t)?!0:e.split(`/`).slice(0,-1).some(e=>$l.has(e))}function tu(e,t){if(!t)return e;let n=[],r=[];for(let t of e)eu(t.path)?r.push(t):n.push(t);return[...n,...r]}function nu(e,t){return e?`Unmark as reviewed`:t?`Mark as reviewed again`:`Mark as reviewed`}function ru(e){switch(e.kind){case`file`:return[{id:`review`,label:nu(e.status===`reviewed`,e.status===`stale`),disabled:!e.canReview},{id:`open`,label:`Open diff`},{id:`open-to-side`,label:e.sideLabel},{id:`open-file`,label:`Open file`},{id:`timeline`,label:`Show timeline`},{id:`copy-relative`,label:`Copy relative path`},...e.canDiscard?[{id:`discard`,label:`Discard`,destructive:!0}]:[]];case`section`:return[{id:`open`,label:`Open`}];case`group`:return[{id:`expand-all`,label:`Expand all`},{id:`collapse-all`,label:`Collapse all`}];default:return e}}var Z=wn(),iu=e(D(),1),Q=e(se(),1),au=Q.createContext({disabled:!1});function ou(){return Q.useContext(au)}var su=e=>/\.(png|jpe?g|gif|webp|avif|svg|ico)$/i.test(e);function cu({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function lu(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:uu(n,e.startContentIndex)}}function uu(e,t){let n=e.unifiedLineStart;for(let r=0;r<t;r++){let t=e.hunkContent[r];n+=t.type===`context`?t.lines:t.deletions+t.additions}return n}function du({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:c,lineAnnotations:l,getHoveredLine:u,getInstance:d,getAnnotationSlotName:f=ao}){let p=n?.(e),m=r?.(e),h=i?.(e),g=a?.(e);return(0,Z.jsxs)(Z.Fragment,{children:[p==null?(0,Z.jsxs)(Z.Fragment,{children:[m!=null&&(0,Z.jsx)(`div`,{slot:`header-prefix`,children:m}),h!=null&&(0,Z.jsx)(`div`,{slot:`header-filename-suffix`,children:h}),g!=null&&(0,Z.jsx)(`div`,{slot:`header-metadata`,children:g})]}):(0,Z.jsx)(`div`,{slot:lo,children:p}),o!=null&&l?.map((t,n)=>(0,Z.jsx)(`div`,{slot:f(t),children:o(t,e)},n)),t!=null&&c!=null&&d!=null&&t.map(t=>{if(t==null)return;let n=fu(t,e);return(0,Z.jsx)(`div`,{slot:n,style:Qi,children:c(t,d)},n)}),s!=null&&(0,Z.jsx)(`div`,{slot:`gutter-utility-slot`,style:Wi,children:s(u)})]})}function fu(e,t){let n=lu(e,t);return n==null?void 0:cu({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}function pu(e){if(e.type===`diff`){let{instance:t,item:n}=e;return t.__getNextRenderData({fileDiff:t.fileDiff??n.fileDiff,lineAnnotations:void 0})}let{instance:t,item:n}=e;return t.__getNextRenderData({file:t.file??n.file,lineAnnotations:void 0})}function mu(e,t){return e==null||t==null?e===t:e.header!==t.header||e.footer!==t.footer?!1:hu(e.items,t.items)}function hu(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r==null||i==null||r.id!==i.id||r.type!==i.type||r.element!==i.element||r.instance!==i.instance||r.version!==i.version)return!1}return!0}function gu(e,t,n){let r=document.createElement(`div`);return r.style.display=`flow-root`,e===`header`?(r.setAttribute(Ba,``),t.before(r)):(r.setAttribute(Pa,``),t.after(r)),n?.observe(r),r}function _u(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function vu(e){let t=window.devicePixelRatio??1;return Math.round(e*t)/t}async function yu(e,t=300){let n;try{await Promise.race([e(),new Promise(e=>{n=setTimeout(e,t)})])}finally{n!=null&&clearTimeout(n)}}function bu({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o,canHydratePartialDiff:s}){let c=Qo(t,n),l=c,u=i?!0:a,d=e.hunks.length-1;for(let n=0;n<e.hunks.length;n++){let i=e.hunks[n];if(i==null)throw Error(`computeEstimatedDiffHeights: invalid hunk index`);let a=Qr({isPartial:e.isPartial,rangeSize:i.collapsedBefore,expandedHunks:u,hunkIndex:n,collapsedContextThreshold:o}),f=(a.fromStart+a.fromEnd)*t.lineHeight;if(c+=f,l+=f,a.collapsedLines>0){let e=br({type:r,metrics:t,hunkIndex:n,hunkSpecs:i.hunkSpecs})?.totalHeight??0;c+=e,l+=e}c+=i.splitLineCount*t.lineHeight,l+=i.unifiedLineCount*t.lineHeight;let p=xu(i);c+=p.split*t.lineHeight,l+=p.unified*t.lineHeight;let m=n===d?ni({fileDiff:e,hunkIndex:n,expandedHunks:u,collapsedContextThreshold:o,errorPrefix:`computeEstimatedDiffHeights`}):void 0;if(m!=null){let e=(m.fromStart+m.fromEnd)*t.lineHeight;if(c+=e,l+=e,m.collapsedLines>0){let e=ei({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}else if(n===d&&e.isPartial&&s){let e=ei({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}if(e.hunks.length>0){let e=vs(t);c+=e,l+=e}return{splitHeight:c,unifiedHeight:l}}function xu(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};let t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type===`context`){let e=+(t.lines>0);return{split:e,unified:e}}return Su(e,t)}function Su(e,t){let n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),r=t.deletions>0&&e.noEOFCRDeletions,i=t.additions>0&&e.noEOFCRAdditions;return{split:r||i?1:0,unified:n}}function Cu({oldFile:e,newFile:t},n){if(e!==void 0||t!==void 0){if(e===void 0||t===void 0)throw Error(`${n}: Pass null for an intentionally missing oldFile or newFile side`);if(e===null){if(t===null)throw Error(`${n}: You must pass oldFile, newFile, or both`);return{oldFile:e,newFile:t}}return{oldFile:e,newFile:t}}}function wu(e){return e===``?[]:e.split(fs)}function Tu(e,t,n,r={}){let i=e===`clone`?Vs(t):t;if(!i.isPartial)throw Error(`hydratePartialDiff: fileDiff must be partial`);switch(i.type){case`change`:case`rename-changed`:return Eu(i,Ou(i,n),ku(i,n),r);case`rename-pure`:{let e=ku(i,n);Au(i,n);let t=wu(e.contents);return i.isPartial=!1,i.deletionLines=t,i.additionLines=t,i.deletionCharacterCount=e.contents.length,i.additionCharacterCount=e.contents.length,Mu(i,null,e,r),i}}throw Error(`hydratePartialDiff: ${i.type} diffs cannot be hydrated from loaded files`)}function Eu(e,t,n,r){let i=wu(t.contents),a=wu(n.contents),{hunks:o,splitLineCount:s,unifiedLineCount:c}=Du(e.hunks,a.length);return e.hunks=o,e.splitLineCount=s,e.unifiedLineCount=c,e.isPartial=!1,e.deletionLines=i,e.additionLines=a,e.deletionCharacterCount=t.contents.length,e.additionCharacterCount=n.contents.length,Mu(e,t,n,r),e}function Du(e,t){let n=0,r=0,i=0,a=[];for(let t of e){let e=Math.max(t.additionStart-1,0),o=Math.max(t.deletionStart-1,0),s=e,c=o,l=0,u=0,d=0,f=0,p=[];for(let e of t.hunkContent)e.type===`context`?(p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.lines,c+=e.lines,d+=e.lines,f+=e.lines):(p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.additions,c+=e.deletions,l+=e.additions,u+=e.deletions,d+=Math.max(e.additions,e.deletions),f+=e.additions+e.deletions);let m=Math.max(li(t.additionStart,t.additionCount)-i,0);a.push({...t,collapsedBefore:m,additionLineIndex:e,deletionLineIndex:o,additionLines:l,deletionLines:u,hunkContent:p,splitLineStart:n+m,unifiedLineStart:r+m,splitLineCount:d,unifiedLineCount:f}),n+=m+d,r+=m+f,i=Oi(t.additionStart,t.additionCount)}if(a.length>0){let e=a[a.length-1],i=Oi(e.additionStart,e.additionCount),o=Math.max(t-i,0);n+=o,r+=o}return{hunks:a,splitLineCount:n,unifiedLineCount:r}}function Ou(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function ku(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function Au(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function ju(e,t,n,r){return e.cacheKey==null?Nu(t,n,r):`${e.cacheKey}:hydrated`}function Mu(e,t,n,r){let i=ju(e,t,n,r);i==null?delete e.cacheKey:e.cacheKey=i}function Nu(e,t,n){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?Sr(n.disableLineMatching===!0?`hydrated-files-raw`:`hydrated-files`,e.cacheKey,t.cacheKey):void 0:e?.cacheKey??t?.cacheKey}var Pu=`/dev/null`;function Fu(e,t,{disableLineMatching:n,...r}={},i=!1){if(e===null&&t===null)throw Error(`parseDiffFromFile: You must pass oldFile, newFile, or both`);let a=e??Iu(),o=t??Iu(),s=Xr(a.name,o.name,a.contents,o.contents,a.header,o.header,r),c=cr(s,{cacheKey:(()=>{let r=e?.cacheKey,i=t?.cacheKey;return r!=null&&i!=null?Sr(n===!0?`diff-raw`:`diff`,r,i):void 0})(),oldFile:a,newFile:o,disableLineMatching:n,throwOnError:i});if(c==null)throw Error(`parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?`);e===null?(c.type=`new`,c.prevName=void 0):t===null&&(c.type=`deleted`,c.prevName=void 0);let l=t?.lang??(t===null?e?.lang:void 0);return l!=null&&(c.lang=l),c}function Iu(){return{name:Pu,contents:``}}var Lu=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){this.enabled&&=(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,!1)}setup(e,t,n){if(t==null||n==null)for(let r of e.children??[])r instanceof HTMLElement&&(`deletions`in r.dataset?t=r:`additions`in r.dataset&&(n=r));n==null||t==null?this.cleanUp():(this.codeDeletions!==t&&(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener(`scroll`,this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&(this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener(`scroll`,this.handleAdditionsScroll,{passive:!0})),this.enabled=!0)}handleDeletionsScroll=()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))};handleAdditionsScroll=()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))}};function Ru(e,t){let n=Fu({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t);return{hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,additionLines:n.additionLines,deletionLines:n.deletionLines,additionCharacterCount:n.additionCharacterCount,deletionCharacterCount:n.deletionCharacterCount,type:n.type}}function zu(e,t){let n=Math.max(e,1),r=Array.from({length:n},(e,t)=>`${` `.repeat(t+1)}\n`).join(``);return r===t&&(r=Array.from({length:n},(e,t)=>`\u0000${` `.repeat(t)}\n`).join(``)),r}function Bu(e){for(let t of e)if(t.trim().length>0)return!1;return!0}function Vu(e,t){return t.length>0&&t.length<e.deletionLines.length&&Bu(t)}function Hu(e,t,n,r){let i=e.deletionLines.join(``),a=zu(t.length,i),o=Fu({name:e.prevName??e.name,contents:i},{name:e.name,contents:a,lang:e.lang},r);return{hunks:o.hunks,splitLineCount:o.splitLineCount,unifiedLineCount:o.unifiedLineCount,additionLines:t,deletionLines:o.deletionLines,additionCharacterCount:n,deletionCharacterCount:o.deletionCharacterCount,type:o.type}}function Uu(e,t){return Hu(e,[``],0,t)}function Wu(e,t){if(e.additionLines.length===0)return Uu(e,t);if(Vu(e,e.additionLines))return Hu(e,e.additionLines,e.additionCharacterCount,t);let n=e.additionLines,r=Ru(e,t);return Ku(r,n),r}function Gu(e){return e.length>1&&e.at(-1)===``}function Ku(e,t){if(!Gu(t))return;let n=t.length-e.additionLines.length;if(n<=0)return;let r=e.additionLines.length,i=e.hunks.at(-1);if(i!=null&&Oi(i.additionStart,i.additionCount)===r){for(let a of i.hunkContent)if(a.type===`change`&&a.additions<a.deletions&&a.additionLineIndex+a.additions===r){e.additionLines=t,a.additions+=n,i.additionCount+=n,i.additionLines+=n,nd(e);return}}}function qu(e,t,n){if(e.isPartial||e.deletionLines.length!==e.additionLines.length)return Ju(e,Ru(e,n));let r=Array.from(t);if(r.length===0)return Ju(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type});for(let t of r){let r=e.additionLines[t],i=e.deletionLines[t];if(r==null||i==null||pr(r)===pr(i))return Ju(e,Ru(e,n))}let i=Yu(e,r);if(i.size===0)return Ju(e,Ru(e,n));for(let t of i)if(!Zu(e,t,n))return Ju(e,Ru(e,n));return nd(e),ii(e)?Ju(e,Ru(e,n)):Ju(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type})}function Ju(e,t){return Object.assign(e,t),t}function Yu(e,t){let n=new Set;for(let r of t){let t=Xu(e,r);if(t==null)return new Set;n.add(t)}return n}function Xu(e,t){for(let[n,r]of e.hunks.entries()){let e=r.additionLineIndex+r.additionCount;if(t>=r.additionLineIndex&&t<e)return n}}function Zu(e,t,n){let r=e.hunks[t];if(r==null)return!1;let i=e.deletionLines.slice(r.deletionLineIndex,r.deletionLineIndex+r.deletionCount),a=e.additionLines.slice(r.additionLineIndex,r.additionLineIndex+r.additionCount),o=Fu({name:e.prevName??e.name,contents:i.join(``)},{name:e.name,contents:a.join(``),lang:e.lang},{...n,context:0}),s=o.hunks[0];return s==null||o.hunks.length!==1?!1:($u(r,s),Qu(e,t),!0)}function Qu(e,t){let n=e.hunks[t];if(n==null)return;if(t!==e.hunks.length-1){n.noEOFCRAdditions=!1,n.noEOFCRDeletions=!1;return}let r=e.additionLines.at(-1),i=e.deletionLines.at(-1);n.noEOFCRAdditions=r!=null&&r!==``&&!r.endsWith(`
|
|
17
17
|
`),n.noEOFCRDeletions=i!=null&&i!==``&&!i.endsWith(`
|
|
18
|
-
`)}function Qu(e,t){let n=e.additionLineIndex,r=e.deletionLineIndex;e.hunkContent=t.hunkContent.map(e=>$u(e,n,r)),e.additionLineIndex=n+t.additionLineIndex,e.additionStart+=t.additionLineIndex,e.additionCount=t.additionCount,e.additionLines=t.additionLines,t.deletionLineIndex>=0&&(e.deletionLineIndex=r+t.deletionLineIndex,e.deletionStart+=t.deletionLineIndex),e.deletionCount=t.deletionCount,e.deletionLines=t.deletionLines,e.noEOFCRAdditions=t.noEOFCRAdditions,e.noEOFCRDeletions=t.noEOFCRDeletions,ed(e)}function $u(e,t,n){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+n}}function ed(e){let t=0,n=0;for(let r of e.hunkContent)r.type===`context`?(t+=r.lines,n+=r.lines):(t+=Math.max(r.additions,r.deletions),n+=r.additions+r.deletions);e.splitLineCount=t,e.unifiedLineCount=n}function td(e){let t=0,n=0,r=0;for(let i of e.hunks)i.collapsedBefore=Math.max(ci(i.additionStart,i.additionCount)-r,0),i.splitLineStart=t+i.collapsedBefore,i.unifiedLineStart=n+i.collapsedBefore,ed(i),t+=i.collapsedBefore+i.splitLineCount,n+=i.collapsedBefore+i.unifiedLineCount,r=Di(i.additionStart,i.additionCount);if(e.hunks.length>0){let r=e.hunks[e.hunks.length-1],i=Math.max(e.additionLines.length-Di(r.additionStart,r.additionCount),0);t+=i,n+=i}e.splitLineCount=t,e.unifiedLineCount=n}var nd=new WeakMap;function rd(e){return e.length>1&&e[e.length-1]===``?e.slice(0,-1):e}function id(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;let i=e.length,a=t.length;for(;i>r&&a>r&&e[i-1]===t[a-1];)i--,a--;if(r!==i||r!==a)return{start:r,deletionEnd:i,additionEnd:a}}function ad(e,t,n){let r=e.hunks,i=e.additionLines,a=rd(i),o=a===i?e:{...e,additionLines:a},s=gd(r,md(o,t,n),e.deletionLines.length),c=yd(o,s);if(e.additionLines=a,e.hunks=c,e.editSessionDirty=!0,kd(e),Gu(e,i),Sd(r,e.hunks))return{regions:s.map(e=>e.previousSpan)}}function od(e,t,n,r){let i=new Set(t),a=Array.from(i).filter(t=>t>=0&&t<e.additionLines.length).sort((e,t)=>e-t);if(a.length===0)return;let o=t=>i.has(t)?r?.get(t):e.additionLines[t],{hunks:s}=e,c,l=0;for(let t of a){for(;l<s.length;){let e=s[l];if(t<Td(e)+e.additionCount)break;l++}let r=s[l],i=r==null?void 0:Td(r);if(i==null||t<i||c!=null&&c!==l)return ad(e,n,o);c=l}if(c!=null){if(sd(e,a,c,r,n))e.editSessionDirty=!0;else return ad(e,n,o)}}function sd(e,t,n,r,i){if(r==null||i?.ignoreWhitespace===!0||i?.stripTrailingCr===!0)return!1;let a=cd(e),o=e.hunks[n];if(o.hunkContent.some(ld))return!1;for(let n of t){let t=r.get(n),i=e.additionLines[n];if(t==null||i==null||a.has(t)||a.has(i))return!1;let s=!1;for(let e of o.hunkContent)if(e.type===`change`&&e.additions===e.deletions&&n>=e.additionLineIndex&&n<e.additionLineIndex+e.additions){s=!0;break}if(!s)return!1}return!0}function cd(e){let t=nd.get(e);if(t?.lines===e.deletionLines)return t.set;let n=new Set(e.deletionLines);return nd.set(e,{lines:e.deletionLines,set:n}),n}function ld(e){return e?.type===`change`&&(e.additions===0||e.deletions===0)}function ud(e,t){let n=new Map,{regions:r}=t;for(let t=0;t<=r.length;t++){let i=r[t-1],a=r[t],o=t===0?e.get(0):i==null?void 0:e.get(i.lastIndex+1),s=a==null?void 0:e.get(a.firstIndex),c=o?.fromStart??0,l=s?.fromEnd??0;(c>0||l>0)&&n.set(t,{fromStart:c,fromEnd:l})}return n}function dd(e,t,n){let r=[];if(e.isPartial)return r;for(let[i,a]of e.hunks.entries()){let o=Zr({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:t,hunkIndex:i,collapsedContextThreshold:n});if(o.rangeSize<=n)continue;let s=Ed(a),c=s-o.rangeSize;o.fromStart>0&&r.push([c,c+o.fromStart]),o.fromEnd>0&&r.push([s-o.fromEnd,s])}let i=ti({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`captureExpansionAnchors`});if(i!=null&&i.fromStart>0&&i.rangeSize>n){let t=e.hunks[e.hunks.length-1],n=Ed(t)+t.deletionCount;r.push([n,n+i.fromStart])}return r}function fd(e,t){let n=new Map;if(t.length===0)return n;let r=(e,r,i)=>{if(i<=r)return;let a=0,o=0;for(let[e,n]of t)n<=r||e>=i||(e<=r&&(a=Math.max(a,Math.min(n,i)-r)),n>=i&&(o=Math.max(o,i-Math.max(e,r))));(a>0||o>0)&&n.set(e,{fromStart:a,fromEnd:o})};for(let[t,n]of e.hunks.entries()){let e=Ed(n);r(t,e-Math.max(n.collapsedBefore,0),e)}let i=e.hunks[e.hunks.length-1];return i!=null&&!e.isPartial&&e.deletionLines.length>0&&r(e.hunks.length,Ed(i)+i.deletionCount,e.deletionLines.length),n}function pd(e,t){return e.editSessionDirty===!0&&(delete e.editSessionDirty,Object.assign(e,e.additionLines.length<=1&&e.additionLines.join(``)===``?Lu(e,t):Uu(e,t)),!0)}function md(e,t,n){if(id(e.deletionLines,e.additionLines)==null)return[];let r=Pu({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t),i,a=(t,a)=>{i??=hd(e.hunks);for(let e=0;e<=a;e++){let o=i.get(t.deletionLineIndex-e);if(o!=null&&o.additions===t.additions&&o.deletions===t.deletions){if(t.additions>0&&n!=null){for(let e=0;e<t.additions;e++)if(n(o.additionLineIndex+e)!==r.additionLines[t.additionLineIndex+e])return a}return e}}return a},o=[],s=0,c=0;for(let e of r.hunks){hr(e,r,a);let t=e.additionCount>0?e.additionLineIndex-s:e.deletionLineIndex-c;s+=t,c+=t;for(let t of e.hunkContent){if(t.type===`context`){s+=t.lines,c+=t.lines;continue}let e=$u(t,0,0);e.additions===0&&(e.additionLineIndex=s),e.deletions===0&&(e.deletionLineIndex=c),o.push(e),s+=e.additions,c+=e.deletions}}return o}function hd(e){let t=new Map;for(let n of e)for(let e of n.hunkContent)e.type===`change`&&(e.additions===0||e.deletions===0)&&t.set(e.deletionLineIndex,e);return t}function gd(e,t,n){let r=e.map((e,t)=>{let n=Ed(e);return{deletionStart:n,deletionEnd:n+e.deletionCount,blocks:[],previousSpan:{firstIndex:t,lastIndex:t}}}),i=[],a=0;for(let e of t){let t=e.deletionLineIndex,o=t+e.deletions;for(;a<r.length&&r[a].deletionEnd<t;)i.push(r[a]),a++;let s=i.length>0&&_d(t,o,i[i.length-1])?i.pop():void 0;for(;a<r.length&&r[a].deletionStart<=o;)s=vd(s,r[a]),a++;if(s==null){let c=t,l=o;if((e.deletions===0||e.additions===0)&&n>e.deletions){let e=i[i.length-1]?.deletionEnd??0,s=r[a]?.deletionStart??n;t>e?c--:o<s&&l++}s={deletionStart:c,deletionEnd:l,blocks:[],previousSpan:void 0}}s.deletionStart=Math.min(s.deletionStart,t),s.deletionEnd=Math.max(s.deletionEnd,o),s.blocks.push(e),i.push(s)}for(;a<r.length;)i.push(r[a]),a++;return i}function _d(e,t,n){return e<=n.deletionEnd&&t>=n.deletionStart}function vd(e,t){return e==null?t:(e.deletionStart=Math.min(e.deletionStart,t.deletionStart),e.deletionEnd=Math.max(e.deletionEnd,t.deletionEnd),e.blocks.push(...t.blocks),t.previousSpan!=null&&(e.previousSpan??={...t.previousSpan},e.previousSpan.firstIndex=Math.min(e.previousSpan.firstIndex,t.previousSpan.firstIndex),e.previousSpan.lastIndex=Math.max(e.previousSpan.lastIndex,t.previousSpan.lastIndex)),e)}function yd(e,t){let n=[],r=0,i=0;for(let a of t){let t=a.deletionStart-r;if(t<0)throw Error(`buildRegionHunks: overlapping old-side regions`);r+=t,i+=t;let o=i,s=[];for(let e of a.blocks){let t=e.deletionLineIndex-r,n=e.additionLineIndex-i;if(t<0||t!==n)throw Error(`buildRegionHunks: canonical block context mismatch`);xd(s,t,i,r),r+=t,i+=n,s.push({...e}),r+=e.deletions,i+=e.additions}let c=a.deletionEnd-r;if(c<0)throw Error(`buildRegionHunks: block exceeds its old-side region`);xd(s,c,i,r),r+=c,i+=c,n.push(bd(e,{additionStart:o,additionEnd:i,deletionStart:a.deletionStart,deletionEnd:a.deletionEnd},s))}if(e.deletionLines.length-r!==e.additionLines.length-i)throw Error(`buildRegionHunks: trailing context mismatch`);return n}function bd(e,t,n){let r=t.additionEnd-t.additionStart,i=t.deletionEnd-t.deletionStart,a=0,o=0;for(let e of n)e.type===`change`&&(a+=e.additions,o+=e.deletions);let s={collapsedBefore:0,additionStart:Dd(t.additionStart,r),additionCount:r,additionLines:a,additionLineIndex:Od(t.additionStart,r),deletionStart:Dd(t.deletionStart,i),deletionCount:i,deletionLines:o,deletionLineIndex:Od(t.deletionStart,i),hunkContent:n,hunkSpecs:`@@ -${Dd(t.deletionStart,i)},${i} +${Dd(t.additionStart,r)},${r} @@`,splitLineStart:0,splitLineCount:0,unifiedLineStart:0,unifiedLineCount:0,noEOFCRAdditions:!1,noEOFCRDeletions:!1};return ed(s),s}function xd(e,t,n,r){t>0&&e.push({type:`context`,lines:t,additionLineIndex:n,deletionLineIndex:r})}function Sd(e,t){if(e.length!==t.length)return!0;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(Ed(r)!==Ed(i)||r.deletionCount!==i.deletionCount||Td(r)!==Td(i)||r.additionCount!==i.additionCount||r.splitLineCount!==i.splitLineCount||!Cd(r,i))return!0}return!1}function Cd(e,t){let n=wd(e),r=wd(t);for(;;){let e=n.next(),t=r.next();if(e.done===!0||t.done===!0)return e.done===t.done;if(e.value[0]!==t.value[0]||e.value[1]!==t.value[1])return!1}}function*wd(e){for(let t of e.hunkContent){if(t.type===`context`){for(let e=0;e<t.lines;e++)yield[t.deletionLineIndex+e,t.additionLineIndex+e];continue}let e=Math.max(t.deletions,t.additions);for(let n=0;n<e;n++)yield[n<t.deletions?t.deletionLineIndex+n:void 0,n<t.additions?t.additionLineIndex+n:void 0]}}function Td(e){return ci(e.additionStart,e.additionCount)}function Ed(e){return ci(e.deletionStart,e.deletionCount)}function Dd(e,t){return t===0?e:e+1}function Od(e,t){return t===0?e-1:e}function kd(e){td(e);for(let t=0;t<e.hunks.length;t++)Zu(e,t)}function Ad(e){return Is({tagName:`div`,properties:{"data-content-buffer":``,"data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function jd(e){return Is({tagName:`div`,children:[Is({tagName:`span`,children:[Ns(`No newline at end of file`)]})],properties:{"data-no-newline":``,"data-line-type":e,"data-column-content":``}})}function Md(e){return Is({tagName:`div`,children:[js({name:e===`both`?`diffs-icon-expand-all`:`diffs-icon-expand`,properties:{"data-icon":``}})],properties:{role:`button`,"data-expand-button":``,"data-expand-both":e===`both`?``:void 0,"data-expand-up":e===`up`?``:void 0,"data-expand-down":e===`down`?``:void 0}})}function Nd({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:a,isLastHunk:o}){let s=0,c=[];if(e===`metadata`&&t!=null&&c.push(Is({tagName:`div`,children:[Ns(t)],properties:{"data-separator-wrapper":``}})),(e===`line-info`||e===`line-info-basic`)&&t!=null){let e=[];n!=null&&(r?(a||(e.push(Md(`up`)),s++),o||(e.push(Md(`down`)),s++)):(e.push(Md(!a&&!o?`both`:a?`down`:`up`)),s++)),e.push(Is({tagName:`div`,children:[Is({tagName:`span`,children:[Ns(t)],properties:{"data-unmodified-lines":``}})],properties:{"data-separator-content":``}})),r&&n!=null&&e.push(Is({tagName:`div`,children:[Ns(`Expand all`)],properties:{role:`button`,"data-expand-button":``,"data-expand-all-button":``}})),c.push(Is({tagName:`div`,children:e,properties:{"data-separator-wrapper":``,"data-separator-multi-button":s>1?``:void 0}}))}return e===`custom`&&i!=null&&c.push(Is({tagName:`slot`,properties:{name:i}})),Is({tagName:`div`,children:c,properties:{"data-separator":c.length===0?`simple`:e,"data-expand-index":n,"data-separator-first":a?``:void 0,"data-separator-last":o?``:void 0}})}function Pd(e,t){return`hunk-separator-${e}-${t}`}function Fd(e){let t=e.at(-1);return t==null?0:Math.max(Di(t.additionStart,t.additionCount),Di(t.deletionStart,t.deletionCount))}var Id=-1,Ld=class{options;annotationSlotName;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++Id}`;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLangs=[`text`];renderCache;pendingHighlightResult;pendingStructuralRows;editSessionActive=!1;constructor(e={theme:yo},t=io,n,r){this.options=e,this.annotationSlotName=t,this.onRenderUpdate=n,this.workerManager=r}cleanUp(){this.endEditSession(),this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.diff=void 0,this.editSessionActive?(this.renderCache!=null&&(this.renderCache.renderRange=void 0),this.pendingHighlightResult=void 0,this.pendingStructuralRows=void 0):this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this)}beginEditSession(e,t){let{editSessionActive:n}=this;this.editSessionActive=!0,n||(this.pendingHighlightResult=void 0),this.diff=e,n&&this.renderCache!=null&&this.renderCache.diff!==e&&this.clearRenderCache();let{renderCache:r}=this;if(!e.isPartial&&e.additionLines.length===0){Object.assign(e,Hu(e,this.options.parseDiffOptions)),this.markEditSessionPass(e),this.clearRenderCache();return}if(r==null||n&&r.diff===e)return;let{options:i}=this.getRenderOptions(e),a=r.diff===e,o=t!=null&&Vi(r.diff,t),{result:s}=r;!r.highlighted||s==null||!_i(r.options,i)||!a&&!o?this.clearRenderCache():a||(this.renderCache={diff:e,options:i,highlighted:!0,result:{...s,code:{...s.code,additionLines:[...s.code.additionLines]}},renderRange:r.renderRange})}endEditSession(){this.editSessionActive=!1,this.pendingHighlightResult=void 0,this.diff??this.clearRenderCache()}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}refreshHighlightedResult(){let{diff:e,renderCache:t,workerManager:n}=this;return e==null||t==null||!Vi(t.diff,e)||Wn(e)||Zd(e,this.getTokenizeMaxLength())?Promise.resolve():!this.editSessionActive&&n?.isWorkingPool()===!0&&e.cacheKey!=null?(n.evictDiffFromCache(e.cacheKey),n.primeDiffHighlightCache(e).then(()=>{this.applyRefreshedResult(e,n.getDiffResultCache(e))}).catch(e=>{Qo(e)||this.onHighlightError(e)})):this.asyncHighlight(e).then(t=>this.applyRefreshedResult(e,t)).catch(e=>this.onHighlightError(e))}applyRefreshedResult(e,t){let{diff:n,renderCache:r}=this;if(t==null||n==null||r==null||!Vi(n,e)||!Vi(r.diff,e)||this.editSessionActive)return;let{options:i}=this.getRenderOptions(n);_i(i,t.options)&&(this.pendingHighlightResult={diff:n,options:t.options,highlighted:!0,result:t.result},this.onRenderUpdate?.())}get diffCache(){return this.renderCache?.diff??this.diff}clearRenderCache(){this.renderCache=void 0,this.pendingHighlightResult=void 0,this.pendingStructuralRows=void 0}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){let r={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};(t===`up`||t===`both`)&&(r.fromStart+=n),(t===`down`||t===`both`)&&(r.fromEnd+=n),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??go}getExpandedHunksMap(){return this.expandedHunks}setExpandedHunksMap(e){this.expandedHunks=e}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(let t of e){let e=(()=>{switch(t.side){case`deletions`:return this.deletionAnnotations;case`additions`:return this.additionAnnotations}})(),n=e[t.lineNumber]??[];e[t.lineNumber]=n,n.push(t)}}updateRenderCache(e,t,n=!1,r,i){this.pendingStructuralRows=void 0;let{renderCache:a}=this;if(a==null)return!1;let{result:o,diff:s}=a;if(o==null)return!1;if(s.isPartial)throw Error(`Could not update render cache for partial diff`);let c=o.code.additionLines,l=this.pendingStructuralRows=n?new Map:void 0,u=[],d=new Map;if(l==null&&r!=null){let t=s.additionLines.length,n=qd(s.additionLines,i);for(let[i,a]of r){if(i<0||i>t||i===t&&(a===``||!n))continue;let r=s.additionLines[i]??``;r!==a&&(s.additionLines[i]=a,s.additionCharacterCount+=a.length-r.length,u.push(i),d.set(i,r),e.has(i)||(c[i]=Jd(i,fr(a))))}}for(let[t,n]of e){let e=c[t]?.properties??{},i=n.map(e=>e[2]).join(``),a=t<s.additionLines.length,o=a?s.additionLines[t]??``:``,f=fr(o);if(l==null&&a&&r?.has(t)!==!0){let e=lo(o,i);s.additionLines[t]=e,s.additionCharacterCount+=e.length-o.length,f!==i&&(u.push(t),d.set(t,o))}let p={type:`element`,tagName:`div`,properties:{"data-line":e[`data-line`]??t+1,"data-line-index":e[`data-line-index`]??t,"data-line-type":e[`data-line-type`]??`context`},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})};l==null?c[t]=p:l.set(t,p)}let f=!1;if(u.length>0){if(this.editSessionActive){if(s.additionLines.length<=1&&s.additionLines.join(``)===``)this.applyRecomputePreservingSessionType(s,Hu(s,this.options.parseDiffOptions)),f=!0;else if(Bu(s,s.additionLines))this.applyRecomputePreservingSessionType(s,Vu(s,s.additionLines,s.additionCharacterCount,this.options.parseDiffOptions)),f=!0;else{let e=od(s,u,this.options.parseDiffOptions,d);this.applyExpansionRemap(e),f=e!=null}}else Object.assign(s,Ku(s,u,this.options.parseDiffOptions))}return o.baseThemeType=t,a.isDirty=!0,f}applyExpansionRemap(e){e!=null&&(this.expandedHunks=ud(this.expandedHunks,e))}applyDocumentChange(e){let{pendingStructuralRows:t,renderCache:n}=this;this.pendingStructuralRows=void 0;let r=this.diff??n?.diff;if(r==null)return;let i=n?.result;if(r.isPartial)throw Error(`Could not apply document change for partial diff`);let{additionLines:a}=r,{lines:o,characterCount:s}=Yd(e);if(r.additionLines=o,r.additionCharacterCount=s,i!=null&&(i.code.additionLines=Kd(a,r.additionLines,i.code.additionLines,e)),r.additionLines.length<=1&&r.additionLines.join(``)===``?(this.applyRecomputePreservingSessionType(r,Hu(r,this.options.parseDiffOptions)),i!=null&&(i.code.additionLines[0]=Jd(0,e.getLineText(0)))):this.editSessionActive?this.applySessionDocumentChange(r,a):Object.assign(r,Uu(r,this.options.parseDiffOptions)),t!=null&&i!=null)for(let[e,n]of t)e<i.code.additionLines.length&&(i.code.additionLines[e]=n);n!=null&&(n.isDirty=!0)}applySessionDocumentChange(e,t){let{parseDiffOptions:n}=this.options,r=e.additionLines;Bu(e,r)?this.applyRecomputePreservingSessionType(e,Vu(e,r,e.additionCharacterCount,n)):this.applyExpansionRemap(ad(e,n,e=>t[e]))}applyRecomputePreservingSessionType(e,t){let n=this.editSessionActive?e.type:void 0;Object.assign(e,t),n!=null&&(e.type=n),this.markEditSessionPass(e)}markEditSessionPass(e){this.editSessionActive&&(e.editSessionDirty=!0)}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e,contentProperties:{"data-line-type":e}}}getSplitLineDecoration({side:e,type:t}){let n=t===`change`?e===`deletions`?`change-deletion`:`change-addition`:t;return{gutterLineType:n,contentProperties:{"data-line-type":n}}}createAnnotationElement=e=>qa(e);getOptionsWithDefaults(){let{diffIndicators:e=`bars`,diffStyle:t=`split`,disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:a=!1,collapsed:o=!1,expandUnchanged:s=!1,collapsedContextThreshold:c=1,expansionLineCount:l=100,hunkSeparators:u=`line-info`,lineDiffType:d=`word-alt`,maxLineDiffLength:f=1e3,overflow:p=`scroll`,stickyHeader:m=!1,theme:h=yo,headerRenderMode:g=`default`,tokenizeMaxLineLength:_=1e3,tokenizeMaxLength:v=Fa,useTokenTransformer:y=!1,useCSSClasses:b=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:a,collapsed:o,expandUnchanged:s,collapsedContextThreshold:c,expansionLineCount:l,hunkSeparators:u,lineDiffType:d,maxLineDiffLength:f,overflow:p,stickyHeader:m,theme:this.workerManager?.getDiffRenderOptions().theme??h,headerRenderMode:g,tokenizeMaxLineLength:_,tokenizeMaxLength:v,useTokenTransformer:y,useCSSClasses:b}}initializeHighlighter(){return xa($a(this.computedLangs,{theme:this.getLocalHighlightTheme(),preferredHighlighter:Do(this.workerManager,this.options)}))}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=Zd(e,this.getTokenizeMaxLength()),r=this.workerManager?.getDiffResultCache(e);r!=null&&!_i(t,r.options)&&(r=void 0),this.renderCache??={diff:e,hydrated:!0,highlighted:!n&&!Wn(e),options:t,result:n?void 0:r?.result,renderRange:void 0};let i=this.getHighlightWorkerManager(e);i==null?Yo({theme:this.getLocalHighlightTheme()})??(this.computedLangs=Xd(e),this.initializeHighlighter().catch(e=>{e instanceof Ps||this.onHighlightError(e)})):this.renderCache.result==null&&!n&&i.highlightDiffAST(this,this.diff)}getHighlightWorkerManager(e){let{editSessionActive:t,workerManager:n}=this;return!t&&n?.isWorkingPool()===!0&&!n.shouldHighlightOnMainThread(e)?n:void 0}cacheHighlightResult(e,t){let{editSessionActive:n,workerManager:r}=this;!n&&r?.isWorkingPool()===!0&&r.setDiffResultCache(e.cacheKey,t)}getLocalHighlightTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??yo}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getDiffRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let e=this.workerManager.getDiffRenderOptions();return this.editSessionActive&&e.useTokenTransformer!==!0?{...e,useTokenTransformer:!0}:e}let{theme:e,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}=this.getOptionsWithDefaults();return{theme:e,useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}})();this.getOptionsWithDefaults();let{renderCache:n}=this;return n?.result==null||!Vi(e,n.diff)||!_i(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}getDiffForNextRender(e){let{options:t}=this.getRenderOptions(e);if(this.getReadyRenderResult(e,t)!=null||this.renderCache==null)return e;if(Vi(this.renderCache.diff,e))return this.renderCache.diff;let n=!(e.additionLines.length>0||e.deletionLines.length>0)||Wn(e)||Zd(e,this.getTokenizeMaxLength());return this.canRenderDiff(e,t,n)?e:this.renderCache.diff}canRenderDiff(e,t,n){let{renderCache:r}=this;return r==null||Vi(r.diff,e)?!0:n?r.result==null&&r.hydrated!==!0||this.workerManager?.isWorkingPool()===!0&&!this.workerManager.shouldHighlightOnMainThread(e)||Yo({theme:t.theme})!=null:r.result==null&&r.hydrated!==!0?!0:this.getHighlightWorkerManager(e)==null?Yo({theme:t.theme})!=null:!r.highlighted}renderDiff(e=this.diff,t=La){if(this.diff=e,e==null){this.pendingHighlightResult=void 0;return}let{expandUnchanged:n,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),{options:i,forceHighlight:a}=this.getRenderOptions(e),o=this.getReadyRenderResult(e,i);this.pendingHighlightResult=void 0,o!=null&&(this.renderCache={...o,diff:e,renderRange:void 0},a=!1),this.renderCache??={diff:e,highlighted:!1,options:i,result:void 0,renderRange:void 0};let s=e.additionLines.length>0||e.deletionLines.length>0,c=!s||Wn(e)||Zd(e,this.getTokenizeMaxLength()),l=this.canRenderDiff(e,i,c),u=!Vi(e,this.renderCache.diff),d=!ks(this.renderCache.renderRange,t),f=this.getHighlightWorkerManager(e);if(f!=null){let o=this.renderCache.result==null&&this.renderCache.highlighted&&!c&&!u&&Xa(t);l&&!o&&(c||this.renderCache.result==null||!this.renderCache.highlighted&&(u||d))&&(this.renderCache.diff=e,this.renderCache.options=i,this.renderCache.highlighted=!1,(this.renderCache.result==null||u||d||a)&&(this.renderCache.result=f.getPlainDiffAST(e,t.startingLine,t.totalLines,Xa(t)||n?!0:this.expandedHunks,r)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||a)&&f.highlightDiffAST(this,e)}else{this.computedLangs=Xd(e);let n=Yo(),r=n!=null&&Ya(i.theme,n),o=n!=null&&ka(this.computedLangs,n),s=!c&&o,u=Number.isFinite(t.totalLines);if(l&&n!=null&&r&&(a||c||!this.renderCache.highlighted&&s||this.renderCache.result==null)){let{result:t,options:r}=this.renderDiffWithHighlighter(e,n,c||!o,u);this.renderCache={diff:e,options:r,highlighted:s,result:t,renderRange:void 0},s&&this.cacheHighlightResult(e,{result:t,options:r})}r&&(c||o)||this.asyncHighlight(e,u).then(({result:t,options:n})=>{c||this.cacheHighlightResult(e,{result:t,options:n}),this.applyHighlightResult(e,t,n,!c)}).catch(e=>{e instanceof Ps||this.onHighlightError(e)})}return this.renderCache.result==null?void 0:this.processDiffResult(this.renderCache.diff,t,this.renderCache.result)}async asyncRender(e,t=La){this.diff=e;let{result:n}=await this.asyncHighlight(e,Number.isFinite(t.totalLines));return this.processDiffResult(e,t,n)}createPreElement(e,t,n){let{diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o}=this.getOptionsWithDefaults();return ao({type:`diff`,diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e,t=!1){let n=Zd(e,this.getTokenizeMaxLength());this.computedLangs=n?[`text`]:Xd(e);let r=Yo(),i=r!=null&&Ya(this.getLocalHighlightTheme(),r),a=n||r!=null&&ka(this.computedLangs,r);return r!=null&&i&&a||(r=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,r,n,t)}renderDiffWithHighlighter(e,t,n=!1,r=!1){let{options:i}=this.getRenderOptions(e),{collapsedContextThreshold:a}=this.getOptionsWithDefaults(),o=Xn(e,t,i,{forcePlainText:n,lazyLineAST:r,expandedHunks:n?!0:void 0,collapsedContextThreshold:a});if(this.editSessionActive&&e.additionLines.length===1&&e.additionLines[0]===``&&o.code.additionLines[0]==null){let t;if(qr({diff:e,diffStyle:`both`,expandedHunks:n?!0:void 0,collapsedContextThreshold:a,callback:({additionLine:e})=>{if(e?.lineIndex===0)return t=e,!0}}),t==null)throw Error(`DiffHunksRenderer: missing empty addition line`);o.code.additionLines[0]=Jd(0,``,t.unifiedLineIndex,t.splitLineIndex)}return{result:o,options:i}}onHighlightSuccess(e,t,n,r=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){let{diff:i,renderCache:a}=this;i!=null&&a!=null&&Vi(i,e)&&_i(n,this.getRenderOptions(i).options)&&(a.result!=null&&a.highlighted&&_i(a.options,n)&&Vi(a.diff,i)||(this.pendingHighlightResult={diff:i,options:n,highlighted:r,result:t},this.onRenderUpdate?.()))}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getDiffResultCache(e);if(n!=null&&_i(t,n.options))return n}getReadyRenderResult(e,t){let{pendingHighlightResult:n}=this;if(n!=null&&Vi(n.diff,e)&&_i(n.options,t))return n;let r=this.getMatchingWorkerResultCache(e,t);if(!(r==null||this.hasHighlightedRenderCache(e,t)))return{diff:e,highlighted:!0,...r}}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&Vi(e,n.diff)&&_i(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let{diffStyle:a,disableFileHeader:o,expandUnchanged:s,expansionLineCount:c,collapsedContextThreshold:l,hunkSeparators:u}=this.getOptionsWithDefaults(),d=this.renderCache?.isDirty??!1,f=a===`unified`,p=Qd(e,this.options.loadDiffFiles!=null),m=!e.isPartial||p,h=[],g=[],_=[],v=[],{additionLines:y,deletionLines:b}=n,x={rowCount:0,hunkSeparators:u,additionsContentAST:h,deletionsContentAST:g,unifiedContentAST:_,unifiedGutterAST:Fs(),deletionsGutterAST:Fs(),additionsGutterAST:Fs(),expansionLineCount:c,hunkData:v,incrementRowCount(e=1){x.rowCount+=e},pushToGutter(e,t){switch(e){case`unified`:x.unifiedGutterAST.children.push(t);break;case`deletions`:x.deletionsGutterAST.children.push(t);break;case`additions`:x.additionsGutterAST.children.push(t)}}},S=_r({fileDiff:e,errorPrefix:`DiffHunksRenderer.processDiffResult`}),C={size:0,side:void 0,increment(){this.size+=1},flush(){a!==`unified`&&(this.size<=0||this.side==null?(this.side=void 0,this.size=0):(this.side===`additions`?(x.pushToGutter(`additions`,Ms(void 0,`buffer`,this.size)),h?.push(Ad(this.size))):(x.pushToGutter(`deletions`,Ms(void 0,`buffer`,this.size)),g?.push(Ad(this.size))),this.size=0,this.side=void 0))}},w=(e,t,n,r,i)=>{x.pushToGutter(e,As(t,n,r,i))};function T(e){C.flush(),a===`unified`?Ud(`unified`,e,x):(Ud(`deletions`,e,x),Ud(`additions`,e,x))}this.pushFileLevelAnnotations(e,a,t,x),qr({diff:e,diffStyle:a,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:s?!0:this.expandedHunks,collapsedContextThreshold:l,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,additionLine:o,deletionLine:s,type:c})=>{let l=s==null?o.splitLineIndex:s.splitLineIndex,h=o==null?s.unifiedLineIndex:o.unifiedLineIndex;a===`split`&&c!==`change`&&C.flush(),r>0&&T({hunkIndex:t,collapsedLines:r,rangeSize:Math.max(n?.collapsedBefore??0,0),hunkSpecs:n?.hunkSpecs,isFirstHunk:t===0,isLastHunk:!1,isExpandable:m});let g=a===`unified`?h:l,_={type:c,hunkIndex:t,lineIndex:g,unifiedLineIndex:h,splitLineIndex:l,deletionLine:s,additionLine:o};if(a===`unified`){let n=this.getUnifiedInjectedRowsForLine?.(_);n?.before!=null&&Bd(n.before,x);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex];if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let a=c===`change`?o==null?`change-deletion`:`change-addition`:c,u=this.getUnifiedLineDecoration({type:c,lineType:a,additionLineIndex:o?.lineIndex,deletionLineIndex:s?.lineIndex});w(`unified`,u.gutterLineType,o==null?s.lineNumber:o.lineNumber,`${h},${l}`,u.gutterProperties),i==null?r!=null&&(r=Wd(r,u.contentProperties,d&&s!=null?{"data-line":s.lineNumber,"data-line-index":`${h},${l}`}:void 0)):i=Wd(i,u.contentProperties,d&&o!=null?{"data-line":o.lineNumber,"data-line-index":`${h},${l}`}:void 0),Hd({diffStyle:`unified`,type:c,deletionLine:r,additionLine:i,unifiedSpan:this.getAnnotations(`unified`,s?.lineNumber,o?.lineNumber,t,g),createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&Bd(n.after,x)}else{let n=this.getSplitInjectedRowsForLine?.(_);n?.before!=null&&Vd(n.before,x,C);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex],a=this.getSplitLineDecoration({side:`deletions`,type:c,lineIndex:s?.lineIndex}),u=this.getSplitLineDecoration({side:`additions`,type:c,lineIndex:o?.lineIndex});if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let f=(()=>{if(c===`change`){if(i==null)return`additions`;if(r==null)return`deletions`}})();f==null?c===`change`&&C.flush():(C.side!=null&&C.side!==f&&C.flush(),C.side=f,C.increment());let p=this.getAnnotations(`split`,s?.lineNumber,o?.lineNumber,t,g);if(p!=null&&C.size>0&&C.flush(),s!=null){let e=Wd(r,a.contentProperties,d?{"data-line":s.lineNumber,"data-line-index":`${s.unifiedLineIndex},${l}`}:void 0);w(`deletions`,a.gutterLineType,s.lineNumber,`${s.unifiedLineIndex},${l}`,a.gutterProperties),e!=null&&(r=e)}if(o!=null){let e=Wd(i,u.contentProperties,d?{"data-line":o.lineNumber,"data-line-index":`${o.unifiedLineIndex},${l}`}:void 0);w(`additions`,u.gutterLineType,o.lineNumber,`${o.unifiedLineIndex},${l}`,u.gutterProperties),e!=null&&(i=e)}Hd({diffStyle:`split`,type:c,additionLine:i,deletionLine:r,...p,createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&Vd(n.after,x,C)}let v=a===`split`&&n!=null&&l===n.splitLineStart+n.splitLineCount-1,E=t===e.hunks.length-1&&n!=null&&(a===`split`?l===n.splitLineStart+n.splitLineCount-1:h===n.unifiedLineStart+n.unifiedLineCount-1),D=v?n.noEOFCRDeletions:!1,O=v?n.noEOFCRAdditions:!1,k=(s?.noEOFCR??!1)||D,A=(o?.noEOFCR??!1)||O;if(A||k){if(a===`split`&&C.flush(),k){let e=c===`context`||c===`context-expanded`?c:`change-deletion`;a===`unified`?(x.unifiedContentAST.push(jd(e)),x.pushToGutter(`unified`,Ms(e,`metadata`,1))):(x.deletionsContentAST.push(jd(e)),x.pushToGutter(`deletions`,Ms(e,`metadata`,1)),A||(x.pushToGutter(`additions`,Ms(void 0,`buffer`,1)),x.additionsContentAST.push(Ad(1))))}if(A&&!(f&&k&&c!==`change`)){let e=c===`context`||c===`context-expanded`?c:`change-addition`;a===`unified`?(x.unifiedContentAST.push(jd(e)),x.pushToGutter(`unified`,Ms(e,`metadata`,1))):(x.additionsContentAST.push(jd(e)),x.pushToGutter(`additions`,Ms(e,`metadata`,1)),k||(x.pushToGutter(`deletions`,Ms(void 0,`buffer`,1)),x.deletionsContentAST.push(Ad(1))))}x.incrementRowCount(1)}u!==`simple`&&u!==`metadata`&&(i>0||E&&p)&&T({hunkIndex:c===`context-expanded`?t:t+1,collapsedLines:E&&p?`unknown`:i,rangeSize:S,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:m}),x.incrementRowCount(1)}}),a===`split`&&C.flush();let E=Math.max(Fd(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),D=t.bufferBefore>0||t.bufferAfter>0,O=!f&&e.type!==`deleted`,k=!f&&e.type!==`new`,A=x.rowCount>0||D;h=O&&A?h:void 0,g=k&&A?g:void 0,_=f&&A?_:void 0;let j=this.createPreElement(g!=null&&h!=null,E);return{fileDiff:e,unifiedGutterAST:f&&A?x.unifiedGutterAST.children:void 0,unifiedContentAST:_,deletionsGutterAST:k&&A?x.deletionsGutterAST.children:void 0,deletionsContentAST:g,additionsGutterAST:O&&A?x.additionsGutterAST.children:void 0,additionsContentAST:h,hunkData:v,preNode:j,themeStyles:r,baseThemeType:i,headerElement:o?void 0:this.renderHeader(e),totalLines:E,rowCount:x.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderCodeAST(e,t){let n=e===`unified`?t.unifiedGutterAST:e===`deletions`?t.deletionsGutterAST:t.additionsGutterAST,r=e===`unified`?t.unifiedContentAST:e===`deletions`?t.deletionsContentAST:t.additionsContentAST;if(n==null||r==null)return;let i=Fs(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,Ba(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators===`line-info`,r=this.renderCodeAST(`unified`,e);if(r!=null)return t.push(Is({tagName:`code`,children:r,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-unified":``}})),{...e.preNode,children:t};let i=this.renderCodeAST(`deletions`,e);i!=null&&t.push(Is({tagName:`code`,children:i,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-deletions":``}}));let a=this.renderCodeAST(`additions`,e);return a!=null&&t.push(Is({tagName:`code`,children:a,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-additions":``}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return Ls(this.renderFullAST(e,t))}renderPartialHTML(e,t){return Ls(t==null?e:Is({tagName:`code`,children:e,properties:{"data-code":``,"data-container-size":this.getOptionsWithDefaults().hunkSeparators===`line-info`?``:void 0,[`data-${t}`]:``}}))}pushFileLevelAnnotations(e,t,n,r){if(!cs(n))return;let i=e.type===`new`?[]:this.getAnnotationNames(Ia(this.deletionAnnotations)),a=e.type===`deleted`?[]:this.getAnnotationNames(Ia(this.additionAnnotations));if(i.length===0&&a.length===0)return;let{createAnnotationElement:o}=this;Hd(t===`unified`?{diffStyle:t,type:`context`,unifiedSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i.concat(a)},createAnnotationElement:o,context:r}:{diffStyle:t,type:`context`,deletionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i},additionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:a},createAnnotationElement:o,context:r})}getAnnotations(e,t,n,r,i){let a={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(t!=null)for(let e of this.deletionAnnotations[t]??[])a.annotations.push(this.annotationSlotName(e));let o={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(n!=null)for(let t of this.additionAnnotations[n]??[])(e===`unified`?a:o).annotations.push(this.annotationSlotName(t));if(e===`unified`)return a.annotations.length>0?a:void 0;if(o.annotations.length!==0||a.annotations.length!==0)return{deletionSpan:a,additionSpan:o}}getAnnotationNames(e){return e?.map(e=>this.annotationSlotName(e))??[]}renderHeader(e){let{headerRenderMode:t,stickyHeader:n}=this.getOptionsWithDefaults();return Pa({fileOrDiff:e,mode:t,stickyHeader:n})}},Rd=new Intl.PluralRules(`en-US`);function zd(e){return`${e} unmodified line${Rd.select(e)===`one`?``:`s`}`}function Bd(e,t){for(let n of e)t.unifiedContentAST.push(n.content),t.pushToGutter(`unified`,n.gutter),t.incrementRowCount(1)}function Vd(e,t,n){for(let{deletion:r,addition:i}of e){if(r==null&&i==null)continue;let e=r!=null&&i!=null?void 0:r==null?`deletions`:`additions`;(e==null||n.side!==e)&&n.flush(),r!=null&&(t.deletionsContentAST.push(r.content),t.pushToGutter(`deletions`,r.gutter)),i!=null&&(t.additionsContentAST.push(i.content),t.pushToGutter(`additions`,i.gutter)),e!=null&&(n.side=e,n.increment()),t.incrementRowCount(1)}}function Hd({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:a,additionSpan:o,createAnnotationElement:s,context:c}){let l=!1;if(e===`unified`){if(r==null?n!=null&&c.unifiedContentAST.push(n):c.unifiedContentAST.push(r),i!=null){let e=t===`change`?n==null?`change-addition`:`change-deletion`:t;c.unifiedContentAST.push(s(i)),c.pushToGutter(`unified`,Ms(e,`annotation`,1)),l=!0}}else if(e===`split`){if(n!=null&&c.deletionsContentAST.push(n),r!=null&&c.additionsContentAST.push(r),a!=null){let e=t===`change`?n==null?`context`:`change-deletion`:t;c.deletionsContentAST.push(s(a)),c.pushToGutter(`deletions`,Ms(e,`annotation`,1)),l=!0}if(o!=null){let e=t===`change`?r==null?`context`:`change-addition`:t;c.additionsContentAST.push(s(o)),c.pushToGutter(`additions`,Ms(e,`annotation`,1)),l=!0}}l&&c.incrementRowCount(1)}function Ud(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:a,isLastHunk:o,isExpandable:s},c){if(typeof n==`number`&&n<=0)return;let l=e===`unified`?c.unifiedContentAST:e===`deletions`?c.deletionsContentAST:c.additionsContentAST;if(c.hunkSeparators===`metadata`){i!=null&&(c.pushToGutter(e,Nd({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),l.push(Nd({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1));return}if(c.hunkSeparators===`simple`){t>0&&(c.pushToGutter(e,Nd({type:`simple`,isFirstHunk:a,isLastHunk:!1})),l.push(Nd({type:`simple`,isFirstHunk:a,isLastHunk:!1})),e!==`additions`&&c.incrementRowCount(1));return}let u=Pd(e,t),d=r>c.expansionLineCount,f=s?t:void 0,p=typeof n==`number`?zd(n):`More unchanged context may be available`;c.pushToGutter(e,Nd({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),l.push(Nd({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1),c.hunkData.push({slotName:u,hunkIndex:t,lines:typeof n==`number`?n:0,lineCountKnown:typeof n==`number`,type:e,expandable:s?{up:!a,down:!o,chunked:d}:void 0})}function Wd(e,t,n){return e==null||e.type!==`element`||t==null&&n==null?e:{...e,properties:{...e.properties,...t,...n}}}function Gd(e){return e.length>0&&e[e.length-1]===``?e.length-1:e.length}function Kd(e,t,n,r){let i=Gd(e),a=Gd(t),o=Math.min(i,a),s=0;for(;s<o&&e[s]===t[s];)s++;let c=0;for(;c<o-s&&e[i-1-c]===t[a-1-c];)c++;let l=Array(t.length);for(let e=0;e<s;e++)l[e]=n[e];for(let e=0;e<c;e++)l[a-1-e]=n[i-1-e];i<e.length&&a<t.length&&(l[t.length-1]=n[e.length-1]);for(let e=s;e<t.length;e++)l[e]??=Jd(e,r.getLineText(e));return l}function qd(e,t){return t===e.length+1&&e.at(-1)?.endsWith(`
|
|
19
|
-
`)===!0}function Jd(e,t,n=e,r=e){return{type:`element`,tagName:`div`,properties:{"data-line":e+1,"data-line-index":`${n},${r}`,"data-line-type":`context`},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:t}]}]}}function Yd(e){let t=[],n=0;for(let r=0;r<e.lineCount;r++){let i=e.getLineText(r,!0);t.push(i),n+=i.length}return{lines:t,characterCount:n}}function Xd(e){if(e.lang!=null)return[e.lang];let t=po(e.prevName??e.name),n=po(e.name);return t===n?[n]:[t,n]}function Zd(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function Qd(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function $d(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function ef(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.lineCountKnown===t.lineCountKnown&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function tf(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:Ao(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators==`function`?`custom`:e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,loadDiffFiles:e?.loadDiffFiles,parseDiffOptions:e?.parseDiffOptions,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}function nf(e){return e.isPartial&&(e.type===`change`||e.type===`rename-changed`||e.type===`rename-pure`)}function rf(e){let t={...e};return delete t.cacheKey,t}function af(e,t){if(e.isPartial||t.isPartial)throw Error(`FileDiff.shouldResetEditorForExternalDiff: diffs must be fully hydrated`);let n=e.lang??po(e.name),r=t.lang??po(t.name),i=e.type!==`new`,a=t.type!==`new`;return e.name!==t.name||n!==r||i!==a||e.deletionLines.length!==t.deletionLines.length||e.deletionLines.some((e,n)=>e!==t.deletionLines[n])}function of(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function sf(e,t){let{oldFile:n}=e;return n==null?t.type===`new`:t.type!==`new`&&n.name===(t.prevName??t.name)&&of(n.lines,t.deletionLines)}var cf=-1,lf=class{options;workerManager;requestOwnerRender;static LoadedCustomComponent=!0;__id=`file-diff:${++cf}`;type=`file-diff`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;get lineAnnotations(){return this.renderedData?.lineAnnotations??To}managersDirty=!1;deletionFile;additionFile;fileDiff;editSession;renderedData;pendingData;forceRenderOverride;renderRange;pendingFiles;appliedPreAttributes;headerCache={lastRenderedHTML:void 0,html:void 0,fileDiff:void 0};lastRowCount;mounted=!1;enabled=!0;editor;refreshViewTimeout;lineStateRefreshPending=!1;deferredSelectedLines;deferredEditorActiveLine;constructor(e={theme:yo},t,n){this.options=e,this.workerManager=t,this.requestOwnerRender=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new wa,this.scrollSyncManager=new Iu,this.interactionManager=new _o(`diff`,Ra(e,typeof e.hunkSeparators==`function`||(e.hunkSeparators??`line-info`)===`line-info`||e.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??yo}getHunksRendererOptions(e){return tf(e)}createHunksRenderer(e){return new Ld(this.getHunksRendererOptions(e),this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t=`additions`)=>this.getLineIndexForDiff(this.getDiffForLineIndex(),e,t);getDiffForLineIndex(){return this.getRenderedDiff()}getLineIndexForDiff(e,t,n){if(e==null)return;let r=e.hunks.at(-1),i,a;hunkIterator:for(let o of e.hunks){let e=n===`deletions`?o.deletionStart:o.additionStart,s=n===`deletions`?o.deletionCount:o.additionCount,c=ci(e,s)+1,l=o.splitLineStart,u=o.unifiedLineStart;if(t<c){let e=c-t;i=Math.max(u-e,0),a=Math.max(l-e,0);break hunkIterator}if(t>=c+s){if(o===r){let e=t-(c+s);i=u+o.unifiedLineCount+e,a=l+o.splitLineCount+e;break hunkIterator}}else{for(let e of o.hunkContent)if(e.type===`context`){if(t<c+e.lines){let e=t-c;a=l+e,i=u+e;break hunkIterator}c+=e.lines,l+=e.lines,u+=e.lines}else{let r=n===`deletions`?e.deletions:e.additions;if(t<c+r){let r=t-c;i=u+(n===`additions`?e.deletions:0)+r,a=l+r;break hunkIterator}c+=r,l+=Math.max(e.deletions,e.additions),u+=e.deletions+e.additions}break hunkIterator}}if(i!=null&&a!=null)return[i,a]}setOptions(e){e!=null&&(this.options=e,this.clearReusableHeader(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(Ra(this.options,typeof this.options.hunkSeparators==`function`||(this.options.hunkSeparators??`line-info`)===`line-info`||this.options.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType!==t&&(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!to(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();getAnnotationSlotName=e=>Ds(this.editSession?.annotations,e,io);getLatestAnnotations(){return this.pendingData?.lineAnnotations??this.editSession?.annotations?.current??this.lineAnnotations}getAnnotationsForDiff(e){let{pendingData:t}=this;return t!=null&&Vi(e,t.fileDiff)?t.lineAnnotations:this.lineAnnotations}isNewAnnotations(e){let t=this.editSession?.annotations;return e===this.getLatestAnnotations()?!1:t==null||e!==t.provided&&e!==t.current}setLineAnnotations(e){let t=this.editSession?.annotations;if(t!=null){if(!this.isNewAnnotations(e))return;No(t,e,io)}let n=this.getWorkingDiff();n!=null&&(this.pendingData={fileDiff:n,lineAnnotations:e})}syncEditSessionAnnotationsFromEditor(e){let t=this.editSession?.annotations;return t==null||e===t.current?!1:(t.current=e,this.renderedData!=null&&(this.renderedData.lineAnnotations=e),this.pendingData=void 0,this.hunksRenderer.setLineAnnotations(e),this.renderAnnotations(),!0)}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators==`function`)}setSelectedLines(e,t){this.lineStateRefreshPending?this.deferredSelectedLines=[e,t]:this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.lineStateRefreshPending?this.deferredEditorActiveLine=[e,t]:this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??`additions`})}flushDeferredLineState(){let{deferredEditorActiveLine:e,deferredSelectedLines:t}=this;this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,e!=null&&this.setEditorActiveLine(...e),t!=null&&this.interactionManager.setSelection(...t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:e=`split`,overflow:t=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t===`wrap`,columnVariables:this.shouldApplyColumnVariables(t)?`apply`:`measure`}),t===`scroll`&&e===`split`?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}shouldApplyColumnVariables(e){return typeof this.options.hunkSeparators==`function`||e===`scroll`&&(this.lineAnnotations.length>0||this.pre?.hasAttribute(`data-has-merge-conflict`)===!0)}getCodeScrollLeft(){return Math.max(this.codeUnified?.scrollLeft??0,this.codeDeletions?.scrollLeft??0,this.codeAdditions?.scrollLeft??0)}setCodeScrollLeft(e){this.codeUnified!=null&&(this.codeUnified.scrollLeft=e),this.codeAdditions!=null&&(this.codeAdditions.scrollLeft=e),this.codeDeletions!=null&&(this.codeDeletions.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(e=!1){let{editor:t}=this;ms(this.handleEditSessionRender),this.emitPostRender(!0),t?.cleanUp(e?`recycle`:`discard`),e||(this.editor=void 0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,e||(this.pendingFiles=void 0),this.isComponentManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.renderedData=void 0,this.pendingData=void 0),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre?.remove(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement?.remove(),this.headerElement=void 0,this.clearHeaderSlots(),this.placeHolder?.remove(),this.placeHolder=void 0,this.headerCache.lastRenderedHTML=void 0,e||this.clearReusableHeader(),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.editSession=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate({fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:r,fileDiff:i,...a}){if(!this.enabled)throw Error(`FileDiff.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated`);let o=Su(a,`FileDiff.hydrate`),s=o?.oldFile,c=o?.newFile;this.hydrateElements(e,t);let l=this.editor!=null;l||mf(this.pre,ff({fileDiff:i,oldFile:s,newFile:c}),this.options.collapsed)||hf(this.headerElement,pf({fileDiff:i,oldFile:s,newFile:c}),this.options.disableFileHeader)?this.render({...a,fileContainer:e,lineAnnotations:r,fileDiff:i,forceRender:l||a.forceRender,preventEmit:!0}):this.hydrationSetup({fileDiff:i,lineAnnotations:r,...o}),n||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),as(e,t);for(let t of e.shadowRoot?.children??[])if(t instanceof SVGElement)this.spriteSVG=t;else if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t;for(let e of t.children)e instanceof HTMLElement&&e.tagName.toLowerCase()===`code`&&(`deletions`in e.dataset&&(this.codeDeletions=e),`additions`in e.dataset&&(this.codeAdditions=e),`unified`in e.dataset&&(this.codeUnified=e))}else`diffsHeader`in t.dataset?this.headerElement=t:t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)?this.themeCSSStyle=t:t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent)}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){let i=r??this.getLatestAnnotations();this.pendingData=void 0,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?Pu(t,n,this.options.parseDiffOptions):void 0),this.renderedData=this.fileDiff==null?void 0:{fileDiff:this.fileDiff,lineAnnotations:i},this.fileDiff!=null&&this.adoptRenderData(this.fileDiff),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.getInputDiff()==null&&this.additionFile==null&&this.deletionFile==null||this.requestRender()||this.render({forceRender:!0,renderRange:this.renderRange})}requestRender(){let{requestOwnerRender:e}=this;return this.editSession!=null||e==null?!1:(this.forceRenderOverride=!0,e(),!0)}get isComponentManaged(){return this.requestOwnerRender!=null}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.loadFilesIfNecessary(),this.hunksRenderer.expandHunk(e,t,n),this.rerender()};loadFilesIfNecessary(){let e=this.getInputDiff(),{loadDiffFiles:t}=this.options;if(e==null||!nf(e)||this.pendingFiles?.fileDiff===e)return;if(t==null)throw Error(`FileDiff: loadDiffFiles is required to load full files for a partial diff`);let n=this.loadFilesForDiff(e,t),r=this.pendingFiles={fileDiff:e,promise:n};r.promise=n.finally(()=>{this.pendingFiles===r&&(this.pendingFiles=void 0)})}__canAttachEditor(){let e=this.getInputDiff();return e!=null&&!e.isPartial}async prepareForEditing(){if(this.__canAttachEditor())return;let e=this.__prepareForEditing();if(e==null){let e=this.getInputDiff();throw e?.isPartial===!0&&!nf(e)?Error(`FileDiff.prepareForEditing: this partial diff cannot be hydrated; provide a complete diff`):Error(`FileDiff.prepareForEditing: a partial diff requires loadDiffFiles`)}if(await e,!this.__canAttachEditor())throw Error(`FileDiff.prepareForEditing: the diff did not finish loading`)}__prepareForEditing(){if(this.__canAttachEditor())return;let e=this.getInputDiff();if(e?.isPartial===!0&&!nf(e))throw Error(`FileDiff: this partial diff cannot be hydrated; provide a complete diff to edit`);return this.loadFilesIfNecessary(),this.pendingFiles?.promise}async loadFilesForDiff(e,t){try{let n=await t(e);if(this.getInputDiff()!==e)return;await this.handleFilesLoaded(e,n)}catch(e){if(this.options.disableErrorHandling===!0)throw e;console.error(e)}}async handleFilesLoaded(e,t){this.getInputDiff()===e&&e.isPartial&&(wu(`merge`,e,t,this.options.parseDiffOptions),this.setHydratedState(t),this.installHydratedSessionDiff(e)?this.rerender():(await vu(()=>this.primeHighlightCache(e)),this.enabled&&this.getInputDiff()===e&&this.rerender()))}installHydratedSessionDiff(e){if(e.isPartial)throw Error(`FileDiff.installHydratedSessionDiff: diffs cannot be partial for editing`);return this.getInputDiff()===e&&this.editSession?.outgoingDiff!=null&&(this.installEditSession(e),!0)}updateInputDiff(e,t){if(Vi(this.getInputDiff(),e))return!1;let n=this.getLatestAnnotations();this.fileDiff=e;let{editSession:r}=this,i=r?.outgoingDiff??r?.diff;return r!=null&&(e.isPartial?r.inputDiff=e:this.installEditSession(e),this.editSession!=null&&(this.editSession.outgoingDiff=i)),this.editSession?.annotations!=null&&t!=null&&(this.editSession.annotations=bs(t,io,this.editSession.annotations)),this.pendingData={fileDiff:this.editSession?.diff??e,lineAnnotations:this.editSession?.annotations?.current??t??n},i!=null&&e.isPartial&&this.loadFilesIfNecessary(),!0}installEditSession(e,t,n){let r=e.additionLines.join(``),i=t==null?void 0:Cu(t.contents),a=n!=null&&sf(n,e);if(n!=null&&!a)throw Error(`FileDiff: retained session cannot resume against a different old file`);if(t!=null&&t.contents!==r&&!a)throw Error(`FileDiff: retained edits are missing their diff session state`);let o=t==null||t.name===e.name&&t.lang===e.lang&&t.contents===r,s=rf(e);t!=null&&i!=null&&!o&&(s.name=t.name,s.lang=t.lang),a&&n!=null&&t!=null&&i!=null&&(s.additionLines=i,s.additionCharacterCount=t.contents.length,s.type=n.type,s.hunks=n.hunks,s.editSessionDirty=!0,td(s));let c=this.editSession?.annotations??bs(this.getLatestAnnotations(),io);this.editSession={diff:s,inputDiff:e,annotations:c,outgoingDiff:this.editSession?.outgoingDiff},this.pendingData={fileDiff:s,lineAnnotations:c.current},this.hunksRenderer.beginEditSession(s,o&&!a?e:void 0)}setHydratedState(e){this.deletionFile=e.oldFile,this.additionFile=e.newFile,this.workerManager?.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:e,deferManagers:t=!1,forceRender:n=!1,preventEmit:r=!1,lineAnnotations:i,fileContainer:a,containerWrapper:o,renderRange:s,...c}){if(!this.enabled)throw Error(`FileDiff.render: attempting to call render after cleaned up`);n=this.forceRenderOverride??n,this.forceRenderOverride=void 0;let l=Su(c,`FileDiff.render`),u=l?.oldFile,d=l?.newFile;this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:f=!1,themeType:p=`system`,expandUnchanged:m=!1}=this.options,h=f?void 0:s,g=this.hasThemeChanged(),_=l!=null,v=_&&(!df(u,this.deletionFile)||!df(d,this.additionFile)),y=e!=null&&!Vi(e,this.getInputDiff()),b=i!=null&&(i.length>0||this.getLatestAnnotations().length>0)&&this.isNewAnnotations(i);if(!f&&ks(h,this.renderRange)&&!n&&!b&&!g&&(e!=null&&!y||e==null&&!v)){let e=this.applyCachedThemeState(p);return e&&this.finalizeRender(),e}let x;e==null&&_&&(v||this.getInputDiff()==null)&&(x=Pu(l.oldFile,l.newFile,this.options.parseDiffOptions));let{renderRange:S}=this;this.renderRange=h,_?(this.deletionFile=u,this.additionFile=d):e!=null&&(this.deletionFile=void 0,this.additionFile=void 0),e!=null&&y?this.updateInputDiff(e,i):x!=null&&(y=!0,this.updateInputDiff(x,i)),y&&this.clearReusableHeader(),i!=null&&this.setLineAnnotations(i);let C=this.getWorkingDiff();if(C==null)return!1;C.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(pd(C,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),m&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.prepareRenderData(this.hunksRenderer.getDiffForNextRender(C));let{disableErrorHandling:w=!1,disableFileHeader:T=!1}=this.options;if(T&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.headerCache.lastRenderedHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,o),this.applyCachedThemeState(p),f){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(C,xo);e!=null&&this.applyThemeState(a,e.themeStyles,p,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,a,e.fileDiff),this.renderSeparators([]),this.adoptRenderData(e?.fileDiff??C),this.injectUnsafeCSS()}catch(e){if(w)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return this.finalizeRender(),r||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(a);if(this.canPartiallyRender(n,b,v||y||g||!Vi(this.getRenderedDiff(),C))&&this.applyPartialRender({fileDiff:C,previousRenderRange:S,renderRange:h})){let e=this.getRenderedDiff();e!=null&&this.adoptRenderData(e)}else{let t=this.hunksRenderer.renderDiff(C,h);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.isWorkingPool()&&this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender()),!1;this.applyThemeState(a,t.themeStyles,p,t.baseThemeType),t.headerElement!=null&&this.applyHeaderToDOM(t.headerElement,a,t.fileDiff),t.additionsContentAST!=null||t.deletionsContentAST!=null||t.unifiedContentAST!=null?this.applyHunksToDOM(e,t):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(t.hunkData),this.adoptRenderData(t.fileDiff)}this.applyBuffers(e,h),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,t||this.flushManagers(),this.finalizeRender(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(w)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return r||this.emitPostRender(),!0}finalizeRender(){}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}getInputDiff(){return this.fileDiff}getWorkingDiff(e=this.fileDiff){return this.editSession?.diff??e}getRenderedDiff(){return this.renderedData?.fileDiff}__getNextRenderData({fileDiff:e,lineAnnotations:t}){let n=this.editSession?.annotations;if(n!=null)return{fileDiff:e,lineAnnotations:t!=null&&this.isNewAnnotations(t)?t:n.provided};let r=this.getWorkingDiff(e)??e,i=this.hunksRenderer.getDiffForNextRender(r);return{fileDiff:i,lineAnnotations:t!=null&&Vi(i,r)?t:this.getAnnotationsForDiff(i)}}prepareRenderData(e){this.hunksRenderer.setLineAnnotations(this.getAnnotationsForDiff(e))}adoptRenderData(e){let{pendingData:t}=this,n=t!=null&&Vi(e,t.fileDiff);this.renderedData={fileDiff:e,lineAnnotations:n?t.lineAnnotations:this.lineAnnotations},n&&(this.pendingData=void 0)}syncRenderViewToEditor(){let{editor:e,fileContainer:t}=this,n=this.getLatestAnnotations(),r=this.computeEditorRenderRange(this.renderRange),i=this.getWorkingDiff();if(e==null||t==null||i==null||i.isPartial)return;let a=a=>{if(!this.enabled||this.editor!==e||this.fileContainer!==t||this.getWorkingDiff()!==i)return;let o=this.editSession?.outgoingDiff,s=this.getInputDiff(),c=o!=null&&s!=null&&o!==i,l=c&&o!=null&&s!=null?af(o,s):!1;e.__syncRenderView({highlighter:a,fileContainer:t,fileDiff:i,lineAnnotations:n,renderRange:r,externalDocument:c,resetHistory:l})},o=this.getTheme(),s=i.lang??po(i.name),c=Yo({theme:o,lang:s});c==null?xa({themes:Qa(o),langs:[`text`,s],preferredHighlighter:Do(this.workerManager,this.options)}).then(a).catch(e=>{e instanceof Ps||console.error(e)}):a(c)}computeEditorRenderRange(e){let t=this.getWorkingDiff();if(e==null||t==null||Xa(e))return e;let{diffStyle:n=`split`,expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a,o;return qr({diff:t,diffStyle:n,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({additionLine:e})=>{e!=null&&(a??=e.lineNumber,o=e.lineNumber)}}),a==null||o==null?{...e,startingLine:0,totalLines:0}:{...e,startingLine:a-1,totalLines:o-a+1}}__acknowledgeDocumentUpdate(){this.editSession!=null&&(this.editSession.outgoingDiff=void 0)}__acceptEditorChange(e){let{lineAnnotations:t}=e;t!=null&&this.syncEditSessionAnnotationsFromEditor(t)}emitEditChange(e){let{onEditChange:t}=this.options;t?.(e)}__captureDocumentSessionState(e=!0){let t=this.getInputDiff(),{diff:n,outgoingDiff:r}=this.editSession??{};if(r!=null&&t!=null){if(!t.isPartial&&af(r,t))return;n=r}if(!(n==null||n.isPartial))return{diffSession:{oldFile:n.type===`new`?null:{name:n.prevName??n.name,lines:e?[...n.deletionLines]:n.deletionLines},type:n.type,hunks:e?Rs(n.hunks):n.hunks},hasChanges:n.editSessionDirty===!0}}__attachEditor(e){if(this.type!==`file-diff`)throw Error(`FileDiff.__attachEditor: cannot attach an editor to a "${this.type}" diff`);if(this.editor!=null)throw Error(`FileDiff.__attachEditor: an editor is already attached`);if(!this.__canAttachEditor())throw Error(`FileDiff.__attachEditor: a complete diff is required before editing`);let t=()=>{this.editor=void 0,this.finishEditSession()};try{return this.resumeEditorRendering(e),t}catch(e){throw t(),e}}__resumeEditor(e){if(this.editor!==e)throw Error(`FileDiff.__resumeEditor: editor association changed`);this.resumeEditorRendering(e)}resumeEditorRendering(e){let t=this.getInputDiff(),n=this.editSession?.outgoingDiff;n!=null&&t!=null&&!t.isPartial&&this.editSession?.diff===n&&this.installEditSession(t);let r=this.editSession==null&&t!=null&&!t.isPartial?t:void 0;r==null?this.editSession!=null&&this.hunksRenderer.beginEditSession(this.editSession.diff):this.installEditSession(r,e.__getDocumentContents(uf(r)),e.__getDocumentSessionState()),this.editor=e,this.getInputDiff()?.isPartial===!0&&this.loadFilesIfNecessary();let i=this.editSession?.diff;this.hunksRenderer.editorRenderReady()?(i!=null&&this.hunksRenderer.diffCache===i&&this.adoptRenderData(i),this.syncRenderViewToEditor()):this.rerender()}finishEditSession(){this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks()}__completeEditSession(e,t){this.settleEditSession(t===`install`,e)}settleEditSession(e,t){let{editSession:n}=this;if(n==null)return;let{diff:r,inputDiff:i,annotations:a}=n,o=a?.provided??this.lineAnnotations;if(this.editor!=null)throw Error(`FileDiff.__completeEditSession: detach the editor before completing the session`);this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks();let s=a?.current,c,l=null,u=null,d=!1,f;if(t==null)throw Error(`FileDiff.__completeEditSession: editor is required for completion`);let p=Bs(r),m={name:p.name,contents:p.additionLines.join(``)};p.lang!=null&&(m.lang=p.lang);let h={fileDiff:p,editor:t,originalFileDiff:i,oldFile:p.type===`new`?null:{name:p.prevName??p.name,contents:p.deletionLines.join(``)},newFile:m,lineAnnotations:s,originalLineAnnotations:o};Object.freeze(h);try{if(t.__emitEditComplete(h),this.options.onEditComplete?.(h)===`accept`){if(p.cacheKey!=null&&p.cacheKey===i.cacheKey)throw Error(`FileDiff.__completeEditSession: an accepted diff must not reuse the replaced diff cacheKey`);c=p,l=h.oldFile,u=h.newFile}}catch(e){d=!0,f=e}if(e&&c!=null&&this.additionFile!=null&&(this.deletionFile=l,this.additionFile=u),this.editSession=void 0,this.fileDiff=e&&c!=null?c:i,this.pendingData={fileDiff:this.fileDiff,lineAnnotations:e&&c!=null?s??o:o},e&&this.fileContainer!=null&&this.rerender(),d)throw f}finalizeEditSessionHunks(){let e=this.getWorkingDiff();if(e==null||e.editSessionDirty!==!0)return!1;let{collapsedContextThreshold:t=1}=this.options,n=dd(e,this.hunksRenderer.getExpandedHunksMap(),t);return pd(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(fd(e,n)),this.hunksRenderer.refreshHighlightedResult(),this.escalateEditSessionRender(),!0}applyDocumentChange(e,t){let n=this.editSession?.diff;if(n==null)throw Error(`FileDiff.applyDocumentChange: requires an active edit session`);this.detachAdditionLines(),this.hunksRenderer.beginEditSession(n),this.hunksRenderer.applyDocumentChange(e),t!=null&&this.syncEditSessionAnnotationsFromEditor(t),this.rerender(),this.interactionManager.setSelectionDirty()}applySuspendedDocumentChange(e,t){this.applyDocumentChange(e,t),this.hunksRenderer.clearRenderCache()}updateRenderCache(e,t,n={}){let r=this.editSession?.diff;if(r==null)throw Error(`FileDiff.updateRenderCache: requires an active edit session`);this.detachAdditionLines(),this.hunksRenderer.beginEditSession(r);let{shouldRefreshDiffsView:i,lineCountChangeInFlight:a}=n;this.hunksRenderer.updateRenderCache(e,t,a,n.changedDocumentLines,n.documentLineCount)?(this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!0,this.escalateEditSessionRender()):i===!0&&(this.refreshViewTimeout!=null&&clearTimeout(this.refreshViewTimeout),this.lineStateRefreshPending=!0,this.refreshViewTimeout=setTimeout(()=>{this.refreshViewTimeout=void 0,this.options.diffStyle===`split`?this.refreshSplitDiffView():this.refreshUnifiedDiffView(),this.flushDeferredLineState()},150))}detachAdditionLines(){let{diff:e,inputDiff:t}=this.editSession??{};e!=null&&(e.additionLines===t?.additionLines||e.additionLines===e.deletionLines)&&(e.additionLines=[...e.additionLines])}isLineRenderable(e){let t=this.getRenderedDiff();if(t==null)return!0;let{expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options;return Fr({fileDiff:t,lineNumber:e,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r})}getNearestRenderableLine(e,t){let n=this.getRenderedDiff();if(n==null)return e;let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;return Ji({fileDiff:n,lineNumber:e,direction:t,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i})}revealLine(e){let t=this.getRenderedDiff(),{expandUnchanged:n=!1,collapsedContextThreshold:r=1,expansionLineCount:i=100}=this.options;if(t==null||t.isPartial||n)return!1;let a=this.hunksRenderer.getExpandedHunksMap();for(let[n,o]of t.hunks.entries()){let[s,c]=lr(o);if(e<s){let c=Zr({isPartial:t.isPartial,rangeSize:o.collapsedBefore,expandedHunks:a,hunkIndex:n,collapsedContextThreshold:r}),l=s-c.rangeSize;if(c.renderAll||e<l+c.fromStart||e>=s-c.fromEnd)return!1;let u=e-(l+c.fromStart)+1,d=s-c.fromEnd-e;return u<=d?this.expandHunk(n,`up`,u+i):this.expandHunk(n,`down`,d+i),!0}if(e<c)return!1}let o=ti({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:a,collapsedContextThreshold:r,errorPrefix:`FileDiff.revealLine`});if(o==null||o.renderAll)return!1;let s=t.hunks[t.hunks.length-1],[,c]=lr(s);return e<c+o.fromStart||e>=c+o.rangeSize?!1:(this.expandHunk(t.hunks.length,`up`,e-(c+o.fromStart)+1+i),!0)}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){es(this.handleEditSessionRender)}handleEditSessionRender=()=>{this.rerender(),this.flushDeferredLineState()};removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.setPlaceholderHeight(e)}setPlaceholderHeight(e){return this.placeHolder!=null&&(this.placeHolder.style.setProperty(`height`,`${e}px`),!0)}async primeHighlightCache(e=this.getInputDiff()){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||Wn(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(e=>{Qo(e)||console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.headerCache.lastRenderedHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){let{hunkSeparators:t}=this.options;if(this.isComponentManaged||this.fileContainer==null||typeof t!=`function`){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();return}let n=new Map(this.separatorCache);for(let r of e){let e=r.slotName,i=this.separatorCache.get(e);if(i==null||!ef(r,i.hunkData)){i?.element.remove();let n=document.createElement(`div`);n.style.display=`contents`,n.slot=r.slotName;let a=t(r,this);a!=null&&n.appendChild(a),this.fileContainer.appendChild(n),i={element:n,hunkData:r},this.separatorCache.set(e,i)}n.delete(e)}for(let[e,{element:t}]of n.entries())this.separatorCache.delete(e),t.remove()}renderAnnotations(){if(this.isComponentManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderedData:t,options:{renderAnnotation:n}}=this;if(n!=null&&t!=null){let{fileDiff:r,lineAnnotations:i}=t;for(let[t,a]of i.entries()){let i=this.getAnnotationSlotName(a),o=`${t}-${i}`,s=this.annotationCache.get(o);if(s==null||s.fileDiff!==r||!$d(a,s.annotation)){s?.element.remove();let e=n(a,r);if(e==null)continue;s={element:Xo(i),annotation:a,fileDiff:r},s.element.appendChild(e),this.fileContainer.appendChild(s.element),this.annotationCache.set(o,s)}e.delete(o)}}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=no();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.headerCache.lastRenderedHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:ya(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):ya(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=qo;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute(`data-unified`)?this.codeUnified=t:t.hasAttribute(`data-deletions`)?this.codeDeletions=t:t.hasAttribute(`data-additions`)&&(this.codeAdditions=t))}applyHeaderToDOM(e,t,n){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{headerCache:{fileDiff:r,html:i,lastRenderedHTML:a}}=this,o=(n!==this.editSession?.diff&&Vi(r,n)?i:void 0)??Ls(e);if(this.headerCache.html=o,this.headerCache.fileDiff=n,o!==a){let e=document.createElement(`div`);e.innerHTML=o;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.headerCache.lastRenderedHTML=o}if(this.isComponentManaged)return;let{renderCustomHeader:s,renderHeaderPrefix:c,renderHeaderFilenameSuffix:l,renderHeaderMetadata:u}=this.options;if(s!=null){let e=s(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,co,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}let d=c?.(n)??void 0,f=l?.(n)??void 0,p=u?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,hs,d),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,va,f),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,Ro,p),this.headerCustom?.remove(),this.headerCustom=void 0}clearReusableHeader(){this.headerCache.html=void 0,this.headerCache.fileDiff=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}injectUnsafeCSS(){let{unsafeCSS:e}=this.options;this.pre?.toggleAttribute(`data-custom-styles`,!!e);let t=this.fileContainer?.shadowRoot;t!=null&&(e==null||e===``?(this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0):(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=Aa(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=mo(e),this.appliedUnsafeCSS=e))}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.getTheme(),s=typeof o==`string`?o:{...o},c=Ma(i);this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c?this.appliedThemeCSS.theme=s:this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i?(this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}):(this.themeCSSStyle=$o({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:Cs(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c})}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e!=null&&this.themeCSSStyle!=null&&(this.themeCSSStyle.textContent=Da(this.themeCSSStyle.textContent??``,Ma(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&so()}applyHunksToDOM(e,t){this.shouldGuardRebuildScroll()?Ho(e,()=>this.replaceCodeColumns(e,t)):this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){let r=this.getColumnPair(e);if(r==null)return!1;let i=gf(t[0]),a=gf(t[1]);return i==null||a==null?!1:(r.gutter.innerHTML=Ls(i),r.content.innerHTML=Ls(a),n!==this.lastRowCount&&(r.gutter.style.setProperty(`grid-row`,`span ${n}`),r.content.style.setProperty(`grid-row`,`span ${n}`)),!0)}replaceCodeColumns(e,t){let{overflow:n=`scroll`}=this.options,r=(this.options.hunkSeparators??`line-info`)===`line-info`,i=n===`wrap`?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let a=!1,o=[],s=this.hunksRenderer.renderCodeAST(`unified`,t),c=this.hunksRenderer.renderCodeAST(`deletions`,t),l=this.hunksRenderer.renderCodeAST(`additions`,t);this.editor?.__captureFocusForDOMReplacement(),s==null?c!=null||l!=null?(c==null?(this.codeDeletions?.remove(),this.codeDeletions=void 0):(a=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=Vo({code:this.codeDeletions,columnType:`deletions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeDeletions,c,t.rowCount)||(this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(c)),o.push(this.codeDeletions)),l==null?(this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=a||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=Vo({code:this.codeAdditions,columnType:`additions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeAdditions,l,t.rowCount)||(this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(l)),o.push(this.codeAdditions))):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=Vo({code:this.codeUnified,columnType:`unified`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeUnified,s,t.rowCount)||(this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(s)),o.push(this.codeUnified)),o.length===0?e.textContent=``:a&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({fileDiff:e,previousRenderRange:t,renderRange:n}){let{pre:r,codeUnified:i,codeAdditions:a,codeDeletions:o,options:{diffStyle:s=`split`}}=this;if(r==null||t==null||n==null||!Number.isFinite(t.totalLines)||!Number.isFinite(n.totalLines)||this.lastRowCount==null)return!1;let c=this.getCodeColumns(s,i,o,a);if(c==null)return!1;let l=t.startingLine,u=n.startingLine,d=l+t.totalLines,f=u+n.totalLines,p=Math.max(l,u),m=Math.min(d,f);if(m<=p)return!1;let h=Math.max(0,p-l),g=Math.max(0,d-m),_=this.trimColumns({columns:c,trimStart:h,trimEnd:g,previousStart:l,overlapStart:p,overlapEnd:m,diffStyle:s});if(_<0)throw Error(`FileDiff.applyPartialRender: failed to trim to overlap`);if(this.lastRowCount<_)throw Error(`FileDiff.applyPartialRender: trimmed beyond DOM row count`);let v=this.lastRowCount-_,y=(t,n)=>{if(!(n<=0))return this.hunksRenderer.renderDiff(e,{startingLine:t,totalLines:n,bufferBefore:0,bufferAfter:0})},b=y(u,Math.max(p-u,0));if(b==null&&u<p)return!1;let x=y(m,Math.max(f-m,0));if(x==null&&f>m)return!1;let S=(e,t)=>{if(e!=null){if(s===`unified`&&!Array.isArray(c))this.insertPartialHTML(s,c,e,t);else if(s===`split`&&Array.isArray(c))this.insertPartialHTML(s,c,e,t);else throw Error(`FileDiff.applyPartialRender.applyChunk: invalid chunk application`);v+=e.rowCount,this.adoptRenderData(e.fileDiff)}};return this.cleanupErrorWrapper(),S(b,`afterbegin`),S(x,`beforeend`),this.lastRowCount!==v&&(this.applyRowSpan(s,c,v),this.lastRowCount=v),!0}insertPartialHTML(e,t,n,r){if(e===`unified`&&!Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`unified`,n);this.renderPartialColumn(t,e,r)}else if(e===`split`&&Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`deletions`,n),i=this.hunksRenderer.renderCodeAST(`additions`,n);this.renderPartialColumn(t[0],e,r),this.renderPartialColumn(t[1],i,r)}else throw Error(`FileDiff.insertPartialHTML: Invalid argument composition`)}refreshSplitDiffView(){let e=this.getWorkingDiff();if(this.options.diffStyle!==`split`||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns(`split`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(n))return;let r=(e,n)=>{if(n==null)return;let r=this.hunksRenderer.renderCodeAST(e,t),i=gf(r?.[0]),a=gf(r?.[1]);for(let[e,t]of[[n.gutter,i],[n.content,a]])if(t!=null&&e.childElementCount===t.length)for(let n=0;n<t.length;n++){let r=e.children[n],i=t[n].properties[`data-line-type`];i!=null&&r.dataset.lineType!==i&&(r.dataset.lineType=i)}};r(`deletions`,n[0]),r(`additions`,n[1]),this.adoptRenderData(t.fileDiff)}refreshUnifiedDiffView(){let e=this.getWorkingDiff();if(this.options.diffStyle!==`unified`||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns(`unified`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(n==null||Array.isArray(n))return;let r=this.hunksRenderer.renderCodeAST(`unified`,t),i=gf(r?.[0]),a=gf(r?.[1]),o=()=>{for(let[e,t]of[[n.gutter,i],[n.content,a]])t!=null&&(e.innerHTML=Ls(t));t.rowCount!==this.lastRowCount&&(this.applyRowSpan(`unified`,n,t.rowCount),this.lastRowCount=t.rowCount),this.adoptRenderData(t.fileDiff)};this.shouldGuardRebuildScroll()?Ho(this.pre,o):o(),this.renderSeparators(t.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=gf(t[0]),i=gf(t[1]);if(r==null||i==null)throw Error(`FileDiff.insertPartialHTML: Unexpected AST structure`);let a=i.at(0);n===`beforeend`&&a?.type===`element`&&typeof a.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(a.properties[`data-buffer-size`],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let o=i.at(-1);n===`afterbegin`&&o?.type===`element`&&typeof o.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(o.properties[`data-buffer-size`],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,a){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let o=this.getBufferSize(t.dataset);o!=null&&(a?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(n,o+e))}applyRowSpan(e,t,n){let r=e=>{e!=null&&(e.gutter.style.setProperty(`grid-row`,`span ${n}`),e.content.style.setProperty(`grid-row`,`span ${n}`))};if(e===`unified`&&!Array.isArray(t))r(t);else if(e===`split`&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error(`dun fuuuuked up`)}trimColumnRows(e,t,n){let r=0,i=0,a=0,o=!1,s=n>=0;if(e==null)return 0;let c=Array.from(e.content.children),l=Array.from(e.gutter.children);if(c.length!==l.length)throw Error(`FileDiff.trimColumnRows: columns do not match`);for(;a<c.length&&!(t<=0&&!s&&!o);){let e=l[a],u=c[a];if(a++,!(e instanceof HTMLElement)||!(u instanceof HTMLElement))throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: invalid row elements`);if(o&&(o=!1,e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset||e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset))e.remove(),u.remove(),i++;else if(`lineIndex`in e.dataset&&`lineIndex`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),t>0&&(t--,t===0&&(o=!0)),i++),r++;else if(`separator`in e.dataset&&`separator`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);else if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);else if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);else if(e.dataset.gutterBuffer===`buffer`&&`contentBuffer`in u.dataset){let a=this.getBufferSize(u.dataset);if(a==null)throw Error(`FileDiff.trimColumnRows: invalid element`);if(t>0){let n=Math.min(t,a),r=a-n;r>0?(this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=n):(e.remove(),u.remove(),i+=a),t-=n,t===0&&r===0&&(o=!0)}else if(s){let t=r,o=r+a-1;if(n<=t)e.remove(),u.remove(),i+=a;else if(n<=o){let t=o-n+1,r=a-t;this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=t}}r+=a}else throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: unknown row elements`)}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:a,trimStart:o}){let s=Math.max(0,r-i),c=n-i;if(c<0)throw Error(`FileDiff.trimColumns: overlap ends before previous`);let l=o>0,u=a>0;if(!l&&!u)return 0;let d=l?s:0,f=u?c:-1;if(t===`unified`&&!Array.isArray(e))return this.trimColumnRows(e,d,f);if(t===`split`&&Array.isArray(e)){let t=this.trimColumnRows(e[0],d,f),n=this.trimColumnRows(e[1],d,f);if(e[0]!=null&&e[1]!=null&&t!==n)throw Error(`FileDiff.trimColumns: split columns out of sync`);return e[0]==null?n:t}throw console.error({diffStyle:t,columns:e}),Error(`FileDiff.trimColumns: Invalid columns for diffType`)}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??``,10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty(`grid-row`,`span ${t}`),e.style.setProperty(`min-height`,`calc(${t} * 1lh)`)}getColumnPair(e){if(e==null)return;let t=e.children[0],n=e.children[1];if(t instanceof HTMLElement&&n instanceof HTMLElement&&t.dataset.gutter!=null&&n.dataset.content!=null)return{gutter:t,content:n}}getCodeColumns(e,t,n,r){if(e===`unified`)return this.getColumnPair(t);{let e=this.getColumnPair(n),t=this.getColumnPair(r);return e!=null||t!=null?[e,t]:void 0}}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}applyBuffers(e,t){t==null||this.shouldDisableVirtualizationBuffers()?(this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)):(t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0))}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){let{diffIndicators:a=`bars`,disableBackground:o=!1,disableLineNumbers:s=!1,overflow:c=`scroll`,diffStyle:l=`split`}=this.options,u={type:`diff`,diffIndicators:a,disableBackground:o,disableLineNumbers:s,overflow:c,split:l!==`unified`&&t!=null&&n!=null,totalLines:r,customProperties:i};Sa(u,this.appliedPreAttributes)||(Bo(e,u),this.appliedPreAttributes=u)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function uf(e){return{name:e.name,lang:e.lang,contents:e.additionLines.join(``)}}function df(e,t){return e==null||t==null?e==null&&t==null:$i(e,t)}function ff({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function pf({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function mf(e,t,n=!1){return!n&&e==null&&t}function hf(e,t,n=!1){return e==null&&t&&!n}function gf(e){if(e!=null&&e.type===`element`)return e.children??[]}var _f=3e3,vf=new Map,yf=-1,bf=class extends lf{__id=`little-virtualized-file-diff:${++yf}`;renderType=`virtualized`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0,ghostTextRows:vf,ghostTextRowsByIndex:new Map};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;currentCollapsed;pendingHydratedDiff;pendingExpansions;pendingRender;constructor(e,t,n,r,i){super(e,r,i),this.virtualizer=t,this.metrics=ns(n)}setMetrics(e,t=!1){let n=ns(e);(t||!Uo(this.metrics,n))&&(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&(this.forceRenderOverride=!0)}syncLineAnnotations(e){return e==null||!this.isNewAnnotations(e)||e.length===0&&this.getLatestAnnotations().length===0?!1:(super.setLineAnnotations(e),!0)}syncEditSessionAnnotationsFromEditor(e){return super.syncEditSessionAnnotationsFromEditor(e)?(this.forceRenderOverride=!0,!0):!1}setFileAnnotationHeight(e){let t=this.cache.fileAnnotationHeight;return e!==t&&(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0)}hasFileAnnotations(e){let t=this.getLayoutAnnotations();return Ka(t)?t.some(t=>t.lineNumber===0?e.type===`new`?t.side===`additions`:e.type!==`deleted`||t.side===`deletions`:!1):!1}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){let t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!us(t,e),r=n&&Of(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:kf(t,e)}),n&&(this.forceRenderOverride=!0),n&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1,resetRenderRange:n=!0}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal=0,this.cache.ghostTextRows=vf,this.cache.ghostTextRowsByIndex.size>0&&this.cache.ghostTextRowsByIndex.clear(),this.invalidateDerivedLayoutCache(t,n),e&&this.isSimpleMode()&&this.computeApproximateSize()}invalidateDerivedLayoutCache(e,t=!0){this.layoutDirty=!0,this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),e&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&t&&(this.renderRange=void 0)}applyGhostTextRows(e,t){let{cache:{heightDeltas:n,ghostTextRows:r,ghostTextRowsByIndex:i},metrics:{lineHeight:a}}=this;if(r===t)return!1;let o=this.getDiffStyle(),s=new Map;for(let[n,r]of t){let t=this.getLineIndexForDiff(e,n+1,`additions`);t!=null&&s.set(o===`split`?t[1]:t[0],r)}let c=!1;for(let e of new Set([...i.keys(),...s.keys()])){let t=((s.get(e)??0)-(i.get(e)??0))*a;if(t===0)continue;let r=(n.get(e)??0)+t;r===0?n.delete(e):n.set(e,r),this.cache.measuredHeightDeltaTotal+=t,c=!0}return this.cache.ghostTextRows=t,this.cache.ghostTextRowsByIndex=s,c}reconcileHeights(){let e=!1,{options:{overflow:t=`scroll`},metrics:{lineHeight:n}}=this,r=this.placeHolder==null?this.getRenderedDiff():this.getLayoutDiff();if(this.fileContainer==null||r==null)return this.height!==0&&(e=!0),this.height=0,e;this.top=this.getVirtualizedTop(),e=this.applyGhostTextRows(r,this.editor?.__getGhostTextRows()??vf);let{ghostTextRowsByIndex:i}=this.cache,a=t!==`scroll`||this.lineAnnotations.length>0||this.isResizeDebuggingEnabled();if(this.placeHolder!=null||!a&&this.cache.heightDeltas.size===0&&this.cache.fileAnnotationHeight===0)return e&&(this.computeApproximateSize(!0),this.setPlaceholderHeight(this.height)),e;let o=this.getDiffStyle(),s=o===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified];if(this.renderRange!=null&&cs(this.renderRange)){let t=xf(s)??0;this.setFileAnnotationHeight(t)&&(e=!0)}for(let t of s){if(t==null)continue;let r=t.children[1];if(!(r instanceof HTMLElement))continue;let s=o===`split`&&t===this.codeDeletions;for(let t of r.children){if(!(t instanceof HTMLElement))continue;let r=t.dataset.lineIndex;if(r==null)continue;let c=Nf(r,o),l=i.get(c)??0;if(s&&l>0)continue;let u=this.cache.heightDeltas.get(c)??0;if(!a&&u===l*n)continue;let d=t.getBoundingClientRect().height+l*n,f=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(f=!0),d+=t.nextElementSibling.getBoundingClientRect().height);let p=this.getEstimatedLineHeight(f),m=d-p;m!==u&&(e=!0,this.cache.measuredHeightDeltaTotal+=m-u,m===0?this.cache.heightDeltas.delete(c):this.cache.heightDeltas.set(c,m))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer!=null&&(e&&(this.top=this.getVirtualizedTop()),this.render());flushManagers(){super.flushManagers(),this.lineStateRefreshPending&&this.flushDeferredLineState()}updateCodeViewLayout(e,t,n,r){let i=!1,a=!1,{pendingExpansions:o,pendingHydratedDiff:s,options:{collapsed:c=!1}}=this;if(s!=null&&(this.pendingHydratedDiff=void 0,s.expectedDiff===e&&(Object.assign(e,s.nextDiff),this.setHydratedState(s.files),this.installHydratedSessionDiff(e),this.forceRenderOverride=!0,i=!0,a=!0)),o!=null){this.pendingExpansions=void 0;for(let{hunkIndex:e,direction:t,expansionLineCountOverride:n}of o)this.hunksRenderer.expandHunk(e,t,n),this.forceRenderOverride=!0,a=!0}let l=this.updateInputDiff(e,r),{pendingRenderDiff:u,layoutDiffChanged:d,renderedDiffChanged:f,annotationsChanged:p}=this.updatePendingRender(e,r);return!this.forceRenderOverride&&(l||f||p)&&(this.forceRenderOverride=!0),(n?.resetDiffLayoutCache===!0||d)&&(i=!0),(d||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights)&&(a=!0),n?.metrics!=null&&(this.metrics=ns(n.metrics),i=!0,a=!0),this.currentCollapsed!==c&&(this.currentCollapsed=c,i=!0),i?this.resetLayoutCache({includeEstimatedHeights:a}):a&&this.invalidateDerivedLayoutCache(!0),this.top=t,this.computeApproximateSize(!1,u),this.height}getLinePosition(e,t=`additions`){let n=this.getLayoutDiff();if(n==null||e<1)return;let r=this.getLineIndexForDiff(n,e,t);if(r==null)return;let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsed:o=!1,collapsedContextThreshold:s=1}=this.options,c=this.getDiffStyle(),l=this.getHunkSeparatorType(),u=c===`split`?r[1]:r[0];this.approximateLayoutCheckpoints(n);let d=Zo(this.metrics,i),f=this.getLayoutCheckpointBeforeLineIndex(u),p=f?.top??d+this.cache.fileAnnotationHeight;if(o)return{top:Po(this.metrics,i),height:0};let m;return qr({diff:n,diffStyle:c,startingLine:f?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:s,callback:({hunkIndex:e,hunk:t,collapsedBefore:n,collapsedAfter:r,deletionLine:i,additionLine:a})=>{let o=c===`split`?a?.splitLineIndex??i?.splitLineIndex:a?.unifiedLineIndex??i?.unifiedLineIndex;if(o==null)throw Error(`VirtualizedFileDiff.getLinePosition: missing line index data`);if(n>0){let r=yr({type:l,metrics:this.metrics,hunkIndex:e,hunkSpecs:t?.hunkSpecs});if(r!=null){if(p+=r.gapBefore,u>=o-n&&u<o)return m={top:p,height:r.height},!0;p+=r.height+r.gapAfter}}let s=this.getLineHeight(o,(a?.noEOFCR??!1)||(i?.noEOFCR??!1));if(o===u)return m={top:p,height:s},!0;if(p+=s,r>0){let e=$r({type:l,metrics:this.metrics});if(e!=null){if(u>o&&u<=o+r)return m={top:p+e.gapBefore,height:e.height},!0;p+=e.totalHeight}}return!1}}),m}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){let t=this.getLayoutDiff();if(t==null)return;let{disableFileHeader:n=!1,expandUnchanged:r=!1,collapsed:i=!1,collapsedContextThreshold:a=1}=this.options;if(i)return;let o=this.getDiffStyle(),s=this.getHunkSeparatorType();this.approximateLayoutCheckpoints(t);let c=this.getLayoutCheckpointBeforeTop(e),l=c?.top??Zo(this.metrics,n)+this.cache.fileAnnotationHeight,u;return qr({diff:t,diffStyle:o,startingLine:c?.renderedLineIndex??0,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:a,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,deletionLine:a,additionLine:c})=>{let d=o===`split`?c?.splitLineIndex??a?.splitLineIndex:c?.unifiedLineIndex??a?.unifiedLineIndex;if(d==null)throw Error(`VirtualizedFileDiff.getNumericScrollAnchor: missing line index data`);if(r>0){let e=yr({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n?.hunkSpecs});e!=null&&(l+=e.totalHeight)}if(l>=e&&(a==null?c!=null&&(u={lineNumber:c.lineNumber,side:`additions`,top:l}):u={lineNumber:a.lineNumber,side:`deletions`,top:l},u!=null))return!0;let f=this.getLineHeight(d,(c?.noEOFCR??!1)||(a?.noEOFCR??!1));if(l+=f,i>0){let e=$r({type:s,metrics:this.metrics});e!=null&&(l+=e.totalHeight)}return!1}}),u}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){let t=this.getLayoutDiff();if(this.top==null||t==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let n=e==null?this.renderRange:this.computeRenderRangeFromWindow(t,this.top,e);if(n==null)return;let{bufferBefore:r,bufferAfter:i,totalLines:a}=n,o=0;if(a===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(o=i)}return{topOffset:this.top+r+o,height:this.height-(r+i)}}cleanUp(e=!1){let t=this.cache.ghostTextRows.size>0;t&&(this.layoutDirty=!0);let n=e&&this.isAdvancedMode()&&this.fileContainer!=null&&(t||!Vi(this.getRenderedDiff(),this.getWorkingDiff()));this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||(this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0),this.pendingRender=void 0,this.isSetup=!1,super.cleanUp(e),n&&this.virtualizer.instanceChanged(this,!0)}expandHunk=(e,t,n)=>{this.getInputDiff()!=null&&(this.loadFilesIfNecessary(),this.isAdvancedMode()?(this.pendingExpansions??=[],this.pendingExpansions.push({hunkIndex:e,direction:t,expansionLineCountOverride:n})):(this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))};async handleFilesLoaded(e,t){if(this.getInputDiff()===e&&e.isPartial){if(this.isAdvancedMode()){let n=wu(`clone`,e,t,this.options.parseDiffOptions);if(await vu(()=>this.primeHighlightCache(n)),this.getInputDiff()!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(wu(`merge`,e,t,this.options.parseDiffOptions),this.setHydratedState(t),!this.installHydratedSessionDiff(e)&&(await vu(()=>this.primeHighlightCache(e)),this.getInputDiff()!==e))return;this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}}loadFilesIfNecessary(){if(this.pendingHydratedDiff!=null){if(this.pendingHydratedDiff.expectedDiff===this.getInputDiff())return;this.pendingHydratedDiff=void 0}super.loadFilesIfNecessary()}isLineRenderable(e){if(super.isLineRenderable(e))return!0;let{pendingExpansions:t}=this,n=this.getRenderedDiff();if(t==null||t.length===0||n==null)return!1;let{expansionLineCount:r=100,collapsedContextThreshold:i=1}=this.options,a=new Map(this.hunksRenderer.getExpandedHunksMap());for(let e of t){let t={...a.get(e.hunkIndex)??{fromStart:0,fromEnd:0}},n=e.expansionLineCountOverride??r;(e.direction===`up`||e.direction===`both`)&&(t.fromStart+=n),(e.direction===`down`||e.direction===`both`)&&(t.fromEnd+=n),a.set(e.hunkIndex,t)}return Fr({fileDiff:n,lineNumber:e,expandedHunks:a,collapsedContextThreshold:i})}invalidateEditSessionLayout(){this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),this.isSimpleMode()||this.computeApproximateSize(!0),this.getSimpleVirtualizer()?.requestHeightReconcile(this)}escalateEditSessionRender(){this.invalidateEditSessionLayout(),this.enabled&&this.getInputDiff()!=null&&(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))}shouldSelfHealEditSession(){return!this.isAdvancedMode()&&super.shouldSelfHealEditSession()}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){if(!this.enabled||this.getInputDiff()==null&&this.additionFile==null&&this.deletionFile==null)return;let e=this.getWorkingDiff(),t=e==null?void 0:this.hunksRenderer.getDiffForNextRender(e);this.isSimpleMode()&&(this.pendingRender=void 0),this.forceRenderOverride=!0,this.isSimpleMode()&&this.requestRender()||this.virtualizer.instanceChanged(this,!Vi(this.getRenderedDiff(),t))}get isComponentManaged(){return this.getAdvancedVirtualizer()?.isComponentManaged??super.isComponentManaged}syncGhostTextRows(){let e=this.getAdvancedVirtualizer();e==null?this.getSimpleVirtualizer()?.requestHeightReconcile(this):(e.capturePendingLayoutAnchor(),this.layoutDirty=!0,e.instanceChanged(this,!0))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1});let i=this.getRenderedDiff();if(!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!=null&&i!=null){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(i,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.getLayoutDiff()){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,t==null){this.layoutDirty=!1;return}this.applyGhostTextRows(t,this.editor?.__getGhostTextRows()??vf);let{disableFileHeader:i=!1,collapsed:a=!1}=this.options;a?(this.height+=Po(this.metrics,i),this.layoutDirty=!1):(this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!r&&this.validateComputedHeight(t),this.layoutDirty=!1)}getLayoutDiff(){return this.pendingRender?.diff??this.getRenderedDiff()}getLayoutAnnotations(){let{pendingRender:e}=this;return e==null?this.lineAnnotations:this.getAnnotationsForDiff(e.diff)}getActiveEstimatedHeight(e=this.getLayoutDiff()){this.ensureEstimatedDiffHeights(e);let t=this.getDiffStyle()===`split`?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(t==null)throw Error(`VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height`);return t}ensureEstimatedDiffHeights(e=this.getLayoutDiff()){if(e==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,{splitHeight:i,unifiedHeight:a}=yu({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:Af(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=i,this.cache.estimatedUnifiedHeight=a}validateComputedHeight(e=this.getLayoutDiff()){if(this.fileContainer==null||e==null)return;let t=this.fileContainer.getBoundingClientRect();t.height===this.height?console.log(`VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFileDiff.computeApproximateSize: computed height doesnt match`,{name:e.name,elementHeight:t.height,computedHeight:this.height})}render({fileContainer:e,fileDiff:t,forceRender:n=!1,lineAnnotations:r,...i}={}){let a=Su(i,`VirtualizedFileDiff.render`),o=a!=null,s=a?.oldFile,c=a?.newFile,l=o&&(!Mf(s,this.deletionFile)||!Mf(c,this.additionFile)),u=t??this.getInputDiff();t==null&&o&&(l||this.getInputDiff()==null)&&(u=Pu(a.oldFile,a.newFile,this.options.parseDiffOptions));let{forceRenderOverride:d,isSetup:f}=this;this.forceRenderOverride=void 0;let p=u!=null&&!Vi(this.getInputDiff(),u),m=p||l;if(e=this.getOrCreateFileContainer(e),u==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;p&&this.updateInputDiff(u,r);let{pendingRenderDiff:h,layoutDiffChanged:g,renderedDiffChanged:_,annotationsChanged:v}=this.pendingRender!=null&&this.pendingRender.workingDiff===(this.getWorkingDiff(u)??u)?{pendingRenderDiff:this.pendingRender.diff,layoutDiffChanged:!1,renderedDiffChanged:!1,annotationsChanged:this.syncLineAnnotations(r)}:this.updatePendingRender(u,r);if(g&&this.resetLayoutCache({includeEstimatedHeights:!0}),f)this.top??=this.getVirtualizedTop(),this.layoutDirty&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,h));else{this.computeApproximateSize(!1,h);let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFileDiff.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!m||!f))return a!=null&&(this.deletionFile=s,this.additionFile=c),p&&this.clearReusableHeader(),this.renderPlaceholder(this.height);let y=this.virtualizer.getWindowSpecs(),b=this.top??0,x=this.computeRenderRangeFromWindow(h,b,y);return super.render({fileDiff:u,fileContainer:e,renderRange:x,lineAnnotations:r,forceRender:(d??n)||v||_||p,...a,...i})}finalizeRender(){if(!Vi(this.getRenderedDiff(),this.pendingRender?.diff))throw Error(`VirtualizedFileDiff.render: rendered a different diff than its prepared layout`);this.pendingRender=void 0,this.isSimpleMode()&&this.getSimpleVirtualizer()?.requestHeightReconcile(this)}updatePendingRender(e,t){let n=this.getWorkingDiff(e)??e,r=this.getRenderedDiff(),{pendingRender:i}=this,a=i?.diff??r,o=this.hunksRenderer.getDiffForNextRender(n);return this.pendingRender={workingDiff:n,diff:o},{pendingRenderDiff:o,annotationsChanged:this.syncLineAnnotations(t),layoutDiffChanged:!Vi(a,o),renderedDiffChanged:!Vi(r,o)}}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type===`advanced`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??`split`}getHunkSeparatorType(){return jf(this.options.hunkSeparators)}approximateLayoutCheckpoints(e){if(!this.layoutDirty&&this.cache.checkpoints.length>0||e.hunks.length===0||this.options.collapsed===!0)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,i=e.hunks.length-1,a=Af(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),s=this.getHunkSeparatorType(),c=n?!0:this.hunksRenderer.getExpandedHunksMap(),l=Sf(this.cache.heightDeltas),u=Zo(this.metrics,t)+this.cache.fileAnnotationHeight,d=0,f=({rowCount:e,startLineIndex:t,preSeparatorHeight:n=0,postSeparatorHeight:r=0,metadataOffsets:i=[]})=>{if(e<=0)return;let a=d,o=d+e,s=Tf(a);for(;s<o;){let e=s-a,r=u+(e>0?n:0)+e*this.metrics.lineHeight+Ef(i,e)*this.metrics.lineHeight+Cf(l,t,t+e);this.cache.checkpoints.push({renderedLineIndex:s,lineIndex:t+e,top:r}),s+=_f}u+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+Cf(l,t,t+e)+r,d=o};for(let t=0;t<e.hunks.length;t++){let n=e.hunks[t];if(n==null)throw Error(`VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index`);let l=Zr({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:c,hunkIndex:t,collapsedContextThreshold:r}),u=l.collapsedLines>0?yr({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n.hunkSpecs})?.totalHeight??0:0;f({rowCount:l.fromStart,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.rangeSize});let d=u;f({rowCount:l.fromEnd,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.fromEnd,preSeparatorHeight:d}),l.fromEnd>0&&(d=0);let p=t===i?ti({fileDiff:e,hunkIndex:t,expandedHunks:c,collapsedContextThreshold:r,errorPrefix:`VirtualizedFileDiff`}):void 0,m=p!=null&&p.collapsedLines>0||t===i&&a?$r({type:s,metrics:this.metrics})?.totalHeight??0:0,h=p==null?0:p.fromStart+p.fromEnd,g=o===`split`?n.splitLineCount:n.unifiedLineCount,_=o===`split`?n.splitLineStart:n.unifiedLineStart;f({rowCount:g,startLineIndex:_,preSeparatorHeight:d,postSeparatorHeight:h===0?m:0,metadataOffsets:Df({diffStyle:o,hunk:n,rowCount:g})}),p!=null&&h>0&&f({rowCount:h,startLineIndex:_+g,postSeparatorHeight:m})}this.cache.totalLines=d}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);if(n.renderedLineIndex%t===0)return n}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let r of e.hunks)n+=t===`split`?r.splitLineCount:r.unifiedLineCount;return n}let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a=r?!0:this.hunksRenderer.getExpandedHunksMap();for(let[r,o]of e.hunks.entries()){let s=t===`split`?o.splitLineCount:o.unifiedLineCount;n+=s;let c=Math.max(o.collapsedBefore,0),{fromStart:l,fromEnd:u,renderAll:d}=Zr({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=ti({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:a,collapsedContextThreshold:i,errorPrefix:`VirtualizedFileDiff`});return o!=null&&(n+=o.fromStart+o.fromEnd),n}getLayoutLineCount(e,t){let n=this.getExpandedLineCount(e,t),r=t===`split`?e.splitLineCount:e.unifiedLineCount;return Math.max(n,r,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:s,lineHeight:c}=this.metrics,l=this.getDiffStyle(),u=this.getHunkSeparatorType(),d=Af(e,this.options.loadDiffFiles!=null),f=this.height,p=this.getLayoutLineCount(e,l),m=Zo(this.metrics,i),h=e.hunks.length>0?_s(this.metrics):0,{fileAnnotationHeight:g}=this.cache,_=m+g,v=Math.max(0,f-m-g-h),y=this.hasFileAnnotations(e),b=t+m,x=g>0&&y&&b<r&&b+g>n;if(t<n-f||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h};if(p<=s||e.hunks.length===0)return{startingLine:0,totalLines:s,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),p=this.getLayoutLineCount(e,l);let S=Math.ceil(Math.max(r-n,0)/c),C=Math.ceil(S/s)*s+s,w=C/s,T=w,E=[],D=(n+r)/2,O=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-C*c*2),s),k=t+(O?.top??_),A=O?.renderedLineIndex??0,j,M,N;if(qr({diff:e,diffStyle:l,startingLine:O?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:i,hunk:a,collapsedBefore:o,collapsedAfter:c,deletionLine:f,additionLine:p})=>{let m=p==null?f.splitLineIndex:p.splitLineIndex,h=p==null?f.unifiedLineIndex:p.unifiedLineIndex,g=(p?.noEOFCR??!1)||(f?.noEOFCR??!1),v=i===e.hunks.length-1&&a!=null&&(l===`split`?m===a.splitLineStart+a.splitLineCount-1:h===a.unifiedLineStart+a.unifiedLineCount-1),y=(o>0?yr({type:u,metrics:this.metrics,hunkIndex:i,hunkSpecs:a?.hunkSpecs}):void 0)?.totalHeight??0;k+=y;let b=A%s===0,x=Math.floor(A/s);if(b&&(E[x]=k-(t+_+y),N!=null)){if(N<=0)return!0;N--}let S=this.getLineHeight(l===`split`?m:h,g);if(k>n-S&&k<r&&(j??=x),M==null&&k+S>D&&(M=x),N==null&&k>=r&&b&&(N=T),A++,k+=S,c>0||v&&d){let e=$r({type:u,metrics:this.metrics});e!=null&&(k<r&&k+e.totalHeight>n&&(j??=x),M==null&&k+e.totalHeight>D&&(M=x),k+=e.totalHeight)}return!1}}),j==null){if(x)j=0,M=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h}}M??=j;let P=Math.round(M-w/2),F=Math.max(0,Math.ceil(p/s)-w),I=Math.max(0,Math.min(P,F)),L=I*s,R=P<0?C+P*s:C,z=E[I]??0,B=L===0?0:g+z,V=I+R/s,H=V<E.length?v-E[V]:v-(k-t-_);return{startingLine:L,totalLines:R,bufferBefore:B,bufferAfter:Math.max(0,H)}}};function xf(e){let t;for(let n of e){if(n==null)continue;let e=n.children[1];if(e instanceof HTMLElement)for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===`-1,-1`&&(t=Math.max(t??0,n.getBoundingClientRect().height))}return t}function Sf(e){let t=Array.from(e).sort((e,t)=>e[0]-t[0]),n=[],r=[0],i=0;for(let[e,a]of t)n.push(e),i+=a,r.push(i);return{lineIndexes:n,prefixTotals:r}}function Cf({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=wf(e,n);return(t[wf(e,r)]??0)-(t[i]??0)}function wf(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid prefix index`);a<t?n=i+1:r=i}return n}function Tf(e){return Math.ceil(e/_f)*_f}function Ef(e,t){let n=0;for(let r of e)r<t&&n++;return n}function Df({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];let r=t.hunkContent.at(-1);if(r==null)return[];if(r.type===`context`)return[n-1];let i=Math.max(r.deletions,r.additions),a=r.deletions+r.additions;if(e===`split`)return i>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];let o=[],s=n-a;return r.deletions>0&&t.noEOFCRDeletions&&o.push(s+r.deletions-1),r.additions>0&&t.noEOFCRAdditions&&o.push(n-1),o}function Of(e,t){return(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function kf(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function Af(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function jf(e){return typeof e==`function`?`custom`:e??`line-info`}function Mf(e,t){return e==null||t==null?e==null&&t==null:$i(e,t)}function Nf(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}var Pf=`theme.disableLineNumbers.overflow.themeType.disableFileHeader.disableVirtualizationBuffers.preferredHighlighter.useCSSClasses.useTokenTransformer.tokenizeMaxLineLength.tokenizeMaxLength.unsafeCSS.diffStyle.diffIndicators.disableBackground.expandUnchanged.loadDiffFiles.parseDiffOptions.collapsedContextThreshold.lineDiffType.maxLineDiffLength.expansionLineCount.lineHoverHighlight.enableTokenInteractionsOnWhitespace.enableGutterUtility.__debugPointerEvents.enableLineSelection.controlledSelection.disableErrorHandling`.split(`.`),Ff=[`theme`,`disableLineNumbers`,`overflow`,`themeType`,`disableFileHeader`,`disableVirtualizationBuffers`,`preferredHighlighter`,`useCSSClasses`,`useTokenTransformer`,`tokenizeMaxLineLength`,`tokenizeMaxLength`,`unsafeCSS`,`lineHoverHighlight`,`enableTokenInteractionsOnWhitespace`,`enableGutterUtility`,`__debugPointerEvents`,`enableLineSelection`,`controlledSelection`,`disableErrorHandling`],If=[`renderCustomHeader`,`renderHeaderPrefix`,`renderHeaderFilenameSuffix`,`renderHeaderMetadata`,`renderAnnotation`,`renderGutterUtility`,`onPostRender`,`onGutterUtilityClick`,`onLineClick`,`onLineNumberClick`,`onLineEnter`,`onLineLeave`,`onTokenClick`,`onTokenEnter`,`onTokenLeave`],Lf=[`onLineSelected`,`onLineSelectionStart`,`onLineSelectionChange`,`onLineSelectionEnd`],Rf=Symbol(`CodeView.itemOptionsState`);function zf(e,t){Object.defineProperty(e,Rf,{configurable:!1,enumerable:!1,value:t})}function Bf(e){return e[Rf]}function Vf(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get(){return n(this)}})}var Hf=120,Uf=1,Wf=`--diffs-overflow-override`;function Gf(e,t,n){return{containerHeight:e,triggerTop:t,targetTop:n,targetBottom:e-n,threshold:e-t}}var Kf=Gf(12e6,1e6,2e6),qf=Gf(2**22,5e5,1e6);function Jf(e){if(e==null)throw Error(`CodeView: createEditor is required for items with edit: true`)}var Yf=(()=>{let{navigator:e}=globalThis,t=e.userAgent,n=/iP(?:hone|ad|od)/.test(t),r=e.platform===`MacIntel`&&e.maxTouchPoints>1;return(n||r)&&/AppleWebKit/.test(t)&&/Safari/.test(t)&&!/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(t)})(),Xf=class e{static __STOP=!1;static __lastScrollPosition=0;type=`advanced`;config={overscrollSize:200,intersectionObserverMargin:0,resizeDebugging:!1};items=[];idToItem=new Map;selectedLines=null;itemEditors=new Map;attachedEditors=new Set;instanceToItem=new Map;layoutDirtyIndex;pendingLayoutReset;renderOptionsRevision=0;slotCoordinator;slotSnapshot;scrollListeners=new Set;scrollHeight=0;containerHeight=-1;scrollTop=0;scrollPageOffset=0;scrollRebaseConfig=Co()?qf:Kf;scrollDirty=!0;scrollInteractionFixTimer;pointerEventsDisabled=!1;codeOverflowFix=!1;height=0;heightDirty=!0;windowSpecs={top:0,bottom:0};renderState={scrollTop:-1,firstIndex:-1,lastIndex:-1,stickyHeight:0,stickyTop:-1,stickyBottom:-1};itemMetricsCache=Os;fileOptionsPrototype;diffOptionsPrototype;pendingScrollTarget;pendingLayoutAnchor;headerResizeAnchor;shouldFixContainerFocus=!1;scrollAnimation;root;resizeObserver;container=document.createElement(`div`);stickyContainer=document.createElement(`div`);stickyOffset=document.createElement(`div`);header={element:void 0,render:void 0,height:0};footer={element:void 0,render:void 0,height:0};elementPool=[];elementPoolVersion=0;elementPoolTracker=new WeakMap;pendingElementPool=[];options;workerManager;isReadySubscription;pendingHighlighterTheme;isComponentManaged;slotSnapshotStale=!1;constructor(e={theme:yo},t,n=!1){this.options=e,this.computeMetricsCache(e.itemMetrics),this.fileOptionsPrototype=this.createFileOptionsPrototype(),this.diffOptionsPrototype=this.createDiffOptionsPrototype(),this.workerManager=t,this.isComponentManaged=n,this.stickyOffset.style.contain=`layout size`,this.stickyContainer.style.position=`sticky`,this.stickyContainer.style.width=`100%`,this.stickyContainer.style.contain=`layout style inline-size`,this.stickyContainer.style.isolation=`isolate`,this.stickyContainer.style.display=`flex`,this.stickyContainer.style.flexDirection=`column`}getLayout(){return this.options.layout??Ca}getItemTopOffset(){return this.getLayout().paddingTop+this.header.height}computeMetricsCache(e){return this.itemMetricsCache={hunkLineCount:e?.hunkLineCount??Os.hunkLineCount,lineHeight:e?.lineHeight??Os.lineHeight,diffHeaderHeight:e?.diffHeaderHeight??Os.diffHeaderHeight,hunkSeparatorHeight:e?.hunkSeparatorHeight,spacing:e?.spacing??Os.spacing,paddingTop:e?.paddingTop,paddingBottom:e?.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??ho}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return os&&this.options.__devOnlyValidateItemHeights===!0}validateRenderedItemHeight(e){if(!this.shouldValidateItemHeights()||e.element==null)return;let t=e.instance.getAdvancedStickySpecs();if(t==null)return;let n=t.height,r=e.element.getBoundingClientRect().height;n!==r&&console.error(`CodeView: reconciled item height does not match DOM height`,{id:e.item.id,type:e.type,index:e.index,version:e.version,expectedHeight:n,actualHeight:r,delta:r-n,stickyTopOffset:t.topOffset,virtualizedHeight:e.instance.getVirtualizedHeight(),top:e.top,scrollTop:this.getScrollTop(),windowSpecs:{...this.windowSpecs},element:e.element,instance:e.instance})}validateStickyContainerHeight(){if(!this.shouldValidateItemHeights())return;let{firstIndex:e,lastIndex:t,stickyHeight:n,stickyTop:r,stickyBottom:i}=this.renderState;if(e===-1||t===-1)return;let a=this.stickyContainer.getBoundingClientRect().height;Math.abs(a-n)<Uf||console.error(`CodeView: sticky container height does not match computed layout`,{computedStickyHeight:n,actualStickyHeight:a,delta:a-n,stickyTop:r,stickyBottom:i,firstIndex:e,lastIndex:t,firstStickySpecs:this.items[e]?.instance.getAdvancedStickySpecs(),lastStickySpecs:this.items[t]?.instance.getAdvancedStickySpecs(),scrollTop:this.getScrollTop(),scrollPageOffset:this.scrollPageOffset,windowSpecs:{...this.windowSpecs},stickyContainer:this.stickyContainer})}clearScrollInteractionTimer(){this.scrollInteractionFixTimer!=null&&(clearTimeout(this.scrollInteractionFixTimer),this.scrollInteractionFixTimer=void 0)}suspendScrollInteractions(){this.clearScrollInteractionTimer(),this.shouldDisablePointerEvents()&&!this.pointerEventsDisabled&&(this.stickyContainer.style.pointerEvents=`none`,this.pointerEventsDisabled=!0),Yf&&!this.codeOverflowFix&&(this.stickyContainer.style.setProperty(Wf,`hidden`),this.codeOverflowFix=!0),this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,Hf)}restoreScrollInteractions=()=>{this.clearScrollInteractionTimer(),this.pointerEventsDisabled&&=(this.stickyContainer.style.removeProperty(`pointer-events`),!1),this.codeOverflowFix&&=(this.stickyContainer.style.setProperty(Wf,`auto`),!1)};syncLayout(){let{gap:e,paddingBottom:t,paddingTop:n}=this.getLayout();this.stickyContainer.style.gap=`${e}px`,this.container?.style.setProperty(`margin-top`,`${n}px`),this.container?.style.setProperty(`margin-bottom`,`${t}px`)}reconcileHeaderFooterHosts(){let e=this.reconcileHost(`header`),t=this.reconcileHost(`footer`);return e||t}reconcileHost(e){let{root:t,container:n}=this;if(t==null||n==null)return!1;let r=e===`header`?this.header:this.footer,i=e===`header`?this.options.renderCodeViewHeader:this.options.renderCodeViewFooter;if(i==null)return r.element==null||(this.resizeObserver?.unobserve(r.element),r.element.remove(),r.element=void 0,r.render=void 0,this.setHostHeight(r,0)),!1;if(r.element!=null&&i===r.render)return!1;let a=r.element??hu(e,n,this.resizeObserver);r.element=a;let o=i();return o==null?!this.isComponentManaged&&a.children.length>0&&(a.textContent=``):a.replaceChildren(o),r.render=i,!0}setHostHeight(e,t){e.height!==t&&(e.height=t,this.scrollDirty=!0)}measureMountedHosts(){this.header.element!=null&&this.setHostHeight(this.header,this.header.element.getBoundingClientRect().height),this.footer.element!=null&&this.setHostHeight(this.footer,this.footer.element.getBoundingClientRect().height)}setup(t){if(this.root!=null)throw Error(`CodeView.setup: already setup`);this.workerManager?.subscribeToThemeChanges(this),this.root=t,this.root.style.overflowAnchor=`none`,this.root.hasAttribute(`tabindex`)||(this.root.tabIndex=-1),this.container??=document.createElement(`div`),this.container.style.contain=`layout style`,this.syncLayout(),this.container.appendChild(this.stickyOffset),this.container.appendChild(this.stickyContainer),this.root.appendChild(this.container),this.scrollDirty=!0,this.heightDirty=!0,this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.stickyContainer),this.root.addEventListener(`scroll`,this.handleScroll,{passive:!0}),this.root.addEventListener(`wheel`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`touchstart`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`pointerdown`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`keydown`,this.clearPendingScroll,{passive:!0}),this.resizeObserver.observe(this.root),this.render(!0),window.__INSTANCE=this,window.__TOGGLE=()=>{e.__STOP?(e.__STOP=!1,this.scrollTo({type:`position`,position:e.__lastScrollPosition,behavior:`instant`})):(e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0)}}reset(){ms(this.computeRenderRangeAndEmit),this.clearReadySubscription(),this.restoreScrollInteractions(),this.cleanAllRenderedItems();let{items:e}=this,t=[...this.itemEditors.values()].map(e=>{let t=this.idToItem.get(e.state.id);return t!=null&&(e.state.removedItem=t.item),e});this.itemEditors.clear(),this.attachedEditors.clear(),this.selectedLines=null,this.items=[],this.idToItem.clear(),this.instanceToItem.clear();let n=!1,r;for(let e of t)try{e.editor.cleanUp(`discard`)}catch(e){n||(n=!0,r=e)}for(let t of e)try{t.instance.cleanUp()}catch(e){n||(n=!0,r=e)}if(this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,this.stickyContainer.textContent=``,this.stickyOffset.style.height=``,this.container?.style.removeProperty(`height`),this.containerHeight=-1,this.windowSpecs={top:0,bottom:0},this.pendingLayoutAnchor=void 0,this.headerResizeAnchor=void 0,this.shouldFixContainerFocus=!1,this.height=0,this.scrollTop=0,this.scrollPageOffset=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.resetRenderState(),this.isComponentManaged||this.flushSlotCoordinator(),n)throw r}cleanUp(){let e=!1,t;try{this.reset()}catch(n){e=!0,t=n}if(this.clearElementPool(),this.restoreScrollInteractions(),this.workerManager?.unsubscribeToThemeChanges(this),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.root?.removeEventListener(`scroll`,this.handleScroll),this.root?.removeEventListener(`wheel`,this.clearPendingScroll),this.root?.removeEventListener(`touchstart`,this.clearPendingScroll),this.root?.removeEventListener(`pointerdown`,this.clearPendingScroll),this.root?.removeEventListener(`keydown`,this.clearPendingScroll),this.root?.style.removeProperty(`overflow-anchor`),this.container?.remove(),this.stickyOffset.remove(),this.stickyContainer.remove(),this.stickyContainer.textContent=``,this.header.element?.remove(),this.header.element=void 0,this.header.render=void 0,this.header.height=0,this.footer.element?.remove(),this.footer.element=void 0,this.footer.render=void 0,this.footer.height=0,this.root=void 0,this.container=void 0,e)throw t}cleanAllRenderedItems(){if(this.renderState.firstIndex!==-1)for(let e=this.renderState.firstIndex;e<=this.renderState.lastIndex;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${e}`);this.releaseRenderedItem(t)}}primeScrollTarget(e){e.type!==`position`&&this.idToItem.get(e.id)?.instance.primeHighlightCache()}getElementPoolLimit(){let e=this.getHeight()+this.config.overscrollSize*2,{diffHeaderHeight:t}=this.itemMetricsCache;return Math.max(8,Math.ceil(e/Math.max(t,10))+1)*(this.isComponentManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let e=this.elementPool.pop();for(;e!=null&&!this.isElementPoolGenerationCurrent(e);)e=this.elementPool.pop();return e??=document.createElement(Ha),this.markElementPoolGenerationCurrent(e),e}releaseRenderedItem(e){let{element:t}=e;t!=null&&this.renderedItemOwnsFocus(t)&&(this.shouldFixContainerFocus=!0),e.instance.cleanUp(!0),this.attachedEditors.delete(e.item.id),e.element=void 0,t!=null&&(t.remove(),this.cleanElement(t),this.queueElementForPool(t))}renderedItemOwnsFocus(e){let{activeElement:t}=document;return t===e||e.contains(t)||e.shadowRoot?.activeElement!=null}fixContainerFocus(){this.shouldFixContainerFocus&&(this.shouldFixContainerFocus=!1,this.root?.focus({preventScroll:!0}))}cleanElement(e){let{shadowRoot:t}=e;if(t!=null)for(let e of Array.from(t.children))tp(e)||e.remove();this.isComponentManaged||e.replaceChildren()}queueElementForPool(e){let t=this.getElementPoolLimit();!this.isElementPoolGenerationCurrent(e)||this.getElementPoolSize()>=t||(this.isElementClean(e)?this.elementPool.push(e):this.pendingElementPool.push(e))}promotePendingPooledElements(){if(this.pendingElementPool.length===0)return;let{pendingElementPool:e}=this;this.pendingElementPool=[];let t=this.getElementPoolLimit();for(let n of e)this.isElementPoolGenerationCurrent(n)&&this.isElementClean(n)&&this.elementPool.length<t?this.elementPool.push(n):this.isElementPoolGenerationCurrent(n)&&this.getElementPoolSize()<t&&this.pendingElementPool.push(n)}isElementClean(e){return e.childNodes.length===0}getElementPoolSize(){return this.elementPool.length+this.pendingElementPool.length}clearElementPool(){this.elementPool.length=0,this.pendingElementPool.length=0}invalidateElementPool(){this.elementPoolVersion++,this.clearElementPool()}markElementPoolGenerationCurrent(e){this.elementPoolTracker.set(e,this.elementPoolVersion)}isElementPoolGenerationCurrent(e){return this.elementPoolTracker.get(e)===this.elementPoolVersion}resolveEffectiveScrollBehavior(e,t){return gu()?`instant`:e.behavior===`smooth-auto`?Math.abs(t-this.getScrollTop())<=this.getHeight()*10?`smooth`:`instant`:e.behavior??`instant`}scrollTo(e){if(this.root==null)return;let t=this.normalizeScrollTarget(e);if(t==null)return;let n=this.resolveScrollTargetTop(t);n!=null&&(this.primeScrollTarget(t),this.resolveEffectiveScrollBehavior(t,n)===`smooth`?this.scrollAnimation??={position:this.getScrollTop(),velocity:0,lastTimestamp:performance.now()}:this.scrollAnimation=void 0,this.suspendScrollInteractions(),this.pendingLayoutAnchor=void 0,this.pendingScrollTarget=t,this.render())}setSelectedLines(e,t){this.applySelectedLines(e,t)}getSelectedLines(){return this.selectedLines}clearSelectedLines(e){this.applySelectedLines(null,e)}getItem(e){return this.idToItem.get(e)?.item}getEditor(e){return this.itemEditors.get(e)?.editor}updateItem(e){let t=this.idToItem.get(e.id);return t==null?(console.error(`CodeView.updateItem: unknown item id "${e.id}"`),!1):this.syncItemRecord(t,e)?(this.markItemLayoutDirty(t),this.scrollDirty=!0,this.render(),this.syncItemEditors(),this.syncSelection(),!0):!1}updateItemId(e,t){if(e===t)return!0;let n=this.idToItem.get(e);if(n==null)return console.error(`CodeView.updateItemId: unknown item id "${e}"`),!1;if(this.idToItem.has(t))return console.error(`CodeView.updateItemId: duplicate item id "${t}"`),!1;this.idToItem.delete(e),n.item.id=t,this.idToItem.set(t,n),this.updateItemOptionsId(n.instance.options,t),this.selectedLines?.id===e&&(this.selectedLines={...this.selectedLines,id:t},this.options.onSelectedLinesChange?.(this.selectedLines));let r=this.itemEditors.get(e);return r!=null&&(this.itemEditors.delete(e),this.itemEditors.set(t,r),this.attachedEditors.delete(e)&&this.attachedEditors.add(t)),this.renamePendingScrollTarget(e,t),this.renamePendingLayoutAnchor(e,t),this.render(),!0}addItem(e){this.addItems([e])}addItems(e){this.appendItemsInternal(e),this.syncItemEditors(),this.syncSelection()}removeItem(e){let t=this.idToItem.get(e);if(t==null)return console.error(`CodeView.removeItem: unknown item id "${e}"`),!1;let n=[];for(let e of this.items)e!==t&&n.push(e.item);return this.setItems(n),!0}setItems(e){let t;this.items.length===0?this.appendItemsInternal(e):this.tryAppendItems(e)||(t=this.reconcileItems(e));try{this.syncItemEditors(t)}finally{for(let e of t?.values()??[])e.instance.cleanUp()}this.syncSelection()}appendItemsInternal(e,t=!0){if(e.length===0)return;let n=this.getLayout(),r=this.items.length===0?0:this.scrollHeight+n.gap,i=r;for(let t=0;t<e.length;t++){let i=e[t];if(i==null)throw Error(`CodeView.appendItemsInternal: missing input item`);if(this.idToItem.has(i.id))throw Error(`CodeView.addItem: duplicate id "${i.id}"`);let a=this.createItem(i,this.items.length,r);this.items.push(a),this.idToItem.set(a.item.id,a),this.instanceToItem.set(a.instance,a),a.height=Zf(a),r+=a.height+n.gap}this.scrollHeight=r-n.gap,this.scrollDirty=!0,t&&(this.canSkipRenderForAppend(i)?this.syncContainerHeight():this.render())}canSkipRenderForAppend(e){return this.container!=null&&this.renderState.firstIndex!==-1&&this.pendingScrollTarget==null&&this.scrollAnimation==null&&this.layoutDirtyIndex==null&&e>this.windowSpecs.bottom}onThemeChange(){this.invalidateElementPool()}setOptions(e){if(e==null)return;this.capturePendingLayoutAnchor();let{options:t}=this,n=this.getLayout(),{itemMetricsCache:r}=this;Qf(t,e)&&this.invalidateElementPool(),this.options=e;let i=this.computeMetricsCache(e.itemMetrics),a=!Uo(r,i),o=!Uo(n,this.getLayout());o&&this.syncLayout();let s=a||$f(t,e);if(s){let n=this.pendingLayoutReset;this.pendingLayoutReset={metrics:a?i:n?.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:n?.includeEstimatedDiffHeights===!0||a||ep(t,e)}}(o||s)&&(this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0),us(t,e)||this.renderOptionsRevision++,this.syncItemEditors();let c=t.renderCodeViewHeader!==e.renderCodeViewHeader||t.renderCodeViewFooter!==e.renderCodeViewFooter;!this.isComponentManaged&&(this.items.length>0||c)&&this.render()}capturePendingLayoutAnchor(e=this.idToItem){this.root!=null&&this.items.length!==0&&this.pendingScrollTarget==null&&(this.pendingLayoutAnchor=this.getScrollAnchor(this.getScrollTop(),e))}render(t=!1){e.__STOP||(t?(ms(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit()):es(this.computeRenderRangeAndEmit))}isReady(){let{workerManager:e}=this;return e==null||e.getStats().workersFailed?this.isSharedHighlighterReady():e.isInitialized()?(this.clearReadySubscription(),!0):(this.isReadySubscription??=e.subscribeToStatChanges(e=>{(e.managerState===`initialized`||e.workersFailed)&&(this.clearReadySubscription(),this.render(!0))}),e.getStats().managerState===`waiting`&&e.initialize().catch(()=>{}),!1)}clearReadySubscription(){this.isReadySubscription!=null&&(this.isReadySubscription(),this.isReadySubscription=void 0,this.pendingHighlighterTheme=void 0)}isSharedHighlighterReady(){let e=this.workerManager?.getFileRenderOptions().theme??this.options.theme??yo;return Yo({theme:e})==null?(to(this.pendingHighlighterTheme,e)||this.clearReadySubscription(),this.isReadySubscription??=(()=>{this.pendingHighlighterTheme=e;let t=!1;return Ko({themes:Qa(e),langs:[],preferredHighlighter:Do(this.workerManager,this.options)}).then(()=>{t||(this.clearReadySubscription(),this.render(!0))},e=>{t||(this.clearReadySubscription(),e instanceof Ps||console.error(e))}),()=>{t=!0}})(),!1):(this.clearReadySubscription(),!0)}instanceChanged(e,t){let n=this.instanceToItem.get(e);if(n==null)throw Error(`CodeView.instanceChanged: An instance has changed that is not registered`);t&&this.markItemLayoutDirty(n),this.itemEditors.has(n.item.id)||(this.slotSnapshotStale=!0),this.render()}getWindowSpecs(){return this.windowSpecs}getContainerElement(){return this.root}getHeaderElement(){return this.header.element}getFooterElement(){return this.footer.element}getRenderedItems(){let{firstIndex:e,lastIndex:t}=this.renderState;if(e===-1||t===-1||t<e)return[];let n=[];for(let r=e;r<=t;r++){let e=this.items[r];e?.element!=null&&(e.type===`diff`?n.push({id:e.item.id,type:`diff`,item:e.item,version:e.version,element:e.element,instance:e.instance}):n.push({id:e.item.id,type:`file`,item:e.item,version:e.version,element:e.element,instance:e.instance}))}return n}setSlotCoordinator(e){return e!==this.slotCoordinator&&(this.slotCoordinator=e,this.slotSnapshot=void 0,!0)}getSlotSnapshot(e){return this.buildSlotSnapshot(e)}buildSlotSnapshot(e){let t=sp(this.getRenderedItems(),e),{element:n}=this.header,{element:r}=this.footer;if(t!=null||n!=null||r!=null)return{items:t,header:n,footer:r}}subscribeToScroll(e){return this.scrollListeners.add(e),()=>{this.scrollListeners.delete(e)}}getLocalTopForInstance(e){let t=this.instanceToItem.get(e);if(t==null)throw Error(`CodeView.getLocalTopForInstance: unknown virtualized instance`);return t.top}getTopForItem(e){let t=this.idToItem.get(e);if(t!=null)return t.top+this.getItemTopOffset()}createItem(e,t,n){let{itemMetricsCache:r}=this;if(e.type===`diff`){let i=new bf(this.createDiffOptions(e.id),this,r,this.workerManager);return{type:`diff`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}let i=new vs(this.createFileOptions(e.id),this,r,this.workerManager);return{type:`file`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}applySelectedLines(e,t){let{selectedLines:n}=this;e==null&&n==null||e!=null&&n?.id===e.id&&Lo(n.range,e.range)||(n!=null&&n.id!==e?.id&&this.idToItem.get(n.id)?.instance.setSelectedLines(null,{notify:!1}),this.selectedLines=e,this.idToItem.get(e?.id??``)?.instance.setSelectedLines(e?.range??null,t))}syncSelection(){if(this.selectedLines==null)return;let e=this.idToItem.get(this.selectedLines.id);e==null?(this.selectedLines=null,this.options.onSelectedLinesChange?.(null)):e.instance.setSelectedLines(this.selectedLines.range,{notify:!1})}isItemInEditMode(e){return e.item.edit===!0&&e.item.collapsed!==!0}attachItemEditor(e){let{id:t}=e.item,{createEditor:n}=this.options;if(e.element==null||this.attachedEditors.has(t)||!this.isItemInEditMode(e))return;let r=this.itemEditors.get(t),i;try{if(r==null&&e.type===`diff`&&!e.instance.__canAttachEditor()){e.instance.__prepareForEditing();return}if(r==null){Jf(n);let r=Bf(e.instance.options);if(r==null)throw Error(`CodeView.attachItemEditor: instance options are missing their state`);let a=e=>{let t=this.idToItem.get(r.id);t!=null&&this.options.onItemEditChange?.(e,t.item)},o=this.options.getEditStateKey?.(e.item);if(e.type===`diff`){let s=n(`file-diff`,{onChange:a},o);i=s,this.itemEditors.set(t,{editor:s,state:r,dispose:s.edit(e.instance)})}else{let s=n(`file`,{onChange:a},o);i=s,this.itemEditors.set(t,{editor:s,state:r,dispose:s.edit(e.instance)})}}else r.dispose=(e.type,r.editor.edit(e.instance));this.attachedEditors.add(t)}catch(t){throw i?.cleanUp(),this.releaseRenderedItem(e),t}}syncItemEditors(e){if(this.itemEditors.size===0)return;let t=[];for(let[n,r]of this.itemEditors){let i=this.idToItem.get(n),a=e?.get(n);if(a==null&&i!=null){let{edit:e=!1,collapsed:t=!1}=i.item;if(e){t&&this.attachedEditors.delete(n)&&r.editor.cleanUp(`recycle`);continue}}else a!=null&&(r.state.removedItem=a.item);this.itemEditors.delete(n),this.attachedEditors.delete(n),t.push(r)}if(t.length===0)return;let n=!1,r;for(let e of t){try{e.dispose()}catch(e){n||(n=!0,r=e)}let t=this.idToItem.get(e.state.id);t!=null&&this.markItemLayoutDirty(t)}if(this.render(),n)throw r}requireItemFromState(e){let t=this.idToItem.get(e.id)?.item??e.removedItem;if(t==null)throw Error(`CodeView.onItemEditComplete: unknown item "${e.id}"`);return t}completeFileItemEdit(e,t){let n=this.requireItemFromState(e);if(n.type!==`file`)throw Error(`CodeView.onItemEditComplete: item "${e.id}" is not a file item`);let r={...n,file:t.file,annotations:t.lineAnnotations,edit:!1,version:(n.version??0)+1};return(this.options.onItemEditComplete?.(t,n,r)??`reject`)===`reject`?`reject`:(this.idToItem.has(n.id)&&this.updateItem(r),`accept`)}completeDiffItemEdit(e,t){let n=this.requireItemFromState(e);if(n.type!==`diff`)throw Error(`CodeView.onItemEditComplete: item "${e.id}" is not a diff item`);let r={...n,fileDiff:t.fileDiff,annotations:t.lineAnnotations,edit:!1,version:(n.version??0)+1};return(this.options.onItemEditComplete?.(t,n,r)??`reject`)===`reject`?`reject`:(this.idToItem.has(n.id)&&this.updateItem(r),`accept`)}renamePendingScrollTarget(e,t){let{pendingScrollTarget:n}=this;n!=null&&n.type!==`position`&&n.id===e&&(this.pendingScrollTarget={...n,id:t})}renamePendingLayoutAnchor(e,t){this.pendingLayoutAnchor?.id===e&&(this.pendingLayoutAnchor.id=t)}createFileOptionsPrototype(){let e={};for(let t of Ff)Vf(e,t,()=>this.options[t]);Vf(e,`stickyHeader`,()=>this.options.stickyHeaders),Vf(e,`collapsed`,e=>{let t=Bf(e);if(t!=null)return this.getItemOptions(t,`file`)?.item.collapsed}),Vf(e,`onEditComplete`,e=>{if(this.options.onItemEditComplete==null)return;let t=Bf(e);if(t!=null)return e=>this.completeFileItemEdit(t,e)});for(let t of If)this.defineItemSharedCallback(e,`file`,t);for(let t of Lf)this.defineItemSelectionCallback(e,`file`,t);return e}createDiffOptionsPrototype(){let e={};for(let t of Pf)Vf(e,t,()=>this.options[t]);Vf(e,`stickyHeader`,()=>this.options.stickyHeaders),Vf(e,`hunkSeparators`,()=>this.options.hunkSeparators),Vf(e,`collapsed`,e=>{let t=Bf(e);if(t!=null)return this.getItemOptions(t,`diff`)?.item.collapsed}),Vf(e,`onEditComplete`,e=>{if(this.options.onItemEditComplete==null)return;let t=Bf(e);if(t!=null)return e=>this.completeDiffItemEdit(t,e)});for(let t of If)this.defineItemSharedCallback(e,`diff`,t);for(let t of Lf)this.defineItemSelectionCallback(e,`diff`,t);return e}createFileOptions(e){let t=Object.create(this.fileOptionsPrototype);return zf(t,{id:e}),t}createDiffOptions(e){let t=Object.create(this.diffOptionsPrototype);return zf(t,{id:e}),t}updateItemOptionsId(e,t){let n=Bf(e);if(n==null)throw Error(`CodeView.updateItemOptionsId: No valid state`);n.id=t}getItemOptions(e,t){let n=this.idToItem.get(e.id);if(n!=null&&n.type===t)return n}defineItemSharedCallback(e,t,n){Vf(e,n,e=>{if(this.options[n]==null)return;let r=Bf(e);if(r==null)return;let i=r.callbackCache??={},a=i[n];return a??(a=((...e)=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=this.options[n];return a?.(...e,i)}),i[n]=a),a})}defineItemSelectionCallback(e,t,n){Vf(e,n,e=>{let r=Bf(e);if(r==null)return;let i=r.callbackCache??={},a=i[n];return a??(a=e=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=e==null?null:{id:i.item.id,range:e};this.options.controlledSelection!==!0&&(e!=null||this.selectedLines?.id===i.item.id)&&this.applySelectedLines(a,{notify:!1}),this.options.onSelectedLinesChange?.(a);let o=this.options[n];return o?.(e,i)},i[n]=a),a})}markLayoutDirtyFromIndex(e){this.layoutDirtyIndex=Math.min(this.layoutDirtyIndex??e,e)}markItemLayoutDirty(e){if(this.items[e.index]!==e)throw Error(`CodeView.markItemLayoutDirty: unknown item id "${e.item.id}"`);this.markLayoutDirtyFromIndex(e.index)}tryAppendItems(e){if(e.length<=this.items.length)return!1;for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null||n.item.id!==r.id||n.type!==r.type)return!1}for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null)throw Error(`CodeView.tryAppendItems: append candidate missing prefix item`);this.syncItemRecord(n,r)&&this.markLayoutDirtyFromIndex(t)}return this.appendItemsInternal(e.slice(this.items.length),!1),this.scrollDirty=!0,this.render(),!0}reconcileItems(e){let{items:t,idToItem:n}=this,r=new Set(t),i=[],a=new Map,o=new Map,s=new Map,c;for(let s=0;s<e.length;s++){let l=e[s];if(l==null)throw Error(`CodeView.reconcileItems: missing input item`);if(a.has(l.id))throw Error(`CodeView.setItems: duplicate id "${l.id}"`);let u=n.get(l.id),d=u!=null&&u.type===l.type?u:this.createItem(l,s,0);d.index=s,u!=null&&u.type===l.type?(r.delete(u),this.syncItemRecord(d,l)&&(c=Math.min(c??s,s))):c=Math.min(c??s,s),t[s]!==d&&(c=Math.min(c??s,s)),i.push(d),a.set(l.id,d),o.set(d.instance,d)}if(c==null){if(r.size===0)return;c=Math.max(i.length-1,0)}this.capturePendingLayoutAnchor(a);for(let e=0;e<t.length;e++){let n=t[e];if(n==null||!r.has(n))continue;s.set(n.item.id,n),this.releaseRenderedItem(n);let a=Math.max(i.length-1,0);c=Math.min(c??a,a)}return this.items=i,this.idToItem=a,this.instanceToItem=o,this.renderState.firstIndex>=i.length?this.resetRenderState():this.renderState.lastIndex>=i.length&&(this.renderState.lastIndex=i.length-1),this.markLayoutDirtyFromIndex(c),this.scrollDirty=!0,this.render(),s.size>0?s:void 0}syncItemRecord(e,t){if(e.type!==t.type)throw Error(`CodeView.syncItemRecord: type mismatch for id "${t.id}"`);return e.version!==t.version&&(e.item=t,e.version=t.version,e.renderedOptionsRevision=-1,!0)}getMaxScrollTopForHeight(e){let{paddingBottom:t,paddingTop:n}=this.getLayout();return Math.max(n+this.header.height+e+this.footer.height+t-this.getHeight(),0)}getMaxScrollTop(){return this.getMaxScrollTopForHeight(this.getScrollHeight())}shouldRebaseScroll(){return this.getMaxScrollTop()>this.scrollRebaseConfig.threshold}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),this.scrollRebaseConfig.containerHeight):this.getScrollHeight()}getMaxPagedScrollTop(){return this.getMaxScrollTopForHeight(this.getPagedScrollHeight())}clampPagedScrollTop(e){let t=this.getMaxPagedScrollTop();return Math.max(0,Math.min(e,t))}clampScrollTop(e){let t=this.getMaxScrollTop();return Math.max(0,Math.min(e,t))}getMaxScrollPageOffset(){return Math.max(this.getMaxScrollTop()-this.getMaxPagedScrollTop(),0)}clampScrollPageOffset(e){let t=this.getMaxScrollPageOffset();return Math.max(0,Math.min(e,t))}resolveScrollPageWindow(e,t){let n=_u(this.clampPagedScrollTop(t)),r=this.clampScrollPageOffset(e-n);return n=_u(this.clampPagedScrollTop(e-r)),r=this.clampScrollPageOffset(e-n),{pagedScrollTop:n,scrollPageOffset:r}}resolvePagedScrollPosition(e){if(!this.shouldRebaseScroll())return{pagedScrollTop:this.clampPagedScrollTop(e),scrollPageOffset:0};let{scrollPageOffset:t,scrollRebaseConfig:n}=this,r=this.clampScrollPageOffset(t),i=e-r,a=this.getMaxPagedScrollTop(),o=this.getMaxScrollPageOffset(),s=i>n.threshold&&r<o,c=i<n.triggerTop&&r>0;return i<0||i>a||s||c?this.resolveScrollPageWindow(e,c?Math.min(n.targetBottom,a):n.targetTop):{pagedScrollTop:_u(this.clampPagedScrollTop(i)),scrollPageOffset:r}}needsScrollPageUpdate(e){let t=_u(this.clampScrollTop(e)),{scrollPageOffset:n}=this.resolvePagedScrollPosition(t);return n!==this.scrollPageOffset}getPagedLayoutTop(e){return this.shouldRebaseScroll()?Math.max(e-this.scrollPageOffset,0):e}getStickyHeaderOffset(){return this.options.stickyHeaders===!0&&this.options.disableFileHeader!==!0?this.itemMetricsCache.diffHeaderHeight:0}getScrollTargetRect(e){let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return{top:t.top,height:t.height};if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${np(e.range)} for item "${e.id}"`);return}return{top:t.top+n.top,height:n.height}}let n=this.getLineScrollPosition(t,e);if(n==null)console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);else return{top:t.top+n.top,height:n.height}}normalizeScrollTarget(e){if(e.type===`position`||e.align!==`nearest`)return e;let t=this.getScrollTargetRect(e);if(t==null)return;let n=e.offset??0,r=this.getItemTopOffset()+t.top,i=r+t.height,a=this.getScrollTop(),o=a+(e.type===`line`||e.type===`range`?this.getStickyHeaderOffset():0),s=a+this.getHeight();if(!(r-n<=o&&i+n>=s)){if(r-n<o)return{...e,align:`start`};if(i+n>s)return{...e,align:`end`}}}resolveScrollTargetTop(e){if(e.type===`position`){let t=this.clampScrollTop(e.position);return t===e.position?this.clampScrollTop(e.position-this.getStickyHeaderOffset()):t}let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top,t.height,e.align,e.offset));if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${np(e.range)} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}let n=this.getLineScrollPosition(t,e);if(n==null)console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);else return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}resolveAlignedScrollPosition(e,t,n,r=0,i=0){e+=this.getItemTopOffset();let a=this.getHeight();return n===`center`&&t+r<a?e-(a-t)/2+r:n===`end`?e-(a-t)+r:e-i-r}getLineScrollPosition(e,t){return e.type===`diff`?e.instance.getLinePosition(t.lineNumber,t.side):e.instance.getLinePosition(t.lineNumber)}getRangeScrollPosition(e,t){let{range:n}=t,r=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.start,side:n.side}),i=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.end,side:n.endSide??n.side});if(r==null||i==null)return;let a=r.top,o=a+r.height,s=i.top,c=s+i.height,l=Math.min(a,s);return{top:l,height:Math.max(o,c)-l}}computeTargetScrollTopForFrame(e,t){if(this.pendingScrollTarget==null)return e;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null)return e;let{scrollAnimation:r}=this;return r==null?n:this.computeSpringStep(r,n,t).position}computeSpringStep(e,t,n){let r=Math.max(0,n-e.lastTimestamp),{omega:i}=this.getSmoothScrollSettings(),a=Math.exp(-i*r),o=e.position-t,s=e.velocity+i*o;return{position:t+(o+s*r)*a,velocity:(s*(1-i*r)-i*o)*a}}advanceScrollAnimation(e,t){if(this.pendingScrollTarget==null)return;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null){this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;return}let r=this.scrollAnimation;if(r==null)return n;r.position+=t;let{position:i,velocity:a}=this.computeSpringStep(r,n,e);r.lastTimestamp=e,r.position=i,r.velocity=a;let{positionEpsilon:o,velocityEpsilon:s}=this.getSmoothScrollSettings();return Math.abs(n-i)<=o&&Math.abs(a)<=s?(r.position=n,r.velocity=0,this.scrollAnimation=void 0,n):r.position}computeRenderRangeAndEmit=(t=performance.now())=>{if(e.__STOP||this.container==null||!this.isReady())return;let n=this.getHeight(),r=this.getScrollTop(),i=this.pendingScrollTarget!=null,a=r,o=this.pendingLayoutAnchor!=null,s=this.getScrollAnchor(a);if(this.layoutDirtyIndex!=null&&(this.recomputeLayout(this.layoutDirtyIndex,this.pendingLayoutReset),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,o=!0),o&&s!=null){let e=this.resolveAnchoredScrollTop(s);if(e!=null){let t=e-a;a=e,this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}}o&&(a=this.clampScrollTop(a),this.syncContainerHeight());let c=this.computeTargetScrollTopForFrame(a,t),l=!o&&(this.renderState.scrollTop===-1||Math.abs(c-this.renderState.scrollTop)>n+this.config.overscrollSize*2);l&&(s=void 0),this.windowSpecs=zs({scrollTop:c-this.header.height,height:n,scrollHeight:this.getScrollHeight(),fitPerfectly:l,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let u=r;(this.pendingScrollTarget!=null&&c!==u||this.needsScrollPageUpdate(c))&&(this.applyScrollFix(c,u,this.windowSpecs),u=c);let{top:d,bottom:f}=this.windowSpecs,{firstIndex:p,lastIndex:m}=this.renderState;if(p>=0)for(let e=p;e<=m;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${e}`);t.top>d-t.height&&t.top<=f||this.releaseRenderedItem(t)}let h=this.reconcileHeaderFooterHosts(),g,_=new Set,v=this.findFirstVisibleIndex(d),y=this.findLastVisibleIndex(f);for(let e=v;e<=y;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: missing item`);let{instance:n}=t;t.element==null?(t.element=this.acquireElement(),ap(this.stickyContainer,t.element,g),n.virtualizedSetup(),ip(t,t.element)&&(t.renderedOptionsRevision=this.renderOptionsRevision,_.add(t)),g=t.element):(ap(this.stickyContainer,t.element,g),ip(t,void 0,t.renderedOptionsRevision!==this.renderOptionsRevision)&&(t.renderedOptionsRevision=this.renderOptionsRevision,_.add(t)),g=t.element),t.item.edit===!0&&this.attachItemEditor(t)}this.renderState.firstIndex=v<=y?v:-1,this.renderState.lastIndex=y,this.flushSlotCoordinator(),this.flushManagers(_),h&&this.measureMountedHosts(),this.reconcileRenderedItems(_),this.syncContainerHeight(),this.updateStickyPositioning();let b=s==null?void 0:this.resolveAnchoredScrollTop(s);s===this.pendingLayoutAnchor&&(this.pendingLayoutAnchor=void 0);let x=b==null?0:b-a,S=c,C=!1;if(this.pendingScrollTarget!=null){let e=this.advanceScrollAnimation(t,x);e==null?S=a:(S=e,C=!0)}else S=b??c;S!==u&&(this.applyScrollFix(S,u,this.windowSpecs),u=S),C&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),this.renderState.scrollTop=_u(u),this.updateStickyPositioning(),i&&(this.headerResizeAnchor=void 0,this.getScrollAnchor(u)),this.validateStickyContainerHeight(),this.fixContainerFocus(),(l||this.scrollAnimation!=null)&&this.render()};flushManagers(e){for(let t of e)t.instance.flushManagers()}syncContainerHeight(){let e=this.getPagedScrollHeight();this.container!=null&&this.containerHeight!==e&&(this.container.style.height=`${e}px`,this.containerHeight=e)}getStickyBounds(e){let{firstIndex:t,lastIndex:n}=e==null?this.renderState:{firstIndex:this.findFirstVisibleIndex(e.top),lastIndex:this.findLastVisibleIndex(e.bottom)};if(t===-1||n===-1||t>n)return;let r=this.items[t]?.instance.getAdvancedStickySpecs(e),i=this.items[n]?.instance.getAdvancedStickySpecs(e);if(r!=null&&i!=null)return{stickyTop:this.getPagedLayoutTop(Math.max(r.topOffset,0)),stickyBottom:this.getPagedLayoutTop(i.topOffset+i.height)}}applyStickyPositioning({stickyTop:e,stickyBottom:t}){let n=this.getHeight(),{itemMetricsCache:r}=this,i=t-e;this.renderState.stickyHeight=i,this.renderState.stickyTop=e,this.renderState.stickyBottom=t,this.stickyOffset.style.height=`${e}px`;let a=(Math.random()*r.lineHeight|0)*-1,o=-Math.max(i+a,0)+n;this.stickyContainer.style.top=`${o}px`,this.stickyContainer.style.bottom=`${o+r.diffHeaderHeight}px`}syncPagedScrollScaffolding(e){this.syncContainerHeight();let t=this.getStickyBounds(e);t==null?this.stickyOffset.style.height=`${this.getPagedLayoutTop(e.top)}px`:this.applyStickyPositioning(t)}reconcileRenderedItems(e){let{firstIndex:t,lastIndex:n}=this.renderState;if(t===-1)return;let r=-1,i=!1;for(let a=t;a<this.items.length&&!(!i&&a>n);a++){let t=this.items[a];if(t==null)throw Error(`CodeView.reconcileRenderedItems: Invalid item`);r===-1?r=t.top:t.top!==r&&(t.top=r,t.instance.syncVirtualizedTop(),i=!0),(e==null?a<=n:e.has(t))&&(t.instance.reconcileHeights()&&(i=!0,t.height=t.instance.getVirtualizedHeight()),this.validateRenderedItemHeight(t)),r+=t.instance.getVirtualizedHeight(),a<this.items.length-1&&(r+=this.getLayout().gap)}i&&r!=null&&(this.scrollDirty=!0,this.scrollHeight=r)}updateStickyPositioning(){let e=this.getStickyBounds();if(e==null){this.renderState.firstIndex===-1&&(this.stickyOffset.style.height=``);return}let{stickyTop:t,stickyBottom:n}=e;(n-t!==this.renderState.stickyHeight||t!==this.renderState.stickyTop||n!==this.renderState.stickyBottom)&&this.applyStickyPositioning(e)}handleScroll=()=>{e.__STOP||(this.suspendScrollInteractions(),this.scrollDirty=!0,this.notifyScroll(),this.render())};clearPendingScroll=()=>{this.headerResizeAnchor=void 0,this.pendingScrollTarget=void 0,this.pendingLayoutAnchor=void 0,this.scrollAnimation=void 0};handleResize=e=>{let t=!1;for(let n of e)if(n.target===this.stickyContainer){let e=n.borderBoxSize[0].blockSize;if(Math.abs(e-this.renderState.stickyHeight)>=Uf){let e=this.getScrollTop(),n=this.getScrollAnchor(e);this.reconcileRenderedItems(),this.updateStickyPositioning();let r=n==null?void 0:this.resolveAnchoredScrollTop(n);if(r!=null){let t=r-e;this.applyScrollFix(r,e,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),t=!0}}else if(n.target===this.header.element||n.target===this.footer.element){let e=n.target===this.header.element?this.header:this.footer,r=n.borderBoxSize[0].blockSize;if(r!==e.height){let n=this.getScrollTop(),i=this.getScrollAnchor(n);this.setHostHeight(e,r);let a=i==null?void 0:this.resolveAnchoredScrollTop(i);if(a!=null){let e=a-n;this.applyScrollFix(a,n,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=e)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),t=!0}}else this.scrollDirty=!0,this.heightDirty=!0,t=!0;t&&this.render(!0)};getScrollAnchorViewportTop(e,t){return e<t?t+this.getStickyHeaderOffset():t}getScrollAnchor(e,t=this.idToItem){let n=this.header.element!=null&&this.header.element.getBoundingClientRect().height!==this.header.height,r=e=>(n||(this.headerResizeAnchor=e==null?void 0:{anchor:e,item:this.idToItem.get(e.id)}),e),i,{pendingLayoutAnchor:a}=this;if(a!=null){let e=this.idToItem.get(a.id);if(e!=null&&t.get(a.id)===e)return r(a);e!=null&&(i=e)}let o=this.headerResizeAnchor;if(n&&this.pendingScrollTarget==null&&o!=null&&this.idToItem.get(o.anchor.id)===o.item&&t.get(o.anchor.id)===o.item)return o.anchor;if(e<=0)return r(void 0);let{firstIndex:s,lastIndex:c,stickyTop:l,stickyBottom:u}=this.renderState;if(s===-1||c===-1)return;let d=this.getHeight();if(l!==-1&&u!==-1){for(let n=s;n<=c;n++){let a=this.items[n];if(a==null)continue;let o=this.getItemTopOffset()+a.top;if(o+a.height<=e)continue;if(o>=e+d)break;if(t.get(a.item.id)!==a){i??=a;continue}if(o>=e)return r({type:`item`,id:a.item.id,viewportOffset:o-e});let s=this.getScrollAnchorViewportTop(o,e)-o,c=a.instance.getNumericScrollAnchor(s);if(c!=null){let t=o+c.top;return r({type:`line`,id:a.item.id,lineNumber:c.lineNumber,side:c.side,viewportOffset:t-e})}}if(i!=null)for(let e=i.index+1;e<this.items.length;e++){let n=this.items[e];if(n!=null&&t.get(n.item.id)===n)return r({type:`item`,id:n.item.id,viewportOffset:0})}return r(void 0)}}resolveAnchoredScrollTop(e){let t=this.idToItem.get(e.id);if(t==null)return;let n=this.getItemTopOffset();if(e.type===`item`){let r=n+t.top;return this.clampScrollTop(r-e.viewportOffset)}let r=t.type===`diff`?t.instance.getLinePosition(e.lineNumber,e.side):t.instance.getLinePosition(e.lineNumber);if(r==null)return;let i=n+t.top+r.top;return this.clampScrollTop(i-e.viewportOffset)}applyScrollFix(e,t,n){if(this.root==null)return;let r=_u(this.clampScrollTop(e)),i=_u(t),{scrollPageOffset:a}=this,o=_u(this.clampPagedScrollTop(i-a)),{pagedScrollTop:s,scrollPageOffset:c}=this.resolvePagedScrollPosition(r),l=s,u=a!==c;(r!==this.renderState.scrollTop||r!==i||l!==o||u)&&(this.suspendScrollInteractions(),(l!==o||u)&&(this.scrollPageOffset=c,this.syncPagedScrollScaffolding(n)),l!==o&&this.root.scrollTo({top:l,behavior:`instant`}),this.renderState.scrollTop=r,this.scrollTop=r,this.scrollDirty=!1)}isPendingTargetSettled(e){let t=this.resolveScrollTargetTop(e);return t==null||_u(this.getScrollTop())===_u(t)}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root?.scrollTop??0;return this.scrollTop=this.clampScrollTop(e+this.scrollPageOffset),this.scrollTop}getHeight(){return this.heightDirty&&(this.heightDirty=!1,this.height=this.root?.getBoundingClientRect().height??0),this.height}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;let e=this.buildSlotSnapshot(this.slotCoordinator);(this.slotSnapshotStale||!pu(this.slotSnapshot,e))&&(this.slotSnapshotStale=!1,this.slotSnapshot=e,this.slotCoordinator.onSnapshotChange(e))}notifyScroll(){if(this.scrollListeners.size===0)return;let e=this.getScrollTop();for(let t of this.scrollListeners)t(e,this)}findFirstVisibleIndex(e){let t=0,n=this.items.length-1,r=this.items.length;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findFirstVisibleIndex: invalid item index`);a.top+a.height>e?(r=i,n=i-1):t=i+1}return r}findLastVisibleIndex(e){let t=0,n=this.items.length-1,r=-1;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findLastVisibleIndex: invalid item index`);a.top<=e?(r=i,t=i+1):n=i-1}return r}recomputeLayout(e=0,t){if(this.items.length===0){this.scrollHeight=0;return}let n=this.getLayout(),r=0;if(e>0){let t=this.items[e-1];if(t==null)throw Error(`CodeView.recomputeLayout: invalid dirty index`);r=t.top+t.height+n.gap}for(let i=e;i<this.items.length;i++){let e=this.items[i];if(e==null)throw Error(`CodeView.recomputeLayout: invalid item index`);e.top=r,e.height=e.type===`diff`?e.instance.updateCodeViewLayout(e.item.fileDiff,r,t,e.item.annotations??[]):e.instance.updateCodeViewLayout(e.item.file,r,t,e.item.annotations??[]),r+=e.height,i<this.items.length-1&&(r+=n.gap)}r!==this.scrollHeight&&(this.scrollDirty=!0),this.scrollHeight=r}resetRenderState(){this.renderState.scrollTop=-1,this.renderState.firstIndex=-1,this.renderState.lastIndex=-1,this.renderState.stickyHeight=0,this.renderState.stickyTop=-1,this.renderState.stickyBottom=-1}getFitPerfectlyOverscroll(){return this.getLayout().gap+this.itemMetricsCache.diffHeaderHeight}};function Zf(e){return e.instance.cleanUp(!0),e.type===`diff`?e.instance.updateCodeViewLayout(e.item.fileDiff,e.top,void 0,e.item.annotations??[]):e.instance.updateCodeViewLayout(e.item.file,e.top,void 0,e.item.annotations??[])}function Qf(e,t){return!to(e.theme??yo,t.theme??yo)||(e.themeType??`system`)!==(t.themeType??`system`)||e.unsafeCSS!==t.unsafeCSS}function $f(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS||(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function ep(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function tp(e){return e instanceof SVGElement||ya(e)&&(e.hasAttribute(`data-core-css`)||e.hasAttribute(`data-theme-css`)||e.hasAttribute(`data-unsafe-css`))}function np(e){let t=rp(e.start,e.side),n=rp(e.end,e.endSide??e.side);return t===n?t:`${t}-${n}`}function rp(e,t){return t==null?`${e}`:`${t===`deletions`?`D`:`A`}${e}`}function ip(e,t,n=!1){return e.type===`diff`?e.instance.render({deferManagers:!0,fileContainer:t,fileDiff:e.item.fileDiff,forceRender:n,lineAnnotations:e.item.annotations??[]}):e.instance.render({deferManagers:!0,fileContainer:t,file:e.item.file,forceRender:n,lineAnnotations:e.item.annotations??[]})}function ap(e,t,n){n==null?e.firstChild!==t&&e.prepend(t):n.nextSibling!==t&&n.after(t)}function op(e){return(e.item.annotations?.length??0)>0||fu(e).lineAnnotations.length>0}function sp(e,{hasHeaderRenderers:t,hasAnnotationRenderer:n,hasGutterRenderer:r}){if(e.length===0)return;if(t||r)return e;if(!n)return;let i=[];for(let t of e)op(t)&&i.push(t);return i.length>0?i:void 0}function cp(e,t){typeof e==`function`?e(t):e!=null&&(e.current=t)}var lp=typeof window>`u`?Q.useEffect:Q.useLayoutEffect;function up(e){return{instance:void 0,items:void 0,controlled:e,managedOptions:void 0,disableFlushSync:!1,slotCoordinator:void 0}}function dp(e,t){let{className:n,containerRef:r,disableWorkerPool:i=!1,editorOptions:a,getEditStateKey:o,initialItems:s,items:c,onItemEditChange:l,onItemEditComplete:u,onScroll:d,onSelectedLinesChange:f,options:p,renderAnnotation:m,renderCodeViewFooter:h,renderCodeViewHeader:g,renderCustomHeader:_,renderGutterUtility:v,renderHeaderFilenameSuffix:y,renderHeaderMetadata:b,renderHeaderPrefix:x,selectedLines:S,style:C}=e,w=c!==void 0,T=pi(),E=(0,Q.useContext)(Rr),D=(0,Q.useRef)(up(w)),O=_!=null,k=m!=null,A=v!=null,j=O||x!=null||y!=null||b!=null,M=j||k||A,N=g!=null,P=h!=null,F=Ii(e=>{f?.(e)}),I=S!==void 0,L=Ii((e,t,n)=>{if(T==null)throw Error(`CodeView: EditContext is not attached`);let r={...a,...t};return T(e,r,n)}),R=Ii((e,t)=>{l?.(e,t)}),z=Ii((e,t,n)=>u?.(e,t,n)??`reject`),B=(0,Q.useMemo)(()=>_p({options:p,hasCustomHeader:O,hasGutterRenderer:A,hasCodeViewHeader:N,hasCodeViewFooter:P,onSelectedLinesChange:f==null?void 0:F,controlledSelection:I,getEditStateKey:o,createEditor:T==null?void 0:L,onItemEditChange:l==null?void 0:R,onItemEditComplete:u==null?void 0:z}),[T,I,L,R,z,F,P,N,O,A,o,l,u,f,p]),[V]=(0,Q.useState)(()=>gp()),[,H]=(0,Q.useState)({}),U=Ii(e=>{D.current.instance!=null&&(e==null||e!==D.current.instance.getContainerElement())&&(D.current.instance.cleanUp(),V.publish(void 0),D.current=up(w)),e!=null&&e!==D.current.instance?.getContainerElement()&&(D.current.instance=new Xf(B,i?void 0:E,!0),D.current.instance.setup(e)),cp(r,e)}),W=Ii(e=>{D.current.disableFlushSync?V.publish(e):(0,ru.flushSync)(()=>{V.publish(e)})}),G=(0,Q.useMemo)(()=>{if(j||k||A||N||P)return{hasHeaderRenderers:j,hasAnnotationRenderer:k,hasGutterRenderer:A,onSnapshotChange:W}},[W,k,A,j,N,P]);return lp(()=>d==null?void 0:D.current.instance?.subscribeToScroll(d)),lp(()=>{let{instance:e,controlled:t,items:n,managedOptions:r,slotCoordinator:i}=D.current;if(e!=null)try{D.current.disableFlushSync=!0;let a=!1;if(us(B,r)||(D.current.managedOptions=B,e.setOptions(B),a=!0),t!==w){console.error(`CodeView: cannot switch between controlled and uncontrolled modes. Remount with a new key instead.`);return}if(w)c!==n&&(mp(n,c)?D.current.items=c:pp(n,c)?(D.current.items=c,e.addItems(c.slice(n.length))):(D.current.items=c,e.setItems(c),a=!0));else if(n==null){let t=s??[];D.current.items=t,t.length>0&&(e.setItems(t),a=!0)}S!==void 0&&e.setSelectedLines(S,{notify:!1});let o=e.setSlotCoordinator(G),l=!1;G!==i&&((G==null||i==null)&&(l=!0),D.current.slotCoordinator=G),(a||o)&&e.render(!0),o&&G==null&&V.publish(void 0),l&&H({})}finally{D.current.disableFlushSync=!1}}),(0,Q.useImperativeHandle)(t,()=>({addItems(e){let{controlled:t,instance:n}=D.current;hp(t,`addItems`),n==null?console.error(`CodeView.addItems: no valid instance to append items with`,e):n.addItems(e)},getItem(e){let{instance:t}=D.current;if(t==null)console.error(`CodeView.getItem: no valid instance exists`,e);else return t.getItem(e)},removeItem(e){let{controlled:t,instance:n}=D.current;return hp(t,`removeItem`),n==null?(console.error(`CodeView.removeItem: no valid instance to remove item from`,e),!1):n.removeItem(e)},updateItem(e){let{controlled:t,instance:n}=D.current;return hp(t,`updateItem`),n==null?(console.error(`CodeView.updateItem: no valid instance to update item with`,e),!1):n.updateItem(e)},updateItemId(e,t){let{controlled:n,instance:r}=D.current;return hp(n,`updateItemId`),r==null?(console.error(`CodeView.updateItemId: no valid instance to update item id with`,e,t),!1):r.updateItemId(e,t)},scrollTo(e){let{instance:t}=D.current;t==null?console.error(`CodeView.scrollTo: no valid instance to scroll with`,e):t.scrollTo(e)},setSelectedLines(e){let{instance:t}=D.current;t==null?console.error(`CodeView.setSelectedLines: no valid instance to update selection with`,e):(t.setSelectedLines(e,{notify:!1}),F(e))},getSelectedLines(){let{instance:e}=D.current;return e==null?(console.error(`CodeView.getSelectedLines: no valid instance exists`),null):e.getSelectedLines()},clearSelectedLines(){let{instance:e}=D.current;e==null?console.error(`CodeView.clearSelectedLines: no valid instance to update selection with`):(e.clearSelectedLines({notify:!1}),F(null))},getEditor(e){let{instance:t}=D.current;if(t==null)console.error(`CodeView.getEditor: no valid instance exists`,e);else return t.getEditor(e)},getInstance(){return D.current.instance}}),[F]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{ref:U,className:n,style:C}),(M||N||P)&&(0,Z.jsx)(vp,{managedContentStore:V,renderCustomHeader:_,renderHeaderPrefix:x,renderHeaderFilenameSuffix:y,renderHeaderMetadata:b,renderAnnotation:m,renderGutterUtility:v,renderCodeViewHeader:g,renderCodeViewFooter:h})]})}var fp=(0,Q.forwardRef)(dp);function pp(e,t){if(e==null||t.length<=e.length)return!1;if(e.length===0)return!0;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return!1;return!0}function mp(e,t){if(e==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function hp(e,t){if(e)throw Error(`CodeView.${t} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`)}function gp(){let e,t=new Set;return{getSnapshot(){return e},publish(n){if(e!==n){e=n;for(let e of t)e()}},subscribe(e){return t.add(e),()=>{t.delete(e)}}}}function _p({options:e,hasCustomHeader:t,hasGutterRenderer:n,hasCodeViewHeader:r,hasCodeViewFooter:i,onSelectedLinesChange:a,controlledSelection:o,getEditStateKey:s,createEditor:c,onItemEditChange:l,onItemEditComplete:u}){let d={...e,controlledSelection:o,onSelectedLinesChange:a,createEditor:c};return s!=null&&(d.getEditStateKey=s),l!=null&&(d.onItemEditChange=l),u!=null&&(d.onItemEditComplete=u),t&&(d.renderCustomHeader=xp),n&&(d.renderGutterUtility=xp),r&&(d.renderCodeViewHeader=xp),i&&(d.renderCodeViewFooter=xp),d}var vp=(0,Q.memo)(function({managedContentStore:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o,renderCodeViewHeader:s,renderCodeViewFooter:c}){"use no memo";let l=Ii(t=>e.subscribe(t)),u=Ii(()=>e.getSnapshot()),d=(0,Q.useSyncExternalStore)(l,u,u),f=(0,Q.useMemo)(()=>{let e={renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o};return d?.items?.map(t=>(0,ru.createPortal)(t.type===`diff`?(0,Z.jsx)(yp,{version:t.version??0,item:t.item,getHoveredLine:t.instance.getHoveredLine,getAnnotationSlotName:t.instance.getAnnotationSlotName,...fu(t),...e}):(0,Z.jsx)(bp,{version:t.version??0,item:t.item,getHoveredLine:t.instance.getHoveredLine,getAnnotationSlotName:t.instance.getAnnotationSlotName,...fu(t),...e}),t.element,t.id))},[t,n,r,i,a,o,d?.items]),p=(0,Q.useMemo)(()=>s!=null&&d?.header!=null?(0,ru.createPortal)(s(),d.header):null,[s,d?.header]),m=(0,Q.useMemo)(()=>c!=null&&d?.footer!=null?(0,ru.createPortal)(c(),d.footer):null,[c,d?.footer]);return(0,Z.jsxs)(Z.Fragment,{children:[f,p,m]})}),yp=(0,Q.memo)(function({item:e,fileDiff:t,lineAnnotations:n,getHoveredLine:r,getAnnotationSlotName:i,renderCustomHeader:a,renderHeaderPrefix:o,renderHeaderFilenameSuffix:s,renderHeaderMetadata:c,renderAnnotation:l,renderGutterUtility:u}){return uu({fileDiff:t,renderCustomHeader:a==null?void 0:()=>a(e),renderHeaderPrefix:o==null?void 0:()=>o(e),renderHeaderFilenameSuffix:s==null?void 0:()=>s(e),renderHeaderMetadata:c==null?void 0:()=>c(e),renderAnnotation:l==null?void 0:(t,n)=>l(t,n,e),lineAnnotations:n,renderGutterUtility:u==null?void 0:t=>u(t,e),getHoveredLine:r,getAnnotationSlotName:i})}),bp=(0,Q.memo)(function({item:e,file:t,lineAnnotations:n,getHoveredLine:r,getAnnotationSlotName:i,renderCustomHeader:a,renderHeaderPrefix:o,renderHeaderFilenameSuffix:s,renderHeaderMetadata:c,renderAnnotation:l,renderGutterUtility:u}){return Yi({file:t,renderCustomHeader:a==null?void 0:()=>a(e),renderHeaderPrefix:o==null?void 0:()=>o(e),renderHeaderFilenameSuffix:s==null?void 0:()=>s(e),renderHeaderMetadata:c==null?void 0:()=>c(e),renderAnnotation:l==null?void 0:(t,n)=>l(t,n,e),lineAnnotations:n,renderGutterUtility:u==null?void 0:t=>u(t,e),getHoveredLine:r,getAnnotationSlotName:i})});function xp(){}var $=Ue();function Sp(e){let t=(0,$.c)(4),{children:n}=e,r,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={poolSize:4,workerFactory:Cp},i={theme:ps,preferredHighlighter:jo},t[0]=r,t[1]=i):(r=t[0],i=t[1]);let a;return t[2]===n?a=t[3]:(a=(0,Z.jsx)(ga,{poolOptions:r,highlighterOptions:i,children:n}),t[2]=n,t[3]=a),a}function Cp(){return new Worker(new URL(`/assets/worker-CcC2iNVI.js`,``+import.meta.url),{type:`module`})}var wp={added:`Added`,modified:`Modified`,deleted:`Deleted`,renamed:`Renamed`,"type-changed":`Type changed`};function Tp(e,t){if(e.status===`renamed`&&e.previousPath!==null&&e.previousPath!==void 0)return`Renamed from ${e.previousPath}`;let n=wp[e.status];return e.path===t?n:`${n} as ${e.path}`}function Ep(e){return e.body===null||e.body===void 0?e.subject:`${e.subject}\n\n${e.body}`}function Dp(e){return[...new Set([e.oldPath,e.newPath].filter(e=>e!=null))]}function Op(e){return e.newPath??e.oldPath??`Unknown path`}var kp=7;function Ap(e){return e.slice(0,kp)}function jp(e){return e.replace(/^refs\/(?:heads|remotes|tags)\//u,``)}function Mp(e){return e.filter(e=>e.kind!==`head`)}function Np(e,t){return e.kind===`local-branch`&&`refs/heads/${e.name}`===t}function Pp(e){switch(e?.head.kind){case`attached`:return jp(e.head.ref);case`unborn`:return`No commits yet on ${jp(e.head.ref)}`;case`detached`:return`Detached HEAD`;default:return`This branch`}}function Fp(e){return e===`shallow`?`Shallow clone: older history is not available.`:e===`wide`?`Too many branches meet here to continue past this point.`:`Start of history.`}function Ip(e,t){return e==null?{name:Pp(t),counts:null,upstream:`Branch status unavailable`}:e.name?e.upstream?{name:e.name,counts:`${e.ahead} ahead · ${e.behind} behind`,upstream:`against ${e.upstream}`}:{name:e.name,counts:null,upstream:`No upstream`}:{name:`Detached HEAD`,counts:null,upstream:`No branch checked out`}}var Lp={kind:`handoff`},Rp={kind:`all-changes`},zp={kind:`specs`},Bp={kind:`branch`},Vp={kind:`graph`};function Hp(e){switch(e.kind){case`handoff`:return`handoff`;case`walkthrough`:return`walkthrough`;case`all-changes`:return`all-changes`;case`walkthrough-changes`:return`walkthrough-changes`;case`specs`:return`specs`;case`change`:return`change:${e.path}`;case`file`:return`file:${e.path}`;case`commit`:return`commit:${e.oid}`;case`pull-request`:return`pull-request:${e.projectId}:${e.number}${e.environmentId?`:environment=${encodeURIComponent(e.environmentId)}`:``}`;case`branch`:return`branch`;case`branch-file`:return`branch:${e.path}`;case`graph`:return`graph`;case`timeline`:return`timeline:${e.path}`;case`walkthrough-step`:return`walkthrough-step:${e.step}`}}function Up(e){if(e==null||e===``)return null;if(e===`handoff`)return Lp;if(e===`walkthrough`)return{kind:`walkthrough`};if(e===`all-changes`)return Rp;if(e===`walkthrough-changes`)return{kind:`walkthrough-changes`};if(e===`specs`)return zp;if(e===`branch`)return Bp;if(e===`graph`)return Vp;let t=e.indexOf(`:`);if(t<=0)return null;let n=e.slice(0,t),r=e.slice(t+1);if(r===``)return null;switch(n){case`change`:case`file`:case`timeline`:return{kind:n,path:r};case`branch`:return{kind:`branch-file`,path:r};case`walkthrough-step`:return/^[1-9][0-9]*$/.test(r)&&Number.isSafeInteger(Number(r))?{kind:n,step:Number(r)}:null;case`commit`:return/^[0-9a-f]{4,64}$/.test(r)?{kind:n,oid:r}:null;case`pull-request`:{let[e,t,i,a]=r.split(`:`);return e!==void 0&&e.length>0&&t!==void 0&&a===void 0&&(i===void 0||/^environment=[a-zA-Z0-9_-]+$/.test(i))&&/^[1-9][0-9]*$/.test(t)&&Number.isSafeInteger(Number(t))?{kind:n,projectId:e,number:Number(t),...i?{environmentId:i.slice(12)}:{}}:null}default:return null}}function Wp(e,t,n){if(e.includes(t))return[...e];let r=n==null?-1:e.indexOf(n),i=[...e];return i.splice(r===-1?i.length:r+1,0,t),i}var Gp={changes:`Changes`,files:`Files`,history:`History`};function Kp(e){switch(e.kind){case`handoff`:return`Changes`;case`walkthrough`:return`Walkthrough`;case`all-changes`:case`walkthrough-changes`:return`All changes`;case`specs`:return`Specs`;case`branch`:return`Branch changes`;case`graph`:return`Commit graph`;case`commit`:return Ap(e.oid);case`pull-request`:return`PR #${e.number}`;case`change`:case`file`:case`branch-file`:return e.path.split(`/`).at(-1)??e.path;case`timeline`:return`Timeline of ${e.path.split(`/`).at(-1)??e.path}`;case`walkthrough-step`:return`Step ${e.step}`}}function qp(e){let t=Up(e.entry),n=(e.firstDocument!==void 0&&(!t||t.kind===`walkthrough`)?e.firstDocument:void 0)??(t?Kp(t):Gp[e.surface??`files`]),r=e.project?`${n} — ${e.project}`:n;return e.environment?`${r} · ${e.environment}`:r}function Jp(e,t){let n=(0,$.c)(9),r;n[0]!==t.connection||n[1]!==e?(r=gn({connection:t.connection,scope:e}),n[0]=t.connection,n[1]=e,n[2]=r):r=n[2];let i;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(i={mode:`promiseExit`},n[3]=i):i=n[3];let[a,o]=L(r,i),s;n[4]===o?s=n[5]:(s=e=>{o(e)},n[4]=o,n[5]=s);let c;return n[6]!==a||n[7]!==s?(c={result:a,dismiss:s},n[6]=a,n[7]=s,n[8]=c):c=n[8],c}function Yp(e){let t=new Map;for(let n of e){let e=n.id.split(`:`)[0]||n.id,r=t.get(e)??[];r.push(n),t.set(e,r)}return[...t.entries()]}function Xp(e,t){let n=e?.filter(e=>!e.id.endsWith(`:default`));return n?.find(e=>e.id===t)?.id??n?.find(e=>/^codex:(?:.*-)?luna(?:-|$)/.test(e.id))?.id??n?.find(e=>e.id===`claude:haiku`)?.id??n?.find(e=>e.id===`claude:sonnet`)?.id}function Zp(e){return e.split(`/`).at(-1)??e}function Qp(e,t){let{message:n,stashOid:r,option:i}=t;return e===`stash-create`?{action:e,message:n,includeUntracked:i}:{action:e,stashOid:r,restoreIndex:i}}function $p(e,t,n){return{mode:e===`amend`?`amend`:`single`,message:e===`commit`?t:``,amendMessage:e===`amend`?t:n,excluded:new Set,added:new Set,groups:null}}function em(e,t,n=new Set){return t.some(t=>!n.has(t.path)&&e.files?.find(e=>e.path===t.path)?.fingerprint!==t.fingerprint)}var tm=[{id:`commit`,label:`Commit…`,description:`Commit selected files`},{id:`amend`,label:`Amend last commit…`,description:`Replace the latest commit`},{id:`push`,label:`Push`,description:`Send committed changes`},{id:`pull`,label:`Pull`,description:`Bring in upstream changes`},{id:`fetch`,label:`Fetch`,description:`Update a remote-tracking branch`},{id:`stash-create`,label:`Stash changes`,description:`Set aside local changes`},{id:`stash-apply`,label:`Apply stash`,description:`Restore a stash and keep it`},{id:`stash-pop`,label:`Pop stash`,description:`Restore, then remove a stash`}],nm=[{id:`commit`,actions:[tm[0],tm[1]]},{id:`sync`,actions:[tm[2],tm[3],tm[4]]},{id:`stash`,actions:[tm[5],tm[7]]}];function rm(e){return tm.find(t=>t.id===e)?.label}function im(e,t,n){return e===`pull`&&n?n:je(e,t)}function am(e){let t=(0,$.c)(17),{scope:n,context:r}=e,{connection:i}=r,a=Nt(bt(oa(n,i))),o=Jp(n,r),s=a?.interrupted;if(!s)return null;let c=s.action.replaceAll(`-`,` `),l;t[0]===c?l=t[1]:(l=(0,Z.jsxs)(`p`,{className:`font-medium`,children:[`A Git action was interrupted:`,` `,c]}),t[0]=c,t[1]=l);let u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`Check the current changes before trying again.`}),t[2]=u):u=t[2];let d;t[3]===o.result?d=t[4]:(d=Qt(o.result)&&(0,Z.jsx)(`p`,{role:`alert`,className:`mt-1 text-destructive`,children:Sn(En(o.result.cause))}),t[3]=o.result,t[4]=d);let f;t[5]!==d||t[6]!==l?(f=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[l,u,d]}),t[5]=d,t[6]=l,t[7]=f):f=t[7];let p;t[8]!==o||t[9]!==s.requestId?(p=()=>o.dismiss(s.requestId),t[8]=o,t[9]=s.requestId,t[10]=p):p=t[10];let m;t[11]!==o.result.waiting||t[12]!==p?(m=(0,Z.jsx)(Y,{size:`xs`,variant:`ghost`,disabled:o.result.waiting,onClick:p,children:`Got it`}),t[11]=o.result.waiting,t[12]=p,t[13]=m):m=t[13];let h;return t[14]!==f||t[15]!==m?(h=(0,Z.jsxs)(`div`,{role:`status`,className:`flex shrink-0 items-start gap-3 border-b border-graph-4/20 bg-graph-4/10 px-3 py-2 text-xs`,children:[f,m]}),t[14]=f,t[15]=m,t[16]=h):h=t[16],h}function om(e){let t=(0,$.c)(23),{scope:n,context:r,onOpen:i}=e,{connection:a}=r,o=Nt(bt(oa(n,a))),s=o?.inProgress;if(!s)return null;let c=o.changes.filter(sm),l=`${s===`merge`?`Merge`:`Rebase`} recovery`,u=s===`merge`?`Merge`:`Rebase`,d=c.length?`is waiting for conflict resolution`:`is ready to finish`,f;t[0]!==u||t[1]!==d?(f=(0,Z.jsxs)(`p`,{className:`font-medium`,children:[u,` `,d]}),t[0]=u,t[1]=d,t[2]=f):f=t[2];let p=c.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:c.map(e=>(0,Z.jsx)(Y,{size:`xs`,variant:`outline`,onClick:()=>i({kind:`file`,path:e.path}),children:e.path},e.path))}),m=s===`merge`&&o.mergeHeadOid?`Use Commit from the Git menu to finish. The merge commit includes every staged resolution.`:`Stage the resolved files, then continue in a terminal in this worktree.`,h;t[3]===m?h=t[4]:(h=(0,Z.jsxs)(`p`,{children:[`Resolve the files in your editor or with your agent.`,` `,m]}),t[3]=m,t[4]=h);let g;t[5]===s?g=t[6]:(g=s===`rebase`&&(0,Z.jsx)(lm,{command:`git rebase --continue`}),t[5]=s,t[6]=g);let _;t[7]!==o||t[8]!==s?(_=s===`merge`&&!o.mergeHeadOid&&(0,Z.jsx)(lm,{command:`git commit`}),t[7]=o,t[8]=s,t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(`span`,{children:`To back out:`}),t[10]=v):v=t[10];let y=`git ${s} --abort`,b;t[11]===y?b=t[12]:(b=(0,Z.jsx)(lm,{command:y}),t[11]=y,t[12]=b);let x;t[13]!==_||t[14]!==b||t[15]!==g?(x=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[g,_,v,b]}),t[13]=_,t[14]=b,t[15]=g,t[16]=x):x=t[16];let S;return t[17]!==l||t[18]!==x||t[19]!==f||t[20]!==p||t[21]!==h?(S=(0,Z.jsxs)(`section`,{"aria-label":l,className:`shrink-0 space-y-2 border-b border-graph-4/20 bg-graph-4/10 px-3 py-2 text-xs`,children:[f,p,h,x]}),t[17]=l,t[18]=x,t[19]=f,t[20]=p,t[21]=h,t[22]=S):S=t[22],S}function sm(e){return e.comparisons.some(cm)}function cm(e){return e.scope===`unmerged`}function lm(e){let t=(0,$.c)(8),{command:n}=e,r=`Copy ${n}`,i,a;t[0]===n?(i=t[1],a=t[2]):(i=()=>ht(n,`command`),a=(0,Z.jsx)(`code`,{children:n}),t[0]=n,t[1]=i,t[2]=a);let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(De,{}),t[3]=o):o=t[3];let s;return t[4]!==r||t[5]!==i||t[6]!==a?(s=(0,Z.jsxs)(Y,{size:`xs`,variant:`outline`,"aria-label":r,onClick:i,children:[a,o]}),t[4]=r,t[5]=i,t[6]=a,t[7]=s):s=t[7],s}function um(e,t){let n=(0,$.c)(5),r;if(n[0]!==t||n[1]!==e.state){let i;n[3]===t?i=n[4]:(i=e=>e.operations.get(t)??null,n[3]=t,n[4]=i),r=e.state.map(i),n[0]=t,n[1]=e.state,n[2]=r}else r=n[2];return Te(r)}var dm=x(e=>de({done:new Set,activeGroup:null,ownHead:null,busy:!1,error:null,drafted:{message:null,groups:null},draftedBy:{message:null,groups:null},editingFiles:!1})),fm=x(e=>new Set);function pm(e,t,n){let i=(0,$.c)(14),{connection:a}=n,{operations:o}=a,s;i[0]!==t||i[1]!==e?(s=hn(e,t),i[0]=t,i[1]=e,i[2]=s):s=i[2];let c=s,l;i[3]!==c||i[4]!==o.state.value.operations?(l=()=>{let e=o.state.value.operations.get(c);return e?.receipt&&Jt(e.receipt)?e.requestId:null},i[3]=c,i[4]=o.state.value.operations,i[5]=l):l=i[5];let[u]=(0,Q.useState)(l),d=um(o,c),f=d?.requestId===u?null:d,p={connection:a,scope:e,action:t},{value:m}=is(tt(p)),h=r(p),g=Se(p),_=N(h),v=N(g),y;i[6]===f?y=i[7]:(y=f?.receipt&&Jt(f.receipt),i[6]=f,i[7]=y);let b=!!y,x;return i[8]!==m||i[9]!==_||i[10]!==f||i[11]!==v||i[12]!==b?(x={...m,execution:_,recovered:v,operation:f,canStartNew:b},i[8]=m,i[9]=_,i[10]=f,i[11]=v,i[12]=b,i[13]=x):x=i[13],x}var mm=x(({signal:e,submit:t,recover:n})=>u(r=>{e!==void 0&&(r.set(t,ye),r.set(n,ye))}));function hm(e,n,r){let i=(0,$.c)(45),{path:a,hunk:o,signal:s,what:u,look:d,readChanges:f,notify:p,dismissNotice:m,close:h}=r,g=pm(e,`discard`,n),_=pm(e,`stash-apply`,n),v=!(!g.operation||g.canStartNew),y;i[0]===f?y=i[1]:(y=()=>t({try:f,catch:xm}),i[0]=f,i[1]=y);let b;i[2]!==h||i[3]!==m||i[4]!==p||i[5]!==_||i[6]!==y||i[7]!==u?(b={what:u,readChanges:y,notify:p,dismissNotice:m,close:h,restore:_,restoreTimeoutMs:l,run:cn},i[2]=h,i[3]=m,i[4]=p,i[5]=_,i[6]=y,i[7]=u,i[8]=b):b=i[8];let x=b,[S]=(0,Q.useState)(ym),[C]=(0,Q.useState)(_m),w;i[9]===Symbol.for(`react.memo_cache_sentinel`)?(w={mode:`promiseExit`},i[9]=w):w=i[9];let[T,E]=L(S,w),D;i[10]===Symbol.for(`react.memo_cache_sentinel`)?(D={mode:`promiseExit`},i[10]=D):D=i[10];let[O,k]=L(C,D),A=c(S),j=c(C),M;i[11]!==C||i[12]!==s||i[13]!==S?(M=mm({signal:s,submit:S,recover:C}),i[11]=C,i[12]=s,i[13]=S,i[14]=M):M=i[14],ie(M);let N=T.waiting||O.waiting,P=gm,F;i[15]!==O||i[16]!==T?(F=P(T)??P(O),i[15]=O,i[16]=T,i[17]=F):F=i[17];let I;i[18]!==j||i[19]!==A?(I=()=>{A(ye),j(ye)},i[18]=j,i[19]=A,i[20]=I):I=i[20];let R;i[21]!==N||i[22]!==g||i[23]!==x||i[24]!==o||i[25]!==d||i[26]!==a||i[27]!==j||i[28]!==E||i[29]!==v?(R=()=>{N||v||!d||(j(ye),E({run:()=>g.run({action:`discard`,path:a,...o?{hunk:o}:{}},wt(d,[a])),discarding:x}))},i[21]=N,i[22]=g,i[23]=x,i[24]=o,i[25]=d,i[26]=a,i[27]=j,i[28]=E,i[29]=v,i[30]=R):R=i[30];let z;i[31]!==N||i[32]!==g.recover||i[33]!==x||i[34]!==k||i[35]!==A?(z=()=>{N||(A(ye),k({recover:g.recover,discarding:x}))},i[31]=N,i[32]=g.recover,i[33]=x,i[34]=k,i[35]=A,i[36]=z):z=i[36];let B;return i[37]!==N||i[38]!==g.operation||i[39]!==F||i[40]!==I||i[41]!==R||i[42]!==z||i[43]!==v?(B={operation:g.operation,uncertain:v,busy:N,error:F,reset:I,run:R,checkOutcome:z},i[37]=N,i[38]=g.operation,i[39]=F,i[40]=I,i[41]=R,i[42]=z,i[43]=v,i[44]=B):B=i[44],B}function gm(e){return Nt(bt(e))??(Qt(e)?{text:Sn(En(e.cause)),moved:!1}:null)}function _m(){return z(vm)}function vm(e){return Fe(e.recover(),e.discarding)}function ym(){return z(bm)}function bm(e){return Fe(e.run(),e.discarding)}function xm(e){return new Ht(e,Sn(e))}function Sm({text:e}){return e.split(/`([^`\n]+)`/).map((e,t)=>t%2?(0,Z.jsx)(`code`,{className:`box-decoration-clone rounded bg-muted px-1 py-0.5 font-mono text-[0.9em]`,children:e},t):e)}function Cm(e){let t=(0,$.c)(6),{text:n,children:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Ga,{className:`mt-0.5 size-4 shrink-0`}),t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=(0,Z.jsx)(Sm,{text:n}),t[1]=n,t[2]=a);let o;return t[3]!==r||t[4]!==a?(o=(0,Z.jsxs)(`p`,{role:`alert`,className:`flex gap-2 text-sm text-destructive`,children:[i,(0,Z.jsxs)(`span`,{children:[a,r]})]}),t[3]=r,t[4]=a,t[5]=o):o=t[5],o}function wm(e){let t=(0,$.c)(48),{scope:n,context:r,path:i,hunk:a,variant:o,signal:s,hiddenTrigger:c,children:l}=e,u=o===void 0?`button`:o,d=c!==void 0&&c,{connection:f}=r,p=Nt(bt(oa(n,f))),m=gi(n,f),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(null),y=p,b=y?un(y):null,x=y?.changes.find(e=>e.path===i),S=_??b,C;t[0]===a?C=t[1]:(C=a?Om(a):null,t[0]=a,t[1]=C);let w=C,T;t[2]!==w||t[3]!==i?(T=w?`${w} of ${Zp(i)}`:Zp(i),t[2]=w,t[3]=i,t[4]=T):T=t[4];let E=T,D;t[5]===g?D=t[6]:(D=()=>g(!1),t[5]=g,t[6]=D);let O;t[7]!==S||t[8]!==a||t[9]!==i||t[10]!==m||t[11]!==s||t[12]!==D||t[13]!==E?(O={path:i,hunk:a,signal:s,what:E,look:S,readChanges:m,notify:Dm,dismissNotice:Em,close:D},t[7]=S,t[8]=a,t[9]=i,t[10]=m,t[11]=s,t[12]=D,t[13]=E,t[14]=O):O=t[14];let k=hm(n,r,O),{busy:A,error:j,uncertain:M}=k,N=!!(S&&(x||h)),[P,F]=(0,Q.useState)();s!==void 0&&s!==P&&b&&(F(s),v(b),g(!0));let I;t[15]!==k||t[16]!==d||t[17]!==a||t[18]!==w||t[19]!==i||t[20]!==g||t[21]!==v||t[22]!==N||t[23]!==b||t[24]!==u?(I=N&&!d?(0,Z.jsxs)(Y,{size:u===`button`?`sm`:`xs`,variant:u===`button`?`destructive`:`ghost`,"aria-label":a?`Discard ${w} of ${Zp(i)}`:`Discard changes to ${Zp(i)}`,onClick:()=>{k.reset(),v(b),g(!0)},children:[(0,Z.jsx)(Rc,{}),km(u)]}):null,t[15]=k,t[16]=d,t[17]=a,t[18]=w,t[19]=i,t[20]=g,t[21]=v,t[22]=N,t[23]=b,t[24]=u,t[25]=I):I=t[25];let L=I,R;t[26]!==A||t[27]!==k.checkOutcome||t[28]!==k.operation?.receipt||t[29]!==k.run||t[30]!==j||t[31]!==a||t[32]!==h||t[33]!==i||t[34]!==g||t[35]!==N||t[36]!==M||t[37]!==E?(R=N?(0,Z.jsx)(Vr,{open:h,onOpenChange:e=>!A&&g(e),children:(0,Z.jsxs)(la,{children:[(0,Z.jsxs)(nr,{children:[(0,Z.jsxs)(Ar,{children:[`Discard `,E,`?`]}),(0,Z.jsx)(Wr,{children:a?`Select one complete changed hunk. Only that hunk is reverted; partial selections are refused. A recovery copy is saved first.`:`The file goes back to the last commit. You can restore the changes.`})]}),(0,Z.jsx)(X,{className:`rounded-lg bg-muted/50 px-3 py-2 font-mono text-xs`,render:(0,Z.jsx)(`p`,{}),text:i}),j&&(0,Z.jsx)(Cm,{text:j.text,children:j.moved?` Look at the diff again before discarding.`:``}),k.operation?.receipt?.progress.map(Tm),M&&!k.operation?.receipt&&(0,Z.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`The response was lost. Check the existing discard request before trying again.`}),(0,Z.jsxs)(ar,{children:[(0,Z.jsx)($n,{disabled:A,children:j?.moved?`Look again`:`Cancel`}),!j?.moved&&(M?(0,Z.jsx)(Y,{disabled:A,onClick:k.checkOutcome,children:A?`Checking…`:`Check outcome`}):(0,Z.jsx)(Y,{variant:`destructive`,disabled:A,onClick:k.run,children:A?`Discarding…`:`Discard`}))]})]})}):null,t[26]=A,t[27]=k.checkOutcome,t[28]=k.operation?.receipt,t[29]=k.run,t[30]=j,t[31]=a,t[32]=h,t[33]=i,t[34]=g,t[35]=N,t[36]=M,t[37]=E,t[38]=R):R=t[38];let z=R;if(l){let e;t[39]!==l||t[40]!==L?(e=l(L),t[39]=l,t[40]=L,t[41]=e):e=t[41];let n;return t[42]!==z||t[43]!==e?(n=(0,Z.jsxs)(Z.Fragment,{children:[e,z]}),t[42]=z,t[43]=e,t[44]=n):n=t[44],n}let B;return t[45]!==z||t[46]!==L?(B=(0,Z.jsxs)(Z.Fragment,{children:[L,z]}),t[45]=z,t[46]=L,t[47]=B):B=t[47],B}function Tm(e){return(0,Z.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:e},e)}function Em(e){return bo.close(e)}function Dm(e){return bo.add(e)}function Om({startLine:e,endLine:t}){return e===t?`line ${e}`:`lines ${e}–${t}`}function km(e){return e===`quiet`?(0,Z.jsx)(`span`,{className:`max-narrow:sr-only`,children:`Discard`}):e===`compact`?`Discard selection`:`Discard`}var Am=zt(`flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`*:data-slot:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-md! [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0`,vertical:`flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-md! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0`}},defaultVariants:{orientation:`horizontal`}});function jm({className:e,orientation:t,...n}){return(0,Z.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":t,className:q(Am({orientation:t}),e),...n})}function Mm(e,n,r){let i=(0,$.c)(32),a=pm(e,`fetch`,n),o=pm(e,`pull`,n),s=pm(e,`push`,n),c=pm(e,`stash-apply`,n),l;i[0]===r.details?l=i[1]:(l=()=>t({try:r.details.read,catch:Fm}),i[0]=r.details,i[1]=l);let u;i[2]!==r.details||i[3]!==l?(u={...r.details,read:l},i[2]=r.details,i[3]=l,i[4]=u):u=i[4];let d;i[5]!==r||i[6]!==u?(d={...r,details:u},i[5]=r,i[6]=u,i[7]=d):d=i[7];let f=d,p,m;i[8]!==a||i[9]!==o||i[10]!==s?(p={fetch:a,pull:o,push:s},m=[`fetch`,`pull`,`push`].map(e=>({name:e,operation:p[e].operation,canStartNew:p[e].canStartNew,checking:p[e].recovered.waiting})).find(Pm),i[8]=a,i[9]=o,i[10]=s,i[11]=p,i[12]=m):(p=i[11],m=i[12]);let h=m,g;i[13]!==f||i[14]!==p||i[15]!==h?(g=()=>{h&&cn(v(f,p[h.name],h.name))},i[13]=f,i[14]=p,i[15]=h,i[16]=g):g=i[16];let _;i[17]!==f||i[18]!==p?(_=(e,t)=>cn(re(f,p[e],e,t)),i[17]=f,i[18]=p,i[19]=_):_=i[19];let y;i[20]!==f||i[21]!==c?(y=e=>cn(I(f,c,e)),i[20]=f,i[21]=c,i[22]=y):y=i[22];let b;i[23]!==r.onLooked||i[24]!==r.refreshLook?(b=()=>V(_e(t({try:r.refreshLook,catch:Nm}),r.onLooked)),i[23]=r.onLooked,i[24]=r.refreshLook,i[25]=b):b=i[25];let x;return i[26]!==h||i[27]!==g||i[28]!==_||i[29]!==y||i[30]!==b?(x={running:h,checkOutcome:g,runNetwork:_,restoreDiscarded:y,lookAgain:b},i[26]=h,i[27]=g,i[28]=_,i[29]=y,i[30]=b,i[31]=x):x=i[31],x}function Nm(e){return new Ht(e,Sn(e))}function Pm(e){let{operation:t,canStartNew:n}=e;return t!=null&&!n}function Fm(e){return new Ht(e,Sn(e))}function Im(e){let t=(0,$.c)(12),{action:n,className:r}=e;switch(n){case`amend`:{let e;return t[0]===r?e=t[1]:(e=(0,Z.jsx)(Ai,{className:r}),t[0]=r,t[1]=e),e}case`push`:{let e;return t[2]===r?e=t[3]:(e=(0,Z.jsx)(Kr,{className:r}),t[2]=r,t[3]=e),e}case`pull`:case`fetch`:{let e;return t[4]===r?e=t[5]:(e=(0,Z.jsx)(Ks,{className:r}),t[4]=r,t[5]=e),e}case`stash-create`:{let e;return t[6]===r?e=t[7]:(e=(0,Z.jsx)(Ws,{className:r}),t[6]=r,t[7]=e),e}case`stash-apply`:case`stash-pop`:{let e;return t[8]===r?e=t[9]:(e=(0,Z.jsx)(Hs,{className:r}),t[8]=r,t[9]=e),e}default:{let e;return t[10]===r?e=t[11]:(e=(0,Z.jsx)(fc,{className:r}),t[10]=r,t[11]=e),e}}}function Lm(e){if(!e)return null;for(let t of e.elements){let e=t.tagName;if(e===`BUTTON`||e===`INPUT`){let e=t;if(e.type===`submit`)return e}}return null}var Rm=`data-checked`,zm=`data-unchecked`;function Bm(e){return{checked(t){return e.indeterminate?{}:t?{[Rm]:``}:{[zm]:``}},...Ze}}var Vm=Q.createContext(void 0);function Hm(){return Q.useContext(Vm)}var Um=Q.createContext(void 0);function Wm(){let e=Q.useContext(Um);if(e===void 0)throw Error(Vt(14));return e}var Gm=`data-parent`,Km=Q.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":o,disabled:s=!1,form:c,id:l,indeterminate:u=!1,inputRef:d,name:f,onCheckedChange:p,parent:m=!1,readOnly:h=!1,render:g,required:v=!1,uncheckedValue:y,value:b,nativeButton:x=!1,style:S,...w}=e,{clearErrors:T}=fn(),{disabled:E,name:D,setDirty:O,setFilled:j,setFocused:M,setTouched:N,state:I,validationMode:L,validityData:R,validation:z}=W(),B=au(),{labelId:V,registerControlId:H,getDescriptionProps:U}=te(),G=Hm(),ee=G?.allValues===void 0?void 0:G.parent,ne=ee!==void 0,re=E||B.disabled||G?.disabled||s,ie=D??f,ae=b??ie,K=Gt(),oe=G?.registerControlId!==H,q=We({id:l||void 0,enabled:oe}),se=x?q:K,ce={};ne&&(m?ce=ee.getParentProps():ae!==void 0&&(ce=ee.getChildProps(ae)));let{checked:le=n,indeterminate:ue=u,onCheckedChange:de,...J}=ce,fe=G?.value,pe=Q.useRef(null),{getButtonProps:me,buttonRef:he}=Be({disabled:re,native:x}),ge=G?.validation??z,[_e,ye]=Ne({controlled:ae!==void 0&&fe!==void 0&&!m?fe.includes(ae):le,default:i,name:`Checkbox`,state:`checked`}),be=ne?!!le:_e,xe=ne&&ue||u;P(pe,K,_e,void 0,!G&&!re,f);let Se=ee?.registerChildId,Ce=Q.useRef(null),we=ge.registerInput,Te=G?ae:void 0,Ee=Q.useCallback(e=>we(e,{controlRef:pe,value:Te}),[we,Te]),De=Yt(d,Ce,m?void 0:Ee),Oe=k(o,V,Ce,!x,q);a(()=>{Ce.current&&(Ce.current.indeterminate=xe),G||j(_e)},[_e,xe,G,j]),Re(_e,()=>{G||(T(ie),O(_e!==R.initialValue),ge.change(_e))});let ke=xn({checked:_e,disabled:re,form:c,name:m?void 0:ie,id:x?void 0:q,required:v,ref:De,style:ie?ct:It,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(h){e.preventDefault();return}let t=e.currentTarget.checked,n=F(A,e.nativeEvent);if(p?.(t,n),!n.isCanceled&&(de?.(t,n),!n.isCanceled&&(ye(t),ae!==void 0&&G!==void 0&&!m&&!ne))){let e=t?[...G.value,ae]:G.value.filter(e=>e!==ae);G.setValue(e,n)}},onClick(e){e.stopPropagation()},onFocus(){pe.current?.focus()}},b===void 0?ve:{value:(G?_e&&b:b)||``},U,e=>ge.getValidationProps(re,e));Q.useEffect(()=>{if(!ee||ae===void 0)return;let e=ee.disabledStatesRef.current;return e.set(ae,re),()=>{e.delete(ae)}},[ee,re,ae]);let Ae=Q.useMemo(()=>({...I,checked:be,disabled:re,readOnly:h,required:v,indeterminate:xe}),[I,be,re,h,v,xe]),je=Bm(Ae),Me=Ct(`span`,e,{state:Ae,ref:[he,pe,t],props:[{id:se,role:`checkbox`,"aria-checked":xe?`mixed`:be,"aria-readonly":h||void 0,"aria-required":v||void 0,"aria-labelledby":Oe,[Gm]:m?``:void 0,onFocus(){re||M(!0)},onBlur(){let e=Ce.current;e&&(N(!0),M(!1),L===`onBlur`&&ge.commit(G?fe:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=Ce.current?.form??null,n=e.currentTarget,r=e.nativeEvent,i=e.preventDefault,a=r.preventDefault,o=!1;e.preventDefault=()=>{o=!0,i.call(e)},r.preventDefault=()=>{o=!0,a.call(r)},a.call(r),_(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||Lm(t)?.click()})},onClick(e){if(h||re)return;e.preventDefault();let t=Ce.current;t&&C(t,e)}},w,J,me,U,e=>ge.getValidationProps(re,e)],stateAttributesMapping:je}),Pe=Me.props.id;return a(()=>{if(Se&&!m&&ae!==void 0&&Pe!==void 0)return Se(ae,Pe)},[Se,m,ae,Pe]),(0,Z.jsxs)(Um.Provider,{value:Ae,children:[Me,!_e&&!G&&ie&&!m&&y!==void 0&&(0,Z.jsx)(`input`,{type:`hidden`,form:c,name:ie,value:y,disabled:re}),(0,Z.jsx)(`input`,{...ke,suppressHydrationWarning:!0})]})}),qm=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Wm(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=he(c),f=Q.useRef(null),p={...s,transitionStatus:u};be({batch:!0,enabled:!c,open:c,ref:f,onComplete(){c||d(!1)}});let m={...Bm(s),...Kt},h=a||l,g=Ct(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null});function Jm({className:e,...t}){return(0,Z.jsx)(Km,{"data-slot":`checkbox`,className:q(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-shadow outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,Z.jsx)(qm,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,Z.jsx)(g,{})})})}function Ym(e,n,r,i){let a=(0,$.c)(29),{expectedStatus:o,onBusy:s,onLookAgain:l}=i,u=pm(e,n,r),[d]=(0,Q.useState)($m),f;a[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={mode:`promiseExit`},a[0]=f):f=a[0];let[p,m]=L(d,f),h=c(d),g=u.execution.waiting||u.recovered.waiting||p.waiting,_=!(!u.operation||u.canStartNew),v=Qm,y=u.operation?.receipt,b;a[1]!==u.execution||a[2]!==u.recovered||a[3]!==p?(b=v(u.execution)??v(p)??v(u.recovered),a[1]=u.execution,a[2]=u.recovered,a[3]=p,a[4]=b):b=a[4];let x;a[5]!==g||a[6]!==o||a[7]!==u||a[8]!==s||a[9]!==h||a[10]!==_?(x=e=>{g||_||(s(!0),h(ye),u.reset(),cn(u.run(e,wt(o,o.files?.map(Zm)??[],void 0,!0)).pipe(zn($e(()=>s(!1))),w)))},a[5]=g,a[6]=o,a[7]=u,a[8]=s,a[9]=h,a[10]=_,a[11]=x):x=a[11];let S;a[12]!==g||a[13]!==u||a[14]!==l||a[15]!==m?(S=()=>{l&&!g&&(u.reset(),m({read:t({try:l,catch:Xm}),startNew:u.startNew()}))},a[12]=g,a[13]=u,a[14]=l,a[15]=m,a[16]=S):S=a[16];let C;a[17]!==u||a[18]!==h?(C=()=>{u.reset(),h(ye),cn(u.recover().pipe(w))},a[17]=u,a[18]=h,a[19]=C):C=a[19];let T;return a[20]!==g||a[21]!==u.operation||a[22]!==y||a[23]!==b||a[24]!==x||a[25]!==S||a[26]!==C||a[27]!==_?(T={operation:u.operation,messageLimit:mn,outcome:y,busy:g,uncertain:_,error:b,onSubmit:x,lookAgain:S,checkOutcome:C},a[20]=g,a[21]=u.operation,a[22]=y,a[23]=b,a[24]=x,a[25]=S,a[26]=C,a[27]=_,a[28]=T):T=a[28],T}function Xm(e){return new Ht(e,Sn(e))}function Zm(e){return e.path}function Qm(e){return Qt(e)?En(e.cause):null}function $m(){return z(eh)}function eh(e){return le(e.read,e.startNew)}function th(e){let t=[],n=[],r=()=>{let e=t.indexOf(null);return e===-1?(t.push(null),t.length-1):e};for(let i of e){let e=t.flatMap((e,t)=>e===i.oid?[t]:[]);for(let n of e)t[n]=null;let a=e.length>0?Math.min(...e):r(),o=i.parentOids.map((e,n)=>{let i=t.indexOf(e),o=n===0?a:i===-1?r():i;return t[o]=e,o});n.push({commit:i,lane:a,outgoing:o,lanesAfter:[...t]})}return n}function nh(e){let t=e.flatMap(e=>[e.lane,...e.outgoing,...e.lanesAfter.flatMap((e,t)=>e==null?[]:[t])]);return 26+Math.max(0,...t)*16}function rh(e){let t=e%100;return`${e}${t>=11&&t<=13?`th`:[`th`,`st`,`nd`,`rd`][e%10]??`th`}`}function ih(e){let t=oh(e),n=t.at(-1);return{snapshot:t[0]?.snapshot??null,commits:t.flatMap(e=>e.commits),nextAfter:n?.nextAfter??null,boundary:n?.boundary??null,restarted:n?.restarted??!1}}function ah(e){let t=oh(e),n=t.at(-1);return{commits:t.flatMap(e=>e.commits),tip:t[0]?.tip??null,nextAfter:n?.nextAfter??null,boundary:n?.boundary??null,restarted:t[0]?.restarted??!1}}function oh(e){let t=e.findLastIndex(e=>e.restarted);return t===-1?e:e.slice(t)}var sh=x(e=>u({loaded:0,selected:void 0,scrollOffset:0,graphScrollOffset:0,resetId:0}).pipe(Ee)),ch=x(({connection:e,scope:t})=>Oe(e,t,[`history`],n=>dh(n,sh({connection:e,scope:t,kind:`commits`}),n=>Ve(function*(){let r=yield*(yield*H(e)).request(e=>e.changes.listCommits({params:{worktreeId:t.worktreeId},query:{after:n?.after,tip:n?.tip}}));return yield*T(e),r}),e=>e.nextAfter&&e.tip?{after:e.nextAfter,tip:e.tip}:void 0),ln(e))),lh=x(({connection:e,scope:t,oid:n,parent:r=1})=>m(e,t,[`commit`,n,r],Ve(function*(){let i=yield*(yield*H(e)).request(e=>e.changes.readCommitFiles({params:{worktreeId:t.worktreeId,oid:n},query:r===1?{}:{parent:r}}));return yield*T(e,i.commit.oid===n&&(i.comparison.kind===`empty-tree`||i.comparison.parentNumber===r)),i}),ln(e))),uh=x(({connection:e,scope:t,path:n})=>Oe(e,t,[`history`,`file`,n],r=>dh(r,sh({connection:e,scope:t,kind:`file`,path:n}),r=>Ve(function*(){let i=yield*(yield*H(e)).request(e=>e.changes.listFileCommits({params:{worktreeId:t.worktreeId},query:{path:n,limit:100,after:r}}));return yield*T(e),i}),e=>e.nextAfter),ln(e)));function dh(e,t,n,r){let i=e.once(t).loaded,a=0;return bn(void 0,o=>Ve(function*(){let s=[],c=a,l=o,u=!1;do{let e=yield*n(l);e.restarted&&(c=0,u=!0),c+=e.commits.length,s.push(e),l=r(e)}while(o===void 0&&c<i&&l!==void 0&&!u);a=c;let d=e.once(t);return e.set(t,{...d,loaded:a,...u?{selected:void 0,scrollOffset:0,graphScrollOffset:0,resetId:d.resetId+1}:{}}),[s,l===void 0?Ln():pt(l)]}))}var fh=x(e=>Le(uh(e),e=>Tn(e,e=>ah(e.items))).pipe(O(0))),ph=x(e=>Le(ch(e),e=>Tn(e,e=>ih(e.items))).pipe(O(0)));x(e=>K((t,n)=>{let r=sh({...e,kind:`commit`,oid:t.oid,parent:t.parent}),i=n(r);n.set(r,{...i,selected:t.path,scrollOffset:0,resetId:i.resetId+1})}));function mh(e,t,n,r){let i=(0,$.c)(5),a=r===void 0?1:r,o;return i[0]!==e||i[1]!==n||i[2]!==a||i[3]!==t?(o=lh({connection:e,scope:t,oid:n,parent:a}),i[0]=e,i[1]=n,i[2]=a,i[3]=t,i[4]=o):o=i[4],is(o).value}function hh(e){let t=(0,$.c)(13),{tracking:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(mr,{className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`}),t[0]=r):r=t[0];let i;t[1]===n.name?i=t[2]:(i=(0,Z.jsx)(X,{className:`min-w-0 flex-1 font-mono text-caption font-medium text-foreground`,text:n.name}),t[1]=n.name,t[2]=i);let a;t[3]===n.counts?a=t[4]:(a=n.counts!==null&&(0,Z.jsx)(`span`,{className:`shrink-0 text-2xs text-muted-foreground tabular-nums`,children:n.counts}),t[3]=n.counts,t[4]=a);let o;t[5]!==i||t[6]!==a?(o=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[i,a]}),t[5]=i,t[6]=a,t[7]=o):o=t[7];let s;t[8]===n.upstream?s=t[9]:(s=(0,Z.jsx)(X,{className:`text-2xs text-muted-foreground`,text:n.upstream}),t[8]=n.upstream,t[9]=s);let c;return t[10]!==o||t[11]!==s?(c=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[r,(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[o,s]})]}),t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function gh(e,t){let n=(0,$.c)(19),r;n[0]!==e||n[1]!==t?(r=ch({connection:e,scope:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2];let i=r,a;n[3]!==e||n[4]!==t?(a=ph({connection:e,scope:t}),n[3]=e,n[4]=t,n[5]=a):a=n[5];let{result:o,value:s}=is(a),l=c(i),u;n[6]!==e||n[7]!==t?(u=sh({connection:e,scope:t,kind:`commits`}),n[6]=e,n[7]=t,n[8]=u):u=n[8];let d=u,f=N(d,_h),p=c(d),m;n[9]===p?m=n[10]:(m=e=>p(t=>({...t,selected:e})),n[9]=p,n[10]=m);let h;n[11]===l?h=n[12]:(h=()=>l(void 0),n[11]=l,n[12]=h);let g;return n[13]!==o||n[14]!==f||n[15]!==m||n[16]!==h||n[17]!==s?(g={...s,result:o,selected:f,select:m,readMore:h},n[13]=o,n[14]=f,n[15]=m,n[16]=h,n[17]=s,n[18]=g):g=n[18],g}function _h(e){return e.selected}function vh(e){let t=(0,$.c)(3),{enabled:n,onVisible:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`h-px`,ref:e=>{if(!e||!n||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(e=>{let[t]=e;t?.isIntersecting&&r()},{rootMargin:`0px 0px 240px 0px`});return t.observe(e),()=>t.disconnect()}}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function yh(e){let t=(0,$.c)(5),[n,r]=(0,Q.useState)(1),i;t[0]===e?i=t[1]:(i=function(t){if(!t)return;let n=t.querySelector(`[data-ref-measurement]`);if(!n)return;let i=()=>{let i=Array.from(n.children,xh),a=i.pop()??0,o=Number.parseFloat(getComputedStyle(t).columnGap),s=t.getBoundingClientRect().width;if(i.reduce(bh,0)+Math.max(0,i.length-1)*o<=s){r(e);return}let c=0,l=0;for(let t of i){c+=t+(l===0?0:o);let n=l+1===e?0:o+a;if(c+n>s)break;l+=1}r(Math.max(1,l))},a=new ResizeObserver(i);return a.observe(t),a.observe(n),i(),()=>a.disconnect()},t[0]=e,t[1]=i);let a=i,o;return t[2]!==a||t[3]!==n?(o={row:a,visibleCount:n},t[2]=a,t[3]=n,t[4]=o):o=t[4],o}function bh(e,t){return e+t}function xh(e){return e.getBoundingClientRect().width}var Sh=`min-w-0 max-w-40`;function Ch(e){let t=(0,$.c)(21),{refs:n,current:r,onOpenCommit:i}=e,a=r===void 0?Eh:r,{row:o,visibleCount:s}=yh(n.length),c;if(t[0]!==a||t[1]!==i||t[2]!==n||t[3]!==o||t[4]!==s){let e=n.slice(s),r;t[6]===n?r=t[7]:(r=n.map(Th),t[6]=n,t[7]=r);let l;t[8]===n.length?l=t[9]:(l=(0,Z.jsxs)(nt,{variant:`secondary`,className:Sh,children:[`+`,n.length]}),t[8]=n.length,t[9]=l);let u;t[10]!==r||t[11]!==l?(u=(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none invisible absolute inset-0 overflow-hidden`,children:(0,Z.jsxs)(`div`,{"data-ref-measurement":!0,className:`flex w-max gap-1`,children:[r,l]})}),t[10]=r,t[11]=l,t[12]=u):u=t[12];let d;if(t[13]!==a||t[14]!==i||t[15]!==n||t[16]!==s){let e;t[18]!==a||t[19]!==i?(e=e=>(0,Z.jsx)(X,{text:e.name,renderTrigger:t=>(0,Z.jsxs)(nt,{render:(0,Z.jsx)(`button`,{type:`button`,onClick:i}),variant:a(e)?`brand-soft`:`outline`,className:`${Sh} pointer-events-auto shrink`,children:[e.kind===`tag`&&(0,Z.jsx)(Ic,{"aria-hidden":`true`}),t]}),children:e.name},`${e.kind}:${e.name}`),t[18]=a,t[19]=i,t[20]=e):e=t[20],d=n.slice(0,s).map(e),t[13]=a,t[14]=i,t[15]=n,t[16]=s,t[17]=d}else d=t[17];c=(0,Z.jsxs)(`div`,{ref:o,className:`pointer-events-none relative flex min-w-0 items-center gap-1`,children:[u,d,e.length>0&&(0,Z.jsxs)(qt,{children:[(0,Z.jsxs)(_n,{render:(0,Z.jsx)(nt,{render:(0,Z.jsx)(`button`,{type:`button`}),variant:`secondary`,className:`${Sh} pointer-events-auto`,"aria-label":`Show ${e.length} more ${ae(e.length,`ref`)}`}),children:[`+`,e.length]}),(0,Z.jsxs)(pn,{align:`start`,className:`max-w-[calc(100vw-2rem)]`,children:[(0,Z.jsx)(Zt,{children:`More refs`}),(0,Z.jsx)(`ul`,{className:`max-h-64 overflow-y-auto text-xs`,children:e.map(wh)})]})]})]}),t[0]=a,t[1]=i,t[2]=n,t[3]=o,t[4]=s,t[5]=c}else c=t[5];return c}function wh(e){return(0,Z.jsxs)(`li`,{className:`flex items-center gap-1 py-1 break-all`,children:[e.kind===`tag`&&(0,Z.jsx)(Ic,{"aria-hidden":`true`,className:`size-3 shrink-0`}),e.name]},`${e.kind}:${e.name}`)}function Th(e){return(0,Z.jsxs)(nt,{variant:`secondary`,className:Sh,children:[e.kind===`tag`&&(0,Z.jsx)(Ic,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{"data-label":e.name,className:`before:content-[attr(data-label)]`})]},`${e.kind}:${e.name}`)}function Eh(){return!1}function Dh(e){let t=(0,$.c)(74),{commit:n,selected:r,height:i,inset:a,layout:o,head:s,headRef:c,onSelect:l,openToSide:u,children:d}=e,f=o===void 0?`stacked`:o,p=s!==void 0&&s,[m,h]=(0,Q.useState)(!1),g;t[0]!==l||t[1]!==u?(g=e=>l(u!==void 0&&e.altKey),t[0]=l,t[1]=u,t[2]=g):g=t[2];let _=g,v;t[3]===c?v=t[4]:(v=e=>Np(e,c),t[3]=c,t[4]=v);let y=v,b;if(t[5]!==n.refs||t[6]!==y){let e;t[8]===y?e=t[9]:(e=(e,t)=>Number(y(t))-Number(y(e)),t[8]=y,t[9]=e),b=Mp(n.refs).toSorted(e),t[5]=n.refs,t[6]=y,t[7]=b}else b=t[7];let x=b,S;t[10]===p?S=t[11]:(S=p?(0,Z.jsx)(nt,{variant:`brand`,className:`relative shrink-0`,children:`HEAD`}):null,t[10]=p,t[11]=S);let C=S,w=f===`stacked`&&`font-medium`,T=(p||r)&&`font-semibold`,E;t[12]!==w||t[13]!==T?(E=q(`flex min-w-0 items-center gap-1 text-ui leading-4.5 font-normal`,w,T),t[12]=w,t[13]=T,t[14]=E):E=t[14];let D;t[15]===n.parentOids.length?D=t[16]:(D=n.parentOids.length>1&&(0,Z.jsx)(gc,{"aria-label":`Merge commit`,className:`size-3.5 shrink-0 text-muted-foreground`}),t[15]=n.parentOids.length,t[16]=D);let O;t[17]===n.subject?O=t[18]:(O=(0,Z.jsx)(X,{text:n.subject}),t[17]=n.subject,t[18]=O);let k=f===`stacked`&&C,A;t[19]!==D||t[20]!==O||t[21]!==k||t[22]!==E?(A=(0,Z.jsxs)(`span`,{className:E,children:[D,O,k]}),t[19]=D,t[20]=O,t[21]=k,t[22]=E,t[23]=A):A=t[23];let j=A,M;t[24]===n.author.timestamp?M=t[25]:(M=ze(n.author.timestamp),t[24]=n.author.timestamp,t[25]=M);let N=M,P;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{e&&h(!1)},t[26]=P):P=t[26];let F;t[27]!==i||t[28]!==a?(F={height:i,paddingLeft:a},t[27]=i,t[28]=a,t[29]=F):F=t[29];let I=f===`stacked`?`flex-col justify-center gap-0.5`:`items-center gap-3`,L=i===void 0&&`py-1.5`,R=r&&`bg-muted ring-1 ring-border ring-inset`,z=p&&`bg-muted ring-1 ring-border ring-inset`,B;t[30]!==I||t[31]!==L||t[32]!==R||t[33]!==z?(B=q(`relative flex w-full rounded-lg px-2 text-left transition-colors hover:bg-accent`,I,L,R,z),t[30]=I,t[31]=L,t[32]=R,t[33]=z,t[34]=B):B=t[34];let V;t[35]!==F||t[36]!==B?(V=(0,Z.jsx)(`div`,{style:F,className:B}),t[35]=F,t[36]=B,t[37]=V):V=t[37];let H;t[38]!==N||t[39]!==d||t[40]!==n.author.name||t[41]!==n.oid||t[42]!==y||t[43]!==C||t[44]!==a||t[45]!==f||t[46]!==x||t[47]!==_||t[48]!==r||t[49]!==j?(H=f===`stacked`?(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:_,className:q(`block min-w-0 text-left before:absolute before:inset-0 before:rounded-lg`,x.length>0?`max-w-3/5`:`flex-1`),children:[j,(0,Z.jsxs)(`span`,{style:{left:a},className:`absolute inset-x-2 mt-0.5 flex min-w-0 gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`code`,{className:`font-mono`,children:Ap(n.oid)}),(0,Z.jsx)(X,{text:n.author.name}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:N})]}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 block h-4`}),d!==void 0&&(0,Z.jsx)(`span`,{className:`flex min-w-0`,children:d})]}),x.length>0&&(0,Z.jsx)(`div`,{className:`flex h-4.5 min-w-0 flex-1 flex-col justify-center`,children:(0,Z.jsx)(Ch,{refs:x,current:y,onOpenCommit:_})})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`code`,{className:`hidden w-16 shrink-0 font-mono text-xs text-muted-foreground @md/graph:block`,children:Ap(n.oid)}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:_,className:`flex max-w-3/5 min-w-0 shrink-0 items-center text-left before:absolute before:inset-0 before:rounded-lg`,children:[j,(0,Z.jsx)(`span`,{className:`sr-only`,children:` ${Ap(n.oid)} ${n.author.name} ${N}`})]}),C,(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:x.length>0&&(0,Z.jsx)(Ch,{refs:x,current:y,onOpenCommit:_})})]}),(0,Z.jsx)(X,{className:`hidden w-28 shrink-0 text-xs text-muted-foreground @2xl/graph:block`,text:n.author.name}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-right text-xs whitespace-nowrap text-muted-foreground tabular-nums`,children:N})]}),t[38]=N,t[39]=d,t[40]=n.author.name,t[41]=n.oid,t[42]=y,t[43]=C,t[44]=a,t[45]=f,t[46]=x,t[47]=_,t[48]=r,t[49]=j,t[50]=H):H=t[50];let U;t[51]!==V||t[52]!==H?(U=(0,Z.jsx)(qi,{render:V,children:H}),t[51]=V,t[52]=H,t[53]=U):U=t[53];let W=!m,G;t[54]===u?G=t[55]:(G=u&&(0,Z.jsxs)(Xr,{onClick:()=>{(0,ru.flushSync)(()=>h(!0)),u.open()},children:[(0,Z.jsx)(Jr,{}),u.label]}),t[54]=u,t[55]=G);let ee;t[56]===n.oid?ee=t[57]:(ee=()=>ht(n.oid,`commit id`),t[56]=n.oid,t[57]=ee);let te;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(De,{}),t[58]=te):te=t[58];let ne;t[59]===ee?ne=t[60]:(ne=(0,Z.jsxs)(Xr,{onClick:ee,children:[te,`Copy commit id`]}),t[59]=ee,t[60]=ne);let re;t[61]===n?re=t[62]:(re=()=>ht(Ep(n),`commit message`),t[61]=n,t[62]=re);let ie;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Z.jsx)(De,{}),t[63]=ie):ie=t[63];let ae;t[64]===re?ae=t[65]:(ae=(0,Z.jsxs)(Xr,{onClick:re,children:[ie,`Copy message`]}),t[64]=re,t[65]=ae);let K;t[66]!==W||t[67]!==G||t[68]!==ne||t[69]!==ae?(K=(0,Z.jsxs)(Gr,{finalFocus:W,children:[G,ne,ae]}),t[66]=W,t[67]=G,t[68]=ne,t[69]=ae,t[70]=K):K=t[70];let oe;return t[71]!==U||t[72]!==K?(oe=(0,Z.jsxs)(ur,{onOpenChange:P,children:[U,K]}),t[71]=U,t[72]=K,t[73]=oe):oe=t[73],oe}var Oh=[`text-graph-1`,`text-graph-2`,`text-graph-3`,`text-graph-4`,`text-graph-5`,`text-graph-6`],kh=e=>13+e*16,Ah=e=>Oh[e%Oh.length]??Oh[0];function jh(e){let t=(0,$.c)(7),{rows:n,width:r,rowHeight:i}=e,a=n.length*i,o;t[0]!==i||t[1]!==n?(o=n.map((e,t)=>{let r=t*i+i*.5,a=n[t+1],o=e.lanesAfter.flatMap((r,i)=>{if(r==null||a==null)return[];let o=e.outgoing.includes(i)?kh(e.lane):kh(i),s=r===a.commit.oid?kh(a.lane):kh(i),c=[o];return o!==kh(i)&&n[t-1]?.lanesAfter[i]===r&&c.push(kh(i)),c.map(e=>({lane:i,startX:e,endX:s}))}),s=e.commit.parentOids.length>1;return(0,Z.jsxs)(`g`,{children:[o.map(e=>{let{lane:t,startX:n,endX:a}=e;return(0,Z.jsx)(`path`,{d:n===a?`M ${n} ${r} L ${a} ${r+i}`:`M ${n} ${r} C ${n} ${r+i*.5}, ${a} ${r+i*.5}, ${a} ${r+i}`,fill:`none`,stroke:`currentColor`,strokeWidth:Me,className:Ah(t)},`${t}-${n}`)}),(0,Z.jsx)(`circle`,{cx:kh(e.lane),cy:r,r:s?5:4,fill:s?`var(--card)`:`currentColor`,stroke:`currentColor`,strokeWidth:2,className:Ah(e.lane)})]},e.commit.oid)}),t[0]=i,t[1]=n,t[2]=o):o=t[2];let s;return t[3]!==a||t[4]!==o||t[5]!==r?(s=(0,Z.jsx)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute top-2 left-1.5`,"data-testid":`history-graph`,width:r,height:a,children:o}),t[3]=a,t[4]=o,t[5]=r,t[6]=s):s=t[6],s}function Mh(e){let t=(0,$.c)(47),{label:n,layout:r,history:i,selected:a,onSelect:o,sideLabel:s,highlightHead:c}=e,l=c!==void 0&&c,u,d,f,p,m,h,g,_;if(t[0]!==l||t[1]!==i.commits||t[2]!==i.snapshot||t[3]!==n||t[4]!==r||t[5]!==o||t[6]!==a||t[7]!==s){d=th(i.commits),_=nh(d),u=r===`columns`?30:44;let e=i.snapshot?.tipOid,c=i.snapshot?.head.kind===`attached`?i.snapshot.head.ref:void 0;g=`relative py-2 pr-3 pl-1.5`,f=n,p=`flex flex-col`,m=Nh;let v;t[16]!==c||t[17]!==l||t[18]!==r||t[19]!==o||t[20]!==u||t[21]!==a||t[22]!==s||t[23]!==e||t[24]!==_?(v=t=>{let{commit:n}=t;return(0,Z.jsx)(`li`,{children:(0,Z.jsx)(Dh,{commit:n,selected:a===n.oid,height:u,inset:_+8,layout:r,head:l&&n.oid===e,headRef:c,onSelect:e=>o(n.oid,e),openToSide:{label:s,open:()=>o(n.oid,!0)}})},n.oid)},t[16]=c,t[17]=l,t[18]=r,t[19]=o,t[20]=u,t[21]=a,t[22]=s,t[23]=e,t[24]=_,t[25]=v):v=t[25],h=d.map(v),t[0]=l,t[1]=i.commits,t[2]=i.snapshot,t[3]=n,t[4]=r,t[5]=o,t[6]=a,t[7]=s,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_}else u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15];let v;t[26]!==f||t[27]!==p||t[28]!==m||t[29]!==h?(v=(0,Z.jsx)(`ol`,{"aria-label":f,className:p,onKeyDown:m,children:h}),t[26]=f,t[27]=p,t[28]=m,t[29]=h,t[30]=v):v=t[30];let y;t[31]!==u||t[32]!==d||t[33]!==_?(y=(0,Z.jsx)(jh,{rows:d,width:_,rowHeight:u}),t[31]=u,t[32]=d,t[33]=_,t[34]=y):y=t[34];let b;t[35]===_?b=t[36]:(b={paddingLeft:_},t[35]=_,t[36]=b);let x;t[37]===i?x=t[38]:(x=(0,Z.jsx)(Ph,{history:i}),t[37]=i,t[38]=x);let S;t[39]!==x||t[40]!==b?(S=(0,Z.jsx)(`div`,{style:b,children:x}),t[39]=x,t[40]=b,t[41]=S):S=t[41];let C;return t[42]!==S||t[43]!==g||t[44]!==v||t[45]!==y?(C=(0,Z.jsxs)(`div`,{className:g,children:[v,y,S]}),t[42]=S,t[43]=g,t[44]=v,t[45]=y,t[46]=C):C=t[46],C}function Nh(e){if(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=Array.from(e.currentTarget.querySelectorAll(`button[aria-pressed]`)),n=e.target instanceof Element?e.target.closest(`li`):null,r=t.findIndex(e=>e.closest(`li`)===n);if(r<0)return;e.preventDefault(),e.stopPropagation();let i=t[r+(e.key===`ArrowDown`?1:-1)];i&&(i.focus(),i.click())}function Ph(e){let t=(0,$.c)(11),{history:n}=e,r;t[0]===n?r=t[1]:(r=(0,Z.jsx)(Fh,{history:n}),t[0]=n,t[1]=r);let i;t[2]!==n.nextAfter||t[3]!==n.result?(i=n.nextAfter!==null&&n.nextAfter!==void 0&&!n.result.waiting&&!Qt(n.result),t[2]=n.nextAfter,t[3]=n.result,t[4]=i):i=t[4];let a;t[5]!==n.readMore||t[6]!==i?(a=(0,Z.jsx)(vh,{enabled:i,onVisible:n.readMore}),t[5]=n.readMore,t[6]=i,t[7]=a):a=t[7];let o;return t[8]!==r||t[9]!==a?(o=(0,Z.jsxs)(Z.Fragment,{children:[r,a]}),t[8]=r,t[9]=a,t[10]=o):o=t[10],o}function Fh(e){let t=(0,$.c)(8),{history:n}=e;if(n.result.waiting){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 px-2 py-3 text-2xs text-muted-foreground`,children:[(0,Z.jsx)(mt,{className:`size-3.5`}),`Loading older commits…`]}),t[0]=e):e=t[0],e}if(Qt(n.result)){let e;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`span`,{children:`Couldn't load older commits`}),t[1]=e):e=t[1];let r;return t[2]===n.readMore?r=t[3]:(r=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-2 text-2xs text-muted-foreground`,children:[e,(0,Z.jsx)(Y,{size:`xs`,variant:`outline`,onClick:n.readMore,children:`Retry`})]}),t[2]=n.readMore,t[3]=r),r}if(n.nextAfter===null||n.nextAfter===void 0){let e;t[4]===n.boundary?e=t[5]:(e=Fp(n.boundary),t[4]=n.boundary,t[5]=e);let r;return t[6]===e?r=t[7]:(r=(0,Z.jsx)(`p`,{className:`px-2 py-3 text-2xs text-muted-foreground`,children:e}),t[6]=e,t[7]=r),r}return null}function Ih(e,t){let n=(0,$.c)(4),r=t===void 0?`scrollOffset`:t,i=N(oe),a;return n[0]!==e||n[1]!==r||n[2]!==i?(a={ref:t=>{if(!t)return;let n=t.querySelector(`[data-slot="scroll-area-viewport"]`)??t;n.scrollTop=i.get(e)[r]},onScrollCapture:t=>{t.target instanceof HTMLElement&&i.set(e,{...i.get(e),[r]:t.target.scrollTop})}},n[0]=e,n[1]=r,n[2]=i,n[3]=a):a=n[3],a}function Lh(e){let t=(0,$.c)(18),{scope:n,connection:r,selected:i,onSelect:a,sideLabel:o,onOpenGraph:s,onOpenChanges:c}=e,l=gh(r,n),u=Nt(bt(oa(n,r))),d=Ip(u?.branch,l.snapshot),p=u?.changes.length??0,m;t[0]!==r||t[1]!==n?(m=sh({connection:r,scope:n,kind:`commits`}),t[0]=r,t[1]=n,t[2]=m):m=t[2];let h=Ih(m),g;t[3]===l?g=t[4]:(g=(0,Z.jsx)(zh,{history:l}),t[3]=l,t[4]=g);let _=ei,v=p>0&&(0,Z.jsx)(`div`,{className:`pt-2 pr-3 pl-1.5`,children:(0,Z.jsxs)(`button`,{type:`button`,onClick:c,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2 text-left text-caption transition-colors hover:bg-accent`,children:[(0,Z.jsx)(ec,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Z.jsx)(X,{className:`flex-1`,text:`Uncommitted changes`}),(0,Z.jsx)(`span`,{className:`text-2xs text-muted-foreground tabular-nums`,children:R(p,`file`)})]})}),y;t[5]!==l||t[6]!==a||t[7]!==i||t[8]!==o?(y=l.commits.length===0?(0,Z.jsx)(Bh,{}):(0,Z.jsx)(Mh,{label:`Commits`,layout:`stacked`,history:l,selected:i||l.selected||``,onSelect:(e,t)=>{l.select(e),a(e,t)},sideLabel:o}),t[5]=l,t[6]=a,t[7]=i,t[8]=o,t[9]=y):y=t[9];let b;t[10]!==_||t[11]!==h||t[12]!==v||t[13]!==y?(b=(0,Z.jsxs)(_,{className:`min-h-0 flex-initial`,role:`region`,"aria-label":`History reading area`,...h,children:[v,y]}),t[10]=_,t[11]=h,t[12]=v,t[13]=y,t[14]=b):b=t[14];let x;return t[15]!==l.commits.length||t[16]!==s?(x=l.commits.length>0&&(0,Z.jsx)(`div`,{className:`shrink-0 border-t p-1.5`,children:(0,Z.jsxs)(Y,{variant:`ghost`,className:`w-full justify-start`,onClick:s,children:[(0,Z.jsx)(mc,{}),`Open graph`,(0,Z.jsx)(f,{className:`ml-auto text-muted-foreground`})]})}),t[15]=l.commits.length,t[16]=s,t[17]=x):x=t[17],(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Z.jsx)(`section`,{"aria-label":`Branch`,className:`flex shrink-0 border-b px-3.5 py-2.5`,children:(0,Z.jsx)(hh,{tracking:d})}),g,b,x]})}function Rh(e){let t=(0,$.c)(7),{history:n}=e,r;t[0]===n.snapshot?r=t[1]:(r=n.snapshot!==null&&n.snapshot!==void 0&&(0,Z.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 border-b px-3.5 font-mono text-caption leading-4 text-muted-foreground`,children:[(0,Z.jsx)(mr,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(X,{className:`min-w-0 flex-1 font-medium text-foreground`,text:Pp(n.snapshot)})]}),t[0]=n.snapshot,t[1]=r);let i;t[2]===n?i=t[3]:(i=(0,Z.jsx)(zh,{history:n}),t[2]=n,t[3]=i);let a;return t[4]!==r||t[5]!==i?(a=(0,Z.jsxs)(Z.Fragment,{children:[r,i]}),t[4]=r,t[5]=i,t[6]=a):a=t[6],a}function zh(e){let t=(0,$.c)(1),{history:n}=e;if(!n.restarted)return null;let r;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`p`,{role:`status`,className:`shrink-0 border-b bg-muted/40 px-3.5 py-2 text-2xs text-muted-foreground`,children:`History changed. Showing it from the top.`}),t[0]=r):r=t[0],r}function Bh(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Or,{children:(0,Z.jsxs)(Gn,{children:[(0,Z.jsx)(ki,{children:`No commits yet`}),(0,Z.jsx)(Mi,{children:`Commits will appear here once this worktree has history.`})]})}),e[0]=t):t=e[0],t}function Vh(e){let t=(0,$.c)(14),{scope:n,connection:r,onSelect:i,sideLabel:a}=e,o=gh(r,n),s=Rt(),c;t[0]!==r||t[1]!==n?(c=sh({connection:r,scope:n,kind:`commits`}),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=Ih(c,`graphScrollOffset`),u;t[3]===o?u=t[4]:(u=(0,Z.jsx)(Rh,{history:o}),t[3]=o,t[4]=u);let d;t[5]!==o||t[6]!==i||t[7]!==s||t[8]!==a?(d=o.commits.length===0?(0,Z.jsx)(Bh,{}):(0,Z.jsx)(Mh,{label:`Commit graph`,highlightHead:!0,layout:s?`stacked`:`columns`,history:o,selected:o.selected??``,onSelect:(e,t)=>{o.select(e),i(e,t)},sideLabel:a}),t[5]=o,t[6]=i,t[7]=s,t[8]=a,t[9]=d):d=t[9];let f;return t[10]!==l||t[11]!==u||t[12]!==d?(f=(0,Z.jsxs)(`div`,{className:`@container/graph flex min-h-0 flex-1 flex-col overflow-auto`,role:`region`,"aria-label":`Graph reading area`,...l,children:[u,d]}),t[10]=l,t[11]=u,t[12]=d,t[13]=f):f=t[13],f}function Hh(e,t,n){let r=(0,$.c)(6),i={connection:e,scope:t,path:n},{value:a,result:o}=is(fh(i)),s=c(uh(i)),l;r[0]===s?l=r[1]:(l=()=>s(void 0),r[0]=s,r[1]=l);let u;return r[2]!==o||r[3]!==l||r[4]!==a?(u={...a,result:o,readMore:l},r[2]=o,r[3]=l,r[4]=a,r[5]=u):u=r[5],u}function Uh(e){let t=(0,$.c)(34),{scope:n,connection:r,path:i,onSelect:a,sideLabel:o}=e,s=Hh(r,n,i),l;t[0]!==r||t[1]!==i||t[2]!==n?(l=sh({connection:r,scope:n,kind:`file`,path:i}),t[0]=r,t[1]=i,t[2]=n,t[3]=l):l=t[3];let u=l,d=N(u,Wh),f=c(u),p=Ih(u),m;t[4]!==a||t[5]!==f?(m=(e,t)=>{f(t=>({...t,selected:e.commit.oid})),a({oid:e.commit.oid,path:e.path},t)},t[4]=a,t[5]=f,t[6]=m):m=t[6];let h=m;if(s.commits.length===0&&s.nextAfter===null){let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Or,{children:(0,Z.jsxs)(Gn,{children:[(0,Z.jsx)(ki,{children:`No commits touch this file`}),(0,Z.jsx)(Mi,{children:`Its timeline starts with the first commit that includes it.`})]})}),t[7]=e):e=t[7],e}let g=`Timeline of ${i}`,_;if(t[8]!==h||t[9]!==i||t[10]!==d||t[11]!==o||t[12]!==s.commits){let e;t[14]!==h||t[15]!==i||t[16]!==d||t[17]!==o?(e=e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(Dh,{commit:e.commit,selected:d===e.commit.oid,onSelect:t=>h(e,t),openToSide:{label:o,open:()=>h(e,!0)},children:(0,Z.jsx)(X,{className:`text-2xs text-muted-foreground`,text:Tp(e,i)})})},e.commit.oid),t[14]=h,t[15]=i,t[16]=d,t[17]=o,t[18]=e):e=t[18],_=s.commits.map(e),t[8]=h,t[9]=i,t[10]=d,t[11]=o,t[12]=s.commits,t[13]=_}else _=t[13];let v;t[19]===s.restarted?v=t[20]:(v=s.restarted&&(0,Z.jsx)(`span`,{role:`status`,children:`History changed. Showing it from the top.`}),t[19]=s.restarted,t[20]=v);let y;t[21]===s?y=t[22]:(y=(0,Z.jsx)(Gh,{timeline:s}),t[21]=s,t[22]=y);let b;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(`span`,{children:`A merge appears only when its own result changed the file.`}),t[23]=b):b=t[23];let x;t[24]!==v||t[25]!==y?(x=(0,Z.jsxs)(`li`,{className:`flex flex-col gap-1 px-2 py-3 text-2xs text-muted-foreground`,children:[v,y,b]}),t[24]=v,t[25]=y,t[26]=x):x=t[26];let S;t[27]!==g||t[28]!==_||t[29]!==x?(S=(0,Z.jsxs)(`ol`,{"aria-label":g,className:`flex flex-col p-2`,children:[_,x]}),t[27]=g,t[28]=_,t[29]=x,t[30]=S):S=t[30];let C;return t[31]!==p||t[32]!==S?(C=(0,Z.jsx)(`div`,{role:`region`,"aria-label":`Timeline reading area`,className:`min-h-0 flex-1 overflow-auto`,...p,children:S}),t[31]=p,t[32]=S,t[33]=C):C=t[33],C}function Wh(e){return e.selected}function Gh(e){let t=(0,$.c)(8),{timeline:n}=e;if(Qt(n.result)){let e;return t[0]===n.readMore?e=t[1]:(e=(0,Z.jsxs)(`div`,{role:`status`,children:[`Couldn't load older commits`,(0,Z.jsx)(Y,{size:`xs`,variant:`outline`,onClick:n.readMore,children:`Retry`})]}),t[0]=n.readMore,t[1]=e),e}if(n.nextAfter){let e=n.result.waiting?`Loading older commits…`:`Load older commits`,r;return t[2]!==e||t[3]!==n.readMore||t[4]!==n.result.waiting?(r=(0,Z.jsx)(Y,{size:`sm`,variant:`outline`,disabled:n.result.waiting,onClick:n.readMore,children:e}),t[2]=e,t[3]=n.readMore,t[4]=n.result.waiting,t[5]=r):r=t[5],r}let r=n.boundary===`shallow`?`Shallow clone: older history is not available.`:`Start of this file’s history.`,i;return t[6]===r?i=t[7]:(i=(0,Z.jsx)(`span`,{children:r}),t[6]=r,t[7]=i),i}function Kh(){let e=globalThis.crypto;if(typeof e?.randomUUID==`function`)return e.randomUUID();let t=URL.createObjectURL(new Blob);return URL.revokeObjectURL(t),t.slice(t.lastIndexOf(`/`)+1)}function qh(e){let t=(0,$.c)(2),n;return t[0]===e.connection?n=t[1]:(n=en(e.connection),t[0]=e.connection,t[1]=n),N(n)}var Jh=j(`BrowserCommitDraft.submit`)(function*(e,t,n){return yield*Je(Ve(function*(){let r=yield*ne(st(),e=>Ft(e,_t)),i=new AbortController,a=()=>{cn(Ft(r,_t))};return yield*ne($e(()=>{t.add(i),i.signal.addEventListener(`abort`,a,{once:!0})}),()=>$e(()=>{i.signal.removeEventListener(`abort`,a),t.delete(i)})),yield*e(n,r)}))});function Yh(e,t,n){let r=(0,$.c)(12),i;r[0]!==t.connection||r[1]!==e?(i=lt({connection:t.connection,scope:e}),r[0]=t.connection,r[1]=e,r[2]=i):i=r[2];let{value:a}=is(i),o;r[3]!==t.connection||r[4]!==e?(o=Lt({connection:t.connection,scope:e}),r[3]=t.connection,r[4]=e,r[5]=o):o=r[5];let s=N(o),c;r[6]!==n||r[7]!==a?(c=e=>Jh(a,n,e),r[6]=n,r[7]=a,r[8]=c):c=r[8];let l;return r[9]!==s||r[10]!==c?(l={result:s,submit:c},r[9]=s,r[10]=c,r[11]=l):l=r[11],l}function Xh(e,n,r,i){let a=(0,$.c)(121),{scope:o,status:s,action:c,onBusy:l,onLookAgain:u,initialMessage:d,lastCommitMessage:f}=e,p=c===void 0?`commit`:c,m=d===void 0?``:d,h=f===void 0?``:f,g;a[0]!==p||a[1]!==m||a[2]!==h?(g=$p(p,m,h),a[0]=p,a[1]=m,a[2]=h,a[3]=g):g=a[3];let _;a[4]===g?_=a[5]:(_={defaultValues:g},a[4]=g,a[5]=_);let v=ys(_),y;a[6]===v?y=a[7]:(y=dm(v),a[6]=v,a[7]=y);let b=y,x;a[8]===v?x=a[9]:(x=fm(v),a[8]=v,a[9]=x);let S=x,{mode:C,message:w,amendMessage:T,excluded:E,added:D,groups:O}=Eo(v.store,ng),{done:k,activeGroup:A,ownHead:j,busy:M,error:N,drafted:P,draftedBy:F,editingFiles:I}=Te(b),L;a[10]===v?L=a[11]:(L=e=>v.setFieldValue(`mode`,e),a[10]=v,a[11]=L);let R=L,z;a[12]===v?z=a[13]:(z=e=>v.setFieldValue(`message`,e),a[12]=v,a[13]=z);let B=z,V;a[14]===v?V=a[15]:(V=e=>v.setFieldValue(`amendMessage`,e),a[14]=v,a[15]=V);let H=V,U;a[16]===v?U=a[17]:(U=e=>v.setFieldValue(`excluded`,e),a[16]=v,a[17]=U);let W=U,G;a[18]===v?G=a[19]:(G=e=>v.setFieldValue(`added`,e),a[18]=v,a[19]=G);let ee=G,te;a[20]===v?te=a[21]:(te=e=>v.setFieldValue(`groups`,e),a[20]=v,a[21]=te);let ne=te,re;a[22]===b?re=a[23]:(re=e=>b.update(t=>({...t,done:typeof e==`function`?e(t.done):e})),a[22]=b,a[23]=re);let ie=re,ae;a[24]===b?ae=a[25]:(ae=e=>b.update(t=>({...t,activeGroup:e})),a[24]=b,a[25]=ae);let K=ae,oe;a[26]===b?oe=a[27]:(oe=e=>b.update(t=>({...t,ownHead:e})),a[26]=b,a[27]=oe);let q=oe,se;a[28]===b?se=a[29]:(se=e=>b.update(t=>({...t,busy:e})),a[28]=b,a[29]=se);let ce=se,le;a[30]===b?le=a[31]:(le=e=>b.update(t=>({...t,error:e})),a[30]=b,a[31]=le);let ue=le,de=(e,t)=>{let n=t?.length===1?`1 selected file`:`${t?.length} selected files`;b.update(r=>({...r,drafted:{...r.drafted,[e]:t},draftedBy:{...r.draftedBy,[e]:t?`Generated by ${Nt(bt(me))?.find(e=>e.id===he)?.label??he} from ${n}`:null}}))},J=C===`amend`?`amend`:`commit`,fe=pm(o,J,n),pe=Yh(o,n,S),me=qh(n),he=Xp(Nt(bt(me)),i.value),ge;if(a[32]!==E||a[33]!==r){let e;a[35]===E?e=a[36]:(e=e=>!E.has(e.path),a[35]=E,a[36]=e),ge=new Set(r.filter(e).flatMap(tg)),a[32]=E,a[33]=r,a[34]=ge}else ge=a[34];let _e;a[37]===ge?_e=a[38]:(_e=[...ge],a[37]=ge,a[38]=_e);let ve=_e,ye;if(a[39]!==D||a[40]!==r){let e;a[42]===D?e=a[43]:(e=e=>D.has(e.path),a[42]=D,a[43]=e),ye=new Set(r.filter(e).flatMap(eg)),a[39]=D,a[40]=r,a[41]=ye}else ye=a[41];let be;a[44]===ye?be=a[45]:(be=[...ye],a[44]=ye,a[45]=be);let xe=J===`amend`?be:ve,Se=J===`amend`?T:w,Ce=!(!fe.operation||fe.canStartNew),we=fe.operation?.receipt,Ee=M||pe.result.waiting||fe.recovered.waiting,De=O?P.groups:P.message,Oe;a[46]!==De||a[47]!==J||a[48]!==k||a[49]!==O||a[50]!==s?(Oe=J===`commit`&&De!=null&&em(s,De,new Set((O??[]).filter(e=>k.has(e.id)).flatMap($h))),a[46]=De,a[47]=J,a[48]=k,a[49]=O,a[50]=s,a[51]=Oe):Oe=a[51];let ke=Oe,Ae;a[52]!==r||a[53]!==O?(Ae=O?r.filter(e=>!O.some(t=>t.paths.includes(e.path))):[],a[52]=r,a[53]=O,a[54]=Ae):Ae=a[54];let Me=Ae,Ne;a[55]!==J||a[56]!==Se||a[57]!==k||a[58]!==O||a[59]!==C||a[60]!==xe||a[61]!==ke||a[62]!==s?(Ne=ke||(C===`groups`?!O?.length||O.filter(e=>!k.has(e.id)).some(Qh):!Se.trim()||J!==`amend`&&s.inProgress!==`merge`&&!xe.length),a[55]=J,a[56]=Se,a[57]=k,a[58]=O,a[59]=C,a[60]=xe,a[61]=ke,a[62]=s,a[63]=Ne):Ne=a[63];let Pe=Ne,Fe;a[64]===s?Fe=a[65]:(Fe=je(`commit`,s),a[64]=s,a[65]=Fe);let Ie=Fe,Le;a[66]===s?Le=a[67]:(Le=je(`amend`,s),a[66]=s,a[67]=Le);let Re=Le,ze;a[68]===u?ze=a[69]:(ze=u?t({try:u,catch:Zh}):void 0,a[68]=u,a[69]=ze);let Be;return a[70]!==A||a[71]!==D||a[72]!==T||a[73]!==Re||a[74]!==Pe||a[75]!==M||a[76]!==J||a[77]!==Ie||a[78]!==ve||a[79]!==S||a[80]!==Se||a[81]!==k||a[82]!==P||a[83]!==F||a[84]!==I||a[85]!==N||a[86]!==E||a[87]!==r||a[88]!==v||a[89]!==pe||a[90]!==fe||a[91]!==O||a[92]!==Me||a[93]!==w||a[94]!==C||a[95]!==he||a[96]!==me||a[97]!==l||a[98]!==j||a[99]!==xe||a[100]!==we||a[101]!==o||a[102]!==K||a[103]!==ee||a[104]!==H||a[105]!==ce||a[106]!==ie||a[107]!==de||a[108]!==ue||a[109]!==W||a[110]!==ne||a[111]!==B||a[112]!==R||a[113]!==q||a[114]!==ke||a[115]!==b||a[116]!==s||a[117]!==ze||a[118]!==Ce||a[119]!==Ee?(Be={scope:o,status:s,onBusy:l,onLookAgain:ze,createId:Kh,mode:C,commitAction:J,git:fe,generator:pe,models:me,model:he,message:w,amendMessage:T,editingFiles:I,excluded:E,added:D,groups:O,done:k,activeGroup:A,ownHead:j,busy:M,error:N,drafted:P,draftedBy:F,files:r,commitPaths:ve,paths:xe,currentMessage:Se,uncertain:Ce,receipt:we,working:Ee,staleDraft:ke,leftUncommitted:Me,blocker:Pe,commitModeBlocker:Ie,amendModeBlocker:Re,controllers:S,form:v,setMode:R,setMessage:B,setAmendMessage:H,setExcluded:W,setAdded:ee,setGroups:ne,setDone:ie,setActiveGroup:K,setOwnHead:q,setBusy:ce,setError:ue,setDrafted:de,state:b},a[70]=A,a[71]=D,a[72]=T,a[73]=Re,a[74]=Pe,a[75]=M,a[76]=J,a[77]=Ie,a[78]=ve,a[79]=S,a[80]=Se,a[81]=k,a[82]=P,a[83]=F,a[84]=I,a[85]=N,a[86]=E,a[87]=r,a[88]=v,a[89]=pe,a[90]=fe,a[91]=O,a[92]=Me,a[93]=w,a[94]=C,a[95]=he,a[96]=me,a[97]=l,a[98]=j,a[99]=xe,a[100]=we,a[101]=o,a[102]=K,a[103]=ee,a[104]=H,a[105]=ce,a[106]=ie,a[107]=de,a[108]=ue,a[109]=W,a[110]=ne,a[111]=B,a[112]=R,a[113]=q,a[114]=ke,a[115]=b,a[116]=s,a[117]=ze,a[118]=Ce,a[119]=Ee,a[120]=Be):Be=a[120],Be}function Zh(e){return new Ht(e,Sn(e))}function Qh(e){return!e.message.trim()||!e.paths.length}function $h(e){return e.paths}function eg(e){return e.paths}function tg(e){return e.paths}function ng(e){return e.values}function rg(e,t,n,r){let i=(0,$.c)(46),a=Xh(e,t,n,r),{state:o,form:s,commitAction:c,setMode:l,setGroups:u,setDrafted:d,setAmendMessage:f,setMessage:p,setAdded:m,setExcluded:h}=a,g,_,v,y;i[0]===a?(g=i[1],_=i[2],v=i[3],y=i[4]):(g=()=>cn(Ye(a)),_=()=>cn(Ke(a,a.mode===`groups`?`groups`:`message`)),v=()=>cn(et(a)),y=()=>cn(xe(a)),i[0]=a,i[1]=g,i[2]=_,i[3]=v,i[4]=y);let b;i[5]===o?b=i[6]:(b=()=>o.update(ig),i[5]=o,i[6]=b);let x;i[7]!==c||i[8]!==f||i[9]!==p?(x=e=>{c===`amend`?f(e):p(e)},i[7]=c,i[8]=f,i[9]=p,i[10]=x):x=i[10];let S;i[11]!==d||i[12]!==u||i[13]!==l?(S=e=>{(e===`single`||e===`amend`||e===`groups`)&&(l(e),e===`single`&&(u(null),d(`groups`,null)))},i[11]=d,i[12]=u,i[13]=l,i[14]=S):S=i[14];let C;i[15]!==c||i[16]!==s||i[17]!==m||i[18]!==h?(C=(e,t)=>{if(c===`amend`){let n=new Set(s.state.values.added);t?n.add(e):n.delete(e),m(n)}else{let n=new Set(s.state.values.excluded);t?n.delete(e):n.add(e),h(n)}},i[15]=c,i[16]=s,i[17]=m,i[18]=h,i[19]=C):C=i[19];let w,T,E,D;i[20]!==s||i[21]!==u?(E=e=>u(s.state.values.groups?.filter(t=>t.id!==e)??null),D=(e,t)=>u(s.state.values.groups?.map(n=>n.id===e?{...n,message:t}:n)??null),w=(e,t)=>u(s.state.values.groups?.map(n=>({...n,paths:[...n.paths.filter(t=>!e.includes(t)),...n.id===t?e:[]]}))??null),T=()=>u([...s.state.values.groups??[],{id:Kh(),message:``,paths:[]}]),i[20]=s,i[21]=u,i[22]=w,i[23]=T,i[24]=E,i[25]=D):(w=i[22],T=i[23],E=i[24],D=i[25]);let O;i[26]!==d||i[27]!==u||i[28]!==l?(O=()=>{l(`single`),u(null),d(`groups`,null)},i[26]=d,i[27]=u,i[28]=l,i[29]=O):O=i[29];let k;return i[30]!==r.set||i[31]!==a||i[32]!==g||i[33]!==_||i[34]!==w||i[35]!==T||i[36]!==O||i[37]!==v||i[38]!==y||i[39]!==b||i[40]!==x||i[41]!==S||i[42]!==C||i[43]!==E||i[44]!==D?(k={...a,messageLimit:mn,groupLimit:20,commit:g,generate:_,lookAgain:v,checkOutcome:y,setModel:r.set,toggleEditingFiles:b,setCurrentMessage:x,setMode:S,setIncluded:C,removeGroup:E,setGroupMessage:D,moveFile:w,addGroup:T,clearGroups:O},i[30]=r.set,i[31]=a,i[32]=g,i[33]=_,i[34]=w,i[35]=T,i[36]=O,i[37]=v,i[38]=y,i[39]=b,i[40]=x,i[41]=S,i[42]=C,i[43]=E,i[44]=D,i[45]=k):k=i[45],k}function ig(e){return{...e,editingFiles:!e.editingFiles}}var ag=x(e=>u(t=>{t.addFinalizer(()=>{for(let t of e)t.abort();e.clear()})}));function og(e){let t=(0,$.c)(2),n;t[0]===e?n=t[1]:(n=ag(e),t[0]=e,t[1]=n),ie(n)}function sg(e){let t=(0,$.c)(102),{status:r,liveBranch:i,onLookAgain:a}=e,{preferences:o,setPreference:s}=Va(),c=e.context,l;t[0]===e.status.changes?l=t[1]:(l=Zl(e.status.changes),t[0]=e.status.changes,t[1]=l);let u;t[2]===s?u=t[3]:(u=e=>s(`commitModel`,e),t[2]=s,t[3]=u);let d;t[4]!==o.commitModel||t[5]!==u?(d={value:o.commitModel,set:u},t[4]=o.commitModel,t[5]=u,t[6]=d):d=t[6];let f=rg(e,c,l,d);og(f.controllers);let{mode:p,commitAction:m,git:h,model:g,groups:_,done:v,commitPaths:y,uncertain:b,receipt:x,working:S,error:C,staleDraft:w,blocker:T,commitModeBlocker:E,amendModeBlocker:D}=f,O,k;t[7]!==T||t[8]!==f||t[9]!==b||t[10]!==S?(O=e=>{e.preventDefault(),T||S||b||f.commit()},k=e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),T||S||b||f.commit())},t[7]=T,t[8]=f,t[9]=b,t[10]=S,t[11]=O,t[12]=k):(O=t[11],k=t[12]);let A=m===`amend`?`Amend last commit`:`Commit changes`,j;t[13]===A?j=t[14]:(j=(0,Z.jsx)(Xi,{children:A}),t[13]=A,t[14]=j);let M=m===`amend`?`The last commit is replaced by one with this message and the files you add.`:`Committed steps fold away in the review and show up in History.`,N;t[15]===M?N=t[16]:(N=(0,Z.jsx)(ea,{children:M}),t[15]=M,t[16]=N);let P;t[17]!==j||t[18]!==N?(P=(0,Z.jsxs)(Hi,{children:[j,N]}),t[17]=j,t[18]=N,t[19]=P):P=t[19];let F=i??void 0,I;t[20]===F?I=t[21]:(I=Ip(F,null),t[20]=F,t[21]=I);let L;t[22]===I?L=t[23]:(L=(0,Z.jsx)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/50 px-3 py-2 text-caption`,children:(0,Z.jsx)(hh,{tracking:I})}),t[22]=I,t[23]=L);let R;t[24]!==D||t[25]!==E||t[26]!==y||t[27]!==f.setMode||t[28]!==p||t[29]!==g||t[30]!==r.inProgress||t[31]!==S?(R=r.inProgress!==`merge`&&(0,Z.jsx)(Es,{value:p,onValueChange:f.setMode,children:(0,Z.jsxs)(ws,{className:`w-full`,children:[(0,Z.jsx)(uo,{value:`single`,className:`flex-1`,disabled:S||E!=null,children:`Single commit`}),(0,Z.jsx)(uo,{value:`amend`,className:`flex-1`,disabled:S||D!=null,children:`Amend last`}),(0,Z.jsx)(uo,{value:`groups`,className:`flex-1`,disabled:S||E!=null||!g||!y.length,children:`Use groups`})]})}),t[24]=D,t[25]=E,t[26]=y,t[27]=f.setMode,t[28]=p,t[29]=g,t[30]=r.inProgress,t[31]=S,t[32]=R):R=t[32];let z=S||b,B;t[33]!==f||t[34]!==p?(B=p===`groups`?(0,Z.jsx)(vg,{form:f}):(0,Z.jsx)(ug,{form:f}),t[33]=f,t[34]=p,t[35]=B):B=t[35];let V;t[36]!==z||t[37]!==B?(V=(0,Z.jsx)(`fieldset`,{disabled:z,className:`flex min-w-0 flex-col gap-3`,children:B}),t[36]=z,t[37]=B,t[38]=V):V=t[38];let H;t[39]!==m||t[40]!==f?(H=m===`commit`&&(0,Z.jsx)(dg,{form:f}),t[39]=m,t[40]=f,t[41]=H):H=t[41];let U;t[42]!==f.currentMessage||t[43]!==p?(U=p!==`groups`&&!f.currentMessage.trim()&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,role:`status`,children:`Write or generate a message before committing.`}),t[42]=f.currentMessage,t[43]=p,t[44]=U):U=t[44];let W;t[45]===w?W=t[46]:(W=w&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-graph-4`,children:`The worktree changed since this draft was proposed. Generate it again before committing.`}),t[45]=w,t[46]=W);let G;t[47]!==m||t[48]!==e?(G=wg(e,m),t[47]=m,t[48]=e,t[49]=G):G=t[49];let ee;t[50]===G?ee=t[51]:(ee=(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:G}),t[50]=G,t[51]=ee);let te;t[52]!==C||t[53]!==x?(te=x&&!(C&&Xt(x))&&(0,Z.jsxs)(`div`,{role:`status`,className:`text-sm`,children:[(0,Z.jsx)(`p`,{children:x.state}),x.progress.map(lg)]}),t[52]=C,t[53]=x,t[54]=te):te=t[54];let ne;t[55]!==x||t[56]!==b?(ne=b&&!x&&(0,Z.jsx)(`p`,{role:`status`,children:`Outcome not yet confirmed`}),t[55]=x,t[56]=b,t[57]=ne):ne=t[57];let re;t[58]===C?re=t[59]:(re=C?(0,Z.jsx)(Cm,{text:Sn(C)}):null,t[58]=C,t[59]=re);let ie;t[60]!==f.lookAgain||t[61]!==a||t[62]!==x||t[63]!==w||t[64]!==S?(ie=(w||x&&n(x))&&a&&(0,Z.jsx)(Y,{type:`button`,variant:`outline`,disabled:S,onClick:f.lookAgain,children:`Look again`}),t[60]=f.lookAgain,t[61]=a,t[62]=x,t[63]=w,t[64]=S,t[65]=ie):ie=t[65];let ae;t[66]!==f.checkOutcome||t[67]!==h.operation||t[68]!==S?(ae=h.operation&&!S&&(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:f.checkOutcome,children:`Check outcome`}),t[66]=f.checkOutcome,t[67]=h.operation,t[68]=S,t[69]=ae):ae=t[69];let K;t[70]!==T||t[71]!==v||t[72]!==_||t[73]!==p||t[74]!==x||t[75]!==r.changes||t[76]!==r.inProgress||t[77]!==b||t[78]!==S?(K=S||b||!!(x&&n(x))||T||r.inProgress!==`merge`&&r.changes.some(cg)||!!(p===`groups`&&_?.every(e=>v.has(e.id))),t[70]=T,t[71]=v,t[72]=_,t[73]=p,t[74]=x,t[75]=r.changes,t[76]=r.inProgress,t[77]=b,t[78]=S,t[79]=K):K=t[79];let oe;t[80]===f?oe=t[81]:(oe=Tg(f),t[80]=f,t[81]=oe);let q;t[82]!==K||t[83]!==oe?(q=(0,Z.jsx)(Y,{type:`submit`,disabled:K,children:oe}),t[82]=K,t[83]=oe,t[84]=q):q=t[84];let se;return t[85]!==P||t[86]!==L||t[87]!==R||t[88]!==V||t[89]!==H||t[90]!==U||t[91]!==W||t[92]!==ee||t[93]!==te||t[94]!==ne||t[95]!==re||t[96]!==ie||t[97]!==ae||t[98]!==q||t[99]!==O||t[100]!==k?(se=(0,Z.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:O,onKeyDown:k,children:[P,L,R,V,H,U,W,ee,te,ne,re,ie,ae,q]}),t[85]=P,t[86]=L,t[87]=R,t[88]=V,t[89]=H,t[90]=U,t[91]=W,t[92]=ee,t[93]=te,t[94]=ne,t[95]=re,t[96]=ie,t[97]=ae,t[98]=q,t[99]=O,t[100]=k,t[101]=se):se=t[101],se}function cg(e){return e.scope===`unmerged`}function lg(e){return(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e},e)}function ug(e){let t=(0,$.c)(47),{form:n}=e,{commitAction:r,editingFiles:i,excluded:a,added:o,files:s,paths:c,currentMessage:l,working:u}=n,d=r===`amend`?`Files to add`:`Files`,f;t[0]===d?f=t[1]:(f=(0,Z.jsx)(`span`,{className:`font-medium`,children:d}),t[0]=d,t[1]=f);let p;t[2]!==s.length||t[3]!==c.length?(p=(0,Z.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[`(`,c.length,` of `,s.length,`)`]}),t[2]=s.length,t[3]=c.length,t[4]=p):p=t[4];let m;t[5]!==r||t[6]!==i||t[7]!==s.length||t[8]!==n||t[9]!==u?(m=r===`commit`&&s.length>0&&(0,Z.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,className:`ml-auto`,disabled:u,onClick:()=>n.toggleEditingFiles(),children:i?`Done`:`Edit`}),t[5]=r,t[6]=i,t[7]=s.length,t[8]=n,t[9]=u,t[10]=m):m=t[10];let h;t[11]!==f||t[12]!==p||t[13]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-caption`,children:[f,p,m]}),t[11]=f,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;if(t[15]!==o||t[16]!==r||t[17]!==i||t[18]!==a||t[19]!==s||t[20]!==n){let e;t[22]!==o||t[23]!==r||t[24]!==i||t[25]!==a||t[26]!==n?(e=e=>{let t=r===`amend`?o.has(e.path):!a.has(e.path),s=r===`amend`||i,c=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(hi,{path:e.path,className:`size-3.5 shrink-0`}),(0,Z.jsx)(X,{className:`min-w-0 flex-1`,text:e.path}),(0,Z.jsx)(`span`,{"aria-hidden":s,className:`shrink-0 text-muted-foreground`,children:Sg(e.kind,t,r)})]});return s?(0,Z.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 rounded-lg px-2 py-1 text-xs hover:bg-muted`,children:[(0,Z.jsx)(Jm,{checked:t,onCheckedChange:t=>n.setIncluded(e.path,t)}),c]},e.path):(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-lg px-2 py-1 text-xs`,children:c},e.path)},t[22]=o,t[23]=r,t[24]=i,t[25]=a,t[26]=n,t[27]=e):e=t[27],g=s.map(e),t[15]=o,t[16]=r,t[17]=i,t[18]=a,t[19]=s,t[20]=n,t[21]=g}else g=t[21];let _;t[28]===g?_=t[29]:(_=(0,Z.jsx)(`div`,{className:`max-h-40 overflow-auto rounded-xl border p-1`,children:g}),t[28]=g,t[29]=_);let v;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Et,{htmlFor:`commit-message`,children:`Message`}),t[30]=v):v=t[30];let y;t[31]!==r||t[32]!==n.draftedBy?(y=r===`commit`&&n.draftedBy.message&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.draftedBy.message}),t[31]=r,t[32]=n.draftedBy,t[33]=y):y=t[33];let b;t[34]===n?b=t[35]:(b=e=>n.setCurrentMessage(e.target.value),t[34]=n,t[35]=b);let x;t[36]!==l||t[37]!==n.messageLimit||t[38]!==b?(x=(0,Z.jsx)(Ir,{id:`commit-message`,value:l,onChange:b,rows:4,maxLength:n.messageLimit,placeholder:`Describe what changed and why`}),t[36]=l,t[37]=n.messageLimit,t[38]=b,t[39]=x):x=t[39];let S;t[40]!==x||t[41]!==y?(S=(0,Z.jsxs)(Ut,{children:[v,y,x]}),t[40]=x,t[41]=y,t[42]=S):S=t[42];let C;return t[43]!==S||t[44]!==h||t[45]!==_?(C=(0,Z.jsxs)(Z.Fragment,{children:[h,_,S]}),t[43]=S,t[44]=h,t[45]=_,t[46]=C):C=t[46],C}function dg(e){let t=(0,$.c)(57),{form:n}=e,{models:r,model:i}=n,a,o,s,c,l,u,d,f,p,m,h,g;if(t[0]!==n||t[1]!==i||t[2]!==r){let e=Nt(bt(r));s=e?.find(e=>e.id===i);let _;t[15]===n?_=t[16]:(_=gg(n),t[15]=n,t[16]=_),c=_,h=`flex flex-wrap items-center gap-2`;let v=!!c||n.working||n.uncertain,y;t[17]===n?y=t[18]:(y=()=>n.generate(),t[17]=n,t[18]=y);let b;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(Ac,{}),t[19]=b):b=t[19];let x=n.generator.result.waiting?`Generating…`:`Generate with AI`;t[20]!==v||t[21]!==y||t[22]!==x?(g=(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:v,onClick:y,children:[b,x]}),t[20]=v,t[21]=y,t[22]=x,t[23]=g):g=t[23],o=S,u=e?.map(hg)??[],d=i??null,f=!e?.length||n.working||n.uncertain,t[24]===n?p=t[25]:(p=e=>{e&&n.setModel(e)},t[24]=n,t[25]=p);let C=e?.length?`Choose a model`:`No coding CLI available`;t[26]===C?m=t[27]:(m=(0,Z.jsx)(Ge,{"aria-label":`Commit model`,className:`w-auto max-w-48`,size:`sm`,children:(0,Z.jsx)(Qe,{placeholder:C})}),t[26]=C,t[27]=m),a=G,l=Yp(e?.filter(mg)??[]).map(fg),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g}else a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14];let _;t[28]!==a||t[29]!==l?(_=(0,Z.jsx)(a,{children:l}),t[28]=a,t[29]=l,t[30]=_):_=t[30];let v;t[31]!==o||t[32]!==u||t[33]!==d||t[34]!==f||t[35]!==p||t[36]!==m||t[37]!==_?(v=(0,Z.jsxs)(o,{items:u,value:d,disabled:f,onValueChange:p,children:[m,_]}),t[31]=o,t[32]=u,t[33]=d,t[34]=f,t[35]=p,t[36]=m,t[37]=_,t[38]=v):v=t[38];let y;t[39]!==s?.label||t[40]!==i||t[41]!==c?(y=c??`Sends the selected changes to ${s?.label} through ${i?.split(`:`)[0]===`claude`?`Claude Code`:`Codex`}.`,t[39]=s?.label,t[40]=i,t[41]=c,t[42]=y):y=t[42];let b;t[43]===y?b=t[44]:(b=(0,Z.jsx)(`p`,{className:`w-full text-xs text-muted-foreground`,role:`status`,children:y}),t[43]=y,t[44]=b);let x;t[45]!==n.generate||t[46]!==n.generator.result||t[47]!==n.uncertain||t[48]!==n.working||t[49]!==c?(x=Qt(n.generator.result)&&!n.working&&(0,Z.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:!!c||n.uncertain,onClick:n.generate,children:`Try again`}),t[45]=n.generate,t[46]=n.generator.result,t[47]=n.uncertain,t[48]=n.working,t[49]=c,t[50]=x):x=t[50];let C;return t[51]!==v||t[52]!==b||t[53]!==x||t[54]!==h||t[55]!==g?(C=(0,Z.jsxs)(`div`,{className:h,children:[g,v,b,x]}),t[51]=v,t[52]=b,t[53]=x,t[54]=h,t[55]=g,t[56]=C):C=t[56],C}function fg(e){let[t,n]=e;return(0,Z.jsxs)(sn,{children:[(0,Z.jsx)(qe,{children:t}),n.map(pg)]},t)}function pg(e){return(0,Z.jsx)(B,{value:e.id,children:e.label},e.id)}function mg(e){return!e.id.endsWith(`:default`)}function hg(e){return{value:e.id,label:e.label}}function gg({models:e,model:t,paths:n}){if(Qt(e))return`Could not load coding CLI models. You can still commit manually.`;let r=Nt(bt(e));return r?!t&&r.some(e=>!e.id.endsWith(`:default`))?`Choose a model to generate a message.`:t?n.length?null:`Select files to generate a message.`:`No coding CLI available. Write a message to commit manually.`:`Loading coding CLI models…`}function _g(e,t){return e?`Groups were not proposed.`:t?`Proposing commits…`:`Generate groups with AI, then review each message and file before committing.`}function vg(e){let t=(0,$.c)(34),{form:n}=e,{groups:r,done:i,activeGroup:a,files:o,leftUncommitted:s,error:c}=n;if(r===null){let e;t[0]!==c||t[1]!==n.working?(e=_g(c,n.working),t[0]=c,t[1]=n.working,t[2]=e):e=t[2];let r;return t[3]===e?r=t[4]:(r=(0,Z.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:e}),t[3]=e,t[4]=r),r}let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l={value:`uncommitted`,label:`Leave uncommitted`},t[5]=l):l=t[5];let u;t[6]===r?u=t[7]:(u=[l,...r.map(xg)],t[6]=r,t[7]=u);let d=u,f;t[8]===n.draftedBy.groups?f=t[9]:(f=n.draftedBy.groups&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.draftedBy.groups}),t[8]=n.draftedBy.groups,t[9]=f);let p;t[10]!==a||t[11]!==d||t[12]!==i||t[13]!==o||t[14]!==n||t[15]!==r?(p=r.map((e,t)=>(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2 rounded-lg border p-3`,"aria-label":`Commit ${t+1}`,children:[(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Commit `,t+1,Cg(e.id,i,a)]}),e.paths.length===0&&i.size===0&&(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>n.removeGroup(e.id),children:`Remove empty group`}),(0,Z.jsx)(Ir,{"aria-label":`Message for commit ${t+1}`,value:e.message,disabled:i.has(e.id),required:!0,maxLength:n.messageLimit,onChange:t=>n.setGroupMessage(e.id,t.target.value)}),o.filter(t=>e.paths.includes(t.path)).map(t=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs`,children:[(0,Z.jsx)(X,{className:`min-w-0 flex-1`,text:t.path}),(0,Z.jsxs)(S,{items:d,value:e.id,disabled:i.size>0,onValueChange:e=>{e&&n.moveFile(t.paths,e)},children:[(0,Z.jsx)(Ge,{size:`sm`,"aria-label":`Commit for ${t.path}`,children:(0,Z.jsx)(Qe,{})}),(0,Z.jsxs)(G,{children:[(0,Z.jsx)(B,{value:`uncommitted`,children:`Leave uncommitted`}),r.map(bg)]})]})]},t.path))]},e.id)),t[10]=a,t[11]=d,t[12]=i,t[13]=o,t[14]=n,t[15]=r,t[16]=p):p=t[16];let m;t[17]!==d||t[18]!==i.size||t[19]!==n||t[20]!==r||t[21]!==s?(m=s.length>0&&(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2 rounded-lg border border-dashed p-3`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Left uncommitted`}),s.map(e=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs`,children:[(0,Z.jsx)(X,{className:`min-w-0 flex-1`,text:e.path}),(0,Z.jsxs)(S,{items:d,value:`uncommitted`,disabled:i.size>0,onValueChange:t=>{t&&n.moveFile(e.paths,t)},children:[(0,Z.jsx)(Ge,{size:`sm`,"aria-label":`Commit for ${e.path}`,children:(0,Z.jsx)(Qe,{})}),(0,Z.jsxs)(G,{children:[(0,Z.jsx)(B,{value:`uncommitted`,children:`Leave uncommitted`}),r.map(yg)]})]})]},e.path))]}),t[17]=d,t[18]=i.size,t[19]=n,t[20]=r,t[21]=s,t[22]=m):m=t[22];let h;t[23]!==i.size||t[24]!==n.addGroup||t[25]!==n.clearGroups||t[26]!==n.groupLimit||t[27]!==r.length?(h=i.size===0&&(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:r.length>=n.groupLimit,onClick:n.addGroup,children:[(0,Z.jsx)(Cr,{}),`Add group`]}),(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:n.clearGroups,children:`Single commit`})]}),t[23]=i.size,t[24]=n.addGroup,t[25]=n.clearGroups,t[26]=n.groupLimit,t[27]=r.length,t[28]=h):h=t[28];let g;return t[29]!==f||t[30]!==p||t[31]!==m||t[32]!==h?(g=(0,Z.jsxs)(Z.Fragment,{children:[f,p,m,h]}),t[29]=f,t[30]=p,t[31]=m,t[32]=h,t[33]=g):g=t[33],g}function yg(e,t){return(0,Z.jsxs)(B,{value:e.id,children:[`Commit `,t+1]},e.id)}function bg(e,t){return(0,Z.jsxs)(B,{value:e.id,children:[`Commit `,t+1]},e.id)}function xg(e,t){return{value:e.id,label:`Commit ${t+1}`}}function Sg(e,t,n){return t?e.replaceAll(`-`,` `):n===`amend`?`Not added`:`Excluded`}function Cg(e,t,n){return t.has(e)?` · committed`:n===e?` · in progress`:``}function wg({status:e,liveBranch:t,replacedSubject:n},r){return r===`amend`?`Amending replaces the last commit${n?`: ${n}`:``}. ${t?.upstream&&t.ahead===0?`This commit is already on the known upstream; amending rewrites shared history.`:`Unselected staged changes stay staged.`}`:e.inProgress===`merge`?`This finishes the merge and commits every staged resolution, including staged files outside your selection.`:`Selected files use their current contents. Other staged files stay staged.`}function Tg({working:e,generator:t,groups:n,commitAction:r}){return e?t.result.waiting?`Generating…`:r===`amend`?`Amending…`:`Committing…`:n&&r===`commit`?`Commit groups in order`:r===`amend`?`Amend last commit`:`Commit selected files`}function Eg(e){let t=(0,$.c)(14),{scope:n,context:r,entry:i,status:a,onBusy:o,onLookAgain:s}=e;if(i===`switch`||i===`discard`||i===`fetch`||i===`pull`||i===`push`)return null;if(i===`commit`||i===`amend`){let e;return t[0]!==r||t[1]!==i||t[2]!==o||t[3]!==s||t[4]!==n||t[5]!==a?(e=(0,Z.jsx)(Dg,{scope:n,context:r,action:i,status:a,onBusy:o,onLookAgain:s}),t[0]=r,t[1]=i,t[2]=o,t[3]=s,t[4]=n,t[5]=a,t[6]=e):e=t[6],e}let c;return t[7]!==r||t[8]!==i||t[9]!==o||t[10]!==s||t[11]!==n||t[12]!==a?(c=(0,Z.jsx)(kg,{scope:n,context:r,action:i,status:a,onBusy:o,onLookAgain:s},i),t[7]=r,t[8]=i,t[9]=o,t[10]=s,t[11]=n,t[12]=a,t[13]=c):c=t[13],c}function Dg(e){let t=(0,$.c)(17),{scope:n,context:r,action:i,status:a,onBusy:o,onLookAgain:s}=e,c;t[0]===i?c=t[1]:(c=(0,Z.jsx)(Og,{action:i}),t[0]=i,t[1]=c);let l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`p`,{role:`status`,children:`Reading commit details…`}),t[2]=l):l=t[2];let u;t[3]===c?u=t[4]:(u=(0,Z.jsxs)(Z.Fragment,{children:[c,l]}),t[3]=c,t[4]=u);let d;t[5]!==i||t[6]!==r||t[7]!==o||t[8]!==s||t[9]!==n||t[10]!==a?(d=e=>{let t=e.headCommit;return i===`amend`&&!t?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Og,{action:i}),(0,Z.jsx)(`p`,{role:`alert`,children:`The last commit could not be read. Close and try again.`})]}):(0,Z.jsx)(sg,{scope:n,context:r,action:i,status:a,liveBranch:e.branch??a.branch,initialMessage:i===`amend`&&t?[t.subject,t.body].filter(Boolean).join(`
|
|
18
|
+
`)}function $u(e,t){let n=e.additionLineIndex,r=e.deletionLineIndex;e.hunkContent=t.hunkContent.map(e=>ed(e,n,r)),e.additionLineIndex=n+t.additionLineIndex,e.additionStart+=t.additionLineIndex,e.additionCount=t.additionCount,e.additionLines=t.additionLines,t.deletionLineIndex>=0&&(e.deletionLineIndex=r+t.deletionLineIndex,e.deletionStart+=t.deletionLineIndex),e.deletionCount=t.deletionCount,e.deletionLines=t.deletionLines,e.noEOFCRAdditions=t.noEOFCRAdditions,e.noEOFCRDeletions=t.noEOFCRDeletions,td(e)}function ed(e,t,n){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+n}}function td(e){let t=0,n=0;for(let r of e.hunkContent)r.type===`context`?(t+=r.lines,n+=r.lines):(t+=Math.max(r.additions,r.deletions),n+=r.additions+r.deletions);e.splitLineCount=t,e.unifiedLineCount=n}function nd(e){let t=0,n=0,r=0;for(let i of e.hunks)i.collapsedBefore=Math.max(li(i.additionStart,i.additionCount)-r,0),i.splitLineStart=t+i.collapsedBefore,i.unifiedLineStart=n+i.collapsedBefore,td(i),t+=i.collapsedBefore+i.splitLineCount,n+=i.collapsedBefore+i.unifiedLineCount,r=Oi(i.additionStart,i.additionCount);if(e.hunks.length>0){let r=e.hunks[e.hunks.length-1],i=Math.max(e.additionLines.length-Oi(r.additionStart,r.additionCount),0);t+=i,n+=i}e.splitLineCount=t,e.unifiedLineCount=n}var rd=new WeakMap;function id(e){return e.length>1&&e[e.length-1]===``?e.slice(0,-1):e}function ad(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;let i=e.length,a=t.length;for(;i>r&&a>r&&e[i-1]===t[a-1];)i--,a--;if(r!==i||r!==a)return{start:r,deletionEnd:i,additionEnd:a}}function od(e,t,n){let r=e.hunks,i=e.additionLines,a=id(i),o=a===i?e:{...e,additionLines:a},s=_d(r,hd(o,t,n),e.deletionLines.length),c=bd(o,s);if(e.additionLines=a,e.hunks=c,e.editSessionDirty=!0,Ad(e),Ku(e,i),Cd(r,e.hunks))return{regions:s.map(e=>e.previousSpan)}}function sd(e,t,n,r){let i=new Set(t),a=Array.from(i).filter(t=>t>=0&&t<e.additionLines.length).sort((e,t)=>e-t);if(a.length===0)return;let o=t=>i.has(t)?r?.get(t):e.additionLines[t],{hunks:s}=e,c,l=0;for(let t of a){for(;l<s.length;){let e=s[l];if(t<Ed(e)+e.additionCount)break;l++}let r=s[l],i=r==null?void 0:Ed(r);if(i==null||t<i||c!=null&&c!==l)return od(e,n,o);c=l}if(c!=null){if(cd(e,a,c,r,n))e.editSessionDirty=!0;else return od(e,n,o)}}function cd(e,t,n,r,i){if(r==null||i?.ignoreWhitespace===!0||i?.stripTrailingCr===!0)return!1;let a=ld(e),o=e.hunks[n];if(o.hunkContent.some(ud))return!1;for(let n of t){let t=r.get(n),i=e.additionLines[n];if(t==null||i==null||a.has(t)||a.has(i))return!1;let s=!1;for(let e of o.hunkContent)if(e.type===`change`&&e.additions===e.deletions&&n>=e.additionLineIndex&&n<e.additionLineIndex+e.additions){s=!0;break}if(!s)return!1}return!0}function ld(e){let t=rd.get(e);if(t?.lines===e.deletionLines)return t.set;let n=new Set(e.deletionLines);return rd.set(e,{lines:e.deletionLines,set:n}),n}function ud(e){return e?.type===`change`&&(e.additions===0||e.deletions===0)}function dd(e,t){let n=new Map,{regions:r}=t;for(let t=0;t<=r.length;t++){let i=r[t-1],a=r[t],o=t===0?e.get(0):i==null?void 0:e.get(i.lastIndex+1),s=a==null?void 0:e.get(a.firstIndex),c=o?.fromStart??0,l=s?.fromEnd??0;(c>0||l>0)&&n.set(t,{fromStart:c,fromEnd:l})}return n}function fd(e,t,n){let r=[];if(e.isPartial)return r;for(let[i,a]of e.hunks.entries()){let o=Qr({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:t,hunkIndex:i,collapsedContextThreshold:n});if(o.rangeSize<=n)continue;let s=Dd(a),c=s-o.rangeSize;o.fromStart>0&&r.push([c,c+o.fromStart]),o.fromEnd>0&&r.push([s-o.fromEnd,s])}let i=ni({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`captureExpansionAnchors`});if(i!=null&&i.fromStart>0&&i.rangeSize>n){let t=e.hunks[e.hunks.length-1],n=Dd(t)+t.deletionCount;r.push([n,n+i.fromStart])}return r}function pd(e,t){let n=new Map;if(t.length===0)return n;let r=(e,r,i)=>{if(i<=r)return;let a=0,o=0;for(let[e,n]of t)n<=r||e>=i||(e<=r&&(a=Math.max(a,Math.min(n,i)-r)),n>=i&&(o=Math.max(o,i-Math.max(e,r))));(a>0||o>0)&&n.set(e,{fromStart:a,fromEnd:o})};for(let[t,n]of e.hunks.entries()){let e=Dd(n);r(t,e-Math.max(n.collapsedBefore,0),e)}let i=e.hunks[e.hunks.length-1];return i!=null&&!e.isPartial&&e.deletionLines.length>0&&r(e.hunks.length,Dd(i)+i.deletionCount,e.deletionLines.length),n}function md(e,t){return e.editSessionDirty===!0&&(delete e.editSessionDirty,Object.assign(e,e.additionLines.length<=1&&e.additionLines.join(``)===``?Ru(e,t):Wu(e,t)),!0)}function hd(e,t,n){if(ad(e.deletionLines,e.additionLines)==null)return[];let r=Fu({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t),i,a=(t,a)=>{i??=gd(e.hunks);for(let e=0;e<=a;e++){let o=i.get(t.deletionLineIndex-e);if(o!=null&&o.additions===t.additions&&o.deletions===t.deletions){if(t.additions>0&&n!=null){for(let e=0;e<t.additions;e++)if(n(o.additionLineIndex+e)!==r.additionLines[t.additionLineIndex+e])return a}return e}}return a},o=[],s=0,c=0;for(let e of r.hunks){gr(e,r,a);let t=e.additionCount>0?e.additionLineIndex-s:e.deletionLineIndex-c;s+=t,c+=t;for(let t of e.hunkContent){if(t.type===`context`){s+=t.lines,c+=t.lines;continue}let e=ed(t,0,0);e.additions===0&&(e.additionLineIndex=s),e.deletions===0&&(e.deletionLineIndex=c),o.push(e),s+=e.additions,c+=e.deletions}}return o}function gd(e){let t=new Map;for(let n of e)for(let e of n.hunkContent)e.type===`change`&&(e.additions===0||e.deletions===0)&&t.set(e.deletionLineIndex,e);return t}function _d(e,t,n){let r=e.map((e,t)=>{let n=Dd(e);return{deletionStart:n,deletionEnd:n+e.deletionCount,blocks:[],previousSpan:{firstIndex:t,lastIndex:t}}}),i=[],a=0;for(let e of t){let t=e.deletionLineIndex,o=t+e.deletions;for(;a<r.length&&r[a].deletionEnd<t;)i.push(r[a]),a++;let s=i.length>0&&vd(t,o,i[i.length-1])?i.pop():void 0;for(;a<r.length&&r[a].deletionStart<=o;)s=yd(s,r[a]),a++;if(s==null){let c=t,l=o;if((e.deletions===0||e.additions===0)&&n>e.deletions){let e=i[i.length-1]?.deletionEnd??0,s=r[a]?.deletionStart??n;t>e?c--:o<s&&l++}s={deletionStart:c,deletionEnd:l,blocks:[],previousSpan:void 0}}s.deletionStart=Math.min(s.deletionStart,t),s.deletionEnd=Math.max(s.deletionEnd,o),s.blocks.push(e),i.push(s)}for(;a<r.length;)i.push(r[a]),a++;return i}function vd(e,t,n){return e<=n.deletionEnd&&t>=n.deletionStart}function yd(e,t){return e==null?t:(e.deletionStart=Math.min(e.deletionStart,t.deletionStart),e.deletionEnd=Math.max(e.deletionEnd,t.deletionEnd),e.blocks.push(...t.blocks),t.previousSpan!=null&&(e.previousSpan??={...t.previousSpan},e.previousSpan.firstIndex=Math.min(e.previousSpan.firstIndex,t.previousSpan.firstIndex),e.previousSpan.lastIndex=Math.max(e.previousSpan.lastIndex,t.previousSpan.lastIndex)),e)}function bd(e,t){let n=[],r=0,i=0;for(let a of t){let t=a.deletionStart-r;if(t<0)throw Error(`buildRegionHunks: overlapping old-side regions`);r+=t,i+=t;let o=i,s=[];for(let e of a.blocks){let t=e.deletionLineIndex-r,n=e.additionLineIndex-i;if(t<0||t!==n)throw Error(`buildRegionHunks: canonical block context mismatch`);Sd(s,t,i,r),r+=t,i+=n,s.push({...e}),r+=e.deletions,i+=e.additions}let c=a.deletionEnd-r;if(c<0)throw Error(`buildRegionHunks: block exceeds its old-side region`);Sd(s,c,i,r),r+=c,i+=c,n.push(xd(e,{additionStart:o,additionEnd:i,deletionStart:a.deletionStart,deletionEnd:a.deletionEnd},s))}if(e.deletionLines.length-r!==e.additionLines.length-i)throw Error(`buildRegionHunks: trailing context mismatch`);return n}function xd(e,t,n){let r=t.additionEnd-t.additionStart,i=t.deletionEnd-t.deletionStart,a=0,o=0;for(let e of n)e.type===`change`&&(a+=e.additions,o+=e.deletions);let s={collapsedBefore:0,additionStart:Od(t.additionStart,r),additionCount:r,additionLines:a,additionLineIndex:kd(t.additionStart,r),deletionStart:Od(t.deletionStart,i),deletionCount:i,deletionLines:o,deletionLineIndex:kd(t.deletionStart,i),hunkContent:n,hunkSpecs:`@@ -${Od(t.deletionStart,i)},${i} +${Od(t.additionStart,r)},${r} @@`,splitLineStart:0,splitLineCount:0,unifiedLineStart:0,unifiedLineCount:0,noEOFCRAdditions:!1,noEOFCRDeletions:!1};return td(s),s}function Sd(e,t,n,r){t>0&&e.push({type:`context`,lines:t,additionLineIndex:n,deletionLineIndex:r})}function Cd(e,t){if(e.length!==t.length)return!0;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(Dd(r)!==Dd(i)||r.deletionCount!==i.deletionCount||Ed(r)!==Ed(i)||r.additionCount!==i.additionCount||r.splitLineCount!==i.splitLineCount||!wd(r,i))return!0}return!1}function wd(e,t){let n=Td(e),r=Td(t);for(;;){let e=n.next(),t=r.next();if(e.done===!0||t.done===!0)return e.done===t.done;if(e.value[0]!==t.value[0]||e.value[1]!==t.value[1])return!1}}function*Td(e){for(let t of e.hunkContent){if(t.type===`context`){for(let e=0;e<t.lines;e++)yield[t.deletionLineIndex+e,t.additionLineIndex+e];continue}let e=Math.max(t.deletions,t.additions);for(let n=0;n<e;n++)yield[n<t.deletions?t.deletionLineIndex+n:void 0,n<t.additions?t.additionLineIndex+n:void 0]}}function Ed(e){return li(e.additionStart,e.additionCount)}function Dd(e){return li(e.deletionStart,e.deletionCount)}function Od(e,t){return t===0?e:e+1}function kd(e,t){return t===0?e-1:e}function Ad(e){nd(e);for(let t=0;t<e.hunks.length;t++)Qu(e,t)}function jd(e){return Ls({tagName:`div`,properties:{"data-content-buffer":``,"data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function Md(e){return Ls({tagName:`div`,children:[Ls({tagName:`span`,children:[Ps(`No newline at end of file`)]})],properties:{"data-no-newline":``,"data-line-type":e,"data-column-content":``}})}function Nd(e){return Ls({tagName:`div`,children:[Ms({name:e===`both`?`diffs-icon-expand-all`:`diffs-icon-expand`,properties:{"data-icon":``}})],properties:{role:`button`,"data-expand-button":``,"data-expand-both":e===`both`?``:void 0,"data-expand-up":e===`up`?``:void 0,"data-expand-down":e===`down`?``:void 0}})}function Pd({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:a,isLastHunk:o}){let s=0,c=[];if(e===`metadata`&&t!=null&&c.push(Ls({tagName:`div`,children:[Ps(t)],properties:{"data-separator-wrapper":``}})),(e===`line-info`||e===`line-info-basic`)&&t!=null){let e=[];n!=null&&(r?(a||(e.push(Nd(`up`)),s++),o||(e.push(Nd(`down`)),s++)):(e.push(Nd(!a&&!o?`both`:a?`down`:`up`)),s++)),e.push(Ls({tagName:`div`,children:[Ls({tagName:`span`,children:[Ps(t)],properties:{"data-unmodified-lines":``}})],properties:{"data-separator-content":``}})),r&&n!=null&&e.push(Ls({tagName:`div`,children:[Ps(`Expand all`)],properties:{role:`button`,"data-expand-button":``,"data-expand-all-button":``}})),c.push(Ls({tagName:`div`,children:e,properties:{"data-separator-wrapper":``,"data-separator-multi-button":s>1?``:void 0}}))}return e===`custom`&&i!=null&&c.push(Ls({tagName:`slot`,properties:{name:i}})),Ls({tagName:`div`,children:c,properties:{"data-separator":c.length===0?`simple`:e,"data-expand-index":n,"data-separator-first":a?``:void 0,"data-separator-last":o?``:void 0}})}function Fd(e,t){return`hunk-separator-${e}-${t}`}function Id(e){let t=e.at(-1);return t==null?0:Math.max(Oi(t.additionStart,t.additionCount),Oi(t.deletionStart,t.deletionCount))}var Ld=-1,Rd=class{options;annotationSlotName;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++Ld}`;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLangs=[`text`];renderCache;pendingHighlightResult;pendingStructuralRows;editSessionActive=!1;constructor(e={theme:bo},t=ao,n,r){this.options=e,this.annotationSlotName=t,this.onRenderUpdate=n,this.workerManager=r}cleanUp(){this.endEditSession(),this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.diff=void 0,this.editSessionActive?(this.renderCache!=null&&(this.renderCache.renderRange=void 0),this.pendingHighlightResult=void 0,this.pendingStructuralRows=void 0):this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this)}beginEditSession(e,t){let{editSessionActive:n}=this;this.editSessionActive=!0,n||(this.pendingHighlightResult=void 0),this.diff=e,n&&this.renderCache!=null&&this.renderCache.diff!==e&&this.clearRenderCache();let{renderCache:r}=this;if(!e.isPartial&&e.additionLines.length===0){Object.assign(e,Uu(e,this.options.parseDiffOptions)),this.markEditSessionPass(e),this.clearRenderCache();return}if(r==null||n&&r.diff===e)return;let{options:i}=this.getRenderOptions(e),a=r.diff===e,o=t!=null&&Hi(r.diff,t),{result:s}=r;!r.highlighted||s==null||!vi(r.options,i)||!a&&!o?this.clearRenderCache():a||(this.renderCache={diff:e,options:i,highlighted:!0,result:{...s,code:{...s.code,additionLines:[...s.code.additionLines]}},renderRange:r.renderRange})}endEditSession(){this.editSessionActive=!1,this.pendingHighlightResult=void 0,this.diff??this.clearRenderCache()}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}refreshHighlightedResult(){let{diff:e,renderCache:t,workerManager:n}=this;return e==null||t==null||!Hi(t.diff,e)||Gn(e)||Qd(e,this.getTokenizeMaxLength())?Promise.resolve():!this.editSessionActive&&n?.isWorkingPool()===!0&&e.cacheKey!=null?(n.evictDiffFromCache(e.cacheKey),n.primeDiffHighlightCache(e).then(()=>{this.applyRefreshedResult(e,n.getDiffResultCache(e))}).catch(e=>{$o(e)||this.onHighlightError(e)})):this.asyncHighlight(e).then(t=>this.applyRefreshedResult(e,t)).catch(e=>this.onHighlightError(e))}applyRefreshedResult(e,t){let{diff:n,renderCache:r}=this;if(t==null||n==null||r==null||!Hi(n,e)||!Hi(r.diff,e)||this.editSessionActive)return;let{options:i}=this.getRenderOptions(n);vi(i,t.options)&&(this.pendingHighlightResult={diff:n,options:t.options,highlighted:!0,result:t.result},this.onRenderUpdate?.())}get diffCache(){return this.renderCache?.diff??this.diff}clearRenderCache(){this.renderCache=void 0,this.pendingHighlightResult=void 0,this.pendingStructuralRows=void 0}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){let r={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};(t===`up`||t===`both`)&&(r.fromStart+=n),(t===`down`||t===`both`)&&(r.fromEnd+=n),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??_o}getExpandedHunksMap(){return this.expandedHunks}setExpandedHunksMap(e){this.expandedHunks=e}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(let t of e){let e=(()=>{switch(t.side){case`deletions`:return this.deletionAnnotations;case`additions`:return this.additionAnnotations}})(),n=e[t.lineNumber]??[];e[t.lineNumber]=n,n.push(t)}}updateRenderCache(e,t,n=!1,r,i){this.pendingStructuralRows=void 0;let{renderCache:a}=this;if(a==null)return!1;let{result:o,diff:s}=a;if(o==null)return!1;if(s.isPartial)throw Error(`Could not update render cache for partial diff`);let c=o.code.additionLines,l=this.pendingStructuralRows=n?new Map:void 0,u=[],d=new Map;if(l==null&&r!=null){let t=s.additionLines.length,n=Jd(s.additionLines,i);for(let[i,a]of r){if(i<0||i>t||i===t&&(a===``||!n))continue;let r=s.additionLines[i]??``;r!==a&&(s.additionLines[i]=a,s.additionCharacterCount+=a.length-r.length,u.push(i),d.set(i,r),e.has(i)||(c[i]=Yd(i,pr(a))))}}for(let[t,n]of e){let e=c[t]?.properties??{},i=n.map(e=>e[2]).join(``),a=t<s.additionLines.length,o=a?s.additionLines[t]??``:``,f=pr(o);if(l==null&&a&&r?.has(t)!==!0){let e=uo(o,i);s.additionLines[t]=e,s.additionCharacterCount+=e.length-o.length,f!==i&&(u.push(t),d.set(t,o))}let p={type:`element`,tagName:`div`,properties:{"data-line":e[`data-line`]??t+1,"data-line-index":e[`data-line-index`]??t,"data-line-type":e[`data-line-type`]??`context`},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})};l==null?c[t]=p:l.set(t,p)}let f=!1;if(u.length>0){if(this.editSessionActive){if(s.additionLines.length<=1&&s.additionLines.join(``)===``)this.applyRecomputePreservingSessionType(s,Uu(s,this.options.parseDiffOptions)),f=!0;else if(Vu(s,s.additionLines))this.applyRecomputePreservingSessionType(s,Hu(s,s.additionLines,s.additionCharacterCount,this.options.parseDiffOptions)),f=!0;else{let e=sd(s,u,this.options.parseDiffOptions,d);this.applyExpansionRemap(e),f=e!=null}}else Object.assign(s,qu(s,u,this.options.parseDiffOptions))}return o.baseThemeType=t,a.isDirty=!0,f}applyExpansionRemap(e){e!=null&&(this.expandedHunks=dd(this.expandedHunks,e))}applyDocumentChange(e){let{pendingStructuralRows:t,renderCache:n}=this;this.pendingStructuralRows=void 0;let r=this.diff??n?.diff;if(r==null)return;let i=n?.result;if(r.isPartial)throw Error(`Could not apply document change for partial diff`);let{additionLines:a}=r,{lines:o,characterCount:s}=Xd(e);if(r.additionLines=o,r.additionCharacterCount=s,i!=null&&(i.code.additionLines=qd(a,r.additionLines,i.code.additionLines,e)),r.additionLines.length<=1&&r.additionLines.join(``)===``?(this.applyRecomputePreservingSessionType(r,Uu(r,this.options.parseDiffOptions)),i!=null&&(i.code.additionLines[0]=Yd(0,e.getLineText(0)))):this.editSessionActive?this.applySessionDocumentChange(r,a):Object.assign(r,Wu(r,this.options.parseDiffOptions)),t!=null&&i!=null)for(let[e,n]of t)e<i.code.additionLines.length&&(i.code.additionLines[e]=n);n!=null&&(n.isDirty=!0)}applySessionDocumentChange(e,t){let{parseDiffOptions:n}=this.options,r=e.additionLines;Vu(e,r)?this.applyRecomputePreservingSessionType(e,Hu(e,r,e.additionCharacterCount,n)):this.applyExpansionRemap(od(e,n,e=>t[e]))}applyRecomputePreservingSessionType(e,t){let n=this.editSessionActive?e.type:void 0;Object.assign(e,t),n!=null&&(e.type=n),this.markEditSessionPass(e)}markEditSessionPass(e){this.editSessionActive&&(e.editSessionDirty=!0)}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e,contentProperties:{"data-line-type":e}}}getSplitLineDecoration({side:e,type:t}){let n=t===`change`?e===`deletions`?`change-deletion`:`change-addition`:t;return{gutterLineType:n,contentProperties:{"data-line-type":n}}}createAnnotationElement=e=>Ja(e);getOptionsWithDefaults(){let{diffIndicators:e=`bars`,diffStyle:t=`split`,disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:a=!1,collapsed:o=!1,expandUnchanged:s=!1,collapsedContextThreshold:c=1,expansionLineCount:l=100,hunkSeparators:u=`line-info`,lineDiffType:d=`word-alt`,maxLineDiffLength:f=1e3,overflow:p=`scroll`,stickyHeader:m=!1,theme:h=bo,headerRenderMode:g=`default`,tokenizeMaxLineLength:_=1e3,tokenizeMaxLength:v=Ia,useTokenTransformer:y=!1,useCSSClasses:b=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:a,collapsed:o,expandUnchanged:s,collapsedContextThreshold:c,expansionLineCount:l,hunkSeparators:u,lineDiffType:d,maxLineDiffLength:f,overflow:p,stickyHeader:m,theme:this.workerManager?.getDiffRenderOptions().theme??h,headerRenderMode:g,tokenizeMaxLineLength:_,tokenizeMaxLength:v,useTokenTransformer:y,useCSSClasses:b}}initializeHighlighter(){return Sa(eo(this.computedLangs,{theme:this.getLocalHighlightTheme(),preferredHighlighter:Oo(this.workerManager,this.options)}))}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=Qd(e,this.getTokenizeMaxLength()),r=this.workerManager?.getDiffResultCache(e);r!=null&&!vi(t,r.options)&&(r=void 0),this.renderCache??={diff:e,hydrated:!0,highlighted:!n&&!Gn(e),options:t,result:n?void 0:r?.result,renderRange:void 0};let i=this.getHighlightWorkerManager(e);i==null?Xo({theme:this.getLocalHighlightTheme()})??(this.computedLangs=Zd(e),this.initializeHighlighter().catch(e=>{e instanceof Fs||this.onHighlightError(e)})):this.renderCache.result==null&&!n&&i.highlightDiffAST(this,this.diff)}getHighlightWorkerManager(e){let{editSessionActive:t,workerManager:n}=this;return!t&&n?.isWorkingPool()===!0&&!n.shouldHighlightOnMainThread(e)?n:void 0}cacheHighlightResult(e,t){let{editSessionActive:n,workerManager:r}=this;!n&&r?.isWorkingPool()===!0&&r.setDiffResultCache(e.cacheKey,t)}getLocalHighlightTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??bo}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getDiffRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let e=this.workerManager.getDiffRenderOptions();return this.editSessionActive&&e.useTokenTransformer!==!0?{...e,useTokenTransformer:!0}:e}let{theme:e,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}=this.getOptionsWithDefaults();return{theme:e,useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}})();this.getOptionsWithDefaults();let{renderCache:n}=this;return n?.result==null||!Hi(e,n.diff)||!vi(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}getDiffForNextRender(e){let{options:t}=this.getRenderOptions(e);if(this.getReadyRenderResult(e,t)!=null||this.renderCache==null)return e;if(Hi(this.renderCache.diff,e))return this.renderCache.diff;let n=!(e.additionLines.length>0||e.deletionLines.length>0)||Gn(e)||Qd(e,this.getTokenizeMaxLength());return this.canRenderDiff(e,t,n)?e:this.renderCache.diff}canRenderDiff(e,t,n){let{renderCache:r}=this;return r==null||Hi(r.diff,e)?!0:n?r.result==null&&r.hydrated!==!0||this.workerManager?.isWorkingPool()===!0&&!this.workerManager.shouldHighlightOnMainThread(e)||Xo({theme:t.theme})!=null:r.result==null&&r.hydrated!==!0?!0:this.getHighlightWorkerManager(e)==null?Xo({theme:t.theme})!=null:!r.highlighted}renderDiff(e=this.diff,t=Ra){if(this.diff=e,e==null){this.pendingHighlightResult=void 0;return}let{expandUnchanged:n,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),{options:i,forceHighlight:a}=this.getRenderOptions(e),o=this.getReadyRenderResult(e,i);this.pendingHighlightResult=void 0,o!=null&&(this.renderCache={...o,diff:e,renderRange:void 0},a=!1),this.renderCache??={diff:e,highlighted:!1,options:i,result:void 0,renderRange:void 0};let s=e.additionLines.length>0||e.deletionLines.length>0,c=!s||Gn(e)||Qd(e,this.getTokenizeMaxLength()),l=this.canRenderDiff(e,i,c),u=!Hi(e,this.renderCache.diff),d=!As(this.renderCache.renderRange,t),f=this.getHighlightWorkerManager(e);if(f!=null){let o=this.renderCache.result==null&&this.renderCache.highlighted&&!c&&!u&&Za(t);l&&!o&&(c||this.renderCache.result==null||!this.renderCache.highlighted&&(u||d))&&(this.renderCache.diff=e,this.renderCache.options=i,this.renderCache.highlighted=!1,(this.renderCache.result==null||u||d||a)&&(this.renderCache.result=f.getPlainDiffAST(e,t.startingLine,t.totalLines,Za(t)||n?!0:this.expandedHunks,r)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||a)&&f.highlightDiffAST(this,e)}else{this.computedLangs=Zd(e);let n=Xo(),r=n!=null&&Xa(i.theme,n),o=n!=null&&Aa(this.computedLangs,n),s=!c&&o,u=Number.isFinite(t.totalLines);if(l&&n!=null&&r&&(a||c||!this.renderCache.highlighted&&s||this.renderCache.result==null)){let{result:t,options:r}=this.renderDiffWithHighlighter(e,n,c||!o,u);this.renderCache={diff:e,options:r,highlighted:s,result:t,renderRange:void 0},s&&this.cacheHighlightResult(e,{result:t,options:r})}r&&(c||o)||this.asyncHighlight(e,u).then(({result:t,options:n})=>{c||this.cacheHighlightResult(e,{result:t,options:n}),this.applyHighlightResult(e,t,n,!c)}).catch(e=>{e instanceof Fs||this.onHighlightError(e)})}return this.renderCache.result==null?void 0:this.processDiffResult(this.renderCache.diff,t,this.renderCache.result)}async asyncRender(e,t=Ra){this.diff=e;let{result:n}=await this.asyncHighlight(e,Number.isFinite(t.totalLines));return this.processDiffResult(e,t,n)}createPreElement(e,t,n){let{diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o}=this.getOptionsWithDefaults();return oo({type:`diff`,diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e,t=!1){let n=Qd(e,this.getTokenizeMaxLength());this.computedLangs=n?[`text`]:Zd(e);let r=Xo(),i=r!=null&&Xa(this.getLocalHighlightTheme(),r),a=n||r!=null&&Aa(this.computedLangs,r);return r!=null&&i&&a||(r=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,r,n,t)}renderDiffWithHighlighter(e,t,n=!1,r=!1){let{options:i}=this.getRenderOptions(e),{collapsedContextThreshold:a}=this.getOptionsWithDefaults(),o=Zn(e,t,i,{forcePlainText:n,lazyLineAST:r,expandedHunks:n?!0:void 0,collapsedContextThreshold:a});if(this.editSessionActive&&e.additionLines.length===1&&e.additionLines[0]===``&&o.code.additionLines[0]==null){let t;if(Jr({diff:e,diffStyle:`both`,expandedHunks:n?!0:void 0,collapsedContextThreshold:a,callback:({additionLine:e})=>{if(e?.lineIndex===0)return t=e,!0}}),t==null)throw Error(`DiffHunksRenderer: missing empty addition line`);o.code.additionLines[0]=Yd(0,``,t.unifiedLineIndex,t.splitLineIndex)}return{result:o,options:i}}onHighlightSuccess(e,t,n,r=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){let{diff:i,renderCache:a}=this;i!=null&&a!=null&&Hi(i,e)&&vi(n,this.getRenderOptions(i).options)&&(a.result!=null&&a.highlighted&&vi(a.options,n)&&Hi(a.diff,i)||(this.pendingHighlightResult={diff:i,options:n,highlighted:r,result:t},this.onRenderUpdate?.()))}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getDiffResultCache(e);if(n!=null&&vi(t,n.options))return n}getReadyRenderResult(e,t){let{pendingHighlightResult:n}=this;if(n!=null&&Hi(n.diff,e)&&vi(n.options,t))return n;let r=this.getMatchingWorkerResultCache(e,t);if(!(r==null||this.hasHighlightedRenderCache(e,t)))return{diff:e,highlighted:!0,...r}}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&Hi(e,n.diff)&&vi(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let{diffStyle:a,disableFileHeader:o,expandUnchanged:s,expansionLineCount:c,collapsedContextThreshold:l,hunkSeparators:u}=this.getOptionsWithDefaults(),d=this.renderCache?.isDirty??!1,f=a===`unified`,p=$d(e,this.options.loadDiffFiles!=null),m=!e.isPartial||p,h=[],g=[],_=[],v=[],{additionLines:y,deletionLines:b}=n,x={rowCount:0,hunkSeparators:u,additionsContentAST:h,deletionsContentAST:g,unifiedContentAST:_,unifiedGutterAST:Is(),deletionsGutterAST:Is(),additionsGutterAST:Is(),expansionLineCount:c,hunkData:v,incrementRowCount(e=1){x.rowCount+=e},pushToGutter(e,t){switch(e){case`unified`:x.unifiedGutterAST.children.push(t);break;case`deletions`:x.deletionsGutterAST.children.push(t);break;case`additions`:x.additionsGutterAST.children.push(t)}}},S=vr({fileDiff:e,errorPrefix:`DiffHunksRenderer.processDiffResult`}),C={size:0,side:void 0,increment(){this.size+=1},flush(){a!==`unified`&&(this.size<=0||this.side==null?(this.side=void 0,this.size=0):(this.side===`additions`?(x.pushToGutter(`additions`,Ns(void 0,`buffer`,this.size)),h?.push(jd(this.size))):(x.pushToGutter(`deletions`,Ns(void 0,`buffer`,this.size)),g?.push(jd(this.size))),this.size=0,this.side=void 0))}},w=(e,t,n,r,i)=>{x.pushToGutter(e,js(t,n,r,i))};function T(e){C.flush(),a===`unified`?Wd(`unified`,e,x):(Wd(`deletions`,e,x),Wd(`additions`,e,x))}this.pushFileLevelAnnotations(e,a,t,x),Jr({diff:e,diffStyle:a,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:s?!0:this.expandedHunks,collapsedContextThreshold:l,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,additionLine:o,deletionLine:s,type:c})=>{let l=s==null?o.splitLineIndex:s.splitLineIndex,h=o==null?s.unifiedLineIndex:o.unifiedLineIndex;a===`split`&&c!==`change`&&C.flush(),r>0&&T({hunkIndex:t,collapsedLines:r,rangeSize:Math.max(n?.collapsedBefore??0,0),hunkSpecs:n?.hunkSpecs,isFirstHunk:t===0,isLastHunk:!1,isExpandable:m});let g=a===`unified`?h:l,_={type:c,hunkIndex:t,lineIndex:g,unifiedLineIndex:h,splitLineIndex:l,deletionLine:s,additionLine:o};if(a===`unified`){let n=this.getUnifiedInjectedRowsForLine?.(_);n?.before!=null&&Vd(n.before,x);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex];if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let a=c===`change`?o==null?`change-deletion`:`change-addition`:c,u=this.getUnifiedLineDecoration({type:c,lineType:a,additionLineIndex:o?.lineIndex,deletionLineIndex:s?.lineIndex});w(`unified`,u.gutterLineType,o==null?s.lineNumber:o.lineNumber,`${h},${l}`,u.gutterProperties),i==null?r!=null&&(r=Gd(r,u.contentProperties,d&&s!=null?{"data-line":s.lineNumber,"data-line-index":`${h},${l}`}:void 0)):i=Gd(i,u.contentProperties,d&&o!=null?{"data-line":o.lineNumber,"data-line-index":`${h},${l}`}:void 0),Ud({diffStyle:`unified`,type:c,deletionLine:r,additionLine:i,unifiedSpan:this.getAnnotations(`unified`,s?.lineNumber,o?.lineNumber,t,g),createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&Vd(n.after,x)}else{let n=this.getSplitInjectedRowsForLine?.(_);n?.before!=null&&Hd(n.before,x,C);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex],a=this.getSplitLineDecoration({side:`deletions`,type:c,lineIndex:s?.lineIndex}),u=this.getSplitLineDecoration({side:`additions`,type:c,lineIndex:o?.lineIndex});if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let f=(()=>{if(c===`change`){if(i==null)return`additions`;if(r==null)return`deletions`}})();f==null?c===`change`&&C.flush():(C.side!=null&&C.side!==f&&C.flush(),C.side=f,C.increment());let p=this.getAnnotations(`split`,s?.lineNumber,o?.lineNumber,t,g);if(p!=null&&C.size>0&&C.flush(),s!=null){let e=Gd(r,a.contentProperties,d?{"data-line":s.lineNumber,"data-line-index":`${s.unifiedLineIndex},${l}`}:void 0);w(`deletions`,a.gutterLineType,s.lineNumber,`${s.unifiedLineIndex},${l}`,a.gutterProperties),e!=null&&(r=e)}if(o!=null){let e=Gd(i,u.contentProperties,d?{"data-line":o.lineNumber,"data-line-index":`${o.unifiedLineIndex},${l}`}:void 0);w(`additions`,u.gutterLineType,o.lineNumber,`${o.unifiedLineIndex},${l}`,u.gutterProperties),e!=null&&(i=e)}Ud({diffStyle:`split`,type:c,additionLine:i,deletionLine:r,...p,createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&Hd(n.after,x,C)}let v=a===`split`&&n!=null&&l===n.splitLineStart+n.splitLineCount-1,E=t===e.hunks.length-1&&n!=null&&(a===`split`?l===n.splitLineStart+n.splitLineCount-1:h===n.unifiedLineStart+n.unifiedLineCount-1),D=v?n.noEOFCRDeletions:!1,O=v?n.noEOFCRAdditions:!1,k=(s?.noEOFCR??!1)||D,A=(o?.noEOFCR??!1)||O;if(A||k){if(a===`split`&&C.flush(),k){let e=c===`context`||c===`context-expanded`?c:`change-deletion`;a===`unified`?(x.unifiedContentAST.push(Md(e)),x.pushToGutter(`unified`,Ns(e,`metadata`,1))):(x.deletionsContentAST.push(Md(e)),x.pushToGutter(`deletions`,Ns(e,`metadata`,1)),A||(x.pushToGutter(`additions`,Ns(void 0,`buffer`,1)),x.additionsContentAST.push(jd(1))))}if(A&&!(f&&k&&c!==`change`)){let e=c===`context`||c===`context-expanded`?c:`change-addition`;a===`unified`?(x.unifiedContentAST.push(Md(e)),x.pushToGutter(`unified`,Ns(e,`metadata`,1))):(x.additionsContentAST.push(Md(e)),x.pushToGutter(`additions`,Ns(e,`metadata`,1)),k||(x.pushToGutter(`deletions`,Ns(void 0,`buffer`,1)),x.deletionsContentAST.push(jd(1))))}x.incrementRowCount(1)}u!==`simple`&&u!==`metadata`&&(i>0||E&&p)&&T({hunkIndex:c===`context-expanded`?t:t+1,collapsedLines:E&&p?`unknown`:i,rangeSize:S,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:m}),x.incrementRowCount(1)}}),a===`split`&&C.flush();let E=Math.max(Id(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),D=t.bufferBefore>0||t.bufferAfter>0,O=!f&&e.type!==`deleted`,k=!f&&e.type!==`new`,A=x.rowCount>0||D;h=O&&A?h:void 0,g=k&&A?g:void 0,_=f&&A?_:void 0;let j=this.createPreElement(g!=null&&h!=null,E);return{fileDiff:e,unifiedGutterAST:f&&A?x.unifiedGutterAST.children:void 0,unifiedContentAST:_,deletionsGutterAST:k&&A?x.deletionsGutterAST.children:void 0,deletionsContentAST:g,additionsGutterAST:O&&A?x.additionsGutterAST.children:void 0,additionsContentAST:h,hunkData:v,preNode:j,themeStyles:r,baseThemeType:i,headerElement:o?void 0:this.renderHeader(e),totalLines:E,rowCount:x.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderCodeAST(e,t){let n=e===`unified`?t.unifiedGutterAST:e===`deletions`?t.deletionsGutterAST:t.additionsGutterAST,r=e===`unified`?t.unifiedContentAST:e===`deletions`?t.deletionsContentAST:t.additionsContentAST;if(n==null||r==null)return;let i=Is(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,Va(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators===`line-info`,r=this.renderCodeAST(`unified`,e);if(r!=null)return t.push(Ls({tagName:`code`,children:r,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-unified":``}})),{...e.preNode,children:t};let i=this.renderCodeAST(`deletions`,e);i!=null&&t.push(Ls({tagName:`code`,children:i,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-deletions":``}}));let a=this.renderCodeAST(`additions`,e);return a!=null&&t.push(Ls({tagName:`code`,children:a,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-additions":``}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return Rs(this.renderFullAST(e,t))}renderPartialHTML(e,t){return Rs(t==null?e:Ls({tagName:`code`,children:e,properties:{"data-code":``,"data-container-size":this.getOptionsWithDefaults().hunkSeparators===`line-info`?``:void 0,[`data-${t}`]:``}}))}pushFileLevelAnnotations(e,t,n,r){if(!ls(n))return;let i=e.type===`new`?[]:this.getAnnotationNames(La(this.deletionAnnotations)),a=e.type===`deleted`?[]:this.getAnnotationNames(La(this.additionAnnotations));if(i.length===0&&a.length===0)return;let{createAnnotationElement:o}=this;Ud(t===`unified`?{diffStyle:t,type:`context`,unifiedSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i.concat(a)},createAnnotationElement:o,context:r}:{diffStyle:t,type:`context`,deletionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i},additionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:a},createAnnotationElement:o,context:r})}getAnnotations(e,t,n,r,i){let a={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(t!=null)for(let e of this.deletionAnnotations[t]??[])a.annotations.push(this.annotationSlotName(e));let o={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(n!=null)for(let t of this.additionAnnotations[n]??[])(e===`unified`?a:o).annotations.push(this.annotationSlotName(t));if(e===`unified`)return a.annotations.length>0?a:void 0;if(o.annotations.length!==0||a.annotations.length!==0)return{deletionSpan:a,additionSpan:o}}getAnnotationNames(e){return e?.map(e=>this.annotationSlotName(e))??[]}renderHeader(e){let{headerRenderMode:t,stickyHeader:n}=this.getOptionsWithDefaults();return Fa({fileOrDiff:e,mode:t,stickyHeader:n})}},zd=new Intl.PluralRules(`en-US`);function Bd(e){return`${e} unmodified line${zd.select(e)===`one`?``:`s`}`}function Vd(e,t){for(let n of e)t.unifiedContentAST.push(n.content),t.pushToGutter(`unified`,n.gutter),t.incrementRowCount(1)}function Hd(e,t,n){for(let{deletion:r,addition:i}of e){if(r==null&&i==null)continue;let e=r!=null&&i!=null?void 0:r==null?`deletions`:`additions`;(e==null||n.side!==e)&&n.flush(),r!=null&&(t.deletionsContentAST.push(r.content),t.pushToGutter(`deletions`,r.gutter)),i!=null&&(t.additionsContentAST.push(i.content),t.pushToGutter(`additions`,i.gutter)),e!=null&&(n.side=e,n.increment()),t.incrementRowCount(1)}}function Ud({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:a,additionSpan:o,createAnnotationElement:s,context:c}){let l=!1;if(e===`unified`){if(r==null?n!=null&&c.unifiedContentAST.push(n):c.unifiedContentAST.push(r),i!=null){let e=t===`change`?n==null?`change-addition`:`change-deletion`:t;c.unifiedContentAST.push(s(i)),c.pushToGutter(`unified`,Ns(e,`annotation`,1)),l=!0}}else if(e===`split`){if(n!=null&&c.deletionsContentAST.push(n),r!=null&&c.additionsContentAST.push(r),a!=null){let e=t===`change`?n==null?`context`:`change-deletion`:t;c.deletionsContentAST.push(s(a)),c.pushToGutter(`deletions`,Ns(e,`annotation`,1)),l=!0}if(o!=null){let e=t===`change`?r==null?`context`:`change-addition`:t;c.additionsContentAST.push(s(o)),c.pushToGutter(`additions`,Ns(e,`annotation`,1)),l=!0}}l&&c.incrementRowCount(1)}function Wd(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:a,isLastHunk:o,isExpandable:s},c){if(typeof n==`number`&&n<=0)return;let l=e===`unified`?c.unifiedContentAST:e===`deletions`?c.deletionsContentAST:c.additionsContentAST;if(c.hunkSeparators===`metadata`){i!=null&&(c.pushToGutter(e,Pd({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),l.push(Pd({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1));return}if(c.hunkSeparators===`simple`){t>0&&(c.pushToGutter(e,Pd({type:`simple`,isFirstHunk:a,isLastHunk:!1})),l.push(Pd({type:`simple`,isFirstHunk:a,isLastHunk:!1})),e!==`additions`&&c.incrementRowCount(1));return}let u=Fd(e,t),d=r>c.expansionLineCount,f=s?t:void 0,p=typeof n==`number`?Bd(n):`More unchanged context may be available`;c.pushToGutter(e,Pd({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),l.push(Pd({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1),c.hunkData.push({slotName:u,hunkIndex:t,lines:typeof n==`number`?n:0,lineCountKnown:typeof n==`number`,type:e,expandable:s?{up:!a,down:!o,chunked:d}:void 0})}function Gd(e,t,n){return e==null||e.type!==`element`||t==null&&n==null?e:{...e,properties:{...e.properties,...t,...n}}}function Kd(e){return e.length>0&&e[e.length-1]===``?e.length-1:e.length}function qd(e,t,n,r){let i=Kd(e),a=Kd(t),o=Math.min(i,a),s=0;for(;s<o&&e[s]===t[s];)s++;let c=0;for(;c<o-s&&e[i-1-c]===t[a-1-c];)c++;let l=Array(t.length);for(let e=0;e<s;e++)l[e]=n[e];for(let e=0;e<c;e++)l[a-1-e]=n[i-1-e];i<e.length&&a<t.length&&(l[t.length-1]=n[e.length-1]);for(let e=s;e<t.length;e++)l[e]??=Yd(e,r.getLineText(e));return l}function Jd(e,t){return t===e.length+1&&e.at(-1)?.endsWith(`
|
|
19
|
+
`)===!0}function Yd(e,t,n=e,r=e){return{type:`element`,tagName:`div`,properties:{"data-line":e+1,"data-line-index":`${n},${r}`,"data-line-type":`context`},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:t}]}]}}function Xd(e){let t=[],n=0;for(let r=0;r<e.lineCount;r++){let i=e.getLineText(r,!0);t.push(i),n+=i.length}return{lines:t,characterCount:n}}function Zd(e){if(e.lang!=null)return[e.lang];let t=mo(e.prevName??e.name),n=mo(e.name);return t===n?[n]:[t,n]}function Qd(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function $d(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function ef(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function tf(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.lineCountKnown===t.lineCountKnown&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function nf(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:jo(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators==`function`?`custom`:e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,loadDiffFiles:e?.loadDiffFiles,parseDiffOptions:e?.parseDiffOptions,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}function rf(e){return e.isPartial&&(e.type===`change`||e.type===`rename-changed`||e.type===`rename-pure`)}function af(e){let t={...e};return delete t.cacheKey,t}function of(e,t){if(e.isPartial||t.isPartial)throw Error(`FileDiff.shouldResetEditorForExternalDiff: diffs must be fully hydrated`);let n=e.lang??mo(e.name),r=t.lang??mo(t.name),i=e.type!==`new`,a=t.type!==`new`;return e.name!==t.name||n!==r||i!==a||e.deletionLines.length!==t.deletionLines.length||e.deletionLines.some((e,n)=>e!==t.deletionLines[n])}function sf(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function cf(e,t){let{oldFile:n}=e;return n==null?t.type===`new`:t.type!==`new`&&n.name===(t.prevName??t.name)&&sf(n.lines,t.deletionLines)}var lf=-1,uf=class{options;workerManager;requestOwnerRender;static LoadedCustomComponent=!0;__id=`file-diff:${++lf}`;type=`file-diff`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;get lineAnnotations(){return this.renderedData?.lineAnnotations??Eo}managersDirty=!1;deletionFile;additionFile;fileDiff;editSession;renderedData;pendingData;forceRenderOverride;renderRange;pendingFiles;appliedPreAttributes;headerCache={lastRenderedHTML:void 0,html:void 0,fileDiff:void 0};lastRowCount;mounted=!1;enabled=!0;editor;refreshViewTimeout;lineStateRefreshPending=!1;deferredSelectedLines;deferredEditorActiveLine;constructor(e={theme:bo},t,n){this.options=e,this.workerManager=t,this.requestOwnerRender=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new Ta,this.scrollSyncManager=new Lu,this.interactionManager=new vo(`diff`,za(e,typeof e.hunkSeparators==`function`||(e.hunkSeparators??`line-info`)===`line-info`||e.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??bo}getHunksRendererOptions(e){return nf(e)}createHunksRenderer(e){return new Rd(this.getHunksRendererOptions(e),this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t=`additions`)=>this.getLineIndexForDiff(this.getDiffForLineIndex(),e,t);getDiffForLineIndex(){return this.getRenderedDiff()}getLineIndexForDiff(e,t,n){if(e==null)return;let r=e.hunks.at(-1),i,a;hunkIterator:for(let o of e.hunks){let e=n===`deletions`?o.deletionStart:o.additionStart,s=n===`deletions`?o.deletionCount:o.additionCount,c=li(e,s)+1,l=o.splitLineStart,u=o.unifiedLineStart;if(t<c){let e=c-t;i=Math.max(u-e,0),a=Math.max(l-e,0);break hunkIterator}if(t>=c+s){if(o===r){let e=t-(c+s);i=u+o.unifiedLineCount+e,a=l+o.splitLineCount+e;break hunkIterator}}else{for(let e of o.hunkContent)if(e.type===`context`){if(t<c+e.lines){let e=t-c;a=l+e,i=u+e;break hunkIterator}c+=e.lines,l+=e.lines,u+=e.lines}else{let r=n===`deletions`?e.deletions:e.additions;if(t<c+r){let r=t-c;i=u+(n===`additions`?e.deletions:0)+r,a=l+r;break hunkIterator}c+=r,l+=Math.max(e.deletions,e.additions),u+=e.deletions+e.additions}break hunkIterator}}if(i!=null&&a!=null)return[i,a]}setOptions(e){e!=null&&(this.options=e,this.clearReusableHeader(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(za(this.options,typeof this.options.hunkSeparators==`function`||(this.options.hunkSeparators??`line-info`)===`line-info`||this.options.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType!==t&&(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!no(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();getAnnotationSlotName=e=>Os(this.editSession?.annotations,e,ao);getLatestAnnotations(){return this.pendingData?.lineAnnotations??this.editSession?.annotations?.current??this.lineAnnotations}getAnnotationsForDiff(e){let{pendingData:t}=this;return t!=null&&Hi(e,t.fileDiff)?t.lineAnnotations:this.lineAnnotations}isNewAnnotations(e){let t=this.editSession?.annotations;return e===this.getLatestAnnotations()?!1:t==null||e!==t.provided&&e!==t.current}setLineAnnotations(e){let t=this.editSession?.annotations;if(t!=null){if(!this.isNewAnnotations(e))return;Po(t,e,ao)}let n=this.getWorkingDiff();n!=null&&(this.pendingData={fileDiff:n,lineAnnotations:e})}syncEditSessionAnnotationsFromEditor(e){let t=this.editSession?.annotations;return t==null||e===t.current?!1:(t.current=e,this.renderedData!=null&&(this.renderedData.lineAnnotations=e),this.pendingData=void 0,this.hunksRenderer.setLineAnnotations(e),this.renderAnnotations(),!0)}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators==`function`)}setSelectedLines(e,t){this.lineStateRefreshPending?this.deferredSelectedLines=[e,t]:this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.lineStateRefreshPending?this.deferredEditorActiveLine=[e,t]:this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??`additions`})}flushDeferredLineState(){let{deferredEditorActiveLine:e,deferredSelectedLines:t}=this;this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,e!=null&&this.setEditorActiveLine(...e),t!=null&&this.interactionManager.setSelection(...t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:e=`split`,overflow:t=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t===`wrap`,columnVariables:this.shouldApplyColumnVariables(t)?`apply`:`measure`}),t===`scroll`&&e===`split`?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}shouldApplyColumnVariables(e){return typeof this.options.hunkSeparators==`function`||e===`scroll`&&(this.lineAnnotations.length>0||this.pre?.hasAttribute(`data-has-merge-conflict`)===!0)}getCodeScrollLeft(){return Math.max(this.codeUnified?.scrollLeft??0,this.codeDeletions?.scrollLeft??0,this.codeAdditions?.scrollLeft??0)}setCodeScrollLeft(e){this.codeUnified!=null&&(this.codeUnified.scrollLeft=e),this.codeAdditions!=null&&(this.codeAdditions.scrollLeft=e),this.codeDeletions!=null&&(this.codeDeletions.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(e=!1){let{editor:t}=this;hs(this.handleEditSessionRender),this.emitPostRender(!0),t?.cleanUp(e?`recycle`:`discard`),e||(this.editor=void 0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,e||(this.pendingFiles=void 0),this.isComponentManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.renderedData=void 0,this.pendingData=void 0),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre?.remove(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement?.remove(),this.headerElement=void 0,this.clearHeaderSlots(),this.placeHolder?.remove(),this.placeHolder=void 0,this.headerCache.lastRenderedHTML=void 0,e||this.clearReusableHeader(),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.editSession=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate({fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:r,fileDiff:i,...a}){if(!this.enabled)throw Error(`FileDiff.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated`);let o=Cu(a,`FileDiff.hydrate`),s=o?.oldFile,c=o?.newFile;this.hydrateElements(e,t);let l=this.editor!=null;l||hf(this.pre,pf({fileDiff:i,oldFile:s,newFile:c}),this.options.collapsed)||gf(this.headerElement,mf({fileDiff:i,oldFile:s,newFile:c}),this.options.disableFileHeader)?this.render({...a,fileContainer:e,lineAnnotations:r,fileDiff:i,forceRender:l||a.forceRender,preventEmit:!0}):this.hydrationSetup({fileDiff:i,lineAnnotations:r,...o}),n||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),os(e,t);for(let t of e.shadowRoot?.children??[])if(t instanceof SVGElement)this.spriteSVG=t;else if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t;for(let e of t.children)e instanceof HTMLElement&&e.tagName.toLowerCase()===`code`&&(`deletions`in e.dataset&&(this.codeDeletions=e),`additions`in e.dataset&&(this.codeAdditions=e),`unified`in e.dataset&&(this.codeUnified=e))}else`diffsHeader`in t.dataset?this.headerElement=t:t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)?this.themeCSSStyle=t:t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent)}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){let i=r??this.getLatestAnnotations();this.pendingData=void 0,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?Fu(t,n,this.options.parseDiffOptions):void 0),this.renderedData=this.fileDiff==null?void 0:{fileDiff:this.fileDiff,lineAnnotations:i},this.fileDiff!=null&&this.adoptRenderData(this.fileDiff),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.getInputDiff()==null&&this.additionFile==null&&this.deletionFile==null||this.requestRender()||this.render({forceRender:!0,renderRange:this.renderRange})}requestRender(){let{requestOwnerRender:e}=this;return this.editSession!=null||e==null?!1:(this.forceRenderOverride=!0,e(),!0)}get isComponentManaged(){return this.requestOwnerRender!=null}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.loadFilesIfNecessary(),this.hunksRenderer.expandHunk(e,t,n),this.rerender()};loadFilesIfNecessary(){let e=this.getInputDiff(),{loadDiffFiles:t}=this.options;if(e==null||!rf(e)||this.pendingFiles?.fileDiff===e)return;if(t==null)throw Error(`FileDiff: loadDiffFiles is required to load full files for a partial diff`);let n=this.loadFilesForDiff(e,t),r=this.pendingFiles={fileDiff:e,promise:n};r.promise=n.finally(()=>{this.pendingFiles===r&&(this.pendingFiles=void 0)})}__canAttachEditor(){let e=this.getInputDiff();return e!=null&&!e.isPartial}async prepareForEditing(){if(this.__canAttachEditor())return;let e=this.__prepareForEditing();if(e==null){let e=this.getInputDiff();throw e?.isPartial===!0&&!rf(e)?Error(`FileDiff.prepareForEditing: this partial diff cannot be hydrated; provide a complete diff`):Error(`FileDiff.prepareForEditing: a partial diff requires loadDiffFiles`)}if(await e,!this.__canAttachEditor())throw Error(`FileDiff.prepareForEditing: the diff did not finish loading`)}__prepareForEditing(){if(this.__canAttachEditor())return;let e=this.getInputDiff();if(e?.isPartial===!0&&!rf(e))throw Error(`FileDiff: this partial diff cannot be hydrated; provide a complete diff to edit`);return this.loadFilesIfNecessary(),this.pendingFiles?.promise}async loadFilesForDiff(e,t){try{let n=await t(e);if(this.getInputDiff()!==e)return;await this.handleFilesLoaded(e,n)}catch(e){if(this.options.disableErrorHandling===!0)throw e;console.error(e)}}async handleFilesLoaded(e,t){this.getInputDiff()===e&&e.isPartial&&(Tu(`merge`,e,t,this.options.parseDiffOptions),this.setHydratedState(t),this.installHydratedSessionDiff(e)?this.rerender():(await yu(()=>this.primeHighlightCache(e)),this.enabled&&this.getInputDiff()===e&&this.rerender()))}installHydratedSessionDiff(e){if(e.isPartial)throw Error(`FileDiff.installHydratedSessionDiff: diffs cannot be partial for editing`);return this.getInputDiff()===e&&this.editSession?.outgoingDiff!=null&&(this.installEditSession(e),!0)}updateInputDiff(e,t){if(Hi(this.getInputDiff(),e))return!1;let n=this.getLatestAnnotations();this.fileDiff=e;let{editSession:r}=this,i=r?.outgoingDiff??r?.diff;return r!=null&&(e.isPartial?r.inputDiff=e:this.installEditSession(e),this.editSession!=null&&(this.editSession.outgoingDiff=i)),this.editSession?.annotations!=null&&t!=null&&(this.editSession.annotations=xs(t,ao,this.editSession.annotations)),this.pendingData={fileDiff:this.editSession?.diff??e,lineAnnotations:this.editSession?.annotations?.current??t??n},i!=null&&e.isPartial&&this.loadFilesIfNecessary(),!0}installEditSession(e,t,n){let r=e.additionLines.join(``),i=t==null?void 0:wu(t.contents),a=n!=null&&cf(n,e);if(n!=null&&!a)throw Error(`FileDiff: retained session cannot resume against a different old file`);if(t!=null&&t.contents!==r&&!a)throw Error(`FileDiff: retained edits are missing their diff session state`);let o=t==null||t.name===e.name&&t.lang===e.lang&&t.contents===r,s=af(e);t!=null&&i!=null&&!o&&(s.name=t.name,s.lang=t.lang),a&&n!=null&&t!=null&&i!=null&&(s.additionLines=i,s.additionCharacterCount=t.contents.length,s.type=n.type,s.hunks=n.hunks,s.editSessionDirty=!0,nd(s));let c=this.editSession?.annotations??xs(this.getLatestAnnotations(),ao);this.editSession={diff:s,inputDiff:e,annotations:c,outgoingDiff:this.editSession?.outgoingDiff},this.pendingData={fileDiff:s,lineAnnotations:c.current},this.hunksRenderer.beginEditSession(s,o&&!a?e:void 0)}setHydratedState(e){this.deletionFile=e.oldFile,this.additionFile=e.newFile,this.workerManager?.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:e,deferManagers:t=!1,forceRender:n=!1,preventEmit:r=!1,lineAnnotations:i,fileContainer:a,containerWrapper:o,renderRange:s,...c}){if(!this.enabled)throw Error(`FileDiff.render: attempting to call render after cleaned up`);n=this.forceRenderOverride??n,this.forceRenderOverride=void 0;let l=Cu(c,`FileDiff.render`),u=l?.oldFile,d=l?.newFile;this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:f=!1,themeType:p=`system`,expandUnchanged:m=!1}=this.options,h=f?void 0:s,g=this.hasThemeChanged(),_=l!=null,v=_&&(!ff(u,this.deletionFile)||!ff(d,this.additionFile)),y=e!=null&&!Hi(e,this.getInputDiff()),b=i!=null&&(i.length>0||this.getLatestAnnotations().length>0)&&this.isNewAnnotations(i);if(!f&&As(h,this.renderRange)&&!n&&!b&&!g&&(e!=null&&!y||e==null&&!v)){let e=this.applyCachedThemeState(p);return e&&this.finalizeRender(),e}let x;e==null&&_&&(v||this.getInputDiff()==null)&&(x=Fu(l.oldFile,l.newFile,this.options.parseDiffOptions));let{renderRange:S}=this;this.renderRange=h,_?(this.deletionFile=u,this.additionFile=d):e!=null&&(this.deletionFile=void 0,this.additionFile=void 0),e!=null&&y?this.updateInputDiff(e,i):x!=null&&(y=!0,this.updateInputDiff(x,i)),y&&this.clearReusableHeader(),i!=null&&this.setLineAnnotations(i);let C=this.getWorkingDiff();if(C==null)return!1;C.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(md(C,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),m&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.prepareRenderData(this.hunksRenderer.getDiffForNextRender(C));let{disableErrorHandling:w=!1,disableFileHeader:T=!1}=this.options;if(T&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.headerCache.lastRenderedHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,o),this.applyCachedThemeState(p),f){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(C,So);e!=null&&this.applyThemeState(a,e.themeStyles,p,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,a,e.fileDiff),this.renderSeparators([]),this.adoptRenderData(e?.fileDiff??C),this.injectUnsafeCSS()}catch(e){if(w)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return this.finalizeRender(),r||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(a);if(this.canPartiallyRender(n,b,v||y||g||!Hi(this.getRenderedDiff(),C))&&this.applyPartialRender({fileDiff:C,previousRenderRange:S,renderRange:h})){let e=this.getRenderedDiff();e!=null&&this.adoptRenderData(e)}else{let t=this.hunksRenderer.renderDiff(C,h);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.isWorkingPool()&&this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender()),!1;this.applyThemeState(a,t.themeStyles,p,t.baseThemeType),t.headerElement!=null&&this.applyHeaderToDOM(t.headerElement,a,t.fileDiff),t.additionsContentAST!=null||t.deletionsContentAST!=null||t.unifiedContentAST!=null?this.applyHunksToDOM(e,t):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(t.hunkData),this.adoptRenderData(t.fileDiff)}this.applyBuffers(e,h),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,t||this.flushManagers(),this.finalizeRender(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(w)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return r||this.emitPostRender(),!0}finalizeRender(){}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}getInputDiff(){return this.fileDiff}getWorkingDiff(e=this.fileDiff){return this.editSession?.diff??e}getRenderedDiff(){return this.renderedData?.fileDiff}__getNextRenderData({fileDiff:e,lineAnnotations:t}){let n=this.editSession?.annotations;if(n!=null)return{fileDiff:e,lineAnnotations:t!=null&&this.isNewAnnotations(t)?t:n.provided};let r=this.getWorkingDiff(e)??e,i=this.hunksRenderer.getDiffForNextRender(r);return{fileDiff:i,lineAnnotations:t!=null&&Hi(i,r)?t:this.getAnnotationsForDiff(i)}}prepareRenderData(e){this.hunksRenderer.setLineAnnotations(this.getAnnotationsForDiff(e))}adoptRenderData(e){let{pendingData:t}=this,n=t!=null&&Hi(e,t.fileDiff);this.renderedData={fileDiff:e,lineAnnotations:n?t.lineAnnotations:this.lineAnnotations},n&&(this.pendingData=void 0)}syncRenderViewToEditor(){let{editor:e,fileContainer:t}=this,n=this.getLatestAnnotations(),r=this.computeEditorRenderRange(this.renderRange),i=this.getWorkingDiff();if(e==null||t==null||i==null||i.isPartial)return;let a=a=>{if(!this.enabled||this.editor!==e||this.fileContainer!==t||this.getWorkingDiff()!==i)return;let o=this.editSession?.outgoingDiff,s=this.getInputDiff(),c=o!=null&&s!=null&&o!==i,l=c&&o!=null&&s!=null?of(o,s):!1;e.__syncRenderView({highlighter:a,fileContainer:t,fileDiff:i,lineAnnotations:n,renderRange:r,externalDocument:c,resetHistory:l})},o=this.getTheme(),s=i.lang??mo(i.name),c=Xo({theme:o,lang:s});c==null?Sa({themes:$a(o),langs:[`text`,s],preferredHighlighter:Oo(this.workerManager,this.options)}).then(a).catch(e=>{e instanceof Fs||console.error(e)}):a(c)}computeEditorRenderRange(e){let t=this.getWorkingDiff();if(e==null||t==null||Za(e))return e;let{diffStyle:n=`split`,expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a,o;return Jr({diff:t,diffStyle:n,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({additionLine:e})=>{e!=null&&(a??=e.lineNumber,o=e.lineNumber)}}),a==null||o==null?{...e,startingLine:0,totalLines:0}:{...e,startingLine:a-1,totalLines:o-a+1}}__acknowledgeDocumentUpdate(){this.editSession!=null&&(this.editSession.outgoingDiff=void 0)}__acceptEditorChange(e){let{lineAnnotations:t}=e;t!=null&&this.syncEditSessionAnnotationsFromEditor(t)}emitEditChange(e){let{onEditChange:t}=this.options;t?.(e)}__captureDocumentSessionState(e=!0){let t=this.getInputDiff(),{diff:n,outgoingDiff:r}=this.editSession??{};if(r!=null&&t!=null){if(!t.isPartial&&of(r,t))return;n=r}if(!(n==null||n.isPartial))return{diffSession:{oldFile:n.type===`new`?null:{name:n.prevName??n.name,lines:e?[...n.deletionLines]:n.deletionLines},type:n.type,hunks:e?zs(n.hunks):n.hunks},hasChanges:n.editSessionDirty===!0}}__attachEditor(e){if(this.type!==`file-diff`)throw Error(`FileDiff.__attachEditor: cannot attach an editor to a "${this.type}" diff`);if(this.editor!=null)throw Error(`FileDiff.__attachEditor: an editor is already attached`);if(!this.__canAttachEditor())throw Error(`FileDiff.__attachEditor: a complete diff is required before editing`);let t=()=>{this.editor=void 0,this.finishEditSession()};try{return this.resumeEditorRendering(e),t}catch(e){throw t(),e}}__resumeEditor(e){if(this.editor!==e)throw Error(`FileDiff.__resumeEditor: editor association changed`);this.resumeEditorRendering(e)}resumeEditorRendering(e){let t=this.getInputDiff(),n=this.editSession?.outgoingDiff;n!=null&&t!=null&&!t.isPartial&&this.editSession?.diff===n&&this.installEditSession(t);let r=this.editSession==null&&t!=null&&!t.isPartial?t:void 0;r==null?this.editSession!=null&&this.hunksRenderer.beginEditSession(this.editSession.diff):this.installEditSession(r,e.__getDocumentContents(df(r)),e.__getDocumentSessionState()),this.editor=e,this.getInputDiff()?.isPartial===!0&&this.loadFilesIfNecessary();let i=this.editSession?.diff;this.hunksRenderer.editorRenderReady()?(i!=null&&this.hunksRenderer.diffCache===i&&this.adoptRenderData(i),this.syncRenderViewToEditor()):this.rerender()}finishEditSession(){this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks()}__completeEditSession(e,t){this.settleEditSession(t===`install`,e)}settleEditSession(e,t){let{editSession:n}=this;if(n==null)return;let{diff:r,inputDiff:i,annotations:a}=n,o=a?.provided??this.lineAnnotations;if(this.editor!=null)throw Error(`FileDiff.__completeEditSession: detach the editor before completing the session`);this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks();let s=a?.current,c,l=null,u=null,d=!1,f;if(t==null)throw Error(`FileDiff.__completeEditSession: editor is required for completion`);let p=Vs(r),m={name:p.name,contents:p.additionLines.join(``)};p.lang!=null&&(m.lang=p.lang);let h={fileDiff:p,editor:t,originalFileDiff:i,oldFile:p.type===`new`?null:{name:p.prevName??p.name,contents:p.deletionLines.join(``)},newFile:m,lineAnnotations:s,originalLineAnnotations:o};Object.freeze(h);try{if(t.__emitEditComplete(h),this.options.onEditComplete?.(h)===`accept`){if(p.cacheKey!=null&&p.cacheKey===i.cacheKey)throw Error(`FileDiff.__completeEditSession: an accepted diff must not reuse the replaced diff cacheKey`);c=p,l=h.oldFile,u=h.newFile}}catch(e){d=!0,f=e}if(e&&c!=null&&this.additionFile!=null&&(this.deletionFile=l,this.additionFile=u),this.editSession=void 0,this.fileDiff=e&&c!=null?c:i,this.pendingData={fileDiff:this.fileDiff,lineAnnotations:e&&c!=null?s??o:o},e&&this.fileContainer!=null&&this.rerender(),d)throw f}finalizeEditSessionHunks(){let e=this.getWorkingDiff();if(e==null||e.editSessionDirty!==!0)return!1;let{collapsedContextThreshold:t=1}=this.options,n=fd(e,this.hunksRenderer.getExpandedHunksMap(),t);return md(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(pd(e,n)),this.hunksRenderer.refreshHighlightedResult(),this.escalateEditSessionRender(),!0}applyDocumentChange(e,t){let n=this.editSession?.diff;if(n==null)throw Error(`FileDiff.applyDocumentChange: requires an active edit session`);this.detachAdditionLines(),this.hunksRenderer.beginEditSession(n),this.hunksRenderer.applyDocumentChange(e),t!=null&&this.syncEditSessionAnnotationsFromEditor(t),this.rerender(),this.interactionManager.setSelectionDirty()}applySuspendedDocumentChange(e,t){this.applyDocumentChange(e,t),this.hunksRenderer.clearRenderCache()}updateRenderCache(e,t,n={}){let r=this.editSession?.diff;if(r==null)throw Error(`FileDiff.updateRenderCache: requires an active edit session`);this.detachAdditionLines(),this.hunksRenderer.beginEditSession(r);let{shouldRefreshDiffsView:i,lineCountChangeInFlight:a}=n;this.hunksRenderer.updateRenderCache(e,t,a,n.changedDocumentLines,n.documentLineCount)?(this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!0,this.escalateEditSessionRender()):i===!0&&(this.refreshViewTimeout!=null&&clearTimeout(this.refreshViewTimeout),this.lineStateRefreshPending=!0,this.refreshViewTimeout=setTimeout(()=>{this.refreshViewTimeout=void 0,this.options.diffStyle===`split`?this.refreshSplitDiffView():this.refreshUnifiedDiffView(),this.flushDeferredLineState()},150))}detachAdditionLines(){let{diff:e,inputDiff:t}=this.editSession??{};e!=null&&(e.additionLines===t?.additionLines||e.additionLines===e.deletionLines)&&(e.additionLines=[...e.additionLines])}isLineRenderable(e){let t=this.getRenderedDiff();if(t==null)return!0;let{expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options;return Ir({fileDiff:t,lineNumber:e,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r})}getNearestRenderableLine(e,t){let n=this.getRenderedDiff();if(n==null)return e;let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;return Yi({fileDiff:n,lineNumber:e,direction:t,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i})}revealLine(e){let t=this.getRenderedDiff(),{expandUnchanged:n=!1,collapsedContextThreshold:r=1,expansionLineCount:i=100}=this.options;if(t==null||t.isPartial||n)return!1;let a=this.hunksRenderer.getExpandedHunksMap();for(let[n,o]of t.hunks.entries()){let[s,c]=ur(o);if(e<s){let c=Qr({isPartial:t.isPartial,rangeSize:o.collapsedBefore,expandedHunks:a,hunkIndex:n,collapsedContextThreshold:r}),l=s-c.rangeSize;if(c.renderAll||e<l+c.fromStart||e>=s-c.fromEnd)return!1;let u=e-(l+c.fromStart)+1,d=s-c.fromEnd-e;return u<=d?this.expandHunk(n,`up`,u+i):this.expandHunk(n,`down`,d+i),!0}if(e<c)return!1}let o=ni({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:a,collapsedContextThreshold:r,errorPrefix:`FileDiff.revealLine`});if(o==null||o.renderAll)return!1;let s=t.hunks[t.hunks.length-1],[,c]=ur(s);return e<c+o.fromStart||e>=c+o.rangeSize?!1:(this.expandHunk(t.hunks.length,`up`,e-(c+o.fromStart)+1+i),!0)}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){ts(this.handleEditSessionRender)}handleEditSessionRender=()=>{this.rerender(),this.flushDeferredLineState()};removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.setPlaceholderHeight(e)}setPlaceholderHeight(e){return this.placeHolder!=null&&(this.placeHolder.style.setProperty(`height`,`${e}px`),!0)}async primeHighlightCache(e=this.getInputDiff()){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||Gn(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(e=>{$o(e)||console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.headerCache.lastRenderedHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){let{hunkSeparators:t}=this.options;if(this.isComponentManaged||this.fileContainer==null||typeof t!=`function`){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();return}let n=new Map(this.separatorCache);for(let r of e){let e=r.slotName,i=this.separatorCache.get(e);if(i==null||!tf(r,i.hunkData)){i?.element.remove();let n=document.createElement(`div`);n.style.display=`contents`,n.slot=r.slotName;let a=t(r,this);a!=null&&n.appendChild(a),this.fileContainer.appendChild(n),i={element:n,hunkData:r},this.separatorCache.set(e,i)}n.delete(e)}for(let[e,{element:t}]of n.entries())this.separatorCache.delete(e),t.remove()}renderAnnotations(){if(this.isComponentManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderedData:t,options:{renderAnnotation:n}}=this;if(n!=null&&t!=null){let{fileDiff:r,lineAnnotations:i}=t;for(let[t,a]of i.entries()){let i=this.getAnnotationSlotName(a),o=`${t}-${i}`,s=this.annotationCache.get(o);if(s==null||s.fileDiff!==r||!ef(a,s.annotation)){s?.element.remove();let e=n(a,r);if(e==null)continue;s={element:Zo(i),annotation:a,fileDiff:r},s.element.appendChild(e),this.fileContainer.appendChild(s.element),this.annotationCache.set(o,s)}e.delete(o)}}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=ro();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.headerCache.lastRenderedHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:ba(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):ba(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=Jo;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute(`data-unified`)?this.codeUnified=t:t.hasAttribute(`data-deletions`)?this.codeDeletions=t:t.hasAttribute(`data-additions`)&&(this.codeAdditions=t))}applyHeaderToDOM(e,t,n){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{headerCache:{fileDiff:r,html:i,lastRenderedHTML:a}}=this,o=(n!==this.editSession?.diff&&Hi(r,n)?i:void 0)??Rs(e);if(this.headerCache.html=o,this.headerCache.fileDiff=n,o!==a){let e=document.createElement(`div`);e.innerHTML=o;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.headerCache.lastRenderedHTML=o}if(this.isComponentManaged)return;let{renderCustomHeader:s,renderHeaderPrefix:c,renderHeaderFilenameSuffix:l,renderHeaderMetadata:u}=this.options;if(s!=null){let e=s(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,lo,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}let d=c?.(n)??void 0,f=l?.(n)??void 0,p=u?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,gs,d),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,ya,f),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,zo,p),this.headerCustom?.remove(),this.headerCustom=void 0}clearReusableHeader(){this.headerCache.html=void 0,this.headerCache.fileDiff=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}injectUnsafeCSS(){let{unsafeCSS:e}=this.options;this.pre?.toggleAttribute(`data-custom-styles`,!!e);let t=this.fileContainer?.shadowRoot;t!=null&&(e==null||e===``?(this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0):(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=ja(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=ho(e),this.appliedUnsafeCSS=e))}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.getTheme(),s=typeof o==`string`?o:{...o},c=Na(i);this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c?this.appliedThemeCSS.theme=s:this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i?(this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}):(this.themeCSSStyle=es({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:ws(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c})}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e!=null&&this.themeCSSStyle!=null&&(this.themeCSSStyle.textContent=Oa(this.themeCSSStyle.textContent??``,Na(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&co()}applyHunksToDOM(e,t){this.shouldGuardRebuildScroll()?Uo(e,()=>this.replaceCodeColumns(e,t)):this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){let r=this.getColumnPair(e);if(r==null)return!1;let i=_f(t[0]),a=_f(t[1]);return i==null||a==null?!1:(r.gutter.innerHTML=Rs(i),r.content.innerHTML=Rs(a),n!==this.lastRowCount&&(r.gutter.style.setProperty(`grid-row`,`span ${n}`),r.content.style.setProperty(`grid-row`,`span ${n}`)),!0)}replaceCodeColumns(e,t){let{overflow:n=`scroll`}=this.options,r=(this.options.hunkSeparators??`line-info`)===`line-info`,i=n===`wrap`?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let a=!1,o=[],s=this.hunksRenderer.renderCodeAST(`unified`,t),c=this.hunksRenderer.renderCodeAST(`deletions`,t),l=this.hunksRenderer.renderCodeAST(`additions`,t);this.editor?.__captureFocusForDOMReplacement(),s==null?c!=null||l!=null?(c==null?(this.codeDeletions?.remove(),this.codeDeletions=void 0):(a=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=Ho({code:this.codeDeletions,columnType:`deletions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeDeletions,c,t.rowCount)||(this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(c)),o.push(this.codeDeletions)),l==null?(this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=a||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=Ho({code:this.codeAdditions,columnType:`additions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeAdditions,l,t.rowCount)||(this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(l)),o.push(this.codeAdditions))):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=Ho({code:this.codeUnified,columnType:`unified`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeUnified,s,t.rowCount)||(this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(s)),o.push(this.codeUnified)),o.length===0?e.textContent=``:a&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({fileDiff:e,previousRenderRange:t,renderRange:n}){let{pre:r,codeUnified:i,codeAdditions:a,codeDeletions:o,options:{diffStyle:s=`split`}}=this;if(r==null||t==null||n==null||!Number.isFinite(t.totalLines)||!Number.isFinite(n.totalLines)||this.lastRowCount==null)return!1;let c=this.getCodeColumns(s,i,o,a);if(c==null)return!1;let l=t.startingLine,u=n.startingLine,d=l+t.totalLines,f=u+n.totalLines,p=Math.max(l,u),m=Math.min(d,f);if(m<=p)return!1;let h=Math.max(0,p-l),g=Math.max(0,d-m),_=this.trimColumns({columns:c,trimStart:h,trimEnd:g,previousStart:l,overlapStart:p,overlapEnd:m,diffStyle:s});if(_<0)throw Error(`FileDiff.applyPartialRender: failed to trim to overlap`);if(this.lastRowCount<_)throw Error(`FileDiff.applyPartialRender: trimmed beyond DOM row count`);let v=this.lastRowCount-_,y=(t,n)=>{if(!(n<=0))return this.hunksRenderer.renderDiff(e,{startingLine:t,totalLines:n,bufferBefore:0,bufferAfter:0})},b=y(u,Math.max(p-u,0));if(b==null&&u<p)return!1;let x=y(m,Math.max(f-m,0));if(x==null&&f>m)return!1;let S=(e,t)=>{if(e!=null){if(s===`unified`&&!Array.isArray(c))this.insertPartialHTML(s,c,e,t);else if(s===`split`&&Array.isArray(c))this.insertPartialHTML(s,c,e,t);else throw Error(`FileDiff.applyPartialRender.applyChunk: invalid chunk application`);v+=e.rowCount,this.adoptRenderData(e.fileDiff)}};return this.cleanupErrorWrapper(),S(b,`afterbegin`),S(x,`beforeend`),this.lastRowCount!==v&&(this.applyRowSpan(s,c,v),this.lastRowCount=v),!0}insertPartialHTML(e,t,n,r){if(e===`unified`&&!Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`unified`,n);this.renderPartialColumn(t,e,r)}else if(e===`split`&&Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`deletions`,n),i=this.hunksRenderer.renderCodeAST(`additions`,n);this.renderPartialColumn(t[0],e,r),this.renderPartialColumn(t[1],i,r)}else throw Error(`FileDiff.insertPartialHTML: Invalid argument composition`)}refreshSplitDiffView(){let e=this.getWorkingDiff();if(this.options.diffStyle!==`split`||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns(`split`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(n))return;let r=(e,n)=>{if(n==null)return;let r=this.hunksRenderer.renderCodeAST(e,t),i=_f(r?.[0]),a=_f(r?.[1]);for(let[e,t]of[[n.gutter,i],[n.content,a]])if(t!=null&&e.childElementCount===t.length)for(let n=0;n<t.length;n++){let r=e.children[n],i=t[n].properties[`data-line-type`];i!=null&&r.dataset.lineType!==i&&(r.dataset.lineType=i)}};r(`deletions`,n[0]),r(`additions`,n[1]),this.adoptRenderData(t.fileDiff)}refreshUnifiedDiffView(){let e=this.getWorkingDiff();if(this.options.diffStyle!==`unified`||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns(`unified`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(n==null||Array.isArray(n))return;let r=this.hunksRenderer.renderCodeAST(`unified`,t),i=_f(r?.[0]),a=_f(r?.[1]),o=()=>{for(let[e,t]of[[n.gutter,i],[n.content,a]])t!=null&&(e.innerHTML=Rs(t));t.rowCount!==this.lastRowCount&&(this.applyRowSpan(`unified`,n,t.rowCount),this.lastRowCount=t.rowCount),this.adoptRenderData(t.fileDiff)};this.shouldGuardRebuildScroll()?Uo(this.pre,o):o(),this.renderSeparators(t.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=_f(t[0]),i=_f(t[1]);if(r==null||i==null)throw Error(`FileDiff.insertPartialHTML: Unexpected AST structure`);let a=i.at(0);n===`beforeend`&&a?.type===`element`&&typeof a.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(a.properties[`data-buffer-size`],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let o=i.at(-1);n===`afterbegin`&&o?.type===`element`&&typeof o.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(o.properties[`data-buffer-size`],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,a){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let o=this.getBufferSize(t.dataset);o!=null&&(a?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(n,o+e))}applyRowSpan(e,t,n){let r=e=>{e!=null&&(e.gutter.style.setProperty(`grid-row`,`span ${n}`),e.content.style.setProperty(`grid-row`,`span ${n}`))};if(e===`unified`&&!Array.isArray(t))r(t);else if(e===`split`&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error(`dun fuuuuked up`)}trimColumnRows(e,t,n){let r=0,i=0,a=0,o=!1,s=n>=0;if(e==null)return 0;let c=Array.from(e.content.children),l=Array.from(e.gutter.children);if(c.length!==l.length)throw Error(`FileDiff.trimColumnRows: columns do not match`);for(;a<c.length&&!(t<=0&&!s&&!o);){let e=l[a],u=c[a];if(a++,!(e instanceof HTMLElement)||!(u instanceof HTMLElement))throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: invalid row elements`);if(o&&(o=!1,e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset||e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset))e.remove(),u.remove(),i++;else if(`lineIndex`in e.dataset&&`lineIndex`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),t>0&&(t--,t===0&&(o=!0)),i++),r++;else if(`separator`in e.dataset&&`separator`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);else if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);else if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);else if(e.dataset.gutterBuffer===`buffer`&&`contentBuffer`in u.dataset){let a=this.getBufferSize(u.dataset);if(a==null)throw Error(`FileDiff.trimColumnRows: invalid element`);if(t>0){let n=Math.min(t,a),r=a-n;r>0?(this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=n):(e.remove(),u.remove(),i+=a),t-=n,t===0&&r===0&&(o=!0)}else if(s){let t=r,o=r+a-1;if(n<=t)e.remove(),u.remove(),i+=a;else if(n<=o){let t=o-n+1,r=a-t;this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=t}}r+=a}else throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: unknown row elements`)}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:a,trimStart:o}){let s=Math.max(0,r-i),c=n-i;if(c<0)throw Error(`FileDiff.trimColumns: overlap ends before previous`);let l=o>0,u=a>0;if(!l&&!u)return 0;let d=l?s:0,f=u?c:-1;if(t===`unified`&&!Array.isArray(e))return this.trimColumnRows(e,d,f);if(t===`split`&&Array.isArray(e)){let t=this.trimColumnRows(e[0],d,f),n=this.trimColumnRows(e[1],d,f);if(e[0]!=null&&e[1]!=null&&t!==n)throw Error(`FileDiff.trimColumns: split columns out of sync`);return e[0]==null?n:t}throw console.error({diffStyle:t,columns:e}),Error(`FileDiff.trimColumns: Invalid columns for diffType`)}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??``,10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty(`grid-row`,`span ${t}`),e.style.setProperty(`min-height`,`calc(${t} * 1lh)`)}getColumnPair(e){if(e==null)return;let t=e.children[0],n=e.children[1];if(t instanceof HTMLElement&&n instanceof HTMLElement&&t.dataset.gutter!=null&&n.dataset.content!=null)return{gutter:t,content:n}}getCodeColumns(e,t,n,r){if(e===`unified`)return this.getColumnPair(t);{let e=this.getColumnPair(n),t=this.getColumnPair(r);return e!=null||t!=null?[e,t]:void 0}}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}applyBuffers(e,t){t==null||this.shouldDisableVirtualizationBuffers()?(this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)):(t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0))}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){let{diffIndicators:a=`bars`,disableBackground:o=!1,disableLineNumbers:s=!1,overflow:c=`scroll`,diffStyle:l=`split`}=this.options,u={type:`diff`,diffIndicators:a,disableBackground:o,disableLineNumbers:s,overflow:c,split:l!==`unified`&&t!=null&&n!=null,totalLines:r,customProperties:i};Ca(u,this.appliedPreAttributes)||(Vo(e,u),this.appliedPreAttributes=u)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function df(e){return{name:e.name,lang:e.lang,contents:e.additionLines.join(``)}}function ff(e,t){return e==null||t==null?e==null&&t==null:ea(e,t)}function pf({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function mf({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function hf(e,t,n=!1){return!n&&e==null&&t}function gf(e,t,n=!1){return e==null&&t&&!n}function _f(e){if(e!=null&&e.type===`element`)return e.children??[]}var vf=3e3,yf=new Map,bf=-1,xf=class extends uf{__id=`little-virtualized-file-diff:${++bf}`;renderType=`virtualized`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0,ghostTextRows:yf,ghostTextRowsByIndex:new Map};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;currentCollapsed;pendingHydratedDiff;pendingExpansions;pendingRender;constructor(e,t,n,r,i){super(e,r,i),this.virtualizer=t,this.metrics=rs(n)}setMetrics(e,t=!1){let n=rs(e);(t||!Wo(this.metrics,n))&&(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&(this.forceRenderOverride=!0)}syncLineAnnotations(e){return e==null||!this.isNewAnnotations(e)||e.length===0&&this.getLatestAnnotations().length===0?!1:(super.setLineAnnotations(e),!0)}syncEditSessionAnnotationsFromEditor(e){return super.syncEditSessionAnnotationsFromEditor(e)?(this.forceRenderOverride=!0,!0):!1}setFileAnnotationHeight(e){let t=this.cache.fileAnnotationHeight;return e!==t&&(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0)}hasFileAnnotations(e){let t=this.getLayoutAnnotations();return qa(t)?t.some(t=>t.lineNumber===0?e.type===`new`?t.side===`additions`:e.type!==`deleted`||t.side===`deletions`:!1):!1}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){let t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!ds(t,e),r=n&&kf(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:Af(t,e)}),n&&(this.forceRenderOverride=!0),n&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1,resetRenderRange:n=!0}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal=0,this.cache.ghostTextRows=yf,this.cache.ghostTextRowsByIndex.size>0&&this.cache.ghostTextRowsByIndex.clear(),this.invalidateDerivedLayoutCache(t,n),e&&this.isSimpleMode()&&this.computeApproximateSize()}invalidateDerivedLayoutCache(e,t=!0){this.layoutDirty=!0,this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),e&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&t&&(this.renderRange=void 0)}applyGhostTextRows(e,t){let{cache:{heightDeltas:n,ghostTextRows:r,ghostTextRowsByIndex:i},metrics:{lineHeight:a}}=this;if(r===t)return!1;let o=this.getDiffStyle(),s=new Map;for(let[n,r]of t){let t=this.getLineIndexForDiff(e,n+1,`additions`);t!=null&&s.set(o===`split`?t[1]:t[0],r)}let c=!1;for(let e of new Set([...i.keys(),...s.keys()])){let t=((s.get(e)??0)-(i.get(e)??0))*a;if(t===0)continue;let r=(n.get(e)??0)+t;r===0?n.delete(e):n.set(e,r),this.cache.measuredHeightDeltaTotal+=t,c=!0}return this.cache.ghostTextRows=t,this.cache.ghostTextRowsByIndex=s,c}reconcileHeights(){let e=!1,{options:{overflow:t=`scroll`},metrics:{lineHeight:n}}=this,r=this.placeHolder==null?this.getRenderedDiff():this.getLayoutDiff();if(this.fileContainer==null||r==null)return this.height!==0&&(e=!0),this.height=0,e;this.top=this.getVirtualizedTop(),e=this.applyGhostTextRows(r,this.editor?.__getGhostTextRows()??yf);let{ghostTextRowsByIndex:i}=this.cache,a=t!==`scroll`||this.lineAnnotations.length>0||this.isResizeDebuggingEnabled();if(this.placeHolder!=null||!a&&this.cache.heightDeltas.size===0&&this.cache.fileAnnotationHeight===0)return e&&(this.computeApproximateSize(!0),this.setPlaceholderHeight(this.height)),e;let o=this.getDiffStyle(),s=o===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified];if(this.renderRange!=null&&ls(this.renderRange)){let t=Sf(s)??0;this.setFileAnnotationHeight(t)&&(e=!0)}for(let t of s){if(t==null)continue;let r=t.children[1];if(!(r instanceof HTMLElement))continue;let s=o===`split`&&t===this.codeDeletions;for(let t of r.children){if(!(t instanceof HTMLElement))continue;let r=t.dataset.lineIndex;if(r==null)continue;let c=Pf(r,o),l=i.get(c)??0;if(s&&l>0)continue;let u=this.cache.heightDeltas.get(c)??0;if(!a&&u===l*n)continue;let d=t.getBoundingClientRect().height+l*n,f=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(f=!0),d+=t.nextElementSibling.getBoundingClientRect().height);let p=this.getEstimatedLineHeight(f),m=d-p;m!==u&&(e=!0,this.cache.measuredHeightDeltaTotal+=m-u,m===0?this.cache.heightDeltas.delete(c):this.cache.heightDeltas.set(c,m))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer!=null&&(e&&(this.top=this.getVirtualizedTop()),this.render());flushManagers(){super.flushManagers(),this.lineStateRefreshPending&&this.flushDeferredLineState()}updateCodeViewLayout(e,t,n,r){let i=!1,a=!1,{pendingExpansions:o,pendingHydratedDiff:s,options:{collapsed:c=!1}}=this;if(s!=null&&(this.pendingHydratedDiff=void 0,s.expectedDiff===e&&(Object.assign(e,s.nextDiff),this.setHydratedState(s.files),this.installHydratedSessionDiff(e),this.forceRenderOverride=!0,i=!0,a=!0)),o!=null){this.pendingExpansions=void 0;for(let{hunkIndex:e,direction:t,expansionLineCountOverride:n}of o)this.hunksRenderer.expandHunk(e,t,n),this.forceRenderOverride=!0,a=!0}let l=this.updateInputDiff(e,r),{pendingRenderDiff:u,layoutDiffChanged:d,renderedDiffChanged:f,annotationsChanged:p}=this.updatePendingRender(e,r);return!this.forceRenderOverride&&(l||f||p)&&(this.forceRenderOverride=!0),(n?.resetDiffLayoutCache===!0||d)&&(i=!0),(d||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights)&&(a=!0),n?.metrics!=null&&(this.metrics=rs(n.metrics),i=!0,a=!0),this.currentCollapsed!==c&&(this.currentCollapsed=c,i=!0),i?this.resetLayoutCache({includeEstimatedHeights:a}):a&&this.invalidateDerivedLayoutCache(!0),this.top=t,this.computeApproximateSize(!1,u),this.height}getLinePosition(e,t=`additions`){let n=this.getLayoutDiff();if(n==null||e<1)return;let r=this.getLineIndexForDiff(n,e,t);if(r==null)return;let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsed:o=!1,collapsedContextThreshold:s=1}=this.options,c=this.getDiffStyle(),l=this.getHunkSeparatorType(),u=c===`split`?r[1]:r[0];this.approximateLayoutCheckpoints(n);let d=Qo(this.metrics,i),f=this.getLayoutCheckpointBeforeLineIndex(u),p=f?.top??d+this.cache.fileAnnotationHeight;if(o)return{top:Fo(this.metrics,i),height:0};let m;return Jr({diff:n,diffStyle:c,startingLine:f?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:s,callback:({hunkIndex:e,hunk:t,collapsedBefore:n,collapsedAfter:r,deletionLine:i,additionLine:a})=>{let o=c===`split`?a?.splitLineIndex??i?.splitLineIndex:a?.unifiedLineIndex??i?.unifiedLineIndex;if(o==null)throw Error(`VirtualizedFileDiff.getLinePosition: missing line index data`);if(n>0){let r=br({type:l,metrics:this.metrics,hunkIndex:e,hunkSpecs:t?.hunkSpecs});if(r!=null){if(p+=r.gapBefore,u>=o-n&&u<o)return m={top:p,height:r.height},!0;p+=r.height+r.gapAfter}}let s=this.getLineHeight(o,(a?.noEOFCR??!1)||(i?.noEOFCR??!1));if(o===u)return m={top:p,height:s},!0;if(p+=s,r>0){let e=ei({type:l,metrics:this.metrics});if(e!=null){if(u>o&&u<=o+r)return m={top:p+e.gapBefore,height:e.height},!0;p+=e.totalHeight}}return!1}}),m}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){let t=this.getLayoutDiff();if(t==null)return;let{disableFileHeader:n=!1,expandUnchanged:r=!1,collapsed:i=!1,collapsedContextThreshold:a=1}=this.options;if(i)return;let o=this.getDiffStyle(),s=this.getHunkSeparatorType();this.approximateLayoutCheckpoints(t);let c=this.getLayoutCheckpointBeforeTop(e),l=c?.top??Qo(this.metrics,n)+this.cache.fileAnnotationHeight,u;return Jr({diff:t,diffStyle:o,startingLine:c?.renderedLineIndex??0,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:a,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,deletionLine:a,additionLine:c})=>{let d=o===`split`?c?.splitLineIndex??a?.splitLineIndex:c?.unifiedLineIndex??a?.unifiedLineIndex;if(d==null)throw Error(`VirtualizedFileDiff.getNumericScrollAnchor: missing line index data`);if(r>0){let e=br({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n?.hunkSpecs});e!=null&&(l+=e.totalHeight)}if(l>=e&&(a==null?c!=null&&(u={lineNumber:c.lineNumber,side:`additions`,top:l}):u={lineNumber:a.lineNumber,side:`deletions`,top:l},u!=null))return!0;let f=this.getLineHeight(d,(c?.noEOFCR??!1)||(a?.noEOFCR??!1));if(l+=f,i>0){let e=ei({type:s,metrics:this.metrics});e!=null&&(l+=e.totalHeight)}return!1}}),u}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){let t=this.getLayoutDiff();if(this.top==null||t==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let n=e==null?this.renderRange:this.computeRenderRangeFromWindow(t,this.top,e);if(n==null)return;let{bufferBefore:r,bufferAfter:i,totalLines:a}=n,o=0;if(a===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(o=i)}return{topOffset:this.top+r+o,height:this.height-(r+i)}}cleanUp(e=!1){let t=this.cache.ghostTextRows.size>0;t&&(this.layoutDirty=!0);let n=e&&this.isAdvancedMode()&&this.fileContainer!=null&&(t||!Hi(this.getRenderedDiff(),this.getWorkingDiff()));this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||(this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0),this.pendingRender=void 0,this.isSetup=!1,super.cleanUp(e),n&&this.virtualizer.instanceChanged(this,!0)}expandHunk=(e,t,n)=>{this.getInputDiff()!=null&&(this.loadFilesIfNecessary(),this.isAdvancedMode()?(this.pendingExpansions??=[],this.pendingExpansions.push({hunkIndex:e,direction:t,expansionLineCountOverride:n})):(this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))};async handleFilesLoaded(e,t){if(this.getInputDiff()===e&&e.isPartial){if(this.isAdvancedMode()){let n=Tu(`clone`,e,t,this.options.parseDiffOptions);if(await yu(()=>this.primeHighlightCache(n)),this.getInputDiff()!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(Tu(`merge`,e,t,this.options.parseDiffOptions),this.setHydratedState(t),!this.installHydratedSessionDiff(e)&&(await yu(()=>this.primeHighlightCache(e)),this.getInputDiff()!==e))return;this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}}loadFilesIfNecessary(){if(this.pendingHydratedDiff!=null){if(this.pendingHydratedDiff.expectedDiff===this.getInputDiff())return;this.pendingHydratedDiff=void 0}super.loadFilesIfNecessary()}isLineRenderable(e){if(super.isLineRenderable(e))return!0;let{pendingExpansions:t}=this,n=this.getRenderedDiff();if(t==null||t.length===0||n==null)return!1;let{expansionLineCount:r=100,collapsedContextThreshold:i=1}=this.options,a=new Map(this.hunksRenderer.getExpandedHunksMap());for(let e of t){let t={...a.get(e.hunkIndex)??{fromStart:0,fromEnd:0}},n=e.expansionLineCountOverride??r;(e.direction===`up`||e.direction===`both`)&&(t.fromStart+=n),(e.direction===`down`||e.direction===`both`)&&(t.fromEnd+=n),a.set(e.hunkIndex,t)}return Ir({fileDiff:n,lineNumber:e,expandedHunks:a,collapsedContextThreshold:i})}invalidateEditSessionLayout(){this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),this.isSimpleMode()||this.computeApproximateSize(!0),this.getSimpleVirtualizer()?.requestHeightReconcile(this)}escalateEditSessionRender(){this.invalidateEditSessionLayout(),this.enabled&&this.getInputDiff()!=null&&(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))}shouldSelfHealEditSession(){return!this.isAdvancedMode()&&super.shouldSelfHealEditSession()}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){if(!this.enabled||this.getInputDiff()==null&&this.additionFile==null&&this.deletionFile==null)return;let e=this.getWorkingDiff(),t=e==null?void 0:this.hunksRenderer.getDiffForNextRender(e);this.isSimpleMode()&&(this.pendingRender=void 0),this.forceRenderOverride=!0,this.isSimpleMode()&&this.requestRender()||this.virtualizer.instanceChanged(this,!Hi(this.getRenderedDiff(),t))}get isComponentManaged(){return this.getAdvancedVirtualizer()?.isComponentManaged??super.isComponentManaged}syncGhostTextRows(){let e=this.getAdvancedVirtualizer();e==null?this.getSimpleVirtualizer()?.requestHeightReconcile(this):(e.capturePendingLayoutAnchor(),this.layoutDirty=!0,e.instanceChanged(this,!0))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1});let i=this.getRenderedDiff();if(!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!=null&&i!=null){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(i,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.getLayoutDiff()){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,t==null){this.layoutDirty=!1;return}this.applyGhostTextRows(t,this.editor?.__getGhostTextRows()??yf);let{disableFileHeader:i=!1,collapsed:a=!1}=this.options;a?(this.height+=Fo(this.metrics,i),this.layoutDirty=!1):(this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!r&&this.validateComputedHeight(t),this.layoutDirty=!1)}getLayoutDiff(){return this.pendingRender?.diff??this.getRenderedDiff()}getLayoutAnnotations(){let{pendingRender:e}=this;return e==null?this.lineAnnotations:this.getAnnotationsForDiff(e.diff)}getActiveEstimatedHeight(e=this.getLayoutDiff()){this.ensureEstimatedDiffHeights(e);let t=this.getDiffStyle()===`split`?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(t==null)throw Error(`VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height`);return t}ensureEstimatedDiffHeights(e=this.getLayoutDiff()){if(e==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,{splitHeight:i,unifiedHeight:a}=bu({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:jf(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=i,this.cache.estimatedUnifiedHeight=a}validateComputedHeight(e=this.getLayoutDiff()){if(this.fileContainer==null||e==null)return;let t=this.fileContainer.getBoundingClientRect();t.height===this.height?console.log(`VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFileDiff.computeApproximateSize: computed height doesnt match`,{name:e.name,elementHeight:t.height,computedHeight:this.height})}render({fileContainer:e,fileDiff:t,forceRender:n=!1,lineAnnotations:r,...i}={}){let a=Cu(i,`VirtualizedFileDiff.render`),o=a!=null,s=a?.oldFile,c=a?.newFile,l=o&&(!Nf(s,this.deletionFile)||!Nf(c,this.additionFile)),u=t??this.getInputDiff();t==null&&o&&(l||this.getInputDiff()==null)&&(u=Fu(a.oldFile,a.newFile,this.options.parseDiffOptions));let{forceRenderOverride:d,isSetup:f}=this;this.forceRenderOverride=void 0;let p=u!=null&&!Hi(this.getInputDiff(),u),m=p||l;if(e=this.getOrCreateFileContainer(e),u==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;p&&this.updateInputDiff(u,r);let{pendingRenderDiff:h,layoutDiffChanged:g,renderedDiffChanged:_,annotationsChanged:v}=this.pendingRender!=null&&this.pendingRender.workingDiff===(this.getWorkingDiff(u)??u)?{pendingRenderDiff:this.pendingRender.diff,layoutDiffChanged:!1,renderedDiffChanged:!1,annotationsChanged:this.syncLineAnnotations(r)}:this.updatePendingRender(u,r);if(g&&this.resetLayoutCache({includeEstimatedHeights:!0}),f)this.top??=this.getVirtualizedTop(),this.layoutDirty&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,h));else{this.computeApproximateSize(!1,h);let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFileDiff.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!m||!f))return a!=null&&(this.deletionFile=s,this.additionFile=c),p&&this.clearReusableHeader(),this.renderPlaceholder(this.height);let y=this.virtualizer.getWindowSpecs(),b=this.top??0,x=this.computeRenderRangeFromWindow(h,b,y);return super.render({fileDiff:u,fileContainer:e,renderRange:x,lineAnnotations:r,forceRender:(d??n)||v||_||p,...a,...i})}finalizeRender(){if(!Hi(this.getRenderedDiff(),this.pendingRender?.diff))throw Error(`VirtualizedFileDiff.render: rendered a different diff than its prepared layout`);this.pendingRender=void 0,this.isSimpleMode()&&this.getSimpleVirtualizer()?.requestHeightReconcile(this)}updatePendingRender(e,t){let n=this.getWorkingDiff(e)??e,r=this.getRenderedDiff(),{pendingRender:i}=this,a=i?.diff??r,o=this.hunksRenderer.getDiffForNextRender(n);return this.pendingRender={workingDiff:n,diff:o},{pendingRenderDiff:o,annotationsChanged:this.syncLineAnnotations(t),layoutDiffChanged:!Hi(a,o),renderedDiffChanged:!Hi(r,o)}}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type===`advanced`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??`split`}getHunkSeparatorType(){return Mf(this.options.hunkSeparators)}approximateLayoutCheckpoints(e){if(!this.layoutDirty&&this.cache.checkpoints.length>0||e.hunks.length===0||this.options.collapsed===!0)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,i=e.hunks.length-1,a=jf(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),s=this.getHunkSeparatorType(),c=n?!0:this.hunksRenderer.getExpandedHunksMap(),l=Cf(this.cache.heightDeltas),u=Qo(this.metrics,t)+this.cache.fileAnnotationHeight,d=0,f=({rowCount:e,startLineIndex:t,preSeparatorHeight:n=0,postSeparatorHeight:r=0,metadataOffsets:i=[]})=>{if(e<=0)return;let a=d,o=d+e,s=Ef(a);for(;s<o;){let e=s-a,r=u+(e>0?n:0)+e*this.metrics.lineHeight+Df(i,e)*this.metrics.lineHeight+wf(l,t,t+e);this.cache.checkpoints.push({renderedLineIndex:s,lineIndex:t+e,top:r}),s+=vf}u+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+wf(l,t,t+e)+r,d=o};for(let t=0;t<e.hunks.length;t++){let n=e.hunks[t];if(n==null)throw Error(`VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index`);let l=Qr({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:c,hunkIndex:t,collapsedContextThreshold:r}),u=l.collapsedLines>0?br({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n.hunkSpecs})?.totalHeight??0:0;f({rowCount:l.fromStart,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.rangeSize});let d=u;f({rowCount:l.fromEnd,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.fromEnd,preSeparatorHeight:d}),l.fromEnd>0&&(d=0);let p=t===i?ni({fileDiff:e,hunkIndex:t,expandedHunks:c,collapsedContextThreshold:r,errorPrefix:`VirtualizedFileDiff`}):void 0,m=p!=null&&p.collapsedLines>0||t===i&&a?ei({type:s,metrics:this.metrics})?.totalHeight??0:0,h=p==null?0:p.fromStart+p.fromEnd,g=o===`split`?n.splitLineCount:n.unifiedLineCount,_=o===`split`?n.splitLineStart:n.unifiedLineStart;f({rowCount:g,startLineIndex:_,preSeparatorHeight:d,postSeparatorHeight:h===0?m:0,metadataOffsets:Of({diffStyle:o,hunk:n,rowCount:g})}),p!=null&&h>0&&f({rowCount:h,startLineIndex:_+g,postSeparatorHeight:m})}this.cache.totalLines=d}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);if(n.renderedLineIndex%t===0)return n}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let r of e.hunks)n+=t===`split`?r.splitLineCount:r.unifiedLineCount;return n}let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a=r?!0:this.hunksRenderer.getExpandedHunksMap();for(let[r,o]of e.hunks.entries()){let s=t===`split`?o.splitLineCount:o.unifiedLineCount;n+=s;let c=Math.max(o.collapsedBefore,0),{fromStart:l,fromEnd:u,renderAll:d}=Qr({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=ni({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:a,collapsedContextThreshold:i,errorPrefix:`VirtualizedFileDiff`});return o!=null&&(n+=o.fromStart+o.fromEnd),n}getLayoutLineCount(e,t){let n=this.getExpandedLineCount(e,t),r=t===`split`?e.splitLineCount:e.unifiedLineCount;return Math.max(n,r,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:s,lineHeight:c}=this.metrics,l=this.getDiffStyle(),u=this.getHunkSeparatorType(),d=jf(e,this.options.loadDiffFiles!=null),f=this.height,p=this.getLayoutLineCount(e,l),m=Qo(this.metrics,i),h=e.hunks.length>0?vs(this.metrics):0,{fileAnnotationHeight:g}=this.cache,_=m+g,v=Math.max(0,f-m-g-h),y=this.hasFileAnnotations(e),b=t+m,x=g>0&&y&&b<r&&b+g>n;if(t<n-f||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h};if(p<=s||e.hunks.length===0)return{startingLine:0,totalLines:s,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),p=this.getLayoutLineCount(e,l);let S=Math.ceil(Math.max(r-n,0)/c),C=Math.ceil(S/s)*s+s,w=C/s,T=w,E=[],D=(n+r)/2,O=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-C*c*2),s),k=t+(O?.top??_),A=O?.renderedLineIndex??0,j,M,N;if(Jr({diff:e,diffStyle:l,startingLine:O?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:i,hunk:a,collapsedBefore:o,collapsedAfter:c,deletionLine:f,additionLine:p})=>{let m=p==null?f.splitLineIndex:p.splitLineIndex,h=p==null?f.unifiedLineIndex:p.unifiedLineIndex,g=(p?.noEOFCR??!1)||(f?.noEOFCR??!1),v=i===e.hunks.length-1&&a!=null&&(l===`split`?m===a.splitLineStart+a.splitLineCount-1:h===a.unifiedLineStart+a.unifiedLineCount-1),y=(o>0?br({type:u,metrics:this.metrics,hunkIndex:i,hunkSpecs:a?.hunkSpecs}):void 0)?.totalHeight??0;k+=y;let b=A%s===0,x=Math.floor(A/s);if(b&&(E[x]=k-(t+_+y),N!=null)){if(N<=0)return!0;N--}let S=this.getLineHeight(l===`split`?m:h,g);if(k>n-S&&k<r&&(j??=x),M==null&&k+S>D&&(M=x),N==null&&k>=r&&b&&(N=T),A++,k+=S,c>0||v&&d){let e=ei({type:u,metrics:this.metrics});e!=null&&(k<r&&k+e.totalHeight>n&&(j??=x),M==null&&k+e.totalHeight>D&&(M=x),k+=e.totalHeight)}return!1}}),j==null){if(x)j=0,M=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h}}M??=j;let P=Math.round(M-w/2),F=Math.max(0,Math.ceil(p/s)-w),I=Math.max(0,Math.min(P,F)),L=I*s,R=P<0?C+P*s:C,z=E[I]??0,B=L===0?0:g+z,V=I+R/s,H=V<E.length?v-E[V]:v-(k-t-_);return{startingLine:L,totalLines:R,bufferBefore:B,bufferAfter:Math.max(0,H)}}};function Sf(e){let t;for(let n of e){if(n==null)continue;let e=n.children[1];if(e instanceof HTMLElement)for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===`-1,-1`&&(t=Math.max(t??0,n.getBoundingClientRect().height))}return t}function Cf(e){let t=Array.from(e).sort((e,t)=>e[0]-t[0]),n=[],r=[0],i=0;for(let[e,a]of t)n.push(e),i+=a,r.push(i);return{lineIndexes:n,prefixTotals:r}}function wf({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=Tf(e,n);return(t[Tf(e,r)]??0)-(t[i]??0)}function Tf(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid prefix index`);a<t?n=i+1:r=i}return n}function Ef(e){return Math.ceil(e/vf)*vf}function Df(e,t){let n=0;for(let r of e)r<t&&n++;return n}function Of({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];let r=t.hunkContent.at(-1);if(r==null)return[];if(r.type===`context`)return[n-1];let i=Math.max(r.deletions,r.additions),a=r.deletions+r.additions;if(e===`split`)return i>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];let o=[],s=n-a;return r.deletions>0&&t.noEOFCRDeletions&&o.push(s+r.deletions-1),r.additions>0&&t.noEOFCRAdditions&&o.push(n-1),o}function kf(e,t){return(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function Af(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function jf(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function Mf(e){return typeof e==`function`?`custom`:e??`line-info`}function Nf(e,t){return e==null||t==null?e==null&&t==null:ea(e,t)}function Pf(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}var Ff=`theme.disableLineNumbers.overflow.themeType.disableFileHeader.disableVirtualizationBuffers.preferredHighlighter.useCSSClasses.useTokenTransformer.tokenizeMaxLineLength.tokenizeMaxLength.unsafeCSS.diffStyle.diffIndicators.disableBackground.expandUnchanged.loadDiffFiles.parseDiffOptions.collapsedContextThreshold.lineDiffType.maxLineDiffLength.expansionLineCount.lineHoverHighlight.enableTokenInteractionsOnWhitespace.enableGutterUtility.__debugPointerEvents.enableLineSelection.controlledSelection.disableErrorHandling`.split(`.`),If=[`theme`,`disableLineNumbers`,`overflow`,`themeType`,`disableFileHeader`,`disableVirtualizationBuffers`,`preferredHighlighter`,`useCSSClasses`,`useTokenTransformer`,`tokenizeMaxLineLength`,`tokenizeMaxLength`,`unsafeCSS`,`lineHoverHighlight`,`enableTokenInteractionsOnWhitespace`,`enableGutterUtility`,`__debugPointerEvents`,`enableLineSelection`,`controlledSelection`,`disableErrorHandling`],Lf=[`renderCustomHeader`,`renderHeaderPrefix`,`renderHeaderFilenameSuffix`,`renderHeaderMetadata`,`renderAnnotation`,`renderGutterUtility`,`onPostRender`,`onGutterUtilityClick`,`onLineClick`,`onLineNumberClick`,`onLineEnter`,`onLineLeave`,`onTokenClick`,`onTokenEnter`,`onTokenLeave`],Rf=[`onLineSelected`,`onLineSelectionStart`,`onLineSelectionChange`,`onLineSelectionEnd`],zf=Symbol(`CodeView.itemOptionsState`);function Bf(e,t){Object.defineProperty(e,zf,{configurable:!1,enumerable:!1,value:t})}function Vf(e){return e[zf]}function Hf(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get(){return n(this)}})}var Uf=120,Wf=1,Gf=`--diffs-overflow-override`;function Kf(e,t,n){return{containerHeight:e,triggerTop:t,targetTop:n,targetBottom:e-n,threshold:e-t}}var qf=Kf(12e6,1e6,2e6),Jf=Kf(2**22,5e5,1e6);function Yf(e){if(e==null)throw Error(`CodeView: createEditor is required for items with edit: true`)}var Xf=(()=>{let{navigator:e}=globalThis,t=e.userAgent,n=/iP(?:hone|ad|od)/.test(t),r=e.platform===`MacIntel`&&e.maxTouchPoints>1;return(n||r)&&/AppleWebKit/.test(t)&&/Safari/.test(t)&&!/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(t)})(),Zf=class e{static __STOP=!1;static __lastScrollPosition=0;type=`advanced`;config={overscrollSize:200,intersectionObserverMargin:0,resizeDebugging:!1};items=[];idToItem=new Map;selectedLines=null;itemEditors=new Map;attachedEditors=new Set;instanceToItem=new Map;layoutDirtyIndex;pendingLayoutReset;renderOptionsRevision=0;slotCoordinator;slotSnapshot;scrollListeners=new Set;scrollHeight=0;containerHeight=-1;scrollTop=0;scrollPageOffset=0;scrollRebaseConfig=wo()?Jf:qf;scrollDirty=!0;scrollInteractionFixTimer;pointerEventsDisabled=!1;codeOverflowFix=!1;height=0;heightDirty=!0;windowSpecs={top:0,bottom:0};renderState={scrollTop:-1,firstIndex:-1,lastIndex:-1,stickyHeight:0,stickyTop:-1,stickyBottom:-1};itemMetricsCache=ks;fileOptionsPrototype;diffOptionsPrototype;pendingScrollTarget;pendingLayoutAnchor;headerResizeAnchor;shouldFixContainerFocus=!1;scrollAnimation;root;resizeObserver;container=document.createElement(`div`);stickyContainer=document.createElement(`div`);stickyOffset=document.createElement(`div`);header={element:void 0,render:void 0,height:0};footer={element:void 0,render:void 0,height:0};elementPool=[];elementPoolVersion=0;elementPoolTracker=new WeakMap;pendingElementPool=[];options;workerManager;isReadySubscription;pendingHighlighterTheme;isComponentManaged;slotSnapshotStale=!1;constructor(e={theme:bo},t,n=!1){this.options=e,this.computeMetricsCache(e.itemMetrics),this.fileOptionsPrototype=this.createFileOptionsPrototype(),this.diffOptionsPrototype=this.createDiffOptionsPrototype(),this.workerManager=t,this.isComponentManaged=n,this.stickyOffset.style.contain=`layout size`,this.stickyContainer.style.position=`sticky`,this.stickyContainer.style.width=`100%`,this.stickyContainer.style.contain=`layout style inline-size`,this.stickyContainer.style.isolation=`isolate`,this.stickyContainer.style.display=`flex`,this.stickyContainer.style.flexDirection=`column`}getLayout(){return this.options.layout??wa}getItemTopOffset(){return this.getLayout().paddingTop+this.header.height}computeMetricsCache(e){return this.itemMetricsCache={hunkLineCount:e?.hunkLineCount??ks.hunkLineCount,lineHeight:e?.lineHeight??ks.lineHeight,diffHeaderHeight:e?.diffHeaderHeight??ks.diffHeaderHeight,hunkSeparatorHeight:e?.hunkSeparatorHeight,spacing:e?.spacing??ks.spacing,paddingTop:e?.paddingTop,paddingBottom:e?.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??go}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return ss&&this.options.__devOnlyValidateItemHeights===!0}validateRenderedItemHeight(e){if(!this.shouldValidateItemHeights()||e.element==null)return;let t=e.instance.getAdvancedStickySpecs();if(t==null)return;let n=t.height,r=e.element.getBoundingClientRect().height;n!==r&&console.error(`CodeView: reconciled item height does not match DOM height`,{id:e.item.id,type:e.type,index:e.index,version:e.version,expectedHeight:n,actualHeight:r,delta:r-n,stickyTopOffset:t.topOffset,virtualizedHeight:e.instance.getVirtualizedHeight(),top:e.top,scrollTop:this.getScrollTop(),windowSpecs:{...this.windowSpecs},element:e.element,instance:e.instance})}validateStickyContainerHeight(){if(!this.shouldValidateItemHeights())return;let{firstIndex:e,lastIndex:t,stickyHeight:n,stickyTop:r,stickyBottom:i}=this.renderState;if(e===-1||t===-1)return;let a=this.stickyContainer.getBoundingClientRect().height;Math.abs(a-n)<Wf||console.error(`CodeView: sticky container height does not match computed layout`,{computedStickyHeight:n,actualStickyHeight:a,delta:a-n,stickyTop:r,stickyBottom:i,firstIndex:e,lastIndex:t,firstStickySpecs:this.items[e]?.instance.getAdvancedStickySpecs(),lastStickySpecs:this.items[t]?.instance.getAdvancedStickySpecs(),scrollTop:this.getScrollTop(),scrollPageOffset:this.scrollPageOffset,windowSpecs:{...this.windowSpecs},stickyContainer:this.stickyContainer})}clearScrollInteractionTimer(){this.scrollInteractionFixTimer!=null&&(clearTimeout(this.scrollInteractionFixTimer),this.scrollInteractionFixTimer=void 0)}suspendScrollInteractions(){this.clearScrollInteractionTimer(),this.shouldDisablePointerEvents()&&!this.pointerEventsDisabled&&(this.stickyContainer.style.pointerEvents=`none`,this.pointerEventsDisabled=!0),Xf&&!this.codeOverflowFix&&(this.stickyContainer.style.setProperty(Gf,`hidden`),this.codeOverflowFix=!0),this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,Uf)}restoreScrollInteractions=()=>{this.clearScrollInteractionTimer(),this.pointerEventsDisabled&&=(this.stickyContainer.style.removeProperty(`pointer-events`),!1),this.codeOverflowFix&&=(this.stickyContainer.style.setProperty(Gf,`auto`),!1)};syncLayout(){let{gap:e,paddingBottom:t,paddingTop:n}=this.getLayout();this.stickyContainer.style.gap=`${e}px`,this.container?.style.setProperty(`margin-top`,`${n}px`),this.container?.style.setProperty(`margin-bottom`,`${t}px`)}reconcileHeaderFooterHosts(){let e=this.reconcileHost(`header`),t=this.reconcileHost(`footer`);return e||t}reconcileHost(e){let{root:t,container:n}=this;if(t==null||n==null)return!1;let r=e===`header`?this.header:this.footer,i=e===`header`?this.options.renderCodeViewHeader:this.options.renderCodeViewFooter;if(i==null)return r.element==null||(this.resizeObserver?.unobserve(r.element),r.element.remove(),r.element=void 0,r.render=void 0,this.setHostHeight(r,0)),!1;if(r.element!=null&&i===r.render)return!1;let a=r.element??gu(e,n,this.resizeObserver);r.element=a;let o=i();return o==null?!this.isComponentManaged&&a.children.length>0&&(a.textContent=``):a.replaceChildren(o),r.render=i,!0}setHostHeight(e,t){e.height!==t&&(e.height=t,this.scrollDirty=!0)}measureMountedHosts(){this.header.element!=null&&this.setHostHeight(this.header,this.header.element.getBoundingClientRect().height),this.footer.element!=null&&this.setHostHeight(this.footer,this.footer.element.getBoundingClientRect().height)}setup(t){if(this.root!=null)throw Error(`CodeView.setup: already setup`);this.workerManager?.subscribeToThemeChanges(this),this.root=t,this.root.style.overflowAnchor=`none`,this.root.hasAttribute(`tabindex`)||(this.root.tabIndex=-1),this.container??=document.createElement(`div`),this.container.style.contain=`layout style`,this.syncLayout(),this.container.appendChild(this.stickyOffset),this.container.appendChild(this.stickyContainer),this.root.appendChild(this.container),this.scrollDirty=!0,this.heightDirty=!0,this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.stickyContainer),this.root.addEventListener(`scroll`,this.handleScroll,{passive:!0}),this.root.addEventListener(`wheel`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`touchstart`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`pointerdown`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`keydown`,this.clearPendingScroll,{passive:!0}),this.resizeObserver.observe(this.root),this.render(!0),window.__INSTANCE=this,window.__TOGGLE=()=>{e.__STOP?(e.__STOP=!1,this.scrollTo({type:`position`,position:e.__lastScrollPosition,behavior:`instant`})):(e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0)}}reset(){hs(this.computeRenderRangeAndEmit),this.clearReadySubscription(),this.restoreScrollInteractions(),this.cleanAllRenderedItems();let{items:e}=this,t=[...this.itemEditors.values()].map(e=>{let t=this.idToItem.get(e.state.id);return t!=null&&(e.state.removedItem=t.item),e});this.itemEditors.clear(),this.attachedEditors.clear(),this.selectedLines=null,this.items=[],this.idToItem.clear(),this.instanceToItem.clear();let n=!1,r;for(let e of t)try{e.editor.cleanUp(`discard`)}catch(e){n||(n=!0,r=e)}for(let t of e)try{t.instance.cleanUp()}catch(e){n||(n=!0,r=e)}if(this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,this.stickyContainer.textContent=``,this.stickyOffset.style.height=``,this.container?.style.removeProperty(`height`),this.containerHeight=-1,this.windowSpecs={top:0,bottom:0},this.pendingLayoutAnchor=void 0,this.headerResizeAnchor=void 0,this.shouldFixContainerFocus=!1,this.height=0,this.scrollTop=0,this.scrollPageOffset=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.resetRenderState(),this.isComponentManaged||this.flushSlotCoordinator(),n)throw r}cleanUp(){let e=!1,t;try{this.reset()}catch(n){e=!0,t=n}if(this.clearElementPool(),this.restoreScrollInteractions(),this.workerManager?.unsubscribeToThemeChanges(this),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.root?.removeEventListener(`scroll`,this.handleScroll),this.root?.removeEventListener(`wheel`,this.clearPendingScroll),this.root?.removeEventListener(`touchstart`,this.clearPendingScroll),this.root?.removeEventListener(`pointerdown`,this.clearPendingScroll),this.root?.removeEventListener(`keydown`,this.clearPendingScroll),this.root?.style.removeProperty(`overflow-anchor`),this.container?.remove(),this.stickyOffset.remove(),this.stickyContainer.remove(),this.stickyContainer.textContent=``,this.header.element?.remove(),this.header.element=void 0,this.header.render=void 0,this.header.height=0,this.footer.element?.remove(),this.footer.element=void 0,this.footer.render=void 0,this.footer.height=0,this.root=void 0,this.container=void 0,e)throw t}cleanAllRenderedItems(){if(this.renderState.firstIndex!==-1)for(let e=this.renderState.firstIndex;e<=this.renderState.lastIndex;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${e}`);this.releaseRenderedItem(t)}}primeScrollTarget(e){e.type!==`position`&&this.idToItem.get(e.id)?.instance.primeHighlightCache()}getElementPoolLimit(){let e=this.getHeight()+this.config.overscrollSize*2,{diffHeaderHeight:t}=this.itemMetricsCache;return Math.max(8,Math.ceil(e/Math.max(t,10))+1)*(this.isComponentManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let e=this.elementPool.pop();for(;e!=null&&!this.isElementPoolGenerationCurrent(e);)e=this.elementPool.pop();return e??=document.createElement(Ua),this.markElementPoolGenerationCurrent(e),e}releaseRenderedItem(e){let{element:t}=e;t!=null&&this.renderedItemOwnsFocus(t)&&(this.shouldFixContainerFocus=!0),e.instance.cleanUp(!0),this.attachedEditors.delete(e.item.id),e.element=void 0,t!=null&&(t.remove(),this.cleanElement(t),this.queueElementForPool(t))}renderedItemOwnsFocus(e){let{activeElement:t}=document;return t===e||e.contains(t)||e.shadowRoot?.activeElement!=null}fixContainerFocus(){this.shouldFixContainerFocus&&(this.shouldFixContainerFocus=!1,this.root?.focus({preventScroll:!0}))}cleanElement(e){let{shadowRoot:t}=e;if(t!=null)for(let e of Array.from(t.children))np(e)||e.remove();this.isComponentManaged||e.replaceChildren()}queueElementForPool(e){let t=this.getElementPoolLimit();!this.isElementPoolGenerationCurrent(e)||this.getElementPoolSize()>=t||(this.isElementClean(e)?this.elementPool.push(e):this.pendingElementPool.push(e))}promotePendingPooledElements(){if(this.pendingElementPool.length===0)return;let{pendingElementPool:e}=this;this.pendingElementPool=[];let t=this.getElementPoolLimit();for(let n of e)this.isElementPoolGenerationCurrent(n)&&this.isElementClean(n)&&this.elementPool.length<t?this.elementPool.push(n):this.isElementPoolGenerationCurrent(n)&&this.getElementPoolSize()<t&&this.pendingElementPool.push(n)}isElementClean(e){return e.childNodes.length===0}getElementPoolSize(){return this.elementPool.length+this.pendingElementPool.length}clearElementPool(){this.elementPool.length=0,this.pendingElementPool.length=0}invalidateElementPool(){this.elementPoolVersion++,this.clearElementPool()}markElementPoolGenerationCurrent(e){this.elementPoolTracker.set(e,this.elementPoolVersion)}isElementPoolGenerationCurrent(e){return this.elementPoolTracker.get(e)===this.elementPoolVersion}resolveEffectiveScrollBehavior(e,t){return _u()?`instant`:e.behavior===`smooth-auto`?Math.abs(t-this.getScrollTop())<=this.getHeight()*10?`smooth`:`instant`:e.behavior??`instant`}scrollTo(e){if(this.root==null)return;let t=this.normalizeScrollTarget(e);if(t==null)return;let n=this.resolveScrollTargetTop(t);n!=null&&(this.primeScrollTarget(t),this.resolveEffectiveScrollBehavior(t,n)===`smooth`?this.scrollAnimation??={position:this.getScrollTop(),velocity:0,lastTimestamp:performance.now()}:this.scrollAnimation=void 0,this.suspendScrollInteractions(),this.pendingLayoutAnchor=void 0,this.pendingScrollTarget=t,this.render())}setSelectedLines(e,t){this.applySelectedLines(e,t)}getSelectedLines(){return this.selectedLines}clearSelectedLines(e){this.applySelectedLines(null,e)}getItem(e){return this.idToItem.get(e)?.item}getEditor(e){return this.itemEditors.get(e)?.editor}updateItem(e){let t=this.idToItem.get(e.id);return t==null?(console.error(`CodeView.updateItem: unknown item id "${e.id}"`),!1):this.syncItemRecord(t,e)?(this.markItemLayoutDirty(t),this.scrollDirty=!0,this.render(),this.syncItemEditors(),this.syncSelection(),!0):!1}updateItemId(e,t){if(e===t)return!0;let n=this.idToItem.get(e);if(n==null)return console.error(`CodeView.updateItemId: unknown item id "${e}"`),!1;if(this.idToItem.has(t))return console.error(`CodeView.updateItemId: duplicate item id "${t}"`),!1;this.idToItem.delete(e),n.item.id=t,this.idToItem.set(t,n),this.updateItemOptionsId(n.instance.options,t),this.selectedLines?.id===e&&(this.selectedLines={...this.selectedLines,id:t},this.options.onSelectedLinesChange?.(this.selectedLines));let r=this.itemEditors.get(e);return r!=null&&(this.itemEditors.delete(e),this.itemEditors.set(t,r),this.attachedEditors.delete(e)&&this.attachedEditors.add(t)),this.renamePendingScrollTarget(e,t),this.renamePendingLayoutAnchor(e,t),this.render(),!0}addItem(e){this.addItems([e])}addItems(e){this.appendItemsInternal(e),this.syncItemEditors(),this.syncSelection()}removeItem(e){let t=this.idToItem.get(e);if(t==null)return console.error(`CodeView.removeItem: unknown item id "${e}"`),!1;let n=[];for(let e of this.items)e!==t&&n.push(e.item);return this.setItems(n),!0}setItems(e){let t;this.items.length===0?this.appendItemsInternal(e):this.tryAppendItems(e)||(t=this.reconcileItems(e));try{this.syncItemEditors(t)}finally{for(let e of t?.values()??[])e.instance.cleanUp()}this.syncSelection()}appendItemsInternal(e,t=!0){if(e.length===0)return;let n=this.getLayout(),r=this.items.length===0?0:this.scrollHeight+n.gap,i=r;for(let t=0;t<e.length;t++){let i=e[t];if(i==null)throw Error(`CodeView.appendItemsInternal: missing input item`);if(this.idToItem.has(i.id))throw Error(`CodeView.addItem: duplicate id "${i.id}"`);let a=this.createItem(i,this.items.length,r);this.items.push(a),this.idToItem.set(a.item.id,a),this.instanceToItem.set(a.instance,a),a.height=Qf(a),r+=a.height+n.gap}this.scrollHeight=r-n.gap,this.scrollDirty=!0,t&&(this.canSkipRenderForAppend(i)?this.syncContainerHeight():this.render())}canSkipRenderForAppend(e){return this.container!=null&&this.renderState.firstIndex!==-1&&this.pendingScrollTarget==null&&this.scrollAnimation==null&&this.layoutDirtyIndex==null&&e>this.windowSpecs.bottom}onThemeChange(){this.invalidateElementPool()}setOptions(e){if(e==null)return;this.capturePendingLayoutAnchor();let{options:t}=this,n=this.getLayout(),{itemMetricsCache:r}=this;$f(t,e)&&this.invalidateElementPool(),this.options=e;let i=this.computeMetricsCache(e.itemMetrics),a=!Wo(r,i),o=!Wo(n,this.getLayout());o&&this.syncLayout();let s=a||ep(t,e);if(s){let n=this.pendingLayoutReset;this.pendingLayoutReset={metrics:a?i:n?.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:n?.includeEstimatedDiffHeights===!0||a||tp(t,e)}}(o||s)&&(this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0),ds(t,e)||this.renderOptionsRevision++,this.syncItemEditors();let c=t.renderCodeViewHeader!==e.renderCodeViewHeader||t.renderCodeViewFooter!==e.renderCodeViewFooter;!this.isComponentManaged&&(this.items.length>0||c)&&this.render()}capturePendingLayoutAnchor(e=this.idToItem){this.root!=null&&this.items.length!==0&&this.pendingScrollTarget==null&&(this.pendingLayoutAnchor=this.getScrollAnchor(this.getScrollTop(),e))}render(t=!1){e.__STOP||(t?(hs(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit()):ts(this.computeRenderRangeAndEmit))}isReady(){let{workerManager:e}=this;return e==null||e.getStats().workersFailed?this.isSharedHighlighterReady():e.isInitialized()?(this.clearReadySubscription(),!0):(this.isReadySubscription??=e.subscribeToStatChanges(e=>{(e.managerState===`initialized`||e.workersFailed)&&(this.clearReadySubscription(),this.render(!0))}),e.getStats().managerState===`waiting`&&e.initialize().catch(()=>{}),!1)}clearReadySubscription(){this.isReadySubscription!=null&&(this.isReadySubscription(),this.isReadySubscription=void 0,this.pendingHighlighterTheme=void 0)}isSharedHighlighterReady(){let e=this.workerManager?.getFileRenderOptions().theme??this.options.theme??bo;return Xo({theme:e})==null?(no(this.pendingHighlighterTheme,e)||this.clearReadySubscription(),this.isReadySubscription??=(()=>{this.pendingHighlighterTheme=e;let t=!1;return qo({themes:$a(e),langs:[],preferredHighlighter:Oo(this.workerManager,this.options)}).then(()=>{t||(this.clearReadySubscription(),this.render(!0))},e=>{t||(this.clearReadySubscription(),e instanceof Fs||console.error(e))}),()=>{t=!0}})(),!1):(this.clearReadySubscription(),!0)}instanceChanged(e,t){let n=this.instanceToItem.get(e);if(n==null)throw Error(`CodeView.instanceChanged: An instance has changed that is not registered`);t&&this.markItemLayoutDirty(n),this.itemEditors.has(n.item.id)||(this.slotSnapshotStale=!0),this.render()}getWindowSpecs(){return this.windowSpecs}getContainerElement(){return this.root}getHeaderElement(){return this.header.element}getFooterElement(){return this.footer.element}getRenderedItems(){let{firstIndex:e,lastIndex:t}=this.renderState;if(e===-1||t===-1||t<e)return[];let n=[];for(let r=e;r<=t;r++){let e=this.items[r];e?.element!=null&&(e.type===`diff`?n.push({id:e.item.id,type:`diff`,item:e.item,version:e.version,element:e.element,instance:e.instance}):n.push({id:e.item.id,type:`file`,item:e.item,version:e.version,element:e.element,instance:e.instance}))}return n}setSlotCoordinator(e){return e!==this.slotCoordinator&&(this.slotCoordinator=e,this.slotSnapshot=void 0,!0)}getSlotSnapshot(e){return this.buildSlotSnapshot(e)}buildSlotSnapshot(e){let t=cp(this.getRenderedItems(),e),{element:n}=this.header,{element:r}=this.footer;if(t!=null||n!=null||r!=null)return{items:t,header:n,footer:r}}subscribeToScroll(e){return this.scrollListeners.add(e),()=>{this.scrollListeners.delete(e)}}getLocalTopForInstance(e){let t=this.instanceToItem.get(e);if(t==null)throw Error(`CodeView.getLocalTopForInstance: unknown virtualized instance`);return t.top}getTopForItem(e){let t=this.idToItem.get(e);if(t!=null)return t.top+this.getItemTopOffset()}createItem(e,t,n){let{itemMetricsCache:r}=this;if(e.type===`diff`){let i=new xf(this.createDiffOptions(e.id),this,r,this.workerManager);return{type:`diff`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}let i=new ys(this.createFileOptions(e.id),this,r,this.workerManager);return{type:`file`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}applySelectedLines(e,t){let{selectedLines:n}=this;e==null&&n==null||e!=null&&n?.id===e.id&&Ro(n.range,e.range)||(n!=null&&n.id!==e?.id&&this.idToItem.get(n.id)?.instance.setSelectedLines(null,{notify:!1}),this.selectedLines=e,this.idToItem.get(e?.id??``)?.instance.setSelectedLines(e?.range??null,t))}syncSelection(){if(this.selectedLines==null)return;let e=this.idToItem.get(this.selectedLines.id);e==null?(this.selectedLines=null,this.options.onSelectedLinesChange?.(null)):e.instance.setSelectedLines(this.selectedLines.range,{notify:!1})}isItemInEditMode(e){return e.item.edit===!0&&e.item.collapsed!==!0}attachItemEditor(e){let{id:t}=e.item,{createEditor:n}=this.options;if(e.element==null||this.attachedEditors.has(t)||!this.isItemInEditMode(e))return;let r=this.itemEditors.get(t),i;try{if(r==null&&e.type===`diff`&&!e.instance.__canAttachEditor()){e.instance.__prepareForEditing();return}if(r==null){Yf(n);let r=Vf(e.instance.options);if(r==null)throw Error(`CodeView.attachItemEditor: instance options are missing their state`);let a=e=>{let t=this.idToItem.get(r.id);t!=null&&this.options.onItemEditChange?.(e,t.item)},o=this.options.getEditStateKey?.(e.item);if(e.type===`diff`){let s=n(`file-diff`,{onChange:a},o);i=s,this.itemEditors.set(t,{editor:s,state:r,dispose:s.edit(e.instance)})}else{let s=n(`file`,{onChange:a},o);i=s,this.itemEditors.set(t,{editor:s,state:r,dispose:s.edit(e.instance)})}}else r.dispose=(e.type,r.editor.edit(e.instance));this.attachedEditors.add(t)}catch(t){throw i?.cleanUp(),this.releaseRenderedItem(e),t}}syncItemEditors(e){if(this.itemEditors.size===0)return;let t=[];for(let[n,r]of this.itemEditors){let i=this.idToItem.get(n),a=e?.get(n);if(a==null&&i!=null){let{edit:e=!1,collapsed:t=!1}=i.item;if(e){t&&this.attachedEditors.delete(n)&&r.editor.cleanUp(`recycle`);continue}}else a!=null&&(r.state.removedItem=a.item);this.itemEditors.delete(n),this.attachedEditors.delete(n),t.push(r)}if(t.length===0)return;let n=!1,r;for(let e of t){try{e.dispose()}catch(e){n||(n=!0,r=e)}let t=this.idToItem.get(e.state.id);t!=null&&this.markItemLayoutDirty(t)}if(this.render(),n)throw r}requireItemFromState(e){let t=this.idToItem.get(e.id)?.item??e.removedItem;if(t==null)throw Error(`CodeView.onItemEditComplete: unknown item "${e.id}"`);return t}completeFileItemEdit(e,t){let n=this.requireItemFromState(e);if(n.type!==`file`)throw Error(`CodeView.onItemEditComplete: item "${e.id}" is not a file item`);let r={...n,file:t.file,annotations:t.lineAnnotations,edit:!1,version:(n.version??0)+1};return(this.options.onItemEditComplete?.(t,n,r)??`reject`)===`reject`?`reject`:(this.idToItem.has(n.id)&&this.updateItem(r),`accept`)}completeDiffItemEdit(e,t){let n=this.requireItemFromState(e);if(n.type!==`diff`)throw Error(`CodeView.onItemEditComplete: item "${e.id}" is not a diff item`);let r={...n,fileDiff:t.fileDiff,annotations:t.lineAnnotations,edit:!1,version:(n.version??0)+1};return(this.options.onItemEditComplete?.(t,n,r)??`reject`)===`reject`?`reject`:(this.idToItem.has(n.id)&&this.updateItem(r),`accept`)}renamePendingScrollTarget(e,t){let{pendingScrollTarget:n}=this;n!=null&&n.type!==`position`&&n.id===e&&(this.pendingScrollTarget={...n,id:t})}renamePendingLayoutAnchor(e,t){this.pendingLayoutAnchor?.id===e&&(this.pendingLayoutAnchor.id=t)}createFileOptionsPrototype(){let e={};for(let t of If)Hf(e,t,()=>this.options[t]);Hf(e,`stickyHeader`,()=>this.options.stickyHeaders),Hf(e,`collapsed`,e=>{let t=Vf(e);if(t!=null)return this.getItemOptions(t,`file`)?.item.collapsed}),Hf(e,`onEditComplete`,e=>{if(this.options.onItemEditComplete==null)return;let t=Vf(e);if(t!=null)return e=>this.completeFileItemEdit(t,e)});for(let t of Lf)this.defineItemSharedCallback(e,`file`,t);for(let t of Rf)this.defineItemSelectionCallback(e,`file`,t);return e}createDiffOptionsPrototype(){let e={};for(let t of Ff)Hf(e,t,()=>this.options[t]);Hf(e,`stickyHeader`,()=>this.options.stickyHeaders),Hf(e,`hunkSeparators`,()=>this.options.hunkSeparators),Hf(e,`collapsed`,e=>{let t=Vf(e);if(t!=null)return this.getItemOptions(t,`diff`)?.item.collapsed}),Hf(e,`onEditComplete`,e=>{if(this.options.onItemEditComplete==null)return;let t=Vf(e);if(t!=null)return e=>this.completeDiffItemEdit(t,e)});for(let t of Lf)this.defineItemSharedCallback(e,`diff`,t);for(let t of Rf)this.defineItemSelectionCallback(e,`diff`,t);return e}createFileOptions(e){let t=Object.create(this.fileOptionsPrototype);return Bf(t,{id:e}),t}createDiffOptions(e){let t=Object.create(this.diffOptionsPrototype);return Bf(t,{id:e}),t}updateItemOptionsId(e,t){let n=Vf(e);if(n==null)throw Error(`CodeView.updateItemOptionsId: No valid state`);n.id=t}getItemOptions(e,t){let n=this.idToItem.get(e.id);if(n!=null&&n.type===t)return n}defineItemSharedCallback(e,t,n){Hf(e,n,e=>{if(this.options[n]==null)return;let r=Vf(e);if(r==null)return;let i=r.callbackCache??={},a=i[n];return a??(a=((...e)=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=this.options[n];return a?.(...e,i)}),i[n]=a),a})}defineItemSelectionCallback(e,t,n){Hf(e,n,e=>{let r=Vf(e);if(r==null)return;let i=r.callbackCache??={},a=i[n];return a??(a=e=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=e==null?null:{id:i.item.id,range:e};this.options.controlledSelection!==!0&&(e!=null||this.selectedLines?.id===i.item.id)&&this.applySelectedLines(a,{notify:!1}),this.options.onSelectedLinesChange?.(a);let o=this.options[n];return o?.(e,i)},i[n]=a),a})}markLayoutDirtyFromIndex(e){this.layoutDirtyIndex=Math.min(this.layoutDirtyIndex??e,e)}markItemLayoutDirty(e){if(this.items[e.index]!==e)throw Error(`CodeView.markItemLayoutDirty: unknown item id "${e.item.id}"`);this.markLayoutDirtyFromIndex(e.index)}tryAppendItems(e){if(e.length<=this.items.length)return!1;for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null||n.item.id!==r.id||n.type!==r.type)return!1}for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null)throw Error(`CodeView.tryAppendItems: append candidate missing prefix item`);this.syncItemRecord(n,r)&&this.markLayoutDirtyFromIndex(t)}return this.appendItemsInternal(e.slice(this.items.length),!1),this.scrollDirty=!0,this.render(),!0}reconcileItems(e){let{items:t,idToItem:n}=this,r=new Set(t),i=[],a=new Map,o=new Map,s=new Map,c;for(let s=0;s<e.length;s++){let l=e[s];if(l==null)throw Error(`CodeView.reconcileItems: missing input item`);if(a.has(l.id))throw Error(`CodeView.setItems: duplicate id "${l.id}"`);let u=n.get(l.id),d=u!=null&&u.type===l.type?u:this.createItem(l,s,0);d.index=s,u!=null&&u.type===l.type?(r.delete(u),this.syncItemRecord(d,l)&&(c=Math.min(c??s,s))):c=Math.min(c??s,s),t[s]!==d&&(c=Math.min(c??s,s)),i.push(d),a.set(l.id,d),o.set(d.instance,d)}if(c==null){if(r.size===0)return;c=Math.max(i.length-1,0)}this.capturePendingLayoutAnchor(a);for(let e=0;e<t.length;e++){let n=t[e];if(n==null||!r.has(n))continue;s.set(n.item.id,n),this.releaseRenderedItem(n);let a=Math.max(i.length-1,0);c=Math.min(c??a,a)}return this.items=i,this.idToItem=a,this.instanceToItem=o,this.renderState.firstIndex>=i.length?this.resetRenderState():this.renderState.lastIndex>=i.length&&(this.renderState.lastIndex=i.length-1),this.markLayoutDirtyFromIndex(c),this.scrollDirty=!0,this.render(),s.size>0?s:void 0}syncItemRecord(e,t){if(e.type!==t.type)throw Error(`CodeView.syncItemRecord: type mismatch for id "${t.id}"`);return e.version!==t.version&&(e.item=t,e.version=t.version,e.renderedOptionsRevision=-1,!0)}getMaxScrollTopForHeight(e){let{paddingBottom:t,paddingTop:n}=this.getLayout();return Math.max(n+this.header.height+e+this.footer.height+t-this.getHeight(),0)}getMaxScrollTop(){return this.getMaxScrollTopForHeight(this.getScrollHeight())}shouldRebaseScroll(){return this.getMaxScrollTop()>this.scrollRebaseConfig.threshold}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),this.scrollRebaseConfig.containerHeight):this.getScrollHeight()}getMaxPagedScrollTop(){return this.getMaxScrollTopForHeight(this.getPagedScrollHeight())}clampPagedScrollTop(e){let t=this.getMaxPagedScrollTop();return Math.max(0,Math.min(e,t))}clampScrollTop(e){let t=this.getMaxScrollTop();return Math.max(0,Math.min(e,t))}getMaxScrollPageOffset(){return Math.max(this.getMaxScrollTop()-this.getMaxPagedScrollTop(),0)}clampScrollPageOffset(e){let t=this.getMaxScrollPageOffset();return Math.max(0,Math.min(e,t))}resolveScrollPageWindow(e,t){let n=vu(this.clampPagedScrollTop(t)),r=this.clampScrollPageOffset(e-n);return n=vu(this.clampPagedScrollTop(e-r)),r=this.clampScrollPageOffset(e-n),{pagedScrollTop:n,scrollPageOffset:r}}resolvePagedScrollPosition(e){if(!this.shouldRebaseScroll())return{pagedScrollTop:this.clampPagedScrollTop(e),scrollPageOffset:0};let{scrollPageOffset:t,scrollRebaseConfig:n}=this,r=this.clampScrollPageOffset(t),i=e-r,a=this.getMaxPagedScrollTop(),o=this.getMaxScrollPageOffset(),s=i>n.threshold&&r<o,c=i<n.triggerTop&&r>0;return i<0||i>a||s||c?this.resolveScrollPageWindow(e,c?Math.min(n.targetBottom,a):n.targetTop):{pagedScrollTop:vu(this.clampPagedScrollTop(i)),scrollPageOffset:r}}needsScrollPageUpdate(e){let t=vu(this.clampScrollTop(e)),{scrollPageOffset:n}=this.resolvePagedScrollPosition(t);return n!==this.scrollPageOffset}getPagedLayoutTop(e){return this.shouldRebaseScroll()?Math.max(e-this.scrollPageOffset,0):e}getStickyHeaderOffset(){return this.options.stickyHeaders===!0&&this.options.disableFileHeader!==!0?this.itemMetricsCache.diffHeaderHeight:0}getScrollTargetRect(e){let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return{top:t.top,height:t.height};if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${rp(e.range)} for item "${e.id}"`);return}return{top:t.top+n.top,height:n.height}}let n=this.getLineScrollPosition(t,e);if(n==null)console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);else return{top:t.top+n.top,height:n.height}}normalizeScrollTarget(e){if(e.type===`position`||e.align!==`nearest`)return e;let t=this.getScrollTargetRect(e);if(t==null)return;let n=e.offset??0,r=this.getItemTopOffset()+t.top,i=r+t.height,a=this.getScrollTop(),o=a+(e.type===`line`||e.type===`range`?this.getStickyHeaderOffset():0),s=a+this.getHeight();if(!(r-n<=o&&i+n>=s)){if(r-n<o)return{...e,align:`start`};if(i+n>s)return{...e,align:`end`}}}resolveScrollTargetTop(e){if(e.type===`position`){let t=this.clampScrollTop(e.position);return t===e.position?this.clampScrollTop(e.position-this.getStickyHeaderOffset()):t}let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top,t.height,e.align,e.offset));if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${rp(e.range)} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}let n=this.getLineScrollPosition(t,e);if(n==null)console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);else return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}resolveAlignedScrollPosition(e,t,n,r=0,i=0){e+=this.getItemTopOffset();let a=this.getHeight();return n===`center`&&t+r<a?e-(a-t)/2+r:n===`end`?e-(a-t)+r:e-i-r}getLineScrollPosition(e,t){return e.type===`diff`?e.instance.getLinePosition(t.lineNumber,t.side):e.instance.getLinePosition(t.lineNumber)}getRangeScrollPosition(e,t){let{range:n}=t,r=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.start,side:n.side}),i=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.end,side:n.endSide??n.side});if(r==null||i==null)return;let a=r.top,o=a+r.height,s=i.top,c=s+i.height,l=Math.min(a,s);return{top:l,height:Math.max(o,c)-l}}computeTargetScrollTopForFrame(e,t){if(this.pendingScrollTarget==null)return e;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null)return e;let{scrollAnimation:r}=this;return r==null?n:this.computeSpringStep(r,n,t).position}computeSpringStep(e,t,n){let r=Math.max(0,n-e.lastTimestamp),{omega:i}=this.getSmoothScrollSettings(),a=Math.exp(-i*r),o=e.position-t,s=e.velocity+i*o;return{position:t+(o+s*r)*a,velocity:(s*(1-i*r)-i*o)*a}}advanceScrollAnimation(e,t){if(this.pendingScrollTarget==null)return;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null){this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;return}let r=this.scrollAnimation;if(r==null)return n;r.position+=t;let{position:i,velocity:a}=this.computeSpringStep(r,n,e);r.lastTimestamp=e,r.position=i,r.velocity=a;let{positionEpsilon:o,velocityEpsilon:s}=this.getSmoothScrollSettings();return Math.abs(n-i)<=o&&Math.abs(a)<=s?(r.position=n,r.velocity=0,this.scrollAnimation=void 0,n):r.position}computeRenderRangeAndEmit=(t=performance.now())=>{if(e.__STOP||this.container==null||!this.isReady())return;let n=this.getHeight(),r=this.getScrollTop(),i=this.pendingScrollTarget!=null,a=r,o=this.pendingLayoutAnchor!=null,s=this.getScrollAnchor(a);if(this.layoutDirtyIndex!=null&&(this.recomputeLayout(this.layoutDirtyIndex,this.pendingLayoutReset),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,o=!0),o&&s!=null){let e=this.resolveAnchoredScrollTop(s);if(e!=null){let t=e-a;a=e,this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}}o&&(a=this.clampScrollTop(a),this.syncContainerHeight());let c=this.computeTargetScrollTopForFrame(a,t),l=!o&&(this.renderState.scrollTop===-1||Math.abs(c-this.renderState.scrollTop)>n+this.config.overscrollSize*2);l&&(s=void 0),this.windowSpecs=Bs({scrollTop:c-this.header.height,height:n,scrollHeight:this.getScrollHeight(),fitPerfectly:l,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let u=r;(this.pendingScrollTarget!=null&&c!==u||this.needsScrollPageUpdate(c))&&(this.applyScrollFix(c,u,this.windowSpecs),u=c);let{top:d,bottom:f}=this.windowSpecs,{firstIndex:p,lastIndex:m}=this.renderState;if(p>=0)for(let e=p;e<=m;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${e}`);t.top>d-t.height&&t.top<=f||this.releaseRenderedItem(t)}let h=this.reconcileHeaderFooterHosts(),g,_=new Set,v=this.findFirstVisibleIndex(d),y=this.findLastVisibleIndex(f);for(let e=v;e<=y;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: missing item`);let{instance:n}=t;t.element==null?(t.element=this.acquireElement(),op(this.stickyContainer,t.element,g),n.virtualizedSetup(),ap(t,t.element)&&(t.renderedOptionsRevision=this.renderOptionsRevision,_.add(t)),g=t.element):(op(this.stickyContainer,t.element,g),ap(t,void 0,t.renderedOptionsRevision!==this.renderOptionsRevision)&&(t.renderedOptionsRevision=this.renderOptionsRevision,_.add(t)),g=t.element),t.item.edit===!0&&this.attachItemEditor(t)}this.renderState.firstIndex=v<=y?v:-1,this.renderState.lastIndex=y,this.flushSlotCoordinator(),this.flushManagers(_),h&&this.measureMountedHosts(),this.reconcileRenderedItems(_),this.syncContainerHeight(),this.updateStickyPositioning();let b=s==null?void 0:this.resolveAnchoredScrollTop(s);s===this.pendingLayoutAnchor&&(this.pendingLayoutAnchor=void 0);let x=b==null?0:b-a,S=c,C=!1;if(this.pendingScrollTarget!=null){let e=this.advanceScrollAnimation(t,x);e==null?S=a:(S=e,C=!0)}else S=b??c;S!==u&&(this.applyScrollFix(S,u,this.windowSpecs),u=S),C&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),this.renderState.scrollTop=vu(u),this.updateStickyPositioning(),i&&(this.headerResizeAnchor=void 0,this.getScrollAnchor(u)),this.validateStickyContainerHeight(),this.fixContainerFocus(),(l||this.scrollAnimation!=null)&&this.render()};flushManagers(e){for(let t of e)t.instance.flushManagers()}syncContainerHeight(){let e=this.getPagedScrollHeight();this.container!=null&&this.containerHeight!==e&&(this.container.style.height=`${e}px`,this.containerHeight=e)}getStickyBounds(e){let{firstIndex:t,lastIndex:n}=e==null?this.renderState:{firstIndex:this.findFirstVisibleIndex(e.top),lastIndex:this.findLastVisibleIndex(e.bottom)};if(t===-1||n===-1||t>n)return;let r=this.items[t]?.instance.getAdvancedStickySpecs(e),i=this.items[n]?.instance.getAdvancedStickySpecs(e);if(r!=null&&i!=null)return{stickyTop:this.getPagedLayoutTop(Math.max(r.topOffset,0)),stickyBottom:this.getPagedLayoutTop(i.topOffset+i.height)}}applyStickyPositioning({stickyTop:e,stickyBottom:t}){let n=this.getHeight(),{itemMetricsCache:r}=this,i=t-e;this.renderState.stickyHeight=i,this.renderState.stickyTop=e,this.renderState.stickyBottom=t,this.stickyOffset.style.height=`${e}px`;let a=(Math.random()*r.lineHeight|0)*-1,o=-Math.max(i+a,0)+n;this.stickyContainer.style.top=`${o}px`,this.stickyContainer.style.bottom=`${o+r.diffHeaderHeight}px`}syncPagedScrollScaffolding(e){this.syncContainerHeight();let t=this.getStickyBounds(e);t==null?this.stickyOffset.style.height=`${this.getPagedLayoutTop(e.top)}px`:this.applyStickyPositioning(t)}reconcileRenderedItems(e){let{firstIndex:t,lastIndex:n}=this.renderState;if(t===-1)return;let r=-1,i=!1;for(let a=t;a<this.items.length&&!(!i&&a>n);a++){let t=this.items[a];if(t==null)throw Error(`CodeView.reconcileRenderedItems: Invalid item`);r===-1?r=t.top:t.top!==r&&(t.top=r,t.instance.syncVirtualizedTop(),i=!0),(e==null?a<=n:e.has(t))&&(t.instance.reconcileHeights()&&(i=!0,t.height=t.instance.getVirtualizedHeight()),this.validateRenderedItemHeight(t)),r+=t.instance.getVirtualizedHeight(),a<this.items.length-1&&(r+=this.getLayout().gap)}i&&r!=null&&(this.scrollDirty=!0,this.scrollHeight=r)}updateStickyPositioning(){let e=this.getStickyBounds();if(e==null){this.renderState.firstIndex===-1&&(this.stickyOffset.style.height=``);return}let{stickyTop:t,stickyBottom:n}=e;(n-t!==this.renderState.stickyHeight||t!==this.renderState.stickyTop||n!==this.renderState.stickyBottom)&&this.applyStickyPositioning(e)}handleScroll=()=>{e.__STOP||(this.suspendScrollInteractions(),this.scrollDirty=!0,this.notifyScroll(),this.render())};clearPendingScroll=()=>{this.headerResizeAnchor=void 0,this.pendingScrollTarget=void 0,this.pendingLayoutAnchor=void 0,this.scrollAnimation=void 0};handleResize=e=>{let t=!1;for(let n of e)if(n.target===this.stickyContainer){let e=n.borderBoxSize[0].blockSize;if(Math.abs(e-this.renderState.stickyHeight)>=Wf){let e=this.getScrollTop(),n=this.getScrollAnchor(e);this.reconcileRenderedItems(),this.updateStickyPositioning();let r=n==null?void 0:this.resolveAnchoredScrollTop(n);if(r!=null){let t=r-e;this.applyScrollFix(r,e,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),t=!0}}else if(n.target===this.header.element||n.target===this.footer.element){let e=n.target===this.header.element?this.header:this.footer,r=n.borderBoxSize[0].blockSize;if(r!==e.height){let n=this.getScrollTop(),i=this.getScrollAnchor(n);this.setHostHeight(e,r);let a=i==null?void 0:this.resolveAnchoredScrollTop(i);if(a!=null){let e=a-n;this.applyScrollFix(a,n,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=e)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),t=!0}}else this.scrollDirty=!0,this.heightDirty=!0,t=!0;t&&this.render(!0)};getScrollAnchorViewportTop(e,t){return e<t?t+this.getStickyHeaderOffset():t}getScrollAnchor(e,t=this.idToItem){let n=this.header.element!=null&&this.header.element.getBoundingClientRect().height!==this.header.height,r=e=>(n||(this.headerResizeAnchor=e==null?void 0:{anchor:e,item:this.idToItem.get(e.id)}),e),i,{pendingLayoutAnchor:a}=this;if(a!=null){let e=this.idToItem.get(a.id);if(e!=null&&t.get(a.id)===e)return r(a);e!=null&&(i=e)}let o=this.headerResizeAnchor;if(n&&this.pendingScrollTarget==null&&o!=null&&this.idToItem.get(o.anchor.id)===o.item&&t.get(o.anchor.id)===o.item)return o.anchor;if(e<=0)return r(void 0);let{firstIndex:s,lastIndex:c,stickyTop:l,stickyBottom:u}=this.renderState;if(s===-1||c===-1)return;let d=this.getHeight();if(l!==-1&&u!==-1){for(let n=s;n<=c;n++){let a=this.items[n];if(a==null)continue;let o=this.getItemTopOffset()+a.top;if(o+a.height<=e)continue;if(o>=e+d)break;if(t.get(a.item.id)!==a){i??=a;continue}if(o>=e)return r({type:`item`,id:a.item.id,viewportOffset:o-e});let s=this.getScrollAnchorViewportTop(o,e)-o,c=a.instance.getNumericScrollAnchor(s);if(c!=null){let t=o+c.top;return r({type:`line`,id:a.item.id,lineNumber:c.lineNumber,side:c.side,viewportOffset:t-e})}}if(i!=null)for(let e=i.index+1;e<this.items.length;e++){let n=this.items[e];if(n!=null&&t.get(n.item.id)===n)return r({type:`item`,id:n.item.id,viewportOffset:0})}return r(void 0)}}resolveAnchoredScrollTop(e){let t=this.idToItem.get(e.id);if(t==null)return;let n=this.getItemTopOffset();if(e.type===`item`){let r=n+t.top;return this.clampScrollTop(r-e.viewportOffset)}let r=t.type===`diff`?t.instance.getLinePosition(e.lineNumber,e.side):t.instance.getLinePosition(e.lineNumber);if(r==null)return;let i=n+t.top+r.top;return this.clampScrollTop(i-e.viewportOffset)}applyScrollFix(e,t,n){if(this.root==null)return;let r=vu(this.clampScrollTop(e)),i=vu(t),{scrollPageOffset:a}=this,o=vu(this.clampPagedScrollTop(i-a)),{pagedScrollTop:s,scrollPageOffset:c}=this.resolvePagedScrollPosition(r),l=s,u=a!==c;(r!==this.renderState.scrollTop||r!==i||l!==o||u)&&(this.suspendScrollInteractions(),(l!==o||u)&&(this.scrollPageOffset=c,this.syncPagedScrollScaffolding(n)),l!==o&&this.root.scrollTo({top:l,behavior:`instant`}),this.renderState.scrollTop=r,this.scrollTop=r,this.scrollDirty=!1)}isPendingTargetSettled(e){let t=this.resolveScrollTargetTop(e);return t==null||vu(this.getScrollTop())===vu(t)}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root?.scrollTop??0;return this.scrollTop=this.clampScrollTop(e+this.scrollPageOffset),this.scrollTop}getHeight(){return this.heightDirty&&(this.heightDirty=!1,this.height=this.root?.getBoundingClientRect().height??0),this.height}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;let e=this.buildSlotSnapshot(this.slotCoordinator);(this.slotSnapshotStale||!mu(this.slotSnapshot,e))&&(this.slotSnapshotStale=!1,this.slotSnapshot=e,this.slotCoordinator.onSnapshotChange(e))}notifyScroll(){if(this.scrollListeners.size===0)return;let e=this.getScrollTop();for(let t of this.scrollListeners)t(e,this)}findFirstVisibleIndex(e){let t=0,n=this.items.length-1,r=this.items.length;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findFirstVisibleIndex: invalid item index`);a.top+a.height>e?(r=i,n=i-1):t=i+1}return r}findLastVisibleIndex(e){let t=0,n=this.items.length-1,r=-1;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findLastVisibleIndex: invalid item index`);a.top<=e?(r=i,t=i+1):n=i-1}return r}recomputeLayout(e=0,t){if(this.items.length===0){this.scrollHeight=0;return}let n=this.getLayout(),r=0;if(e>0){let t=this.items[e-1];if(t==null)throw Error(`CodeView.recomputeLayout: invalid dirty index`);r=t.top+t.height+n.gap}for(let i=e;i<this.items.length;i++){let e=this.items[i];if(e==null)throw Error(`CodeView.recomputeLayout: invalid item index`);e.top=r,e.height=e.type===`diff`?e.instance.updateCodeViewLayout(e.item.fileDiff,r,t,e.item.annotations??[]):e.instance.updateCodeViewLayout(e.item.file,r,t,e.item.annotations??[]),r+=e.height,i<this.items.length-1&&(r+=n.gap)}r!==this.scrollHeight&&(this.scrollDirty=!0),this.scrollHeight=r}resetRenderState(){this.renderState.scrollTop=-1,this.renderState.firstIndex=-1,this.renderState.lastIndex=-1,this.renderState.stickyHeight=0,this.renderState.stickyTop=-1,this.renderState.stickyBottom=-1}getFitPerfectlyOverscroll(){return this.getLayout().gap+this.itemMetricsCache.diffHeaderHeight}};function Qf(e){return e.instance.cleanUp(!0),e.type===`diff`?e.instance.updateCodeViewLayout(e.item.fileDiff,e.top,void 0,e.item.annotations??[]):e.instance.updateCodeViewLayout(e.item.file,e.top,void 0,e.item.annotations??[])}function $f(e,t){return!no(e.theme??bo,t.theme??bo)||(e.themeType??`system`)!==(t.themeType??`system`)||e.unsafeCSS!==t.unsafeCSS}function ep(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS||(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function tp(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function np(e){return e instanceof SVGElement||ba(e)&&(e.hasAttribute(`data-core-css`)||e.hasAttribute(`data-theme-css`)||e.hasAttribute(`data-unsafe-css`))}function rp(e){let t=ip(e.start,e.side),n=ip(e.end,e.endSide??e.side);return t===n?t:`${t}-${n}`}function ip(e,t){return t==null?`${e}`:`${t===`deletions`?`D`:`A`}${e}`}function ap(e,t,n=!1){return e.type===`diff`?e.instance.render({deferManagers:!0,fileContainer:t,fileDiff:e.item.fileDiff,forceRender:n,lineAnnotations:e.item.annotations??[]}):e.instance.render({deferManagers:!0,fileContainer:t,file:e.item.file,forceRender:n,lineAnnotations:e.item.annotations??[]})}function op(e,t,n){n==null?e.firstChild!==t&&e.prepend(t):n.nextSibling!==t&&n.after(t)}function sp(e){return(e.item.annotations?.length??0)>0||pu(e).lineAnnotations.length>0}function cp(e,{hasHeaderRenderers:t,hasAnnotationRenderer:n,hasGutterRenderer:r}){if(e.length===0)return;if(t||r)return e;if(!n)return;let i=[];for(let t of e)sp(t)&&i.push(t);return i.length>0?i:void 0}function lp(e,t){typeof e==`function`?e(t):e!=null&&(e.current=t)}var up=typeof window>`u`?Q.useEffect:Q.useLayoutEffect;function dp(e){return{instance:void 0,items:void 0,controlled:e,managedOptions:void 0,disableFlushSync:!1,slotCoordinator:void 0}}function fp(e,t){let{className:n,containerRef:r,disableWorkerPool:i=!1,editorOptions:a,getEditStateKey:o,initialItems:s,items:c,onItemEditChange:l,onItemEditComplete:u,onScroll:d,onSelectedLinesChange:f,options:p,renderAnnotation:m,renderCodeViewFooter:h,renderCodeViewHeader:g,renderCustomHeader:_,renderGutterUtility:v,renderHeaderFilenameSuffix:y,renderHeaderMetadata:b,renderHeaderPrefix:x,selectedLines:S,style:C}=e,w=c!==void 0,T=mi(),E=(0,Q.useContext)(zr),D=(0,Q.useRef)(dp(w)),O=_!=null,k=m!=null,A=v!=null,j=O||x!=null||y!=null||b!=null,M=j||k||A,N=g!=null,P=h!=null,F=Li(e=>{f?.(e)}),I=S!==void 0,L=Li((e,t,n)=>{if(T==null)throw Error(`CodeView: EditContext is not attached`);let r={...a,...t};return T(e,r,n)}),R=Li((e,t)=>{l?.(e,t)}),z=Li((e,t,n)=>u?.(e,t,n)??`reject`),B=(0,Q.useMemo)(()=>vp({options:p,hasCustomHeader:O,hasGutterRenderer:A,hasCodeViewHeader:N,hasCodeViewFooter:P,onSelectedLinesChange:f==null?void 0:F,controlledSelection:I,getEditStateKey:o,createEditor:T==null?void 0:L,onItemEditChange:l==null?void 0:R,onItemEditComplete:u==null?void 0:z}),[T,I,L,R,z,F,P,N,O,A,o,l,u,f,p]),[V]=(0,Q.useState)(()=>_p()),[,H]=(0,Q.useState)({}),U=Li(e=>{D.current.instance!=null&&(e==null||e!==D.current.instance.getContainerElement())&&(D.current.instance.cleanUp(),V.publish(void 0),D.current=dp(w)),e!=null&&e!==D.current.instance?.getContainerElement()&&(D.current.instance=new Zf(B,i?void 0:E,!0),D.current.instance.setup(e)),lp(r,e)}),W=Li(e=>{D.current.disableFlushSync?V.publish(e):(0,iu.flushSync)(()=>{V.publish(e)})}),G=(0,Q.useMemo)(()=>{if(j||k||A||N||P)return{hasHeaderRenderers:j,hasAnnotationRenderer:k,hasGutterRenderer:A,onSnapshotChange:W}},[W,k,A,j,N,P]);return up(()=>d==null?void 0:D.current.instance?.subscribeToScroll(d)),up(()=>{let{instance:e,controlled:t,items:n,managedOptions:r,slotCoordinator:i}=D.current;if(e!=null)try{D.current.disableFlushSync=!0;let a=!1;if(ds(B,r)||(D.current.managedOptions=B,e.setOptions(B),a=!0),t!==w){console.error(`CodeView: cannot switch between controlled and uncontrolled modes. Remount with a new key instead.`);return}if(w)c!==n&&(hp(n,c)?D.current.items=c:mp(n,c)?(D.current.items=c,e.addItems(c.slice(n.length))):(D.current.items=c,e.setItems(c),a=!0));else if(n==null){let t=s??[];D.current.items=t,t.length>0&&(e.setItems(t),a=!0)}S!==void 0&&e.setSelectedLines(S,{notify:!1});let o=e.setSlotCoordinator(G),l=!1;G!==i&&((G==null||i==null)&&(l=!0),D.current.slotCoordinator=G),(a||o)&&e.render(!0),o&&G==null&&V.publish(void 0),l&&H({})}finally{D.current.disableFlushSync=!1}}),(0,Q.useImperativeHandle)(t,()=>({addItems(e){let{controlled:t,instance:n}=D.current;gp(t,`addItems`),n==null?console.error(`CodeView.addItems: no valid instance to append items with`,e):n.addItems(e)},getItem(e){let{instance:t}=D.current;if(t==null)console.error(`CodeView.getItem: no valid instance exists`,e);else return t.getItem(e)},removeItem(e){let{controlled:t,instance:n}=D.current;return gp(t,`removeItem`),n==null?(console.error(`CodeView.removeItem: no valid instance to remove item from`,e),!1):n.removeItem(e)},updateItem(e){let{controlled:t,instance:n}=D.current;return gp(t,`updateItem`),n==null?(console.error(`CodeView.updateItem: no valid instance to update item with`,e),!1):n.updateItem(e)},updateItemId(e,t){let{controlled:n,instance:r}=D.current;return gp(n,`updateItemId`),r==null?(console.error(`CodeView.updateItemId: no valid instance to update item id with`,e,t),!1):r.updateItemId(e,t)},scrollTo(e){let{instance:t}=D.current;t==null?console.error(`CodeView.scrollTo: no valid instance to scroll with`,e):t.scrollTo(e)},setSelectedLines(e){let{instance:t}=D.current;t==null?console.error(`CodeView.setSelectedLines: no valid instance to update selection with`,e):(t.setSelectedLines(e,{notify:!1}),F(e))},getSelectedLines(){let{instance:e}=D.current;return e==null?(console.error(`CodeView.getSelectedLines: no valid instance exists`),null):e.getSelectedLines()},clearSelectedLines(){let{instance:e}=D.current;e==null?console.error(`CodeView.clearSelectedLines: no valid instance to update selection with`):(e.clearSelectedLines({notify:!1}),F(null))},getEditor(e){let{instance:t}=D.current;if(t==null)console.error(`CodeView.getEditor: no valid instance exists`,e);else return t.getEditor(e)},getInstance(){return D.current.instance}}),[F]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{ref:U,className:n,style:C}),(M||N||P)&&(0,Z.jsx)(yp,{managedContentStore:V,renderCustomHeader:_,renderHeaderPrefix:x,renderHeaderFilenameSuffix:y,renderHeaderMetadata:b,renderAnnotation:m,renderGutterUtility:v,renderCodeViewHeader:g,renderCodeViewFooter:h})]})}var pp=(0,Q.forwardRef)(fp);function mp(e,t){if(e==null||t.length<=e.length)return!1;if(e.length===0)return!0;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return!1;return!0}function hp(e,t){if(e==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function gp(e,t){if(e)throw Error(`CodeView.${t} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`)}function _p(){let e,t=new Set;return{getSnapshot(){return e},publish(n){if(e!==n){e=n;for(let e of t)e()}},subscribe(e){return t.add(e),()=>{t.delete(e)}}}}function vp({options:e,hasCustomHeader:t,hasGutterRenderer:n,hasCodeViewHeader:r,hasCodeViewFooter:i,onSelectedLinesChange:a,controlledSelection:o,getEditStateKey:s,createEditor:c,onItemEditChange:l,onItemEditComplete:u}){let d={...e,controlledSelection:o,onSelectedLinesChange:a,createEditor:c};return s!=null&&(d.getEditStateKey=s),l!=null&&(d.onItemEditChange=l),u!=null&&(d.onItemEditComplete=u),t&&(d.renderCustomHeader=Sp),n&&(d.renderGutterUtility=Sp),r&&(d.renderCodeViewHeader=Sp),i&&(d.renderCodeViewFooter=Sp),d}var yp=(0,Q.memo)(function({managedContentStore:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o,renderCodeViewHeader:s,renderCodeViewFooter:c}){"use no memo";let l=Li(t=>e.subscribe(t)),u=Li(()=>e.getSnapshot()),d=(0,Q.useSyncExternalStore)(l,u,u),f=(0,Q.useMemo)(()=>{let e={renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o};return d?.items?.map(t=>(0,iu.createPortal)(t.type===`diff`?(0,Z.jsx)(bp,{version:t.version??0,item:t.item,getHoveredLine:t.instance.getHoveredLine,getAnnotationSlotName:t.instance.getAnnotationSlotName,...pu(t),...e}):(0,Z.jsx)(xp,{version:t.version??0,item:t.item,getHoveredLine:t.instance.getHoveredLine,getAnnotationSlotName:t.instance.getAnnotationSlotName,...pu(t),...e}),t.element,t.id))},[t,n,r,i,a,o,d?.items]),p=(0,Q.useMemo)(()=>s!=null&&d?.header!=null?(0,iu.createPortal)(s(),d.header):null,[s,d?.header]),m=(0,Q.useMemo)(()=>c!=null&&d?.footer!=null?(0,iu.createPortal)(c(),d.footer):null,[c,d?.footer]);return(0,Z.jsxs)(Z.Fragment,{children:[f,p,m]})}),bp=(0,Q.memo)(function({item:e,fileDiff:t,lineAnnotations:n,getHoveredLine:r,getAnnotationSlotName:i,renderCustomHeader:a,renderHeaderPrefix:o,renderHeaderFilenameSuffix:s,renderHeaderMetadata:c,renderAnnotation:l,renderGutterUtility:u}){return du({fileDiff:t,renderCustomHeader:a==null?void 0:()=>a(e),renderHeaderPrefix:o==null?void 0:()=>o(e),renderHeaderFilenameSuffix:s==null?void 0:()=>s(e),renderHeaderMetadata:c==null?void 0:()=>c(e),renderAnnotation:l==null?void 0:(t,n)=>l(t,n,e),lineAnnotations:n,renderGutterUtility:u==null?void 0:t=>u(t,e),getHoveredLine:r,getAnnotationSlotName:i})}),xp=(0,Q.memo)(function({item:e,file:t,lineAnnotations:n,getHoveredLine:r,getAnnotationSlotName:i,renderCustomHeader:a,renderHeaderPrefix:o,renderHeaderFilenameSuffix:s,renderHeaderMetadata:c,renderAnnotation:l,renderGutterUtility:u}){return Xi({file:t,renderCustomHeader:a==null?void 0:()=>a(e),renderHeaderPrefix:o==null?void 0:()=>o(e),renderHeaderFilenameSuffix:s==null?void 0:()=>s(e),renderHeaderMetadata:c==null?void 0:()=>c(e),renderAnnotation:l==null?void 0:(t,n)=>l(t,n,e),lineAnnotations:n,renderGutterUtility:u==null?void 0:t=>u(t,e),getHoveredLine:r,getAnnotationSlotName:i})});function Sp(){}var $=Ue();function Cp(e){let t=(0,$.c)(4),{children:n}=e,r,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={poolSize:4,workerFactory:wp},i={theme:ms,preferredHighlighter:Mo},t[0]=r,t[1]=i):(r=t[0],i=t[1]);let a;return t[2]===n?a=t[3]:(a=(0,Z.jsx)(_a,{poolOptions:r,highlighterOptions:i,children:n}),t[2]=n,t[3]=a),a}function wp(){return new Worker(new URL(`/assets/worker-CcC2iNVI.js`,``+import.meta.url),{type:`module`})}var Tp={added:`Added`,modified:`Modified`,deleted:`Deleted`,renamed:`Renamed`,"type-changed":`Type changed`};function Ep(e,t){if(e.status===`renamed`&&e.previousPath!==null&&e.previousPath!==void 0)return`Renamed from ${e.previousPath}`;let n=Tp[e.status];return e.path===t?n:`${n} as ${e.path}`}function Dp(e){return e.body===null||e.body===void 0?e.subject:`${e.subject}\n\n${e.body}`}function Op(e){return[...new Set([e.oldPath,e.newPath].filter(e=>e!=null))]}function kp(e){return e.newPath??e.oldPath??`Unknown path`}var Ap=7;function jp(e){return e.slice(0,Ap)}function Mp(e){return e.replace(/^refs\/(?:heads|remotes|tags)\//u,``)}function Np(e){return e.filter(e=>e.kind!==`head`)}function Pp(e,t){return e.kind===`local-branch`&&`refs/heads/${e.name}`===t}function Fp(e){switch(e?.head.kind){case`attached`:return Mp(e.head.ref);case`unborn`:return`No commits yet on ${Mp(e.head.ref)}`;case`detached`:return`Detached HEAD`;default:return`This branch`}}function Ip(e){return e===`shallow`?`Shallow clone: older history is not available.`:e===`wide`?`Too many branches meet here to continue past this point.`:`Start of history.`}function Lp(e,t){return e==null?{name:Fp(t),counts:null,upstream:`Branch status unavailable`}:e.name?e.upstream?{name:e.name,counts:`${e.ahead} ahead · ${e.behind} behind`,upstream:`against ${e.upstream}`}:{name:e.name,counts:null,upstream:`No upstream`}:{name:`Detached HEAD`,counts:null,upstream:`No branch checked out`}}var Rp={kind:`handoff`},zp={kind:`all-changes`},Bp={kind:`specs`},Vp={kind:`branch`},Hp={kind:`graph`};function Up(e){switch(e.kind){case`handoff`:return`handoff`;case`walkthrough`:return`walkthrough`;case`all-changes`:return`all-changes`;case`walkthrough-changes`:return`walkthrough-changes`;case`specs`:return`specs`;case`change`:return`change:${e.path}`;case`file`:return`file:${e.path}`;case`commit`:return`commit:${e.oid}`;case`pull-request`:return`pull-request:${e.projectId}:${e.number}${e.environmentId?`:environment=${encodeURIComponent(e.environmentId)}`:``}`;case`branch`:return`branch`;case`branch-file`:return`branch:${e.path}`;case`graph`:return`graph`;case`timeline`:return`timeline:${e.path}`;case`walkthrough-step`:return`walkthrough-step:${e.step}`}}function Wp(e){if(e==null||e===``)return null;if(e===`handoff`)return Rp;if(e===`walkthrough`)return{kind:`walkthrough`};if(e===`all-changes`)return zp;if(e===`walkthrough-changes`)return{kind:`walkthrough-changes`};if(e===`specs`)return Bp;if(e===`branch`)return Vp;if(e===`graph`)return Hp;let t=e.indexOf(`:`);if(t<=0)return null;let n=e.slice(0,t),r=e.slice(t+1);if(r===``)return null;switch(n){case`change`:case`file`:case`timeline`:return{kind:n,path:r};case`branch`:return{kind:`branch-file`,path:r};case`walkthrough-step`:return/^[1-9][0-9]*$/.test(r)&&Number.isSafeInteger(Number(r))?{kind:n,step:Number(r)}:null;case`commit`:return/^[0-9a-f]{4,64}$/.test(r)?{kind:n,oid:r}:null;case`pull-request`:{let[e,t,i,a]=r.split(`:`);return e!==void 0&&e.length>0&&t!==void 0&&a===void 0&&(i===void 0||/^environment=[a-zA-Z0-9_-]+$/.test(i))&&/^[1-9][0-9]*$/.test(t)&&Number.isSafeInteger(Number(t))?{kind:n,projectId:e,number:Number(t),...i?{environmentId:i.slice(12)}:{}}:null}default:return null}}function Gp(e,t,n){if(e.includes(t))return[...e];let r=n==null?-1:e.indexOf(n),i=[...e];return i.splice(r===-1?i.length:r+1,0,t),i}var Kp={changes:`Changes`,files:`Files`,history:`History`};function qp(e){switch(e.kind){case`handoff`:return`Changes`;case`walkthrough`:return`Walkthrough`;case`all-changes`:case`walkthrough-changes`:return`All changes`;case`specs`:return`Specs`;case`branch`:return`Branch changes`;case`graph`:return`Commit graph`;case`commit`:return jp(e.oid);case`pull-request`:return`PR #${e.number}`;case`change`:case`file`:case`branch-file`:return e.path.split(`/`).at(-1)??e.path;case`timeline`:return`Timeline of ${e.path.split(`/`).at(-1)??e.path}`;case`walkthrough-step`:return`Step ${e.step}`}}function Jp(e){let t=Wp(e.entry),n=(e.firstDocument!==void 0&&(!t||t.kind===`walkthrough`)?e.firstDocument:void 0)??(t?qp(t):Kp[e.surface??`files`]),r=e.project?`${n} — ${e.project}`:n;return e.environment?`${r} · ${e.environment}`:r}function Yp(e,t){let n=(0,$.c)(9),r;n[0]!==t.connection||n[1]!==e?(r=_n({connection:t.connection,scope:e}),n[0]=t.connection,n[1]=e,n[2]=r):r=n[2];let i;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(i={mode:`promiseExit`},n[3]=i):i=n[3];let[a,o]=L(r,i),s;n[4]===o?s=n[5]:(s=e=>{o(e)},n[4]=o,n[5]=s);let c;return n[6]!==a||n[7]!==s?(c={result:a,dismiss:s},n[6]=a,n[7]=s,n[8]=c):c=n[8],c}function Xp(e){let t=new Map;for(let n of e){let e=n.id.split(`:`)[0]||n.id,r=t.get(e)??[];r.push(n),t.set(e,r)}return[...t.entries()]}function Zp(e,t){let n=e?.filter(e=>!e.id.endsWith(`:default`));return n?.find(e=>e.id===t)?.id??n?.find(e=>/^codex:(?:.*-)?luna(?:-|$)/.test(e.id))?.id??n?.find(e=>e.id===`claude:haiku`)?.id??n?.find(e=>e.id===`claude:sonnet`)?.id}function Qp(e){return e.split(`/`).at(-1)??e}function $p(e,t){let{message:n,stashOid:r,option:i}=t;return e===`stash-create`?{action:e,message:n,includeUntracked:i}:{action:e,stashOid:r,restoreIndex:i}}function em(e,t,n){return{mode:e===`amend`?`amend`:`single`,message:e===`commit`?t:``,amendMessage:e===`amend`?t:n,excluded:new Set,added:new Set,groups:null}}function tm(e,t,n=new Set){return t.some(t=>!n.has(t.path)&&e.files?.find(e=>e.path===t.path)?.fingerprint!==t.fingerprint)}var nm=[{id:`commit`,label:`Commit…`,description:`Commit selected files`},{id:`amend`,label:`Amend last commit…`,description:`Replace the latest commit`},{id:`push`,label:`Push`,description:`Send committed changes`},{id:`pull`,label:`Pull`,description:`Bring in upstream changes`},{id:`fetch`,label:`Fetch`,description:`Update a remote-tracking branch`},{id:`stash-create`,label:`Stash changes`,description:`Set aside local changes`},{id:`stash-apply`,label:`Apply stash`,description:`Restore a stash and keep it`},{id:`stash-pop`,label:`Pop stash`,description:`Restore, then remove a stash`}],rm=[{id:`commit`,actions:[nm[0],nm[1]]},{id:`sync`,actions:[nm[2],nm[3],nm[4]]},{id:`stash`,actions:[nm[5],nm[7]]}];function im(e){return nm.find(t=>t.id===e)?.label}function am(e,t,n){return e===`pull`&&n?n:je(e,t)}function om(e){let t=(0,$.c)(17),{scope:n,context:r}=e,{connection:i}=r,a=Pt(xt(sa(n,i))),o=Yp(n,r),s=a?.interrupted;if(!s)return null;let c=s.action.replaceAll(`-`,` `),l;t[0]===c?l=t[1]:(l=(0,Z.jsxs)(`p`,{className:`font-medium`,children:[`A Git action was interrupted:`,` `,c]}),t[0]=c,t[1]=l);let u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`Check the current changes before trying again.`}),t[2]=u):u=t[2];let d;t[3]===o.result?d=t[4]:(d=$t(o.result)&&(0,Z.jsx)(`p`,{role:`alert`,className:`mt-1 text-destructive`,children:Cn(Dn(o.result.cause))}),t[3]=o.result,t[4]=d);let f;t[5]!==d||t[6]!==l?(f=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[l,u,d]}),t[5]=d,t[6]=l,t[7]=f):f=t[7];let p;t[8]!==o||t[9]!==s.requestId?(p=()=>o.dismiss(s.requestId),t[8]=o,t[9]=s.requestId,t[10]=p):p=t[10];let m;t[11]!==o.result.waiting||t[12]!==p?(m=(0,Z.jsx)(Y,{size:`xs`,variant:`ghost`,disabled:o.result.waiting,onClick:p,children:`Got it`}),t[11]=o.result.waiting,t[12]=p,t[13]=m):m=t[13];let h;return t[14]!==f||t[15]!==m?(h=(0,Z.jsxs)(`div`,{role:`status`,className:`flex shrink-0 items-start gap-3 border-b border-graph-4/20 bg-graph-4/10 px-3 py-2 text-xs`,children:[f,m]}),t[14]=f,t[15]=m,t[16]=h):h=t[16],h}function sm(e){let t=(0,$.c)(23),{scope:n,context:r,onOpen:i}=e,{connection:a}=r,o=Pt(xt(sa(n,a))),s=o?.inProgress;if(!s)return null;let c=o.changes.filter(cm),l=`${s===`merge`?`Merge`:`Rebase`} recovery`,u=s===`merge`?`Merge`:`Rebase`,d=c.length?`is waiting for conflict resolution`:`is ready to finish`,f;t[0]!==u||t[1]!==d?(f=(0,Z.jsxs)(`p`,{className:`font-medium`,children:[u,` `,d]}),t[0]=u,t[1]=d,t[2]=f):f=t[2];let p=c.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:c.map(e=>(0,Z.jsx)(Y,{size:`xs`,variant:`outline`,onClick:()=>i({kind:`file`,path:e.path}),children:e.path},e.path))}),m=s===`merge`&&o.mergeHeadOid?`Use Commit from the Git menu to finish. The merge commit includes every staged resolution.`:`Stage the resolved files, then continue in a terminal in this worktree.`,h;t[3]===m?h=t[4]:(h=(0,Z.jsxs)(`p`,{children:[`Resolve the files in your editor or with your agent.`,` `,m]}),t[3]=m,t[4]=h);let g;t[5]===s?g=t[6]:(g=s===`rebase`&&(0,Z.jsx)(um,{command:`git rebase --continue`}),t[5]=s,t[6]=g);let _;t[7]!==o||t[8]!==s?(_=s===`merge`&&!o.mergeHeadOid&&(0,Z.jsx)(um,{command:`git commit`}),t[7]=o,t[8]=s,t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(`span`,{children:`To back out:`}),t[10]=v):v=t[10];let y=`git ${s} --abort`,b;t[11]===y?b=t[12]:(b=(0,Z.jsx)(um,{command:y}),t[11]=y,t[12]=b);let x;t[13]!==_||t[14]!==b||t[15]!==g?(x=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[g,_,v,b]}),t[13]=_,t[14]=b,t[15]=g,t[16]=x):x=t[16];let S;return t[17]!==l||t[18]!==x||t[19]!==f||t[20]!==p||t[21]!==h?(S=(0,Z.jsxs)(`section`,{"aria-label":l,className:`shrink-0 space-y-2 border-b border-graph-4/20 bg-graph-4/10 px-3 py-2 text-xs`,children:[f,p,h,x]}),t[17]=l,t[18]=x,t[19]=f,t[20]=p,t[21]=h,t[22]=S):S=t[22],S}function cm(e){return e.comparisons.some(lm)}function lm(e){return e.scope===`unmerged`}function um(e){let t=(0,$.c)(8),{command:n}=e,r=`Copy ${n}`,i,a;t[0]===n?(i=t[1],a=t[2]):(i=()=>ht(n,`command`),a=(0,Z.jsx)(`code`,{children:n}),t[0]=n,t[1]=i,t[2]=a);let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(De,{}),t[3]=o):o=t[3];let s;return t[4]!==r||t[5]!==i||t[6]!==a?(s=(0,Z.jsxs)(Y,{size:`xs`,variant:`outline`,"aria-label":r,onClick:i,children:[a,o]}),t[4]=r,t[5]=i,t[6]=a,t[7]=s):s=t[7],s}function dm(e,t){let n=(0,$.c)(5),r;if(n[0]!==t||n[1]!==e.state){let i;n[3]===t?i=n[4]:(i=e=>e.operations.get(t)??null,n[3]=t,n[4]=i),r=e.state.map(i),n[0]=t,n[1]=e.state,n[2]=r}else r=n[2];return Te(r)}var fm=x(e=>de({done:new Set,activeGroup:null,ownHead:null,busy:!1,error:null,drafted:{message:null,groups:null},draftedBy:{message:null,groups:null},editingFiles:!1})),pm=x(e=>new Set);function mm(e,t,n){let i=(0,$.c)(14),{connection:a}=n,{operations:o}=a,s;i[0]!==t||i[1]!==e?(s=gn(e,t),i[0]=t,i[1]=e,i[2]=s):s=i[2];let c=s,l;i[3]!==c||i[4]!==o.state.value.operations?(l=()=>{let e=o.state.value.operations.get(c);return e?.receipt&&Yt(e.receipt)?e.requestId:null},i[3]=c,i[4]=o.state.value.operations,i[5]=l):l=i[5];let[u]=(0,Q.useState)(l),d=dm(o,c),f=d?.requestId===u?null:d,p={connection:a,scope:e,action:t},{value:m}=as(tt(p)),h=r(p),g=Se(p),_=N(h),v=N(g),y;i[6]===f?y=i[7]:(y=f?.receipt&&Yt(f.receipt),i[6]=f,i[7]=y);let b=!!y,x;return i[8]!==m||i[9]!==_||i[10]!==f||i[11]!==v||i[12]!==b?(x={...m,execution:_,recovered:v,operation:f,canStartNew:b},i[8]=m,i[9]=_,i[10]=f,i[11]=v,i[12]=b,i[13]=x):x=i[13],x}var hm=x(({signal:e,submit:t,recover:n})=>u(r=>{e!==void 0&&(r.set(t,ye),r.set(n,ye))}));function gm(e,n,r){let i=(0,$.c)(45),{path:a,hunk:o,signal:s,what:u,look:d,readChanges:f,notify:p,dismissNotice:m,close:h}=r,g=mm(e,`discard`,n),_=mm(e,`stash-apply`,n),v=!(!g.operation||g.canStartNew),y;i[0]===f?y=i[1]:(y=()=>t({try:f,catch:Sm}),i[0]=f,i[1]=y);let b;i[2]!==h||i[3]!==m||i[4]!==p||i[5]!==_||i[6]!==y||i[7]!==u?(b={what:u,readChanges:y,notify:p,dismissNotice:m,close:h,restore:_,restoreTimeoutMs:l,run:ln},i[2]=h,i[3]=m,i[4]=p,i[5]=_,i[6]=y,i[7]=u,i[8]=b):b=i[8];let x=b,[S]=(0,Q.useState)(bm),[C]=(0,Q.useState)(vm),w;i[9]===Symbol.for(`react.memo_cache_sentinel`)?(w={mode:`promiseExit`},i[9]=w):w=i[9];let[T,E]=L(S,w),D;i[10]===Symbol.for(`react.memo_cache_sentinel`)?(D={mode:`promiseExit`},i[10]=D):D=i[10];let[O,k]=L(C,D),A=c(S),j=c(C),M;i[11]!==C||i[12]!==s||i[13]!==S?(M=hm({signal:s,submit:S,recover:C}),i[11]=C,i[12]=s,i[13]=S,i[14]=M):M=i[14],ie(M);let N=T.waiting||O.waiting,P=_m,F;i[15]!==O||i[16]!==T?(F=P(T)??P(O),i[15]=O,i[16]=T,i[17]=F):F=i[17];let I;i[18]!==j||i[19]!==A?(I=()=>{A(ye),j(ye)},i[18]=j,i[19]=A,i[20]=I):I=i[20];let R;i[21]!==N||i[22]!==g||i[23]!==x||i[24]!==o||i[25]!==d||i[26]!==a||i[27]!==j||i[28]!==E||i[29]!==v?(R=()=>{N||v||!d||(j(ye),E({run:()=>g.run({action:`discard`,path:a,...o?{hunk:o}:{}},Tt(d,[a])),discarding:x}))},i[21]=N,i[22]=g,i[23]=x,i[24]=o,i[25]=d,i[26]=a,i[27]=j,i[28]=E,i[29]=v,i[30]=R):R=i[30];let z;i[31]!==N||i[32]!==g.recover||i[33]!==x||i[34]!==k||i[35]!==A?(z=()=>{N||(A(ye),k({recover:g.recover,discarding:x}))},i[31]=N,i[32]=g.recover,i[33]=x,i[34]=k,i[35]=A,i[36]=z):z=i[36];let B;return i[37]!==N||i[38]!==g.operation||i[39]!==F||i[40]!==I||i[41]!==R||i[42]!==z||i[43]!==v?(B={operation:g.operation,uncertain:v,busy:N,error:F,reset:I,run:R,checkOutcome:z},i[37]=N,i[38]=g.operation,i[39]=F,i[40]=I,i[41]=R,i[42]=z,i[43]=v,i[44]=B):B=i[44],B}function _m(e){return Pt(xt(e))??($t(e)?{text:Cn(Dn(e.cause)),moved:!1}:null)}function vm(){return z(ym)}function ym(e){return Fe(e.recover(),e.discarding)}function bm(){return z(xm)}function xm(e){return Fe(e.run(),e.discarding)}function Sm(e){return new Ut(e,Cn(e))}function Cm({text:e}){return e.split(/`([^`\n]+)`/).map((e,t)=>t%2?(0,Z.jsx)(`code`,{className:`box-decoration-clone rounded bg-muted px-1 py-0.5 font-mono text-[0.9em]`,children:e},t):e)}function wm(e){let t=(0,$.c)(6),{text:n,children:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Ka,{className:`mt-0.5 size-4 shrink-0`}),t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=(0,Z.jsx)(Cm,{text:n}),t[1]=n,t[2]=a);let o;return t[3]!==r||t[4]!==a?(o=(0,Z.jsxs)(`p`,{role:`alert`,className:`flex gap-2 text-sm text-destructive`,children:[i,(0,Z.jsxs)(`span`,{children:[a,r]})]}),t[3]=r,t[4]=a,t[5]=o):o=t[5],o}function Tm(e){let t=(0,$.c)(48),{scope:n,context:r,path:i,hunk:a,variant:o,signal:s,hiddenTrigger:c,children:l}=e,u=o===void 0?`button`:o,d=c!==void 0&&c,{connection:f}=r,p=Pt(xt(sa(n,f))),m=_i(n,f),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(null),y=p,b=y?dn(y):null,x=y?.changes.find(e=>e.path===i),S=_??b,C;t[0]===a?C=t[1]:(C=a?km(a):null,t[0]=a,t[1]=C);let w=C,T;t[2]!==w||t[3]!==i?(T=w?`${w} of ${Qp(i)}`:Qp(i),t[2]=w,t[3]=i,t[4]=T):T=t[4];let E=T,D;t[5]===g?D=t[6]:(D=()=>g(!1),t[5]=g,t[6]=D);let O;t[7]!==S||t[8]!==a||t[9]!==i||t[10]!==m||t[11]!==s||t[12]!==D||t[13]!==E?(O={path:i,hunk:a,signal:s,what:E,look:S,readChanges:m,notify:Om,dismissNotice:Dm,close:D},t[7]=S,t[8]=a,t[9]=i,t[10]=m,t[11]=s,t[12]=D,t[13]=E,t[14]=O):O=t[14];let k=gm(n,r,O),{busy:A,error:j,uncertain:M}=k,N=!!(S&&(x||h)),[P,F]=(0,Q.useState)();s!==void 0&&s!==P&&b&&(F(s),v(b),g(!0));let I;t[15]!==k||t[16]!==d||t[17]!==a||t[18]!==w||t[19]!==i||t[20]!==g||t[21]!==v||t[22]!==N||t[23]!==b||t[24]!==u?(I=N&&!d?(0,Z.jsxs)(Y,{size:u===`button`?`sm`:`xs`,variant:u===`button`?`destructive`:`ghost`,"aria-label":a?`Discard ${w} of ${Qp(i)}`:`Discard changes to ${Qp(i)}`,onClick:()=>{k.reset(),v(b),g(!0)},children:[(0,Z.jsx)(zc,{}),Am(u)]}):null,t[15]=k,t[16]=d,t[17]=a,t[18]=w,t[19]=i,t[20]=g,t[21]=v,t[22]=N,t[23]=b,t[24]=u,t[25]=I):I=t[25];let L=I,R;t[26]!==A||t[27]!==k.checkOutcome||t[28]!==k.operation?.receipt||t[29]!==k.run||t[30]!==j||t[31]!==a||t[32]!==h||t[33]!==i||t[34]!==g||t[35]!==N||t[36]!==M||t[37]!==E?(R=N?(0,Z.jsx)(Hr,{open:h,onOpenChange:e=>!A&&g(e),children:(0,Z.jsxs)(ua,{children:[(0,Z.jsxs)(rr,{children:[(0,Z.jsxs)(jr,{children:[`Discard `,E,`?`]}),(0,Z.jsx)(Gr,{children:a?`Select one complete changed hunk. Only that hunk is reverted; partial selections are refused. A recovery copy is saved first.`:`The file goes back to the last commit. You can restore the changes.`})]}),(0,Z.jsx)(X,{className:`rounded-lg bg-muted/50 px-3 py-2 font-mono text-xs`,render:(0,Z.jsx)(`p`,{}),text:i}),j&&(0,Z.jsx)(wm,{text:j.text,children:j.moved?` Look at the diff again before discarding.`:``}),k.operation?.receipt?.progress.map(Em),M&&!k.operation?.receipt&&(0,Z.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`The response was lost. Check the existing discard request before trying again.`}),(0,Z.jsxs)(or,{children:[(0,Z.jsx)(er,{disabled:A,children:j?.moved?`Look again`:`Cancel`}),!j?.moved&&(M?(0,Z.jsx)(Y,{disabled:A,onClick:k.checkOutcome,children:A?`Checking…`:`Check outcome`}):(0,Z.jsx)(Y,{variant:`destructive`,disabled:A,onClick:k.run,children:A?`Discarding…`:`Discard`}))]})]})}):null,t[26]=A,t[27]=k.checkOutcome,t[28]=k.operation?.receipt,t[29]=k.run,t[30]=j,t[31]=a,t[32]=h,t[33]=i,t[34]=g,t[35]=N,t[36]=M,t[37]=E,t[38]=R):R=t[38];let z=R;if(l){let e;t[39]!==l||t[40]!==L?(e=l(L),t[39]=l,t[40]=L,t[41]=e):e=t[41];let n;return t[42]!==z||t[43]!==e?(n=(0,Z.jsxs)(Z.Fragment,{children:[e,z]}),t[42]=z,t[43]=e,t[44]=n):n=t[44],n}let B;return t[45]!==z||t[46]!==L?(B=(0,Z.jsxs)(Z.Fragment,{children:[L,z]}),t[45]=z,t[46]=L,t[47]=B):B=t[47],B}function Em(e){return(0,Z.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:e},e)}function Dm(e){return xo.close(e)}function Om(e){return xo.add(e)}function km({startLine:e,endLine:t}){return e===t?`line ${e}`:`lines ${e}–${t}`}function Am(e){return e===`quiet`?(0,Z.jsx)(`span`,{className:`max-narrow:sr-only`,children:`Discard`}):e===`compact`?`Discard selection`:`Discard`}var jm=Bt(`flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`*:data-slot:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-md! [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0`,vertical:`flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-md! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0`}},defaultVariants:{orientation:`horizontal`}});function Mm({className:e,orientation:t,...n}){return(0,Z.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":t,className:q(jm({orientation:t}),e),...n})}function Nm({className:e,render:t,...n}){return vt({defaultTagName:`div`,props:Sn({className:q(`flex items-center gap-2 rounded-md border bg-muted px-2.5 text-xs/relaxed font-medium [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4`,e)},n),render:t,state:{slot:`button-group-text`}})}function Pm(e,n,r){let i=(0,$.c)(32),a=mm(e,`fetch`,n),o=mm(e,`pull`,n),s=mm(e,`push`,n),c=mm(e,`stash-apply`,n),l;i[0]===r.details?l=i[1]:(l=()=>t({try:r.details.read,catch:Lm}),i[0]=r.details,i[1]=l);let u;i[2]!==r.details||i[3]!==l?(u={...r.details,read:l},i[2]=r.details,i[3]=l,i[4]=u):u=i[4];let d;i[5]!==r||i[6]!==u?(d={...r,details:u},i[5]=r,i[6]=u,i[7]=d):d=i[7];let f=d,p,m;i[8]!==a||i[9]!==o||i[10]!==s?(p={fetch:a,pull:o,push:s},m=[`fetch`,`pull`,`push`].map(e=>({name:e,operation:p[e].operation,canStartNew:p[e].canStartNew,checking:p[e].recovered.waiting})).find(Im),i[8]=a,i[9]=o,i[10]=s,i[11]=p,i[12]=m):(p=i[11],m=i[12]);let h=m,g;i[13]!==f||i[14]!==p||i[15]!==h?(g=()=>{h&&ln(v(f,p[h.name],h.name))},i[13]=f,i[14]=p,i[15]=h,i[16]=g):g=i[16];let _;i[17]!==f||i[18]!==p?(_=(e,t)=>ln(re(f,p[e],e,t)),i[17]=f,i[18]=p,i[19]=_):_=i[19];let y;i[20]!==f||i[21]!==c?(y=e=>ln(I(f,c,e)),i[20]=f,i[21]=c,i[22]=y):y=i[22];let b;i[23]!==r.onLooked||i[24]!==r.refreshLook?(b=()=>V(_e(t({try:r.refreshLook,catch:Fm}),r.onLooked)),i[23]=r.onLooked,i[24]=r.refreshLook,i[25]=b):b=i[25];let x;return i[26]!==h||i[27]!==g||i[28]!==_||i[29]!==y||i[30]!==b?(x={running:h,checkOutcome:g,runNetwork:_,restoreDiscarded:y,lookAgain:b},i[26]=h,i[27]=g,i[28]=_,i[29]=y,i[30]=b,i[31]=x):x=i[31],x}function Fm(e){return new Ut(e,Cn(e))}function Im(e){let{operation:t,canStartNew:n}=e;return t!=null&&!n}function Lm(e){return new Ut(e,Cn(e))}function Rm(e){let t=(0,$.c)(12),{action:n,className:r}=e;switch(n){case`amend`:{let e;return t[0]===r?e=t[1]:(e=(0,Z.jsx)(ji,{className:r}),t[0]=r,t[1]=e),e}case`push`:{let e;return t[2]===r?e=t[3]:(e=(0,Z.jsx)(qr,{className:r}),t[2]=r,t[3]=e),e}case`pull`:case`fetch`:{let e;return t[4]===r?e=t[5]:(e=(0,Z.jsx)(qs,{className:r}),t[4]=r,t[5]=e),e}case`stash-create`:{let e;return t[6]===r?e=t[7]:(e=(0,Z.jsx)(Gs,{className:r}),t[6]=r,t[7]=e),e}case`stash-apply`:case`stash-pop`:{let e;return t[8]===r?e=t[9]:(e=(0,Z.jsx)(Us,{className:r}),t[8]=r,t[9]=e),e}default:{let e;return t[10]===r?e=t[11]:(e=(0,Z.jsx)(pc,{className:r}),t[10]=r,t[11]=e),e}}}function zm(e){if(!e)return null;for(let t of e.elements){let e=t.tagName;if(e===`BUTTON`||e===`INPUT`){let e=t;if(e.type===`submit`)return e}}return null}var Bm=`data-checked`,Vm=`data-unchecked`;function Hm(e){return{checked(t){return e.indeterminate?{}:t?{[Bm]:``}:{[Vm]:``}},...Ze}}var Um=Q.createContext(void 0);function Wm(){return Q.useContext(Um)}var Gm=Q.createContext(void 0);function Km(){let e=Q.useContext(Gm);if(e===void 0)throw Error(Ht(14));return e}var qm=`data-parent`,Jm=Q.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":o,disabled:s=!1,form:c,id:l,indeterminate:u=!1,inputRef:d,name:f,onCheckedChange:p,parent:m=!1,readOnly:h=!1,render:g,required:v=!1,uncheckedValue:y,value:b,nativeButton:x=!1,style:S,...w}=e,{clearErrors:T}=pn(),{disabled:E,name:D,setDirty:O,setFilled:j,setFocused:M,setTouched:N,state:I,validationMode:L,validityData:R,validation:z}=W(),B=ou(),{labelId:V,registerControlId:H,getDescriptionProps:U}=te(),G=Wm(),ee=G?.allValues===void 0?void 0:G.parent,ne=ee!==void 0,re=E||B.disabled||G?.disabled||s,ie=D??f,ae=b??ie,K=Kt(),oe=G?.registerControlId!==H,q=We({id:l||void 0,enabled:oe}),se=x?q:K,ce={};ne&&(m?ce=ee.getParentProps():ae!==void 0&&(ce=ee.getChildProps(ae)));let{checked:le=n,indeterminate:ue=u,onCheckedChange:de,...J}=ce,fe=G?.value,pe=Q.useRef(null),{getButtonProps:me,buttonRef:he}=Be({disabled:re,native:x}),ge=G?.validation??z,[_e,ye]=Ne({controlled:ae!==void 0&&fe!==void 0&&!m?fe.includes(ae):le,default:i,name:`Checkbox`,state:`checked`}),be=ne?!!le:_e,xe=ne&&ue||u;P(pe,K,_e,void 0,!G&&!re,f);let Se=ee?.registerChildId,Ce=Q.useRef(null),we=ge.registerInput,Te=G?ae:void 0,Ee=Q.useCallback(e=>we(e,{controlRef:pe,value:Te}),[we,Te]),De=Xt(d,Ce,m?void 0:Ee),Oe=k(o,V,Ce,!x,q);a(()=>{Ce.current&&(Ce.current.indeterminate=xe),G||j(_e)},[_e,xe,G,j]),Re(_e,()=>{G||(T(ie),O(_e!==R.initialValue),ge.change(_e))});let ke=Sn({checked:_e,disabled:re,form:c,name:m?void 0:ie,id:x?void 0:q,required:v,ref:De,style:ie?ct:Lt,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(h){e.preventDefault();return}let t=e.currentTarget.checked,n=F(A,e.nativeEvent);if(p?.(t,n),!n.isCanceled&&(de?.(t,n),!n.isCanceled&&(ye(t),ae!==void 0&&G!==void 0&&!m&&!ne))){let e=t?[...G.value,ae]:G.value.filter(e=>e!==ae);G.setValue(e,n)}},onClick(e){e.stopPropagation()},onFocus(){pe.current?.focus()}},b===void 0?ve:{value:(G?_e&&b:b)||``},U,e=>ge.getValidationProps(re,e));Q.useEffect(()=>{if(!ee||ae===void 0)return;let e=ee.disabledStatesRef.current;return e.set(ae,re),()=>{e.delete(ae)}},[ee,re,ae]);let Ae=Q.useMemo(()=>({...I,checked:be,disabled:re,readOnly:h,required:v,indeterminate:xe}),[I,be,re,h,v,xe]),je=Hm(Ae),Me=wt(`span`,e,{state:Ae,ref:[he,pe,t],props:[{id:se,role:`checkbox`,"aria-checked":xe?`mixed`:be,"aria-readonly":h||void 0,"aria-required":v||void 0,"aria-labelledby":Oe,[qm]:m?``:void 0,onFocus(){re||M(!0)},onBlur(){let e=Ce.current;e&&(N(!0),M(!1),L===`onBlur`&&ge.commit(G?fe:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=Ce.current?.form??null,n=e.currentTarget,r=e.nativeEvent,i=e.preventDefault,a=r.preventDefault,o=!1;e.preventDefault=()=>{o=!0,i.call(e)},r.preventDefault=()=>{o=!0,a.call(r)},a.call(r),_(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||zm(t)?.click()})},onClick(e){if(h||re)return;e.preventDefault();let t=Ce.current;t&&C(t,e)}},w,J,me,U,e=>ge.getValidationProps(re,e)],stateAttributesMapping:je}),Pe=Me.props.id;return a(()=>{if(Se&&!m&&ae!==void 0&&Pe!==void 0)return Se(ae,Pe)},[Se,m,ae,Pe]),(0,Z.jsxs)(Gm.Provider,{value:Ae,children:[Me,!_e&&!G&&ie&&!m&&y!==void 0&&(0,Z.jsx)(`input`,{type:`hidden`,form:c,name:ie,value:y,disabled:re}),(0,Z.jsx)(`input`,{...ke,suppressHydrationWarning:!0})]})}),Ym=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Km(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=he(c),f=Q.useRef(null),p={...s,transitionStatus:u};be({batch:!0,enabled:!c,open:c,ref:f,onComplete(){c||d(!1)}});let m={...Hm(s),...qt},h=a||l,g=wt(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null});function Xm({className:e,...t}){return(0,Z.jsx)(Jm,{"data-slot":`checkbox`,className:q(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-shadow outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,Z.jsx)(Ym,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,Z.jsx)(g,{})})})}function Zm(e,n,r,i){let a=(0,$.c)(29),{expectedStatus:o,onBusy:s,onLookAgain:l}=i,u=mm(e,n,r),[d]=(0,Q.useState)(th),f;a[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={mode:`promiseExit`},a[0]=f):f=a[0];let[p,m]=L(d,f),h=c(d),g=u.execution.waiting||u.recovered.waiting||p.waiting,_=!(!u.operation||u.canStartNew),v=eh,y=u.operation?.receipt,b;a[1]!==u.execution||a[2]!==u.recovered||a[3]!==p?(b=v(u.execution)??v(p)??v(u.recovered),a[1]=u.execution,a[2]=u.recovered,a[3]=p,a[4]=b):b=a[4];let x;a[5]!==g||a[6]!==o||a[7]!==u||a[8]!==s||a[9]!==h||a[10]!==_?(x=e=>{g||_||(s(!0),h(ye),u.reset(),ln(u.run(e,Tt(o,o.files?.map($m)??[],void 0,!0)).pipe(Bn($e(()=>s(!1))),w)))},a[5]=g,a[6]=o,a[7]=u,a[8]=s,a[9]=h,a[10]=_,a[11]=x):x=a[11];let S;a[12]!==g||a[13]!==u||a[14]!==l||a[15]!==m?(S=()=>{l&&!g&&(u.reset(),m({read:t({try:l,catch:Qm}),startNew:u.startNew()}))},a[12]=g,a[13]=u,a[14]=l,a[15]=m,a[16]=S):S=a[16];let C;a[17]!==u||a[18]!==h?(C=()=>{u.reset(),h(ye),ln(u.recover().pipe(w))},a[17]=u,a[18]=h,a[19]=C):C=a[19];let T;return a[20]!==g||a[21]!==u.operation||a[22]!==y||a[23]!==b||a[24]!==x||a[25]!==S||a[26]!==C||a[27]!==_?(T={operation:u.operation,messageLimit:hn,outcome:y,busy:g,uncertain:_,error:b,onSubmit:x,lookAgain:S,checkOutcome:C},a[20]=g,a[21]=u.operation,a[22]=y,a[23]=b,a[24]=x,a[25]=S,a[26]=C,a[27]=_,a[28]=T):T=a[28],T}function Qm(e){return new Ut(e,Cn(e))}function $m(e){return e.path}function eh(e){return $t(e)?Dn(e.cause):null}function th(){return z(nh)}function nh(e){return le(e.read,e.startNew)}function rh(e){let t=[],n=[],r=()=>{let e=t.indexOf(null);return e===-1?(t.push(null),t.length-1):e};for(let i of e){let e=t.flatMap((e,t)=>e===i.oid?[t]:[]);for(let n of e)t[n]=null;let a=e.length>0?Math.min(...e):r(),o=i.parentOids.map((e,n)=>{let i=t.indexOf(e),o=n===0?a:i===-1?r():i;return t[o]=e,o});n.push({commit:i,lane:a,outgoing:o,lanesAfter:[...t]})}return n}function ih(e){let t=e.flatMap(e=>[e.lane,...e.outgoing,...e.lanesAfter.flatMap((e,t)=>e==null?[]:[t])]);return 26+Math.max(0,...t)*16}function ah(e){let t=e%100;return`${e}${t>=11&&t<=13?`th`:[`th`,`st`,`nd`,`rd`][e%10]??`th`}`}function oh(e){let t=ch(e),n=t.at(-1);return{snapshot:t[0]?.snapshot??null,commits:t.flatMap(e=>e.commits),nextAfter:n?.nextAfter??null,boundary:n?.boundary??null,restarted:n?.restarted??!1}}function sh(e){let t=ch(e),n=t.at(-1);return{commits:t.flatMap(e=>e.commits),tip:t[0]?.tip??null,nextAfter:n?.nextAfter??null,boundary:n?.boundary??null,restarted:t[0]?.restarted??!1}}function ch(e){let t=e.findLastIndex(e=>e.restarted);return t===-1?e:e.slice(t)}var lh=x(e=>u({loaded:0,selected:void 0,scrollOffset:0,graphScrollOffset:0,resetId:0}).pipe(Ee)),uh=x(({connection:e,scope:t})=>Oe(e,t,[`history`],n=>ph(n,lh({connection:e,scope:t,kind:`commits`}),n=>Ve(function*(){let r=yield*(yield*H(e)).request(e=>e.changes.listCommits({params:{worktreeId:t.worktreeId},query:{after:n?.after,tip:n?.tip}}));return yield*T(e),r}),e=>e.nextAfter&&e.tip?{after:e.nextAfter,tip:e.tip}:void 0),un(e))),dh=x(({connection:e,scope:t,oid:n,parent:r=1})=>m(e,t,[`commit`,n,r],Ve(function*(){let i=yield*(yield*H(e)).request(e=>e.changes.readCommitFiles({params:{worktreeId:t.worktreeId,oid:n},query:r===1?{}:{parent:r}}));return yield*T(e,i.commit.oid===n&&(i.comparison.kind===`empty-tree`||i.comparison.parentNumber===r)),i}),un(e))),fh=x(({connection:e,scope:t,path:n})=>Oe(e,t,[`history`,`file`,n],r=>ph(r,lh({connection:e,scope:t,kind:`file`,path:n}),r=>Ve(function*(){let i=yield*(yield*H(e)).request(e=>e.changes.listFileCommits({params:{worktreeId:t.worktreeId},query:{path:n,limit:100,after:r}}));return yield*T(e),i}),e=>e.nextAfter),un(e)));function ph(e,t,n,r){let i=e.once(t).loaded,a=0;return xn(void 0,o=>Ve(function*(){let s=[],c=a,l=o,u=!1;do{let e=yield*n(l);e.restarted&&(c=0,u=!0),c+=e.commits.length,s.push(e),l=r(e)}while(o===void 0&&c<i&&l!==void 0&&!u);a=c;let d=e.once(t);return e.set(t,{...d,loaded:a,...u?{selected:void 0,scrollOffset:0,graphScrollOffset:0,resetId:d.resetId+1}:{}}),[s,l===void 0?Rn():pt(l)]}))}var mh=x(e=>Le(fh(e),e=>En(e,e=>sh(e.items))).pipe(O(0))),hh=x(e=>Le(uh(e),e=>En(e,e=>oh(e.items))).pipe(O(0)));x(e=>K((t,n)=>{let r=lh({...e,kind:`commit`,oid:t.oid,parent:t.parent}),i=n(r);n.set(r,{...i,selected:t.path,scrollOffset:0,resetId:i.resetId+1})}));function gh(e,t,n,r){let i=(0,$.c)(5),a=r===void 0?1:r,o;return i[0]!==e||i[1]!==n||i[2]!==a||i[3]!==t?(o=dh({connection:e,scope:t,oid:n,parent:a}),i[0]=e,i[1]=n,i[2]=a,i[3]=t,i[4]=o):o=i[4],as(o).value}function _h(e){let t=(0,$.c)(13),{tracking:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(hr,{className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`}),t[0]=r):r=t[0];let i;t[1]===n.name?i=t[2]:(i=(0,Z.jsx)(X,{className:`min-w-0 flex-1 font-mono text-caption font-medium text-foreground`,text:n.name}),t[1]=n.name,t[2]=i);let a;t[3]===n.counts?a=t[4]:(a=n.counts!==null&&(0,Z.jsx)(`span`,{className:`shrink-0 text-2xs text-muted-foreground tabular-nums`,children:n.counts}),t[3]=n.counts,t[4]=a);let o;t[5]!==i||t[6]!==a?(o=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[i,a]}),t[5]=i,t[6]=a,t[7]=o):o=t[7];let s;t[8]===n.upstream?s=t[9]:(s=(0,Z.jsx)(X,{className:`text-2xs text-muted-foreground`,text:n.upstream}),t[8]=n.upstream,t[9]=s);let c;return t[10]!==o||t[11]!==s?(c=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[r,(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[o,s]})]}),t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function vh(e,t){let n=(0,$.c)(19),r;n[0]!==e||n[1]!==t?(r=uh({connection:e,scope:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2];let i=r,a;n[3]!==e||n[4]!==t?(a=hh({connection:e,scope:t}),n[3]=e,n[4]=t,n[5]=a):a=n[5];let{result:o,value:s}=as(a),l=c(i),u;n[6]!==e||n[7]!==t?(u=lh({connection:e,scope:t,kind:`commits`}),n[6]=e,n[7]=t,n[8]=u):u=n[8];let d=u,f=N(d,yh),p=c(d),m;n[9]===p?m=n[10]:(m=e=>p(t=>({...t,selected:e})),n[9]=p,n[10]=m);let h;n[11]===l?h=n[12]:(h=()=>l(void 0),n[11]=l,n[12]=h);let g;return n[13]!==o||n[14]!==f||n[15]!==m||n[16]!==h||n[17]!==s?(g={...s,result:o,selected:f,select:m,readMore:h},n[13]=o,n[14]=f,n[15]=m,n[16]=h,n[17]=s,n[18]=g):g=n[18],g}function yh(e){return e.selected}function bh(e){let t=(0,$.c)(3),{enabled:n,onVisible:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`h-px`,ref:e=>{if(!e||!n||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(e=>{let[t]=e;t?.isIntersecting&&r()},{rootMargin:`0px 0px 240px 0px`});return t.observe(e),()=>t.disconnect()}}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function xh(e){let t=(0,$.c)(5),[n,r]=(0,Q.useState)(1),i;t[0]===e?i=t[1]:(i=function(t){if(!t)return;let n=t.querySelector(`[data-ref-measurement]`);if(!n)return;let i=()=>{let i=Array.from(n.children,Ch),a=i.pop()??0,o=Number.parseFloat(getComputedStyle(t).columnGap),s=t.getBoundingClientRect().width;if(i.reduce(Sh,0)+Math.max(0,i.length-1)*o<=s){r(e);return}let c=0,l=0;for(let t of i){c+=t+(l===0?0:o);let n=l+1===e?0:o+a;if(c+n>s)break;l+=1}r(Math.max(1,l))},a=new ResizeObserver(i);return a.observe(t),a.observe(n),i(),()=>a.disconnect()},t[0]=e,t[1]=i);let a=i,o;return t[2]!==a||t[3]!==n?(o={row:a,visibleCount:n},t[2]=a,t[3]=n,t[4]=o):o=t[4],o}function Sh(e,t){return e+t}function Ch(e){return e.getBoundingClientRect().width}var wh=`min-w-0 max-w-40`;function Th(e){let t=(0,$.c)(21),{refs:n,current:r,onOpenCommit:i}=e,a=r===void 0?Oh:r,{row:o,visibleCount:s}=xh(n.length),c;if(t[0]!==a||t[1]!==i||t[2]!==n||t[3]!==o||t[4]!==s){let e=n.slice(s),r;t[6]===n?r=t[7]:(r=n.map(Dh),t[6]=n,t[7]=r);let l;t[8]===n.length?l=t[9]:(l=(0,Z.jsxs)(nt,{variant:`secondary`,className:wh,children:[`+`,n.length]}),t[8]=n.length,t[9]=l);let u;t[10]!==r||t[11]!==l?(u=(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none invisible absolute inset-0 overflow-hidden`,children:(0,Z.jsxs)(`div`,{"data-ref-measurement":!0,className:`flex w-max gap-1`,children:[r,l]})}),t[10]=r,t[11]=l,t[12]=u):u=t[12];let d;if(t[13]!==a||t[14]!==i||t[15]!==n||t[16]!==s){let e;t[18]!==a||t[19]!==i?(e=e=>(0,Z.jsx)(X,{text:e.name,renderTrigger:t=>(0,Z.jsxs)(nt,{render:(0,Z.jsx)(`button`,{type:`button`,onClick:i}),variant:a(e)?`brand-soft`:`outline`,className:`${wh} pointer-events-auto shrink`,children:[e.kind===`tag`&&(0,Z.jsx)(Lc,{"aria-hidden":`true`}),t]}),children:e.name},`${e.kind}:${e.name}`),t[18]=a,t[19]=i,t[20]=e):e=t[20],d=n.slice(0,s).map(e),t[13]=a,t[14]=i,t[15]=n,t[16]=s,t[17]=d}else d=t[17];c=(0,Z.jsxs)(`div`,{ref:o,className:`pointer-events-none relative flex min-w-0 items-center gap-1`,children:[u,d,e.length>0&&(0,Z.jsxs)(Jt,{children:[(0,Z.jsxs)(vn,{render:(0,Z.jsx)(nt,{render:(0,Z.jsx)(`button`,{type:`button`}),variant:`secondary`,className:`${wh} pointer-events-auto`,"aria-label":`Show ${e.length} more ${ae(e.length,`ref`)}`}),children:[`+`,e.length]}),(0,Z.jsxs)(mn,{align:`start`,className:`max-w-[calc(100vw-2rem)]`,children:[(0,Z.jsx)(Qt,{children:`More refs`}),(0,Z.jsx)(`ul`,{className:`max-h-64 overflow-y-auto text-xs`,children:e.map(Eh)})]})]})]}),t[0]=a,t[1]=i,t[2]=n,t[3]=o,t[4]=s,t[5]=c}else c=t[5];return c}function Eh(e){return(0,Z.jsxs)(`li`,{className:`flex items-center gap-1 py-1 break-all`,children:[e.kind===`tag`&&(0,Z.jsx)(Lc,{"aria-hidden":`true`,className:`size-3 shrink-0`}),e.name]},`${e.kind}:${e.name}`)}function Dh(e){return(0,Z.jsxs)(nt,{variant:`secondary`,className:wh,children:[e.kind===`tag`&&(0,Z.jsx)(Lc,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{"data-label":e.name,className:`before:content-[attr(data-label)]`})]},`${e.kind}:${e.name}`)}function Oh(){return!1}function kh(e){let t=(0,$.c)(74),{commit:n,selected:r,height:i,inset:a,layout:o,head:s,headRef:c,onSelect:l,openToSide:u,children:d}=e,f=o===void 0?`stacked`:o,p=s!==void 0&&s,[m,h]=(0,Q.useState)(!1),g;t[0]!==l||t[1]!==u?(g=e=>l(u!==void 0&&e.altKey),t[0]=l,t[1]=u,t[2]=g):g=t[2];let _=g,v;t[3]===c?v=t[4]:(v=e=>Pp(e,c),t[3]=c,t[4]=v);let y=v,b;if(t[5]!==n.refs||t[6]!==y){let e;t[8]===y?e=t[9]:(e=(e,t)=>Number(y(t))-Number(y(e)),t[8]=y,t[9]=e),b=Np(n.refs).toSorted(e),t[5]=n.refs,t[6]=y,t[7]=b}else b=t[7];let x=b,S;t[10]===p?S=t[11]:(S=p?(0,Z.jsx)(nt,{variant:`brand`,className:`relative shrink-0`,children:`HEAD`}):null,t[10]=p,t[11]=S);let C=S,w=f===`stacked`&&`font-medium`,T=(p||r)&&`font-semibold`,E;t[12]!==w||t[13]!==T?(E=q(`flex min-w-0 items-center gap-1 text-ui leading-4.5 font-normal`,w,T),t[12]=w,t[13]=T,t[14]=E):E=t[14];let D;t[15]===n.parentOids.length?D=t[16]:(D=n.parentOids.length>1&&(0,Z.jsx)(_c,{"aria-label":`Merge commit`,className:`size-3.5 shrink-0 text-muted-foreground`}),t[15]=n.parentOids.length,t[16]=D);let O;t[17]===n.subject?O=t[18]:(O=(0,Z.jsx)(X,{text:n.subject}),t[17]=n.subject,t[18]=O);let k=f===`stacked`&&C,A;t[19]!==D||t[20]!==O||t[21]!==k||t[22]!==E?(A=(0,Z.jsxs)(`span`,{className:E,children:[D,O,k]}),t[19]=D,t[20]=O,t[21]=k,t[22]=E,t[23]=A):A=t[23];let j=A,M;t[24]===n.author.timestamp?M=t[25]:(M=ze(n.author.timestamp),t[24]=n.author.timestamp,t[25]=M);let N=M,P;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{e&&h(!1)},t[26]=P):P=t[26];let F;t[27]!==i||t[28]!==a?(F={height:i,paddingLeft:a},t[27]=i,t[28]=a,t[29]=F):F=t[29];let I=f===`stacked`?`flex-col justify-center gap-0.5`:`items-center gap-3`,L=i===void 0&&`py-1.5`,R=r&&`bg-muted ring-1 ring-border ring-inset`,z=p&&`bg-muted ring-1 ring-border ring-inset`,B;t[30]!==I||t[31]!==L||t[32]!==R||t[33]!==z?(B=q(`relative flex w-full rounded-lg px-2 text-left transition-colors hover:bg-accent`,I,L,R,z),t[30]=I,t[31]=L,t[32]=R,t[33]=z,t[34]=B):B=t[34];let V;t[35]!==F||t[36]!==B?(V=(0,Z.jsx)(`div`,{style:F,className:B}),t[35]=F,t[36]=B,t[37]=V):V=t[37];let H;t[38]!==N||t[39]!==d||t[40]!==n.author.name||t[41]!==n.oid||t[42]!==y||t[43]!==C||t[44]!==a||t[45]!==f||t[46]!==x||t[47]!==_||t[48]!==r||t[49]!==j?(H=f===`stacked`?(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:_,className:q(`block min-w-0 text-left before:absolute before:inset-0 before:rounded-lg`,x.length>0?`max-w-3/5`:`flex-1`),children:[j,(0,Z.jsxs)(`span`,{style:{left:a},className:`absolute inset-x-2 mt-0.5 flex min-w-0 gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`code`,{className:`font-mono`,children:jp(n.oid)}),(0,Z.jsx)(X,{text:n.author.name}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:N})]}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 block h-4`}),d!==void 0&&(0,Z.jsx)(`span`,{className:`flex min-w-0`,children:d})]}),x.length>0&&(0,Z.jsx)(`div`,{className:`flex h-4.5 min-w-0 flex-1 flex-col justify-center`,children:(0,Z.jsx)(Th,{refs:x,current:y,onOpenCommit:_})})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`code`,{className:`hidden w-16 shrink-0 font-mono text-xs text-muted-foreground @md/graph:block`,children:jp(n.oid)}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:_,className:`flex max-w-3/5 min-w-0 shrink-0 items-center text-left before:absolute before:inset-0 before:rounded-lg`,children:[j,(0,Z.jsx)(`span`,{className:`sr-only`,children:` ${jp(n.oid)} ${n.author.name} ${N}`})]}),C,(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:x.length>0&&(0,Z.jsx)(Th,{refs:x,current:y,onOpenCommit:_})})]}),(0,Z.jsx)(X,{className:`hidden w-28 shrink-0 text-xs text-muted-foreground @2xl/graph:block`,text:n.author.name}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-right text-xs whitespace-nowrap text-muted-foreground tabular-nums`,children:N})]}),t[38]=N,t[39]=d,t[40]=n.author.name,t[41]=n.oid,t[42]=y,t[43]=C,t[44]=a,t[45]=f,t[46]=x,t[47]=_,t[48]=r,t[49]=j,t[50]=H):H=t[50];let U;t[51]!==V||t[52]!==H?(U=(0,Z.jsx)(Ji,{render:V,children:H}),t[51]=V,t[52]=H,t[53]=U):U=t[53];let W=!m,G;t[54]===u?G=t[55]:(G=u&&(0,Z.jsxs)(Zr,{onClick:()=>{(0,iu.flushSync)(()=>h(!0)),u.open()},children:[(0,Z.jsx)(Yr,{}),u.label]}),t[54]=u,t[55]=G);let ee;t[56]===n.oid?ee=t[57]:(ee=()=>ht(n.oid,`commit id`),t[56]=n.oid,t[57]=ee);let te;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(De,{}),t[58]=te):te=t[58];let ne;t[59]===ee?ne=t[60]:(ne=(0,Z.jsxs)(Zr,{onClick:ee,children:[te,`Copy commit id`]}),t[59]=ee,t[60]=ne);let re;t[61]===n?re=t[62]:(re=()=>ht(Dp(n),`commit message`),t[61]=n,t[62]=re);let ie;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Z.jsx)(De,{}),t[63]=ie):ie=t[63];let ae;t[64]===re?ae=t[65]:(ae=(0,Z.jsxs)(Zr,{onClick:re,children:[ie,`Copy message`]}),t[64]=re,t[65]=ae);let K;t[66]!==W||t[67]!==G||t[68]!==ne||t[69]!==ae?(K=(0,Z.jsxs)(Kr,{finalFocus:W,children:[G,ne,ae]}),t[66]=W,t[67]=G,t[68]=ne,t[69]=ae,t[70]=K):K=t[70];let oe;return t[71]!==U||t[72]!==K?(oe=(0,Z.jsxs)(dr,{onOpenChange:P,children:[U,K]}),t[71]=U,t[72]=K,t[73]=oe):oe=t[73],oe}var Ah=[`text-graph-1`,`text-graph-2`,`text-graph-3`,`text-graph-4`,`text-graph-5`,`text-graph-6`],jh=e=>13+e*16,Mh=e=>Ah[e%Ah.length]??Ah[0];function Nh(e){let t=(0,$.c)(7),{rows:n,width:r,rowHeight:i}=e,a=n.length*i,o;t[0]!==i||t[1]!==n?(o=n.map((e,t)=>{let r=t*i+i*.5,a=n[t+1],o=e.lanesAfter.flatMap((r,i)=>{if(r==null||a==null)return[];let o=e.outgoing.includes(i)?jh(e.lane):jh(i),s=r===a.commit.oid?jh(a.lane):jh(i),c=[o];return o!==jh(i)&&n[t-1]?.lanesAfter[i]===r&&c.push(jh(i)),c.map(e=>({lane:i,startX:e,endX:s}))}),s=e.commit.parentOids.length>1;return(0,Z.jsxs)(`g`,{children:[o.map(e=>{let{lane:t,startX:n,endX:a}=e;return(0,Z.jsx)(`path`,{d:n===a?`M ${n} ${r} L ${a} ${r+i}`:`M ${n} ${r} C ${n} ${r+i*.5}, ${a} ${r+i*.5}, ${a} ${r+i}`,fill:`none`,stroke:`currentColor`,strokeWidth:Me,className:Mh(t)},`${t}-${n}`)}),(0,Z.jsx)(`circle`,{cx:jh(e.lane),cy:r,r:s?5:4,fill:s?`var(--card)`:`currentColor`,stroke:`currentColor`,strokeWidth:2,className:Mh(e.lane)})]},e.commit.oid)}),t[0]=i,t[1]=n,t[2]=o):o=t[2];let s;return t[3]!==a||t[4]!==o||t[5]!==r?(s=(0,Z.jsx)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute top-2 left-1.5`,"data-testid":`history-graph`,width:r,height:a,children:o}),t[3]=a,t[4]=o,t[5]=r,t[6]=s):s=t[6],s}function Ph(e){let t=(0,$.c)(47),{label:n,layout:r,history:i,selected:a,onSelect:o,sideLabel:s,highlightHead:c}=e,l=c!==void 0&&c,u,d,f,p,m,h,g,_;if(t[0]!==l||t[1]!==i.commits||t[2]!==i.snapshot||t[3]!==n||t[4]!==r||t[5]!==o||t[6]!==a||t[7]!==s){d=rh(i.commits),_=ih(d),u=r===`columns`?30:44;let e=i.snapshot?.tipOid,c=i.snapshot?.head.kind===`attached`?i.snapshot.head.ref:void 0;g=`relative py-2 pr-3 pl-1.5`,f=n,p=`flex flex-col`,m=Fh;let v;t[16]!==c||t[17]!==l||t[18]!==r||t[19]!==o||t[20]!==u||t[21]!==a||t[22]!==s||t[23]!==e||t[24]!==_?(v=t=>{let{commit:n}=t;return(0,Z.jsx)(`li`,{children:(0,Z.jsx)(kh,{commit:n,selected:a===n.oid,height:u,inset:_+8,layout:r,head:l&&n.oid===e,headRef:c,onSelect:e=>o(n.oid,e),openToSide:{label:s,open:()=>o(n.oid,!0)}})},n.oid)},t[16]=c,t[17]=l,t[18]=r,t[19]=o,t[20]=u,t[21]=a,t[22]=s,t[23]=e,t[24]=_,t[25]=v):v=t[25],h=d.map(v),t[0]=l,t[1]=i.commits,t[2]=i.snapshot,t[3]=n,t[4]=r,t[5]=o,t[6]=a,t[7]=s,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_}else u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15];let v;t[26]!==f||t[27]!==p||t[28]!==m||t[29]!==h?(v=(0,Z.jsx)(`ol`,{"aria-label":f,className:p,onKeyDown:m,children:h}),t[26]=f,t[27]=p,t[28]=m,t[29]=h,t[30]=v):v=t[30];let y;t[31]!==u||t[32]!==d||t[33]!==_?(y=(0,Z.jsx)(Nh,{rows:d,width:_,rowHeight:u}),t[31]=u,t[32]=d,t[33]=_,t[34]=y):y=t[34];let b;t[35]===_?b=t[36]:(b={paddingLeft:_},t[35]=_,t[36]=b);let x;t[37]===i?x=t[38]:(x=(0,Z.jsx)(Ih,{history:i}),t[37]=i,t[38]=x);let S;t[39]!==x||t[40]!==b?(S=(0,Z.jsx)(`div`,{style:b,children:x}),t[39]=x,t[40]=b,t[41]=S):S=t[41];let C;return t[42]!==S||t[43]!==g||t[44]!==v||t[45]!==y?(C=(0,Z.jsxs)(`div`,{className:g,children:[v,y,S]}),t[42]=S,t[43]=g,t[44]=v,t[45]=y,t[46]=C):C=t[46],C}function Fh(e){if(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=Array.from(e.currentTarget.querySelectorAll(`button[aria-pressed]`)),n=e.target instanceof Element?e.target.closest(`li`):null,r=t.findIndex(e=>e.closest(`li`)===n);if(r<0)return;e.preventDefault(),e.stopPropagation();let i=t[r+(e.key===`ArrowDown`?1:-1)];i&&(i.focus(),i.click())}function Ih(e){let t=(0,$.c)(11),{history:n}=e,r;t[0]===n?r=t[1]:(r=(0,Z.jsx)(Lh,{history:n}),t[0]=n,t[1]=r);let i;t[2]!==n.nextAfter||t[3]!==n.result?(i=n.nextAfter!==null&&n.nextAfter!==void 0&&!n.result.waiting&&!$t(n.result),t[2]=n.nextAfter,t[3]=n.result,t[4]=i):i=t[4];let a;t[5]!==n.readMore||t[6]!==i?(a=(0,Z.jsx)(bh,{enabled:i,onVisible:n.readMore}),t[5]=n.readMore,t[6]=i,t[7]=a):a=t[7];let o;return t[8]!==r||t[9]!==a?(o=(0,Z.jsxs)(Z.Fragment,{children:[r,a]}),t[8]=r,t[9]=a,t[10]=o):o=t[10],o}function Lh(e){let t=(0,$.c)(8),{history:n}=e;if(n.result.waiting){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 px-2 py-3 text-2xs text-muted-foreground`,children:[(0,Z.jsx)(mt,{className:`size-3.5`}),`Loading older commits…`]}),t[0]=e):e=t[0],e}if($t(n.result)){let e;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`span`,{children:`Couldn't load older commits`}),t[1]=e):e=t[1];let r;return t[2]===n.readMore?r=t[3]:(r=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-2 text-2xs text-muted-foreground`,children:[e,(0,Z.jsx)(Y,{size:`xs`,variant:`outline`,onClick:n.readMore,children:`Retry`})]}),t[2]=n.readMore,t[3]=r),r}if(n.nextAfter===null||n.nextAfter===void 0){let e;t[4]===n.boundary?e=t[5]:(e=Ip(n.boundary),t[4]=n.boundary,t[5]=e);let r;return t[6]===e?r=t[7]:(r=(0,Z.jsx)(`p`,{className:`px-2 py-3 text-2xs text-muted-foreground`,children:e}),t[6]=e,t[7]=r),r}return null}function Rh(e,t){let n=(0,$.c)(4),r=t===void 0?`scrollOffset`:t,i=N(oe),a;return n[0]!==e||n[1]!==r||n[2]!==i?(a={ref:t=>{if(!t)return;let n=t.querySelector(`[data-slot="scroll-area-viewport"]`)??t;n.scrollTop=i.get(e)[r]},onScrollCapture:t=>{t.target instanceof HTMLElement&&i.set(e,{...i.get(e),[r]:t.target.scrollTop})}},n[0]=e,n[1]=r,n[2]=i,n[3]=a):a=n[3],a}function zh(e){let t=(0,$.c)(18),{scope:n,connection:r,selected:i,onSelect:a,sideLabel:o,onOpenGraph:s,onOpenChanges:c}=e,l=vh(r,n),u=Pt(xt(sa(n,r))),d=Lp(u?.branch,l.snapshot),p=u?.changes.length??0,m;t[0]!==r||t[1]!==n?(m=lh({connection:r,scope:n,kind:`commits`}),t[0]=r,t[1]=n,t[2]=m):m=t[2];let h=Rh(m),g;t[3]===l?g=t[4]:(g=(0,Z.jsx)(Vh,{history:l}),t[3]=l,t[4]=g);let _=ti,v=p>0&&(0,Z.jsx)(`div`,{className:`pt-2 pr-3 pl-1.5`,children:(0,Z.jsxs)(`button`,{type:`button`,onClick:c,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2 text-left text-caption transition-colors hover:bg-accent`,children:[(0,Z.jsx)(tc,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Z.jsx)(X,{className:`flex-1`,text:`Uncommitted changes`}),(0,Z.jsx)(`span`,{className:`text-2xs text-muted-foreground tabular-nums`,children:R(p,`file`)})]})}),y;t[5]!==l||t[6]!==a||t[7]!==i||t[8]!==o?(y=l.commits.length===0?(0,Z.jsx)(Hh,{}):(0,Z.jsx)(Ph,{label:`Commits`,layout:`stacked`,history:l,selected:i||l.selected||``,onSelect:(e,t)=>{l.select(e),a(e,t)},sideLabel:o}),t[5]=l,t[6]=a,t[7]=i,t[8]=o,t[9]=y):y=t[9];let b;t[10]!==_||t[11]!==h||t[12]!==v||t[13]!==y?(b=(0,Z.jsxs)(_,{className:`min-h-0 flex-initial`,role:`region`,"aria-label":`History reading area`,...h,children:[v,y]}),t[10]=_,t[11]=h,t[12]=v,t[13]=y,t[14]=b):b=t[14];let x;return t[15]!==l.commits.length||t[16]!==s?(x=l.commits.length>0&&(0,Z.jsx)(`div`,{className:`shrink-0 border-t p-1.5`,children:(0,Z.jsxs)(Y,{variant:`ghost`,className:`w-full justify-start`,onClick:s,children:[(0,Z.jsx)(hc,{}),`Open graph`,(0,Z.jsx)(f,{className:`ml-auto text-muted-foreground`})]})}),t[15]=l.commits.length,t[16]=s,t[17]=x):x=t[17],(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Z.jsx)(`section`,{"aria-label":`Branch`,className:`flex shrink-0 border-b px-3.5 py-2.5`,children:(0,Z.jsx)(_h,{tracking:d})}),g,b,x]})}function Bh(e){let t=(0,$.c)(7),{history:n}=e,r;t[0]===n.snapshot?r=t[1]:(r=n.snapshot!==null&&n.snapshot!==void 0&&(0,Z.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 border-b px-3.5 font-mono text-caption leading-4 text-muted-foreground`,children:[(0,Z.jsx)(hr,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(X,{className:`min-w-0 flex-1 font-medium text-foreground`,text:Fp(n.snapshot)})]}),t[0]=n.snapshot,t[1]=r);let i;t[2]===n?i=t[3]:(i=(0,Z.jsx)(Vh,{history:n}),t[2]=n,t[3]=i);let a;return t[4]!==r||t[5]!==i?(a=(0,Z.jsxs)(Z.Fragment,{children:[r,i]}),t[4]=r,t[5]=i,t[6]=a):a=t[6],a}function Vh(e){let t=(0,$.c)(1),{history:n}=e;if(!n.restarted)return null;let r;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`p`,{role:`status`,className:`shrink-0 border-b bg-muted/40 px-3.5 py-2 text-2xs text-muted-foreground`,children:`History changed. Showing it from the top.`}),t[0]=r):r=t[0],r}function Hh(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(kr,{children:(0,Z.jsxs)(Kn,{children:[(0,Z.jsx)(Ai,{children:`No commits yet`}),(0,Z.jsx)(Ni,{children:`Commits will appear here once this worktree has history.`})]})}),e[0]=t):t=e[0],t}function Uh(e){let t=(0,$.c)(14),{scope:n,connection:r,onSelect:i,sideLabel:a}=e,o=vh(r,n),s=zt(),c;t[0]!==r||t[1]!==n?(c=lh({connection:r,scope:n,kind:`commits`}),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=Rh(c,`graphScrollOffset`),u;t[3]===o?u=t[4]:(u=(0,Z.jsx)(Bh,{history:o}),t[3]=o,t[4]=u);let d;t[5]!==o||t[6]!==i||t[7]!==s||t[8]!==a?(d=o.commits.length===0?(0,Z.jsx)(Hh,{}):(0,Z.jsx)(Ph,{label:`Commit graph`,highlightHead:!0,layout:s?`stacked`:`columns`,history:o,selected:o.selected??``,onSelect:(e,t)=>{o.select(e),i(e,t)},sideLabel:a}),t[5]=o,t[6]=i,t[7]=s,t[8]=a,t[9]=d):d=t[9];let f;return t[10]!==l||t[11]!==u||t[12]!==d?(f=(0,Z.jsxs)(`div`,{className:`@container/graph flex min-h-0 flex-1 flex-col overflow-auto`,role:`region`,"aria-label":`Graph reading area`,...l,children:[u,d]}),t[10]=l,t[11]=u,t[12]=d,t[13]=f):f=t[13],f}function Wh(e,t,n){let r=(0,$.c)(6),i={connection:e,scope:t,path:n},{value:a,result:o}=as(mh(i)),s=c(fh(i)),l;r[0]===s?l=r[1]:(l=()=>s(void 0),r[0]=s,r[1]=l);let u;return r[2]!==o||r[3]!==l||r[4]!==a?(u={...a,result:o,readMore:l},r[2]=o,r[3]=l,r[4]=a,r[5]=u):u=r[5],u}function Gh(e){let t=(0,$.c)(34),{scope:n,connection:r,path:i,onSelect:a,sideLabel:o}=e,s=Wh(r,n,i),l;t[0]!==r||t[1]!==i||t[2]!==n?(l=lh({connection:r,scope:n,kind:`file`,path:i}),t[0]=r,t[1]=i,t[2]=n,t[3]=l):l=t[3];let u=l,d=N(u,Kh),f=c(u),p=Rh(u),m;t[4]!==a||t[5]!==f?(m=(e,t)=>{f(t=>({...t,selected:e.commit.oid})),a({oid:e.commit.oid,path:e.path},t)},t[4]=a,t[5]=f,t[6]=m):m=t[6];let h=m;if(s.commits.length===0&&s.nextAfter===null){let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(kr,{children:(0,Z.jsxs)(Kn,{children:[(0,Z.jsx)(Ai,{children:`No commits touch this file`}),(0,Z.jsx)(Ni,{children:`Its timeline starts with the first commit that includes it.`})]})}),t[7]=e):e=t[7],e}let g=`Timeline of ${i}`,_;if(t[8]!==h||t[9]!==i||t[10]!==d||t[11]!==o||t[12]!==s.commits){let e;t[14]!==h||t[15]!==i||t[16]!==d||t[17]!==o?(e=e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(kh,{commit:e.commit,selected:d===e.commit.oid,onSelect:t=>h(e,t),openToSide:{label:o,open:()=>h(e,!0)},children:(0,Z.jsx)(X,{className:`text-2xs text-muted-foreground`,text:Ep(e,i)})})},e.commit.oid),t[14]=h,t[15]=i,t[16]=d,t[17]=o,t[18]=e):e=t[18],_=s.commits.map(e),t[8]=h,t[9]=i,t[10]=d,t[11]=o,t[12]=s.commits,t[13]=_}else _=t[13];let v;t[19]===s.restarted?v=t[20]:(v=s.restarted&&(0,Z.jsx)(`span`,{role:`status`,children:`History changed. Showing it from the top.`}),t[19]=s.restarted,t[20]=v);let y;t[21]===s?y=t[22]:(y=(0,Z.jsx)(qh,{timeline:s}),t[21]=s,t[22]=y);let b;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(`span`,{children:`A merge appears only when its own result changed the file.`}),t[23]=b):b=t[23];let x;t[24]!==v||t[25]!==y?(x=(0,Z.jsxs)(`li`,{className:`flex flex-col gap-1 px-2 py-3 text-2xs text-muted-foreground`,children:[v,y,b]}),t[24]=v,t[25]=y,t[26]=x):x=t[26];let S;t[27]!==g||t[28]!==_||t[29]!==x?(S=(0,Z.jsxs)(`ol`,{"aria-label":g,className:`flex flex-col p-2`,children:[_,x]}),t[27]=g,t[28]=_,t[29]=x,t[30]=S):S=t[30];let C;return t[31]!==p||t[32]!==S?(C=(0,Z.jsx)(`div`,{role:`region`,"aria-label":`Timeline reading area`,className:`min-h-0 flex-1 overflow-auto`,...p,children:S}),t[31]=p,t[32]=S,t[33]=C):C=t[33],C}function Kh(e){return e.selected}function qh(e){let t=(0,$.c)(8),{timeline:n}=e;if($t(n.result)){let e;return t[0]===n.readMore?e=t[1]:(e=(0,Z.jsxs)(`div`,{role:`status`,children:[`Couldn't load older commits`,(0,Z.jsx)(Y,{size:`xs`,variant:`outline`,onClick:n.readMore,children:`Retry`})]}),t[0]=n.readMore,t[1]=e),e}if(n.nextAfter){let e=n.result.waiting?`Loading older commits…`:`Load older commits`,r;return t[2]!==e||t[3]!==n.readMore||t[4]!==n.result.waiting?(r=(0,Z.jsx)(Y,{size:`sm`,variant:`outline`,disabled:n.result.waiting,onClick:n.readMore,children:e}),t[2]=e,t[3]=n.readMore,t[4]=n.result.waiting,t[5]=r):r=t[5],r}let r=n.boundary===`shallow`?`Shallow clone: older history is not available.`:`Start of this file’s history.`,i;return t[6]===r?i=t[7]:(i=(0,Z.jsx)(`span`,{children:r}),t[6]=r,t[7]=i),i}function Jh(){let e=globalThis.crypto;if(typeof e?.randomUUID==`function`)return e.randomUUID();let t=URL.createObjectURL(new Blob);return URL.revokeObjectURL(t),t.slice(t.lastIndexOf(`/`)+1)}function Yh(e){let t=(0,$.c)(2),n;return t[0]===e.connection?n=t[1]:(n=tn(e.connection),t[0]=e.connection,t[1]=n),N(n)}var Xh=j(`BrowserCommitDraft.submit`)(function*(e,t,n){return yield*Je(Ve(function*(){let r=yield*ne(st(),e=>It(e,_t)),i=new AbortController,a=()=>{ln(It(r,_t))};return yield*ne($e(()=>{t.add(i),i.signal.addEventListener(`abort`,a,{once:!0})}),()=>$e(()=>{i.signal.removeEventListener(`abort`,a),t.delete(i)})),yield*e(n,r)}))});function Zh(e,t,n){let r=(0,$.c)(12),i;r[0]!==t.connection||r[1]!==e?(i=lt({connection:t.connection,scope:e}),r[0]=t.connection,r[1]=e,r[2]=i):i=r[2];let{value:a}=as(i),o;r[3]!==t.connection||r[4]!==e?(o=Rt({connection:t.connection,scope:e}),r[3]=t.connection,r[4]=e,r[5]=o):o=r[5];let s=N(o),c;r[6]!==n||r[7]!==a?(c=e=>Xh(a,n,e),r[6]=n,r[7]=a,r[8]=c):c=r[8];let l;return r[9]!==s||r[10]!==c?(l={result:s,submit:c},r[9]=s,r[10]=c,r[11]=l):l=r[11],l}function Qh(e,n,r,i){let a=(0,$.c)(121),{scope:o,status:s,action:c,onBusy:l,onLookAgain:u,initialMessage:d,lastCommitMessage:f}=e,p=c===void 0?`commit`:c,m=d===void 0?``:d,h=f===void 0?``:f,g;a[0]!==p||a[1]!==m||a[2]!==h?(g=em(p,m,h),a[0]=p,a[1]=m,a[2]=h,a[3]=g):g=a[3];let _;a[4]===g?_=a[5]:(_={defaultValues:g},a[4]=g,a[5]=_);let v=bs(_),y;a[6]===v?y=a[7]:(y=fm(v),a[6]=v,a[7]=y);let b=y,x;a[8]===v?x=a[9]:(x=pm(v),a[8]=v,a[9]=x);let S=x,{mode:C,message:w,amendMessage:T,excluded:E,added:D,groups:O}=Do(v.store,ig),{done:k,activeGroup:A,ownHead:j,busy:M,error:N,drafted:P,draftedBy:F,editingFiles:I}=Te(b),L;a[10]===v?L=a[11]:(L=e=>v.setFieldValue(`mode`,e),a[10]=v,a[11]=L);let R=L,z;a[12]===v?z=a[13]:(z=e=>v.setFieldValue(`message`,e),a[12]=v,a[13]=z);let B=z,V;a[14]===v?V=a[15]:(V=e=>v.setFieldValue(`amendMessage`,e),a[14]=v,a[15]=V);let H=V,U;a[16]===v?U=a[17]:(U=e=>v.setFieldValue(`excluded`,e),a[16]=v,a[17]=U);let W=U,G;a[18]===v?G=a[19]:(G=e=>v.setFieldValue(`added`,e),a[18]=v,a[19]=G);let ee=G,te;a[20]===v?te=a[21]:(te=e=>v.setFieldValue(`groups`,e),a[20]=v,a[21]=te);let ne=te,re;a[22]===b?re=a[23]:(re=e=>b.update(t=>({...t,done:typeof e==`function`?e(t.done):e})),a[22]=b,a[23]=re);let ie=re,ae;a[24]===b?ae=a[25]:(ae=e=>b.update(t=>({...t,activeGroup:e})),a[24]=b,a[25]=ae);let K=ae,oe;a[26]===b?oe=a[27]:(oe=e=>b.update(t=>({...t,ownHead:e})),a[26]=b,a[27]=oe);let q=oe,se;a[28]===b?se=a[29]:(se=e=>b.update(t=>({...t,busy:e})),a[28]=b,a[29]=se);let ce=se,le;a[30]===b?le=a[31]:(le=e=>b.update(t=>({...t,error:e})),a[30]=b,a[31]=le);let ue=le,de=(e,t)=>{let n=t?.length===1?`1 selected file`:`${t?.length} selected files`;b.update(r=>({...r,drafted:{...r.drafted,[e]:t},draftedBy:{...r.draftedBy,[e]:t?`Generated by ${Pt(xt(me))?.find(e=>e.id===he)?.label??he} from ${n}`:null}}))},J=C===`amend`?`amend`:`commit`,fe=mm(o,J,n),pe=Zh(o,n,S),me=Yh(n),he=Zp(Pt(xt(me)),i.value),ge;if(a[32]!==E||a[33]!==r){let e;a[35]===E?e=a[36]:(e=e=>!E.has(e.path),a[35]=E,a[36]=e),ge=new Set(r.filter(e).flatMap(rg)),a[32]=E,a[33]=r,a[34]=ge}else ge=a[34];let _e;a[37]===ge?_e=a[38]:(_e=[...ge],a[37]=ge,a[38]=_e);let ve=_e,ye;if(a[39]!==D||a[40]!==r){let e;a[42]===D?e=a[43]:(e=e=>D.has(e.path),a[42]=D,a[43]=e),ye=new Set(r.filter(e).flatMap(ng)),a[39]=D,a[40]=r,a[41]=ye}else ye=a[41];let be;a[44]===ye?be=a[45]:(be=[...ye],a[44]=ye,a[45]=be);let xe=J===`amend`?be:ve,Se=J===`amend`?T:w,Ce=!(!fe.operation||fe.canStartNew),we=fe.operation?.receipt,Ee=M||pe.result.waiting||fe.recovered.waiting,De=O?P.groups:P.message,Oe;a[46]!==De||a[47]!==J||a[48]!==k||a[49]!==O||a[50]!==s?(Oe=J===`commit`&&De!=null&&tm(s,De,new Set((O??[]).filter(e=>k.has(e.id)).flatMap(tg))),a[46]=De,a[47]=J,a[48]=k,a[49]=O,a[50]=s,a[51]=Oe):Oe=a[51];let ke=Oe,Ae;a[52]!==r||a[53]!==O?(Ae=O?r.filter(e=>!O.some(t=>t.paths.includes(e.path))):[],a[52]=r,a[53]=O,a[54]=Ae):Ae=a[54];let Me=Ae,Ne;a[55]!==J||a[56]!==Se||a[57]!==k||a[58]!==O||a[59]!==C||a[60]!==xe||a[61]!==ke||a[62]!==s?(Ne=ke||(C===`groups`?!O?.length||O.filter(e=>!k.has(e.id)).some(eg):!Se.trim()||J!==`amend`&&s.inProgress!==`merge`&&!xe.length),a[55]=J,a[56]=Se,a[57]=k,a[58]=O,a[59]=C,a[60]=xe,a[61]=ke,a[62]=s,a[63]=Ne):Ne=a[63];let Pe=Ne,Fe;a[64]===s?Fe=a[65]:(Fe=je(`commit`,s),a[64]=s,a[65]=Fe);let Ie=Fe,Le;a[66]===s?Le=a[67]:(Le=je(`amend`,s),a[66]=s,a[67]=Le);let Re=Le,ze;a[68]===u?ze=a[69]:(ze=u?t({try:u,catch:$h}):void 0,a[68]=u,a[69]=ze);let Be;return a[70]!==A||a[71]!==D||a[72]!==T||a[73]!==Re||a[74]!==Pe||a[75]!==M||a[76]!==J||a[77]!==Ie||a[78]!==ve||a[79]!==S||a[80]!==Se||a[81]!==k||a[82]!==P||a[83]!==F||a[84]!==I||a[85]!==N||a[86]!==E||a[87]!==r||a[88]!==v||a[89]!==pe||a[90]!==fe||a[91]!==O||a[92]!==Me||a[93]!==w||a[94]!==C||a[95]!==he||a[96]!==me||a[97]!==l||a[98]!==j||a[99]!==xe||a[100]!==we||a[101]!==o||a[102]!==K||a[103]!==ee||a[104]!==H||a[105]!==ce||a[106]!==ie||a[107]!==de||a[108]!==ue||a[109]!==W||a[110]!==ne||a[111]!==B||a[112]!==R||a[113]!==q||a[114]!==ke||a[115]!==b||a[116]!==s||a[117]!==ze||a[118]!==Ce||a[119]!==Ee?(Be={scope:o,status:s,onBusy:l,onLookAgain:ze,createId:Jh,mode:C,commitAction:J,git:fe,generator:pe,models:me,model:he,message:w,amendMessage:T,editingFiles:I,excluded:E,added:D,groups:O,done:k,activeGroup:A,ownHead:j,busy:M,error:N,drafted:P,draftedBy:F,files:r,commitPaths:ve,paths:xe,currentMessage:Se,uncertain:Ce,receipt:we,working:Ee,staleDraft:ke,leftUncommitted:Me,blocker:Pe,commitModeBlocker:Ie,amendModeBlocker:Re,controllers:S,form:v,setMode:R,setMessage:B,setAmendMessage:H,setExcluded:W,setAdded:ee,setGroups:ne,setDone:ie,setActiveGroup:K,setOwnHead:q,setBusy:ce,setError:ue,setDrafted:de,state:b},a[70]=A,a[71]=D,a[72]=T,a[73]=Re,a[74]=Pe,a[75]=M,a[76]=J,a[77]=Ie,a[78]=ve,a[79]=S,a[80]=Se,a[81]=k,a[82]=P,a[83]=F,a[84]=I,a[85]=N,a[86]=E,a[87]=r,a[88]=v,a[89]=pe,a[90]=fe,a[91]=O,a[92]=Me,a[93]=w,a[94]=C,a[95]=he,a[96]=me,a[97]=l,a[98]=j,a[99]=xe,a[100]=we,a[101]=o,a[102]=K,a[103]=ee,a[104]=H,a[105]=ce,a[106]=ie,a[107]=de,a[108]=ue,a[109]=W,a[110]=ne,a[111]=B,a[112]=R,a[113]=q,a[114]=ke,a[115]=b,a[116]=s,a[117]=ze,a[118]=Ce,a[119]=Ee,a[120]=Be):Be=a[120],Be}function $h(e){return new Ut(e,Cn(e))}function eg(e){return!e.message.trim()||!e.paths.length}function tg(e){return e.paths}function ng(e){return e.paths}function rg(e){return e.paths}function ig(e){return e.values}function ag(e,t,n,r){let i=(0,$.c)(46),a=Qh(e,t,n,r),{state:o,form:s,commitAction:c,setMode:l,setGroups:u,setDrafted:d,setAmendMessage:f,setMessage:p,setAdded:m,setExcluded:h}=a,g,_,v,y;i[0]===a?(g=i[1],_=i[2],v=i[3],y=i[4]):(g=()=>ln(Ye(a)),_=()=>ln(Ke(a,a.mode===`groups`?`groups`:`message`)),v=()=>ln(et(a)),y=()=>ln(xe(a)),i[0]=a,i[1]=g,i[2]=_,i[3]=v,i[4]=y);let b;i[5]===o?b=i[6]:(b=()=>o.update(og),i[5]=o,i[6]=b);let x;i[7]!==c||i[8]!==f||i[9]!==p?(x=e=>{c===`amend`?f(e):p(e)},i[7]=c,i[8]=f,i[9]=p,i[10]=x):x=i[10];let S;i[11]!==d||i[12]!==u||i[13]!==l?(S=e=>{(e===`single`||e===`amend`||e===`groups`)&&(l(e),e===`single`&&(u(null),d(`groups`,null)))},i[11]=d,i[12]=u,i[13]=l,i[14]=S):S=i[14];let C;i[15]!==c||i[16]!==s||i[17]!==m||i[18]!==h?(C=(e,t)=>{if(c===`amend`){let n=new Set(s.state.values.added);t?n.add(e):n.delete(e),m(n)}else{let n=new Set(s.state.values.excluded);t?n.delete(e):n.add(e),h(n)}},i[15]=c,i[16]=s,i[17]=m,i[18]=h,i[19]=C):C=i[19];let w,T,E,D;i[20]!==s||i[21]!==u?(E=e=>u(s.state.values.groups?.filter(t=>t.id!==e)??null),D=(e,t)=>u(s.state.values.groups?.map(n=>n.id===e?{...n,message:t}:n)??null),w=(e,t)=>u(s.state.values.groups?.map(n=>({...n,paths:[...n.paths.filter(t=>!e.includes(t)),...n.id===t?e:[]]}))??null),T=()=>u([...s.state.values.groups??[],{id:Jh(),message:``,paths:[]}]),i[20]=s,i[21]=u,i[22]=w,i[23]=T,i[24]=E,i[25]=D):(w=i[22],T=i[23],E=i[24],D=i[25]);let O;i[26]!==d||i[27]!==u||i[28]!==l?(O=()=>{l(`single`),u(null),d(`groups`,null)},i[26]=d,i[27]=u,i[28]=l,i[29]=O):O=i[29];let k;return i[30]!==r.set||i[31]!==a||i[32]!==g||i[33]!==_||i[34]!==w||i[35]!==T||i[36]!==O||i[37]!==v||i[38]!==y||i[39]!==b||i[40]!==x||i[41]!==S||i[42]!==C||i[43]!==E||i[44]!==D?(k={...a,messageLimit:hn,groupLimit:20,commit:g,generate:_,lookAgain:v,checkOutcome:y,setModel:r.set,toggleEditingFiles:b,setCurrentMessage:x,setMode:S,setIncluded:C,removeGroup:E,setGroupMessage:D,moveFile:w,addGroup:T,clearGroups:O},i[30]=r.set,i[31]=a,i[32]=g,i[33]=_,i[34]=w,i[35]=T,i[36]=O,i[37]=v,i[38]=y,i[39]=b,i[40]=x,i[41]=S,i[42]=C,i[43]=E,i[44]=D,i[45]=k):k=i[45],k}function og(e){return{...e,editingFiles:!e.editingFiles}}var sg=x(e=>u(t=>{t.addFinalizer(()=>{for(let t of e)t.abort();e.clear()})}));function cg(e){let t=(0,$.c)(2),n;t[0]===e?n=t[1]:(n=sg(e),t[0]=e,t[1]=n),ie(n)}function lg(e){let t=(0,$.c)(102),{status:r,liveBranch:i,onLookAgain:a}=e,{preferences:o,setPreference:s}=Ha(),c=e.context,l;t[0]===e.status.changes?l=t[1]:(l=Ql(e.status.changes),t[0]=e.status.changes,t[1]=l);let u;t[2]===s?u=t[3]:(u=e=>s(`commitModel`,e),t[2]=s,t[3]=u);let d;t[4]!==o.commitModel||t[5]!==u?(d={value:o.commitModel,set:u},t[4]=o.commitModel,t[5]=u,t[6]=d):d=t[6];let f=ag(e,c,l,d);cg(f.controllers);let{mode:p,commitAction:m,git:h,model:g,groups:_,done:v,commitPaths:y,uncertain:b,receipt:x,working:S,error:C,staleDraft:w,blocker:T,commitModeBlocker:E,amendModeBlocker:D}=f,O,k;t[7]!==T||t[8]!==f||t[9]!==b||t[10]!==S?(O=e=>{e.preventDefault(),T||S||b||f.commit()},k=e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),T||S||b||f.commit())},t[7]=T,t[8]=f,t[9]=b,t[10]=S,t[11]=O,t[12]=k):(O=t[11],k=t[12]);let A=m===`amend`?`Amend last commit`:`Commit changes`,j;t[13]===A?j=t[14]:(j=(0,Z.jsx)(Zi,{children:A}),t[13]=A,t[14]=j);let M=m===`amend`?`The last commit is replaced by one with this message and the files you add.`:`Committed steps fold away in the review and show up in History.`,N;t[15]===M?N=t[16]:(N=(0,Z.jsx)(ta,{children:M}),t[15]=M,t[16]=N);let P;t[17]!==j||t[18]!==N?(P=(0,Z.jsxs)(Ui,{children:[j,N]}),t[17]=j,t[18]=N,t[19]=P):P=t[19];let F=i??void 0,I;t[20]===F?I=t[21]:(I=Lp(F,null),t[20]=F,t[21]=I);let L;t[22]===I?L=t[23]:(L=(0,Z.jsx)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/50 px-3 py-2 text-caption`,children:(0,Z.jsx)(_h,{tracking:I})}),t[22]=I,t[23]=L);let R;t[24]!==D||t[25]!==E||t[26]!==y||t[27]!==f.setMode||t[28]!==p||t[29]!==g||t[30]!==r.inProgress||t[31]!==S?(R=r.inProgress!==`merge`&&(0,Z.jsx)(Ds,{value:p,onValueChange:f.setMode,children:(0,Z.jsxs)(Ts,{className:`w-full`,children:[(0,Z.jsx)(fo,{value:`single`,className:`flex-1`,disabled:S||E!=null,children:`Single commit`}),(0,Z.jsx)(fo,{value:`amend`,className:`flex-1`,disabled:S||D!=null,children:`Amend last`}),(0,Z.jsx)(fo,{value:`groups`,className:`flex-1`,disabled:S||E!=null||!g||!y.length,children:`Use groups`})]})}),t[24]=D,t[25]=E,t[26]=y,t[27]=f.setMode,t[28]=p,t[29]=g,t[30]=r.inProgress,t[31]=S,t[32]=R):R=t[32];let z=S||b,B;t[33]!==f||t[34]!==p?(B=p===`groups`?(0,Z.jsx)(bg,{form:f}):(0,Z.jsx)(fg,{form:f}),t[33]=f,t[34]=p,t[35]=B):B=t[35];let V;t[36]!==z||t[37]!==B?(V=(0,Z.jsx)(`fieldset`,{disabled:z,className:`flex min-w-0 flex-col gap-3`,children:B}),t[36]=z,t[37]=B,t[38]=V):V=t[38];let H;t[39]!==m||t[40]!==f?(H=m===`commit`&&(0,Z.jsx)(pg,{form:f}),t[39]=m,t[40]=f,t[41]=H):H=t[41];let U;t[42]!==f.currentMessage||t[43]!==p?(U=p!==`groups`&&!f.currentMessage.trim()&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,role:`status`,children:`Write or generate a message before committing.`}),t[42]=f.currentMessage,t[43]=p,t[44]=U):U=t[44];let W;t[45]===w?W=t[46]:(W=w&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-graph-4`,children:`The worktree changed since this draft was proposed. Generate it again before committing.`}),t[45]=w,t[46]=W);let G;t[47]!==m||t[48]!==e?(G=Eg(e,m),t[47]=m,t[48]=e,t[49]=G):G=t[49];let ee;t[50]===G?ee=t[51]:(ee=(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:G}),t[50]=G,t[51]=ee);let te;t[52]!==C||t[53]!==x?(te=x&&!(C&&Zt(x))&&(0,Z.jsxs)(`div`,{role:`status`,className:`text-sm`,children:[(0,Z.jsx)(`p`,{children:x.state}),x.progress.map(dg)]}),t[52]=C,t[53]=x,t[54]=te):te=t[54];let ne;t[55]!==x||t[56]!==b?(ne=b&&!x&&(0,Z.jsx)(`p`,{role:`status`,children:`Outcome not yet confirmed`}),t[55]=x,t[56]=b,t[57]=ne):ne=t[57];let re;t[58]===C?re=t[59]:(re=C?(0,Z.jsx)(wm,{text:Cn(C)}):null,t[58]=C,t[59]=re);let ie;t[60]!==f.lookAgain||t[61]!==a||t[62]!==x||t[63]!==w||t[64]!==S?(ie=(w||x&&n(x))&&a&&(0,Z.jsx)(Y,{type:`button`,variant:`outline`,disabled:S,onClick:f.lookAgain,children:`Look again`}),t[60]=f.lookAgain,t[61]=a,t[62]=x,t[63]=w,t[64]=S,t[65]=ie):ie=t[65];let ae;t[66]!==f.checkOutcome||t[67]!==h.operation||t[68]!==S?(ae=h.operation&&!S&&(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:f.checkOutcome,children:`Check outcome`}),t[66]=f.checkOutcome,t[67]=h.operation,t[68]=S,t[69]=ae):ae=t[69];let K;t[70]!==T||t[71]!==v||t[72]!==_||t[73]!==p||t[74]!==x||t[75]!==r.changes||t[76]!==r.inProgress||t[77]!==b||t[78]!==S?(K=S||b||!!(x&&n(x))||T||r.inProgress!==`merge`&&r.changes.some(ug)||!!(p===`groups`&&_?.every(e=>v.has(e.id))),t[70]=T,t[71]=v,t[72]=_,t[73]=p,t[74]=x,t[75]=r.changes,t[76]=r.inProgress,t[77]=b,t[78]=S,t[79]=K):K=t[79];let oe;t[80]===f?oe=t[81]:(oe=Dg(f),t[80]=f,t[81]=oe);let q;t[82]!==K||t[83]!==oe?(q=(0,Z.jsx)(Y,{type:`submit`,disabled:K,children:oe}),t[82]=K,t[83]=oe,t[84]=q):q=t[84];let se;return t[85]!==P||t[86]!==L||t[87]!==R||t[88]!==V||t[89]!==H||t[90]!==U||t[91]!==W||t[92]!==ee||t[93]!==te||t[94]!==ne||t[95]!==re||t[96]!==ie||t[97]!==ae||t[98]!==q||t[99]!==O||t[100]!==k?(se=(0,Z.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:O,onKeyDown:k,children:[P,L,R,V,H,U,W,ee,te,ne,re,ie,ae,q]}),t[85]=P,t[86]=L,t[87]=R,t[88]=V,t[89]=H,t[90]=U,t[91]=W,t[92]=ee,t[93]=te,t[94]=ne,t[95]=re,t[96]=ie,t[97]=ae,t[98]=q,t[99]=O,t[100]=k,t[101]=se):se=t[101],se}function ug(e){return e.scope===`unmerged`}function dg(e){return(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e},e)}function fg(e){let t=(0,$.c)(47),{form:n}=e,{commitAction:r,editingFiles:i,excluded:a,added:o,files:s,paths:c,currentMessage:l,working:u}=n,d=r===`amend`?`Files to add`:`Files`,f;t[0]===d?f=t[1]:(f=(0,Z.jsx)(`span`,{className:`font-medium`,children:d}),t[0]=d,t[1]=f);let p;t[2]!==s.length||t[3]!==c.length?(p=(0,Z.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[`(`,c.length,` of `,s.length,`)`]}),t[2]=s.length,t[3]=c.length,t[4]=p):p=t[4];let m;t[5]!==r||t[6]!==i||t[7]!==s.length||t[8]!==n||t[9]!==u?(m=r===`commit`&&s.length>0&&(0,Z.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,className:`ml-auto`,disabled:u,onClick:()=>n.toggleEditingFiles(),children:i?`Done`:`Edit`}),t[5]=r,t[6]=i,t[7]=s.length,t[8]=n,t[9]=u,t[10]=m):m=t[10];let h;t[11]!==f||t[12]!==p||t[13]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-caption`,children:[f,p,m]}),t[11]=f,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;if(t[15]!==o||t[16]!==r||t[17]!==i||t[18]!==a||t[19]!==s||t[20]!==n){let e;t[22]!==o||t[23]!==r||t[24]!==i||t[25]!==a||t[26]!==n?(e=e=>{let t=r===`amend`?o.has(e.path):!a.has(e.path),s=r===`amend`||i,c=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(gi,{path:e.path,className:`size-3.5 shrink-0`}),(0,Z.jsx)(X,{className:`min-w-0 flex-1`,text:e.path}),(0,Z.jsx)(`span`,{"aria-hidden":s,className:`shrink-0 text-muted-foreground`,children:wg(e.kind,t,r)})]});return s?(0,Z.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 rounded-lg px-2 py-1 text-xs hover:bg-muted`,children:[(0,Z.jsx)(Xm,{checked:t,onCheckedChange:t=>n.setIncluded(e.path,t)}),c]},e.path):(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-lg px-2 py-1 text-xs`,children:c},e.path)},t[22]=o,t[23]=r,t[24]=i,t[25]=a,t[26]=n,t[27]=e):e=t[27],g=s.map(e),t[15]=o,t[16]=r,t[17]=i,t[18]=a,t[19]=s,t[20]=n,t[21]=g}else g=t[21];let _;t[28]===g?_=t[29]:(_=(0,Z.jsx)(`div`,{className:`max-h-40 overflow-auto rounded-xl border p-1`,children:g}),t[28]=g,t[29]=_);let v;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Dt,{htmlFor:`commit-message`,children:`Message`}),t[30]=v):v=t[30];let y;t[31]!==r||t[32]!==n.draftedBy?(y=r===`commit`&&n.draftedBy.message&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.draftedBy.message}),t[31]=r,t[32]=n.draftedBy,t[33]=y):y=t[33];let b;t[34]===n?b=t[35]:(b=e=>n.setCurrentMessage(e.target.value),t[34]=n,t[35]=b);let x;t[36]!==l||t[37]!==n.messageLimit||t[38]!==b?(x=(0,Z.jsx)(Lr,{id:`commit-message`,value:l,onChange:b,rows:4,maxLength:n.messageLimit,placeholder:`Describe what changed and why`}),t[36]=l,t[37]=n.messageLimit,t[38]=b,t[39]=x):x=t[39];let S;t[40]!==x||t[41]!==y?(S=(0,Z.jsxs)(Wt,{children:[v,y,x]}),t[40]=x,t[41]=y,t[42]=S):S=t[42];let C;return t[43]!==S||t[44]!==h||t[45]!==_?(C=(0,Z.jsxs)(Z.Fragment,{children:[h,_,S]}),t[43]=S,t[44]=h,t[45]=_,t[46]=C):C=t[46],C}function pg(e){let t=(0,$.c)(57),{form:n}=e,{models:r,model:i}=n,a,o,s,c,l,u,d,f,p,m,h,g;if(t[0]!==n||t[1]!==i||t[2]!==r){let e=Pt(xt(r));s=e?.find(e=>e.id===i);let _;t[15]===n?_=t[16]:(_=vg(n),t[15]=n,t[16]=_),c=_,h=`flex flex-wrap items-center gap-2`;let v=!!c||n.working||n.uncertain,y;t[17]===n?y=t[18]:(y=()=>n.generate(),t[17]=n,t[18]=y);let b;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(jc,{}),t[19]=b):b=t[19];let x=n.generator.result.waiting?`Generating…`:`Generate with AI`;t[20]!==v||t[21]!==y||t[22]!==x?(g=(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:v,onClick:y,children:[b,x]}),t[20]=v,t[21]=y,t[22]=x,t[23]=g):g=t[23],o=S,u=e?.map(_g)??[],d=i??null,f=!e?.length||n.working||n.uncertain,t[24]===n?p=t[25]:(p=e=>{e&&n.setModel(e)},t[24]=n,t[25]=p);let C=e?.length?`Choose a model`:`No coding CLI available`;t[26]===C?m=t[27]:(m=(0,Z.jsx)(Ge,{"aria-label":`Commit model`,className:`w-auto max-w-48`,size:`sm`,children:(0,Z.jsx)(Qe,{placeholder:C})}),t[26]=C,t[27]=m),a=G,l=Xp(e?.filter(gg)??[]).map(mg),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g}else a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14];let _;t[28]!==a||t[29]!==l?(_=(0,Z.jsx)(a,{children:l}),t[28]=a,t[29]=l,t[30]=_):_=t[30];let v;t[31]!==o||t[32]!==u||t[33]!==d||t[34]!==f||t[35]!==p||t[36]!==m||t[37]!==_?(v=(0,Z.jsxs)(o,{items:u,value:d,disabled:f,onValueChange:p,children:[m,_]}),t[31]=o,t[32]=u,t[33]=d,t[34]=f,t[35]=p,t[36]=m,t[37]=_,t[38]=v):v=t[38];let y;t[39]!==s?.label||t[40]!==i||t[41]!==c?(y=c??`Sends the selected changes to ${s?.label} through ${i?.split(`:`)[0]===`claude`?`Claude Code`:`Codex`}.`,t[39]=s?.label,t[40]=i,t[41]=c,t[42]=y):y=t[42];let b;t[43]===y?b=t[44]:(b=(0,Z.jsx)(`p`,{className:`w-full text-xs text-muted-foreground`,role:`status`,children:y}),t[43]=y,t[44]=b);let x;t[45]!==n.generate||t[46]!==n.generator.result||t[47]!==n.uncertain||t[48]!==n.working||t[49]!==c?(x=$t(n.generator.result)&&!n.working&&(0,Z.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:!!c||n.uncertain,onClick:n.generate,children:`Try again`}),t[45]=n.generate,t[46]=n.generator.result,t[47]=n.uncertain,t[48]=n.working,t[49]=c,t[50]=x):x=t[50];let C;return t[51]!==v||t[52]!==b||t[53]!==x||t[54]!==h||t[55]!==g?(C=(0,Z.jsxs)(`div`,{className:h,children:[g,v,b,x]}),t[51]=v,t[52]=b,t[53]=x,t[54]=h,t[55]=g,t[56]=C):C=t[56],C}function mg(e){let[t,n]=e;return(0,Z.jsxs)(cn,{children:[(0,Z.jsx)(qe,{children:t}),n.map(hg)]},t)}function hg(e){return(0,Z.jsx)(B,{value:e.id,children:e.label},e.id)}function gg(e){return!e.id.endsWith(`:default`)}function _g(e){return{value:e.id,label:e.label}}function vg({models:e,model:t,paths:n}){if($t(e))return`Could not load coding CLI models. You can still commit manually.`;let r=Pt(xt(e));return r?!t&&r.some(e=>!e.id.endsWith(`:default`))?`Choose a model to generate a message.`:t?n.length?null:`Select files to generate a message.`:`No coding CLI available. Write a message to commit manually.`:`Loading coding CLI models…`}function yg(e,t){return e?`Groups were not proposed.`:t?`Proposing commits…`:`Generate groups with AI, then review each message and file before committing.`}function bg(e){let t=(0,$.c)(34),{form:n}=e,{groups:r,done:i,activeGroup:a,files:o,leftUncommitted:s,error:c}=n;if(r===null){let e;t[0]!==c||t[1]!==n.working?(e=yg(c,n.working),t[0]=c,t[1]=n.working,t[2]=e):e=t[2];let r;return t[3]===e?r=t[4]:(r=(0,Z.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:e}),t[3]=e,t[4]=r),r}let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l={value:`uncommitted`,label:`Leave uncommitted`},t[5]=l):l=t[5];let u;t[6]===r?u=t[7]:(u=[l,...r.map(Cg)],t[6]=r,t[7]=u);let d=u,f;t[8]===n.draftedBy.groups?f=t[9]:(f=n.draftedBy.groups&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.draftedBy.groups}),t[8]=n.draftedBy.groups,t[9]=f);let p;t[10]!==a||t[11]!==d||t[12]!==i||t[13]!==o||t[14]!==n||t[15]!==r?(p=r.map((e,t)=>(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2 rounded-lg border p-3`,"aria-label":`Commit ${t+1}`,children:[(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Commit `,t+1,Tg(e.id,i,a)]}),e.paths.length===0&&i.size===0&&(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>n.removeGroup(e.id),children:`Remove empty group`}),(0,Z.jsx)(Lr,{"aria-label":`Message for commit ${t+1}`,value:e.message,disabled:i.has(e.id),required:!0,maxLength:n.messageLimit,onChange:t=>n.setGroupMessage(e.id,t.target.value)}),o.filter(t=>e.paths.includes(t.path)).map(t=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs`,children:[(0,Z.jsx)(X,{className:`min-w-0 flex-1`,text:t.path}),(0,Z.jsxs)(S,{items:d,value:e.id,disabled:i.size>0,onValueChange:e=>{e&&n.moveFile(t.paths,e)},children:[(0,Z.jsx)(Ge,{size:`sm`,"aria-label":`Commit for ${t.path}`,children:(0,Z.jsx)(Qe,{})}),(0,Z.jsxs)(G,{children:[(0,Z.jsx)(B,{value:`uncommitted`,children:`Leave uncommitted`}),r.map(Sg)]})]})]},t.path))]},e.id)),t[10]=a,t[11]=d,t[12]=i,t[13]=o,t[14]=n,t[15]=r,t[16]=p):p=t[16];let m;t[17]!==d||t[18]!==i.size||t[19]!==n||t[20]!==r||t[21]!==s?(m=s.length>0&&(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2 rounded-lg border border-dashed p-3`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Left uncommitted`}),s.map(e=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs`,children:[(0,Z.jsx)(X,{className:`min-w-0 flex-1`,text:e.path}),(0,Z.jsxs)(S,{items:d,value:`uncommitted`,disabled:i.size>0,onValueChange:t=>{t&&n.moveFile(e.paths,t)},children:[(0,Z.jsx)(Ge,{size:`sm`,"aria-label":`Commit for ${e.path}`,children:(0,Z.jsx)(Qe,{})}),(0,Z.jsxs)(G,{children:[(0,Z.jsx)(B,{value:`uncommitted`,children:`Leave uncommitted`}),r.map(xg)]})]})]},e.path))]}),t[17]=d,t[18]=i.size,t[19]=n,t[20]=r,t[21]=s,t[22]=m):m=t[22];let h;t[23]!==i.size||t[24]!==n.addGroup||t[25]!==n.clearGroups||t[26]!==n.groupLimit||t[27]!==r.length?(h=i.size===0&&(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:r.length>=n.groupLimit,onClick:n.addGroup,children:[(0,Z.jsx)(wr,{}),`Add group`]}),(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:n.clearGroups,children:`Single commit`})]}),t[23]=i.size,t[24]=n.addGroup,t[25]=n.clearGroups,t[26]=n.groupLimit,t[27]=r.length,t[28]=h):h=t[28];let g;return t[29]!==f||t[30]!==p||t[31]!==m||t[32]!==h?(g=(0,Z.jsxs)(Z.Fragment,{children:[f,p,m,h]}),t[29]=f,t[30]=p,t[31]=m,t[32]=h,t[33]=g):g=t[33],g}function xg(e,t){return(0,Z.jsxs)(B,{value:e.id,children:[`Commit `,t+1]},e.id)}function Sg(e,t){return(0,Z.jsxs)(B,{value:e.id,children:[`Commit `,t+1]},e.id)}function Cg(e,t){return{value:e.id,label:`Commit ${t+1}`}}function wg(e,t,n){return t?e.replaceAll(`-`,` `):n===`amend`?`Not added`:`Excluded`}function Tg(e,t,n){return t.has(e)?` · committed`:n===e?` · in progress`:``}function Eg({status:e,liveBranch:t,replacedSubject:n},r){return r===`amend`?`Amending replaces the last commit${n?`: ${n}`:``}. ${t?.upstream&&t.ahead===0?`This commit is already on the known upstream; amending rewrites shared history.`:`Unselected staged changes stay staged.`}`:e.inProgress===`merge`?`This finishes the merge and commits every staged resolution, including staged files outside your selection.`:`Selected files use their current contents. Other staged files stay staged.`}function Dg({working:e,generator:t,groups:n,commitAction:r}){return e?t.result.waiting?`Generating…`:r===`amend`?`Amending…`:`Committing…`:n&&r===`commit`?`Commit groups in order`:r===`amend`?`Amend last commit`:`Commit selected files`}function Og(e){let t=(0,$.c)(14),{scope:n,context:r,entry:i,status:a,onBusy:o,onLookAgain:s}=e;if(i===`switch`||i===`discard`||i===`fetch`||i===`pull`||i===`push`)return null;if(i===`commit`||i===`amend`){let e;return t[0]!==r||t[1]!==i||t[2]!==o||t[3]!==s||t[4]!==n||t[5]!==a?(e=(0,Z.jsx)(kg,{scope:n,context:r,action:i,status:a,onBusy:o,onLookAgain:s}),t[0]=r,t[1]=i,t[2]=o,t[3]=s,t[4]=n,t[5]=a,t[6]=e):e=t[6],e}let c;return t[7]!==r||t[8]!==i||t[9]!==o||t[10]!==s||t[11]!==n||t[12]!==a?(c=(0,Z.jsx)(jg,{scope:n,context:r,action:i,status:a,onBusy:o,onLookAgain:s},i),t[7]=r,t[8]=i,t[9]=o,t[10]=s,t[11]=n,t[12]=a,t[13]=c):c=t[13],c}function kg(e){let t=(0,$.c)(17),{scope:n,context:r,action:i,status:a,onBusy:o,onLookAgain:s}=e,c;t[0]===i?c=t[1]:(c=(0,Z.jsx)(Ag,{action:i}),t[0]=i,t[1]=c);let l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`p`,{role:`status`,children:`Reading commit details…`}),t[2]=l):l=t[2];let u;t[3]===c?u=t[4]:(u=(0,Z.jsxs)(Z.Fragment,{children:[c,l]}),t[3]=c,t[4]=u);let d;t[5]!==i||t[6]!==r||t[7]!==o||t[8]!==s||t[9]!==n||t[10]!==a?(d=e=>{let t=e.headCommit;return i===`amend`&&!t?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ag,{action:i}),(0,Z.jsx)(`p`,{role:`alert`,children:`The last commit could not be read. Close and try again.`})]}):(0,Z.jsx)(lg,{scope:n,context:r,action:i,status:a,liveBranch:e.branch??a.branch,initialMessage:i===`amend`&&t?[t.subject,t.body].filter(Boolean).join(`
|
|
20
20
|
|
|
21
21
|
`):``,lastCommitMessage:t?[t.subject,t.body].filter(Boolean).join(`
|
|
22
22
|
|
|
23
|
-
`):``,...t?{replacedSubject:t.subject}:{},onBusy:o,onLookAgain:s})},t[5]=i,t[6]=r,t[7]=o,t[8]=s,t[9]=n,t[10]=a,t[11]=d):d=t[11];let f;return t[12]!==r||t[13]!==n||t[14]!==u||t[15]!==d?(f=(0,Z.jsx)(Ag,{scope:n,context:r,pending:u,children:d}),t[12]=r,t[13]=n,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function Og(e){let t=(0,$.c)(7),{action:n}=e,r=n===`amend`?`Amend last commit`:`Commit changes`,i;t[0]===r?i=t[1]:(i=(0,Z.jsx)(Xi,{children:r}),t[0]=r,t[1]=i);let a=n===`amend`?`The last commit is replaced by one with this message and the files you add.`:`Committed steps fold away in the review and show up in History.`,o;t[2]===a?o=t[3]:(o=(0,Z.jsx)(ea,{children:a}),t[2]=a,t[3]=o);let s;return t[4]!==i||t[5]!==o?(s=(0,Z.jsxs)(Hi,{children:[i,o]}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function kg(e){let t=(0,$.c)(12),{scope:n,context:r,action:i,status:a,onBusy:o,onLookAgain:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Reading branch…`}),t[0]=c):c=t[0];let l;t[1]!==i||t[2]!==r||t[3]!==o||t[4]!==s||t[5]!==n||t[6]!==a?(l=e=>(0,Z.jsx)(jg,{scope:n,context:r,action:i,status:{...a,branch:e.branch??a.branch},expectedStatus:a,onBusy:o,onLookAgain:s}),t[1]=i,t[2]=r,t[3]=o,t[4]=s,t[5]=n,t[6]=a,t[7]=l):l=t[7];let u;return t[8]!==r||t[9]!==n||t[10]!==l?(u=(0,Z.jsx)(Ag,{scope:n,context:r,pending:c,children:l}),t[8]=r,t[9]=n,t[10]=l,t[11]=u):u=t[11],u}function Ag(e){let t=(0,$.c)(12),{scope:n,context:r,pending:i,children:a}=e,o=Ti(n,r.connection);if(Qt(o.result)){let e;t[0]===o.result.cause?e=t[1]:(e=Sn(En(o.result.cause)),t[0]=o.result.cause,t[1]=e);let n;t[2]===e?n=t[3]:(n=(0,Z.jsx)(Cm,{text:e}),t[2]=e,t[3]=n);let r;t[4]===o.refresh?r=t[5]:(r=(0,Z.jsx)(Y,{variant:`outline`,onClick:o.refresh,children:`Read status again`}),t[4]=o.refresh,t[5]=r);let i;return t[6]!==n||t[7]!==r?(i=(0,Z.jsxs)(Z.Fragment,{children:[n,r]}),t[6]=n,t[7]=r,t[8]=i):i=t[8],i}if(!gt(o.result))return i;let s;return t[9]!==a||t[10]!==o.result.value?(s=a(o.result.value),t[9]=a,t[10]=o.result.value,t[11]=s):s=t[11],s}function jg(e){let t=(0,$.c)(67),{scope:r,context:i,action:a,status:o,expectedStatus:s,onBusy:c,onLookAgain:l}=e,u=s===void 0?o:s,f=o.branch,[p,m]=(0,Q.useState)(`Porcelain review`),[h,g]=(0,Q.useState)(f?.stashes?.[0]?.oid??``),[_,v]=(0,Q.useState)(a===`stash-create`),y;t[0]!==u||t[1]!==c||t[2]!==l?(y={expectedStatus:u,onBusy:c,onLookAgain:l},t[0]=u,t[1]=c,t[2]=l,t[3]=y):y=t[3];let b=Ym(r,a,i,y),{busy:x,uncertain:C,outcome:w,error:T}=b,E;t[4]!==a||t[5]!==b||t[6]!==p||t[7]!==_||t[8]!==h?(E=e=>{e.preventDefault(),b.onSubmit(Qp(a,{message:p,stashOid:h,option:_}))},t[4]=a,t[5]=b,t[6]=p,t[7]=_,t[8]=h,t[9]=E):E=t[9];let D=x||C,O;t[10]!==a||t[11]!==_?(O=a===`stash-create`&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_?`Tracked changes and new files are set aside. The handoff stays empty until you restore the stash.`:`Tracked changes are set aside. New files stay in the worktree.`}),t[10]=a,t[11]=_,t[12]=O):O=t[12];let k;t[13]!==a||t[14]!==b.messageLimit||t[15]!==p?(k=a===`stash-create`&&(0,Z.jsxs)(Ut,{children:[(0,Z.jsx)(Et,{htmlFor:`git-message`,children:`Message`}),(0,Z.jsx)(Ir,{id:`git-message`,value:p,onChange:e=>m(e.target.value),required:!0,maxLength:b.messageLimit})]}),t[13]=a,t[14]=b.messageLimit,t[15]=p,t[16]=k):k=t[16];let A;t[17]!==a||t[18]!==f||t[19]!==h?(A=(a===`stash-apply`||a===`stash-pop`)&&(0,Z.jsxs)(Ut,{children:[(0,Z.jsx)(Et,{htmlFor:`git-stash`,children:`Stash`}),f?.stashes?.length?(0,Z.jsxs)(S,{items:f.stashes.map(Ng),value:h,onValueChange:e=>{e&&g(e)},children:[(0,Z.jsx)(Ge,{id:`git-stash`,children:(0,Z.jsx)(Qe,{})}),(0,Z.jsx)(G,{children:f.stashes.map(Mg)})]}):(0,Z.jsx)(d,{id:`git-stash`,value:h,onChange:e=>g(e.target.value),required:!0,pattern:`([a-f0-9]{40}|[a-f0-9]{64})`})]}),t[17]=a,t[18]=f,t[19]=h,t[20]=A):A=t[20];let j;t[21]===_?j=t[22]:(j=(0,Z.jsx)(Jm,{checked:_,onCheckedChange:v}),t[21]=_,t[22]=j);let M=a===`stash-create`?`Include untracked files`:`Restore staged changes`,N;t[23]!==j||t[24]!==M?(N=(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[j,M]}),t[23]=j,t[24]=M,t[25]=N):N=t[25];let P;t[26]!==N||t[27]!==D||t[28]!==O||t[29]!==k||t[30]!==A?(P=(0,Z.jsxs)(`fieldset`,{disabled:D,className:`flex min-w-0 flex-col gap-4`,children:[O,k,A,N]}),t[26]=N,t[27]=D,t[28]=O,t[29]=k,t[30]=A,t[31]=P):P=t[31];let F;t[32]===w?F=t[33]:(F=(0,Z.jsx)(Pg,{outcome:w}),t[32]=w,t[33]=F);let I;t[34]!==w||t[35]!==C?(I=C&&!w&&(0,Z.jsx)(`p`,{role:`status`,children:`Outcome not yet confirmed`}),t[34]=w,t[35]=C,t[36]=I):I=t[36];let L;t[37]===T?L=t[38]:(L=T?(0,Z.jsx)(Cm,{text:Sn(T)}):null,t[37]=T,t[38]=L);let R;t[39]!==x||t[40]!==b.lookAgain||t[41]!==l||t[42]!==w?(R=w&&n(w)&&l&&(0,Z.jsx)(Y,{type:`button`,variant:`outline`,disabled:x,onClick:b.lookAgain,children:`Look again`}),t[39]=x,t[40]=b.lookAgain,t[41]=l,t[42]=w,t[43]=R):R=t[43];let z;t[44]!==x||t[45]!==b.checkOutcome||t[46]!==b.operation?(z=b.operation&&!x&&(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:b.checkOutcome,children:`Check outcome`}),t[44]=x,t[45]=b.checkOutcome,t[46]=b.operation,t[47]=z):z=t[47];let B;t[48]!==x||t[49]!==w||t[50]!==C?(B=x||C||!!(w&&n(w)),t[48]=x,t[49]=w,t[50]=C,t[51]=B):B=t[51];let V;t[52]!==a||t[53]!==x?(V=x?`Working…`:rm(a),t[52]=a,t[53]=x,t[54]=V):V=t[54];let H;t[55]!==B||t[56]!==V?(H=(0,Z.jsx)(Y,{type:`submit`,disabled:B,children:V}),t[55]=B,t[56]=V,t[57]=H):H=t[57];let U;return t[58]!==P||t[59]!==F||t[60]!==I||t[61]!==L||t[62]!==R||t[63]!==z||t[64]!==H||t[65]!==E?(U=(0,Z.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:E,children:[P,F,I,L,R,z,H]}),t[58]=P,t[59]=F,t[60]=I,t[61]=L,t[62]=R,t[63]=z,t[64]=H,t[65]=E,t[66]=U):U=t[66],U}function Mg(e){return(0,Z.jsxs)(B,{value:e.oid,children:[e.message,` · `,Ap(e.oid)]},e.oid)}function Ng(e){return{value:e.oid,label:`${e.message} · ${Ap(e.oid)}`}}function Pg(e){let t=(0,$.c)(7),{outcome:n}=e;if(!n)return null;if(n.message&&Xt(n)&&n.state!==`conflicted`){let e;return t[0]===n.message?e=t[1]:(e=(0,Z.jsx)(Cm,{text:n.message}),t[0]=n.message,t[1]=e),e}let r=n.state,i;t[2]===n?i=t[3]:(i=Fg(n),t[2]=n,t[3]=i);let a;return t[4]!==n.state||t[5]!==i?(a=(0,Z.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[r,i]}),t[4]=n.state,t[5]=i,t[6]=a):a=t[6],a}function Fg({message:e,reason:t}){return e?` · ${e}`:t?` · ${t.replaceAll(`_`,` `).toLowerCase()}`:``}function Ig(e){let t=(0,$.c)(53),{scope:n,context:r}=e,{connection:i}=r,a=Nt(bt(oa(n,i))),[o,c]=(0,Q.useState)(!1),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>e=>{if(!e)return;let t=()=>c(e.getClientRects().length===0);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[0]=l):l=t[0];let[u]=(0,Q.useState)(l),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),h=a!=null&&E(un(a)).kind===`hint`,g=d||h,_=Ti(n,i,g),v=Nt(bt(_.result)),y=bi(n,i),b=Ta(i),x;t[1]===b?x=t[2]:(x=Oo(b),t[1]=b,t[2]=x);let S=x,C;t[3]!==S||t[4]!==b?(C=S?void 0:oo(b),t[3]=S,t[4]=b,t[5]=C):C=t[5];let w=C,[T,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(null),[F,I]=(0,Q.useState)(null),L;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>f(!0),t[6]=L):L=t[6];let R;t[7]!==w||t[8]!==S?(R=S?{kind:`ready`,strategy:S}:{kind:`blocked`,reason:w??`Changes & Git settings for this computer are unavailable.`},t[7]=w,t[8]=S,t[9]=R):R=t[9];let z;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{e&&j(null),k(e)},t[10]=z):z=t[10];let B;t[11]!==_||t[12]!==y||t[13]!==R?(B={details:_,enableDetails:L,pull:R,notify:Bg,onProgress:z,onResult:j,refreshLook:y,onLooked:I},t[11]=_,t[12]=y,t[13]=R,t[14]=B):B=t[14];let V=Mm(n,r,B);if(a==null)return null;let H={...un(a),branch:ee(a.branch,g?v?.branch:void 0)},W;t[15]===N?W=t[16]:(W=e=>e.id===N,t[15]=N,t[16]=W);let G=tm.find(W),te=E(H),ne=te.kind===`run`&&te.action===`pull`&&!S,re=ne&&w?w:s(te,H),ie=U(te,H),ae=M(H),K=V.running,oe;t[17]!==_.result||t[18]!==g?(oe=g&&vn(_.result),t[17]=_.result,t[18]=g,t[19]=oe):oe=t[19];let q=oe,se=q?nm.slice(0,1):nm,ce=e=>{we(e)?V.runNetwork(e,H.branch):(I(H),P(e))},le;t[20]===K?le=t[21]:(le=e=>{e||j(null),K&&k(e)},t[20]=K,t[21]=le);let ue=K?`${Bn(K.name)}…`:te.label,de=!K&&ie!=null&&` ${ie}`,J;t[22]!==ue||t[23]!==de?(J=(0,Z.jsxs)(`span`,{ref:u,"aria-hidden":`true`,className:`hidden @min-lg/pane:inline`,children:[ue,de]}),t[22]=ue,t[23]=de,t[24]=J):J=t[24];let fe;t[25]!==V.checkOutcome||t[26]!==A||t[27]!==K?(fe=(0,Z.jsx)(pn,{align:`end`,className:`w-80`,children:A&&!K?(0,Z.jsxs)(ot,{children:[(0,Z.jsx)(Zt,{children:A.title}),A.description!==void 0&&(A.type===`error`?(0,Z.jsx)(Cm,{text:A.description}):(0,Z.jsx)(Pt,{children:(0,Z.jsx)(Sm,{text:A.description})}))]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Zt,{children:K?`${Bn(K.name)}…`:`Git action…`}),(0,Z.jsx)(`ol`,{className:`flex flex-col gap-0.5 font-mono text-2xs leading-4`,children:K?.operation?.receipt?.progress.length?K.operation.receipt.progress.slice(-4).map(zg):(0,Z.jsx)(`li`,{className:`text-muted-foreground`,children:`Waiting for Git…`})}),K&&A?.description&&(0,Z.jsx)(Cm,{text:A.description}),K&&(0,Z.jsx)(Y,{variant:`outline`,disabled:K.checking,onClick:V.checkOutcome,children:K.checking?`Checking…`:`Check outcome`})]})}),t[25]=V.checkOutcome,t[26]=A,t[27]=K,t[28]=fe):fe=t[28];let pe;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(pe=e=>{m(e),e&&f(!0)},t[29]=pe):pe=t[29];let me=K!=null,he;t[30]===me?he=t[31]:(he=(0,Z.jsx)(on,{render:(0,Z.jsx)(Y,{variant:`outline`,size:`icon`,"aria-label":`Git actions`,disabled:me})}),t[30]=me,t[31]=he);let ge;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(Ae,{className:`size-3.5`}),t[32]=ge):ge=t[32];let _e;t[33]===he?_e=t[34]:(_e=(0,Z.jsx)(nn,{render:he,children:ge}),t[33]=he,t[34]=_e);let ve;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Z.jsx)(yt,{role:`tooltip`,className:`break-all`,children:`Git actions`}),t[35]=ve):ve=t[35];let ye;t[36]===_e?ye=t[37]:(ye=(0,Z.jsxs)(wn,{children:[_e,ve]}),t[36]=_e,t[37]=ye);let be=ae?(0,Z.jsx)(hh,{tracking:Ip(ae,null)}):(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(mr,{className:`size-3.5 shrink-0`}),`Git actions`]}),xe;t[38]===be?xe=t[39]:(xe=(0,Z.jsx)(Wt,{children:(0,Z.jsx)(St,{children:be})}),t[38]=be,t[39]=xe);let Se;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,Z.jsx)(Dt,{}),t[40]=Se):Se=t[40];let Ce=se.map((e,t)=>(0,Z.jsxs)(Q.Fragment,{children:[(0,Z.jsx)(Wt,{children:e.actions.map(e=>{let t=im(e.id,H,w),n=t??He(e.id,H);return(0,Z.jsxs)(wn,{onOpenChange:Rg,children:[(0,Z.jsx)(nn,{render:(0,Z.jsx)(`span`,{className:`block`}),children:(0,Z.jsxs)(Dn,{disabled:t!=null,onClick:()=>ce(e.id),children:[(0,Z.jsx)(Im,{action:e.id}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(X,{text:e.label}),t&&(0,Z.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:t})]})]})}),(0,Z.jsxs)(yt,{children:[e.description,n&&` ${n}`]})]},e.id)})}),(q||t<se.length-1)&&(0,Z.jsx)(Dt,{})]},e.id)),Te;t[41]===q?Te=t[42]:(Te=q&&(0,Z.jsx)(`p`,{role:`status`,className:`px-2 py-1 text-xs text-muted-foreground`,children:`Reading Git status…`}),t[41]=q,t[42]=Te);let Ee=!q&&(ae?.discarded?.length??0)>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Dt,{}),(0,Z.jsxs)(Wt,{children:[(0,Z.jsx)(St,{children:`Discarded`}),ae?.discarded?.map(e=>{let t=e.kind===`rename`?`Restore discarded rename of ${e.path}`:`Restore discarded hunk of ${e.path}`;return(0,Z.jsxs)(wn,{onOpenChange:Lg,children:[(0,Z.jsx)(nn,{render:(0,Z.jsx)(`span`,{className:`block`}),children:(0,Z.jsxs)(Dn,{onClick:()=>{m(!1),V.restoreDiscarded(e)},children:[(0,Z.jsx)(Rc,{}),(0,Z.jsx)(X,{className:`min-w-0`,text:t,propagateEscape:!0})]})}),(0,Z.jsxs)(yt,{children:[t,` · Kept until you restore it`]})]},e.oid)})]})]}),De;t[43]!==q||t[44]!==xe||t[45]!==Ce||t[46]!==Te||t[47]!==Ee?(De=(0,Z.jsxs)(vt,{align:`end`,className:`w-76`,"aria-busy":q,children:[xe,Se,Ce,Te,Ee]}),t[43]=q,t[44]=xe,t[45]=Ce,t[46]=Te,t[47]=Ee,t[48]=De):De=t[48];let Oe;return t[49]!==p||t[50]!==ye||t[51]!==De?(Oe=(0,Z.jsxs)(tn,{open:p,onOpenChange:pe,children:[ye,De]}),t[49]=p,t[50]=ye,t[51]=De,t[52]=Oe):Oe=t[52],(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(jm,{"aria-label":`Git controls`,className:`shrink-0`,children:[(0,Z.jsxs)(wn,{children:[(0,Z.jsxs)(qt,{open:K!=null&&O||A!=null,onOpenChange:le,children:[(0,Z.jsxs)(nn,{render:(0,Z.jsx)(_n,{render:(0,Z.jsx)(Y,{variant:`outline`,size:o?`icon`:`default`,"aria-label":K?`${Bn(K.name)} in progress: show progress`:te.label,disabled:K==null&&(te.kind===`hint`||ne),focusableWhenDisabled:!0,className:`aria-disabled:cursor-default`,onClick:()=>{K||A||(te.kind===`commit`?ce(`commit`):te.kind===`stash`?ce(`stash-apply`):te.kind===`run`&&V.runNetwork(te.action,H.branch))}})}),children:[K?(0,Z.jsx)(mt,{className:`size-3.5`}):(0,Z.jsx)(Im,{action:Vg(te),className:`size-3.5`}),J]}),fe]}),(0,Z.jsx)(yt,{role:`tooltip`,className:`break-all`,children:K?`${Bn(K.name)} in progress: show progress`:re})]}),Oe]}),N==null?null:(0,Z.jsx)(Un,{open:!0,disablePointerDismissal:!0,onOpenChange:e=>{!e&&!T&&P(null)},children:(0,Z.jsxs)(vi,{"aria-busy":T,className:`max-h-[min(90svh,48rem)] overflow-y-auto sm:max-w-2xl`,children:[G?.id!==`commit`&&G?.id!==`amend`&&(0,Z.jsxs)(Hi,{children:[(0,Z.jsx)(Xi,{children:G?.label??`Git action`}),(0,Z.jsx)(ea,{children:Hg(G?.id)})]}),(0,Z.jsx)(Eg,{scope:n,context:r,entry:N,status:F??H,onBusy:D,onLookAgain:V.lookAgain})]})})]})}function Lg(e,t){t.reason===`escape-key`&&t.allowPropagation()}function Rg(e,t){t.reason===`escape-key`&&t.allowPropagation()}function zg(e){return(0,Z.jsx)(X,{render:(0,Z.jsx)(`li`,{}),text:e},e)}function Bg(e){let{title:t,description:n,type:r}=e;return bo.add({title:t,description:n===void 0?void 0:(0,Z.jsx)(Sm,{text:n}),type:r})}function Vg(e){return e.kind===`run`?e.action:e.kind===`stash`?`stash-apply`:`commit`}function Hg(e){return e===`stash-pop`?`Its changes come back into the working tree and the stash is dropped.`:e===`stash-apply`?`Its changes come back into the working tree and the stash is kept.`:`Every change, new files included, is set aside until you pop the stash.`}function Ug(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=me(`(min-width: 1280px)`),e[0]=t):t=e[0],N(t)}var Wg=()=>({tabs:[],pinned:[]});function Gg(e){return e===`handoff`||e===`walkthrough`}function Kg(e,t=`handoff`,n=!1){let r=n?[t,`walkthrough`]:[t];return{tabs:[...r,...e.tabs.filter(e=>!r.includes(e))],pinned:e.pinned.filter(e=>!Gg(e))}}function qg(e,t,n){if(e[t]?.tabs.includes(n))return t;let r=+(t===0);return e[r]?.tabs.includes(n)?r:t}function Jg(e){return[...[`handoff`,`walkthrough`].filter(t=>e.tabs.includes(t)),...e.pinned.filter(t=>!Gg(t)&&e.tabs.includes(t)),...e.tabs.filter(t=>!Gg(t)&&!e.pinned.includes(t))]}function Yg(e,t,n){return e.tabs.includes(t)?e:{...e,tabs:Wp(e.tabs,t,n)}}function Xg(e,t){return Gg(t)?e:{tabs:e.tabs.filter(e=>e!==t),pinned:e.pinned.filter(e=>e!==t)}}function Zg(e,t){return{...e,tabs:e.tabs.filter(n=>Gg(n)||n===t||e.pinned.includes(n))}}function Qg(e){return{...e,tabs:e.tabs.filter(t=>Gg(t)||e.pinned.includes(t))}}function $g(e,t){return Gg(t)?e:e.pinned.includes(t)?{...e,pinned:e.pinned.filter(e=>e!==t)}:{...e,pinned:[...e.pinned,t]}}function e_(e,t,n){if(n.tabs.includes(t))return t;let r=Jg(e),i=new Set(Jg(n)),a=r.indexOf(t);return a===-1?null:[...r.slice(a+1),...r.slice(0,a).reverse()].find(e=>i.has(e)&&!Gg(e))??e.tabs.find(e=>i.has(e))??null}function t_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function n_(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&(Up(e)??null)!==null):[]}function r_(e){if(!t_(e)||!Array.isArray(e.panes))return null;let t=e.panes.map(e=>{let t=n_(t_(e)?e.tabs:void 0);return{tabs:t,pinned:n_(t_(e)?e.pinned:void 0).filter(e=>t.includes(e))}}).filter((e,t)=>t===0||e.tabs.length>0);return t.length>0?t:null}function i_(e){return e===null?`Open to the side`:e===`left`?`Open in the right pane`:`Open in the left pane`}function a_(e){if(e!==0)return{value:String(e),description:R(e,`uncommitted file`)}}function o_(e,t,n){let r=t.flatMap(e=>Jg(e)),i=n===null?e:[n,...e],a=new Set(r);return[...new Set([...i,...r])].filter(e=>a.has(e))}function s_(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function c_(e){return!e||typeof e!=`object`||!(`folded`in e)||!(`expanded`in e)?{folded:[],expanded:[]}:s_(e.folded)&&s_(e.expanded)?{folded:e.folded,expanded:e.expanded}:{folded:[],expanded:[]}}function l_(e,t,n=!1){return e.folded.includes(t)||n&&!e.expanded.includes(t)}function u_(e,t,n){let r=new Set(e.folded),i=new Set(e.expanded);for(let e of t)n?(r.add(e),i.delete(e)):(r.delete(e),i.add(e));return{folded:[...r],expanded:[...i]}}function d_(e,t){return e?.owner===t?void 0:e}var f_=jn(ft({saved:rn})),p_=jn(ft({focused:Mt([0,1])})),m_=Nn.pipe(p(ft({panes:at(Tt(ft({tabs:Tt(In),pinned:Tt(In)}))),saved:rn,focused:Mt([0,1])}),{decode:ge(e=>({panes:r_(e),saved:f_(e).pipe(kn(e=>e.saved),an(()=>!0)),focused:p_(e).pipe(kn(e=>e.focused),an(()=>0))})),encode:ce()})),h_=Nn.pipe(p(ft({folded:Tt(In),expanded:Tt(In)}),{decode:ge(c_),encode:ce()})),g_=x(e=>Hn({runtime:_a,key:`porcelain.tabs.${e}`,schema:m_,defaultValue:()=>({panes:null,saved:!1,focused:0})})),__=x(e=>u([]).pipe(Ee)),v_=x(e=>Hn({runtime:_a,key:e,schema:h_,defaultValue:()=>({folded:[],expanded:[]})}));function y_(e){let t=(0,$.c)(13),n;t[0]===e?n=t[1]:(n=g_(e),t[0]=e,t[1]=n);let r=n,{panes:i,saved:a,focused:o}=N(r),s=c(r),l=N(oe),u;t[2]!==r||t[3]!==l?(u=e=>{let t=l.get(r);t.focused!==e&&l.set(r,{...t,focused:e})},t[2]=r,t[3]=l,t[4]=u):u=t[4];let d;t[5]===s?d=t[6]:(d=e=>s(t=>({...t,panes:e,saved:!0})),t[5]=s,t[6]=d);let f;return t[7]!==o||t[8]!==i||t[9]!==a||t[10]!==u||t[11]!==d?(f={panes:i,saved:a,focused:o,setFocused:u,save:d},t[7]=o,t[8]=i,t[9]=a,t[10]=u,t[11]=d,t[12]=f):f=t[12],f}function b_(e,t){let n=(0,$.c)(7),r=`porcelain.folds.${e}.${t}`,i;n[0]===r?i=n[1]:(i=v_(r),n[0]=r,n[1]=i);let a=i,o=N(a),s=c(a),l;n[2]===s?l=n[3]:(l=(e,t)=>s(n=>u_(n,e,t)),n[2]=s,n[3]=l);let u;return n[4]!==l||n[5]!==o?(u={folds:o,setCollapsed:l},n[4]=l,n[5]=o,n[6]=u):u=n[6],u}var x_=x(e=>u(25).pipe(Ee)),S_=x(e=>u({viewer:null,restored:null})),C_=x(e=>u({scrollTop:0,selection:null,focused:void 0}).pipe(Ee));function w_(e){let t=(0,$.c)(33),n=(0,Q.useId)(),r;t[0]===n?r=t[1]:(r=S_(n),t[0]=n,t[1]=r);let i=r;ie(i);let a=N(oe),o;t[2]===e?o=t[3]:(o=C_(e),t[2]=e,t[3]=o);let s=o,c,l,u,d,f,p;t[4]!==s||t[5]!==a?(c=()=>a.get(s).scrollTop,l=()=>a.get(s).selection,u=()=>a.get(s).focused,d=e=>a.set(s,{...a.get(s),focused:e}),f=e=>{a.set(s,{...a.get(s),scrollTop:e})},p=e=>{a.set(s,{...a.get(s),selection:e})},t[4]=s,t[5]=a,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p):(c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11]);let m;t[12]!==i||t[13]!==a?(m=e=>a.get(i).viewer?.scrollTo(e),t[12]=i,t[13]=a,t[14]=m):m=t[14];let h;t[15]!==i||t[16]!==e||t[17]!==s||t[18]!==a?(h=(t,n)=>{let r=a.get(i);(r.restored?.viewer!==t||r.restored.owner!==e)&&(t.scrollTo({type:`position`,position:a.get(s).scrollTop+n,behavior:`instant`}),a.set(i,{...r,restored:{viewer:t,owner:e}}))},t[15]=i,t[16]=e,t[17]=s,t[18]=a,t[19]=h):h=t[19];let g;t[20]!==i||t[21]!==a?(g=e=>{if(e)return a.set(i,{...a.get(i),viewer:e}),()=>{let t=a.get(i);t.viewer===e&&a.set(i,{...t,viewer:null})}},t[20]=i,t[21]=a,t[22]=g):g=t[22];let _;return t[23]!==h||t[24]!==g||t[25]!==c||t[26]!==l||t[27]!==u||t[28]!==d||t[29]!==f||t[30]!==p||t[31]!==m?(_={position:c,selection:l,focused:u,rememberFocus:d,rememberPosition:f,rememberSelection:p,scrollTo:m,restorePosition:h,attach:g},t[23]=h,t[24]=g,t[25]=c,t[26]=l,t[27]=u,t[28]=d,t[29]=f,t[30]=p,t[31]=m,t[32]=_):_=t[32],_}var T_=Hn({runtime:_a,key:`porcelain.review-panel.open`,schema:rn,defaultValue:()=>!0}).pipe(Ee);function E_(){let e=(0,$.c)(3),t=N(T_),n=c(T_),r;return e[0]!==t||e[1]!==n?(r={open:t,setOpen:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],r}var D_=x(e=>u(void 0).pipe(Ee)),O_=new Map,k_=x(e=>u(t=>{let n=Symbol();O_.set(e.worktreeId,{owner:n,title:e.title}),t.set(D_(e.worktreeId),e.title),t.addFinalizer(()=>{d_(O_.get(e.worktreeId),n)||(O_.delete(e.worktreeId),t.set(D_(e.worktreeId),void 0))})}));function A_(e){let t=(0,$.c)(18),{worktreeId:n,entry:r,side:i,onSearch:a,fallback:o,focused:s,setFocused:c,ready:l,focusBoundary:u,focusBoundaryOpen:d,firstDocument:f,companion:p}=e,{panes:m,saved:h,save:g}=y_(n),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=[void 0,void 0],t[0]=_):_=t[0];let[v,y]=(0,Q.useState)(_),b;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(b=[null,null],t[1]=b):b=t[1];let[x,S]=(0,Q.useState)(b),C=(0,Q.useId)(),w;t[2]===C?w=t[3]:(w=M_(C),t[2]=C,t[3]=w);let T=N(w),E=T.cancel,D=[r!=null&&(Up(r)??null)!==null?r:void 0,i!=null&&(Up(i)??null)!==null?i:void 0],O;t[4]!==r||t[5]!==o||t[6]!==a||t[7]!==l||t[8]!==h||t[9]!==i?(O=N_({ready:l,entry:r,side:i,onSearch:a,fallback:o,saved:h}),t[4]=r,t[5]=o,t[6]=a,t[7]=l,t[8]=h,t[9]=i,t[10]=O):O=t[10],ie(O);let k=e=>{let t=v[e];return t===void 0?D[e]:t??void 0},A=[Kg(m?.[0]??Wg(),f,p),...m?.slice(1)??[]],j=Jg(m?.[0]??Wg()).at(-1),M=j&&!Gg(j)?j:f,P=[k(0)??(m==null?o??f:M),k(1)??(k(0)!==void 0||A[1]===null||A[1]===void 0?null:Jg(A[1]).at(-1)??null)],F=[Yg(A[0]??Wg(),P[0]??``,x[0])];(P[0]===null||P[0]===void 0)&&(F[0]=A[0]??Wg()),P[1]!==null&&P[1]!==void 0&&(F[1]=Yg(A[1]??Wg(),P[1],x[1]));let I=F.length>1;if(l){let e=v.map((e,t)=>e!==void 0&&(D[t]??null)===(e??null)?void 0:e);(e[0]!==v[0]||e[1]!==v[1])&&y([e[0],e[1]]),(x[0]!==P[0]||x[1]!==P[1])&&S(P)}ie(P_({worktreeId:n,panes:F,ready:l}));let L;t[11]===n?L=t[12]:(L=__(n),t[11]=n,t[12]=L);let R=N(L),z=P[s]??null;ie(F_({worktreeId:n,panes:F,active:z,ready:l}));let B=o_(R,F,z).flatMap(j_),V;t[13]!==E||t[14]!==a?(V=e=>{E(),y(t=>[`entry`in e?e.entry??null:t[0],`side`in e?e.side??null:t[1]]),a({...`entry`in e?{entry:e.entry??void 0}:{},...`side`in e?{side:e.side??void 0}:{}})},t[13]=E,t[14]=a,t[15]=V):V=t[15];let H=V,U;t[16]===H?U=t[17]:(U=(e,t)=>H(e===0?{entry:t}:{side:t}),t[16]=H,t[17]=U);let W=U,G=(e,t)=>F.map((n,r)=>r===e?t:n),ee=(e,t,n)=>{if(E(),I&&t.tabs.length===0){let t=+(e===0);g([F[t]??Wg()]),c(0),H({entry:P[t],side:null})}else g(G(e,t)),n!==P[e]&&W(e,n)};return{recentFiles:B,bindQuickOpen:T.bindQuickOpen,focusDestination:T.schedule,hasDestinationFocus(){return T.current()!==null},selectPane(e){E(),c(e)},focusPane(e,t){if(d||T.restoringQuickOpen&&t.getAttribute(`role`)===`tab`)return;let n=T.destination;n!==null&&(n.pane!==e||t.getAttribute(`role`)!==`tab`||t.getAttribute(`data-entry`)!==n.key)&&E(),c(e)},bindPane(e,t){return T.bind(e,t,{focused:s,actives:P,panes:F,focusBoundary:u})},split:I,panes:F.map((e,t)=>({tabs:Jg(e),pinned:e.pinned,active:P[t]??null})),activate(e,t){c(e),W(e,t)},open(e,t,n){let r=n!==void 0&&n,i=qg(F,e,t);return W(i,t),r?T.cancel():T.request({pane:i,key:t}),c(i),i},closePane(e){I&&ee(e,Wg(),null)},close(e,t){let n=F[e]??Wg(),r=Xg(n,t);ee(e,r,t===P[e]?e_(n,t,r):P[e])},closeOthers(e,t){ee(e,Zg(F[e]??Wg(),t),t)},closeUnpinned(e){let t=Qg(F[e]??Wg()),n=P[e];ee(e,t,n!=null&&t.tabs.includes(n)?n:Jg(t)[0]??null)},togglePin(e,t){g(G(e,$g(F[e]??Wg(),t)))},openToSide(e,t){let n=+(e===0),r=[...F];r[n]=Yg(F[n]??Wg(),t,P[n]),g(r),W(n,t),T.request({pane:n,key:t}),c(n)},step(e,t){E();let n=Jg(F[e]??Wg());if(n.length===0)return;let r=P[e]===null||P[e]===void 0?-1:n.indexOf(P[e]);W(e,n[(r+t+n.length)%n.length]??null)}}}function j_(e){let t=Up(e);return t?.kind===`file`?[t.path]:[]}var M_=x(e=>u(e=>{let t=[null,null],n=null,r=!1,i=null,a,o=null,s=()=>{o!==null&&cancelAnimationFrame(o),o=null},c=()=>{i=null,r=!1,s()},l=()=>i&&a&&(a.focused!==i.pane||a.actives[i.pane]!==i.key||!a.panes[i.pane]?.tabs.includes(i.key))?null:i,u=()=>{i&&o===null&&(o=requestAnimationFrame(()=>{o=null;let e=l();if(!e||a?.focusBoundary?.isConnected||n?.isConnected)return;let s=[...t[e.pane]?.querySelectorAll(`[role="tab"]`)??[]].find(t=>t.dataset.entry===e.key);s?.isConnected&&(s.focus(),s.ownerDocument.activeElement===s&&i===e&&(i=null,r=!1))}))};return e.addFinalizer(c),{get destination(){return i},get restoringQuickOpen(){return r},current:l,cancel:c,schedule:u,bindQuickOpen:e=>{n=e,e===null&&u()},request(e){i=e,r=n?.isConnected===!0},bind(e,n,r){if(s(),a=r,t[e]=n,l(),n)return u(),()=>{t[e]===n&&(t[e]=null),s()}}}})),N_=x(({ready:e,entry:t,side:n,onSearch:r,fallback:i,saved:a})=>u(()=>{e&&(t!==void 0&&Up(t)===null&&r({entry:void 0},{replace:!0}),n!==void 0&&Up(n)===null&&r({side:void 0},{replace:!0}),!a&&t===void 0&&n===void 0&&i!==null&&r({entry:i},{replace:!0}))})),P_=x(({worktreeId:e,panes:t,ready:n})=>u(r=>{if(!n)return;let i=g_(e),a=r.once(i);a.saved&&JSON.stringify(a.panes)===JSON.stringify(t)&&(t.length>1||a.focused===0)||r.set(i,{...a,panes:t,saved:!0,focused:t.length>1?a.focused:0})})),F_=x(({worktreeId:e,panes:t,active:n,ready:r})=>u(i=>{if(!r)return;let a=__(e),o=i.once(a),s=o_(o,t,n);o.length===s.length&&o.every((e,t)=>e===s[t])||i.set(a,s)}));function I_(e,t){return{onActivate:n=>e.activate(t,n),onClose:n=>e.close(t,n),onCloseOthers:n=>e.closeOthers(t,n),onCloseUnpinned:()=>e.closeUnpinned(t),onTogglePin:n=>e.togglePin(t,n),onOpenToSide:n=>e.openToSide(t,n),onClosePane:e.split?()=>e.closePane(t):void 0}}function L_(e){let t=e?.closest(`[data-tab-viewport]`);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.left<r.left?n.left-r.left:Math.max(0,n.right-r.right);t.scrollBy({left:i})}function R_(e,t){let n=Up(e);switch(n?.kind){case`handoff`:{let e=`Changes`;return{Icon:br,title:e,hint:t?`${e} · ${t.description}`:e}}case`walkthrough`:return{Icon:wc,title:`Walkthrough`,hint:`Walkthrough`};case`walkthrough-step`:return{Icon:br,title:`Step ${n.step}`,hint:`Changes in step ${n.step}`};case`all-changes`:case`walkthrough-changes`:return{Icon:br,title:`All changes`,hint:`Every changed file, including specs`};case`specs`:return{Icon:uc,title:`Specs`,hint:`Changed spec and test files`};case`change`:return{Icon:Lr,title:ui(n.path),accessibleName:n.path,hint:`${n.path} · changes`};case`file`:return{Icon:Lr,title:ui(n.path),accessibleName:n.path,hint:n.path};case`commit`:return{Icon:fc,title:Ap(n.oid),hint:`Commit ${n.oid}`};case`branch`:return{Icon:mr,title:`Branch`,hint:`Every change on the branch`};case`branch-file`:return{Icon:Lr,title:ui(n.path),accessibleName:n.path,hint:`${n.path} · branch`};case`pull-request`:return{Icon:bc,title:`PR #${n.number}`,hint:`Pull request #${n.number}`};case`graph`:return{Icon:mr,title:`Graph`,hint:`Commit graph of the checked-out branch`};case`timeline`:return{Icon:Ai,title:`Timeline of ${ui(n.path)}`,accessibleName:`Timeline of ${n.path}`,hint:`${n.path} · timeline`};default:return{Icon:ic,title:e,hint:e}}}function z_(e){let t=(0,$.c)(46),n,r,i,a,o,s,c,l,u,d;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10]):({changeCount:i,tabs:u,pinned:c,active:r,side:l,focused:o,leading:s,trailing:d,commitContext:a,...n}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d);let f=l!=null&&`gap-2`,p=l!=null&&o&&`bg-muted/40`,m;t[11]!==f||t[12]!==p?(m=q(`flex h-12 shrink-0 items-center gap-1.5 border-b px-2.5 text-[length:var(--text-ui)] leading-[1.4]`,f,p),t[11]=f,t[12]=p,t[13]=m):m=t[13];let h;t[14]===s?h=t[15]:(h=s!=null&&(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center`,children:s}),t[14]=s,t[15]=h);let g=l==null?`Open documents`:`Open documents, ${l} pane`,_;t[16]!==n||t[17]!==r||t[18]!==i||t[19]!==c||t[20]!==l||t[21]!==u?(_=u.includes(`handoff`)&&(0,Z.jsx)(`span`,{className:`flex shrink-0`,children:(0,Z.jsx)(H_,{count:a_(i),tabKey:`handoff`,active:r===`handoff`,pinned:!1,hasUnpinned:u.some(e=>!Gg(e)&&!c.includes(e)),side:l,...n})}),t[16]=n,t[17]=r,t[18]=i,t[19]=c,t[20]=l,t[21]=u,t[22]=_):_=t[22];let v;t[23]!==n||t[24]!==r||t[25]!==a||t[26]!==c||t[27]!==l||t[28]!==u?(v=u.filter(B_).map((e,t)=>{let i=c.includes(e),o=i&&!c.includes(u[t+1]??``)&&t<u.length-1,s=Up(e),d={tabKey:e,count:void 0,active:e===r,pinned:i,hasUnpinned:u.some(e=>!Gg(e)&&!c.includes(e)),side:l,...n};return(0,Z.jsxs)(`span`,{className:`flex min-w-0 shrink-0 items-center`,children:[a&&s?.kind===`commit`?(0,Z.jsx)(U_,{...d,commitContext:a,oid:s.oid}):(0,Z.jsx)(H_,{...d}),o&&(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-4 w-px shrink-0 bg-border`})]},e)}),t[23]=n,t[24]=r,t[25]=a,t[26]=c,t[27]=l,t[28]=u,t[29]=v):v=t[29];let y;t[30]===v?y=t[31]:(y=(0,Z.jsx)(ni,{"data-tab-viewport":``,className:`size-full overflow-y-hidden`,ref:V_,children:(0,Z.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center gap-1 px-1.5`,children:v})}),t[30]=v,t[31]=y);let b;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(Qr,{orientation:`horizontal`,className:`absolute inset-x-0 bottom-0 data-horizontal:h-1.5`}),t[32]=b):b=t[32];let x;t[33]===y?x=t[34]:(x=(0,Z.jsxs)(Pr,{className:`@container/tabs relative h-full min-w-0 flex-1`,children:[y,b]}),t[33]=y,t[34]=x);let S;t[35]!==x||t[36]!==g||t[37]!==_?(S=(0,Z.jsxs)(`div`,{role:`tablist`,"aria-label":g,className:`flex h-full min-w-0 flex-1 items-center gap-1`,children:[_,x]}),t[35]=x,t[36]=g,t[37]=_,t[38]=S):S=t[38];let C;t[39]===d?C=t[40]:(C=d!=null&&(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:d}),t[39]=d,t[40]=C);let w;return t[41]!==S||t[42]!==C||t[43]!==m||t[44]!==h?(w=(0,Z.jsxs)(`div`,{"data-pane-bar":``,className:m,children:[h,S,C]}),t[41]=S,t[42]=C,t[43]=m,t[44]=h,t[45]=w):w=t[45],w}function B_(e){return e!==`handoff`}function V_(e){if(!e)return;let t=()=>L_(e.querySelector(`[role="tab"][aria-selected="true"]`)),n=0,r=new ResizeObserver(()=>{cancelAnimationFrame(n),n=requestAnimationFrame(t)});return r.observe(e),()=>{cancelAnimationFrame(n),r.disconnect()}}function H_(e){let t=(0,$.c)(92),{tabKey:n,count:r,commitSubject:i,active:a,pinned:o,hasUnpinned:s,side:c,onActivate:l,onClose:u,onCloseOthers:d,onCloseUnpinned:f,onTogglePin:p,onOpenToSide:m,onClosePane:h}=e,g;t[0]!==r||t[1]!==n?(g=R_(n,r),t[0]=r,t[1]=n,t[2]=g):g=t[2];let{Icon:_,title:v,hint:y,accessibleName:b}=g,x=b===void 0?v:b,S=(0,Q.useId)(),C=i?`${v} ${i}`:v,w=i?`${y} · ${i}`:y,[T,E]=(0,Q.useState)(!1),D;t[3]===c?D=t[4]:(D=i_(c),t[3]=c,t[4]=D);let O=D,k;t[5]!==l||t[6]!==n?(k=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l(n))},t[5]=l,t[6]=n,t[7]=k):k=t[7];let A=k,j;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{e&&E(!1)},t[8]=j):j=t[8];let M;t[9]===n?M=t[10]:(M=q(`min-w-0 flex-1`,n.startsWith(`file:`)&&`italic`),t[9]=n,t[10]=M);let N=o?`${w} · pinned`:w,P;t[11]!==_||t[12]!==x||t[13]!==A||t[14]!==a||t[15]!==i||t[16]!==r||t[17]!==S||t[18]!==l||t[19]!==u||t[20]!==p||t[21]!==o||t[22]!==n||t[23]!==C||t[24]!==v?(P=e=>(0,Z.jsxs)(qi,{render:(0,Z.jsx)(`div`,{ref:e=>{a&&L_(e)},role:`tab`,tabIndex:0,"aria-selected":a,"aria-label":i?C:x,"aria-describedby":r?S:void 0,"data-entry":n,className:q(`group flex h-7 min-w-0 max-w-[min(100cqw,calc(var(--spacing)*45))] cursor-default items-center gap-1.5 rounded-md px-2 text-xs font-medium transition-colors`,a?`bg-muted text-foreground ring-1 ring-border ring-inset`:`text-muted-foreground hover:bg-accent/50`,a&&!Gg(n)&&!o&&`pr-0.5`),onClick:()=>l(n),onAuxClick:e=>{e.button===1&&!o&&!Gg(n)&&(e.preventDefault(),u(n))},onKeyDown:e=>{e.target===e.currentTarget&&A(e)}}),children:[(0,Z.jsx)(_,{className:`size-3.5 shrink-0`,strokeWidth:Gg(n)?1.75:void 0}),e,r&&(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-2xs leading-4 whitespace-nowrap text-muted-foreground tabular-nums`,children:r.value}),!Gg(n)&&o&&(0,Z.jsxs)(wn,{disableHoverablePopup:!0,children:[(0,Z.jsx)(nn,{render:(0,Z.jsx)(Y,{type:`button`,"aria-label":`Unpin ${v}`,onClick:e=>{e.stopPropagation(),p(n)},variant:`ghost`,size:`icon-xs`}),children:(0,Z.jsx)(Mr,{className:`size-3`})}),(0,Z.jsx)(yt,{children:`Unpin ${v}`})]}),!Gg(n)&&a&&(0,Z.jsxs)(wn,{disableHoverablePopup:!0,children:[(0,Z.jsx)(nn,{render:(0,Z.jsx)(Y,{type:`button`,"aria-label":`Close ${v}`,onClick:e=>{e.stopPropagation(),u(n)},variant:`ghost`,size:`icon-xs`,className:`mr-0.5`}),children:(0,Z.jsx)(jt,{className:`size-3`})}),(0,Z.jsxs)(yt,{children:[`Close ${v}`,(0,Z.jsx)(Jn,{children:ko(vo.closeTab)})]})]})]}),t[11]=_,t[12]=x,t[13]=A,t[14]=a,t[15]=i,t[16]=r,t[17]=S,t[18]=l,t[19]=u,t[20]=p,t[21]=o,t[22]=n,t[23]=C,t[24]=v,t[25]=P):P=t[25];let F;t[26]!==M||t[27]!==N||t[28]!==P||t[29]!==C?(F=(0,Z.jsx)(X,{className:M,text:N,disclose:`always`,renderTrigger:P,children:C}),t[26]=M,t[27]=N,t[28]=P,t[29]=C,t[30]=F):F=t[30];let I=!T,L;t[31]===n?L=t[32]:(L=Gg(n),t[31]=n,t[32]=L);let R;t[33]!==p||t[34]!==n?(R=()=>p(n),t[33]=p,t[34]=n,t[35]=R):R=t[35];let z;t[36]===o?z=t[37]:(z=o?(0,Z.jsx)(Er,{}):(0,Z.jsx)(Mr,{}),t[36]=o,t[37]=z);let B=o?`Unpin`:`Pin`,V;t[38]!==L||t[39]!==R||t[40]!==z||t[41]!==B?(V=(0,Z.jsxs)(Xr,{disabled:L,onClick:R,children:[z,B]}),t[38]=L,t[39]=R,t[40]=z,t[41]=B,t[42]=V):V=t[42];let H=m===void 0,U;t[43]!==m||t[44]!==n?(U=()=>{(0,ru.flushSync)(()=>E(!0)),m?.(n)},t[43]=m,t[44]=n,t[45]=U):U=t[45];let W;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Z.jsx)(Jr,{}),t[46]=W):W=t[46];let G;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)(vr,{children:ko(vo.openToSide)}),t[47]=G):G=t[47];let ee;t[48]!==O||t[49]!==H||t[50]!==U?(ee=(0,Z.jsxs)(Xr,{disabled:H,onClick:U,children:[W,O,G]}),t[48]=O,t[49]=H,t[50]=U,t[51]=ee):ee=t[51];let te;t[52]===h?te=t[53]:(te=h&&(0,Z.jsxs)(Xr,{onClick:h,children:[(0,Z.jsx)(Jr,{}),`Close pane`]}),t[52]=h,t[53]=te);let ne;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(cr,{}),t[54]=ne):ne=t[54];let re;t[55]===n?re=t[56]:(re=Gg(n),t[55]=n,t[56]=re);let ie;t[57]!==u||t[58]!==n?(ie=()=>u(n),t[57]=u,t[58]=n,t[59]=ie):ie=t[59];let ae;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(jt,{}),t[60]=ae):ae=t[60];let K;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Z.jsx)(vr,{children:ko(vo.closeTab)}),t[61]=K):K=t[61];let oe;t[62]!==re||t[63]!==ie?(oe=(0,Z.jsxs)(Xr,{disabled:re,onClick:ie,children:[ae,`Close`,K]}),t[62]=re,t[63]=ie,t[64]=oe):oe=t[64];let se;t[65]!==d||t[66]!==n?(se=()=>d(n),t[65]=d,t[66]=n,t[67]=se):se=t[67];let ce;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(Mc,{}),t[68]=ce):ce=t[68];let le;t[69]===se?le=t[70]:(le=(0,Z.jsxs)(Xr,{onClick:se,children:[ce,`Close others`]}),t[69]=se,t[70]=le);let ue=!s,de;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Z.jsx)(Ec,{}),t[71]=de):de=t[71];let J;t[72]!==f||t[73]!==ue?(J=(0,Z.jsxs)(Xr,{disabled:ue,onClick:f,children:[de,`Close unpinned`]}),t[72]=f,t[73]=ue,t[74]=J):J=t[74];let fe;t[75]!==I||t[76]!==V||t[77]!==ee||t[78]!==te||t[79]!==oe||t[80]!==le||t[81]!==J?(fe=(0,Z.jsxs)(Gr,{className:`min-w-52`,finalFocus:I,children:[V,ee,te,ne,oe,le,J]}),t[75]=I,t[76]=V,t[77]=ee,t[78]=te,t[79]=oe,t[80]=le,t[81]=J,t[82]=fe):fe=t[82];let pe;t[83]!==fe||t[84]!==F?(pe=(0,Z.jsxs)(ur,{onOpenChange:j,children:[F,fe]}),t[83]=fe,t[84]=F,t[85]=pe):pe=t[85];let me;t[86]!==r||t[87]!==S?(me=r&&(0,Z.jsx)(`span`,{id:S,hidden:!0,children:r.description}),t[86]=r,t[87]=S,t[88]=me):me=t[88];let he;return t[89]!==pe||t[90]!==me?(he=(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1`,children:[pe,me]}),t[89]=pe,t[90]=me,t[91]=he):he=t[91],he}function U_(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({commitContext:n,oid:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]!==n||t[5]!==r?(a=lh({...n,oid:r,parent:1}),t[4]=n,t[5]=r,t[6]=a):a=t[6];let o=N(a),s;t[7]===o?s=t[8]:(s=Nt(bt(o)),t[7]=o,t[8]=s);let c=s?.commit.subject,l;return t[9]!==c||t[10]!==i?(l=(0,Z.jsx)(H_,{...i,commitSubject:c}),t[9]=c,t[10]=i,t[11]=l):l=t[11],l}function W_(e,t,n){let r=(0,$.c)(13),i;r[0]!==e||r[1]!==n||r[2]!==t?(i=xt({connection:e,projectId:t,number:n}),r[0]=e,r[1]=n,r[2]=t,r[3]=i):i=r[3];let{value:a}=is(i),o=Oi(e);if(a.kind!==`available`)return;let s;if(r[4]!==o.projects||r[5]!==t||r[6]!==a.pullRequest){let e;r[8]===t?e=r[9]:(e=e=>e.id===t&&e.available,r[8]=t,r[9]=e),s=o.projects.find(e)?.worktrees.find(e=>e.available&&e.branch===a.pullRequest.headBranch),r[4]=o.projects,r[5]=t,r[6]=a.pullRequest,r[7]=s}else s=r[7];let c=s,l;return r[10]!==t||r[11]!==c?(l=c?{projectId:t,worktreeId:c.id}:void 0,r[10]=t,r[11]=c,r[12]=l):l=r[12],l}function G_(e){let t=(0,$.c)(13),{label:n,description:r,icon:i,shortcut:a,onClick:o,disabled:s,pressed:c,variant:l,iconOnly:u}=e,d=s!==void 0&&s,f=l===void 0?`ghost`:l,p=u!==void 0&&u,m;t[0]===p?m=t[1]:(m=p?[`compact`]:[`compact`,`key`,`full`],t[0]=p,t[1]=m);let h;return t[2]!==i||t[3]!==r||t[4]!==d||t[5]!==p||t[6]!==n||t[7]!==o||t[8]!==c||t[9]!==a||t[10]!==m||t[11]!==f?(h=(0,Z.jsx)(Z.Fragment,{children:m.map(e=>(0,Z.jsxs)(wn,{children:[(0,Z.jsxs)(nn,{render:(0,Z.jsx)(Y,{variant:f,size:e===`compact`?`icon`:`default`,className:q(!p&&e===`compact`&&`@min-lg/pane:hidden`,e===`key`&&`hidden @min-lg/pane:inline-flex @min-3xl/pane:hidden`,e===`full`&&`hidden @min-3xl/pane:inline-flex`),"aria-label":n,"aria-keyshortcuts":a,"aria-pressed":c,disabled:d,focusableWhenDisabled:!0,onClick:o}),children:[c===!1?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`size-3.5 shrink-0 rounded-sm border-[--spacing(0.375)] border-border-strong bg-background`}):(0,Z.jsx)(i,{className:`size-3.5`}),e===`full`&&(0,Z.jsx)(`span`,{children:n}),a&&e!==`compact`&&(0,Z.jsx)(Jn,{children:ko(a)})]}),(0,Z.jsxs)(yt,{role:`tooltip`,children:[r??n,a&&(0,Z.jsx)(Jn,{children:ko(a)})]})]},e))}),t[2]=i,t[3]=r,t[4]=d,t[5]=p,t[6]=n,t[7]=o,t[8]=c,t[9]=a,t[10]=m,t[11]=f,t[12]=h):h=t[12],h}function K_(e,t,n){let r=(0,$.c)(4),i=n===void 0?Gi:n,a;return r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=da({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3],is(a).value}function q_(e,t,n){let r=(0,$.c)(4),i=n===void 0?Gi:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=da({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3],ie(a)}function J_(e,t,n,r){let i=(0,$.c)(4),a=K_(e,t),o;return i[0]!==n||i[1]!==r||i[2]!==a?(o=Br(n,a,r),i[0]=n,i[1]=r,i[2]=a,i[3]=o):o=i[3],o}function Y_(e){let t=(0,$.c)(13),{scope:n,context:r,base:i,children:a}=e,s=Li(n,r.connection,i);if(Qt(s.result)){let e;t[0]===s.result.cause?e=t[1]:(e=Xl(En(s.result.cause)),t[0]=s.result.cause,t[1]=e);let n;return t[2]!==s.refresh||t[3]!==e?(n=(0,Z.jsx)(Ce,{description:e,onRetry:s.refresh}),t[2]=s.refresh,t[3]=e,t[4]=n):n=t[4],n}if(!gt(s.result)){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(o,{label:`Comparing the branch`}),t[5]=e):e=t[5],e}if(s.result.value.base===void 0){let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Rn,{title:`No default branch`,description:`Choose the branch this one is compared against in the Branch list.`}),t[6]=e):e=t[6],e}let c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(o,{label:`Comparing the branch`}),t[7]=c):c=t[7];let l;t[8]!==s.result.value||t[9]!==a?(l=a(s.result.value),t[8]=s.result.value,t[9]=a,t[10]=l):l=t[10];let u;return t[11]===l?u=t[12]:(u=(0,Z.jsx)(Q.Suspense,{fallback:c,children:l}),t[11]=l,t[12]=u),u}function X_(e){return e?e.hunks.flatMap(e=>{let t=e.additionStart;return e.hunkContent.flatMap(e=>{if(e.type===`context`)return t+=e.lines,[];let n=t;return t+=e.additions,Array.from({length:e.additions},(e,t)=>`[data-code] [data-line="${n+t}"] { box-shadow: inset calc(var(--spacing) * 0.75) 0 var(--add-fg); }`)})}).join(`
|
|
24
|
-
`):``}function
|
|
25
|
-
`).filter((e,t,n)=>t<n.length-1||e).length,deletions:0}:e.fileDiff.hunks.reduce((e,t)=>({additions:e.additions+t.additionLines,deletions:e.deletions+t.deletionLines}),{additions:0,deletions:0})}function rv(e,t,n){let r=(0,$.c)(9),i=n===void 0?Gi:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=di({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3];let o=a.set,s;r[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={mode:`promiseExit`},r[4]=s):s=r[4];let[l,u]=L(o,s),d=c(o),f;return r[5]!==l||r[6]!==u||r[7]!==d?(f={result:l,submit:u,start:d},r[5]=l,r[6]=u,r[7]=d,r[8]=f):f=r[8],f}function iv(e,t,n){let r=(0,$.c)(9),i=n===void 0?Gi:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=di({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3];let o=a.remove,s;r[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={mode:`promiseExit`},r[4]=s):s=r[4];let[l,u]=L(o,s),d=c(o),f;return r[5]!==l||r[6]!==u||r[7]!==d?(f={result:l,submit:u,start:d},r[5]=l,r[6]=u,r[7]=d,r[8]=f):f=r[8],f}function av(e,t,n){let r=(0,$.c)(10),i=n===void 0?Gi:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=di({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3];let[o,s]=L(a.bulk),c;r[4]===o?c=r[5]:(c=Nt(bt(o)),r[4]=o,r[5]=c);let l=c,u=!o.waiting&&l?.kind===`mark`?l.report:null,d;return r[6]!==o||r[7]!==s||r[8]!==u?(d={result:o,report:u,start:s},r[6]=o,r[7]=s,r[8]=u,r[9]=d):d=r[9],d}function ov(e,t,n,r){let i=(0,$.c)(4),a=r===void 0?Gi:r,o=rv(e,t,a),s=iv(e,t,a),c;return i[0]!==o||i[1]!==n||i[2]!==s?(c={toggle(e){let t=ai(e,o.result.waiting||s.result.waiting);t&&(t.kind===`unmark`?s.submit(t.path):o.submit(t.input)).then(e=>{$t(e)&&n({title:`Could not update review`,description:ca(En(e.cause)),type:`error`})})}},i[0]=o,i[1]=n,i[2]=s,i[3]=c):c=i[3],c}function sv(e){let t=(0,$.c)(7),{counts:n}=e,r;t[0]===n.additions?r=t[1]:(r=(0,Z.jsxs)(`span`,{className:`text-add-fg`,children:[`+`,n.additions]}),t[0]=n.additions,t[1]=r);let i;t[2]===n.deletions?i=t[3]:(i=(0,Z.jsxs)(`span`,{className:`text-del-fg`,children:[`−`,n.deletions]}),t[2]=n.deletions,t[3]=i);let a;return t[4]!==r||t[5]!==i?(a=(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-xs leading-4 font-medium tabular-nums`,children:[r,` `,i]}),t[4]=r,t[5]=i,t[6]=a):a=t[6],a}function cv(e){if(!(!e||e.side===`deletions`||e.endSide!==void 0&&e.endSide!==e.side))return{startLine:Math.min(e.start,e.end),endLine:Math.max(e.start,e.end)}}function lv(e){let t=(0,$.c)(10),n=ov(e.scope,e.context,uv,e.range),r;t[0]!==e.interaction.entry||t[1]!==e.range?(r=JSON.stringify([e.interaction.entry,e.range]),t[0]=e.interaction.entry,t[1]=e.range,t[2]=r):r=t[2];let i;t[3]!==e.onReview||t[4]!==n?(i=e.onReview??(e=>n.toggle(e.review)),t[3]=e.onReview,t[4]=n,t[5]=i):i=t[5];let a;return t[6]!==e||t[7]!==r||t[8]!==i?(a=(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(dv,{...e,onToggleReviewed:i},r)}),t[6]=e,t[7]=r,t[8]=i,t[9]=a):a=t[9],a}function uv(e){return bo.add(e)}function dv(e){let t=(0,$.c)(117),{entries:n,scope:r,context:i,interaction:a,header:o,footer:s,headerLeading:c,headerActions:l,emptyActions:u,toolbar:d,foundLine:p,disableFileHeader:m,fileDiff:h,compactThreads:_,fullHeight:v,compactHeight:y,collapsible:b,decision:x,column:S,framed:C,range:w,onToggleReviewed:T}=e,E=m!==void 0&&m,D=_!==void 0&&_,O=v!==void 0&&v,k=y!==void 0&&y,A=b!==void 0&&b,j=x!==void 0&&x,M=S!==void 0&&S,N=C!==void 0&&C,{dark:P}=wo(),{preferences:F}=Va(),I=xs(i.connection),L=j?n:eu(n,I),z=b_(a.worktreeId,a.entry),B;t[0]!==i.connection.environmentId||t[1]!==a.entry||t[2]!==a.worktreeId||t[3]!==w?(B=JSON.stringify([i.connection.environmentId,a.worktreeId,a.entry,w]),t[0]=i.connection.environmentId,t[1]=a.entry,t[2]=a.worktreeId,t[3]=w,t[4]=B):B=t[4];let V=w_(B),H;t[5]===V?H=t[6]:(H=()=>V.selection(),t[5]=V,t[6]=H);let[U,W]=(0,Q.useState)(H),G=U?L.find(e=>e.id===U.lines.id):void 0,ee=U!==null&&G?.version!==U.version,te=ee?null:U?.lines??null,ne=e=>{let t=e?L.find(t=>t.id===e.id):void 0,n=e&&t?{lines:e,version:t.version}:null;W(n),V.rememberSelection(n)},re=te?.range,ie;t[7]===re?ie=t[8]:(ie=cv(re),t[7]=re,t[8]=ie);let ae=ie,K;t[9]===V?K=t[10]:(K=()=>V.focused(),t[9]=V,t[10]=K);let[oe,se]=(0,Q.useState)(K),ce;t[11]===V?ce=t[12]:(ce=e=>{se(e),V.rememberFocus(e)},t[11]=V,t[12]=ce);let le=ce,ue;t[13]===oe?ue=t[14]:(ue=e=>e.id===oe,t[13]=oe,t[14]=ue);let de=Math.max(L.findIndex(ue),0),J=new Set(L.filter(e=>l_(z.folds,e.id,L.length>1&&e.review?.reviewed===!0||(A||L.length>1)&&I&&$l(e.path))).map(gv)),[fe,pe]=(0,Q.useState)(),[me,he]=(0,Q.useState)(),ge=e=>{let t=L[e];t&&(le(t.id),V.scrollTo({type:`item`,id:t.id,align:`start`}))},_e=new Map(L.map(hv)),ve=L.map(e=>({id:e.id,collapsed:J.has(e.id),version:Fo(JSON.stringify([e.version,J.has(e.id)])),...ev(e)})),ye=L.filter(mv),be=new Set(ye.map(pv)).size,xe=ye[0]?.id,Se=new Map;for(let e of L)e.review&&!Se.has(e.review.path)&&Se.set(e.review.path,e.id);let Ce=O||s?12:160,we=j||M||D||N?ts:ps,Te=P?`dark`:`light`,Ee=F.lineOverflow,De=F.diffStyle,Oe=!E&&!O,ke=E||k,je,Me;t[15]===le?(je=t[16],Me=t[17]):(je=(e,t)=>le(t.item.id),Me=(e,t)=>le(t.item.id),t[15]=le,t[16]=je,t[17]=Me);let Ne;t[18]===h?Ne=t[19]:(Ne=X_(h),t[18]=h,t[19]=Ne);let Pe=`${D?`[data-line-annotation]:has([data-file-thread-marker]) { margin-left: 0; }`:``}${Ne}${j||M||N?gs:``}${M?zo:``}${rs}${E||k?`[data-code] { padding-top: 0 !important; }`:Wo}${D?fs:``}${k?`[data-diffs-header], pre { border: 0; border-radius: 0; }`:``}`,Fe;t[20]===M?Fe=t[21]:(Fe=M?{itemMetrics:{lineHeight:22,diffHeaderHeight:41}}:{},t[20]=M,t[21]=Fe);let Ie;t[22]!==k||t[23]!==E?(Ie=E||k?{itemMetrics:{paddingTop:0}}:{},t[22]=k,t[23]=E,t[24]=Ie):Ie=t[24];let Le=E||k?0:12,Re=k?0:Ce,ze;t[25]!==Le||t[26]!==Re?(ze={paddingTop:Le,paddingBottom:Re,gap:12},t[25]=Le,t[26]=Re,t[27]=ze):ze=t[27];let Be;t[28]!==F.diffStyle||t[29]!==F.lineOverflow||t[30]!==we||t[31]!==Te||t[32]!==Oe||t[33]!==ke||t[34]!==je||t[35]!==Me||t[36]!==Pe||t[37]!==Fe||t[38]!==Ie||t[39]!==ze?(Be={preferredHighlighter:jo,theme:we,themeType:Te,overflow:Ee,diffStyle:De,diffIndicators:`classic`,hunkSeparators:`line-info`,stickyHeaders:Oe,disableFileHeader:ke,enableLineSelection:!0,enableGutterUtility:!1,onLineClick:je,onLineNumberClick:Me,lineHoverHighlight:`number`,unsafeCSS:Pe,...Fe,...Ie,layout:ze},t[28]=F.diffStyle,t[29]=F.lineOverflow,t[30]=we,t[31]=Te,t[32]=Oe,t[33]=ke,t[34]=je,t[35]=Me,t[36]=Pe,t[37]=Fe,t[38]=Ie,t[39]=ze,t[40]=Be):Be=t[40];let Ve=Be,He=L.length>0&&L.every(e=>J.has(e.id)),Ue;t[41]!==L||t[42]!==z?(Ue=e=>z.setCollapsed(L.map(fv),e),t[41]=L,t[42]=z,t[43]=Ue):Ue=t[43];let We=Ue,Ge=e=>{le(e),z.setCollapsed([e],!J.has(e))},Ke;t[44]===He?Ke=t[45]:(Ke=He?(0,Z.jsx)(Qs,{"aria-hidden":`true`,"data-icon":`inline-start`}):(0,Z.jsx)(Xs,{"aria-hidden":`true`,"data-icon":`inline-start`}),t[44]=He,t[45]=Ke);let qe=Ke,Je=He?`Expand all files`:`Collapse all files`,Ye;t[46]!==He||t[47]!==We?(Ye=()=>We(!He),t[46]=He,t[47]=We,t[48]=Ye):Ye=t[48];let Xe;t[49]!==qe||t[50]!==Je||t[51]!==Ye?(Xe=(0,Z.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:Ye,children:[qe,Je]}),t[49]=qe,t[50]=Je,t[51]=Ye,t[52]=Xe):Xe=t[52];let Ze=Xe,Qe=L.length>1?Ze:null,$e;t[53]!==a.entry||t[54]!==a.singleHeader||t[55]!==a.toolbarTarget?($e=a.toolbarTarget!==void 0&&(/^(file|review-file|review-change|change|branch|walkthrough-step):/.test(a.entry)||a.singleHeader&&a.entry===`branch`),t[53]=a.entry,t[54]=a.singleHeader,t[55]=a.toolbarTarget,t[56]=$e):$e=t[56];let et=$e,tt=L[de]??L[0],nt;t[57]!==u||t[58]!==tt||t[59]!==l||t[60]!==T||t[61]!==et?(nt=et&&(tt?(0,Z.jsxs)(Z.Fragment,{children:[tt.review&&(0,Z.jsx)(G_,{label:`Reviewed`,variant:`outline`,icon:tt?.review?.reviewed?g:Pc,shortcut:vo.toggleReviewed,disabled:!tt?.review?.fingerprint,pressed:tt?.review?.reviewed,onClick:()=>{tt&&T(tt)}}),l]}):u??l),t[57]=u,t[58]=tt,t[59]=l,t[60]=T,t[61]=et,t[62]=nt):nt=t[62];let rt=nt,it;t[63]!==Qe||t[64]!==L||t[65]!==ge||t[66]!==de||t[67]!==z||t[68]!==o?(it=o&&(()=>o({collapse:Qe,current:L[de]?.path,counts:tv(L),open:e=>{let t=L.findIndex(t=>t.path===e),n=L[t];n&&z.setCollapsed([n.id],!1),ge(t)}})),t[63]=Qe,t[64]=L,t[65]=ge,t[66]=de,t[67]=z,t[68]=o,t[69]=it):it=t[69];let at=it,ot=(j||M||D||N)&&`decision-code`,st=D&&`file-code`,ct=N&&`commit-code`,lt=k&&`overflow-hidden rounded-lg border`,ut;t[70]!==ot||t[71]!==st||t[72]!==ct||t[73]!==lt?(ut=q(`@container/code relative flex min-h-0 flex-1 flex-col`,ot,st,ct,lt),t[70]=ot,t[71]=st,t[72]=ct,t[73]=lt,t[74]=ut):ut=t[74];let dt;t[75]!==a.toolbarTarget||t[76]!==rt?(dt=a.toolbarTarget&&rt&&(0,ru.createPortal)(rt,a.toolbarTarget),t[75]=a.toolbarTarget,t[76]=rt,t[77]=dt):dt=t[77];let ft;t[78]!==L||t[79]!==ge||t[80]!==de||t[81]!==a.active||t[82]!==T?(ft=a.active&&L.length>0&&(0,Z.jsx)(vv,{next:()=>ge(Math.min(de+1,L.length-1)),previous:()=>ge(Math.max(de-1,0)),review:()=>{let e=L[de];e?.review&&T(e)}}),t[78]=L,t[79]=ge,t[80]=de,t[81]=a.active,t[82]=T,t[83]=ft):ft=t[83];let pt;t[84]===ee?pt=t[85]:(pt=ee&&(0,Z.jsx)(`p`,{role:`status`,className:`absolute bottom-3 left-3 z-10 rounded-lg border bg-popover p-2 text-xs`,children:`Code changed since these lines were selected. Select lines again.`}),t[84]=ee,t[85]=pt);let mt;t[86]!==ae||t[87]!==i||t[88]!==r||t[89]!==G?(mt=ae&&G?.discardScope&&(0,Z.jsx)(`div`,{className:`absolute bottom-3 left-3 z-10 rounded-lg border bg-popover p-2`,children:(0,Z.jsx)(wm,{scope:r,context:i,path:G.path,hunk:{scope:G.discardScope,...ae},variant:`compact`})}),t[86]=ae,t[87]=i,t[88]=r,t[89]=G,t[90]=mt):mt=t[90];let ht;t[91]!==Qe||t[92]!==M||t[93]!==d?(ht=d?d(Qe):!M&&Qe&&(0,Z.jsx)(`div`,{className:`flex shrink-0 justify-end px-3`,children:Qe}),t[91]=Qe,t[92]=M,t[93]=d,t[94]=ht):ht=t[94];let gt;t[95]!==M||t[96]!==L.length||t[97]!==s||t[98]!==o||t[99]!==l||t[100]!==c||t[101]!==et||t[102]!==at?(gt=L.length===0&&(o||l||s)&&(0,Z.jsxs)(`div`,{className:q(`min-h-0 flex-1 overflow-auto`,M&&_v),"data-testid":`empty-code-document`,children:[c&&(0,Z.jsx)(`div`,{className:`flex items-center gap-1 px-3.5 py-2`,children:c}),at?.(),s?.(),!et&&l&&(0,Z.jsx)(`div`,{className:`flex justify-end px-3.5 py-2`,children:(0,Z.jsx)(jm,{children:l})})]}),t[95]=M,t[96]=L.length,t[97]=s,t[98]=o,t[99]=l,t[100]=c,t[101]=et,t[102]=at,t[103]=gt):gt=t[103];let _t;t[104]!==k||t[105]!==L[0]?(_t=k&&L[0]&&(0,Z.jsx)(`div`,{className:`flex min-h-10 shrink-0 items-center gap-2 border-b bg-muted px-2 py-1`,children:(0,Z.jsx)(X,{className:`min-w-0 flex-1 font-mono text-caption font-medium`,text:L[0].path})}),t[104]=k,t[105]=L[0],t[106]=_t):_t=t[106];let vt=L.length>0&&(0,Z.jsx)(fp,{ref:e=>{if(!e)return;let t=e.getInstance();if(!t)return;let n=V.attach(t),r=requestAnimationFrame(()=>{V.restorePosition(t,Ve.stickyHeaders&&!Ve.disableFileHeader?Ve.itemMetrics?.diffHeaderHeight??Wa.diffHeaderHeight:0);let n=a.fileTarget,r=n?L.find(e=>e.path===n.path):void 0;n&&r&&n.nonce!==me&&(z.setCollapsed([r.id],!1),e.scrollTo({type:`item`,id:r.id,align:`start`}),le(r.id),he(n.nonce));let i=L[0];p&&i&&fe!==p.nonce&&(ne({id:i.id,range:{start:p.line,end:p.line}}),e.scrollTo({type:`line`,id:i.id,lineNumber:p.line,align:`center`}),pe(p.nonce))});return()=>{cancelAnimationFrame(r),n?.()}},items:ve,onScroll:V.rememberPosition,selectedLines:te,onSelectedLinesChange:e=>{ne(e),e&&le(e.id)},renderHeaderMetadata:e=>{let t=_e.get(e.id);if(E||!t)return null;let n=e.id===L[0]?.id,r=!et&&n?l:null,i=e.id===L[0]?.id?c:null,a=t.review?.stale?(0,Z.jsx)(`span`,{className:`rounded-md bg-graph-4/15 px-1.5 py-0.5 font-sans text-2xs text-graph-4`,children:`Changed since reviewed`}):null;return M?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[a,(0,Z.jsx)(sv,{counts:nv(t)})]}):!a&&!i&&!r?null:(0,Z.jsxs)(`div`,{className:q(`flex max-w-full items-center justify-end gap-1.5`,!j&&`flex-wrap`),children:[a,i,r&&(0,Z.jsx)(jm,{children:r})]})},disableWorkerPool:j||M||D||N,options:Ve,className:q(k&&`max-h-48 flex-none overflow-auto`,!k&&O&&`flex-none overflow-visible`,!k&&!O&&`min-h-0 flex-1 overflow-auto`,M&&_v),...at?{renderCodeViewHeader:at}:{},...s?{renderCodeViewFooter:s}:{},renderHeaderPrefix:e=>{let t=_e.get(e.id);if(!t)return null;let n=J.has(e.id),r=t.review,i=r&&!et&&Se.get(r.path)===t.id?r.control:null;return(0,Z.jsxs)(`span`,{className:q(`flex items-center`,M?`gap-2`:`gap-1`),children:[!j&&I&&e.id===xe&&L.length>ye.length&&(0,Z.jsxs)(`span`,{className:`mr-2 border-r pr-2 font-sans text-xs font-medium`,children:[`Specs · `,R(be,`file`)]}),(M||A||L.length>1)&&(0,Z.jsx)(yv,{label:`${n?`Expand`:`Collapse`} ${t.path}`,icon:n?f:Ae,expanded:!n,onClick:()=>Ge(e.id)}),i]})},renderHeaderFilenameSuffix:e=>{let t=_e.get(e.id);return t&&t.note?(0,Z.jsx)(X,{className:`ml-2 hidden max-w-48 font-sans text-xs text-muted-foreground @code-wide/code:block`,text:t.note}):null}}),yt;return t[107]!==ut||t[108]!==dt||t[109]!==ft||t[110]!==pt||t[111]!==mt||t[112]!==ht||t[113]!==gt||t[114]!==_t||t[115]!==vt?(yt=(0,Z.jsxs)(`div`,{role:`region`,"aria-label":`Code content`,className:ut,children:[dt,ft,pt,mt,ht,gt,_t,vt]}),t[107]=ut,t[108]=dt,t[109]=ft,t[110]=pt,t[111]=mt,t[112]=ht,t[113]=gt,t[114]=_t,t[115]=vt,t[116]=yt):yt=t[116],yt}function fv(e){return e.id}function pv(e){return e.path}function mv(e){return $l(e.path)}function hv(e){return[e.id,e]}function gv(e){return e.id}var _v=`px-[max(--spacing(4),calc((100%-var(--container-reading))/2))] @2xl/pane:px-[max(--spacing(7),calc((100%-var(--container-reading))/2))]`;function vv(e){let t=(0,$.c)(1),{next:n,previous:r,review:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={ignoreInputs:!0},t[0]=a):a=t[0];let o=a;return So(vo.nextFile,n,o),So(vo.previousFile,r,o),So(vo.toggleReviewed,i,o),null}function yv(e){let t=(0,$.c)(14),{label:n,icon:r,expanded:i,onClick:a}=e,o;t[0]!==i||t[1]!==n||t[2]!==a?(o=(0,Z.jsx)(Y,{size:`icon-xs`,variant:`ghost`,"aria-label":n,"aria-expanded":i,onClick:a}),t[0]=i,t[1]=n,t[2]=a,t[3]=o):o=t[3];let s;t[4]===r?s=t[5]:(s=(0,Z.jsx)(r,{}),t[4]=r,t[5]=s);let c;t[6]!==o||t[7]!==s?(c=(0,Z.jsx)(nn,{render:o,children:s}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===n?l=t[10]:(l=(0,Z.jsx)(yt,{children:n}),t[9]=n,t[10]=l);let u;return t[11]!==c||t[12]!==l?(u=(0,Z.jsxs)(wn,{children:[c,l]}),t[11]=c,t[12]=l,t[13]=u):u=t[13],u}function bv(e){let t=(0,$.c)(51),{target:n,barActions:r,title:i,titleLabel:a,subtitle:o,children:s,className:c,inline:l}=e;if(l!==void 0&&l){let e=a??(typeof i==`string`?i:``),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`h1`,{}),t[0]=n):n=t[0];let r;t[1]!==e||t[2]!==i?(r=(0,Z.jsx)(X,{text:e,render:n,className:`min-w-0 text-ui font-semibold`,children:i}),t[1]=e,t[2]=i,t[3]=r):r=t[3];let c;t[4]===o?c=t[5]:(c=o&&(0,Z.jsx)(`span`,{className:`shrink-0 text-caption text-muted-foreground`,children:o}),t[4]=o,t[5]=c);let l;t[6]!==r||t[7]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-64 items-baseline gap-2`,children:[r,c]}),t[6]=r,t[7]=c,t[8]=l):l=t[8];let u;t[9]===s?u=t[10]:(u=(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:s}),t[9]=s,t[10]=u);let d;return t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(`header`,{"data-testid":`document-toolbar`,className:`flex min-h-11 shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b px-4 py-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}if(n!==void 0){let e;t[14]!==r||t[15]!==s||t[16]!==n?(e=n&&(0,ru.createPortal)(r===void 0?s:r,n),t[14]=r,t[15]=s,t[16]=n,t[17]=e):e=t[17];let c=a??(typeof i==`string`?i:``),l;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`h1`,{}),t[18]=l):l=t[18];let u;t[19]!==c||t[20]!==i?(u=(0,Z.jsx)(X,{text:c,render:l,className:`text-ui font-semibold`,children:i}),t[19]=c,t[20]=i,t[21]=u):u=t[21];let d;t[22]===o?d=t[23]:(d=o&&(0,Z.jsx)(`p`,{className:`text-2xs text-muted-foreground`,children:o}),t[22]=o,t[23]=d);let f;t[24]!==r||t[25]!==s?(f=r!==void 0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:s}),t[24]=r,t[25]=s,t[26]=f):f=t[26];let p;t[27]!==u||t[28]!==d||t[29]!==f?(p=(0,Z.jsxs)(`div`,{className:`shrink-0 px-3.5 py-2`,children:[u,d,f]}),t[27]=u,t[28]=d,t[29]=f,t[30]=p):p=t[30];let m;return t[31]!==e||t[32]!==p?(m=(0,Z.jsxs)(Z.Fragment,{children:[e,p]}),t[31]=e,t[32]=p,t[33]=m):m=t[33],m}let u;t[34]===c?u=t[35]:(u=q(`flex min-h-11 shrink-0 flex-wrap items-center gap-x-2.5 gap-y-1 border-b px-3.5`,c),t[34]=c,t[35]=u);let d=a??(typeof i==`string`?i:``),f;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(`h1`,{}),t[36]=f):f=t[36];let p;t[37]!==d||t[38]!==i?(p=(0,Z.jsx)(X,{text:d,render:f,className:`text-ui leading-tight font-semibold`,children:i}),t[37]=d,t[38]=i,t[39]=p):p=t[39];let m;t[40]===o?m=t[41]:(m=o!=null&&(0,Z.jsx)(X,{text:o,render:(0,Z.jsx)(`p`,{}),className:`text-2xs leading-tight text-muted-foreground`}),t[40]=o,t[41]=m);let h;t[42]!==p||t[43]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-auto flex-col`,children:[p,m]}),t[42]=p,t[43]=m,t[44]=h):h=t[44];let g;t[45]===s?g=t[46]:(g=(0,Z.jsx)(`div`,{className:`ml-auto flex max-w-full shrink-0 flex-wrap items-center justify-end gap-1.5`,children:s}),t[45]=s,t[46]=g);let _;return t[47]!==u||t[48]!==h||t[49]!==g?(_=(0,Z.jsxs)(`header`,{"data-testid":`document-toolbar`,className:u,children:[h,g]}),t[47]=u,t[48]=h,t[49]=g,t[50]=_):_=t[50],_}function xv(e){let t=(0,$.c)(4),{more:n,pending:r,onReadMore:i}=e;if(n<=0)return null;let a=r?`Reading…`:`Read ${Math.min(n,25)} more of ${n}`,o;return t[0]!==i||t[1]!==r||t[2]!==a?(o=(0,Z.jsx)(`div`,{className:`border-t px-4 py-3 text-center`,children:(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,onClick:i,disabled:r,children:a})}),t[0]=i,t[1]=r,t[2]=a,t[3]=o):o=t[3],o}function Sv(e,t,n){return{path:n.path,fingerprint:n.fingerprint??null,reviewed:n.reviewStatus===`reviewed`,stale:n.reviewStatus===`stale`,control:(0,Z.jsx)(Cv,{scope:e,context:t,path:n.path,fingerprint:n.fingerprint,status:n.reviewStatus,compact:!0},`review:${n.path}`)}}function Cv(e){let t=(0,$.c)(45),{scope:n,context:r,path:i,fingerprint:a,status:o,compact:s,range:c}=e,l=s!==void 0&&s,u=c===void 0?Gi:c,d=rv(n,r,u),f=iv(n,r,u),p=d.result.waiting||f.result.waiting,m,h;if(t[0]!==l||t[1]!==a||t[2]!==d||t[3]!==i||t[4]!==p||t[5]!==o||t[6]!==f){h=Symbol.for(`react.early_return_sentinel`);bb0:{let e=pa(d.result,f.result);if(a==null){let e;t[9]===i?e=t[10]:(e=fa([i]),t[9]=i,t[10]=e);let n;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(ha,{className:`size-3`,"aria-hidden":`true`}),t[11]=n):n=t[11];let r=l?`Not reviewable`:`Not reviewable: too large or unreadable`,a;t[12]!==e||t[13]!==r?(a=(0,Z.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1 text-2xs text-muted-foreground`,children:[n,r]}),t[12]=e,t[13]=r,t[14]=a):a=t[14],h=a;break bb0}let n=o===`reviewed`,r;t[15]!==i||t[16]!==o?(r=aa(i,o),t[15]=i,t[16]=o,t[17]=r):r=t[17];let s=r,c=l?`icon-xs`:`xs`,u=n?`ghost`:`outline`,g;t[18]!==a||t[19]!==d||t[20]!==i||t[21]!==n||t[22]!==f?(g=()=>{n?f.start(i):d.start({path:i,fingerprint:a})},t[18]=a,t[19]=d,t[20]=i,t[21]=n,t[22]=f,t[23]=g):g=t[23];let _;t[24]!==l||t[25]!==p||t[26]!==o?(_=(0,Z.jsx)(Ev,{pending:p,status:o,compact:l}),t[24]=l,t[25]=p,t[26]=o,t[27]=_):_=t[27];let v;t[28]!==l||t[29]!==o?(v=!l&&Dv(o),t[28]=l,t[29]=o,t[30]=v):v=t[30];let y;t[31]!==s||t[32]!==p||t[33]!==n||t[34]!==v||t[35]!==c||t[36]!==u||t[37]!==g||t[38]!==_?(y=(0,Z.jsx)(nn,{render:(0,Z.jsxs)(Y,{type:`button`,size:c,variant:u,"aria-pressed":n,disabled:p,"aria-label":s,onClick:g,children:[_,v]})}),t[31]=s,t[32]=p,t[33]=n,t[34]=v,t[35]=c,t[36]=u,t[37]=g,t[38]=_,t[39]=y):y=t[39];let b;t[40]===s?b=t[41]:(b=(0,Z.jsx)(yt,{role:`tooltip`,className:`break-all`,children:s}),t[40]=s,t[41]=b);let x;t[42]!==y||t[43]!==b?(x=(0,Z.jsxs)(wn,{children:[y,b]}),t[42]=y,t[43]=b,t[44]=x):x=t[44],m=(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[x,e!==void 0&&(0,Z.jsx)(X,{className:`max-w-52 text-2xs text-destructive`,render:(0,Z.jsx)(`span`,{role:`alert`}),text:ca(e)})]})}t[0]=l,t[1]=a,t[2]=d,t[3]=i,t[4]=p,t[5]=o,t[6]=f,t[7]=m,t[8]=h}else m=t[7],h=t[8];return h===Symbol.for(`react.early_return_sentinel`)?m:h}function wv(e){let t=(0,$.c)(23),{scope:n,context:r,path:i,fingerprint:a,status:o,latest:s,onStart:c}=e,l=rv(n,r,Gi),u=iv(n,r,Gi),d=l.result.waiting||u.result.waiting,f=pa(l.result,u.result),p=s?f:void 0,m=(0,Q.useId)(),h=o===`reviewed`,g=a!=null,_=o===`stale`?`Changed since reviewed`:`Toggle reviewed`,v;t[0]!==i||t[1]!==g||t[2]!==_?(v=g?_:fa([i]),t[0]=i,t[1]=g,t[2]=_,t[3]=v):v=t[3];let y=v,b=`${i} reviewed`,x=p!==void 0,S=d||!g,C;t[4]!==d||t[5]!==a||t[6]!==l||t[7]!==c||t[8]!==i||t[9]!==h||t[10]!==u?(C=()=>{d||a==null||(c(),h?u.start(i):l.start({path:i,fingerprint:a}))},t[4]=d,t[5]=a,t[6]=l,t[7]=c,t[8]=i,t[9]=h,t[10]=u,t[11]=C):C=t[11];let w;t[12]!==d||t[13]!==m||t[14]!==h||t[15]!==b||t[16]!==x||t[17]!==S||t[18]!==C?(w=(0,Z.jsx)(nn,{render:(0,Z.jsx)(Jm,{checked:h,"aria-label":b,"aria-describedby":m,"aria-invalid":x,disabled:S,"aria-busy":d,onCheckedChange:C})}),t[12]=d,t[13]=m,t[14]=h,t[15]=b,t[16]=x,t[17]=S,t[18]=C,t[19]=w):w=t[19];let T;return t[20]!==y||t[21]!==m?(T=(0,Z.jsx)(`span`,{id:m,hidden:!0,children:y}),t[20]=y,t[21]=m,t[22]=T):T=t[22],(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(wn,{children:[w,(0,Z.jsx)(yt,{role:`tooltip`,className:`break-all`,children:p===void 0?y:ca(p)})]}),T,p!==void 0&&(0,Z.jsx)(`span`,{role:`alert`,className:`sr-only`,children:ca(p)})]})}function Tv(e){let t=(0,$.c)(44),{scope:n,context:r,entries:i,compact:a,range:o}=e,s=a!==void 0&&a,c=av(n,r,o===void 0?Gi:o),l,u,d,f,p,m,h,g,_,v,y,b,x;if(t[0]!==c||t[1]!==s||t[2]!==i){f=Si(i);let e=c.result.waiting,n=f.blocked||e;m=`inline-flex min-w-0 flex-col items-end gap-1`,d=wn,u=nn,l=Y,h=`button`,g=s?`icon-xs`:`xs`,_=`outline`,v=n,y=f.label,b=()=>{n||(f.unmarking?c.start({kind:`unmark`,paths:f.reviewedPaths}):c.start({kind:`mark`,entries:f.entries}))},x=(0,Z.jsx)(Ov,{pending:e,unmarking:f.unmarking}),p=!s&&kv(e,f.unmarking,f.text),t[0]=c,t[1]=s,t[2]=i,t[3]=l,t[4]=u,t[5]=d,t[6]=f,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=y,t[14]=b,t[15]=x}else l=t[3],u=t[4],d=t[5],f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],v=t[12],y=t[13],b=t[14],x=t[15];let S;t[16]!==l||t[17]!==p||t[18]!==h||t[19]!==g||t[20]!==_||t[21]!==v||t[22]!==y||t[23]!==b||t[24]!==x?(S=(0,Z.jsxs)(l,{type:h,size:g,variant:_,disabled:v,"aria-label":y,onClick:b,children:[x,p]}),t[16]=l,t[17]=p,t[18]=h,t[19]=g,t[20]=_,t[21]=v,t[22]=y,t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]!==u||t[27]!==S?(C=(0,Z.jsx)(u,{render:S}),t[26]=u,t[27]=S,t[28]=C):C=t[28];let w;t[29]===f.label?w=t[30]:(w=(0,Z.jsx)(yt,{role:`tooltip`,className:`break-all`,children:f.label}),t[29]=f.label,t[30]=w);let T;t[31]!==d||t[32]!==C||t[33]!==w?(T=(0,Z.jsxs)(d,{children:[C,w]}),t[31]=d,t[32]=C,t[33]=w,t[34]=T):T=t[34];let E;t[35]===c.report?E=t[36]:(E=c.report&&(0,Z.jsx)(Av,{report:c.report}),t[35]=c.report,t[36]=E);let D;t[37]===c.result?D=t[38]:(D=Qt(c.result)&&(0,Z.jsx)(`span`,{role:`alert`,className:`max-w-64 text-right text-2xs text-destructive`,children:ca(En(c.result.cause))}),t[37]=c.result,t[38]=D);let O;return t[39]!==m||t[40]!==T||t[41]!==E||t[42]!==D?(O=(0,Z.jsxs)(`span`,{className:m,children:[T,E,D]}),t[39]=m,t[40]=T,t[41]=E,t[42]=D,t[43]=O):O=t[43],O}function Ev(e){let t=(0,$.c)(7),{pending:n,status:r,compact:i}=e;if(n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(dt,{className:`animate-spin`}),t[0]=e):e=t[0],e}if(r===`reviewed`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(g,{}),t[1]=e):e=t[1],e}if(r===`stale`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ss,{}),t[2]=e):e=t[2],e}let a=i&&`invisible`,o;t[3]===a?o=t[4]:(o=q(a),t[3]=a,t[4]=o);let s;return t[5]===o?s=t[6]:(s=(0,Z.jsx)(g,{className:o}),t[5]=o,t[6]=s),s}function Dv(e){return e===`reviewed`?`Reviewed`:e===`stale`?`Review again`:`Mark reviewed`}function Ov(e){let t=(0,$.c)(3),{pending:n,unmarking:r}=e;if(n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(dt,{className:`animate-spin`}),t[0]=e):e=t[0],e}if(r){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ss,{}),t[1]=e):e=t[1],e}let i;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(g,{}),t[2]=i):i=t[2],i}function kv(e,t,n){return e?t?`Unmarking…`:`Marking…`:n}function Av(e){let t=(0,$.c)(11),{report:n}=e,r=n.failed.length,i=r>0?`alert`:`status`,a=r>0?`text-destructive`:`text-muted-foreground`,o;t[0]===a?o=t[1]:(o=q(`max-w-64 text-right text-2xs leading-tight`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=r>0&&(0,Z.jsx)(dr,{className:`mr-1 inline size-3`}),t[2]=r,t[3]=s);let c;t[4]===n?c=t[5]:(c=wi(n),t[4]=n,t[5]=c);let l;return t[6]!==i||t[7]!==o||t[8]!==s||t[9]!==c?(l=(0,Z.jsxs)(`span`,{role:i,className:o,children:[s,c]}),t[6]=i,t[7]=o,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function jv(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Nv,{...e,path:void 0}),t[0]=e,t[1]=n),n}function Mv(e){let t=(0,$.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({path:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,Z.jsx)(Nv,{...r,path:n}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}function Nv(e){let t=(0,$.c)(14),{scope:n,context:r,interaction:i,base:a,path:o,only:s,heading:c,fullHeight:l,onOpen:u}=e,d=l!==void 0&&l,f;t[0]!==r||t[1]!==d||t[2]!==c||t[3]!==i||t[4]!==u||t[5]!==s||t[6]!==o||t[7]!==n?(f=e=>(0,Z.jsx)(Pv,{scope:n,context:r,interaction:i,onOpen:u,branch:e,path:o,only:s,heading:c,fullHeight:d}),t[0]=r,t[1]=d,t[2]=c,t[3]=i,t[4]=u,t[5]=s,t[6]=o,t[7]=n,t[8]=f):f=t[8];let p;return t[9]!==a||t[10]!==r||t[11]!==n||t[12]!==f?(p=(0,Z.jsx)(Y_,{scope:n,context:r,base:a,children:f}),t[9]=a,t[10]=r,t[11]=n,t[12]=f,t[13]=p):p=t[13],p}function Pv(e){let t=(0,$.c)(33),{scope:n,context:r,interaction:i,branch:a,path:o,only:s,heading:c,fullHeight:l,onOpen:u}=e,d=l!==void 0&&l,f;t[0]===a?f=t[1]:(f=Ri(a),t[0]=a,t[1]=f);let p=f,m=K_(n,r,p);if(a.base===null||a.base===void 0)return null;let h;t[2]!==a.files||t[3]!==s||t[4]!==o?(h=()=>s?a.files.filter(e=>s.includes(e.path)||e.oldPath!==void 0&&s.includes(e.oldPath)).map(Fv):o==null?void 0:[o],t[2]=a.files,t[3]=s,t[4]=o,t[5]=h):h=t[5];let g=h,_;t[6]!==a.files||t[7]!==m||t[8]!==g?(_=ua(a.files,m,g()),t[6]=a.files,t[7]=m,t[8]=g,t[9]=_):_=t[9];let v=_;if(o!=null&&v.length===0){let e;t[10]===a.base.ref?e=t[11]:(e=jp(a.base.ref),t[10]=a.base.ref,t[11]=e);let n=`${o} has no committed change since ${e}.`,r;return t[12]===n?r=t[13]:(r=(0,Z.jsx)(Rn,{title:`Not changed on this branch`,description:n}),t[12]=n,t[13]=r),r}let y=o!=null,b=a.base.ref,x=a.head,S=a.mergeBaseOid??``,C=a.commits,w;t[14]===a?w=t[15]:(w=Yl(a),t[14]=a,t[15]=w);let T;t[16]!==a.base.ref||t[17]!==a.commits||t[18]!==a.head||t[19]!==w||t[20]!==S?(T={base:b,head:x,mergeBaseOid:S,commits:C,diffRange:w},t[16]=a.base.ref,t[17]=a.commits,t[18]=a.head,t[19]=w,t[20]=S,t[21]=T):T=t[21];let E;return t[22]!==r||t[23]!==d||t[24]!==c||t[25]!==i||t[26]!==v||t[27]!==u||t[28]!==p||t[29]!==n||t[30]!==T||t[31]!==y?(E=(0,Z.jsx)(Iv,{scope:n,context:r,interaction:i,onOpen:u,range:p,items:v,single:y,heading:c,fullHeight:d,branch:T}),t[22]=r,t[23]=d,t[24]=c,t[25]=i,t[26]=v,t[27]=u,t[28]=p,t[29]=n,t[30]=T,t[31]=y,t[32]=E):E=t[32],E}function Fv(e){return e.path}function Iv(e){let t=(0,$.c)(55),{scope:n,context:r,interaction:i,range:a,items:o,single:s,heading:c,fullHeight:l,branch:u,onOpen:d}=e,f=l!==void 0&&l,{connection:p}=r,m=Nt(bt(oa(n,p))),h=JSON.stringify([u.base,u.head.branch]),[g,_]=L(x_(JSON.stringify([p.environmentId,n.projectId,n.worktreeId,h]))),v=o.slice(0,g),y=ra(n,p,u.diffRange,v.map(Dp)),b=JSON.stringify([u.diffRange,v.map(Rv)]),[x,S]=(0,Q.useState)({version:``,comparison:h,patches:new Map});if(!y.pending&&!y.failed&&x.version!==b){let e;t[0]===y.patches?e=t[1]:(e=e=>{let t=y.patches.get(Dp(e).join(`\0`));return t?[[e.fingerprint,t]]:[]},t[0]=y.patches,t[1]=e),S({version:b,comparison:h,patches:new Map(v.flatMap(e))})}let C=e=>y.patches.get(Dp(e).join(`\0`))??(x.comparison===h?x.patches.get(e.fingerprint):void 0),w;t[2]!==r||t[3]!==a||t[4]!==n?(w=(e,t)=>(0,Z.jsx)(Cv,{scope:n,context:r,path:e.path,fingerprint:e.fingerprint,status:e.reviewStatus,range:a,compact:t},`review:${e.path}`),t[2]=r,t[3]=a,t[4]=n,t[5]=w):w=t[5];let T=w,E;t[6]!==u.head.oid||t[7]!==T||t[8]!==C?(E=e=>{let t=Ki(u.head.oid,e,C(e));return t==null?[]:[{...t,id:`branch:${e.path}`,review:{path:e.path,fingerprint:e.fingerprint,reviewed:e.reviewStatus===`reviewed`,stale:e.reviewStatus===`stale`,control:T(e,!0)}}]},t[6]=u.head.oid,t[7]=T,t[8]=C,t[9]=E):E=t[9];let D=v.flatMap(E),O=new Set(D.map(Lv)),k=v.filter(e=>!O.has(e.path)),A=o.length-v.length,j=m?.changes.length??0,[M]=o,N=i.singleHeader||c!==void 0,P;t[10]!==M||t[11]!==d||t[12]!==s?(P=s&&M?(0,Z.jsx)(G_,{label:`Timeline`,iconOnly:!0,icon:Ai,onClick:()=>d({kind:`timeline`,path:M.path})}):void 0,t[10]=M,t[11]=d,t[12]=s,t[13]=P):P=t[13];let F;t[14]!==r||t[15]!==T||t[16]!==M||t[17]!==c||t[18]!==i.toolbarTarget||t[19]!==o||t[20]!==a||t[21]!==n||t[22]!==s||t[23]!==N?(F=e=>s&&M&&N?null:s&&M?(0,Z.jsx)(bv,{target:i.toolbarTarget,barActions:null,title:ui(M.path),subtitle:`${M.path} · on the branch`,children:T(M,!1)}):N?(0,Z.jsxs)(bv,{inline:!0,...c?{title:c.title,titleLabel:c.titleLabel}:{title:`All changes`},subtitle:R(o.length,`file`),children:[e,c?.after]}):(0,Z.jsxs)(bv,{target:i.toolbarTarget,barActions:null,title:`Branch`,subtitle:`${R(o.length,`file`)} changed`,children:[e,(0,Z.jsx)(Tv,{scope:n,context:r,entries:o,range:a})]}),t[14]=r,t[15]=T,t[16]=M,t[17]=c,t[18]=i.toolbarTarget,t[19]=o,t[20]=a,t[21]=n,t[22]=s,t[23]=N,t[24]=F):F=t[24];let I;t[25]!==u||t[26]!==T||t[27]!==y.failed||t[28]!==y.retry||t[29]!==k||t[30]!==C||t[31]!==s||t[32]!==N||t[33]!==j?(I=()=>(0,Z.jsx)(zv,{branch:u,single:s,singleHeader:N,uncommitted:j,omitted:k,patchOf:C,failed:y.failed,onRetry:y.retry,control:e=>T(e,!0)}),t[25]=u,t[26]=T,t[27]=y.failed,t[28]=y.retry,t[29]=k,t[30]=C,t[31]=s,t[32]=N,t[33]=j,t[34]=I):I=t[34];let z;t[35]!==r||t[36]!==D||t[37]!==f||t[38]!==i||t[39]!==a||t[40]!==n||t[41]!==P||t[42]!==F||t[43]!==I?(z=(0,Z.jsx)(lv,{fullHeight:f,scope:n,context:r,interaction:i,range:a,headerActions:P,entries:D,toolbar:F,header:I}),t[35]=r,t[36]=D,t[37]=f,t[38]=i,t[39]=a,t[40]=n,t[41]=P,t[42]=F,t[43]=I,t[44]=z):z=t[44];let B;t[45]!==_||t[46]!==g?(B=()=>_(g+25),t[45]=_,t[46]=g,t[47]=B):B=t[47];let V;t[48]!==y.pending||t[49]!==A||t[50]!==B?(V=(0,Z.jsx)(xv,{more:A,pending:y.pending,onReadMore:B}),t[48]=y.pending,t[49]=A,t[50]=B,t[51]=V):V=t[51];let H;return t[52]!==z||t[53]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[z,V]}),t[52]=z,t[53]=V,t[54]=H):H=t[54],H}function Lv(e){return e.path}function Rv(e){return e.fingerprint}function zv(e){let t=(0,$.c)(26),{branch:n,single:r,singleHeader:i,uncommitted:a,omitted:o,patchOf:s,failed:c,onRetry:l,control:u}=e,d;t[0]===n.head.branch?d=t[1]:(d=n.head.branch===null||n.head.branch===void 0?`This commit`:jp(n.head.branch),t[0]=n.head.branch,t[1]=d);let f=d;if(i&&!c&&o.length===0)return null;let p;t[2]!==n.base||t[3]!==n.commits||t[4]!==n.head.oid||t[5]!==n.mergeBaseOid||t[6]!==f||t[7]!==r||t[8]!==i?(p=!r&&!i&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`h2`,{className:`text-sm font-semibold`,children:[f,` since `,jp(n.base)]}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-2xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:R(n.commits,`commit`)}),(0,Z.jsxs)(`span`,{children:[`from`,` `,(0,Z.jsx)(`span`,{className:`font-mono`,children:Ap(n.mergeBaseOid)}),` `,`to `,(0,Z.jsx)(`span`,{className:`font-mono`,children:Ap(n.head.oid)})]}),(0,Z.jsx)(nt,{variant:`secondary`,children:jp(n.base)})]})]}),t[2]=n.base,t[3]=n.commits,t[4]=n.head.oid,t[5]=n.mergeBaseOid,t[6]=f,t[7]=r,t[8]=i,t[9]=p):p=t[9];let m;t[10]!==i||t[11]!==a?(m=a>0&&!i&&(0,Z.jsx)(`p`,{className:`mt-1 text-2xs text-muted-foreground`,children:`Uncommitted changes are not part of the branch review. Review them under Uncommitted.`}),t[10]=i,t[11]=a,t[12]=m):m=t[12];let h;t[13]!==c||t[14]!==l?(h=c&&(0,Z.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-xs text-muted-foreground`,children:[`Some patches could not be read.`,(0,Z.jsx)(Y,{size:`xs`,variant:`outline`,onClick:l,children:`Try again`})]}),t[13]=c,t[14]=l,t[15]=h):h=t[15];let g;t[16]!==u||t[17]!==c||t[18]!==o||t[19]!==s?(g=o.length>0&&(0,Z.jsx)(`ul`,{className:`mt-3 space-y-1.5`,"aria-label":`Changes without code preview`,children:o.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 rounded-lg border bg-muted/25 px-3 py-2 text-xs`,children:[u(e),(0,Z.jsx)(X,{className:`font-mono font-medium`,text:e.path}),(0,Z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.status,` ·`,` `,Uc(e,s(e),c)??`No code change`]})]},e.path))}),t[16]=u,t[17]=c,t[18]=o,t[19]=s,t[20]=g):g=t[20];let _;return t[21]!==p||t[22]!==m||t[23]!==h||t[24]!==g?(_=(0,Z.jsxs)(`section`,{className:`mx-4 mt-3 rounded-xl border px-4 py-3`,children:[p,m,h,g]}),t[21]=p,t[22]=m,t[23]=h,t[24]=g,t[25]=_):_=t[25],_}var Bv=e=>Dp(e).join(`\0`);function Vv(e){let t=(0,$.c)(51),{scope:n,context:r,interaction:i,oid:a,onOpen:o}=e,{connection:s}=r,[c,l]=(0,Q.useState)(1),[,u]=(0,Q.useTransition)(),d=mh(s,n,a,c),f;t[0]!==s||t[1]!==n?(f=ph({connection:s,scope:n}),t[0]=s,t[1]=n,t[2]=f):f=t[2];let p=Nt(bt(N(f))),m=p?.snapshot?.head.kind===`attached`&&p.commits.some(e=>e.oid===a)?jp(p.snapshot.head.ref):void 0,h=`${a}:${c}`,g;t[3]===h?g=t[4]:(g={of:h,shown:25},t[3]=h,t[4]=g);let[_,v]=(0,Q.useState)(g),y=_.of===`${a}:${c}`?_.shown:25,b;t[5]!==a||t[6]!==c||t[7]!==y?(b=()=>v({of:`${a}:${c}`,shown:y+25}),t[5]=a,t[6]=c,t[7]=y,t[8]=b):b=t[8];let x=b,S=d.files.slice(0,y),C=S.map(Gv),w=Qi(s,n,a,c,C),T;t[9]===w.patches?T=t[10]:(T=e=>w.patches.get(Bv(e)),t[9]=w.patches,t[10]=T);let E=T,D;t[11]!==a||t[12]!==c||t[13]!==E?(D=e=>{let t=Ki(a,e,E(e));return t==null?[]:[{...t,id:`${t.id}:${c}`}]},t[11]=a,t[12]=c,t[13]=E,t[14]=D):D=t[14];let O=S.flatMap(D),k;t[15]!==a||t[16]!==E?(k=e=>(Ki(a,e,E(e))??null)===null,t[15]=a,t[16]=E,t[17]=k):k=t[17];let A=S.filter(k),j=d.files.length-S.length,M;t[18]!==d.commit.subject||t[19]!==a?(M=d.commit.subject||`Commit ${Ap(a)}`,t[18]=d.commit.subject,t[19]=a,t[20]=M):M=t[20];let P=M,F=new Map(O.map(Wv));for(let e of S)E(e)?.kind===`metadata-only`&&F.set(Op(e),{added:0,removed:0});let I=j===0&&d.files.every(e=>{let t=E(e);return F.has(Op(e))||t?.kind===`binary`})?[...F.values()].reduce(Uv,{added:0,removed:0}):void 0,L;t[21]===a?L=t[22]:(L=(0,Z.jsx)(G_,{label:`Copy hash`,icon:De,onClick:()=>ht(a,`commit id`)}),t[21]=a,t[22]=L);let R;t[23]===o?R=t[24]:(R=(0,Z.jsx)(G_,{label:`Open in graph`,icon:mr,onClick:()=>o({kind:`graph`})}),t[23]=o,t[24]=R);let z;t[25]!==R||t[26]!==L?(z=(0,Z.jsxs)(Z.Fragment,{children:[L,R]}),t[25]=R,t[26]=L,t[27]=z):z=t[27];let B=z,V;t[28]!==B||t[29]!==m||t[30]!==d.commit||t[31]!==i.toolbarTarget||t[32]!==a||t[33]!==c||t[34]!==u||t[35]!==P?(V=e=>(0,Z.jsxs)(`header`,{className:`mx-auto w-full max-w-commit px-7 pt-10`,children:[i.toolbarTarget?(0,ru.createPortal)(B,i.toolbarTarget):(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:B}),(0,Z.jsxs)(`div`,{className:`flex min-h-5.5 min-w-0 flex-wrap items-center gap-x-2 text-ui leading-5.5 font-medium text-muted-foreground`,children:[(0,Z.jsx)(fc,{className:`size-3.5 shrink-0`}),(0,Z.jsxs)(`span`,{children:[`Commit`,` `,(0,Z.jsx)(X,{text:a,disclose:`always`,className:`font-mono text-caption text-foreground`,children:Ap(a)})]}),m&&(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[`on`,` `,(0,Z.jsx)(X,{text:m,className:`font-mono text-caption font-normal`})]})]}),(0,Z.jsx)(X,{text:P,render:(0,Z.jsx)(`h1`,{}),className:`mt-3 text-2xl leading-tight font-semibold tracking-tight`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[d.commit.parentOids.length>1&&(0,Z.jsx)(Es,{value:String(c),onValueChange:e=>u(()=>l(Number(e))),children:(0,Z.jsx)(ws,{children:d.commit.parentOids.map(Hv)})}),(0,Z.jsx)(G_,{label:`Copy message`,icon:De,onClick:()=>ht(Ep(d.commit),`commit message`)}),e]})]}),t[28]=B,t[29]=m,t[30]=d.commit,t[31]=i.toolbarTarget,t[32]=a,t[33]=c,t[34]=u,t[35]=P,t[36]=V):V=t[36];let H=()=>(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(Kv,{commit:d,branch:m,counts:F,total:I,omitted:A,patchOf:E,failed:w.failed,onRetry:w.retry})}),U;t[37]!==r||t[38]!==O||t[39]!==i||t[40]!==n||t[41]!==V||t[42]!==H?(U=(0,Z.jsx)(lv,{toolbar:V,framed:!0,scope:n,context:r,interaction:i,entries:O,header:H}),t[37]=r,t[38]=O,t[39]=i,t[40]=n,t[41]=V,t[42]=H,t[43]=U):U=t[43];let W;t[44]!==w.pending||t[45]!==j||t[46]!==x?(W=(0,Z.jsx)(xv,{more:j,pending:w.pending,onReadMore:x}),t[44]=w.pending,t[45]=j,t[46]=x,t[47]=W):W=t[47];let G;return t[48]!==U||t[49]!==W?(G=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[U,W]}),t[48]=U,t[49]=W,t[50]=G):G=t[50],G}function Hv(e,t){return(0,Z.jsxs)(uo,{value:String(t+1),children:[rh(t+1),` parent ·`,` `,(0,Z.jsx)(`span`,{className:`font-mono`,children:Ap(e)})]},e)}function Uv(e,t){return{added:e.added+t.added,removed:e.removed+t.removed}}function Wv(e){return[e.path,e.lineCounts]}function Gv(e){return Dp(e)}function Kv(e){let t=(0,$.c)(67),{commit:n,omitted:r,patchOf:i,failed:a,onRetry:o,branch:s,counts:c,total:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-5 shrink-0 place-items-center rounded-sm border border-border-strong text-foreground`,children:(0,Z.jsx)(Bc,{className:`size-3`})}),t[0]=u):u=t[0];let d;t[1]===n.commit.author.name?d=t[2]:(d=(0,Z.jsx)(X,{text:n.commit.author.name,className:`font-medium text-foreground`}),t[1]=n.commit.author.name,t[2]=d);let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),t[3]=f):f=t[3];let p;t[4]===n.commit.author.timestamp?p=t[5]:(p=ze(n.commit.author.timestamp),t[4]=n.commit.author.timestamp,t[5]=p);let m;t[6]===p?m=t[7]:(m=(0,Z.jsx)(`span`,{children:p}),t[6]=p,t[7]=m);let h;t[8]!==n.commit.parentOids||t[9]!==n.comparison.baseOid||t[10]!==n.comparison.kind||t[11]!==n.comparison.parentNumber?(h=n.comparison.kind===`parent`?(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`· `}),`parent`,` `,(0,Z.jsx)(`span`,{className:`font-mono text-caption leading-5 text-foreground`,children:Ap(n.comparison.baseOid)}),n.commit.parentOids.length>1&&` (${rh(n.comparison.parentNumber)} parent of a merge)`]}):(0,Z.jsx)(`span`,{children:`root commit`}),t[8]=n.commit.parentOids,t[9]=n.comparison.baseOid,t[10]=n.comparison.kind,t[11]=n.comparison.parentNumber,t[12]=h):h=t[12];let g;t[13]!==d||t[14]!==m||t[15]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-ui leading-5 text-muted-foreground`,children:[u,d,f,m,h]}),t[13]=d,t[14]=m,t[15]=h,t[16]=g):g=t[16];let _;if(t[17]!==s||t[18]!==n.commit.refs){let e;t[20]===s?e=t[21]:(e=e=>e.kind!==`local-branch`||e.name!==s,t[20]=s,t[21]=e),_=Mp(n.commit.refs).filter(e).map(qv),t[17]=s,t[18]=n.commit.refs,t[19]=_}else _=t[19];let v;t[22]===_?v=t[23]:(v=(0,Z.jsx)(`div`,{className:`mt-2 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-caption text-muted-foreground`,children:_}),t[22]=_,t[23]=v);let y;t[24]===n.commit.body?y=t[25]:(y=n.commit.body!==null&&n.commit.body!==void 0&&(0,Z.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap text-ui leading-relaxed wrap-anywhere text-muted-foreground`,children:n.commit.body}),t[24]=n.commit.body,t[25]=y);let b;t[26]!==n.commit.bodyTruncated||t[27]!==n.commit.subjectTruncated?(b=(n.commit.subjectTruncated||n.commit.bodyTruncated)&&(0,Z.jsx)(`p`,{className:`mt-1 text-caption text-muted-foreground`,children:`Commit message truncated`}),t[26]=n.commit.bodyTruncated,t[27]=n.commit.subjectTruncated,t[28]=b):b=t[28];let x;t[29]===n.files.length?x=t[30]:(x=R(n.files.length,`file`),t[29]=n.files.length,t[30]=x);let S;t[31]===x?S=t[32]:(S=(0,Z.jsxs)(`span`,{children:[x,` changed`]}),t[31]=x,t[32]=S);let C;t[33]===l?C=t[34]:(C=l&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`mx-2 font-normal text-muted-foreground`,children:`·`}),(0,Z.jsx)(Zv,{count:l})]}),t[33]=l,t[34]=C);let w;t[35]!==n.files.length||t[36]!==a||t[37]!==l?(w=!l&&n.files.length>0&&(0,Z.jsx)(`span`,{className:`ml-2 font-normal text-muted-foreground`,children:a?`Line counts unavailable`:`Line counts incomplete`}),t[35]=n.files.length,t[36]=a,t[37]=l,t[38]=w):w=t[38];let T;t[39]!==S||t[40]!==C||t[41]!==w?(T=(0,Z.jsxs)(`p`,{className:`border-b pb-1.5 text-xs font-medium tabular-nums`,children:[S,C,w]}),t[39]=S,t[40]=C,t[41]=w,t[42]=T):T=t[42];let E;if(t[43]!==n.files||t[44]!==c||t[45]!==i){let e;t[47]!==c||t[48]!==i?(e=e=>(0,Z.jsxs)(`li`,{className:`flex h-8 min-w-0 items-center gap-2.5 rounded-sm pr-1.5 pl-1 text-caption leading-4`,children:[(0,Z.jsx)(`span`,{"aria-label":e.status,className:`w-4 shrink-0 text-center font-mono text-xs font-semibold text-brand`,children:e.status.slice(0,1).toUpperCase()}),(0,Z.jsx)(X,{text:Dp(e).join(` → `),className:`flex-1 font-mono font-medium`}),(0,Z.jsx)(Zv,{count:c.get(Op(e))}),i(e)?.kind===`binary`&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Binary`})]},Bv(e)),t[47]=c,t[48]=i,t[49]=e):e=t[49],E=n.files.map(e),t[43]=n.files,t[44]=c,t[45]=i,t[46]=E}else E=t[46];let D;t[50]===E?D=t[51]:(D=(0,Z.jsx)(`ul`,{className:`max-h-64 divide-y overflow-y-auto border-b`,"aria-label":`Changed files`,children:E}),t[50]=E,t[51]=D);let O;t[52]!==T||t[53]!==D?(O=(0,Z.jsxs)(`section`,{"aria-label":`Files changed`,className:`mt-7`,children:[T,D]}),t[52]=T,t[53]=D,t[54]=O):O=t[54];let k;t[55]!==a||t[56]!==r||t[57]!==o||t[58]!==i?(k=r.length>0&&(0,Z.jsx)(Jv,{changes:r,patchOf:i,failed:a,onRetry:o}),t[55]=a,t[56]=r,t[57]=o,t[58]=i,t[59]=k):k=t[59];let A;return t[60]!==y||t[61]!==b||t[62]!==O||t[63]!==k||t[64]!==g||t[65]!==v?(A=(0,Z.jsxs)(`section`,{className:`mx-auto mt-1 mb-6 w-full max-w-commit min-w-0 px-7`,children:[g,v,y,b,O,k]}),t[60]=y,t[61]=b,t[62]=O,t[63]=k,t[64]=g,t[65]=v,t[66]=A):A=t[66],A}function qv(e){return(0,Z.jsx)(X,{text:e.name,className:`font-mono`},`${e.kind}:${e.name}`)}function Jv(e){let t=(0,$.c)(15),{changes:n,patchOf:r,failed:i,onRetry:a}=e,o;t[0]!==i||t[1]!==a?(o=i&&(0,Z.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-xs text-muted-foreground`,children:[`Some patches could not be read.`,(0,Z.jsx)(Y,{size:`xs`,variant:`outline`,onClick:a,children:`Try again`})]}),t[0]=i,t[1]=a,t[2]=o):o=t[2];let s;if(t[3]!==n||t[4]!==i||t[5]!==r){let e;t[7]!==i||t[8]!==r?(e=e=>{let t=Op(e),n=r(e),a=kr(e),o=Uc(e,n,i)??`No code change`;return(0,Z.jsxs)(`li`,{className:`rounded-lg border bg-muted/25 px-3 py-2 text-xs`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(X,{className:`font-mono font-medium`,text:t}),(0,Z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.status,` · `,o]})]}),a&&n?.kind===`text`&&(0,Z.jsx)(`pre`,{className:`mt-1 overflow-x-auto whitespace-pre-wrap font-mono text-2xs text-muted-foreground`,children:n.patch.split(`
|
|
26
|
-
`).filter(
|
|
27
|
-
`)})]},`${e.oldPath}->${e.newPath}:${e.status}`)},t[7]=i,t[8]=r,t[9]=e):e=t[9],s=n.map(e),t[3]=n,t[4]=i,t[5]=r,t[6]=s}else s=t[6];let c;t[10]===s?c=t[11]:(c=(0,Z.jsx)(`ul`,{className:`mt-3 space-y-1.5`,"aria-label":`Changes without code preview`,children:s}),t[10]=s,t[11]=c);let l;return t[12]!==o||t[13]!==c?(l=(0,Z.jsxs)(Z.Fragment,{children:[o,c]}),t[12]=o,t[13]=c,t[14]=l):l=t[14],l}function
|
|
28
|
-
`);for(let[e,t]of a.entries()){let a=t.toLocaleLowerCase(),o=a.indexOf(r);for(;o!==-1;){if(i.length===n)return i;i.push({line:e+1,column:o}),o=a.indexOf(r,o+r.length)}}return i}function iy(e,t){return Math.max(0,Math.min(e,t-1))}function ay(e,t,n){return t===0?0:(iy(e,t)+n+t)%t}function oy(e,t,n){if(t===0)return`No results`;let r=t===n?`+`:``;return`${iy(e,t)+1} of ${t}${r}`}function sy(e){let t=(0,$.c)(65),{text:n,focusRequest:r,onReveal:i,onClose:a}=e,[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(0),u;t[0]!==o||t[1]!==n?(u=ry(n,o,Ie),t[0]=o,t[1]=n,t[2]=u):u=t[2];let d=u,[f,p]=(0,Q.useState)(),m;t[3]!==d||t[4]!==i?(m=(e,t)=>{let n=t===void 0?d:t;l(e);let r=n[e];r&&i(r.line)},t[3]=d,t[4]=i,t[5]=m):m=t[5];let h=m,g;t[6]!==c||t[7]!==d.length||t[8]!==h?(g=e=>h(ay(c,d.length,e)),t[6]=c,t[7]=d.length,t[8]=h,t[9]=g):g=t[9];let _=g,v;t[10]===a?v=t[11]:(v=e=>{e.key===`Escape`&&(e.preventDefault(),a())},t[10]=a,t[11]=v);let y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(Tr,{children:(0,Z.jsx)(Kn,{})}),t[12]=y):y=t[12];let b;t[13]!==r||t[14]!==f?(b=e=>{e&&f!==r&&(e.focus(),e.select(),p(r))},t[13]=r,t[14]=f,t[15]=b):b=t[15];let x;t[16]!==h||t[17]!==n?(x=e=>{s(e.target.value),h(0,ry(n,e.target.value,Ie))},t[16]=h,t[17]=n,t[18]=x):x=t[18];let S;t[19]===_?S=t[20]:(S=e=>{e.key===`Enter`&&(e.preventDefault(),_(e.shiftKey?-1:1))},t[19]=_,t[20]=S);let C;t[21]!==o||t[22]!==b||t[23]!==x||t[24]!==S?(C=(0,Z.jsx)(or,{ref:b,"aria-label":`Find in file`,placeholder:`Find in file`,value:o,onChange:x,onKeyDown:S}),t[21]=o,t[22]=b,t[23]=x,t[24]=S,t[25]=C):C=t[25];let w;t[26]!==c||t[27]!==d.length||t[28]!==o?(w=o!==``&&(0,Z.jsx)(pr,{role:`status`,children:oy(c,d.length,1e4)}),t[26]=c,t[27]=d.length,t[28]=o,t[29]=w):w=t[29];let T=d.length===0,E;t[30]===_?E=t[31]:(E=()=>_(-1),t[30]=_,t[31]=E);let D;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(An,{}),t[32]=D):D=t[32];let O;t[33]!==T||t[34]!==E?(O=(0,Z.jsx)(nn,{render:(0,Z.jsx)(jr,{size:`icon-xs`,"aria-label":`Previous match`,disabled:T,onClick:E,children:D})}),t[33]=T,t[34]=E,t[35]=O):O=t[35];let k;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(yt,{role:`tooltip`,className:`break-all`,children:`Previous match`}),t[36]=k):k=t[36];let A;t[37]===O?A=t[38]:(A=(0,Z.jsxs)(wn,{children:[O,k]}),t[37]=O,t[38]=A);let j=d.length===0,M;t[39]===_?M=t[40]:(M=()=>_(1),t[39]=_,t[40]=M);let N;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(Ae,{}),t[41]=N):N=t[41];let P;t[42]!==j||t[43]!==M?(P=(0,Z.jsx)(nn,{render:(0,Z.jsx)(jr,{size:`icon-xs`,"aria-label":`Next match`,disabled:j,onClick:M,children:N})}),t[42]=j,t[43]=M,t[44]=P):P=t[44];let F;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(yt,{role:`tooltip`,className:`break-all`,children:`Next match`}),t[45]=F):F=t[45];let I;t[46]===P?I=t[47]:(I=(0,Z.jsxs)(wn,{children:[P,F]}),t[46]=P,t[47]=I);let L;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(jt,{}),t[48]=L):L=t[48];let R;t[49]===a?R=t[50]:(R=(0,Z.jsx)(nn,{render:(0,Z.jsx)(jr,{size:`icon-xs`,"aria-label":`Close find`,onClick:a,children:L})}),t[49]=a,t[50]=R);let z;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(yt,{role:`tooltip`,className:`break-all`,children:`Close find`}),t[51]=z):z=t[51];let B;t[52]===R?B=t[53]:(B=(0,Z.jsxs)(wn,{children:[R,z]}),t[52]=R,t[53]=B);let V;t[54]!==w||t[55]!==A||t[56]!==I||t[57]!==B?(V=(0,Z.jsxs)(Tr,{align:`inline-end`,children:[w,A,I,B]}),t[54]=w,t[55]=A,t[56]=I,t[57]=B,t[58]=V):V=t[58];let H;t[59]!==V||t[60]!==C?(H=(0,Z.jsxs)(Sr,{className:`w-full max-w-sm`,children:[y,C,V]}),t[59]=V,t[60]=C,t[61]=H):H=t[61];let U;return t[62]!==H||t[63]!==v?(U=(0,Z.jsx)(`div`,{role:`search`,className:`flex shrink-0 justify-end border-b px-3 py-1.5`,onKeyDown:v,children:H}),t[62]=H,t[63]=v,t[64]=U):U=t[64],U}function cy(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=ou(e.path)?(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-auto`,children:[(0,Z.jsx)(by,{...e}),(0,Z.jsx)(hy,{path:e.path,copy:!1,children:(0,Z.jsxs)(jm,{className:`max-w-full flex-wrap justify-end`,children:[(0,Z.jsx)(gy,{path:e.path,onOpen:e.onOpen}),(0,Z.jsx)(_y,{path:e.path})]})}),(0,Z.jsx)(na,{scope:e.scope,path:e.path,connection:e.context.connection})]}):(0,Z.jsx)(ly,{...e}),t[0]=e,t[1]=n),n}function ly(e){let t=(0,$.c)(16),n;t[0]===e.path?n=t[1]:(n=e.path.split(`/`).slice(0,-1).join(`/`),t[0]=e.path,t[1]=n);let r=n,{connection:i}=e.context,a=Pi(i,e.scope,r),o;t[2]===e.path?o=t[3]:(o=e.path.split(`/`).at(-1),t[2]=e.path,t[3]=o);let s=o,c;if(t[4]!==a.entries||t[5]!==s){let e;t[7]===s?e=t[8]:(e=e=>e.name===s,t[7]=s,t[8]=e),c=a.entries.find(e),t[4]=a.entries,t[5]=s,t[6]=c}else c=t[6];let l=c;if(l?.kind===`symlink`){let n=`Not followed: symlink to ${l.target??`an unknown target`}`,r;return t[9]!==e||t[10]!==n?(r=(0,Z.jsx)(uy,{...e,message:n}),t[9]=e,t[10]=n,t[11]=r):r=t[11],r}if(l?.kind===`submodule`){let n;return t[12]===e?n=t[13]:(n=(0,Z.jsx)(uy,{...e,message:`Not followed: submodule`}),t[12]=e,t[13]=n),n}let u;return t[14]===e?u=t[15]:(u=(0,Z.jsx)(dy,{...e}),t[14]=e,t[15]=u),u}function uy(e){let t=(0,$.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({message:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===r?i=t[4]:(i=(0,Z.jsx)(by,{...r}),t[3]=r,t[4]=i);let a;t[5]===r.path?a=t[6]:(a=(0,Z.jsx)(hy,{path:r.path}),t[5]=r.path,t[6]=a);let o;t[7]===n?o=t[8]:(o=(0,Z.jsx)(`div`,{className:`grid min-h-48 flex-1 place-items-center p-6`,children:(0,Z.jsx)(Rn,{title:`Not shown`,description:n})}),t[7]=n,t[8]=o);let s;return t[9]!==i||t[10]!==a||t[11]!==o?(s=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[i,a,o]}),t[9]=i,t[10]=a,t[11]=o,t[12]=s):s=t[12],s}function dy(e){let t=(0,$.c)(24),{scope:n,context:r,interaction:i,path:a,onOpen:o}=e,{connection:s}=r,{file:c,draft:l,state:u,reset:d,edit:f}=ls(s,n,a),p=`kind`in c;if(p&&u.owner===null&&u.text===u.savedText){let e;return t[0]!==r||t[1]!==c.reason||t[2]!==i||t[3]!==o||t[4]!==a||t[5]!==n?(e=(0,Z.jsx)(uy,{scope:n,context:r,interaction:i,onOpen:o,path:a,message:c.reason}),t[0]=r,t[1]=c.reason,t[2]=i,t[3]=o,t[4]=a,t[5]=n,t[6]=e):e=t[6],e}let m;t[7]===p?m=t[8]:(m=p&&(0,Z.jsx)(`p`,{role:`alert`,className:`border-b bg-graph-4/10 px-3.5 py-2 text-xs text-graph-4`,children:`The file is no longer readable. Your unsaved draft is still available below.`}),t[7]=p,t[8]=m);let h=p?u.savedText:c.text,g=p?u.fingerprint:c.contentFingerprint,_;t[9]!==r||t[10]!==l||t[11]!==f||t[12]!==i||t[13]!==o||t[14]!==a||t[15]!==d||t[16]!==n||t[17]!==u||t[18]!==h||t[19]!==g?(_=(0,Z.jsx)(fy,{scope:n,context:r,interaction:i,path:a,text:h,contentFingerprint:g,draft:l,draftState:u,reset:d,edit:f,onOpen:o}),t[9]=r,t[10]=l,t[11]=f,t[12]=i,t[13]=o,t[14]=a,t[15]=d,t[16]=n,t[17]=u,t[18]=h,t[19]=g,t[20]=_):_=t[20];let v;return t[21]!==m||t[22]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[m,_]}),t[21]=m,t[22]=_,t[23]=v):v=t[23],v}function fy(e){let t=(0,$.c)(87),{scope:n,context:r,interaction:i,path:a,text:o,contentFingerprint:s,draft:c,draftState:l,reset:u,edit:d,onOpen:f}=e,{preferences:p}=Va(),{connection:m}=r,h=oi(n,m),g;t[0]===a?g=t[1]:(g=vy(a),t[0]=a,t[1]=g);let _=g,v;t[2]===a?v=t[3]:(v=[a],t[2]=a,t[3]=v);let y=J_(n,r,h,v)[0],b=y?.comparisons??[],x=b.find(py)??b[0],S=x?Wc(x):void 0,C;t[4]!==a||t[5]!==y?(C=y?[{path:a,fingerprint:y.fingerprint}]:[],t[4]=a,t[5]=y,t[6]=C):C=t[6];let w=Ci(n,m,y?.statusToken??``,C,S?[S]:[]),T=S?w.diffs.get(tr(S)):void 0,E=x&&x.scope!==`untracked`&&x.scope!==`unmerged`&&T?zi(x,T)?.fileDiff:void 0,D=x&&`kind`in x?`${x.scope} · ${x.kind}`:x?.scope,O;if(t[7]!==h.changes||t[8]!==a){let e;t[10]===a?e=t[11]:(e=e=>e.path===a,t[10]=a,t[11]=e),O=h.changes.some(e),t[7]=h.changes,t[8]=a,t[9]=O}else O=t[9];let k=O,A;t[12]!==_||t[13]!==p?(A=()=>yy(_,p),t[12]=_,t[13]=p,t[14]=A):A=t[14];let[j,M]=(0,Q.useState)(A),{active:N}=i,[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(),[R,z]=(0,Q.useState)(),B=(0,Q.useId)();fi(c,B,s);let V=_===`code`||j===`source`,H;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>L(Date.now()),t[15]=H):H=t[15];let U=N&&V&&!P,W;t[16]===U?W=t[17]:(W={enabled:U,ignoreInputs:!1,conflictBehavior:`allow`},t[16]=U,t[17]=W),So(vo.findInFile,H,W);let G=l.diskChanged.has(B)?`Changed on disk just now`:``,ee;t[18]===G?ee=t[19]:(ee=(0,Z.jsx)(`span`,{"aria-live":`polite`,className:`hidden text-xs text-muted-foreground xl:inline`,children:G}),t[18]=G,t[19]=ee);let te;t[20]!==_||t[21]!==j?(te=_!==`code`&&(0,Z.jsx)(Es,{value:j,onValueChange:e=>{(e===`rendered`||e===`source`)&&M(e)},children:(0,Z.jsxs)(ws,{children:[(0,Z.jsx)(uo,{value:`rendered`,children:_===`markdown`?`Reader`:`Preview`}),(0,Z.jsx)(uo,{value:`source`,children:`Source`})]})}),t[20]=_,t[21]=j,t[22]=te):te=t[22];let ne;t[23]!==ee||t[24]!==te?(ne=(0,Z.jsxs)(Z.Fragment,{children:[ee,te]}),t[23]=ee,t[24]=te,t[25]=ne):ne=t[25];let re=ne,ie;t[26]!==s||t[27]!==l.owner||t[28]!==l.savedText||t[29]!==l.text||t[30]!==d||t[31]!==B?(ie=s&&(0,Z.jsxs)(wn,{children:[(0,Z.jsx)(nn,{render:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,disabled:l.owner!==null&&l.owner!==B,"aria-label":l.text===l.savedText?`Edit`:`Resume edit`,onClick:()=>{d(B)&&F(!0)}}),children:(0,Z.jsx)(it,{})}),(0,Z.jsx)(yt,{role:`tooltip`,children:l.owner!==null&&l.owner!==B?`Editing in another pane`:`Edit`})]}),t[26]=s,t[27]=l.owner,t[28]=l.savedText,t[29]=l.text,t[30]=d,t[31]=B,t[32]=ie):ie=t[32];let ae;t[33]!==k||t[34]!==f||t[35]!==a?(ae=k&&(0,Z.jsxs)(wn,{children:[(0,Z.jsx)(nn,{render:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,"aria-label":`Open diff`,onClick:()=>f({kind:`change`,path:a})}),children:(0,Z.jsx)(br,{})}),(0,Z.jsx)(yt,{role:`tooltip`,children:`Open diff`})]}),t[33]=k,t[34]=f,t[35]=a,t[36]=ae):ae=t[36];let K;t[37]!==i.toolbarTarget||t[38]!==f||t[39]!==a?(K=i.toolbarTarget===void 0&&(0,Z.jsx)(gy,{path:a,onOpen:f}),t[37]=i.toolbarTarget,t[38]=f,t[39]=a,t[40]=K):K=t[40];let oe;t[41]===a?oe=t[42]:(oe=(0,Z.jsx)(_y,{path:a}),t[41]=a,t[42]=oe);let q;t[43]!==ie||t[44]!==ae||t[45]!==K||t[46]!==oe?(q=(0,Z.jsxs)(Z.Fragment,{children:[ie,ae,K,oe]}),t[43]=ie,t[44]=ae,t[45]=K,t[46]=oe,t[47]=q):q=t[47];let se=q;if(P){let e;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>F(!1),t[48]=e):e=t[48];let n;t[49]!==s||t[50]!==u||t[51]!==o?(n=()=>{u(o,s??``),F(!1)},t[49]=s,t[50]=u,t[51]=o,t[52]=n):n=t[52];let r;t[53]===a?r=t[54]:(r=e=>(0,Z.jsx)(hy,{path:a,children:e}),t[53]=a,t[54]=r);let i;return t[55]!==N||t[56]!==k||t[57]!==c||t[58]!==l||t[59]!==B||t[60]!==a||t[61]!==n||t[62]!==r?(i=(0,Z.jsx)(ji,{owner:B,path:a,draft:c,state:l,active:N,changed:k,onDone:e,onDiscard:n,renderToolbar:r}),t[55]=N,t[56]=k,t[57]=c,t[58]=l,t[59]=B,t[60]=a,t[61]=n,t[62]=r,t[63]=i):i=t[63],i}let ce;t[64]!==i.toolbarTarget||t[65]!==f||t[66]!==a||t[67]!==V?(ce=i.toolbarTarget&&!V&&(0,ru.createPortal)((0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(gy,{path:a,onOpen:f})}),i.toolbarTarget),t[64]=i.toolbarTarget,t[65]=f,t[66]=a,t[67]=V,t[68]=ce):ce=t[68];let le;t[69]!==se||t[70]!==r||t[71]!==E||t[72]!==I||t[73]!==R||t[74]!==i||t[75]!==_||t[76]!==re||t[77]!==j||t[78]!==D||t[79]!==f||t[80]!==a||t[81]!==n||t[82]!==o?(le=j===`rendered`&&_!==`code`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(hy,{path:a,copy:!1,children:[re,(0,Z.jsx)(jm,{className:`max-w-full flex-wrap justify-end`,children:se})]}),(0,Z.jsx)(my,{scope:n,context:r,path:a,kind:_,text:o})]}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[I!==void 0&&(0,Z.jsx)(sy,{text:o,focusRequest:I,onReveal:e=>z({line:e,nonce:Date.now()}),onClose:()=>L(void 0)}),(0,Z.jsxs)(ey,{path:a,note:D,diff:E,children:[re,se]}),(0,Z.jsx)(lv,{disableFileHeader:!0,compactThreads:!0,fileDiff:E,scope:n,context:r,interaction:i,headerActions:i.toolbarTarget===void 0?void 0:(0,Z.jsx)(gy,{path:a,onOpen:f}),...R===void 0?{}:{foundLine:R},entries:[{...Z_(`file:${a}`,a,o)}]})]}),t[69]=se,t[70]=r,t[71]=E,t[72]=I,t[73]=R,t[74]=i,t[75]=_,t[76]=re,t[77]=j,t[78]=D,t[79]=f,t[80]=a,t[81]=n,t[82]=o,t[83]=le):le=t[83];let ue;return t[84]!==ce||t[85]!==le?(ue=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-card`,children:[ce,le]}),t[84]=ce,t[85]=le,t[86]=ue):ue=t[86],ue}function py(e){return e.scope===`unstaged`}function my(e){let t=(0,$.c)(8),{scope:n,context:r,path:i,kind:a,text:o}=e;if(a===`markdown`){let e;return t[0]===o?e=t[1]:(e=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,Z.jsx)(Dr,{text:o,className:`mx-auto max-w-[78ch] px-6 py-6`})}),t[0]=o,t[1]=e),e}let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(`p`,{className:`border-b bg-muted/40 px-3.5 py-1.5 text-2xs text-muted-foreground`,children:`Sandboxed preview: scripts run, and cannot read Porcelain, your cookies or the review API, load anything from the network, submit a form, or move the page around them.`}),t[2]=s):s=t[2];let c;return t[3]!==r.connection||t[4]!==i||t[5]!==n||t[6]!==o?(c=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,children:[s,(0,Z.jsx)(qn,{scope:n,path:i,html:o,connection:r.connection})]}),t[3]=r.connection,t[4]=i,t[5]=n,t[6]=o,t[7]=c):c=t[7],c}function hy(e){let t=(0,$.c)(7),{path:n,children:r,copy:i}=e,a=i===void 0||i,o;t[0]!==a||t[1]!==n?(o=a&&(0,Z.jsx)(_y,{path:n}),t[0]=a,t[1]=n,t[2]=o):o=t[2];let s;return t[3]!==r||t[4]!==n||t[5]!==o?(s=(0,Z.jsxs)(ey,{path:n,children:[r,o]}),t[3]=r,t[4]=n,t[5]=o,t[6]=s):s=t[6],s}function gy(e){let t=(0,$.c)(3),{path:n,onOpen:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,Z.jsx)(G_,{label:`Timeline`,iconOnly:!0,icon:Ai,onClick:()=>r({kind:`timeline`,path:n})}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function _y(e){let t=(0,$.c)(8),{path:n}=e,r;t[0]===n?r=t[1]:(r=(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,"aria-label":`Copy path`,onClick:()=>ht(n,`path`)}),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(De,{}),t[2]=i):i=t[2];let a;t[3]===r?a=t[4]:(a=(0,Z.jsx)(nn,{render:r,children:i}),t[3]=r,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(yt,{role:`tooltip`,children:`Copy path`}),t[5]=o):o=t[5];let s;return t[6]===a?s=t[7]:(s=(0,Z.jsxs)(wn,{children:[a,o]}),t[6]=a,t[7]=s),s}function vy(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.mdx`)?`markdown`:t.endsWith(`.html`)||t.endsWith(`.htm`)?`html`:`code`}function yy(e,t){return e===`markdown`||e===`html`?t.documentsDefault:`source`}function by(e){let t=(0,$.c)(6),{interaction:n,path:r,onOpen:i}=e;if(!n.toolbarTarget)return null;let a;t[0]!==i||t[1]!==r?(a=(0,Z.jsx)(gy,{path:r,onOpen:i}),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o;return t[3]!==n.toolbarTarget||t[4]!==a?(o=(0,ru.createPortal)(a,n.toolbarTarget),t[3]=n.toolbarTarget,t[4]=a,t[5]=o):o=t[5],o}function xy(e){return[...new Set(e)].join(`, `)}function Sy(e){let t=(0,$.c)(37),{scope:n,context:r,interaction:i,paths:a,files:o,focus:s,header:c,headerActions:l,headerLeading:u,toolbar:d,footer:f,column:p,fullHeight:m}=e,h=o===void 0?[]:o,g=p!==void 0&&p,_=m!==void 0&&m,{connection:v}=r,[y,b]=(0,Q.useState)(),x;t[0]!==y||t[1]!==b?(x=(e,t)=>{y===e&&(b(void 0),t.focus({preventScroll:!0}),t.scrollIntoView({block:`start`}))},t[0]=y,t[1]=b,t[2]=x):x=t[2];let S=x;q_(n,r);let C=oi(n,v),w=Qn(J_(n,r,C,a),h),T=w[0]?.statusToken??``,E=Ci(n,v,T,w.flatMap(ky),w.flatMap(Dy)),D=wr(v,n,w.flatMap(Ty)),O;t[3]===E.diffs?O=t[4]:(O=e=>{let t=Wc(e);return t?E.diffs.get(tr(t)):void 0},t[3]=E.diffs,t[4]=O);let k=O,A=E.pending||D.pending,j=E.failed||D.failed,M=new Map(h.map(wy)),N;t[5]!==k||t[6]!==D?(N=e=>{let t=e.comparisons.flatMap(e=>{if(e.scope===`unmerged`)return[`Conflict`];if(e.scope===`untracked`)return D.contents.has(e.path)?[]:[`Not readable`];if(!e.supported)return[`Unsupported comparison`];let t=k(e);return t?t.kind===`binary`?[`Binary change`]:t.kind===`omitted`?[`Content omitted: ${Vc(t.reason)}`]:zi(e,t)?[]:[`No single-file textual patch`]:[]});return t.length>0?[{item:e,reasons:t}]:[]},t[5]=k,t[6]=D,t[7]=N):N=t[7];let P=w.flatMap(N),F=w.flatMap(e=>e.comparisons.flatMap(t=>{let i=Sv(n,r,e);if(t.scope===`untracked`){let n=D.contents.get(t.path);return n===void 0?[]:[{...Z_(Ur(t),e.path,n,M.get(e.path)??`untracked`),review:i}]}if(t.scope===`unmerged`||!t.supported)return[];let a=My(k(t),s?.[e.path]),o=a?zi(t,a):null,c=M.get(e.path);return o?[{...o,...c?{note:c}:{},review:i,discardScope:t.scope}]:[]})),I=new Set(F.map(Cy)),L=i.toolbarTarget!==void 0&&/^(file|change|branch|walkthrough-step):/.test(i.entry)&&F.length===0&&w.length===1?P[0]?.item:void 0,R=c||A||j||P.length>0?e=>(0,Z.jsxs)(Z.Fragment,{children:[c?.({...e,open:t=>{b(void 0),I.has(t)?e.open(t):b(t)}}),(A||j)&&(0,Z.jsx)(Ny,{failed:j,retry:()=>{E.retry(),D.retry()}}),P.length>0&&(0,Z.jsx)(Py,{changes:P,column:g,onTarget:(e,t)=>{t&&S(e,t)},renderedPaths:I,scope:n,context:r,paneFile:!!L})]}):void 0,z;t[8]!==r||t[9]!==l||t[10]!==i.active||t[11]!==L||t[12]!==n?(z=L?(0,Z.jsx)(Fy,{scope:n,context:r,item:L,active:i.active,children:l}):void 0,t[8]=r,t[9]=l,t[10]=i.active,t[11]=L,t[12]=n,t[13]=z):z=t[13];let B;t[14]===f?B=t[15]:(B=f?{footer:f}:{},t[14]=f,t[15]=B);let V;t[16]===R?V=t[17]:(V=R?{header:R}:{},t[16]=R,t[17]=V);let H;t[18]===l?H=t[19]:(H=l?{headerActions:l}:{},t[18]=l,t[19]=H);let U;t[20]===u?U=t[21]:(U=u?{headerLeading:u}:{},t[20]=u,t[21]=U);let W;t[22]===d?W=t[23]:(W=d?{toolbar:d}:{},t[22]=d,t[23]=W);let G;return t[24]!==g||t[25]!==r||t[26]!==F||t[27]!==_||t[28]!==i||t[29]!==n||t[30]!==H||t[31]!==U||t[32]!==W||t[33]!==z||t[34]!==B||t[35]!==V?(G=(0,Z.jsx)(lv,{fullHeight:_,emptyActions:z,scope:n,context:r,interaction:i,entries:F,column:g,...B,...V,...H,...U,...W}),t[24]=g,t[25]=r,t[26]=F,t[27]=_,t[28]=i,t[29]=n,t[30]=H,t[31]=U,t[32]=W,t[33]=z,t[34]=B,t[35]=V,t[36]=G):G=t[36],G}function Cy(e){return e.path}function wy(e){return[e.path,e.note]}function Ty(e){return e.comparisons.flatMap(Ey)}function Ey(e){return e.scope===`untracked`?[e.path]:[]}function Dy(e){return e.comparisons.flatMap(Oy)}function Oy(e){let t=Wc(e);return t?[t]:[]}function ky(e){return e.comparisons.some(Ay)?[{path:e.path,fingerprint:e.fingerprint}]:[]}function Ay(e){return e.scope===`staged`||e.scope===`unstaged`}var jy=new WeakMap;function My(e,t){if(!e||!t?.length||e.kind!==`text`)return e;let n=t.map(e=>`${e.startLine}-${e.endLine}`).join(`,`),r=jy.get(e),i=r?.get(n);if(i)return i;let a=Jl(e.patch,t),o=a?{...e,patch:a}:e;return r??=new Map,r.set(n,o),jy.set(e,r),o}function Ny(e){let t=(0,$.c)(3),{failed:n,retry:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)(`section`,{className:`mx-4 mt-3 flex items-center gap-3 rounded-lg border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"aria-live":`polite`,children:n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:`The changes in this document could not be read.`}),(0,Z.jsx)(Y,{size:`xs`,variant:`outline`,onClick:r,children:`Load the changes again`})]}):(0,Z.jsx)(`span`,{children:`Loading changes…`})}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function Py(e){let t=(0,$.c)(21),{changes:n,column:r,onTarget:i,renderedPaths:a,scope:o,context:s,paneFile:c}=e,l=!r&&`mx-4`,u;t[0]===l?u=t[1]:(u=q(`mt-3 rounded-lg border bg-muted/40 px-4 py-3`,l),t[0]=l,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(`p`,{className:`text-xs font-medium`,children:`Non-text content`}),t[2]=d):d=t[2];let f;if(t[3]!==n||t[4]!==s||t[5]!==i||t[6]!==c||t[7]!==a||t[8]!==o){let e;t[10]!==s||t[11]!==i||t[12]!==c||t[13]!==a||t[14]!==o?(e=e=>{let{item:t,reasons:n}=e;return(0,Z.jsxs)(`li`,{"aria-label":`${t.path}: ${xy(n)}`,tabIndex:-1,ref:e=>i(t.path,e),className:`flex min-w-0 scroll-mt-3 flex-wrap items-center gap-2 outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Z.jsx)(X,{className:`min-w-0 basis-full`,text:t.path}),ou(t.path)&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:`Current worktree image`}),(0,Z.jsx)(na,{scope:o,path:t.path,connection:s.connection})]}),(0,Z.jsx)(nt,{variant:`outline`,className:`h-auto max-w-full text-left whitespace-normal`,children:xy(n)}),!c&&!a.has(t.path)&&(0,Z.jsx)(Cv,{scope:o,context:s,path:t.path,fingerprint:t.fingerprint,status:t.reviewStatus,compact:!!t.fingerprint})]},t.path)},t[10]=s,t[11]=i,t[12]=c,t[13]=a,t[14]=o,t[15]=e):e=t[15],f=n.map(e),t[3]=n,t[4]=s,t[5]=i,t[6]=c,t[7]=a,t[8]=o,t[9]=f}else f=t[9];let p;t[16]===f?p=t[17]:(p=(0,Z.jsx)(`ul`,{className:`mt-2 flex flex-col gap-2 text-xs text-muted-foreground`,children:f}),t[16]=f,t[17]=p);let m;return t[18]!==u||t[19]!==p?(m=(0,Z.jsxs)(`section`,{className:u,children:[d,p]}),t[18]=u,t[19]=p,t[20]=m):m=t[20],m}function Fy(e){let t=(0,$.c)(17),{scope:n,context:r,item:i,active:a,children:o}=e,s=ov(n,r,Iy),c;t[0]!==r||t[1]!==i||t[2]!==n?(c=Sv(n,r,i),t[0]=r,t[1]=i,t[2]=n,t[3]=c):c=t[3];let l=c,u;t[4]!==s||t[5]!==l?(u=()=>s.toggle(l),t[4]=s,t[5]=l,t[6]=u):u=t[6];let d=u,f;t[7]===a?f=t[8]:(f={enabled:a,ignoreInputs:!0},t[7]=a,t[8]=f),So(vo.toggleReviewed,d,f);let p=l.reviewed?g:Pc,m=!l.fingerprint,h;t[9]!==p||t[10]!==m||t[11]!==l.reviewed||t[12]!==d?(h=(0,Z.jsx)(G_,{label:`Reviewed`,variant:`outline`,icon:p,shortcut:vo.toggleReviewed,disabled:m,pressed:l.reviewed,onClick:d}),t[9]=p,t[10]=m,t[11]=l.reviewed,t[12]=d,t[13]=h):h=t[13];let _;return t[14]!==o||t[15]!==h?(_=(0,Z.jsxs)(Z.Fragment,{children:[h,o]}),t[14]=o,t[15]=h,t[16]=_):_=t[16],_}function Iy(e){return bo.add(e)}var Ly=Q.createContext(void 0);function Ry(){let e=Q.useContext(Ly);if(e===void 0)throw Error(Vt(13));return e}var zy={imageLoadingStatus:()=>null},By=Q.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,[o,s]=Q.useState(`idle`),c={imageLoadingStatus:o},l=Q.useMemo(()=>({imageLoadingStatus:o,setImageLoadingStatus:s}),[o,s]),u=Ct(`span`,e,{state:c,ref:t,props:a,stateAttributesMapping:zy});return(0,Z.jsx)(Ly.Provider,{value:l,children:u})});function Vy(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i},o){let s=Q.useState(`idle`),c=s[1];return a(()=>{if(!o)return y;if(!e&&!i)return c(`error`),y;let a=!0,s=new window.Image,l=e=>()=>{a&&c(e)};return c(`loading`),s.onload=l(`loaded`),s.onerror=l(`error`),t&&(s.referrerPolicy=t),s.crossOrigin=n??null,r&&(s.sizes=r),i&&(s.srcset=i),e&&(s.src=e),s.complete&&c(s.naturalWidth>0?`loaded`:`error`),()=>{a=!1}},[o,e,i,r,n,t,c]),s}var Hy={...zy,...Kt},Uy=Q.forwardRef(function(e,t){let{className:n,render:r,onLoadingStatusChange:i,keepMounted:o=!1,style:s,sizes:c,srcSet:l,src:u,...d}=e,{setImageLoadingStatus:f}=Ry(),[p,m]=Vy(u,e,!o),h=p===`loaded`,{mounted:g,transitionStatus:_,setMounted:v}=he(h),y=Q.useRef(null),b=Q.useRef(!0);a(()=>{if(!o)return;let e=b.current;b.current=!1;let t=y.current;if(!t)return;if(!t.complete){m(`loading`);return}let n=t.naturalWidth>0?`loaded`:`error`;m(n),n===`loaded`&&e&&v(!0)},[o,u,l,c,d.crossOrigin,d.referrerPolicy,r,m,v]);let x=o?{"data-loading":p===`loading`?``:void 0,"data-error":p===`error`?``:void 0,"aria-hidden":p!==`loaded`||void 0,onLoad(){m(`loaded`)},onError(){m(`error`)}}:void 0,S=pe(e=>{i?.(e),f(e)});a(()=>{p!==`idle`&&S(p)},[p,S]),a(()=>()=>f(`idle`),[f]),be({enabled:!h,open:h,ref:y,onComplete(){h||v(!1)}});let C={imageLoadingStatus:p,transitionStatus:o&&_===`ending`?void 0:_},w=o||g,T={};c!==void 0&&(T.sizes=c),l!==void 0&&(T.srcSet=l),u!==void 0&&(T.src=u);let E=Ct(`img`,e,{state:C,ref:[t,y],props:[x,d,T],stateAttributesMapping:Hy,enabled:w});return w?E:null}),Wy=Q.forwardRef(function(e,t){let{className:n,render:r,delay:i=0,style:a,...o}=e,{imageLoadingStatus:s}=Ry(),[c,l]=Q.useState(i===0),u=ke();return Q.useEffect(()=>(i>0?u.start(i,()=>l(!0)):l(!0),u.clear),[u,i]),Ct(`span`,e,{state:{imageLoadingStatus:s},ref:t,props:o,stateAttributesMapping:zy,enabled:s!==`loaded`&&(i===0||c)})});function Gy({className:e,size:t=`default`,...n}){return(0,Z.jsx)(By,{"data-slot":`avatar`,"data-size":t,className:q(`group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten`,e),...n})}function Ky({className:e,...t}){return(0,Z.jsx)(Uy,{"data-slot":`avatar-image`,className:q(`aspect-square size-full rounded-full object-cover`,e),...t})}function qy({className:e,...t}){return(0,Z.jsx)(Wy,{"data-slot":`avatar-fallback`,className:q(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t})}var Jy={open:bc,draft:Sc,merged:gc,closed:vc};function Yy(e){let t=(0,$.c)(10),{pull:n}=e,r;t[0]===n?r=t[1]:(r=Ja(n),t[0]=n,t[1]=r);let i=r,a=Jy[i],o;t[2]===a?o=t[3]:(o=(0,Z.jsx)(a,{"aria-hidden":`true`}),t[2]=a,t[3]=o);let s;t[4]===n?s=t[5]:(s=Za(n),t[4]=n,t[5]=s);let c;return t[6]!==i||t[7]!==o||t[8]!==s?(c=(0,Z.jsxs)(nt,{variant:i,children:[o,s]}),t[6]=i,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function Xy(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(nt,{variant:`outline`,children:[(0,Z.jsx)(Ga,{"aria-hidden":`true`}),`GitHub unavailable`]}),e[0]=t):t=e[0],t}var Zy={passed:(0,Z.jsx)(g,{"aria-hidden":`true`,strokeWidth:2.5,className:`size-3 shrink-0 text-add-fg`}),running:(0,Z.jsx)(dt,{"aria-hidden":`true`,className:`size-3 shrink-0`}),failed:(0,Z.jsx)(jt,{"aria-hidden":`true`,strokeWidth:2.5,className:`size-3 shrink-0 text-del-fg`})};function Qy(e){let t=(0,$.c)(6),{tone:n,label:r,className:i}=e,a;t[0]===i?a=t[1]:(a=q(`inline-flex items-center gap-1`,i),t[0]=i,t[1]=a);let o=n!==`none`&&Zy[n],s;return t[2]!==r||t[3]!==a||t[4]!==o?(s=(0,Z.jsxs)(`span`,{className:a,children:[o,r]}),t[2]=r,t[3]=a,t[4]=o,t[5]=s):s=t[5],s}function $y(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground`,children:`·`}),e[0]=t):t=e[0],t}var eb={passed:`open`,failed:`closed`,none:`outline`};function tb(e){let t=(0,$.c)(63),{projectId:n,number:r,context:i,toolbarTarget:a,onBack:s,onFile:c}=e,l;t[0]!==i.connection||t[1]!==r||t[2]!==n?(l=xt({connection:i.connection,projectId:n,number:r}),t[0]=i.connection,t[1]=r,t[2]=n,t[3]=l):l=t[3];let u=l,d=N(u),f=Vn(u),p;t[4]===d?p=t[5]:(p=Nt(bt(d)),t[4]=d,t[5]=p);let m=p;if(Qt(d)){let e;return t[6]!==s||t[7]!==f?(e=(0,Z.jsx)(Ce,{description:`The pull request could not be read.`,onRetry:f,onBack:s}),t[6]=s,t[7]=f,t[8]=e):e=t[8],e}if(!m){let e;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(o,{label:`Loading pull request`}),t[9]=e):e=t[9],e}if(m.kind===`unavailable`){let e;return t[10]!==s||t[11]!==d.waiting||t[12]!==f||t[13]!==m.reason?(e=(0,Z.jsx)(fb,{reason:m.reason,retrying:d.waiting,onRetry:f,onBack:s}),t[10]=s,t[11]=d.waiting,t[12]=f,t[13]=m.reason,t[14]=e):e=t[14],e}let h=m.pullRequest,g;t[15]!==i.connection||t[16]!==r||t[17]!==n||t[18]!==h.state?(g=h.state===`merged`||h.state===`closed`?(0,Z.jsx)(yi,{connection:i.connection,projectId:n,number:r}):void 0,t[15]=i.connection,t[16]=r,t[17]=n,t[18]=h.state,t[19]=g):g=t[19];let _;t[20]!==h.url||t[21]!==g||t[22]!==a?(_=(0,Z.jsx)(rb,{url:h.url,target:a,archive:g}),t[20]=h.url,t[21]=g,t[22]=a,t[23]=_):_=t[23];let v=`Pull request #${r}`,y;t[24]===h?y=t[25]:(y=(0,Z.jsx)(ib,{pull:h}),t[24]=h,t[25]=y);let b;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(`h2`,{children:`Description`}),t[26]=b):b=t[26];let x;t[27]===h.author?x=t[28]:(x=h.author&&(0,Z.jsx)(X,{text:`by ${h.author}`}),t[27]=h.author,t[28]=x);let S;t[29]!==h.author||t[30]!==h.createdAt?(S=h.author&&h.createdAt&&(0,Z.jsx)($y,{}),t[29]=h.author,t[30]=h.createdAt,t[31]=S):S=t[31];let C;t[32]===h.createdAt?C=t[33]:(C=h.createdAt&&(0,Z.jsx)(`time`,{dateTime:h.createdAt,children:pb(h.createdAt)}),t[32]=h.createdAt,t[33]=C);let w;t[34]!==C||t[35]!==x||t[36]!==S?(w=(0,Z.jsxs)(`div`,{className:nb,children:[b,(0,Z.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-1.5 font-normal`,children:[x,S,C]})]}),t[34]=C,t[35]=x,t[36]=S,t[37]=w):w=t[37];let T;t[38]===h.description?T=t[39]:(T=h.description.trim()?(0,Z.jsx)(Dr,{text:h.description,className:`pt-3.5 text-(length:--text-prose) leading-6 wrap-anywhere text-foreground-2 [&_h1]:text-foreground [&_h2]:text-foreground [&_h3]:text-base [&_h3]:leading-6 [&_h3]:text-foreground [&_code]:text-ui [&_code]:leading-5 [&_p]:leading-6 [&_p]:mt-1 [&_p]:mb-0 [&_ul]:mt-2 [&_ul]:mb-0 [&_ol]:mt-2 [&_ol]:mb-0 [&_li]:my-0 [&_h1]:mb-0 [&_h2]:mb-0 [&_h3]:mb-0 [&_h1]:tracking-pr-subheading [&_h2]:tracking-pr-subheading [&_h3]:tracking-pr-subheading [&_code]:rounded-sm [&_code]:px-1.25 [&_code]:py-px [&_code]:ring-1 [&_code]:ring-border [&_code]:ring-inset`}):(0,Z.jsx)(`p`,{className:`pt-3.5 text-ui text-muted-foreground`,children:`No description provided.`}),t[38]=h.description,t[39]=T);let E;t[40]!==w||t[41]!==T?(E=(0,Z.jsxs)(`section`,{"aria-label":`Description`,children:[w,T]}),t[40]=w,t[41]=T,t[42]=E):E=t[42];let D;t[43]!==s||t[44]!==c||t[45]!==h?(D=(0,Z.jsx)(ob,{pull:h,onBack:s,onFile:c}),t[43]=s,t[44]=c,t[45]=h,t[46]=D):D=t[46];let O;t[47]!==E||t[48]!==D?(O=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[E,D]}),t[47]=E,t[48]=D,t[49]=O):O=t[49];let k;t[50]===h?k=t[51]:(k=(0,Z.jsx)(`aside`,{"aria-label":`Checks and details`,className:`min-w-0 shrink-0 @min-4xl/pr:w-68`,children:(0,Z.jsx)(ub,{pull:h})}),t[50]=h,t[51]=k);let A;t[52]!==O||t[53]!==k?(A=(0,Z.jsxs)(`div`,{className:`mt-7 flex min-w-0 flex-col gap-x-11 gap-y-7 @min-4xl/pr:flex-row`,children:[O,k]}),t[52]=O,t[53]=k,t[54]=A):A=t[54];let j;t[55]!==d.waiting||t[56]!==A||t[57]!==v||t[58]!==y?(j=(0,Z.jsxs)(`article`,{"aria-busy":d.waiting,"aria-label":v,className:`mx-auto w-full max-w-280 min-w-0 px-4 pt-9 pb-12 text-ui @min-3xl/pr:px-7`,children:[y,A]}),t[55]=d.waiting,t[56]=A,t[57]=v,t[58]=y,t[59]=j):j=t[59];let M;return t[60]!==j||t[61]!==_?(M=(0,Z.jsxs)(`div`,{className:`@container/pr flex min-h-0 min-w-0 flex-1 flex-col overflow-auto`,children:[_,j]}),t[60]=j,t[61]=_,t[62]=M):M=t[62],M}var nb=`flex min-h-6 min-w-0 flex-wrap items-center gap-x-2 gap-y-1 border-b pb-1.5 text-xs leading-4 font-medium text-muted-foreground`;function rb(e){let t=(0,$.c)(21),{url:n,target:r,archive:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,nativeButton:!1,render:(0,Z.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`}),"aria-label":`Open on GitHub`,className:``}),t[0]=n,t[1]=a);let o=r!==void 0&&`hidden @min-3xl/pane:inline`,s;t[2]===o?s=t[3]:(s=q(o),t[2]=o,t[3]=s);let c;t[4]===s?c=t[5]:(c=(0,Z.jsx)(`span`,{className:s,children:`Open on GitHub`}),t[4]=s,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(h,{"aria-hidden":`true`,className:`size-3.5`}),t[6]=l):l=t[6];let u;t[7]!==a||t[8]!==c?(u=(0,Z.jsxs)(nn,{render:a,children:[c,l]}),t[7]=a,t[8]=c,t[9]=u):u=t[9];let d;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(yt,{children:`Open on GitHub`}),t[10]=d):d=t[10];let f;t[11]===u?f=t[12]:(f=(0,Z.jsxs)(wn,{children:[u,d]}),t[11]=u,t[12]=f);let p;t[13]!==i||t[14]!==f?(p=(0,Z.jsxs)(Z.Fragment,{children:[i,f]}),t[13]=i,t[14]=f,t[15]=p):p=t[15];let m=p;if(r!==void 0){let e;return t[16]!==m||t[17]!==r?(e=r?(0,ru.createPortal)(m,r):null,t[16]=m,t[17]=r,t[18]=e):e=t[18],e}let g;return t[19]===m?g=t[20]:(g=(0,Z.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-end border-b px-3`,children:m}),t[19]=m,t[20]=g),g}function ib(e){let t=(0,$.c)(50),{pull:n}=e,r;t[0]===n.url?r=t[1]:(r=Go(n.url)?.split(`/`).at(-1),t[0]=n.url,t[1]=r);let i=r,a,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(bc,{"aria-hidden":`true`,strokeWidth:1.75,className:`size-3.5 shrink-0`}),o=(0,Z.jsx)(`span`,{className:`shrink-0`,children:`Pull request`}),t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s;t[4]===i?s=t[5]:(s=i&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($y,{}),(0,Z.jsx)(X,{text:i})]}),t[4]=i,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,Z.jsxs)(`div`,{className:`flex h-5.5 min-w-0 items-center gap-2 text-ui leading-5.5 font-medium text-muted-foreground`,children:[a,o,s]}),t[6]=s,t[7]=c);let l;t[8]===n.number?l=t[9]:(l=(0,Z.jsxs)(`span`,{className:`text-title-dim tabular-nums`,children:[`#`,n.number]}),t[8]=n.number,t[9]=l);let u;t[10]!==n.title||t[11]!==l?(u=(0,Z.jsxs)(`h1`,{className:`mt-3 text-4xl leading-10 font-semibold tracking-pr-title wrap-anywhere`,children:[l,` `,n.title]}),t[10]=n.title,t[11]=l,t[12]=u):u=t[12];let d;t[13]===n?d=t[14]:(d=(0,Z.jsx)(Yy,{pull:n}),t[13]=n,t[14]=d);let f;t[15]!==n.author||t[16]!==n.authorAvatarUrl?(f=n.author&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(sb,{author:n.author,url:n.authorAvatarUrl}),(0,Z.jsx)(X,{text:n.author,className:`font-medium text-foreground`}),(0,Z.jsx)($y,{})]}),t[15]=n.author,t[16]=n.authorAvatarUrl,t[17]=f):f=t[17];let p;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(`span`,{tabIndex:0,className:`inline-flex max-w-full min-w-0 items-center gap-1.5 font-mono text-caption text-foreground outline-none`}),t[18]=p):p=t[18];let m;t[19]===n.baseBranch?m=t[20]:(m=(0,Z.jsx)(X,{text:n.baseBranch}),t[19]=n.baseBranch,t[20]=m);let h;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(Js,{"aria-hidden":`true`,strokeWidth:1.75,className:`size-3 shrink-0 text-muted-foreground`}),t[21]=h):h=t[21];let g;t[22]===n.headBranch?g=t[23]:(g=(0,Z.jsx)(X,{text:n.headBranch}),t[22]=n.headBranch,t[23]=g);let _;t[24]!==m||t[25]!==g?(_=(0,Z.jsxs)(nn,{render:p,children:[m,h,g]}),t[24]=m,t[25]=g,t[26]=_):_=t[26];let v;t[27]!==n.baseBranch||t[28]!==n.headBranch?(v=(0,Z.jsxs)(yt,{children:[`Merges `,n.headBranch,` into `,n.baseBranch]}),t[27]=n.baseBranch,t[28]=n.headBranch,t[29]=v):v=t[29];let y;t[30]!==_||t[31]!==v?(y=(0,Z.jsxs)(wn,{children:[_,v]}),t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)($y,{}),t[33]=b):b=t[33];let x;t[34]===n.updatedAt?x=t[35]:(x=pb(n.updatedAt),t[34]=n.updatedAt,t[35]=x);let S;t[36]===x?S=t[37]:(S=(0,Z.jsxs)(`span`,{children:[`updated `,x]}),t[36]=x,t[37]=S);let C;t[38]!==y||t[39]!==S||t[40]!==d||t[41]!==f?(C=(0,Z.jsxs)(`div`,{className:`mt-3.5 flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-2 text-ui leading-5 text-muted-foreground`,children:[d,f,y,b,S]}),t[38]=y,t[39]=S,t[40]=d,t[41]=f,t[42]=C):C=t[42];let w;t[43]===n.labels?w=t[44]:(w=n.labels.length>0&&(0,Z.jsx)(`ul`,{"aria-label":`Labels`,className:`mt-3 flex min-w-0 flex-wrap gap-1.5`,children:n.labels.map(ab)}),t[43]=n.labels,t[44]=w);let T;return t[45]!==C||t[46]!==w||t[47]!==c||t[48]!==u?(T=(0,Z.jsxs)(`header`,{className:`min-w-0`,children:[c,u,C,w]}),t[45]=C,t[46]=w,t[47]=c,t[48]=u,t[49]=T):T=t[49],T}function ab(e,t){return(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,children:(0,Z.jsx)(nt,{variant:`outline`,className:`max-w-full`,children:(0,Z.jsx)(X,{text:e.name})})},`${e.name}:${t}`)}function ob(e){let t=(0,$.c)(23),{pull:n,onBack:r,onFile:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`h2`,{children:`Conversation`}),t[0]=a):a=t[0];let o;t[1]===n.timeline.length?o=t[2]:(o=(0,Z.jsx)(`span`,{className:`font-normal tabular-nums`,children:n.timeline.length}),t[1]=n.timeline.length,t[2]=o);let s=`${n.url}#issue-comment-box`,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Fn,{"aria-hidden":`true`,className:`size-3 shrink-0`}),t[3]=c):c=t[3];let l,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsxs)(`span`,{children:[`Comments on GitHub ·`,` `,(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:`reply there`})]}),u=(0,Z.jsx)(h,{"aria-hidden":`true`,className:`size-3 shrink-0`}),t[4]=l,t[5]=u):(l=t[4],u=t[5]);let d;t[6]===s?d=t[7]:(d=(0,Z.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:`ml-auto inline-flex max-w-full min-w-0 flex-wrap items-center gap-1 font-normal outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[c,l,u]}),t[6]=s,t[7]=d);let f;t[8]!==o||t[9]!==d?(f=(0,Z.jsxs)(`div`,{className:nb,children:[a,o,d]}),t[8]=o,t[9]=d,t[10]=f):f=t[10];let p;t[11]!==i||t[12]!==n.timeline?(p=n.timeline.length>0?(0,Z.jsx)(`ol`,{"aria-label":`Timeline`,className:`relative mt-3.5 flex min-w-0 flex-col gap-4 before:absolute before:top-4 before:bottom-2.5 before:left-2.5 before:w-px before:bg-border`,children:Jo(n.timeline).map(e=>{let{item:t,comments:n}=e;return(0,Z.jsx)(cb,{item:t,onFile:i,children:n.length>0&&(0,Z.jsx)(`ol`,{"aria-label":`Comments on review by ${t.author??`Unknown author`}`,className:`mt-3 flex min-w-0 flex-col gap-3 border-l pl-3`,children:n.map(e=>(0,Z.jsx)(cb,{item:e,onFile:i},e.id))})},t.id)})}):(0,Z.jsx)(`p`,{className:`pt-3.5 text-ui text-muted-foreground`,children:`No comments or reviews on GitHub yet.`}),t[11]=i,t[12]=n.timeline,t[13]=p):p=t[13];let m;t[14]===n.truncated?m=t[15]:(m=n.truncated&&(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Some labels or conversation items are not shown. Open on GitHub to see everything.`}),t[14]=n.truncated,t[15]=m);let g;t[16]===r?g=t[17]:(g=(0,Z.jsxs)(`p`,{className:`mt-4 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-xs leading-4 text-muted-foreground @min-3xl/pr:ml-7.5`,children:[`Questions about the change belong in its Walkthrough.`,(0,Z.jsx)(Y,{variant:`link`,size:`sm`,onClick:r,children:`Back to the worktree`})]}),t[16]=r,t[17]=g);let _;return t[18]!==m||t[19]!==g||t[20]!==f||t[21]!==p?(_=(0,Z.jsxs)(`section`,{"aria-label":`Conversation on GitHub`,className:`mt-7 min-w-0`,children:[f,p,m,g]}),t[18]=m,t[19]=g,t[20]=f,t[21]=p,t[22]=_):_=t[22],_}function sb(e){let t=(0,$.c)(9),{author:n,url:r}=e,i;t[0]===r?i=t[1]:(i=r&&(0,Z.jsx)(Ky,{src:r,alt:``}),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=n.slice(0,1).toUpperCase(),t[2]=n,t[3]=a);let o;t[4]===a?o=t[5]:(o=(0,Z.jsx)(qy,{children:a}),t[4]=a,t[5]=o);let s;return t[6]!==i||t[7]!==o?(s=(0,Z.jsxs)(Gy,{size:`sm`,"aria-hidden":`true`,children:[i,o]}),t[6]=i,t[7]=o,t[8]=s):s=t[8],s}function cb(e){let t=(0,$.c)(51),{item:n,onFile:r,children:i}=e,{dark:a}=wo(),o;t[0]===n.reviewState?o=t[1]:(o=ro(n.reviewState),t[0]=n.reviewState,t[1]=o);let s=o,c=n.author??`Unknown author`,l=n.line??n.originalLine,u=n.path,d=n.path===void 0?void 0:`${n.path}${l===void 0?``:`:${l}`}`,f;t[2]!==c||t[3]!==n.authorAvatarUrl?(f=(0,Z.jsx)(`div`,{className:`z-1 shrink-0 bg-background`,children:(0,Z.jsx)(sb,{author:c,url:n.authorAvatarUrl})}),t[2]=c,t[3]=n.authorAvatarUrl,t[4]=f):f=t[4];let p;t[5]===c?p=t[6]:(p=(0,Z.jsx)(X,{text:c,className:`text-ui leading-4.5 font-semibold text-foreground`}),t[5]=c,t[6]=p);let m;t[7]===s?m=t[8]:(m=s&&(0,Z.jsx)(nt,{variant:eb[s.tone],children:s.label}),t[7]=s,t[8]=m);let g=!s&&n.kind===`comment`?`commented · `:``,_;t[9]===n.time?_=t[10]:(_=pb(n.time),t[9]=n.time,t[10]=_);let v;t[11]!==g||t[12]!==_?(v=(0,Z.jsxs)(`span`,{children:[g,_]}),t[11]=g,t[12]=_,t[13]=v):v=t[13];let y;t[14]===n.url?y=t[15]:(y=(0,Z.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`}),t[14]=n.url,t[15]=y);let b=`Open this ${n.kind===`review`?`review`:`comment`} on GitHub`,x;t[16]!==y||t[17]!==b?(x=(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,nativeButton:!1,render:y,"aria-label":b,className:`ml-auto`}),t[16]=y,t[17]=b,t[18]=x):x=t[18];let S;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(h,{"aria-hidden":`true`,className:`size-3`}),t[19]=S):S=t[19];let C;t[20]===x?C=t[21]:(C=(0,Z.jsx)(nn,{render:x,children:S}),t[20]=x,t[21]=C);let w;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(yt,{children:`Open on GitHub`}),t[22]=w):w=t[22];let T;t[23]===C?T=t[24]:(T=(0,Z.jsxs)(wn,{children:[C,w]}),t[23]=C,t[24]=T);let E;t[25]!==T||t[26]!==p||t[27]!==m||t[28]!==v?(E=(0,Z.jsxs)(`div`,{className:`flex min-h-5 min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs leading-4 text-muted-foreground`,children:[p,m,v,T]}),t[25]=T,t[26]=p,t[27]=m,t[28]=v,t[29]=E):E=t[29];let D;t[30]!==d||t[31]!==n.path||t[32]!==r||t[33]!==u?(D=d&&(0,Z.jsxs)(`div`,{className:`mt-2.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 rounded-t-lg border bg-muted px-2 py-1.5`,children:[r&&n.path!==void 0?(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,"aria-label":`Open ${d}`,className:`max-w-full min-w-0 justify-start`,onClick:()=>{u!==void 0&&r(u)},children:[(0,Z.jsx)(Lr,{"aria-hidden":`true`}),(0,Z.jsx)(X,{text:d})]}):(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono text-xs`,children:[(0,Z.jsx)(Lr,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Z.jsx)(X,{text:d})]}),(0,Z.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`review comment`})]}),t[30]=d,t[31]=n.path,t[32]=r,t[33]=u,t[34]=D):D=t[34];let O;t[35]!==a||t[36]!==n.diffHunk||t[37]!==u?(O=n.diffHunk&&(0,Z.jsx)(`div`,{role:`region`,"aria-label":`Code excerpt for ${u??`review comment`}`,className:`max-h-64 min-w-0 overflow-auto border-x`,children:(0,Z.jsx)(Nr,{file:{name:u??`review.diff`,contents:n.diffHunk,lang:`diff`},options:{theme:ps,preferredHighlighter:jo,themeType:a?`dark`:`light`,disableFileHeader:!0,disableLineNumbers:!0,overflow:`wrap`}})}),t[35]=a,t[36]=n.diffHunk,t[37]=u,t[38]=O):O=t[38];let k;t[39]!==d||t[40]!==n.body?(k=n.body.trim()&&(0,Z.jsx)(Dr,{text:n.body,className:q(`mt-1 text-sm leading-5.5 wrap-anywhere [&_p]:my-0 [&_p]:leading-5.5`,d&&`mt-0 rounded-b-lg border border-t-0 px-3 py-2.5 text-ui [&_p]:leading-4.75`)}),t[39]=d,t[40]=n.body,t[41]=k):k=t[41];let A;t[42]!==i||t[43]!==E||t[44]!==D||t[45]!==O||t[46]!==k?(A=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[E,D,O,k,i]}),t[42]=i,t[43]=E,t[44]=D,t[45]=O,t[46]=k,t[47]=A):A=t[47];let j;return t[48]!==A||t[49]!==f?(j=(0,Z.jsxs)(`li`,{className:`relative flex min-w-0 items-start gap-2.5`,children:[f,A]}),t[48]=A,t[49]=f,t[50]=j):j=t[50],j}var lb={passed:{Icon:Ua,label:`Passed`,color:`text-add-fg`},failed:{Icon:nc,label:`Failed`,color:`text-del-fg`},running:{Icon:dt,label:`Running`,color:`text-muted-foreground`}};function ub(e){let t=(0,$.c)(34),{pull:n}=e,r;t[0]!==n.checks||t[1]!==n.checksSummary||t[2]!==n.checksTruncated?(r=eo(n.checks,n.checksTruncated,n.checksSummary),t[0]=n.checks,t[1]=n.checksSummary,t[2]=n.checksTruncated,t[3]=r):r=t[3];let i=r,a;t[4]===n.mergeable?a=t[5]:(a=ba(n.mergeable),t[4]=n.mergeable,t[5]=a);let o=a,s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(`h2`,{children:`Checks`}),t[6]=s):s=t[6];let c=i.tone===`passed`?`${n.checks.length}${n.checksTruncated?`+`:``} passed`:i.label,l;t[7]!==i.tone||t[8]!==c?(l=(0,Z.jsxs)(`div`,{className:nb,children:[s,(0,Z.jsx)(Qy,{tone:i.tone,label:c,className:`ml-auto text-foreground tabular-nums`})]}),t[7]=i.tone,t[8]=c,t[9]=l):l=t[9];let u;t[10]===n.checks?u=t[11]:(u=n.checks.length===0?(0,Z.jsx)(`p`,{className:`pt-3 text-ui text-muted-foreground`,children:`No checks reported by GitHub.`}):(0,Z.jsx)(`ul`,{className:`mt-1`,"aria-label":`Pull request checks`,children:n.checks.map(db)}),t[10]=n.checks,t[11]=u);let d;t[12]===n.checksTruncated?d=t[13]:(d=n.checksTruncated&&(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`More checks are available on GitHub.`}),t[12]=n.checksTruncated,t[13]=d);let f;t[14]!==l||t[15]!==u||t[16]!==d?(f=(0,Z.jsxs)(`section`,{"aria-label":`GitHub checks`,children:[l,u,d]}),t[14]=l,t[15]=u,t[16]=d,t[17]=f):f=t[17];let p;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Head`}),t[18]=p):p=t[18];let m=n.headSha,h;t[19]===n.headSha?h=t[20]:(h=Ap(n.headSha),t[19]=n.headSha,t[20]=h);let g;t[21]!==n.headSha||t[22]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex h-7 min-w-0 items-center gap-2`,children:[p,(0,Z.jsx)(`dd`,{className:`ml-auto min-w-0 font-mono text-caption font-medium`,children:(0,Z.jsx)(X,{text:m,disclose:`always`,children:h})})]}),t[21]=n.headSha,t[22]=h,t[23]=g):g=t[23];let _;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Mergeable`}),t[24]=_):_=t[24];let v;t[25]!==o.label||t[26]!==o.tone?(v=(0,Z.jsxs)(`div`,{className:`flex h-7 items-center gap-2 border-t`,children:[_,(0,Z.jsx)(`dd`,{className:`ml-auto font-medium`,children:(0,Z.jsx)(Qy,{tone:o.tone,label:o.label,className:`gap-1.5`})})]}),t[25]=o.label,t[26]=o.tone,t[27]=v):v=t[27];let y;t[28]!==g||t[29]!==v?(y=(0,Z.jsxs)(`dl`,{"aria-label":`Merge`,className:`mt-5 border-y text-ui leading-4.5`,children:[g,v]}),t[28]=g,t[29]=v,t[30]=y):y=t[30];let b;return t[31]!==y||t[32]!==f?(b=(0,Z.jsxs)(Z.Fragment,{children:[f,y]}),t[31]=y,t[32]=f,t[33]=b):b=t[33],b}function db(e,t){let n=Oa(e),r=ja(e.durationMs),a=lb[n],o=a.Icon;return(0,Z.jsxs)(`li`,{className:`flex h-7 min-w-0 items-center gap-2 text-ui leading-4.5`,children:[(0,Z.jsx)(o,{role:`img`,"aria-label":a.label,className:q(`size-3.5 shrink-0`,a.color)}),(0,Z.jsx)(X,{text:e.name,className:`min-w-0 flex-1`}),r&&(0,Z.jsx)(`span`,{className:`shrink-0 text-xs leading-4 text-muted-foreground tabular-nums`,children:r}),e.detailsUrl&&(0,Z.jsxs)(wn,{children:[(0,Z.jsxs)(nn,{render:(0,Z.jsx)(`a`,{href:e.detailsUrl,target:`_blank`,rel:`noreferrer`,"aria-label":`Details for ${e.name} on GitHub`,className:i({variant:`ghost`,size:`sm`})}),children:[`Details`,(0,Z.jsx)(h,{"aria-hidden":`true`,className:`size-2.75`})]}),(0,Z.jsxs)(yt,{children:[`Details for `,e.name,` on GitHub`]})]})]},`${e.name}:${t}`)}function fb(e){let t=(0,$.c)(28),{reason:n,retrying:r,onRetry:i,onBack:a}=e,o=Xe(),s;t[0]===n?s=t[1]:(s=fo(n),t[0]=n,t[1]=s);let{description:c,action:l}=s,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(Xy,{}),t[2]=u):u=t[2];let d;t[3]!==l.kind||t[4]!==l.label||t[5]!==o?(d=l.kind===`settings`&&(0,Z.jsxs)(Y,{variant:`outline`,onClick:()=>void o({to:`/settings/$section`,params:{section:`git`}}),children:[(0,Z.jsx)(Ni,{}),l.label]}),t[3]=l.kind,t[4]=l.label,t[5]=o,t[6]=d):d=t[6];let f;t[7]!==l.kind||t[8]!==l.label||t[9]!==l.url?(f=l.kind===`install`&&(0,Z.jsxs)(Y,{variant:`outline`,nativeButton:!1,render:(0,Z.jsx)(`a`,{href:l.url,target:`_blank`,rel:`noreferrer`}),children:[(0,Z.jsx)(h,{}),l.label]}),t[7]=l.kind,t[8]=l.label,t[9]=l.url,t[10]=f):f=t[10];let p;t[11]!==l.kind||t[12]!==l.label||t[13]!==l.text?(p=l.kind===`copy`&&(0,Z.jsxs)(Y,{variant:`outline`,onClick:()=>ht(l.text,`command`),children:[(0,Z.jsx)(De,{}),l.label]}),t[11]=l.kind,t[12]=l.label,t[13]=l.text,t[14]=p):p=t[14];let m;t[15]!==l.kind||t[16]!==i||t[17]!==r?(m=l.kind!==`install`&&(0,Z.jsx)(Y,{variant:`outline`,disabled:r,onClick:i,children:`Try again`}),t[15]=l.kind,t[16]=i,t[17]=r,t[18]=m):m=t[18];let g;t[19]===a?g=t[20]:(g=(0,Z.jsx)(Y,{variant:`ghost`,onClick:a,children:`Back to the worktree`}),t[19]=a,t[20]=g);let _;return t[21]!==c||t[22]!==d||t[23]!==f||t[24]!==p||t[25]!==m||t[26]!==g?(_=(0,Z.jsxs)(Rn,{title:`Pull request unavailable`,description:c,children:[u,d,f,p,m,g]}),t[21]=c,t[22]=d,t[23]=f,t[24]=p,t[25]=m,t[26]=g,t[27]=_):_=t[27],_}function pb(e){return Number.isFinite(Date.parse(e))?ze(e):`unknown time`}function mb(e){let t=(0,$.c)(53),{scope:n,context:r,document:i,onOpen:a,onBrowse:o,sideLabel:s,active:c,base:l,toolbarTarget:u,walkthrough:d,walkthroughCode:f,singleHeader:p,fileTarget:m}=e,h=c!==void 0&&c,g=p!==void 0&&p,_=n.worktreeId,v;t[0]===i?v=t[1]:(v=Hp(i),t[0]=i,t[1]=v);let y;t[2]!==h||t[3]!==m||t[4]!==n.worktreeId||t[5]!==g||t[6]!==v||t[7]!==u?(y={toolbarTarget:u,active:h,worktreeId:_,entry:v,fileTarget:m,singleHeader:g},t[2]=h,t[3]=m,t[4]=n.worktreeId,t[5]=g,t[6]=v,t[7]=u,t[8]=y):y=t[8];let b;t[9]!==l||t[10]!==r||t[11]!==o||t[12]!==a||t[13]!==n||t[14]!==s||t[15]!==y?(b={base:l,scope:n,context:r,onOpen:a,onBrowse:o,sideLabel:s,interaction:y},t[9]=l,t[10]=r,t[11]=o,t[12]=a,t[13]=n,t[14]=s,t[15]=y,t[16]=b):b=t[16];let x=b;switch(i.kind){case`handoff`:{let e;return t[17]===x?e=t[18]:(e=(0,Z.jsx)(xb,{...x}),t[17]=x,t[18]=e),e}case`walkthrough`:{let e;return t[19]!==d||t[20]!==x?(e=d?(0,Z.jsx)(d,{...x}):null,t[19]=d,t[20]=x,t[21]=e):e=t[21],e}case`all-changes`:{let e;return t[22]===x?e=t[23]:(e=(0,Z.jsx)(xb,{...x}),t[22]=x,t[23]=e),e}case`specs`:{let e;return t[24]===x?e=t[25]:(e=(0,Z.jsx)(xb,{...x,specsOnly:!0}),t[24]=x,t[25]=e),e}case`change`:{let e;return t[26]!==i.path||t[27]!==x?(e=(0,Z.jsx)(Cb,{...x,path:i.path}),t[26]=i.path,t[27]=x,t[28]=e):e=t[28],e}case`file`:{let e;return t[29]!==i.path||t[30]!==x?(e=(0,Z.jsx)(cy,{...x,path:i.path}),t[29]=i.path,t[30]=x,t[31]=e):e=t[31],e}case`commit`:{let e;return t[32]!==i.oid||t[33]!==x?(e=(0,Z.jsx)(Vv,{...x,oid:i.oid}),t[32]=i.oid,t[33]=x,t[34]=e):e=t[34],e}case`branch`:{let e;return t[35]===x?e=t[36]:(e=(0,Z.jsx)(jv,{...x}),t[35]=x,t[36]=e),e}case`branch-file`:{let e;return t[37]!==i.path||t[38]!==x?(e=(0,Z.jsx)(Mv,{...x,path:i.path}),t[37]=i.path,t[38]=x,t[39]=e):e=t[39],e}case`walkthrough-step`:case`walkthrough-changes`:{let e;return t[40]!==f||t[41]!==i||t[42]!==x?(e=f?(0,Z.jsx)(f,{...x,document:i}):null,t[40]=f,t[41]=i,t[42]=x,t[43]=e):e=t[43],e}case`timeline`:{let e;return t[44]!==i.path||t[45]!==x?(e=(0,Z.jsx)(yb,{...x,path:i.path}),t[44]=i.path,t[45]=x,t[46]=e):e=t[46],e}case`graph`:{let e;return t[47]===x?e=t[48]:(e=(0,Z.jsx)(vb,{...x}),t[47]=x,t[48]=e),e}case`pull-request`:{let e;return t[49]!==r||t[50]!==i||t[51]!==u?(e=(0,Z.jsx)(hb,{document:i,context:r,toolbarTarget:u}),t[49]=r,t[50]=i,t[51]=u,t[52]=e):e=t[52],e}}}function hb(e){let t=(0,$.c)(13),{document:n,context:r,toolbarTarget:i}=e,a=fe(),o=Bt(),s;t[0]!==r||t[1]!==n.environmentId||t[2]!==a||t[3]!==o?(s=n.environmentId===void 0?r.connection:[a.connection,...o.map(gb)].find(e=>e.environmentId===n.environmentId),t[0]=r,t[1]=n.environmentId,t[2]=a,t[3]=o,t[4]=s):s=t[4];let c=s;if(!c){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Rn,{title:`Computer not paired`,description:`Pair this pull request's computer in Settings to read it.`}),t[5]=e):e=t[5],e}let l;t[6]===c?l=t[7]:(l={connection:c},t[6]=c,t[7]=l);let u;return t[8]!==n||t[9]!==a.connection.environmentId||t[10]!==l||t[11]!==i?(u=(0,Z.jsx)(_b,{document:n,context:l,localEnvironmentId:a.connection.environmentId,toolbarTarget:i}),t[8]=n,t[9]=a.connection.environmentId,t[10]=l,t[11]=i,t[12]=u):u=t[12],u}function gb(e){return e.connection}function _b(e){let t=(0,$.c)(17),{document:n,context:r,localEnvironmentId:i,toolbarTarget:a}=e,o=Xe(),s=W_(r.connection,n.projectId,n.number),c;t[0]!==s||t[1]!==r.connection||t[2]!==i||t[3]!==o?(c=e=>{if(!s){o({to:`/`});return}let t=s,n={entry:Hp(e)};o(r.connection.environmentId===i?{to:`/$projectId/$worktreeId`,params:t,search:n}:{to:`/remotes/$environmentId/$projectId/$worktreeId`,params:{...t,environmentId:r.connection.environmentId},search:n})},t[0]=s,t[1]=r.connection,t[2]=i,t[3]=o,t[4]=c):c=t[4];let l=c,u;t[5]===l?u=t[6]:(u=()=>l({kind:`handoff`}),t[5]=l,t[6]=u);let d;t[7]!==s||t[8]!==l?(d=s?e=>l({kind:`file`,path:e}):void 0,t[7]=s,t[8]=l,t[9]=d):d=t[9];let f;return t[10]!==r||t[11]!==n.number||t[12]!==n.projectId||t[13]!==u||t[14]!==d||t[15]!==a?(f=(0,Z.jsx)(tb,{projectId:n.projectId,number:n.number,context:r,toolbarTarget:a,onBack:u,onFile:d}),t[10]=r,t[11]=n.number,t[12]=n.projectId,t[13]=u,t[14]=d,t[15]=a,t[16]=f):f=t[16],f}function vb(e){let t=(0,$.c)(7),{scope:n,context:r,onOpen:i,sideLabel:a}=e,o;t[0]===i?o=t[1]:(o=(e,t)=>i({kind:`commit`,oid:e},{toSide:t===!0}),t[0]=i,t[1]=o);let s;return t[2]!==r.connection||t[3]!==n||t[4]!==a||t[5]!==o?(s=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(Vh,{scope:n,connection:r.connection,sideLabel:a,onSelect:o})}),t[2]=r.connection,t[3]=n,t[4]=a,t[5]=o,t[6]=s):s=t[6],s}function yb(e){let t=(0,$.c)(17),{scope:n,context:r,path:i,onOpen:a,sideLabel:o}=e,s=`Timeline of ${i}`,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Ai,{className:`size-4 shrink-0`}),t[0]=c):c=t[0];let l;t[1]===i?l=t[2]:(l=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[c,(0,Z.jsx)(X,{text:i})]}),t[1]=i,t[2]=l);let u;t[3]!==s||t[4]!==l?(u=(0,Z.jsx)(bv,{titleLabel:s,title:l,subtitle:`Commits that changed this file`}),t[3]=s,t[4]=l,t[5]=u):u=t[5];let d;t[6]===a?d=t[7]:(d=(e,t)=>a({kind:`commit`,oid:e.oid},{path:e.path,toSide:t===!0}),t[6]=a,t[7]=d);let f;t[8]!==r.connection||t[9]!==i||t[10]!==n||t[11]!==o||t[12]!==d?(f=(0,Z.jsx)(Uh,{scope:n,connection:r.connection,path:i,sideLabel:o,onSelect:d}),t[8]=r.connection,t[9]=i,t[10]=n,t[11]=o,t[12]=d,t[13]=f):f=t[13];let p;return t[14]!==u||t[15]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[u,f]}),t[14]=u,t[15]=f,t[16]=p):p=t[16],p}function bb(e,t){return R(t,e?`uncommitted spec change`:`uncommitted change`)}function xb(e){let t=(0,$.c)(68),{scope:n,context:r,interaction:i,onBrowse:a,specsOnly:o,only:s,heading:c,fullHeight:l}=e,u=o!==void 0&&o,[d,f]=(0,Q.useState)(!1),{connection:p}=r;q_(n,r);let m=oi(n,p),h=J_(n,r,m),g;t[0]!==s||t[1]!==u?(g=e=>s?s.includes(e):!u||$l(e),t[0]=s,t[1]=u,t[2]=g):g=t[2];let _=g,v,y,b,x,S,C,w,T,E,D;if(t[3]!==d||t[4]!==h||t[5]!==r||t[6]!==l||t[7]!==c||t[8]!==_||t[9]!==i||t[10]!==m||t[11]!==a||t[12]!==s||t[13]!==n||t[14]!==u){D=Symbol.for(`react.early_return_sentinel`);bb0:{let e;if(t[25]===_?e=t[26]:(e=e=>_(e.path),t[25]=_,t[26]=e),y=h.filter(e),b=i.singleHeader||c!==void 0,!u&&y.length===0&&d&&f(!1),s&&y.length===0){let e;t[27]===c?e=t[28]:(e=c&&(0,Z.jsx)(bv,{inline:!0,title:c.title,titleLabel:c.titleLabel,children:c.after}),t[27]=c,t[28]=e);let n;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`p`,{className:`p-5 text-prose text-foreground-2`,children:`Nothing uncommitted in this step.`}),t[29]=n):n=t[29];let r;t[30]===e?r=t[31]:(r=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[e,n]}),t[30]=e,t[31]=r),D=r;break bb0}if(!u&&y.length===0){let e=m.branch?.name??`This worktree`,n;t[32]===e?n=t[33]:(n=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`font-mono text-foreground`,children:e}),` `,`matches its last commit. Browse files or history from the right.`]}),t[32]=e,t[33]=n);let r;t[34]===a?r=t[35]:(r=e=>a(`files`,e.currentTarget),t[34]=a,t[35]=r);let i;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Jn,{children:ko(vo.surfaceFiles)}),t[36]=i):i=t[36];let o;t[37]===r?o=t[38]:(o=(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:r,children:[`Files `,i]}),t[37]=r,t[38]=o);let s;t[39]===a?s=t[40]:(s=e=>a(`history`,e.currentTarget),t[39]=a,t[40]=s);let c;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Jn,{children:ko(vo.surfaceHistory)}),t[41]=c):c=t[41];let l;t[42]===s?l=t[43]:(l=(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:s,children:[`History `,c]}),t[42]=s,t[43]=l);let u;t[44]!==n||t[45]!==o||t[46]!==l?(u=(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-xl`,children:(0,Z.jsxs)(Rn,{title:`No changes to review`,description:n,children:[o,l]})}),t[44]=n,t[45]=o,t[46]=l,t[47]=u):u=t[47],D=u;break bb0}E=`flex min-h-0 flex-1 flex-col`,v=Sy,x=l,S=n,C=r,w=i,T=u||s?{paths:y.map(Sb)}:{}}t[3]=d,t[4]=h,t[5]=r,t[6]=l,t[7]=c,t[8]=_,t[9]=i,t[10]=m,t[11]=a,t[12]=s,t[13]=n,t[14]=u,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S,t[20]=C,t[21]=w,t[22]=T,t[23]=E,t[24]=D}else v=t[15],y=t[16],b=t[17],x=t[18],S=t[19],C=t[20],w=t[21],T=t[22],E=t[23],D=t[24];if(D!==Symbol.for(`react.early_return_sentinel`))return D;let O=!b,k;t[48]!==d||t[49]!==y||t[50]!==r||t[51]!==c||t[52]!==n||t[53]!==b||t[54]!==u?(k=b?{toolbar:e=>(0,Z.jsxs)(bv,{inline:!0,...c?{title:c.title,titleLabel:c.titleLabel}:{title:`All changes`},subtitle:bb(u,y.length),children:[e,c?.after]})}:{header:e=>(0,Z.jsx)(`div`,{className:`pt-6`,children:(0,Z.jsx)(Qv,{scope:n,context:r,label:bb(u,y.length),items:y,controls:e,actionsOpen:d,onActionsOpenChange:f,actions:(0,Z.jsx)(Tv,{scope:n,context:r,entries:y})})})},t[48]=d,t[49]=y,t[50]=r,t[51]=c,t[52]=n,t[53]=b,t[54]=u,t[55]=k):k=t[55];let A;t[56]!==v||t[57]!==O||t[58]!==k||t[59]!==x||t[60]!==S||t[61]!==C||t[62]!==w||t[63]!==T?(A=(0,Z.jsx)(v,{fullHeight:x,scope:S,context:C,interaction:w,...T,column:O,...k}),t[56]=v,t[57]=O,t[58]=k,t[59]=x,t[60]=S,t[61]=C,t[62]=w,t[63]=T,t[64]=A):A=t[64];let j;return t[65]!==A||t[66]!==E?(j=(0,Z.jsx)(`div`,{className:E,children:A}),t[65]=A,t[66]=E,t[67]=j):j=t[67],j}function Sb(e){return e.path}function Cb(e){let t=(0,$.c)(14),{scope:n,context:r,interaction:i,onOpen:a,path:o}=e,{connection:s}=r;q_(n,r);let c=oi(n,s),l;if(t[0]===o?l=t[1]:(l=[o],t[0]=o,t[1]=l),!J_(n,r,c,l).find(e=>e.path===o)){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Rn,{title:`Change no longer present`,description:`Choose a change that is still present in the current review.`}),t[2]=e):e=t[2],e}let u;t[3]!==r||t[4]!==i||t[5]!==a||t[6]!==o||t[7]!==n?(u=e=>(0,Z.jsx)(Sy,{headerActions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G_,{label:`Timeline`,iconOnly:!0,icon:Ai,onClick:()=>a({kind:`timeline`,path:o})}),i.singleHeader&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G_,{label:`Open file`,iconOnly:!0,icon:oc,onClick:()=>a({kind:`file`,path:o})}),e]})]}),headerLeading:i.singleHeader?void 0:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Y,{variant:`ghost`,size:`xs`,"aria-label":`Open file`,onClick:()=>a({kind:`file`,path:o}),children:[(0,Z.jsx)(oc,{}),(0,Z.jsx)(`span`,{className:`max-narrow:sr-only`,children:`Open file`})]}),e]}),scope:n,context:r,interaction:i,paths:[o]}),t[3]=r,t[4]=i,t[5]=a,t[6]=o,t[7]=n,t[8]=u):u=t[8];let d;return t[9]!==r||t[10]!==o||t[11]!==n||t[12]!==u?(d=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(wm,{scope:n,context:r,path:o,variant:`quiet`,children:u})}),t[9]=r,t[10]=o,t[11]=n,t[12]=u,t[13]=d):d=t[13],d}var wb=[{value:`uncommitted`,label:`Uncommitted`,Icon:br},{value:`branch`,label:`Branch`,Icon:mr}];function Tb(e){let t=(0,$.c)(6),{value:n,onValueChange:r}=e,i;t[0]===r?i=t[1]:(i=e=>{Ei(e)&&r(e)},t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(ws,{"aria-label":`Compare`,children:wb.map(Eb)}),t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==n?(o=(0,Z.jsx)(Es,{className:`shrink-0`,value:n,onValueChange:i,children:a}),t[3]=i,t[4]=n,t[5]=o):o=t[5],o}function Eb(e){let{value:t,label:n,Icon:r}=e;return(0,Z.jsxs)(wn,{children:[(0,Z.jsxs)(nn,{render:(0,Z.jsx)(uo,{value:t,"aria-label":n}),children:[(0,Z.jsx)(r,{className:`@min-3xl/pane:hidden`}),(0,Z.jsx)(`span`,{className:`hidden whitespace-nowrap @min-3xl/pane:inline`,children:n})]}),(0,Z.jsx)(yt,{children:n})]},t)}function Db(e){let t=(0,$.c)(80),{scope:n,connection:r,base:i,onBase:a,compact:o}=e,s=o!==void 0&&o,[c,l]=(0,Q.useState)(!1),u=mi(n,r,c),d=Li(n,r,i),f,p,m,h,g,_,v,y,b,x,S,C,w,T,E;if(t[0]!==i||t[1]!==u.refresh||t[2]!==u.result||t[3]!==s||t[4]!==d.result||t[5]!==a||t[6]!==c){let e=Nt(bt(u.result)),n;t[22]===d.result?n=t[23]:(n=Nt(bt(d.result)),t[22]=d.result,t[23]=n);let r=i??n?.base?.ref,o;t[24]===r?o=t[25]:(o=r===void 0?`the default branch`:jp(r),t[24]=r,t[25]=o);let D=o,O=e?.defaultRef??null,k=i??O,A=[{heading:`Local`,entries:e?.bases.filter(Ab)??[]},{heading:`Remote`,entries:e?.bases.filter(kb)??[]}].filter(Ob),j=e=>{a(e===O?void 0:e),l(!1)};h=qt,g=c,_=l;let M=s?`max-w-24 @min-3xl/pane:max-w-40`:`w-full`,N;t[26]===M?N=t[27]:(N=q(`justify-between`,M),t[26]=M,t[27]=N);let P=`Compare against ${D}`,F;t[28]!==N||t[29]!==P?(F=(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,className:N,"aria-label":P,title:`Choose the branch this one is compared against`}),t[28]=N,t[29]=P,t[30]=F):F=t[30];let I=s&&`hidden @min-3xl/pane:block`,L;t[31]===I?L=t[32]:(L=q(`size-3.5 shrink-0 text-muted-foreground`,I),t[31]=I,t[32]=L);let R;t[33]===L?R=t[34]:(R=(0,Z.jsx)(mr,{className:L}),t[33]=L,t[34]=R);let z=`Against ${D}`,B=s&&`hidden @min-3xl/pane:inline`,V;t[35]===B?V=t[36]:(V=q(`text-muted-foreground`,B),t[35]=B,t[36]=V);let H;t[37]===V?H=t[38]:(H=(0,Z.jsxs)(`span`,{className:V,children:[`Against`,` `]}),t[37]=V,t[38]=H);let U;t[39]!==D||t[40]!==z||t[41]!==H?(U=(0,Z.jsxs)(X,{text:z,children:[H,D]}),t[39]=D,t[40]=z,t[41]=H,t[42]=U):U=t[42];let W;t[43]!==R||t[44]!==U?(W=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[R,U]}),t[43]=R,t[44]=U,t[45]=W):W=t[45];let G;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)(Qs,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[46]=G):G=t[46],t[47]!==F||t[48]!==W?(v=(0,Z.jsxs)(_n,{render:F,children:[W,G]}),t[47]=F,t[48]=W,t[49]=v):v=t[49],m=pn,T=`start`,E=`w-72`,p=zr,t[50]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(Hr,{"aria-label":`Find a base branch`,placeholder:`Find a branch`}),t[50]=w):w=t[50],f=er,y=`Base branches`,t[51]===u.result?b=t[52]:(b=vn(u.result)&&(0,Z.jsx)(`p`,{role:`status`,className:`p-3 text-xs text-muted-foreground`,children:`Reading branches…`}),t[51]=u.result,t[52]=b),t[53]!==u.refresh||t[54]!==u.result?(x=Qt(u.result)&&(0,Z.jsxs)(`div`,{className:`p-3 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`block`,children:`The branches could not be read.`}),(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,className:`mt-2`,onClick:u.refresh,children:`Try again`})]}),t[53]=u.refresh,t[54]=u.result,t[55]=x):x=t[55],t[56]===u.result?S=t[57]:(S=gt(u.result)&&(0,Z.jsx)(Zn,{children:`No branch matches.`}),t[56]=u.result,t[57]=S),C=A.map(e=>(0,Z.jsx)(sa,{heading:e.heading,children:e.entries.map(e=>(0,Z.jsxs)(rr,{value:e.name,"data-checked":e.ref===k,onSelect:()=>j(e.ref),children:[(0,Z.jsx)(X,{text:e.name}),e.ref===O&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`default`})]},e.ref))},e.heading)),t[0]=i,t[1]=u.refresh,t[2]=u.result,t[3]=s,t[4]=d.result,t[5]=a,t[6]=c,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S,t[18]=C,t[19]=w,t[20]=T,t[21]=E}else f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12],v=t[13],y=t[14],b=t[15],x=t[16],S=t[17],C=t[18],w=t[19],T=t[20],E=t[21];let D;t[58]!==f||t[59]!==y||t[60]!==b||t[61]!==x||t[62]!==S||t[63]!==C?(D=(0,Z.jsxs)(f,{"aria-label":y,children:[b,x,S,C]}),t[58]=f,t[59]=y,t[60]=b,t[61]=x,t[62]=S,t[63]=C,t[64]=D):D=t[64];let O;t[65]!==p||t[66]!==D||t[67]!==w?(O=(0,Z.jsxs)(p,{children:[w,D]}),t[65]=p,t[66]=D,t[67]=w,t[68]=O):O=t[68];let k;t[69]!==m||t[70]!==O||t[71]!==T||t[72]!==E?(k=(0,Z.jsx)(m,{align:T,className:E,children:O}),t[69]=m,t[70]=O,t[71]=T,t[72]=E,t[73]=k):k=t[73];let A;return t[74]!==h||t[75]!==g||t[76]!==_||t[77]!==v||t[78]!==k?(A=(0,Z.jsxs)(h,{open:g,onOpenChange:_,children:[v,k]}),t[74]=h,t[75]=g,t[76]=_,t[77]=v,t[78]=k,t[79]=A):A=t[79],A}function Ob(e){return e.entries.length>0}function kb(e){return e.remote}function Ab(e){return!e.remote}function jb(e,t){let n=(0,$.c)(6),r;n[0]===e?r=n[1]:(r=b(e),n[0]=e,n[1]=r);let i;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={mode:`promiseExit`},n[2]=i):i=n[2];let a=c(r,i),o;return n[3]!==a||n[4]!==t?(o=e=>{a(t).then(t=>{yn(t)&&e()})},n[3]=a,n[4]=t,n[5]=o):o=n[5],o}var Mb=class extends Q.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}render(){return this.state.error?(0,Z.jsx)(Ce,{description:ca(this.state.error),onRetry:()=>this.props.reset(()=>this.setState({error:null}))}):this.props.children}};function Nb(e){let t=(0,$.c)(9),{children:n,connection:r,scope:i,loadingLabel:a,documentKey:s}=e,c=a===void 0?`Loading review`:a,l=jb(r,i),u;t[0]===c?u=t[1]:(u=(0,Z.jsx)(o,{label:c}),t[0]=c,t[1]=u);let d;t[2]!==n||t[3]!==s||t[4]!==l?(d=(0,Z.jsx)(Mb,{reset:l,children:n},s),t[2]=n,t[3]=s,t[4]=l,t[5]=d):d=t[5];let f;return t[6]!==u||t[7]!==d?(f=(0,Z.jsx)(Q.Suspense,{fallback:u,children:d}),t[6]=u,t[7]=d,t[8]=f):f=t[8],f}function Pb(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({layout:n,onSurface:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=Lb(),t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=e=>(0,Z.jsx)(zb,{...i,actionsTarget:e}),t[5]=i,t[6]=o);let s;return t[7]!==n||t[8]!==r||t[9]!==i.surface||t[10]!==o?(s=(0,Z.jsx)(Fb,{layout:n,surfaces:Ib,names:a,published:!1,surface:i.surface,onSurface:r,children:o}),t[7]=n,t[8]=r,t[9]=i.surface,t[10]=o,t[11]=s):s=t[11],s}function Fb(e){let t=(0,$.c)(19),{layout:n,surfaces:r,names:i,published:a,surface:o,onSurface:s,children:c}=e,{element:l,attach:u}=ma(),d;t[0]===u?d=t[1]:(d=(0,Z.jsx)(`div`,{ref:u,className:`ml-auto flex shrink-0 items-center gap-0.5`}),t[0]=u,t[1]=d);let f=d,p;t[2]!==l||t[3]!==c?(p=c(l),t[2]=l,t[3]=c,t[4]=p):p=t[4];let m=p,h=n===`docked`&&`motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-right-1 duration-150`,g;t[5]===h?g=t[6]:(g=q(`flex h-full min-h-0 flex-col overflow-hidden rounded-paper bg-card shadow-paper`,h),t[5]=h,t[6]=g);let _;t[7]!==m||t[8]!==n||t[9]!==i||t[10]!==s||t[11]!==a||t[12]!==o||t[13]!==r||t[14]!==f?(_=n===`docked`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-1 border-b pr-2.5 pl-4`,children:[(0,Z.jsx)(X,{className:`text-ui leading-5 font-semibold`,render:(0,Z.jsx)(`h2`,{}),text:i[o]}),f]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 text-sm`,children:m})]}):(0,Z.jsxs)(Es,{value:o,onValueChange:e=>{si(e)&&s(e)},className:`min-h-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-1 border-b px-1.5`,children:[(0,Z.jsx)(ws,{className:`h-8 min-w-0 flex-1`,children:r.map(e=>(0,Z.jsx)(X,{propagateEscape:!0,text:i[e],renderTrigger:t=>(0,Z.jsxs)(uo,{value:e,className:`min-w-0`,children:[(0,Z.jsx)(Rb,{published:a,surface:e,className:`size-3.5 shrink-0`}),t]})},e))}),f]}),(0,Z.jsx)(Mo,{value:o,className:`min-h-0 overflow-hidden`,children:m})]}),t[7]=m,t[8]=n,t[9]=i,t[10]=s,t[11]=a,t[12]=o,t[13]=r,t[14]=f,t[15]=_):_=t[15];let v;return t[16]!==g||t[17]!==_?(v=(0,Z.jsx)(`aside`,{"aria-label":`Review sidebar`,"data-testid":`review-sidebar`,className:g,children:_}),t[16]=g,t[17]=_,t[18]=v):v=t[18],v}var Ib=[`files`,`changes`,`history`];function Lb(){return Gp}function Rb(e){let t=(0,$.c)(7),{published:n,surface:r,className:i}=e;if(r===`files`){let e;return t[0]===i?e=t[1]:(e=(0,Z.jsx)(cc,{className:i}),t[0]=i,t[1]=e),e}if(r===`history`){let e;return t[2]===i?e=t[3]:(e=(0,Z.jsx)(Ai,{className:i}),t[2]=i,t[3]=e),e}let a;return t[4]!==i||t[5]!==n?(a=n?(0,Z.jsx)(wc,{className:i}):(0,Z.jsx)(br,{className:i}),t[4]=i,t[5]=n,t[6]=a):a=t[6],a}function zb(e){let t=(0,$.c)(38),{changesNavigation:n,guided:r,scope:i,context:a,worktreePath:o,surface:s,activeEntry:c,available:l,onOpen:u,sideLabel:d,changes:f,actionsTarget:p}=e;if(!l){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`div`,{className:`p-3`,children:(0,Z.jsx)(Rn,{title:`Worktree unavailable`,description:`Restore the checkout and return to Porcelain to browse its files and Git state.`})}),t[0]=e):e=t[0],e}let m=s===`files`?`Loading files`:`Loading review`,h=`${i.worktreeId}:${s}`,g;t[1]!==n||t[2]!==c||t[3]!==f||t[4]!==a||t[5]!==r||t[6]!==u||t[7]!==i||t[8]!==d||t[9]!==s?(g=s===`changes`&&(0,Z.jsx)(n,{scope:i,context:a,activeEntry:c,onOpen:u,sideLabel:d,changeScope:f.scope,base:f.base,onChangeScope:f.onScope,onBase:f.onBase,allChanges:r?Rp:{kind:`handoff`}}),t[1]=n,t[2]=c,t[3]=f,t[4]=a,t[5]=r,t[6]=u,t[7]=i,t[8]=d,t[9]=s,t[10]=g):g=t[10];let _;t[11]!==p||t[12]!==c||t[13]!==a.connection||t[14]!==u||t[15]!==i||t[16]!==d||t[17]!==s||t[18]!==o?(_=s===`files`&&(0,Z.jsx)(ta,{scope:i,connection:a.connection,worktreePath:o,selected:c?.startsWith(`file:`)?c.slice(5):``,onOpen:u,sideLabel:d,actionsTarget:p}),t[11]=p,t[12]=c,t[13]=a.connection,t[14]=u,t[15]=i,t[16]=d,t[17]=s,t[18]=o,t[19]=_):_=t[19];let v;t[20]!==c||t[21]!==a.connection||t[22]!==u||t[23]!==i||t[24]!==d||t[25]!==s?(v=s===`history`&&(0,Z.jsx)(Lh,{scope:i,connection:a.connection,selected:c?.startsWith(`commit:`)?c.slice(7):``,onSelect:(e,t)=>u({kind:`commit`,oid:e},{toSide:t===!0,preserveFocus:!0}),sideLabel:d,onOpenGraph:()=>u({kind:`graph`}),onOpenChanges:()=>u(Rp)}),t[20]=c,t[21]=a.connection,t[22]=u,t[23]=i,t[24]=d,t[25]=s,t[26]=v):v=t[26];let y;t[27]!==a.connection||t[28]!==i||t[29]!==m||t[30]!==h||t[31]!==g||t[32]!==_||t[33]!==v?(y=(0,Z.jsxs)(Nb,{connection:a.connection,scope:i,loadingLabel:m,children:[g,_,v]},h),t[27]=a.connection,t[28]=i,t[29]=m,t[30]=h,t[31]=g,t[32]=_,t[33]=v,t[34]=y):y=t[34];let b=y,x;return t[35]!==b||t[36]!==s?(x=s===`changes`?(0,Z.jsx)(ei,{className:`h-full`,children:b}):(0,Z.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:b}),t[35]=b,t[36]=s,t[37]=x):x=t[37],x}var Bb={files:vo.surfaceFiles,changes:vo.surfaceChanges,history:vo.surfaceHistory};function Vb(e){let t=(0,$.c)(32),{surfaces:n,names:r,published:i,surface:a,open:o,onSelect:s,onHide:c,onToggle:l,toggleRef:u}=e,d=o?`Hide side panel`:`Show side panel`,f;if(t[0]!==r||t[1]!==c||t[2]!==s||t[3]!==o||t[4]!==i||t[5]!==a||t[6]!==n){let e;t[8]!==r||t[9]!==c||t[10]!==s||t[11]!==o||t[12]!==i||t[13]!==a?(e=e=>{let t=o&&a===e;return(0,Z.jsx)(`span`,{"data-selected":t||void 0,className:`workspace-choice inline-flex rounded-lg data-selected:text-foreground`,children:(0,Z.jsxs)(wn,{children:[(0,Z.jsx)(nn,{render:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":r[e],"aria-pressed":t,"aria-keyshortcuts":Bb[e],onClick:()=>t?c():s(e)}),children:(0,Z.jsx)(Rb,{published:i,surface:e})}),(0,Z.jsxs)(yt,{side:`left`,children:[r[e],` `,(0,Z.jsx)(Jn,{children:ko(Bb[e])})]})]})},e)},t[8]=r,t[9]=c,t[10]=s,t[11]=o,t[12]=i,t[13]=a,t[14]=e):e=t[14],f=n.map(e),t[0]=r,t[1]=c,t[2]=s,t[3]=o,t[4]=i,t[5]=a,t[6]=n,t[7]=f}else f=t[7];let p;t[15]!==l||t[16]!==o||t[17]!==d||t[18]!==u?(p=(0,Z.jsx)(Y,{ref:u,variant:`ghost`,size:`icon`,className:`mt-auto`,"aria-label":d,"aria-expanded":o,"aria-keyshortcuts":vo.toggleSidebar,onClick:l}),t[15]=l,t[16]=o,t[17]=d,t[18]=u,t[19]=p):p=t[19];let m;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(Oc,{}),t[20]=m):m=t[20];let h;t[21]===p?h=t[22]:(h=(0,Z.jsx)(nn,{render:p,children:m}),t[21]=p,t[22]=h);let g;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(Jn,{children:ko(vo.toggleSidebar)}),t[23]=g):g=t[23];let _;t[24]===d?_=t[25]:(_=(0,Z.jsxs)(yt,{side:`left`,children:[d,` `,g]}),t[24]=d,t[25]=_);let v;t[26]!==h||t[27]!==_?(v=(0,Z.jsxs)(wn,{children:[h,_]}),t[26]=h,t[27]=_,t[28]=v):v=t[28];let y;return t[29]!==f||t[30]!==v?(y=(0,Z.jsxs)(`nav`,{"aria-label":`Side panel`,className:`flex w-11 shrink-0 flex-col items-center gap-1 pt-2.5 pb-2 pl-1 text-muted-foreground`,children:[f,v]}),t[29]=f,t[30]=v,t[31]=y):y=t[31],y}function Hb(e){let t=(0,$.c)(177),{worktree:n,projectId:r,search:i,onSearch:a,context:o,navigationTrigger:s,walkthrough:c,changesNavigation:l,walkthroughCode:u,firstDocument:d}=e,{open:f,setOpen:p}=E_(),[m,h]=(0,Q.useState)(!1),g=Ug(),[_,v]=(0,Q.useState)(g);_!==g&&(v(g),g&&m&&(p(!0),h(!1)));let y=ma(),b=ma(),x=ma(),{isMobile:S,open:C,openMobile:w}=Ot(),T=i.surface??(d.guided?`changes`:`files`),E;t[0]!==r||t[1]!==n.id?(E={projectId:r,worktreeId:n.id},t[0]=r,t[1]=n.id,t[2]=E):E=t[2];let D=E,{saved:O,focused:k,setFocused:A}=y_(n.id),j=oa(D,o.connection),M=Li(D,o.connection,i.base).result,N=Nt(bt(M))?.files.length===0&&(Nt(bt(j))?.changes.length??0)>0,P;t[3]===j?P=t[4]:(P=kt(bt(j)),t[3]=j,t[4]=P);let F=P,I;t[5]!==O||t[6]!==i.entry||t[7]!==i.side?(I=!O&&!Up(i.entry)&&!Up(i.side),t[5]=O,t[6]=i.entry,t[7]=i.side,t[8]=I):I=t[8];let L=I,R=!L||!F&&!d.pending,z=d.title===`Walkthrough`?`walkthrough`:`handoff`,B=d.title===`Walkthrough`||(Nt(bt(j))?.changes.length??0)>0?z:null,V=m&&!g,H;t[9]!==B||t[10]!==d.companion||t[11]!==z||t[12]!==k||t[13]!==x.element||t[14]!==a||t[15]!==R||t[16]!==i.entry||t[17]!==i.side||t[18]!==A||t[19]!==V||t[20]!==n.id?(H={firstDocument:z,companion:d.companion,worktreeId:n.id,entry:i.entry,side:i.side,onSearch:a,fallback:B,focused:k,setFocused:A,ready:R,focusBoundary:x.element,focusBoundaryOpen:V},t[9]=B,t[10]=d.companion,t[11]=z,t[12]=k,t[13]=x.element,t[14]=a,t[15]=R,t[16]=i.entry,t[17]=i.side,t[18]=A,t[19]=V,t[20]=n.id,t[21]=H):H=t[21];let U=A_(H),W;t[22]!==k||t[23]!==U.split?(W=i_(qb(U.split,k)),t[22]=k,t[23]=U.split,t[24]=W):W=t[24];let G=W,ee;t[25]!==f||t[26]!==y||t[27]!==p?(ee=()=>{f&&y.element?.focus(),p(Wb)},t[25]=f,t[26]=y,t[27]=p,t[28]=ee):ee=t[28];let te=ee,ne;t[29]!==g||t[30]!==te?(ne=()=>{g?te():h(Ub)},t[29]=g,t[30]=te,t[31]=ne):ne=t[31];let re;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(re={ignoreInputs:!0},t[32]=re):re=t[32],So(vo.toggleSidebar,ne,re);let[ie,ae]=(0,Q.useState)(),K;t[33]!==g||t[34]!==k||t[35]!==U?(K=(e,t)=>{let n=Hp(e),r=+(k===0),i=t?.toSide?r:U.open(k,n,t?.preserveFocus===!0&&g);ae(t?.path?{path:t.path,nonce:Date.now(),pane:i,key:n}:void 0),t?.toSide&&U.openToSide(k,n),h(!1)},t[33]=g,t[34]=k,t[35]=U,t[36]=K):K=t[36];let oe=K,q;t[37]===a?q=t[38]:(q=e=>{a({surface:e})},t[37]=a,t[38]=q);let se=q,ce;t[39]!==g||t[40]!==p||t[41]!==se?(ce=e=>{se(e),g?p(!0):h(!0)},t[39]=g,t[40]=p,t[41]=se,t[42]=ce):ce=t[42];let le=ce,ue;t[43]===le?ue=t[44]:(ue=()=>le(`changes`),t[43]=le,t[44]=ue);let de;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(de={ignoreInputs:!0},t[45]=de):de=t[45],So(vo.surfaceChanges,ue,de);let J;t[46]===le?J=t[47]:(J=()=>le(`files`),t[46]=le,t[47]=J);let fe;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(fe={ignoreInputs:!0},t[48]=fe):fe=t[48],So(vo.surfaceFiles,J,fe);let pe;t[49]===le?pe=t[50]:(pe=()=>le(`history`),t[49]=le,t[50]=pe);let me;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(me={ignoreInputs:!0},t[51]=me):me=t[51],So(vo.surfaceHistory,pe,me);let he=ma(),ge;t[52]!==he||t[53]!==le?(ge=(e,t)=>{he.attach(t),le(e)},t[52]=he,t[53]=le,t[54]=ge):ge=t[54];let _e=ge,ve=i.scope??(d.guided&&!N?`branch`:`uncommitted`),ye,be;t[55]===a?(ye=t[56],be=t[57]):(ye=e=>a({scope:e}),be=e=>a({base:e}),t[55]=a,t[56]=ye,t[57]=be);let xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae,je,Me,Ne;if(t[58]!==_e||t[59]!==he||t[60]!==l||t[61]!==o||t[62]!==g||t[63]!==ie||t[64]!==d||t[65]!==k||t[66]!==U||t[67]!==m||t[68]!==x||t[69]!==b||t[70]!==s||t[71]!==S||t[72]!==C||t[73]!==w||t[74]!==L||t[75]!==a||t[76]!==oe||t[77]!==j||t[78]!==f||t[79]!==y||t[80]!==D||t[81]!==i.base||t[82]!==p||t[83]!==se||t[84]!==le||t[85]!==G||t[86]!==T||t[87]!==ve||t[88]!==ye||t[89]!==be||t[90]!==te||t[91]!==c||t[92]!==u||t[93]!==n.available||t[94]!==n.path){let e={scope:ve,onScope:ye,onBase:be},r=U.panes[k]?.active??void 0,_=t=>(0,Z.jsx)(Pb,{changesNavigation:l,guided:d.title===`Walkthrough`,layout:t,scope:D,context:o,worktreePath:n.path,surface:T,activeEntry:r,available:n.available,onSurface:se,onOpen:oe,sideLabel:G,changes:{...e,base:i.base,onBase:e=>a({base:e})}}),v;t[108]!==he||t[109]!==o||t[110]!==g||t[111]!==U||t[112]!==m||t[113]!==b||t[114]!==D?(v=e=>(0,Z.jsxs)(`div`,{"data-review-controls":``,className:`contents`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-5 w-px bg-border`}),(0,Z.jsx)(Ig,{scope:D,context:o}),(0,Z.jsxs)(wn,{children:[(0,Z.jsx)(nn,{render:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,ref:e=>b.attach(e),className:`xl:hidden`,"aria-label":`Review`,"aria-haspopup":`dialog`,"aria-expanded":m&&!g,"aria-keyshortcuts":vo.toggleSidebar,onClick:()=>{he.attach(null),U.selectPane(e),h(!0)},children:(0,Z.jsx)(Oc,{})})}),(0,Z.jsxs)(yt,{role:`tooltip`,className:`break-all`,children:[`Review `,(0,Z.jsx)(Jn,{children:ko(vo.toggleSidebar)})]})]})]}),t[108]=he,t[109]=o,t[110]=g,t[111]=U,t[112]=m,t[113]=b,t[114]=D,t[115]=v):v=t[115];let E=v,O;t[116]===oe?O=t[117]:(O=e=>oe({kind:`file`,path:e}),t[116]=oe,t[117]=O),t[118]!==o.connection||t[119]!==U.bindQuickOpen||t[120]!==U.recentFiles||t[121]!==D||t[122]!==O?(Me=(0,Z.jsx)(Fi,{bindPopup:U.bindQuickOpen,openFiles:U.recentFiles,scope:D,connection:o.connection,onOpen:O}),t[118]=o.connection,t[119]=U.bindQuickOpen,t[120]=U.recentFiles,t[121]=D,t[122]=O,t[123]=Me):Me=t[123];let A=S?0:480,M;t[124]!==o||t[125]!==D?(M=(0,Z.jsx)(am,{scope:D,context:o}),t[124]=o,t[125]=D,t[126]=M):M=t[126];let N;t[127]!==o||t[128]!==oe||t[129]!==D?(N=(0,Z.jsx)(om,{scope:D,context:o,onOpen:oe}),t[127]=o,t[128]=oe,t[129]=D,t[130]=N):N=t[130];let P=(0,Z.jsxs)(`section`,{"aria-label":`Review content`,className:`flex h-full min-w-0 flex-col overflow-hidden rounded-paper border bg-card`,children:[M,N,(0,Z.jsx)(Gb,{walkthrough:c,walkthroughCode:u,firstDocument:d,changesNavigation:l,fileTarget:ie,scope:D,context:o,overview:j,needsDefault:L,layout:U,base:i.base,changes:e,focused:k,onOpen:oe,onBrowse:_e,navigationTrigger:s,navigatorIsMobile:S,navigatorOpen:C,navigatorOpenMobile:w,tabControls:E})]}),F;t[131]!==A||t[132]!==P?(F=(0,Z.jsx)(ii,{id:`review-document`,minSize:A,children:P}),t[131]=A,t[132]=P,t[133]=F):F=t[133];let I=f&&g&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(xi,{"aria-label":`Document panes and side panel`,className:`w-2 bg-transparent after:w-2`}),(0,Z.jsx)(ii,{id:`review-sidebar`,defaultSize:320,minSize:260,maxSize:520,children:_(`docked`)})]}),R;t[134]!==F||t[135]!==I?(R=(0,Z.jsxs)(ia,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[F,I]}),t[134]=F,t[135]=I,t[136]=R):R=t[136];let z;t[137]!==g||t[138]!==f||t[139]!==y||t[140]!==p||t[141]!==le||t[142]!==T||t[143]!==te?(z=g&&(0,Z.jsx)(Vb,{surfaces:Ib,names:Lb(),published:!1,surface:T,open:f,onSelect:le,onHide:()=>p(!1),onToggle:te,toggleRef:e=>y.attach(e)}),t[137]=g,t[138]=f,t[139]=y,t[140]=p,t[141]=le,t[142]=T,t[143]=te,t[144]=z):z=t[144],t[145]!==R||t[146]!==z?(Ne=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[R,z]}),t[145]=R,t[146]=z,t[147]=Ne):Ne=t[147],Se=rt,ke=m&&!g,Ae=h,t[148]===U?je=t[149]:(je=e=>{e||U.focusDestination()},t[148]=U,t[149]=je),xe=On,t[150]!==U||t[151]!==x?(Ce=e=>{x.attach(e),e===null&&U.focusDestination()},t[150]=U,t[151]=x,t[152]=Ce):Ce=t[152],t[153]!==he.element||t[154]!==U||t[155]!==x.element||t[156]!==b.element?(we=()=>{if(U.hasDestinationFocus())return!1;let e=document.activeElement;return e===document.body||x.element?.contains(e)?he.element?.isConnected?he.element:b.element:!1},t[153]=he.element,t[154]=U,t[155]=x.element,t[156]=b.element,t[157]=we):we=t[157],Te=`w-[min(90vw,22rem)]!`,Ee=!1,t[158]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,Z.jsxs)(ut,{className:`sr-only`,children:[(0,Z.jsx)(Mn,{children:`Worktree review`}),(0,Z.jsx)(Pn,{children:`Choose a review surface and open a document.`})]}),t[158]=De):De=t[158],Oe=!g&&_(`sheet`),t[58]=_e,t[59]=he,t[60]=l,t[61]=o,t[62]=g,t[63]=ie,t[64]=d,t[65]=k,t[66]=U,t[67]=m,t[68]=x,t[69]=b,t[70]=s,t[71]=S,t[72]=C,t[73]=w,t[74]=L,t[75]=a,t[76]=oe,t[77]=j,t[78]=f,t[79]=y,t[80]=D,t[81]=i.base,t[82]=p,t[83]=se,t[84]=le,t[85]=G,t[86]=T,t[87]=ve,t[88]=ye,t[89]=be,t[90]=te,t[91]=c,t[92]=u,t[93]=n.available,t[94]=n.path,t[95]=xe,t[96]=Se,t[97]=Ce,t[98]=we,t[99]=Te,t[100]=Ee,t[101]=De,t[102]=Oe,t[103]=ke,t[104]=Ae,t[105]=je,t[106]=Me,t[107]=Ne}else xe=t[95],Se=t[96],Ce=t[97],we=t[98],Te=t[99],Ee=t[100],De=t[101],Oe=t[102],ke=t[103],Ae=t[104],je=t[105],Me=t[106],Ne=t[107];let Pe;t[159]!==xe||t[160]!==Ce||t[161]!==we||t[162]!==Te||t[163]!==Ee||t[164]!==De||t[165]!==Oe?(Pe=(0,Z.jsxs)(xe,{ref:Ce,finalFocus:we,className:Te,showCloseButton:Ee,children:[De,Oe]}),t[159]=xe,t[160]=Ce,t[161]=we,t[162]=Te,t[163]=Ee,t[164]=De,t[165]=Oe,t[166]=Pe):Pe=t[166];let Fe;t[167]!==Se||t[168]!==ke||t[169]!==Ae||t[170]!==je||t[171]!==Pe?(Fe=(0,Z.jsx)(Se,{open:ke,onOpenChange:Ae,onOpenChangeComplete:je,children:Pe}),t[167]=Se,t[168]=ke,t[169]=Ae,t[170]=je,t[171]=Pe,t[172]=Fe):Fe=t[172];let Ie;return t[173]!==Me||t[174]!==Ne||t[175]!==Fe?(Ie=(0,Z.jsxs)(Z.Fragment,{children:[Me,Ne,Fe]}),t[173]=Me,t[174]=Ne,t[175]=Fe,t[176]=Ie):Ie=t[176],Ie}function Ub(e){return!e}function Wb(e){return!e}function Gb(e){let t=(0,$.c)(3),n=kt(bt(e.overview));if(e.needsDefault&&n&&Qt(e.overview))throw En(e.overview.cause);if(e.needsDefault&&(n||e.firstDocument.pending)){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(o,{label:`Loading review`}),t[0]=e):e=t[0],e}let r;return t[1]===e?r=t[2]:(r=(0,Z.jsx)(Kb,{...e}),t[1]=e,t[2]=r),r}function Kb(e){let t=(0,$.c)(52),{overview:n,walkthrough:r,changesNavigation:i,walkthroughCode:a,firstDocument:o,layout:s,fileTarget:c,scope:l,context:u,base:d,changes:f,focused:p,onOpen:m,onBrowse:h,navigationTrigger:g,navigatorIsMobile:_,navigatorOpen:v,navigatorOpenMobile:y,tabControls:b}=e,x;t[0]!==p||t[1]!==s.panes?(x=s.panes[p]??{tabs:[],pinned:[],active:null},t[0]=p,t[1]=s.panes,t[2]=x):x=t[2];let S=x,C=s.split||p===0,w;t[3]===C?w=t[4]:(w={ignoreInputs:!0,enabled:C},t[3]=C,t[4]=w);let T=w,E;t[5]!==p||t[6]!==s?(E=()=>s.step(p,1),t[5]=p,t[6]=s,t[7]=E):E=t[7],So(vo.nextTab,E,T);let D;t[8]!==p||t[9]!==s?(D=()=>s.step(p,-1),t[8]=p,t[9]=s,t[10]=D):D=t[10],So(vo.previousTab,D,T);let O;t[11]!==p||t[12]!==S.active||t[13]!==s?(O=()=>S.active!==null&&S.active!==void 0&&s.close(p,S.active),t[11]=p,t[12]=S.active,t[13]=s,t[14]=O):O=t[14],So(vo.closeTab,O,T);let k;t[15]!==p||t[16]!==S.active||t[17]!==s?(k=()=>S.active!==null&&S.active!==void 0&&s.openToSide(p,S.active),t[15]=p,t[16]=S.active,t[17]=s,t[18]=k):k=t[18],So(vo.openToSide,k,T);let A;t[19]!==d||t[20]!==f||t[21]!==i||t[22]!==u||t[23]!==c||t[24]!==o||t[25]!==p||t[26]!==s||t[27]!==g||t[28]!==_||t[29]!==v||t[30]!==y||t[31]!==h||t[32]!==m||t[33]!==n||t[34]!==l||t[35]!==b||t[36]!==r||t[37]!==a?(A=e=>({walkthrough:r,changesNavigation:i,walkthroughCode:a,firstDocument:o,fileTarget:c,index:e,changeCount:Nt(bt(n))?.changes.length??0,layout:s,split:s.split,focused:p===e,scope:l,context:u,base:d,changes:f,onOpen:m,onBrowse:h,navigationTrigger:g,navigatorIsMobile:_,navigatorOpen:v,navigatorOpenMobile:y,tabControls:b}),t[19]=d,t[20]=f,t[21]=i,t[22]=u,t[23]=c,t[24]=o,t[25]=p,t[26]=s,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=h,t[32]=m,t[33]=n,t[34]=l,t[35]=b,t[36]=r,t[37]=a,t[38]=A):A=t[38];let j=A,M=_?`vertical`:`horizontal`,N=_?200:320,P;t[39]===j?P=t[40]:(P=(0,Z.jsx)(Jb,{...j(0)}),t[39]=j,t[40]=P);let F;t[41]!==N||t[42]!==P?(F=(0,Z.jsx)(ii,{id:`pane-left`,minSize:N,children:P}),t[41]=N,t[42]=P,t[43]=F):F=t[43];let I;t[44]!==s.split||t[45]!==_||t[46]!==j?(I=s.split&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(xi,{"aria-label":_?`Top and bottom document panes`:`Left and right document panes`,withHandle:!0}),(0,Z.jsx)(ii,{id:`pane-right`,minSize:_?200:320,children:(0,Z.jsx)(Jb,{...j(1)})})]}),t[44]=s.split,t[45]=_,t[46]=j,t[47]=I):I=t[47];let L;return t[48]!==F||t[49]!==I||t[50]!==M?(L=(0,Z.jsxs)(ia,{orientation:M,className:`min-h-0 flex-1`,children:[F,I]}),t[48]=F,t[49]=I,t[50]=M,t[51]=L):L=t[51],L}function qb(e,t){return e?t===0?`left`:`right`:null}function Jb(e){let t=(0,$.c)(35),{changeCount:n,walkthrough:r,walkthroughCode:i,firstDocument:a,fileTarget:o,index:s,layout:c,split:l,focused:u,scope:d,context:f,base:p,changes:m,onOpen:h,onBrowse:g,navigationTrigger:_,navigatorIsMobile:v,navigatorOpen:y,navigatorOpenMobile:b,tabControls:x}=e,{element:S,attach:C}=ma(),w=c.panes[s]??{tabs:[],pinned:[],active:null},T=(0,Q.useDeferredValue)(w.active),E=w.active!==`handoff`&&w.tabs.includes(T??``)?T:w.active,D=E!==w.active,O=Up(E??void 0),k;t[0]!==s||t[1]!==c?(k=e=>{let t=e.target;t instanceof Element&&e.currentTarget.contains(t)&&t.closest(`[data-review-controls]`)===null&&(e.type===`pointerdown`?c.selectPane(s):c.focusPane(s,t))},t[0]=s,t[1]=c,t[2]=k):k=t[2];let A=k,j;t[3]!==s||t[4]!==c?(j=e=>c.bindPane(s,e),t[3]=s,t[4]=c,t[5]=j):j=t[5];let M=l&&s===1&&`border-l`,N=s===1&&`motion-safe:animate-in motion-safe:fade-in-0 duration-150`,P;t[6]!==M||t[7]!==N?(P=q(`@container/pane relative flex h-full min-h-0 min-w-0 flex-col`,M,N),t[6]=M,t[7]=N,t[8]=P):P=t[8];let F;t[9]!==f.connection||t[10]!==d?(F={connection:f.connection,scope:d},t[9]=f.connection,t[10]=d,t[11]=F):F=t[11];let I;t[12]!==s||t[13]!==_||t[14]!==v||t[15]!==y||t[16]!==b?(I=s===0?(0,Z.jsxs)(wn,{children:[(0,Z.jsx)(nn,{render:(0,Z.jsx)(`span`,{className:`inline-flex`}),children:(0,Z.jsx)(At,{ref:e=>_.attach(e),"aria-label":`Toggle Sidebar`,"aria-expanded":v?b:y,"aria-keyshortcuts":Io()===`mac`?`Meta+B`:`Control+B`,onClick:()=>{!v&&y&&requestAnimationFrame(()=>_.element?.focus())}})}),(0,Z.jsxs)(yt,{role:`tooltip`,className:`break-all`,children:[`Toggle Sidebar`,` `,(0,Z.jsx)(Jn,{children:ko(vo.toggleNavigator)})]})]}):void 0,t[12]=s,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=I):I=t[17];let L=w.tabs,R=w.pinned,z;t[18]!==s||t[19]!==l?(z=qb(l,s),t[18]=s,t[19]=l,t[20]=z):z=t[20];let B;t[21]!==s||t[22]!==c?(B=I_(c,s),t[21]=s,t[22]=c,t[23]=B):B=t[23];let V=O?.kind===`handoff`&&(0,Z.jsx)(Tb,{value:m.scope,onValueChange:m.onScope}),H=(O?.kind===`branch`||O?.kind===`handoff`&&m.scope===`branch`)&&!a.guided&&(0,Z.jsx)(Db,{scope:d,connection:f.connection,base:p,onBase:m.onBase,compact:!0}),U;t[24]!==C||t[25]!==V||t[26]!==H?(U=(0,Z.jsxs)(`div`,{ref:C,"data-pane-controls":``,role:`toolbar`,"aria-label":`Document controls`,className:`flex items-center gap-1`,children:[V,H]}),t[24]=C,t[25]=V,t[26]=H,t[27]=U):U=t[27];let W;t[28]!==s||t[29]!==l||t[30]!==x?(W=(!l||s===1)&&x(s),t[28]=s,t[29]=l,t[30]=x,t[31]=W):W=t[31];let G;return t[32]!==U||t[33]!==W?(G=(0,Z.jsxs)(Z.Fragment,{children:[U,W]}),t[32]=U,t[33]=W,t[34]=G):G=t[34],(0,Z.jsxs)(`section`,{ref:j,"aria-label":l?`${s===0?`Left`:`Right`} pane`:void 0,"data-focused":u,"aria-busy":D,onPointerDownCapture:A,onFocusCapture:A,className:P,children:[(0,Z.jsx)(z_,{changeCount:n,commitContext:F,leading:I,tabs:L,pinned:R,active:E,side:z,focused:u,...B,trailing:G}),O?.kind===`branch-file`&&!a.guided&&(0,Z.jsxs)(`div`,{role:`group`,"aria-label":`Branch comparison`,className:`flex items-center gap-2 border-b px-3.5 py-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:`Branch comparison`}),(0,Z.jsx)(Db,{scope:d,connection:f.connection,base:p,onBase:m.onBase,compact:!0})]}),w.tabs.filter(e=>e===E||e===`walkthrough`).map(e=>{let t=Up(e);if(!t)return null;let n=e===E,c=t;return t.kind===`handoff`&&(c={kind:m.scope===`branch`?`branch`:`all-changes`}),(0,Z.jsx)(`div`,{"aria-hidden":!n,inert:!n||D,className:q(`flex min-h-0 flex-1 flex-col overflow-hidden`,!n&&`pointer-events-none invisible absolute opacity-0 inset-x-0 top-12 bottom-0`),children:(0,Z.jsx)(Nb,{documentKey:e,connection:f.connection,scope:d,children:(0,Z.jsx)(mb,{walkthrough:r,walkthroughCode:i,singleHeader:a.guided,scope:d,context:f,document:c,sideLabel:i_(qb(l,s)),base:p,onOpen:h,onBrowse:g,active:n&&u&&!D,toolbarTarget:n&&!D?S:null,fileTarget:n&&o?.pane===s&&o.key===E?o:void 0})})},t.kind===`walkthrough`?`walkthrough`:`document`)})]})}var Yb={open:br,review:g,"open-to-side":Jr,"open-file":oc,timeline:Ai,"copy-relative":De,discard:Rc,"expand-all":Qs,"collapse-all":Xs};function Xb(e){let t=(0,$.c)(2),{action:n}=e,r=Yb[n.id],i;return t[0]===r?i=t[1]:(i=(0,Z.jsx)(r,{}),t[0]=r,t[1]=i),i}function Zb(e){let t=(0,$.c)(46),{actions:n,label:r,description:i,onAction:a,children:o}=e,s=(0,Q.useId)(),[c,l]=(0,Q.useState)(!1),u;t[0]===a?u=t[1]:(u=e=>{e===`open-to-side`&&(0,ru.flushSync)(()=>l(!0)),a(e)},t[0]=a,t[1]=u);let d=u,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>{e&&l(!1)},t[2]=f):f=t[2];let p=f,m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(`div`,{className:`min-w-0`}),t[3]=m):m=t[3];let h;t[4]!==i||t[5]!==s?(h=i&&(0,Z.jsx)(`span`,{id:s,className:`sr-only`,children:i}),t[4]=i,t[5]=s,t[6]=h):h=t[6];let g=i?s:void 0,_;t[7]!==r||t[8]!==g?(_=(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,className:`shrink-0`,"aria-label":r,"aria-describedby":g}),t[7]=r,t[8]=g,t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Yn,{}),t[10]=v):v=t[10];let y;t[11]===_?y=t[12]:(y=(0,Z.jsx)(nn,{render:(0,Z.jsx)(on,{render:_,children:v})}),t[11]=_,t[12]=y);let b;t[13]===r?b=t[14]:(b=(0,Z.jsx)(yt,{role:`tooltip`,className:`break-all`,children:r}),t[13]=r,t[14]=b);let x;t[15]!==y||t[16]!==b?(x=(0,Z.jsxs)(wn,{children:[y,b]}),t[15]=y,t[16]=b,t[17]=x):x=t[17];let S=!c,C;if(t[18]!==d||t[19]!==n){let e;t[21]===d?e=t[22]:(e=e=>(0,Z.jsxs)(Dn,{disabled:e.disabled,variant:e.destructive?`destructive`:`default`,onClick:()=>d(e.id),children:[(0,Z.jsx)(Xb,{action:e}),e.label]},e.id),t[21]=d,t[22]=e),C=n.map(e),t[18]=d,t[19]=n,t[20]=C}else C=t[20];let w;t[23]!==S||t[24]!==C?(w=(0,Z.jsx)(vt,{align:`end`,finalFocus:S,children:C}),t[23]=S,t[24]=C,t[25]=w):w=t[25];let T;t[26]!==x||t[27]!==w||t[28]!==h?(T=(0,Z.jsxs)(tn,{onOpenChange:p,children:[h,x,w]}),t[26]=x,t[27]=w,t[28]=h,t[29]=T):T=t[29];let E;t[30]!==o||t[31]!==T?(E=o(T),t[30]=o,t[31]=T,t[32]=E):E=t[32];let D;t[33]===E?D=t[34]:(D=(0,Z.jsx)(qi,{render:m,children:E}),t[33]=E,t[34]=D);let O=!c,k;if(t[35]!==d||t[36]!==n){let e;t[38]===d?e=t[39]:(e=e=>(0,Z.jsxs)(Xr,{disabled:e.disabled,variant:e.destructive?`destructive`:`default`,onClick:()=>d(e.id),children:[(0,Z.jsx)(Xb,{action:e}),e.label]},e.id),t[38]=d,t[39]=e),k=n.map(e),t[35]=d,t[36]=n,t[37]=k}else k=t[37];let A;t[40]!==O||t[41]!==k?(A=(0,Z.jsx)(Gr,{finalFocus:O,children:k}),t[40]=O,t[41]=k,t[42]=A):A=t[42];let j;return t[43]!==D||t[44]!==A?(j=(0,Z.jsxs)(ur,{onOpenChange:p,children:[D,A]}),t[43]=D,t[44]=A,t[45]=j):j=t[45],j}var Qb=`flex w-full min-w-0 items-center gap-1.5 rounded-lg px-2 py-1 text-left text-caption transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:font-medium`;function $b(e){let t=(0,$.c)(30),{path:n,document:r,note:i,scopes:a,changeStatus:o,reviewStatus:s,active:c,onOpen:l,sideLabel:u,onReview:d,canReview:f,onDiscard:p,indented:m}=e,h=m!==void 0&&m,g;t[0]===n?g=t[1]:(g=ui(n),t[0]=n,t[1]=g);let _;t[2]===a?_=t[3]:(_=a.length>0?` · ${a.join(` + `)}`:``,t[2]=a,t[3]=_);let v=`${g}${_}`,y;t[4]!==r||t[5]!==p||t[6]!==l||t[7]!==d||t[8]!==n?(y=e=>{bb10:switch(e){case`review`:d();break bb10;case`open`:l(r);break bb10;case`open-to-side`:l(r,{toSide:!0});break bb10;case`open-file`:l({kind:`file`,path:n});break bb10;case`timeline`:l({kind:`timeline`,path:n});break bb10;case`copy-relative`:ht(n,`relative path`);break bb10;case`discard`:p?.()}},t[4]=r,t[5]=p,t[6]=l,t[7]=d,t[8]=n,t[9]=y):y=t[9];let b=y,x=`Actions for ${n}`,S=p!==void 0,C;t[10]!==f||t[11]!==s||t[12]!==u||t[13]!==S?(C=nu({kind:`file`,status:s,canReview:f,sideLabel:u,canDiscard:S}),t[10]=f,t[11]=s,t[12]=u,t[13]=S,t[14]=C):C=t[14];let w;t[15]!==c||t[16]!==o||t[17]!==r||t[18]!==h||t[19]!==v||t[20]!==i||t[21]!==l||t[22]!==n||t[23]!==s?(w=e=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":c,"aria-label":v,"aria-description":tx(o,s),title:i==null?n:`${n}\n${i}`,className:q(Qb,`flex-1 text-muted-foreground`,h&&`pl-7`,c&&`bg-accent font-medium text-foreground`),onClick:e=>l(r,{toSide:e.altKey}),children:[(0,Z.jsx)(ex,{status:o,reviewStatus:s}),(0,Z.jsx)(hi,{path:n,className:`size-3.5 shrink-0`}),(0,Z.jsx)(X,{className:q(`min-w-0 flex-1 `,s===`reviewed`&&`line-through decoration-muted-foreground/40`),text:ui(n)})]}),e]}),t[15]=c,t[16]=o,t[17]=r,t[18]=h,t[19]=v,t[20]=i,t[21]=l,t[22]=n,t[23]=s,t[24]=w):w=t[24];let T;return t[25]!==b||t[26]!==x||t[27]!==C||t[28]!==w?(T=(0,Z.jsx)(Zb,{label:x,actions:C,onAction:b,children:w}),t[25]=b,t[26]=x,t[27]=C,t[28]=w,t[29]=T):T=t[29],T}function ex(e){let t=(0,$.c)(16),{status:n,reviewStatus:r}=e,i=r??`unreviewed`,a;t[0]!==r||t[1]!==n?(a=tx(n,r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s=n===void 0&&`bg-muted-foreground/60`,c=(n===`added`||n===`untracked`)&&`bg-graph-2`,l=n===`modified`&&`bg-graph-4`,u=n===`deleted`&&`bg-destructive`,d=n===`renamed`&&`bg-graph-1`,f;t[3]!==s||t[4]!==c||t[5]!==l||t[6]!==u||t[7]!==d?(f=q(`size-1.5 rounded-full`,s,c,l,u,d),t[3]=s,t[4]=c,t[5]=l,t[6]=u,t[7]=d,t[8]=f):f=t[8];let p;t[9]===f?p=t[10]:(p=(0,Z.jsx)(`span`,{className:f}),t[9]=f,t[10]=p);let m;return t[11]!==o||t[12]!==i||t[13]!==n||t[14]!==p?(m=(0,Z.jsx)(`span`,{role:`img`,"aria-label":o,className:`grid w-3.5 shrink-0 place-items-center`,"data-review-state":i,"data-change-status":n,title:o,children:p}),t[11]=o,t[12]=i,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function tx(e,t){return`${e===void 0?`Change type unavailable`:Ea[e].label} · ${nx(t)}`}function nx(e){return e===`reviewed`?`Reviewed`:e===`stale`?`Changed since review`:`Not reviewed`}function rx(e){let t=(0,$.c)(17),{label:n,active:r,onOpen:i,className:a,plain:o,children:s}=e,c=a===void 0?Qb:a;if(o!==void 0&&o){let e;return t[0]!==r||t[1]!==s||t[2]!==c||t[3]!==n||t[4]!==i?(e=(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center`,children:(0,Z.jsx)(`button`,{type:`button`,className:c,"aria-pressed":r,"aria-label":n,onClick:i,children:s})}),t[0]=r,t[1]=s,t[2]=c,t[3]=n,t[4]=i,t[5]=e):e=t[5],e}let l=`Actions for ${n}`,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=nu({kind:`section`}),t[6]=u):u=t[6];let d;t[7]!==r||t[8]!==s||t[9]!==c||t[10]!==i?(d=e=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,Z.jsx)(`button`,{type:`button`,className:c,"aria-pressed":r,onClick:i,children:s}),e]}),t[7]=r,t[8]=s,t[9]=c,t[10]=i,t[11]=d):d=t[11];let f;return t[12]!==i||t[13]!==l||t[14]!==u||t[15]!==d?(f=(0,Z.jsx)(Zb,{label:l,actions:u,onAction:i,children:d}),t[12]=i,t[13]=l,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function ix(e){let t=(0,$.c)(15),{name:n,count:r,expanded:i,onExpanded:a,onAll:o,action:s,children:c}=e,l=i?Ae:f,u;t[0]!==l||t[1]!==r||t[2]!==i||t[3]!==n||t[4]!==a?(u=e=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:Qb,"aria-label":n,"aria-expanded":i,onClick:()=>a(!i),children:[(0,Z.jsx)(X,{className:`min-w-0 flex-1`,text:`${n} · ${R(r,`file`)}`}),(0,Z.jsx)(l,{className:`size-3.5 shrink-0`})]}),e]}),t[0]=l,t[1]=r,t[2]=i,t[3]=n,t[4]=a,t[5]=u):u=t[5];let d=u,p;t[6]!==s||t[7]!==n||t[8]!==o||t[9]!==d?(p=s?d(s):(0,Z.jsx)(Zb,{label:`Actions for ${n}`,actions:nu({kind:`group`}),onAction:e=>o(e===`expand-all`),children:d}),t[6]=s,t[7]=n,t[8]=o,t[9]=d,t[10]=p):p=t[10];let m=i&&c,h;return t[11]!==n||t[12]!==p||t[13]!==m?(h=(0,Z.jsxs)(`section`,{"aria-label":n,className:`mt-3 border-t pt-2`,children:[p,m]}),t[11]=n,t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function ax(e){let t=(0,$.c)(17),{label:n,value:r,options:i,onValue:a,className:o}=e,s;t[0]===o?s=t[1]:(s=q(`shrink-0`,o),t[0]=o,t[1]=s);let c;t[2]!==a||t[3]!==i?(c=e=>{let t=i.find(t=>t.value===e);t&&a(t.value)},t[2]=a,t[3]=i,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=i.map(ox),t[5]=i,t[6]=l);let u;t[7]!==n||t[8]!==l?(u=(0,Z.jsx)(ws,{"aria-label":n,className:`w-full`,children:l}),t[7]=n,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==c||t[11]!==u||t[12]!==r?(d=(0,Z.jsx)(Es,{value:r,onValueChange:c,children:u}),t[10]=c,t[11]=u,t[12]=r,t[13]=d):d=t[13];let f;return t[14]!==s||t[15]!==d?(f=(0,Z.jsx)(`div`,{className:s,children:d}),t[14]=s,t[15]=d,t[16]=f):f=t[16],f}function ox(e){return(0,Z.jsx)(uo,{value:e.value,className:`min-w-0`,children:e.label},e.value)}function sx(e){let t=(0,$.c)(16),{scope:n,context:r,base:i,activeEntry:a,onOpen:o,sideLabel:s,onBase:c,grouping:l}=e,u;t[0]!==i||t[1]!==r.connection||t[2]!==c||t[3]!==n?(u=(0,Z.jsx)(`div`,{className:`shrink-0 px-2 pt-2`,children:(0,Z.jsx)(Db,{scope:n,connection:r.connection,base:i,onBase:c})}),t[0]=i,t[1]=r.connection,t[2]=c,t[3]=n,t[4]=u):u=t[4];let d;t[5]!==a||t[6]!==i||t[7]!==r||t[8]!==l||t[9]!==o||t[10]!==n||t[11]!==s?(d=(0,Z.jsx)(cx,{scope:n,context:r,base:i,activeEntry:a,onOpen:o,sideLabel:s,grouping:l}),t[5]=a,t[6]=i,t[7]=r,t[8]=l,t[9]=o,t[10]=n,t[11]=s,t[12]=d):d=t[12];let f;return t[13]!==u||t[14]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[u,d]}),t[13]=u,t[14]=d,t[15]=f):f=t[15],f}function cx(e){let t=(0,$.c)(12),{scope:n,context:r,base:i,activeEntry:a,onOpen:o,sideLabel:s,grouping:c}=e,l;t[0]!==a||t[1]!==r||t[2]!==c||t[3]!==o||t[4]!==n||t[5]!==s?(l=e=>(0,Z.jsx)(lx,{scope:n,context:r,branch:e,activeEntry:a,onOpen:o,sideLabel:s,grouping:c}),t[0]=a,t[1]=r,t[2]=c,t[3]=o,t[4]=n,t[5]=s,t[6]=l):l=t[6];let u;return t[7]!==i||t[8]!==r||t[9]!==n||t[10]!==l?(u=(0,Z.jsx)(Y_,{scope:n,context:r,base:i,children:l}),t[7]=i,t[8]=r,t[9]=n,t[10]=l,t[11]=u):u=t[11],u}function lx(e){let t=(0,$.c)(53),{scope:n,context:r,branch:i,activeEntry:a,onOpen:o,sideLabel:s,grouping:c}=e,l=xs(r.connection),u;t[0]===i?u=t[1]:(u=Ri(i),t[0]=i,t[1]=u);let d=u,f=K_(n,r,d),p=ov(n,r,ux,d);if(i.base===null||i.base===void 0)return null;let m,h,g,_,v,y,b;if(t[2]!==c||t[3]!==a||t[4]!==i.base.ref||t[5]!==i.commits||t[6]!==i.files||t[7]!==i.head.branch||t[8]!==r||t[9]!==f||t[10]!==o||t[11]!==p||t[12]!==n||t[13]!==s||t[14]!==l){let e=ua(i.files,f),u;t[22]===i.head.branch?u=t[23]:(u=i.head.branch===null||i.head.branch===void 0?`this commit`:jp(i.head.branch),t[22]=i.head.branch,t[23]=u);let d=u,x;t[24]===i.commits?x=t[25]:(x=R(i.commits,`commit`),t[24]=i.commits,t[25]=x);let S=x,C=c?`All changes`:`All branch changes`,w;t[26]!==a||t[27]!==o||t[28]!==p||t[29]!==s?(w=e=>(0,Z.jsx)($b,{path:e.path,document:{kind:`branch-file`,path:e.path},note:e.status,changeStatus:Ts(e),scopes:[e.status],reviewStatus:e.reviewStatus,active:a===Hp({kind:`branch-file`,path:e.path}),onOpen:o,sideLabel:s,canReview:e.fingerprint!==null&&e.fingerprint!==void 0,onReview:()=>p.toggle({path:e.path,reviewed:e.reviewStatus===`reviewed`,fingerprint:e.fingerprint})},e.path),t[26]=a,t[27]=o,t[28]=p,t[29]=s,t[30]=w):w=t[30];let T=w;m=ei,b=`h-0 min-h-0 flex-1`,h=`p-2 pr-3`;let E;t[31]===i.base.ref?E=t[32]:(E=jp(i.base.ref),t[31]=i.base.ref,t[32]=E),t[33]!==S||t[34]!==d||t[35]!==E?(g=(0,Z.jsxs)(`p`,{className:`px-2 pb-1.5 text-2xs text-muted-foreground`,children:[S,` on `,d,` since `,E]}),t[33]=S,t[34]=d,t[35]=E,t[36]=g):g=t[36];let D;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=Hp(Bp),t[37]=D):D=t[37];let O;t[38]===o?O=t[39]:(O=()=>o(Bp),t[38]=o,t[39]=O);let k;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(mr,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[40]=k):k=t[40];let A;t[41]===C?A=t[42]:(A=(0,Z.jsx)(X,{className:`min-w-0 flex-1`,text:C}),t[41]=C,t[42]=A),_=(0,Z.jsxs)(rx,{label:C,active:a===D,onOpen:O,plain:c!==void 0,children:[k,A,(0,Z.jsx)(`span`,{className:`ml-auto text-2xs text-muted-foreground tabular-nums`,children:e.length})]}),v=e.length===0&&(0,Z.jsxs)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:[`No changes since `,jp(i.base.ref)]}),y=c?(0,Z.jsx)(c,{scope:n,context:r,items:e,row:T,activeEntry:a,onOpen:o}):eu(e,l).map(T),t[2]=c,t[3]=a,t[4]=i.base.ref,t[5]=i.commits,t[6]=i.files,t[7]=i.head.branch,t[8]=r,t[9]=f,t[10]=o,t[11]=p,t[12]=n,t[13]=s,t[14]=l,t[15]=m,t[16]=h,t[17]=g,t[18]=_,t[19]=v,t[20]=y,t[21]=b}else m=t[15],h=t[16],g=t[17],_=t[18],v=t[19],y=t[20],b=t[21];let x;t[43]!==h||t[44]!==g||t[45]!==_||t[46]!==v||t[47]!==y?(x=(0,Z.jsxs)(`div`,{className:h,children:[g,_,v,y]}),t[43]=h,t[44]=g,t[45]=_,t[46]=v,t[47]=y,t[48]=x):x=t[48];let S;return t[49]!==m||t[50]!==b||t[51]!==x?(S=(0,Z.jsx)(m,{className:b,children:x}),t[49]=m,t[50]=b,t[51]=x,t[52]=S):S=t[52],S}function ux(e){return bo.add(e)}var dx=[{value:`uncommitted`,label:`Uncommitted`},{value:`branch`,label:`Branch`}];function fx(e){let t=(0,$.c)(29),{grouping:n,scope:r,context:i,activeEntry:a,onOpen:o,sideLabel:s,changeScope:c,base:l,onChangeScope:u,onBase:d,allChanges:f}=e,{connection:p}=i;q_(r,i);let m=oi(r,p),h=J_(r,i,m),g=c===`branch`,_;t[0]!==c||t[1]!==u?(_=(0,Z.jsx)(ax,{label:`Changes to review`,className:`px-2.5 pt-3`,value:c,onValue:u,options:dx}),t[0]=c,t[1]=u,t[2]=_):_=t[2];let v;t[3]!==a||t[4]!==l||t[5]!==g||t[6]!==i||t[7]!==n?.branch||t[8]!==d||t[9]!==o||t[10]!==r||t[11]!==s?(v=g&&(0,Z.jsx)(sx,{scope:r,context:i,base:l,activeEntry:a,onOpen:o,sideLabel:s,onBase:d,grouping:n?.branch}),t[3]=a,t[4]=l,t[5]=g,t[6]=i,t[7]=n?.branch,t[8]=d,t[9]=o,t[10]=r,t[11]=s,t[12]=v):v=t[12];let y;t[13]!==a||t[14]!==f||t[15]!==l||t[16]!==g||t[17]!==h||t[18]!==i||t[19]!==n?.uncommitted||t[20]!==m||t[21]!==o||t[22]!==r||t[23]!==s?(y=!g&&(0,Z.jsx)(px,{scope:r,context:i,activeEntry:a,onOpen:o,sideLabel:s,list:m,changes:h,grouping:n?.uncommitted,allChanges:f,base:l}),t[13]=a,t[14]=f,t[15]=l,t[16]=g,t[17]=h,t[18]=i,t[19]=n?.uncommitted,t[20]=m,t[21]=o,t[22]=r,t[23]=s,t[24]=y):y=t[24];let b;return t[25]!==_||t[26]!==v||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[_,v,y]}),t[25]=_,t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function px(e){let t=(0,$.c)(16),{scope:n,context:r,activeEntry:i,onOpen:a,sideLabel:o,list:s,changes:c,grouping:l,allChanges:u,base:d}=e,f=xs(r.connection),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p={changes:!0,specs:!1},t[0]=p):p=t[0];let[m,h]=(0,Q.useState)(p),g=s.changes.map(vx),_=f?g.filter(_x):g,v=f?g.filter($l):[],y=new Map(c.map(gx)),b=Ss(s.changes),x=ov(n,r,hx),[S,C]=(0,Q.useState)(null),w=()=>l?(0,Z.jsx)(l,{base:d,scope:n,context:r,paths:g,row:T,activeEntry:i,onOpen:a}):(0,Z.jsx)(rx,{label:`All changes`,active:i===Hp(u),onOpen:()=>a(u),children:`All changes`}),T=e=>(0,Z.jsx)($b,{path:e,document:{kind:`change`,path:e},note:void 0,changeStatus:b.files.get(e),scopes:[...new Set(s.changes.find(t=>t.path===e)?.comparisons.map(mx))],reviewStatus:y.get(e)?.reviewStatus,active:i===Hp({kind:`change`,path:e}),onOpen:a,sideLabel:o,canReview:y.get(e)?.fingerprint!==null&&y.get(e)?.fingerprint!==void 0,onReview:()=>x.toggle({path:e,reviewed:y.get(e)?.reviewStatus===`reviewed`,fingerprint:y.get(e)?.fingerprint}),onDiscard:()=>C(t=>({path:e,nonce:(t?.nonce??0)+1}))},e),E=ei,D;t[1]===w?D=t[2]:(D=w(),t[1]=w,t[2]=D);let O=!l&&g.length===0&&(0,Z.jsx)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:`No changes`}),k=!l&&_.length>0&&(0,Z.jsx)(ix,{name:`Changed files`,count:_.length,expanded:m.changes,onExpanded:e=>h(t=>({...t,changes:e})),onAll:e=>h({changes:e,specs:e}),children:_.map(T)}),A=!l&&v.length>0&&(0,Z.jsxs)(ix,{name:`Specs`,count:v.length,expanded:m.specs,onExpanded:e=>h(t=>({...t,specs:e})),onAll:e=>h({changes:e,specs:e}),children:[(0,Z.jsx)(rx,{label:`Open all specs`,active:i===`specs`,onOpen:()=>a(zp),children:`Open all specs`}),v.map(T)]}),j;t[3]!==r||t[4]!==S||t[5]!==n?(j=S&&(0,Z.jsx)(wm,{scope:n,context:r,path:S.path,signal:S.nonce,hiddenTrigger:!0}),t[3]=r,t[4]=S,t[5]=n,t[6]=j):j=t[6];let M;t[7]!==D||t[8]!==O||t[9]!==k||t[10]!==A||t[11]!==j?(M=(0,Z.jsxs)(`div`,{className:`px-2.5 pt-2 pb-3`,children:[D,O,k,A,j]}),t[7]=D,t[8]=O,t[9]=k,t[10]=A,t[11]=j,t[12]=M):M=t[12];let N;return t[13]!==E||t[14]!==M?(N=(0,Z.jsx)(E,{className:`h-0 min-h-0 flex-1`,children:M}),t[13]=E,t[14]=M,t[15]=N):N=t[15],N}function mx(e){return e.scope}function hx(e){return bo.add(e)}function gx(e){return[e.path,e]}function _x(e){return!$l(e)}function vx(e){return e.path}function yx(e){let t={projectId:e.projectId,worktreeId:e.worktreeId};return e.remote===null?dn({to:`/$projectId/$worktreeId`,params:t}):dn({to:`/remotes/$environmentId/$projectId/$worktreeId`,params:{environmentId:e.remote,...t}})}function bx(e,t){let n=(0,$.c)(2),r=Wi(e,t,xx),i;return n[0]===r?i=n[1]:(i=()=>r?r():li.openWithPayload({remote:null}),n[0]=r,n[1]=i),i}function xx(e){return bo.add({title:`Could not open the project`,description:Pe(e),type:`error`})}function Sx(e){let t=(0,$.c)(10),{connection:n,empty:r}=e,i=Xe(),a=Bt(),o;t[0]!==r||t[1]!==i?(o=e=>i({...yx(e),replace:r}),t[0]=r,t[1]=i,t[2]=o):o=t[2];let s=o,c=bx(n,s),l;t[3]!==i||t[4]!==c?(l=ue(e=>{typeof e!=`object`&&(e===`open-settings`?i({to:`/settings/$section`,params:{section:Bi}}):c())}),t[3]=i,t[4]=c,t[5]=l):l=t[5],ie(l);let u;return t[6]!==n||t[7]!==s||t[8]!==a?(u=(0,Z.jsx)(gr,{connection:n,remotes:a,onOpened:s}),t[6]=n,t[7]=s,t[8]=a,t[9]=u):u=t[9],u}export{Sp as _,rx as a,xb as c,Y_ as d,D_ as f,qp as g,Hp as h,fx as i,jv as l,Rp as m,bx as n,Hb as o,k_ as p,yx as r,Nb as s,Sx as t,bv as u,Ac as v};
|
|
23
|
+
`):``,...t?{replacedSubject:t.subject}:{},onBusy:o,onLookAgain:s})},t[5]=i,t[6]=r,t[7]=o,t[8]=s,t[9]=n,t[10]=a,t[11]=d):d=t[11];let f;return t[12]!==r||t[13]!==n||t[14]!==u||t[15]!==d?(f=(0,Z.jsx)(Mg,{scope:n,context:r,pending:u,children:d}),t[12]=r,t[13]=n,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function Ag(e){let t=(0,$.c)(7),{action:n}=e,r=n===`amend`?`Amend last commit`:`Commit changes`,i;t[0]===r?i=t[1]:(i=(0,Z.jsx)(Zi,{children:r}),t[0]=r,t[1]=i);let a=n===`amend`?`The last commit is replaced by one with this message and the files you add.`:`Committed steps fold away in the review and show up in History.`,o;t[2]===a?o=t[3]:(o=(0,Z.jsx)(ta,{children:a}),t[2]=a,t[3]=o);let s;return t[4]!==i||t[5]!==o?(s=(0,Z.jsxs)(Ui,{children:[i,o]}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function jg(e){let t=(0,$.c)(12),{scope:n,context:r,action:i,status:a,onBusy:o,onLookAgain:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Reading branch…`}),t[0]=c):c=t[0];let l;t[1]!==i||t[2]!==r||t[3]!==o||t[4]!==s||t[5]!==n||t[6]!==a?(l=e=>(0,Z.jsx)(Ng,{scope:n,context:r,action:i,status:{...a,branch:e.branch??a.branch},expectedStatus:a,onBusy:o,onLookAgain:s}),t[1]=i,t[2]=r,t[3]=o,t[4]=s,t[5]=n,t[6]=a,t[7]=l):l=t[7];let u;return t[8]!==r||t[9]!==n||t[10]!==l?(u=(0,Z.jsx)(Mg,{scope:n,context:r,pending:c,children:l}),t[8]=r,t[9]=n,t[10]=l,t[11]=u):u=t[11],u}function Mg(e){let t=(0,$.c)(12),{scope:n,context:r,pending:i,children:a}=e,o=Ei(n,r.connection);if($t(o.result)){let e;t[0]===o.result.cause?e=t[1]:(e=Cn(Dn(o.result.cause)),t[0]=o.result.cause,t[1]=e);let n;t[2]===e?n=t[3]:(n=(0,Z.jsx)(wm,{text:e}),t[2]=e,t[3]=n);let r;t[4]===o.refresh?r=t[5]:(r=(0,Z.jsx)(Y,{variant:`outline`,onClick:o.refresh,children:`Read status again`}),t[4]=o.refresh,t[5]=r);let i;return t[6]!==n||t[7]!==r?(i=(0,Z.jsxs)(Z.Fragment,{children:[n,r]}),t[6]=n,t[7]=r,t[8]=i):i=t[8],i}if(!gt(o.result))return i;let s;return t[9]!==a||t[10]!==o.result.value?(s=a(o.result.value),t[9]=a,t[10]=o.result.value,t[11]=s):s=t[11],s}function Ng(e){let t=(0,$.c)(67),{scope:r,context:i,action:a,status:o,expectedStatus:s,onBusy:c,onLookAgain:l}=e,u=s===void 0?o:s,f=o.branch,[p,m]=(0,Q.useState)(`Porcelain review`),[h,g]=(0,Q.useState)(f?.stashes?.[0]?.oid??``),[_,v]=(0,Q.useState)(a===`stash-create`),y;t[0]!==u||t[1]!==c||t[2]!==l?(y={expectedStatus:u,onBusy:c,onLookAgain:l},t[0]=u,t[1]=c,t[2]=l,t[3]=y):y=t[3];let b=Zm(r,a,i,y),{busy:x,uncertain:C,outcome:w,error:T}=b,E;t[4]!==a||t[5]!==b||t[6]!==p||t[7]!==_||t[8]!==h?(E=e=>{e.preventDefault(),b.onSubmit($p(a,{message:p,stashOid:h,option:_}))},t[4]=a,t[5]=b,t[6]=p,t[7]=_,t[8]=h,t[9]=E):E=t[9];let D=x||C,O;t[10]!==a||t[11]!==_?(O=a===`stash-create`&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_?`Tracked changes and new files are set aside. The handoff stays empty until you restore the stash.`:`Tracked changes are set aside. New files stay in the worktree.`}),t[10]=a,t[11]=_,t[12]=O):O=t[12];let k;t[13]!==a||t[14]!==b.messageLimit||t[15]!==p?(k=a===`stash-create`&&(0,Z.jsxs)(Wt,{children:[(0,Z.jsx)(Dt,{htmlFor:`git-message`,children:`Message`}),(0,Z.jsx)(Lr,{id:`git-message`,value:p,onChange:e=>m(e.target.value),required:!0,maxLength:b.messageLimit})]}),t[13]=a,t[14]=b.messageLimit,t[15]=p,t[16]=k):k=t[16];let A;t[17]!==a||t[18]!==f||t[19]!==h?(A=(a===`stash-apply`||a===`stash-pop`)&&(0,Z.jsxs)(Wt,{children:[(0,Z.jsx)(Dt,{htmlFor:`git-stash`,children:`Stash`}),f?.stashes?.length?(0,Z.jsxs)(S,{items:f.stashes.map(Fg),value:h,onValueChange:e=>{e&&g(e)},children:[(0,Z.jsx)(Ge,{id:`git-stash`,children:(0,Z.jsx)(Qe,{})}),(0,Z.jsx)(G,{children:f.stashes.map(Pg)})]}):(0,Z.jsx)(d,{id:`git-stash`,value:h,onChange:e=>g(e.target.value),required:!0,pattern:`([a-f0-9]{40}|[a-f0-9]{64})`})]}),t[17]=a,t[18]=f,t[19]=h,t[20]=A):A=t[20];let j;t[21]===_?j=t[22]:(j=(0,Z.jsx)(Xm,{checked:_,onCheckedChange:v}),t[21]=_,t[22]=j);let M=a===`stash-create`?`Include untracked files`:`Restore staged changes`,N;t[23]!==j||t[24]!==M?(N=(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[j,M]}),t[23]=j,t[24]=M,t[25]=N):N=t[25];let P;t[26]!==N||t[27]!==D||t[28]!==O||t[29]!==k||t[30]!==A?(P=(0,Z.jsxs)(`fieldset`,{disabled:D,className:`flex min-w-0 flex-col gap-4`,children:[O,k,A,N]}),t[26]=N,t[27]=D,t[28]=O,t[29]=k,t[30]=A,t[31]=P):P=t[31];let F;t[32]===w?F=t[33]:(F=(0,Z.jsx)(Ig,{outcome:w}),t[32]=w,t[33]=F);let I;t[34]!==w||t[35]!==C?(I=C&&!w&&(0,Z.jsx)(`p`,{role:`status`,children:`Outcome not yet confirmed`}),t[34]=w,t[35]=C,t[36]=I):I=t[36];let L;t[37]===T?L=t[38]:(L=T?(0,Z.jsx)(wm,{text:Cn(T)}):null,t[37]=T,t[38]=L);let R;t[39]!==x||t[40]!==b.lookAgain||t[41]!==l||t[42]!==w?(R=w&&n(w)&&l&&(0,Z.jsx)(Y,{type:`button`,variant:`outline`,disabled:x,onClick:b.lookAgain,children:`Look again`}),t[39]=x,t[40]=b.lookAgain,t[41]=l,t[42]=w,t[43]=R):R=t[43];let z;t[44]!==x||t[45]!==b.checkOutcome||t[46]!==b.operation?(z=b.operation&&!x&&(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:b.checkOutcome,children:`Check outcome`}),t[44]=x,t[45]=b.checkOutcome,t[46]=b.operation,t[47]=z):z=t[47];let B;t[48]!==x||t[49]!==w||t[50]!==C?(B=x||C||!!(w&&n(w)),t[48]=x,t[49]=w,t[50]=C,t[51]=B):B=t[51];let V;t[52]!==a||t[53]!==x?(V=x?`Working…`:im(a),t[52]=a,t[53]=x,t[54]=V):V=t[54];let H;t[55]!==B||t[56]!==V?(H=(0,Z.jsx)(Y,{type:`submit`,disabled:B,children:V}),t[55]=B,t[56]=V,t[57]=H):H=t[57];let U;return t[58]!==P||t[59]!==F||t[60]!==I||t[61]!==L||t[62]!==R||t[63]!==z||t[64]!==H||t[65]!==E?(U=(0,Z.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:E,children:[P,F,I,L,R,z,H]}),t[58]=P,t[59]=F,t[60]=I,t[61]=L,t[62]=R,t[63]=z,t[64]=H,t[65]=E,t[66]=U):U=t[66],U}function Pg(e){return(0,Z.jsxs)(B,{value:e.oid,children:[e.message,` · `,jp(e.oid)]},e.oid)}function Fg(e){return{value:e.oid,label:`${e.message} · ${jp(e.oid)}`}}function Ig(e){let t=(0,$.c)(7),{outcome:n}=e;if(!n)return null;if(n.message&&Zt(n)&&n.state!==`conflicted`){let e;return t[0]===n.message?e=t[1]:(e=(0,Z.jsx)(wm,{text:n.message}),t[0]=n.message,t[1]=e),e}let r=n.state,i;t[2]===n?i=t[3]:(i=Lg(n),t[2]=n,t[3]=i);let a;return t[4]!==n.state||t[5]!==i?(a=(0,Z.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[r,i]}),t[4]=n.state,t[5]=i,t[6]=a):a=t[6],a}function Lg({message:e,reason:t}){return e?` · ${e}`:t?` · ${t.replaceAll(`_`,` `).toLowerCase()}`:``}function Rg(e){let t=(0,$.c)(53),{scope:n,context:r}=e,{connection:i}=r,a=Pt(xt(sa(n,i))),[o,c]=(0,Q.useState)(!1),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>e=>{if(!e)return;let t=()=>c(e.getClientRects().length===0);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[0]=l):l=t[0];let[u]=(0,Q.useState)(l),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),h=a!=null&&E(dn(a)).kind===`hint`,g=d||h,_=Ei(n,i,g),v=Pt(xt(_.result)),y=xi(n,i),b=Ea(i),x;t[1]===b?x=t[2]:(x=ko(b),t[1]=b,t[2]=x);let S=x,C;t[3]!==S||t[4]!==b?(C=S?void 0:so(b),t[3]=S,t[4]=b,t[5]=C):C=t[5];let w=C,[T,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(null),[F,I]=(0,Q.useState)(null),L;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>f(!0),t[6]=L):L=t[6];let R;t[7]!==w||t[8]!==S?(R=S?{kind:`ready`,strategy:S}:{kind:`blocked`,reason:w??`Changes & Git settings for this computer are unavailable.`},t[7]=w,t[8]=S,t[9]=R):R=t[9];let z;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{e&&j(null),k(e)},t[10]=z):z=t[10];let B;t[11]!==_||t[12]!==y||t[13]!==R?(B={details:_,enableDetails:L,pull:R,notify:Hg,onProgress:z,onResult:j,refreshLook:y,onLooked:I},t[11]=_,t[12]=y,t[13]=R,t[14]=B):B=t[14];let V=Pm(n,r,B);if(a==null)return null;let H={...dn(a),branch:ee(a.branch,g?v?.branch:void 0)},W;t[15]===N?W=t[16]:(W=e=>e.id===N,t[15]=N,t[16]=W);let G=nm.find(W),te=E(H),ne=te.kind===`run`&&te.action===`pull`&&!S,re=ne&&w?w:s(te,H),ie=U(te,H),ae=M(H),K=V.running,oe;t[17]!==_.result||t[18]!==g?(oe=g&&yn(_.result),t[17]=_.result,t[18]=g,t[19]=oe):oe=t[19];let q=oe,se=q?rm.slice(0,1):rm,ce=e=>{we(e)?V.runNetwork(e,H.branch):(I(H),P(e))},le;t[20]===K?le=t[21]:(le=e=>{e||j(null),K&&k(e)},t[20]=K,t[21]=le);let ue=K?`${Vn(K.name)}…`:te.label,de=!K&&ie!=null&&` ${ie}`,J;t[22]!==ue||t[23]!==de?(J=(0,Z.jsxs)(`span`,{ref:u,"aria-hidden":`true`,className:`hidden @min-lg/pane:inline`,children:[ue,de]}),t[22]=ue,t[23]=de,t[24]=J):J=t[24];let fe;t[25]!==V.checkOutcome||t[26]!==A||t[27]!==K?(fe=(0,Z.jsx)(mn,{align:`end`,className:`w-80`,children:A&&!K?(0,Z.jsxs)(ot,{children:[(0,Z.jsx)(Qt,{children:A.title}),A.description!==void 0&&(A.type===`error`?(0,Z.jsx)(wm,{text:A.description}):(0,Z.jsx)(Ft,{children:(0,Z.jsx)(Cm,{text:A.description})}))]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Qt,{children:K?`${Vn(K.name)}…`:`Git action…`}),(0,Z.jsx)(`ol`,{className:`flex flex-col gap-0.5 font-mono text-2xs leading-4`,children:K?.operation?.receipt?.progress.length?K.operation.receipt.progress.slice(-4).map(Vg):(0,Z.jsx)(`li`,{className:`text-muted-foreground`,children:`Waiting for Git…`})}),K&&A?.description&&(0,Z.jsx)(wm,{text:A.description}),K&&(0,Z.jsx)(Y,{variant:`outline`,disabled:K.checking,onClick:V.checkOutcome,children:K.checking?`Checking…`:`Check outcome`})]})}),t[25]=V.checkOutcome,t[26]=A,t[27]=K,t[28]=fe):fe=t[28];let pe;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(pe=e=>{m(e),e&&f(!0)},t[29]=pe):pe=t[29];let me=K!=null,he;t[30]===me?he=t[31]:(he=(0,Z.jsx)(sn,{render:(0,Z.jsx)(Y,{variant:`outline`,size:`icon`,"aria-label":`Git actions`,disabled:me})}),t[30]=me,t[31]=he);let ge;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(Ae,{className:`size-3.5`}),t[32]=ge):ge=t[32];let _e;t[33]===he?_e=t[34]:(_e=(0,Z.jsx)(rn,{render:he,children:ge}),t[33]=he,t[34]=_e);let ve;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Z.jsx)(bt,{role:`tooltip`,className:`break-all`,children:`Git actions`}),t[35]=ve):ve=t[35];let ye;t[36]===_e?ye=t[37]:(ye=(0,Z.jsxs)(Tn,{children:[_e,ve]}),t[36]=_e,t[37]=ye);let be=ae?(0,Z.jsx)(_h,{tracking:Lp(ae,null)}):(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(hr,{className:`size-3.5 shrink-0`}),`Git actions`]}),xe;t[38]===be?xe=t[39]:(xe=(0,Z.jsx)(Gt,{children:(0,Z.jsx)(Ct,{children:be})}),t[38]=be,t[39]=xe);let Se;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,Z.jsx)(Ot,{}),t[40]=Se):Se=t[40];let Ce=se.map((e,t)=>(0,Z.jsxs)(Q.Fragment,{children:[(0,Z.jsx)(Gt,{children:e.actions.map(e=>{let t=am(e.id,H,w),n=t??He(e.id,H);return(0,Z.jsxs)(Tn,{onOpenChange:Bg,children:[(0,Z.jsx)(rn,{render:(0,Z.jsx)(`span`,{className:`block`}),children:(0,Z.jsxs)(On,{disabled:t!=null,onClick:()=>ce(e.id),children:[(0,Z.jsx)(Rm,{action:e.id}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(X,{text:e.label}),t&&(0,Z.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:t})]})]})}),(0,Z.jsxs)(bt,{children:[e.description,n&&` ${n}`]})]},e.id)})}),(q||t<se.length-1)&&(0,Z.jsx)(Ot,{})]},e.id)),Te;t[41]===q?Te=t[42]:(Te=q&&(0,Z.jsx)(`p`,{role:`status`,className:`px-2 py-1 text-xs text-muted-foreground`,children:`Reading Git status…`}),t[41]=q,t[42]=Te);let Ee=!q&&(ae?.discarded?.length??0)>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ot,{}),(0,Z.jsxs)(Gt,{children:[(0,Z.jsx)(Ct,{children:`Discarded`}),ae?.discarded?.map(e=>{let t=e.kind===`rename`?`Restore discarded rename of ${e.path}`:`Restore discarded hunk of ${e.path}`;return(0,Z.jsxs)(Tn,{onOpenChange:zg,children:[(0,Z.jsx)(rn,{render:(0,Z.jsx)(`span`,{className:`block`}),children:(0,Z.jsxs)(On,{onClick:()=>{m(!1),V.restoreDiscarded(e)},children:[(0,Z.jsx)(zc,{}),(0,Z.jsx)(X,{className:`min-w-0`,text:t,propagateEscape:!0})]})}),(0,Z.jsxs)(bt,{children:[t,` · Kept until you restore it`]})]},e.oid)})]})]}),De;t[43]!==q||t[44]!==xe||t[45]!==Ce||t[46]!==Te||t[47]!==Ee?(De=(0,Z.jsxs)(yt,{align:`end`,className:`w-76`,"aria-busy":q,children:[xe,Se,Ce,Te,Ee]}),t[43]=q,t[44]=xe,t[45]=Ce,t[46]=Te,t[47]=Ee,t[48]=De):De=t[48];let Oe;return t[49]!==p||t[50]!==ye||t[51]!==De?(Oe=(0,Z.jsxs)(nn,{open:p,onOpenChange:pe,children:[ye,De]}),t[49]=p,t[50]=ye,t[51]=De,t[52]=Oe):Oe=t[52],(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Mm,{"aria-label":`Git controls`,className:`shrink-0`,children:[(0,Z.jsxs)(Tn,{children:[(0,Z.jsxs)(Jt,{open:K!=null&&O||A!=null,onOpenChange:le,children:[(0,Z.jsxs)(rn,{render:(0,Z.jsx)(vn,{render:(0,Z.jsx)(Y,{variant:`outline`,size:o?`icon`:`default`,"aria-label":K?`${Vn(K.name)} in progress: show progress`:te.label,disabled:K==null&&(te.kind===`hint`||ne),focusableWhenDisabled:!0,className:`aria-disabled:cursor-default`,onClick:()=>{K||A||(te.kind===`commit`?ce(`commit`):te.kind===`stash`?ce(`stash-apply`):te.kind===`run`&&V.runNetwork(te.action,H.branch))}})}),children:[K?(0,Z.jsx)(mt,{className:`size-3.5`}):(0,Z.jsx)(Rm,{action:Ug(te),className:`size-3.5`}),J]}),fe]}),(0,Z.jsx)(bt,{role:`tooltip`,className:`break-all`,children:K?`${Vn(K.name)} in progress: show progress`:re})]}),Oe]}),N==null?null:(0,Z.jsx)(Wn,{open:!0,disablePointerDismissal:!0,onOpenChange:e=>{!e&&!T&&P(null)},children:(0,Z.jsxs)(yi,{"aria-busy":T,className:`max-h-[min(90svh,48rem)] overflow-y-auto sm:max-w-2xl`,children:[G?.id!==`commit`&&G?.id!==`amend`&&(0,Z.jsxs)(Ui,{children:[(0,Z.jsx)(Zi,{children:G?.label??`Git action`}),(0,Z.jsx)(ta,{children:Wg(G?.id)})]}),(0,Z.jsx)(Og,{scope:n,context:r,entry:N,status:F??H,onBusy:D,onLookAgain:V.lookAgain})]})})]})}function zg(e,t){t.reason===`escape-key`&&t.allowPropagation()}function Bg(e,t){t.reason===`escape-key`&&t.allowPropagation()}function Vg(e){return(0,Z.jsx)(X,{render:(0,Z.jsx)(`li`,{}),text:e},e)}function Hg(e){let{title:t,description:n,type:r}=e;return xo.add({title:t,description:n===void 0?void 0:(0,Z.jsx)(Cm,{text:n}),type:r})}function Ug(e){return e.kind===`run`?e.action:e.kind===`stash`?`stash-apply`:`commit`}function Wg(e){return e===`stash-pop`?`Its changes come back into the working tree and the stash is dropped.`:e===`stash-apply`?`Its changes come back into the working tree and the stash is kept.`:`Every change, new files included, is set aside until you pop the stash.`}function Gg(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=me(`(min-width: 1280px)`),e[0]=t):t=e[0],N(t)}var Kg=()=>({tabs:[],pinned:[]});function qg(e){return e===`handoff`||e===`walkthrough`}function Jg(e,t=`handoff`,n=!1){let r=n?[t,`walkthrough`]:[t];return{tabs:[...r,...e.tabs.filter(e=>!r.includes(e))],pinned:e.pinned.filter(e=>!qg(e))}}function Yg(e,t,n){if(e[t]?.tabs.includes(n))return t;let r=+(t===0);return e[r]?.tabs.includes(n)?r:t}function Xg(e){return[...[`handoff`,`walkthrough`].filter(t=>e.tabs.includes(t)),...e.pinned.filter(t=>!qg(t)&&e.tabs.includes(t)),...e.tabs.filter(t=>!qg(t)&&!e.pinned.includes(t))]}function Zg(e,t,n){return e.tabs.includes(t)?e:{...e,tabs:Gp(e.tabs,t,n)}}function Qg(e,t){return qg(t)?e:{tabs:e.tabs.filter(e=>e!==t),pinned:e.pinned.filter(e=>e!==t)}}function $g(e,t){return{...e,tabs:e.tabs.filter(n=>qg(n)||n===t||e.pinned.includes(n))}}function e_(e){return{...e,tabs:e.tabs.filter(t=>qg(t)||e.pinned.includes(t))}}function t_(e,t){return qg(t)?e:e.pinned.includes(t)?{...e,pinned:e.pinned.filter(e=>e!==t)}:{...e,pinned:[...e.pinned,t]}}function n_(e,t,n){if(n.tabs.includes(t))return t;let r=Xg(e),i=new Set(Xg(n)),a=r.indexOf(t);return a===-1?null:[...r.slice(a+1),...r.slice(0,a).reverse()].find(e=>i.has(e)&&!qg(e))??e.tabs.find(e=>i.has(e))??null}function r_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function i_(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&(Wp(e)??null)!==null):[]}function a_(e){if(!r_(e)||!Array.isArray(e.panes))return null;let t=e.panes.map(e=>{let t=i_(r_(e)?e.tabs:void 0);return{tabs:t,pinned:i_(r_(e)?e.pinned:void 0).filter(e=>t.includes(e))}}).filter((e,t)=>t===0||e.tabs.length>0);return t.length>0?t:null}function o_(e){return e===null?`Open to the side`:e===`left`?`Open in the right pane`:`Open in the left pane`}function s_(e){if(e!==0)return{value:String(e),description:R(e,`uncommitted file`)}}function c_(e,t,n){let r=t.flatMap(e=>Xg(e)),i=n===null?e:[n,...e],a=new Set(r);return[...new Set([...i,...r])].filter(e=>a.has(e))}function l_(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function u_(e){return!e||typeof e!=`object`||!(`folded`in e)||!(`expanded`in e)?{folded:[],expanded:[]}:l_(e.folded)&&l_(e.expanded)?{folded:e.folded,expanded:e.expanded}:{folded:[],expanded:[]}}function d_(e,t,n=!1){return e.folded.includes(t)||n&&!e.expanded.includes(t)}function f_(e,t,n){let r=new Set(e.folded),i=new Set(e.expanded);for(let e of t)n?(r.add(e),i.delete(e)):(r.delete(e),i.add(e));return{folded:[...r],expanded:[...i]}}function p_(e,t){return e?.owner===t?void 0:e}var m_=Mn(ft({saved:an})),h_=Mn(ft({focused:Nt([0,1])})),g_=Pn.pipe(p(ft({panes:at(Et(ft({tabs:Et(Ln),pinned:Et(Ln)}))),saved:an,focused:Nt([0,1])}),{decode:ge(e=>({panes:a_(e),saved:m_(e).pipe(An(e=>e.saved),on(()=>!0)),focused:h_(e).pipe(An(e=>e.focused),on(()=>0))})),encode:ce()})),__=Pn.pipe(p(ft({folded:Et(Ln),expanded:Et(Ln)}),{decode:ge(u_),encode:ce()})),v_=x(e=>Un({runtime:va,key:`porcelain.tabs.${e}`,schema:g_,defaultValue:()=>({panes:null,saved:!1,focused:0})})),y_=x(e=>u([]).pipe(Ee)),b_=x(e=>Un({runtime:va,key:e,schema:__,defaultValue:()=>({folded:[],expanded:[]})}));function x_(e){let t=(0,$.c)(13),n;t[0]===e?n=t[1]:(n=v_(e),t[0]=e,t[1]=n);let r=n,{panes:i,saved:a,focused:o}=N(r),s=c(r),l=N(oe),u;t[2]!==r||t[3]!==l?(u=e=>{let t=l.get(r);t.focused!==e&&l.set(r,{...t,focused:e})},t[2]=r,t[3]=l,t[4]=u):u=t[4];let d;t[5]===s?d=t[6]:(d=e=>s(t=>({...t,panes:e,saved:!0})),t[5]=s,t[6]=d);let f;return t[7]!==o||t[8]!==i||t[9]!==a||t[10]!==u||t[11]!==d?(f={panes:i,saved:a,focused:o,setFocused:u,save:d},t[7]=o,t[8]=i,t[9]=a,t[10]=u,t[11]=d,t[12]=f):f=t[12],f}function S_(e,t){let n=(0,$.c)(7),r=`porcelain.folds.${e}.${t}`,i;n[0]===r?i=n[1]:(i=b_(r),n[0]=r,n[1]=i);let a=i,o=N(a),s=c(a),l;n[2]===s?l=n[3]:(l=(e,t)=>s(n=>f_(n,e,t)),n[2]=s,n[3]=l);let u;return n[4]!==l||n[5]!==o?(u={folds:o,setCollapsed:l},n[4]=l,n[5]=o,n[6]=u):u=n[6],u}var C_=x(e=>u(25).pipe(Ee)),w_=x(e=>u({viewer:null,restored:null})),T_=x(e=>u({scrollTop:0,selection:null,focused:void 0}).pipe(Ee));function E_(e){let t=(0,$.c)(33),n=(0,Q.useId)(),r;t[0]===n?r=t[1]:(r=w_(n),t[0]=n,t[1]=r);let i=r;ie(i);let a=N(oe),o;t[2]===e?o=t[3]:(o=T_(e),t[2]=e,t[3]=o);let s=o,c,l,u,d,f,p;t[4]!==s||t[5]!==a?(c=()=>a.get(s).scrollTop,l=()=>a.get(s).selection,u=()=>a.get(s).focused,d=e=>a.set(s,{...a.get(s),focused:e}),f=e=>{a.set(s,{...a.get(s),scrollTop:e})},p=e=>{a.set(s,{...a.get(s),selection:e})},t[4]=s,t[5]=a,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p):(c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11]);let m;t[12]!==i||t[13]!==a?(m=e=>a.get(i).viewer?.scrollTo(e),t[12]=i,t[13]=a,t[14]=m):m=t[14];let h;t[15]!==i||t[16]!==e||t[17]!==s||t[18]!==a?(h=(t,n)=>{let r=a.get(i);(r.restored?.viewer!==t||r.restored.owner!==e)&&(t.scrollTo({type:`position`,position:a.get(s).scrollTop+n,behavior:`instant`}),a.set(i,{...r,restored:{viewer:t,owner:e}}))},t[15]=i,t[16]=e,t[17]=s,t[18]=a,t[19]=h):h=t[19];let g;t[20]!==i||t[21]!==a?(g=e=>{if(e)return a.set(i,{...a.get(i),viewer:e}),()=>{let t=a.get(i);t.viewer===e&&a.set(i,{...t,viewer:null})}},t[20]=i,t[21]=a,t[22]=g):g=t[22];let _;return t[23]!==h||t[24]!==g||t[25]!==c||t[26]!==l||t[27]!==u||t[28]!==d||t[29]!==f||t[30]!==p||t[31]!==m?(_={position:c,selection:l,focused:u,rememberFocus:d,rememberPosition:f,rememberSelection:p,scrollTo:m,restorePosition:h,attach:g},t[23]=h,t[24]=g,t[25]=c,t[26]=l,t[27]=u,t[28]=d,t[29]=f,t[30]=p,t[31]=m,t[32]=_):_=t[32],_}var D_=Un({runtime:va,key:`porcelain.review-panel.open`,schema:an,defaultValue:()=>!0}).pipe(Ee);function O_(){let e=(0,$.c)(3),t=N(D_),n=c(D_),r;return e[0]!==t||e[1]!==n?(r={open:t,setOpen:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],r}var k_=x(e=>u(void 0).pipe(Ee)),A_=new Map,j_=x(e=>u(t=>{let n=Symbol();A_.set(e.worktreeId,{owner:n,title:e.title}),t.set(k_(e.worktreeId),e.title),t.addFinalizer(()=>{p_(A_.get(e.worktreeId),n)||(A_.delete(e.worktreeId),t.set(k_(e.worktreeId),void 0))})}));function M_(e){let t=(0,$.c)(18),{worktreeId:n,entry:r,side:i,onSearch:a,fallback:o,focused:s,setFocused:c,ready:l,focusBoundary:u,focusBoundaryOpen:d,firstDocument:f,companion:p}=e,{panes:m,saved:h,save:g}=x_(n),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=[void 0,void 0],t[0]=_):_=t[0];let[v,y]=(0,Q.useState)(_),b;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(b=[null,null],t[1]=b):b=t[1];let[x,S]=(0,Q.useState)(b),C=(0,Q.useId)(),w;t[2]===C?w=t[3]:(w=P_(C),t[2]=C,t[3]=w);let T=N(w),E=T.cancel,D=[r!=null&&(Wp(r)??null)!==null?r:void 0,i!=null&&(Wp(i)??null)!==null?i:void 0],O;t[4]!==r||t[5]!==o||t[6]!==a||t[7]!==l||t[8]!==h||t[9]!==i?(O=F_({ready:l,entry:r,side:i,onSearch:a,fallback:o,saved:h}),t[4]=r,t[5]=o,t[6]=a,t[7]=l,t[8]=h,t[9]=i,t[10]=O):O=t[10],ie(O);let k=e=>{let t=v[e];return t===void 0?D[e]:t??void 0},A=[Jg(m?.[0]??Kg(),f,p),...m?.slice(1)??[]],j=Xg(m?.[0]??Kg()).at(-1),M=j&&!qg(j)?j:f,P=[k(0)??(m==null?o??f:M),k(1)??(k(0)!==void 0||A[1]===null||A[1]===void 0?null:Xg(A[1]).at(-1)??null)],F=[Zg(A[0]??Kg(),P[0]??``,x[0])];(P[0]===null||P[0]===void 0)&&(F[0]=A[0]??Kg()),P[1]!==null&&P[1]!==void 0&&(F[1]=Zg(A[1]??Kg(),P[1],x[1]));let I=F.length>1;if(l){let e=v.map((e,t)=>e!==void 0&&(D[t]??null)===(e??null)?void 0:e);(e[0]!==v[0]||e[1]!==v[1])&&y([e[0],e[1]]),(x[0]!==P[0]||x[1]!==P[1])&&S(P)}ie(I_({worktreeId:n,panes:F,ready:l}));let L;t[11]===n?L=t[12]:(L=y_(n),t[11]=n,t[12]=L);let R=N(L),z=P[s]??null;ie(L_({worktreeId:n,panes:F,active:z,ready:l}));let B=c_(R,F,z).flatMap(N_),V;t[13]!==E||t[14]!==a?(V=e=>{E(),y(t=>[`entry`in e?e.entry??null:t[0],`side`in e?e.side??null:t[1]]),a({...`entry`in e?{entry:e.entry??void 0}:{},...`side`in e?{side:e.side??void 0}:{}})},t[13]=E,t[14]=a,t[15]=V):V=t[15];let H=V,U;t[16]===H?U=t[17]:(U=(e,t)=>H(e===0?{entry:t}:{side:t}),t[16]=H,t[17]=U);let W=U,G=(e,t)=>F.map((n,r)=>r===e?t:n),ee=(e,t,n)=>{if(E(),I&&t.tabs.length===0){let t=+(e===0);g([F[t]??Kg()]),c(0),H({entry:P[t],side:null})}else g(G(e,t)),n!==P[e]&&W(e,n)};return{recentFiles:B,bindQuickOpen:T.bindQuickOpen,focusDestination:T.schedule,hasDestinationFocus(){return T.current()!==null},selectPane(e){E(),c(e)},focusPane(e,t){if(d||T.restoringQuickOpen&&t.getAttribute(`role`)===`tab`)return;let n=T.destination;n!==null&&(n.pane!==e||t.getAttribute(`role`)!==`tab`||t.getAttribute(`data-entry`)!==n.key)&&E(),c(e)},bindPane(e,t){return T.bind(e,t,{focused:s,actives:P,panes:F,focusBoundary:u})},split:I,panes:F.map((e,t)=>({tabs:Xg(e),pinned:e.pinned,active:P[t]??null})),activate(e,t){c(e),W(e,t)},open(e,t,n){let r=n!==void 0&&n,i=Yg(F,e,t);return W(i,t),r?T.cancel():T.request({pane:i,key:t}),c(i),i},closePane(e){I&&ee(e,Kg(),null)},close(e,t){let n=F[e]??Kg(),r=Qg(n,t);ee(e,r,t===P[e]?n_(n,t,r):P[e])},closeOthers(e,t){ee(e,$g(F[e]??Kg(),t),t)},closeUnpinned(e){let t=e_(F[e]??Kg()),n=P[e];ee(e,t,n!=null&&t.tabs.includes(n)?n:Xg(t)[0]??null)},togglePin(e,t){g(G(e,t_(F[e]??Kg(),t)))},openToSide(e,t){let n=+(e===0),r=[...F];r[n]=Zg(F[n]??Kg(),t,P[n]),g(r),W(n,t),T.request({pane:n,key:t}),c(n)},step(e,t){E();let n=Xg(F[e]??Kg());if(n.length===0)return;let r=P[e]===null||P[e]===void 0?-1:n.indexOf(P[e]);W(e,n[(r+t+n.length)%n.length]??null)}}}function N_(e){let t=Wp(e);return t?.kind===`file`?[t.path]:[]}var P_=x(e=>u(e=>{let t=[null,null],n=null,r=!1,i=null,a,o=null,s=()=>{o!==null&&cancelAnimationFrame(o),o=null},c=()=>{i=null,r=!1,s()},l=()=>i&&a&&(a.focused!==i.pane||a.actives[i.pane]!==i.key||!a.panes[i.pane]?.tabs.includes(i.key))?null:i,u=()=>{i&&o===null&&(o=requestAnimationFrame(()=>{o=null;let e=l();if(!e||a?.focusBoundary?.isConnected||n?.isConnected)return;let s=[...t[e.pane]?.querySelectorAll(`[role="tab"]`)??[]].find(t=>t.dataset.entry===e.key);s?.isConnected&&(s.focus(),s.ownerDocument.activeElement===s&&i===e&&(i=null,r=!1))}))};return e.addFinalizer(c),{get destination(){return i},get restoringQuickOpen(){return r},current:l,cancel:c,schedule:u,bindQuickOpen:e=>{n=e,e===null&&u()},request(e){i=e,r=n?.isConnected===!0},bind(e,n,r){if(s(),a=r,t[e]=n,l(),n)return u(),()=>{t[e]===n&&(t[e]=null),s()}}}})),F_=x(({ready:e,entry:t,side:n,onSearch:r,fallback:i,saved:a})=>u(()=>{e&&(t!==void 0&&Wp(t)===null&&r({entry:void 0},{replace:!0}),n!==void 0&&Wp(n)===null&&r({side:void 0},{replace:!0}),!a&&t===void 0&&n===void 0&&i!==null&&r({entry:i},{replace:!0}))})),I_=x(({worktreeId:e,panes:t,ready:n})=>u(r=>{if(!n)return;let i=v_(e),a=r.once(i);a.saved&&JSON.stringify(a.panes)===JSON.stringify(t)&&(t.length>1||a.focused===0)||r.set(i,{...a,panes:t,saved:!0,focused:t.length>1?a.focused:0})})),L_=x(({worktreeId:e,panes:t,active:n,ready:r})=>u(i=>{if(!r)return;let a=y_(e),o=i.once(a),s=c_(o,t,n);o.length===s.length&&o.every((e,t)=>e===s[t])||i.set(a,s)}));function R_(e,t){return{onActivate:n=>e.activate(t,n),onClose:n=>e.close(t,n),onCloseOthers:n=>e.closeOthers(t,n),onCloseUnpinned:()=>e.closeUnpinned(t),onTogglePin:n=>e.togglePin(t,n),onOpenToSide:n=>e.openToSide(t,n),onClosePane:e.split?()=>e.closePane(t):void 0}}function z_(e){let t=e?.closest(`[data-tab-viewport]`);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.left<r.left?n.left-r.left:Math.max(0,n.right-r.right);t.scrollBy({left:i})}function B_(e,t){let n=Wp(e);switch(n?.kind){case`handoff`:{let e=`Changes`;return{Icon:xr,title:e,hint:t?`${e} · ${t.description}`:e}}case`walkthrough`:return{Icon:Tc,title:`Walkthrough`,hint:`Walkthrough`};case`walkthrough-step`:return{Icon:xr,title:`Step ${n.step}`,hint:`Changes in step ${n.step}`};case`all-changes`:case`walkthrough-changes`:return{Icon:xr,title:`All changes`,hint:`Every changed file, including specs`};case`specs`:return{Icon:dc,title:`Specs`,hint:`Changed spec and test files`};case`change`:return{Icon:Rr,title:di(n.path),accessibleName:n.path,hint:`${n.path} · changes`};case`file`:return{Icon:Rr,title:di(n.path),accessibleName:n.path,hint:n.path};case`commit`:return{Icon:pc,title:jp(n.oid),hint:`Commit ${n.oid}`};case`branch`:return{Icon:hr,title:`Branch`,hint:`Every change on the branch`};case`branch-file`:return{Icon:Rr,title:di(n.path),accessibleName:n.path,hint:`${n.path} · branch`};case`pull-request`:return{Icon:xc,title:`PR #${n.number}`,hint:`Pull request #${n.number}`};case`graph`:return{Icon:hr,title:`Graph`,hint:`Commit graph of the checked-out branch`};case`timeline`:return{Icon:ji,title:`Timeline of ${di(n.path)}`,accessibleName:`Timeline of ${n.path}`,hint:`${n.path} · timeline`};default:return{Icon:ac,title:e,hint:e}}}function V_(e){let t=(0,$.c)(44),n,r,i,a,o,s,c,l,u;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]):({changeCount:i,tabs:l,pinned:s,active:r,side:c,leading:o,trailing:u,commitContext:a,...n}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u);let d=c!=null&&`gap-2`,f;t[10]===d?f=t[11]:(f=q(`flex h-12 shrink-0 items-center gap-1.5 border-b px-2.5 text-[length:var(--text-ui)] leading-[1.4]`,d),t[10]=d,t[11]=f);let p;t[12]===o?p=t[13]:(p=o!=null&&(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center`,children:o}),t[12]=o,t[13]=p);let m=c==null?`Open documents`:`Open documents, ${c} pane`,h;t[14]!==n||t[15]!==r||t[16]!==i||t[17]!==s||t[18]!==c||t[19]!==l?(h=l.includes(`handoff`)&&(0,Z.jsx)(`span`,{className:`flex shrink-0`,children:(0,Z.jsx)(W_,{count:s_(i),tabKey:`handoff`,active:r===`handoff`,pinned:!1,hasUnpinned:l.some(e=>!qg(e)&&!s.includes(e)),side:c,...n})}),t[14]=n,t[15]=r,t[16]=i,t[17]=s,t[18]=c,t[19]=l,t[20]=h):h=t[20];let g;t[21]!==n||t[22]!==r||t[23]!==a||t[24]!==s||t[25]!==c||t[26]!==l?(g=l.filter(H_).map((e,t)=>{let i=s.includes(e),o=i&&!s.includes(l[t+1]??``)&&t<l.length-1,u=Wp(e),d={tabKey:e,count:void 0,active:e===r,pinned:i,hasUnpinned:l.some(e=>!qg(e)&&!s.includes(e)),side:c,...n};return(0,Z.jsxs)(`span`,{className:`flex min-w-0 shrink-0 items-center`,children:[a&&u?.kind===`commit`?(0,Z.jsx)(G_,{...d,commitContext:a,oid:u.oid}):(0,Z.jsx)(W_,{...d}),o&&(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-4 w-px shrink-0 bg-border`})]},e)}),t[21]=n,t[22]=r,t[23]=a,t[24]=s,t[25]=c,t[26]=l,t[27]=g):g=t[27];let _;t[28]===g?_=t[29]:(_=(0,Z.jsx)(ri,{"data-tab-viewport":``,className:`size-full overflow-y-hidden`,ref:U_,children:(0,Z.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center gap-1 px-1.5`,children:g})}),t[28]=g,t[29]=_);let v;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)($r,{orientation:`horizontal`,className:`absolute inset-x-0 bottom-0 data-horizontal:h-1.5`}),t[30]=v):v=t[30];let y;t[31]===_?y=t[32]:(y=(0,Z.jsxs)(Fr,{className:`@container/tabs relative h-full min-w-0 flex-1`,children:[_,v]}),t[31]=_,t[32]=y);let b;t[33]!==m||t[34]!==h||t[35]!==y?(b=(0,Z.jsxs)(`div`,{role:`tablist`,"aria-label":m,className:`flex h-full min-w-0 flex-1 items-center gap-1`,children:[h,y]}),t[33]=m,t[34]=h,t[35]=y,t[36]=b):b=t[36];let x;t[37]===u?x=t[38]:(x=u!=null&&(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:u}),t[37]=u,t[38]=x);let S;return t[39]!==b||t[40]!==x||t[41]!==f||t[42]!==p?(S=(0,Z.jsxs)(`div`,{"data-pane-bar":``,className:f,children:[p,b,x]}),t[39]=b,t[40]=x,t[41]=f,t[42]=p,t[43]=S):S=t[43],S}function H_(e){return e!==`handoff`}function U_(e){if(!e)return;let t=()=>z_(e.querySelector(`[role="tab"][aria-selected="true"]`)),n=0,r=new ResizeObserver(()=>{cancelAnimationFrame(n),n=requestAnimationFrame(t)});return r.observe(e),()=>{cancelAnimationFrame(n),r.disconnect()}}function W_(e){let t=(0,$.c)(92),{tabKey:n,count:r,commitSubject:i,active:a,pinned:o,hasUnpinned:s,side:c,onActivate:l,onClose:u,onCloseOthers:d,onCloseUnpinned:f,onTogglePin:p,onOpenToSide:m,onClosePane:h}=e,g;t[0]!==r||t[1]!==n?(g=B_(n,r),t[0]=r,t[1]=n,t[2]=g):g=t[2];let{Icon:_,title:v,hint:y,accessibleName:b}=g,x=b===void 0?v:b,S=(0,Q.useId)(),C=i?`${v} ${i}`:v,w=i?`${y} · ${i}`:y,[T,E]=(0,Q.useState)(!1),D;t[3]===c?D=t[4]:(D=o_(c),t[3]=c,t[4]=D);let O=D,k;t[5]!==l||t[6]!==n?(k=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l(n))},t[5]=l,t[6]=n,t[7]=k):k=t[7];let A=k,j;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{e&&E(!1)},t[8]=j):j=t[8];let M;t[9]===n?M=t[10]:(M=q(`min-w-0 flex-1`,n.startsWith(`file:`)&&`italic`),t[9]=n,t[10]=M);let N=o?`${w} · pinned`:w,P;t[11]!==_||t[12]!==x||t[13]!==A||t[14]!==a||t[15]!==i||t[16]!==r||t[17]!==S||t[18]!==l||t[19]!==u||t[20]!==p||t[21]!==o||t[22]!==n||t[23]!==C||t[24]!==v?(P=e=>(0,Z.jsxs)(Ji,{render:(0,Z.jsx)(`div`,{ref:e=>{a&&z_(e)},role:`tab`,tabIndex:0,"aria-selected":a,"aria-label":i?C:x,"aria-describedby":r?S:void 0,"data-entry":n,className:q(`group flex h-7 min-w-0 max-w-[min(100cqw,calc(var(--spacing)*45))] cursor-default items-center gap-1.5 rounded-md px-2 text-xs font-medium transition-colors`,a?`bg-muted text-foreground ring-1 ring-border ring-inset`:`text-muted-foreground hover:bg-accent/50`,a&&!qg(n)&&!o&&`pr-0.5`),onClick:()=>l(n),onAuxClick:e=>{e.button===1&&!o&&!qg(n)&&(e.preventDefault(),u(n))},onKeyDown:e=>{e.target===e.currentTarget&&A(e)}}),children:[(0,Z.jsx)(_,{className:`size-3.5 shrink-0`,strokeWidth:qg(n)?1.75:void 0}),e,r&&(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-2xs leading-4 whitespace-nowrap text-muted-foreground tabular-nums`,children:r.value}),!qg(n)&&o&&(0,Z.jsxs)(Tn,{disableHoverablePopup:!0,children:[(0,Z.jsx)(rn,{render:(0,Z.jsx)(Y,{type:`button`,"aria-label":`Unpin ${v}`,onClick:e=>{e.stopPropagation(),p(n)},variant:`ghost`,size:`icon-xs`}),children:(0,Z.jsx)(Nr,{className:`size-3`})}),(0,Z.jsx)(bt,{children:`Unpin ${v}`})]}),!qg(n)&&a&&(0,Z.jsxs)(Tn,{disableHoverablePopup:!0,children:[(0,Z.jsx)(rn,{render:(0,Z.jsx)(Y,{type:`button`,"aria-label":`Close ${v}`,onClick:e=>{e.stopPropagation(),u(n)},variant:`ghost`,size:`icon-xs`,className:`mr-0.5`}),children:(0,Z.jsx)(Mt,{className:`size-3`})}),(0,Z.jsxs)(bt,{children:[`Close ${v}`,(0,Z.jsx)(Yn,{children:Ao(yo.closeTab)})]})]})]}),t[11]=_,t[12]=x,t[13]=A,t[14]=a,t[15]=i,t[16]=r,t[17]=S,t[18]=l,t[19]=u,t[20]=p,t[21]=o,t[22]=n,t[23]=C,t[24]=v,t[25]=P):P=t[25];let F;t[26]!==M||t[27]!==N||t[28]!==P||t[29]!==C?(F=(0,Z.jsx)(X,{className:M,text:N,disclose:`always`,renderTrigger:P,children:C}),t[26]=M,t[27]=N,t[28]=P,t[29]=C,t[30]=F):F=t[30];let I=!T,L;t[31]===n?L=t[32]:(L=qg(n),t[31]=n,t[32]=L);let R;t[33]!==p||t[34]!==n?(R=()=>p(n),t[33]=p,t[34]=n,t[35]=R):R=t[35];let z;t[36]===o?z=t[37]:(z=o?(0,Z.jsx)(Dr,{}):(0,Z.jsx)(Nr,{}),t[36]=o,t[37]=z);let B=o?`Unpin`:`Pin`,V;t[38]!==L||t[39]!==R||t[40]!==z||t[41]!==B?(V=(0,Z.jsxs)(Zr,{disabled:L,onClick:R,children:[z,B]}),t[38]=L,t[39]=R,t[40]=z,t[41]=B,t[42]=V):V=t[42];let H=m===void 0,U;t[43]!==m||t[44]!==n?(U=()=>{(0,iu.flushSync)(()=>E(!0)),m?.(n)},t[43]=m,t[44]=n,t[45]=U):U=t[45];let W;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Z.jsx)(Yr,{}),t[46]=W):W=t[46];let G;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)(yr,{children:Ao(yo.openToSide)}),t[47]=G):G=t[47];let ee;t[48]!==O||t[49]!==H||t[50]!==U?(ee=(0,Z.jsxs)(Zr,{disabled:H,onClick:U,children:[W,O,G]}),t[48]=O,t[49]=H,t[50]=U,t[51]=ee):ee=t[51];let te;t[52]===h?te=t[53]:(te=h&&(0,Z.jsxs)(Zr,{onClick:h,children:[(0,Z.jsx)(Yr,{}),`Close pane`]}),t[52]=h,t[53]=te);let ne;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(lr,{}),t[54]=ne):ne=t[54];let re;t[55]===n?re=t[56]:(re=qg(n),t[55]=n,t[56]=re);let ie;t[57]!==u||t[58]!==n?(ie=()=>u(n),t[57]=u,t[58]=n,t[59]=ie):ie=t[59];let ae;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(Mt,{}),t[60]=ae):ae=t[60];let K;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Z.jsx)(yr,{children:Ao(yo.closeTab)}),t[61]=K):K=t[61];let oe;t[62]!==re||t[63]!==ie?(oe=(0,Z.jsxs)(Zr,{disabled:re,onClick:ie,children:[ae,`Close`,K]}),t[62]=re,t[63]=ie,t[64]=oe):oe=t[64];let se;t[65]!==d||t[66]!==n?(se=()=>d(n),t[65]=d,t[66]=n,t[67]=se):se=t[67];let ce;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(Nc,{}),t[68]=ce):ce=t[68];let le;t[69]===se?le=t[70]:(le=(0,Z.jsxs)(Zr,{onClick:se,children:[ce,`Close others`]}),t[69]=se,t[70]=le);let ue=!s,de;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Z.jsx)(Dc,{}),t[71]=de):de=t[71];let J;t[72]!==f||t[73]!==ue?(J=(0,Z.jsxs)(Zr,{disabled:ue,onClick:f,children:[de,`Close unpinned`]}),t[72]=f,t[73]=ue,t[74]=J):J=t[74];let fe;t[75]!==I||t[76]!==V||t[77]!==ee||t[78]!==te||t[79]!==oe||t[80]!==le||t[81]!==J?(fe=(0,Z.jsxs)(Kr,{className:`min-w-52`,finalFocus:I,children:[V,ee,te,ne,oe,le,J]}),t[75]=I,t[76]=V,t[77]=ee,t[78]=te,t[79]=oe,t[80]=le,t[81]=J,t[82]=fe):fe=t[82];let pe;t[83]!==fe||t[84]!==F?(pe=(0,Z.jsxs)(dr,{onOpenChange:j,children:[F,fe]}),t[83]=fe,t[84]=F,t[85]=pe):pe=t[85];let me;t[86]!==r||t[87]!==S?(me=r&&(0,Z.jsx)(`span`,{id:S,hidden:!0,children:r.description}),t[86]=r,t[87]=S,t[88]=me):me=t[88];let he;return t[89]!==pe||t[90]!==me?(he=(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1`,children:[pe,me]}),t[89]=pe,t[90]=me,t[91]=he):he=t[91],he}function G_(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({commitContext:n,oid:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]!==n||t[5]!==r?(a=dh({...n,oid:r,parent:1}),t[4]=n,t[5]=r,t[6]=a):a=t[6];let o=N(a),s;t[7]===o?s=t[8]:(s=Pt(xt(o)),t[7]=o,t[8]=s);let c=s?.commit.subject,l;return t[9]!==c||t[10]!==i?(l=(0,Z.jsx)(W_,{...i,commitSubject:c}),t[9]=c,t[10]=i,t[11]=l):l=t[11],l}function K_(e,t,n){let r=(0,$.c)(13),i;r[0]!==e||r[1]!==n||r[2]!==t?(i=St({connection:e,projectId:t,number:n}),r[0]=e,r[1]=n,r[2]=t,r[3]=i):i=r[3];let{value:a}=as(i),o=ki(e);if(a.kind!==`available`)return;let s;if(r[4]!==o.projects||r[5]!==t||r[6]!==a.pullRequest){let e;r[8]===t?e=r[9]:(e=e=>e.id===t&&e.available,r[8]=t,r[9]=e),s=o.projects.find(e)?.worktrees.find(e=>e.available&&e.branch===a.pullRequest.headBranch),r[4]=o.projects,r[5]=t,r[6]=a.pullRequest,r[7]=s}else s=r[7];let c=s,l;return r[10]!==t||r[11]!==c?(l=c?{projectId:t,worktreeId:c.id}:void 0,r[10]=t,r[11]=c,r[12]=l):l=r[12],l}function q_(e){let t=(0,$.c)(13),{label:n,description:r,icon:i,shortcut:a,onClick:o,disabled:s,pressed:c,variant:l,iconOnly:u}=e,d=s!==void 0&&s,f=l===void 0?`ghost`:l,p=u!==void 0&&u,m;t[0]===p?m=t[1]:(m=p?[`compact`]:[`compact`,`key`,`full`],t[0]=p,t[1]=m);let h;return t[2]!==i||t[3]!==r||t[4]!==d||t[5]!==p||t[6]!==n||t[7]!==o||t[8]!==c||t[9]!==a||t[10]!==m||t[11]!==f?(h=(0,Z.jsx)(Z.Fragment,{children:m.map(e=>(0,Z.jsxs)(Tn,{children:[(0,Z.jsxs)(rn,{render:(0,Z.jsx)(Y,{variant:f,size:e===`compact`?`icon`:`default`,className:q(!p&&e===`compact`&&`@min-lg/pane:hidden`,e===`key`&&`hidden @min-lg/pane:inline-flex @min-3xl/pane:hidden`,e===`full`&&`hidden @min-3xl/pane:inline-flex`),"aria-label":n,"aria-keyshortcuts":a,"aria-pressed":c,disabled:d,focusableWhenDisabled:!0,onClick:o}),children:[c===!1?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`size-3.5 shrink-0 rounded-sm border-[--spacing(0.375)] border-border-strong bg-background`}):(0,Z.jsx)(i,{className:`size-3.5`}),e===`full`&&(0,Z.jsx)(`span`,{children:n}),a&&e!==`compact`&&(0,Z.jsx)(Yn,{children:Ao(a)})]}),(0,Z.jsxs)(bt,{role:`tooltip`,children:[r??n,a&&(0,Z.jsx)(Yn,{children:Ao(a)})]})]},e))}),t[2]=i,t[3]=r,t[4]=d,t[5]=p,t[6]=n,t[7]=o,t[8]=c,t[9]=a,t[10]=m,t[11]=f,t[12]=h):h=t[12],h}function J_(e,t,n){let r=(0,$.c)(4),i=n===void 0?Ki:n,a;return r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=fa({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3],as(a).value}function Y_(e,t,n){let r=(0,$.c)(4),i=n===void 0?Ki:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=fa({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3],ie(a)}function X_(e,t,n,r){let i=(0,$.c)(4),a=J_(e,t),o;return i[0]!==n||i[1]!==r||i[2]!==a?(o=Vr(n,a,r),i[0]=n,i[1]=r,i[2]=a,i[3]=o):o=i[3],o}function Z_(e){let t=(0,$.c)(13),{scope:n,context:r,base:i,children:a}=e,s=Ri(n,r.connection,i);if($t(s.result)){let e;t[0]===s.result.cause?e=t[1]:(e=Zl(Dn(s.result.cause)),t[0]=s.result.cause,t[1]=e);let n;return t[2]!==s.refresh||t[3]!==e?(n=(0,Z.jsx)(Ce,{description:e,onRetry:s.refresh}),t[2]=s.refresh,t[3]=e,t[4]=n):n=t[4],n}if(!gt(s.result)){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(o,{label:`Comparing the branch`}),t[5]=e):e=t[5],e}if(s.result.value.base===void 0){let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(zn,{title:`No default branch`,description:`Choose the branch this one is compared against in the Branch list.`}),t[6]=e):e=t[6],e}let c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(o,{label:`Comparing the branch`}),t[7]=c):c=t[7];let l;t[8]!==s.result.value||t[9]!==a?(l=a(s.result.value),t[8]=s.result.value,t[9]=a,t[10]=l):l=t[10];let u;return t[11]===l?u=t[12]:(u=(0,Z.jsx)(Q.Suspense,{fallback:c,children:l}),t[11]=l,t[12]=u),u}function Q_(e){return e?e.hunks.flatMap(e=>{let t=e.additionStart;return e.hunkContent.flatMap(e=>{if(e.type===`context`)return t+=e.lines,[];let n=t;return t+=e.additions,Array.from({length:e.additions},(e,t)=>`[data-code] [data-line="${n+t}"] { box-shadow: inset calc(var(--spacing) * 0.75) 0 var(--add-fg); }`)})}).join(`
|
|
24
|
+
`):``}function $_(e,t,n,r){return{id:e,kind:`file`,path:t,contents:n,version:Io(n),...r?{note:r}:{}}}var ev=new Map,tv=new Map;function nv(e){if(e.kind===`diff`){let t=ev.get(e.id);return t?.cacheKey!==void 0&&t.cacheKey===e.fileDiff.cacheKey?{type:`diff`,fileDiff:t}:(ev.set(e.id,e.fileDiff),{type:`diff`,fileDiff:e.fileDiff})}let t=tv.get(e.id);if(t?.name===e.path&&t.contents===e.contents)return{type:`file`,file:t};let n={name:e.path,contents:e.contents};return tv.set(e.id,n),{type:`file`,file:n}}function rv(e){let t=new Map;for(let n of e){let e=t.get(n.path)??{additions:0,deletions:0},r=iv(n);e.additions+=r.additions,e.deletions+=r.deletions,t.set(n.path,e)}return t}function iv(e){return e.kind===`file`?{additions:e.contents.split(`
|
|
25
|
+
`).filter((e,t,n)=>t<n.length-1||e).length,deletions:0}:e.fileDiff.hunks.reduce((e,t)=>({additions:e.additions+t.additionLines,deletions:e.deletions+t.deletionLines}),{additions:0,deletions:0})}function av(e,t,n){let r=(0,$.c)(9),i=n===void 0?Ki:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=fi({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3];let o=a.set,s;r[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={mode:`promiseExit`},r[4]=s):s=r[4];let[l,u]=L(o,s),d=c(o),f;return r[5]!==l||r[6]!==u||r[7]!==d?(f={result:l,submit:u,start:d},r[5]=l,r[6]=u,r[7]=d,r[8]=f):f=r[8],f}function ov(e,t,n){let r=(0,$.c)(9),i=n===void 0?Ki:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=fi({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3];let o=a.remove,s;r[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={mode:`promiseExit`},r[4]=s):s=r[4];let[l,u]=L(o,s),d=c(o),f;return r[5]!==l||r[6]!==u||r[7]!==d?(f={result:l,submit:u,start:d},r[5]=l,r[6]=u,r[7]=d,r[8]=f):f=r[8],f}function sv(e,t,n){let r=(0,$.c)(10),i=n===void 0?Ki:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=fi({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3];let[o,s]=L(a.bulk),c;r[4]===o?c=r[5]:(c=Pt(xt(o)),r[4]=o,r[5]=c);let l=c,u=!o.waiting&&l?.kind===`mark`?l.report:null,d;return r[6]!==o||r[7]!==s||r[8]!==u?(d={result:o,report:u,start:s},r[6]=o,r[7]=s,r[8]=u,r[9]=d):d=r[9],d}function cv(e,t,n,r){let i=(0,$.c)(4),a=r===void 0?Ki:r,o=av(e,t,a),s=ov(e,t,a),c;return i[0]!==o||i[1]!==n||i[2]!==s?(c={toggle(e){let t=oi(e,o.result.waiting||s.result.waiting);t&&(t.kind===`unmark`?s.submit(t.path):o.submit(t.input)).then(e=>{en(e)&&n({title:`Could not update review`,description:la(Dn(e.cause)),type:`error`})})}},i[0]=o,i[1]=n,i[2]=s,i[3]=c):c=i[3],c}function lv(e){let t=(0,$.c)(7),{counts:n}=e,r;t[0]===n.additions?r=t[1]:(r=(0,Z.jsxs)(`span`,{className:`text-add-fg`,children:[`+`,n.additions]}),t[0]=n.additions,t[1]=r);let i;t[2]===n.deletions?i=t[3]:(i=(0,Z.jsxs)(`span`,{className:`text-del-fg`,children:[`−`,n.deletions]}),t[2]=n.deletions,t[3]=i);let a;return t[4]!==r||t[5]!==i?(a=(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-xs leading-4 font-medium tabular-nums`,children:[r,` `,i]}),t[4]=r,t[5]=i,t[6]=a):a=t[6],a}function uv(e){if(!(!e||e.side===`deletions`||e.endSide!==void 0&&e.endSide!==e.side))return{startLine:Math.min(e.start,e.end),endLine:Math.max(e.start,e.end)}}function dv(e){let t=(0,$.c)(10),n=cv(e.scope,e.context,fv,e.range),r;t[0]!==e.interaction.entry||t[1]!==e.range?(r=JSON.stringify([e.interaction.entry,e.range]),t[0]=e.interaction.entry,t[1]=e.range,t[2]=r):r=t[2];let i;t[3]!==e.onReview||t[4]!==n?(i=e.onReview??(e=>n.toggle(e.review)),t[3]=e.onReview,t[4]=n,t[5]=i):i=t[5];let a;return t[6]!==e||t[7]!==r||t[8]!==i?(a=(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(pv,{...e,onToggleReviewed:i},r)}),t[6]=e,t[7]=r,t[8]=i,t[9]=a):a=t[9],a}function fv(e){return xo.add(e)}function pv(e){let t=(0,$.c)(117),{entries:n,scope:r,context:i,interaction:a,header:o,footer:s,headerLeading:c,headerActions:l,emptyActions:u,toolbar:d,foundLine:p,disableFileHeader:m,fileDiff:h,compactThreads:_,fullHeight:v,compactHeight:y,collapsible:b,decision:x,column:S,framed:C,range:w,onToggleReviewed:T}=e,E=m!==void 0&&m,D=_!==void 0&&_,O=v!==void 0&&v,k=y!==void 0&&y,A=b!==void 0&&b,j=x!==void 0&&x,M=S!==void 0&&S,N=C!==void 0&&C,{dark:P}=To(),{preferences:F}=Ha(),I=Ss(i.connection),L=j?n:tu(n,I),z=S_(a.worktreeId,a.entry),B;t[0]!==i.connection.environmentId||t[1]!==a.entry||t[2]!==a.worktreeId||t[3]!==w?(B=JSON.stringify([i.connection.environmentId,a.worktreeId,a.entry,w]),t[0]=i.connection.environmentId,t[1]=a.entry,t[2]=a.worktreeId,t[3]=w,t[4]=B):B=t[4];let V=E_(B),H;t[5]===V?H=t[6]:(H=()=>V.selection(),t[5]=V,t[6]=H);let[U,W]=(0,Q.useState)(H),G=U?L.find(e=>e.id===U.lines.id):void 0,ee=U!==null&&G?.version!==U.version,te=ee?null:U?.lines??null,ne=e=>{let t=e?L.find(t=>t.id===e.id):void 0,n=e&&t?{lines:e,version:t.version}:null;W(n),V.rememberSelection(n)},re=te?.range,ie;t[7]===re?ie=t[8]:(ie=uv(re),t[7]=re,t[8]=ie);let ae=ie,K;t[9]===V?K=t[10]:(K=()=>V.focused(),t[9]=V,t[10]=K);let[oe,se]=(0,Q.useState)(K),ce;t[11]===V?ce=t[12]:(ce=e=>{se(e),V.rememberFocus(e)},t[11]=V,t[12]=ce);let le=ce,ue;t[13]===oe?ue=t[14]:(ue=e=>e.id===oe,t[13]=oe,t[14]=ue);let de=Math.max(L.findIndex(ue),0),J=new Set(L.filter(e=>d_(z.folds,e.id,L.length>1&&e.review?.reviewed===!0||(A||L.length>1)&&I&&eu(e.path))).map(vv)),[fe,pe]=(0,Q.useState)(),[me,he]=(0,Q.useState)(),ge=e=>{let t=L[e];t&&(le(t.id),V.scrollTo({type:`item`,id:t.id,align:`start`}))},_e=new Map(L.map(_v)),ve=L.map(e=>({id:e.id,collapsed:J.has(e.id),version:Io(JSON.stringify([e.version,J.has(e.id)])),...nv(e)})),ye=L.filter(gv),be=new Set(ye.map(hv)).size,xe=ye[0]?.id,Se=new Map;for(let e of L)e.review&&!Se.has(e.review.path)&&Se.set(e.review.path,e.id);let Ce=O||s?12:160,we=j||M||D||N?ns:ms,Te=P?`dark`:`light`,Ee=F.lineOverflow,De=F.diffStyle,Oe=!E&&!O,ke=E||k,je,Me;t[15]===le?(je=t[16],Me=t[17]):(je=(e,t)=>le(t.item.id),Me=(e,t)=>le(t.item.id),t[15]=le,t[16]=je,t[17]=Me);let Ne;t[18]===h?Ne=t[19]:(Ne=Q_(h),t[18]=h,t[19]=Ne);let Pe=`${D?`[data-line-annotation]:has([data-file-thread-marker]) { margin-left: 0; }`:``}${Ne}${j||M||N?_s:``}${M?Bo:``}${is}${E||k?`[data-code] { padding-top: 0 !important; }`:Go}${D?ps:``}${k?`[data-diffs-header], pre { border: 0; border-radius: 0; }`:``}`,Fe;t[20]===M?Fe=t[21]:(Fe=M?{itemMetrics:{lineHeight:22,diffHeaderHeight:41}}:{},t[20]=M,t[21]=Fe);let Ie;t[22]!==k||t[23]!==E?(Ie=E||k?{itemMetrics:{paddingTop:0}}:{},t[22]=k,t[23]=E,t[24]=Ie):Ie=t[24];let Le=E||k?0:12,Re=k?0:Ce,ze;t[25]!==Le||t[26]!==Re?(ze={paddingTop:Le,paddingBottom:Re,gap:12},t[25]=Le,t[26]=Re,t[27]=ze):ze=t[27];let Be;t[28]!==F.diffStyle||t[29]!==F.lineOverflow||t[30]!==we||t[31]!==Te||t[32]!==Oe||t[33]!==ke||t[34]!==je||t[35]!==Me||t[36]!==Pe||t[37]!==Fe||t[38]!==Ie||t[39]!==ze?(Be={preferredHighlighter:Mo,theme:we,themeType:Te,overflow:Ee,diffStyle:De,diffIndicators:`classic`,hunkSeparators:`line-info`,stickyHeaders:Oe,disableFileHeader:ke,enableLineSelection:!0,enableGutterUtility:!1,onLineClick:je,onLineNumberClick:Me,lineHoverHighlight:`number`,unsafeCSS:Pe,...Fe,...Ie,layout:ze},t[28]=F.diffStyle,t[29]=F.lineOverflow,t[30]=we,t[31]=Te,t[32]=Oe,t[33]=ke,t[34]=je,t[35]=Me,t[36]=Pe,t[37]=Fe,t[38]=Ie,t[39]=ze,t[40]=Be):Be=t[40];let Ve=Be,He=L.length>0&&L.every(e=>J.has(e.id)),Ue;t[41]!==L||t[42]!==z?(Ue=e=>z.setCollapsed(L.map(mv),e),t[41]=L,t[42]=z,t[43]=Ue):Ue=t[43];let We=Ue,Ge=e=>{le(e),z.setCollapsed([e],!J.has(e))},Ke;t[44]===He?Ke=t[45]:(Ke=He?(0,Z.jsx)($s,{"aria-hidden":`true`,"data-icon":`inline-start`}):(0,Z.jsx)(Zs,{"aria-hidden":`true`,"data-icon":`inline-start`}),t[44]=He,t[45]=Ke);let qe=Ke,Je=He?`Expand all files`:`Collapse all files`,Ye;t[46]!==He||t[47]!==We?(Ye=()=>We(!He),t[46]=He,t[47]=We,t[48]=Ye):Ye=t[48];let Xe;t[49]!==qe||t[50]!==Je||t[51]!==Ye?(Xe=(0,Z.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:Ye,children:[qe,Je]}),t[49]=qe,t[50]=Je,t[51]=Ye,t[52]=Xe):Xe=t[52];let Ze=Xe,Qe=L.length>1?Ze:null,$e;t[53]!==a.entry||t[54]!==a.singleHeader||t[55]!==a.toolbarTarget?($e=a.toolbarTarget!==void 0&&(/^(file|review-file|review-change|change|branch|walkthrough-step):/.test(a.entry)||a.singleHeader&&a.entry===`branch`),t[53]=a.entry,t[54]=a.singleHeader,t[55]=a.toolbarTarget,t[56]=$e):$e=t[56];let et=$e,tt=L[de]??L[0],nt;t[57]!==u||t[58]!==tt||t[59]!==l||t[60]!==T||t[61]!==et?(nt=et&&(tt?(0,Z.jsxs)(Z.Fragment,{children:[tt.review&&(0,Z.jsx)(q_,{label:`Reviewed`,variant:`outline`,icon:tt?.review?.reviewed?g:Fc,shortcut:yo.toggleReviewed,disabled:!tt?.review?.fingerprint,pressed:tt?.review?.reviewed,onClick:()=>{tt&&T(tt)}}),l]}):u??l),t[57]=u,t[58]=tt,t[59]=l,t[60]=T,t[61]=et,t[62]=nt):nt=t[62];let rt=nt,it;t[63]!==Qe||t[64]!==L||t[65]!==ge||t[66]!==de||t[67]!==z||t[68]!==o?(it=o&&(()=>o({collapse:Qe,current:L[de]?.path,counts:rv(L),open:e=>{let t=L.findIndex(t=>t.path===e),n=L[t];n&&z.setCollapsed([n.id],!1),ge(t)}})),t[63]=Qe,t[64]=L,t[65]=ge,t[66]=de,t[67]=z,t[68]=o,t[69]=it):it=t[69];let at=it,ot=(j||M||D||N)&&`decision-code`,st=D&&`file-code`,ct=N&&`commit-code`,lt=k&&`overflow-hidden rounded-lg border`,ut;t[70]!==ot||t[71]!==st||t[72]!==ct||t[73]!==lt?(ut=q(`@container/code relative flex min-h-0 flex-1 flex-col`,ot,st,ct,lt),t[70]=ot,t[71]=st,t[72]=ct,t[73]=lt,t[74]=ut):ut=t[74];let dt;t[75]!==a.toolbarTarget||t[76]!==rt?(dt=a.toolbarTarget&&rt&&(0,iu.createPortal)(rt,a.toolbarTarget),t[75]=a.toolbarTarget,t[76]=rt,t[77]=dt):dt=t[77];let ft;t[78]!==L||t[79]!==ge||t[80]!==de||t[81]!==a.active||t[82]!==T?(ft=a.active&&L.length>0&&(0,Z.jsx)(bv,{next:()=>ge(Math.min(de+1,L.length-1)),previous:()=>ge(Math.max(de-1,0)),review:()=>{let e=L[de];e?.review&&T(e)}}),t[78]=L,t[79]=ge,t[80]=de,t[81]=a.active,t[82]=T,t[83]=ft):ft=t[83];let pt;t[84]===ee?pt=t[85]:(pt=ee&&(0,Z.jsx)(`p`,{role:`status`,className:`absolute bottom-3 left-3 z-10 rounded-lg border bg-popover p-2 text-xs`,children:`Code changed since these lines were selected. Select lines again.`}),t[84]=ee,t[85]=pt);let mt;t[86]!==ae||t[87]!==i||t[88]!==r||t[89]!==G?(mt=ae&&G?.discardScope&&(0,Z.jsx)(`div`,{className:`absolute bottom-3 left-3 z-10 rounded-lg border bg-popover p-2`,children:(0,Z.jsx)(Tm,{scope:r,context:i,path:G.path,hunk:{scope:G.discardScope,...ae},variant:`compact`})}),t[86]=ae,t[87]=i,t[88]=r,t[89]=G,t[90]=mt):mt=t[90];let ht;t[91]!==Qe||t[92]!==M||t[93]!==d?(ht=d?d(Qe):!M&&Qe&&(0,Z.jsx)(`div`,{className:`flex shrink-0 justify-end px-3`,children:Qe}),t[91]=Qe,t[92]=M,t[93]=d,t[94]=ht):ht=t[94];let gt;t[95]!==M||t[96]!==L.length||t[97]!==s||t[98]!==o||t[99]!==l||t[100]!==c||t[101]!==et||t[102]!==at?(gt=L.length===0&&(o||l||s)&&(0,Z.jsxs)(`div`,{className:q(`min-h-0 flex-1 overflow-auto`,M&&yv),"data-testid":`empty-code-document`,children:[c&&(0,Z.jsx)(`div`,{className:`flex items-center gap-1 px-3.5 py-2`,children:c}),at?.(),s?.(),!et&&l&&(0,Z.jsx)(`div`,{className:`flex justify-end px-3.5 py-2`,children:(0,Z.jsx)(Mm,{children:l})})]}),t[95]=M,t[96]=L.length,t[97]=s,t[98]=o,t[99]=l,t[100]=c,t[101]=et,t[102]=at,t[103]=gt):gt=t[103];let _t;t[104]!==k||t[105]!==L[0]?(_t=k&&L[0]&&(0,Z.jsx)(`div`,{className:`flex min-h-10 shrink-0 items-center gap-2 border-b bg-muted px-2 py-1`,children:(0,Z.jsx)(X,{className:`min-w-0 flex-1 font-mono text-caption font-medium`,text:L[0].path})}),t[104]=k,t[105]=L[0],t[106]=_t):_t=t[106];let vt=L.length>0&&(0,Z.jsx)(pp,{ref:e=>{if(!e)return;let t=e.getInstance();if(!t)return;let n=V.attach(t),r=requestAnimationFrame(()=>{V.restorePosition(t,Ve.stickyHeaders&&!Ve.disableFileHeader?Ve.itemMetrics?.diffHeaderHeight??Ga.diffHeaderHeight:0);let n=a.fileTarget,r=n?L.find(e=>e.path===n.path):void 0;n&&r&&n.nonce!==me&&(z.setCollapsed([r.id],!1),e.scrollTo({type:`item`,id:r.id,align:`start`}),le(r.id),he(n.nonce));let i=L[0];p&&i&&fe!==p.nonce&&(ne({id:i.id,range:{start:p.line,end:p.line}}),e.scrollTo({type:`line`,id:i.id,lineNumber:p.line,align:`center`}),pe(p.nonce))});return()=>{cancelAnimationFrame(r),n?.()}},items:ve,onScroll:V.rememberPosition,selectedLines:te,onSelectedLinesChange:e=>{ne(e),e&&le(e.id)},renderHeaderMetadata:e=>{let t=_e.get(e.id);if(E||!t)return null;let n=e.id===L[0]?.id,r=!et&&n?l:null,i=e.id===L[0]?.id?c:null,a=t.review?.stale?(0,Z.jsx)(`span`,{className:`rounded-md bg-graph-4/15 px-1.5 py-0.5 font-sans text-2xs text-graph-4`,children:`Changed since reviewed`}):null;return M?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[a,(0,Z.jsx)(lv,{counts:iv(t)})]}):!a&&!i&&!r?null:(0,Z.jsxs)(`div`,{className:q(`flex max-w-full items-center justify-end gap-1.5`,!j&&`flex-wrap`),children:[a,i,r&&(0,Z.jsx)(Mm,{children:r})]})},disableWorkerPool:j||M||D||N,options:Ve,className:q(k&&`max-h-48 flex-none overflow-auto`,!k&&O&&`flex-none overflow-visible`,!k&&!O&&`min-h-0 flex-1 overflow-auto`,M&&yv),...at?{renderCodeViewHeader:at}:{},...s?{renderCodeViewFooter:s}:{},renderHeaderPrefix:e=>{let t=_e.get(e.id);if(!t)return null;let n=J.has(e.id),r=t.review,i=r&&!et&&Se.get(r.path)===t.id?r.control:null;return(0,Z.jsxs)(`span`,{className:q(`flex items-center`,M?`gap-2`:`gap-1`),children:[!j&&I&&e.id===xe&&L.length>ye.length&&(0,Z.jsxs)(`span`,{className:`mr-2 border-r pr-2 font-sans text-xs font-medium`,children:[`Specs · `,R(be,`file`)]}),(M||A||L.length>1)&&(0,Z.jsx)(xv,{label:`${n?`Expand`:`Collapse`} ${t.path}`,icon:n?f:Ae,expanded:!n,onClick:()=>Ge(e.id)}),i]})},renderHeaderFilenameSuffix:e=>{let t=_e.get(e.id);return t&&t.note?(0,Z.jsx)(X,{className:`ml-2 hidden max-w-48 font-sans text-xs text-muted-foreground @code-wide/code:block`,text:t.note}):null}}),yt;return t[107]!==ut||t[108]!==dt||t[109]!==ft||t[110]!==pt||t[111]!==mt||t[112]!==ht||t[113]!==gt||t[114]!==_t||t[115]!==vt?(yt=(0,Z.jsxs)(`div`,{role:`region`,"aria-label":`Code content`,className:ut,children:[dt,ft,pt,mt,ht,gt,_t,vt]}),t[107]=ut,t[108]=dt,t[109]=ft,t[110]=pt,t[111]=mt,t[112]=ht,t[113]=gt,t[114]=_t,t[115]=vt,t[116]=yt):yt=t[116],yt}function mv(e){return e.id}function hv(e){return e.path}function gv(e){return eu(e.path)}function _v(e){return[e.id,e]}function vv(e){return e.id}var yv=`px-[max(--spacing(4),calc((100%-var(--container-reading))/2))] @2xl/pane:px-[max(--spacing(7),calc((100%-var(--container-reading))/2))]`;function bv(e){let t=(0,$.c)(1),{next:n,previous:r,review:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={ignoreInputs:!0},t[0]=a):a=t[0];let o=a;return Co(yo.nextFile,n,o),Co(yo.previousFile,r,o),Co(yo.toggleReviewed,i,o),null}function xv(e){let t=(0,$.c)(14),{label:n,icon:r,expanded:i,onClick:a}=e,o;t[0]!==i||t[1]!==n||t[2]!==a?(o=(0,Z.jsx)(Y,{size:`icon-xs`,variant:`ghost`,"aria-label":n,"aria-expanded":i,onClick:a}),t[0]=i,t[1]=n,t[2]=a,t[3]=o):o=t[3];let s;t[4]===r?s=t[5]:(s=(0,Z.jsx)(r,{}),t[4]=r,t[5]=s);let c;t[6]!==o||t[7]!==s?(c=(0,Z.jsx)(rn,{render:o,children:s}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===n?l=t[10]:(l=(0,Z.jsx)(bt,{children:n}),t[9]=n,t[10]=l);let u;return t[11]!==c||t[12]!==l?(u=(0,Z.jsxs)(Tn,{children:[c,l]}),t[11]=c,t[12]=l,t[13]=u):u=t[13],u}function Sv(e){let t=(0,$.c)(51),{target:n,barActions:r,title:i,titleLabel:a,subtitle:o,children:s,className:c,inline:l}=e;if(l!==void 0&&l){let e=a??(typeof i==`string`?i:``),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`h1`,{}),t[0]=n):n=t[0];let r;t[1]!==e||t[2]!==i?(r=(0,Z.jsx)(X,{text:e,render:n,className:`min-w-0 text-ui font-semibold`,children:i}),t[1]=e,t[2]=i,t[3]=r):r=t[3];let c;t[4]===o?c=t[5]:(c=o&&(0,Z.jsx)(`span`,{className:`shrink-0 text-caption text-muted-foreground`,children:o}),t[4]=o,t[5]=c);let l;t[6]!==r||t[7]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-64 items-baseline gap-2`,children:[r,c]}),t[6]=r,t[7]=c,t[8]=l):l=t[8];let u;t[9]===s?u=t[10]:(u=(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:s}),t[9]=s,t[10]=u);let d;return t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(`header`,{"data-testid":`document-toolbar`,className:`flex min-h-11 shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b px-4 py-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}if(n!==void 0){let e;t[14]!==r||t[15]!==s||t[16]!==n?(e=n&&(0,iu.createPortal)(r===void 0?s:r,n),t[14]=r,t[15]=s,t[16]=n,t[17]=e):e=t[17];let c=a??(typeof i==`string`?i:``),l;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`h1`,{}),t[18]=l):l=t[18];let u;t[19]!==c||t[20]!==i?(u=(0,Z.jsx)(X,{text:c,render:l,className:`text-ui font-semibold`,children:i}),t[19]=c,t[20]=i,t[21]=u):u=t[21];let d;t[22]===o?d=t[23]:(d=o&&(0,Z.jsx)(`p`,{className:`text-2xs text-muted-foreground`,children:o}),t[22]=o,t[23]=d);let f;t[24]!==r||t[25]!==s?(f=r!==void 0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:s}),t[24]=r,t[25]=s,t[26]=f):f=t[26];let p;t[27]!==u||t[28]!==d||t[29]!==f?(p=(0,Z.jsxs)(`div`,{className:`shrink-0 px-3.5 py-2`,children:[u,d,f]}),t[27]=u,t[28]=d,t[29]=f,t[30]=p):p=t[30];let m;return t[31]!==e||t[32]!==p?(m=(0,Z.jsxs)(Z.Fragment,{children:[e,p]}),t[31]=e,t[32]=p,t[33]=m):m=t[33],m}let u;t[34]===c?u=t[35]:(u=q(`flex min-h-11 shrink-0 flex-wrap items-center gap-x-2.5 gap-y-1 border-b px-3.5`,c),t[34]=c,t[35]=u);let d=a??(typeof i==`string`?i:``),f;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(`h1`,{}),t[36]=f):f=t[36];let p;t[37]!==d||t[38]!==i?(p=(0,Z.jsx)(X,{text:d,render:f,className:`text-ui leading-tight font-semibold`,children:i}),t[37]=d,t[38]=i,t[39]=p):p=t[39];let m;t[40]===o?m=t[41]:(m=o!=null&&(0,Z.jsx)(X,{text:o,render:(0,Z.jsx)(`p`,{}),className:`text-2xs leading-tight text-muted-foreground`}),t[40]=o,t[41]=m);let h;t[42]!==p||t[43]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-auto flex-col`,children:[p,m]}),t[42]=p,t[43]=m,t[44]=h):h=t[44];let g;t[45]===s?g=t[46]:(g=(0,Z.jsx)(`div`,{className:`ml-auto flex max-w-full shrink-0 flex-wrap items-center justify-end gap-1.5`,children:s}),t[45]=s,t[46]=g);let _;return t[47]!==u||t[48]!==h||t[49]!==g?(_=(0,Z.jsxs)(`header`,{"data-testid":`document-toolbar`,className:u,children:[h,g]}),t[47]=u,t[48]=h,t[49]=g,t[50]=_):_=t[50],_}function Cv(e){let t=(0,$.c)(4),{more:n,pending:r,onReadMore:i}=e;if(n<=0)return null;let a=r?`Reading…`:`Read ${Math.min(n,25)} more of ${n}`,o;return t[0]!==i||t[1]!==r||t[2]!==a?(o=(0,Z.jsx)(`div`,{className:`border-t px-4 py-3 text-center`,children:(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,onClick:i,disabled:r,children:a})}),t[0]=i,t[1]=r,t[2]=a,t[3]=o):o=t[3],o}function wv(e,t,n){return{path:n.path,fingerprint:n.fingerprint??null,reviewed:n.reviewStatus===`reviewed`,stale:n.reviewStatus===`stale`,control:(0,Z.jsx)(Tv,{scope:e,context:t,path:n.path,fingerprint:n.fingerprint,status:n.reviewStatus,compact:!0},`review:${n.path}`)}}function Tv(e){let t=(0,$.c)(45),{scope:n,context:r,path:i,fingerprint:a,status:o,compact:s,range:c}=e,l=s!==void 0&&s,u=c===void 0?Ki:c,d=av(n,r,u),f=ov(n,r,u),p=d.result.waiting||f.result.waiting,m,h;if(t[0]!==l||t[1]!==a||t[2]!==d||t[3]!==i||t[4]!==p||t[5]!==o||t[6]!==f){h=Symbol.for(`react.early_return_sentinel`);bb0:{let e=ma(d.result,f.result);if(a==null){let e;t[9]===i?e=t[10]:(e=pa([i]),t[9]=i,t[10]=e);let n;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(ga,{className:`size-3`,"aria-hidden":`true`}),t[11]=n):n=t[11];let r=l?`Not reviewable`:`Not reviewable: too large or unreadable`,a;t[12]!==e||t[13]!==r?(a=(0,Z.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1 text-2xs text-muted-foreground`,children:[n,r]}),t[12]=e,t[13]=r,t[14]=a):a=t[14],h=a;break bb0}let n=o===`reviewed`,r;t[15]!==i||t[16]!==o?(r=oa(i,o),t[15]=i,t[16]=o,t[17]=r):r=t[17];let s=r,c=l?`icon-xs`:`xs`,u=n?`ghost`:`outline`,g;t[18]!==a||t[19]!==d||t[20]!==i||t[21]!==n||t[22]!==f?(g=()=>{n?f.start(i):d.start({path:i,fingerprint:a})},t[18]=a,t[19]=d,t[20]=i,t[21]=n,t[22]=f,t[23]=g):g=t[23];let _;t[24]!==l||t[25]!==p||t[26]!==o?(_=(0,Z.jsx)(Ov,{pending:p,status:o,compact:l}),t[24]=l,t[25]=p,t[26]=o,t[27]=_):_=t[27];let v;t[28]!==l||t[29]!==o?(v=!l&&kv(o),t[28]=l,t[29]=o,t[30]=v):v=t[30];let y;t[31]!==s||t[32]!==p||t[33]!==n||t[34]!==v||t[35]!==c||t[36]!==u||t[37]!==g||t[38]!==_?(y=(0,Z.jsx)(rn,{render:(0,Z.jsxs)(Y,{type:`button`,size:c,variant:u,"aria-pressed":n,disabled:p,"aria-label":s,onClick:g,children:[_,v]})}),t[31]=s,t[32]=p,t[33]=n,t[34]=v,t[35]=c,t[36]=u,t[37]=g,t[38]=_,t[39]=y):y=t[39];let b;t[40]===s?b=t[41]:(b=(0,Z.jsx)(bt,{role:`tooltip`,className:`break-all`,children:s}),t[40]=s,t[41]=b);let x;t[42]!==y||t[43]!==b?(x=(0,Z.jsxs)(Tn,{children:[y,b]}),t[42]=y,t[43]=b,t[44]=x):x=t[44],m=(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[x,e!==void 0&&(0,Z.jsx)(X,{className:`max-w-52 text-2xs text-destructive`,render:(0,Z.jsx)(`span`,{role:`alert`}),text:la(e)})]})}t[0]=l,t[1]=a,t[2]=d,t[3]=i,t[4]=p,t[5]=o,t[6]=f,t[7]=m,t[8]=h}else m=t[7],h=t[8];return h===Symbol.for(`react.early_return_sentinel`)?m:h}function Ev(e){let t=(0,$.c)(23),{scope:n,context:r,path:i,fingerprint:a,status:o,latest:s,onStart:c}=e,l=av(n,r,Ki),u=ov(n,r,Ki),d=l.result.waiting||u.result.waiting,f=ma(l.result,u.result),p=s?f:void 0,m=(0,Q.useId)(),h=o===`reviewed`,g=a!=null,_=o===`stale`?`Changed since reviewed`:`Toggle reviewed`,v;t[0]!==i||t[1]!==g||t[2]!==_?(v=g?_:pa([i]),t[0]=i,t[1]=g,t[2]=_,t[3]=v):v=t[3];let y=v,b=`${i} reviewed`,x=p!==void 0,S=d||!g,C;t[4]!==d||t[5]!==a||t[6]!==l||t[7]!==c||t[8]!==i||t[9]!==h||t[10]!==u?(C=()=>{d||a==null||(c(),h?u.start(i):l.start({path:i,fingerprint:a}))},t[4]=d,t[5]=a,t[6]=l,t[7]=c,t[8]=i,t[9]=h,t[10]=u,t[11]=C):C=t[11];let w;t[12]!==d||t[13]!==m||t[14]!==h||t[15]!==b||t[16]!==x||t[17]!==S||t[18]!==C?(w=(0,Z.jsx)(rn,{render:(0,Z.jsx)(Xm,{checked:h,"aria-label":b,"aria-describedby":m,"aria-invalid":x,disabled:S,"aria-busy":d,onCheckedChange:C})}),t[12]=d,t[13]=m,t[14]=h,t[15]=b,t[16]=x,t[17]=S,t[18]=C,t[19]=w):w=t[19];let T;return t[20]!==y||t[21]!==m?(T=(0,Z.jsx)(`span`,{id:m,hidden:!0,children:y}),t[20]=y,t[21]=m,t[22]=T):T=t[22],(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Tn,{children:[w,(0,Z.jsx)(bt,{role:`tooltip`,className:`break-all`,children:p===void 0?y:la(p)})]}),T,p!==void 0&&(0,Z.jsx)(`span`,{role:`alert`,className:`sr-only`,children:la(p)})]})}function Dv(e){let t=(0,$.c)(44),{scope:n,context:r,entries:i,compact:a,range:o}=e,s=a!==void 0&&a,c=sv(n,r,o===void 0?Ki:o),l,u,d,f,p,m,h,g,_,v,y,b,x;if(t[0]!==c||t[1]!==s||t[2]!==i){f=Ci(i);let e=c.result.waiting,n=f.blocked||e;m=`inline-flex min-w-0 flex-col items-end gap-1`,d=Tn,u=rn,l=Y,h=`button`,g=s?`icon-xs`:`xs`,_=`outline`,v=n,y=f.label,b=()=>{n||(f.unmarking?c.start({kind:`unmark`,paths:f.reviewedPaths}):c.start({kind:`mark`,entries:f.entries}))},x=(0,Z.jsx)(Av,{pending:e,unmarking:f.unmarking}),p=!s&&jv(e,f.unmarking,f.text),t[0]=c,t[1]=s,t[2]=i,t[3]=l,t[4]=u,t[5]=d,t[6]=f,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=y,t[14]=b,t[15]=x}else l=t[3],u=t[4],d=t[5],f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],v=t[12],y=t[13],b=t[14],x=t[15];let S;t[16]!==l||t[17]!==p||t[18]!==h||t[19]!==g||t[20]!==_||t[21]!==v||t[22]!==y||t[23]!==b||t[24]!==x?(S=(0,Z.jsxs)(l,{type:h,size:g,variant:_,disabled:v,"aria-label":y,onClick:b,children:[x,p]}),t[16]=l,t[17]=p,t[18]=h,t[19]=g,t[20]=_,t[21]=v,t[22]=y,t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]!==u||t[27]!==S?(C=(0,Z.jsx)(u,{render:S}),t[26]=u,t[27]=S,t[28]=C):C=t[28];let w;t[29]===f.label?w=t[30]:(w=(0,Z.jsx)(bt,{role:`tooltip`,className:`break-all`,children:f.label}),t[29]=f.label,t[30]=w);let T;t[31]!==d||t[32]!==C||t[33]!==w?(T=(0,Z.jsxs)(d,{children:[C,w]}),t[31]=d,t[32]=C,t[33]=w,t[34]=T):T=t[34];let E;t[35]===c.report?E=t[36]:(E=c.report&&(0,Z.jsx)(Mv,{report:c.report}),t[35]=c.report,t[36]=E);let D;t[37]===c.result?D=t[38]:(D=$t(c.result)&&(0,Z.jsx)(`span`,{role:`alert`,className:`max-w-64 text-right text-2xs text-destructive`,children:la(Dn(c.result.cause))}),t[37]=c.result,t[38]=D);let O;return t[39]!==m||t[40]!==T||t[41]!==E||t[42]!==D?(O=(0,Z.jsxs)(`span`,{className:m,children:[T,E,D]}),t[39]=m,t[40]=T,t[41]=E,t[42]=D,t[43]=O):O=t[43],O}function Ov(e){let t=(0,$.c)(7),{pending:n,status:r,compact:i}=e;if(n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(dt,{className:`animate-spin`}),t[0]=e):e=t[0],e}if(r===`reviewed`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(g,{}),t[1]=e):e=t[1],e}if(r===`stale`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(cs,{}),t[2]=e):e=t[2],e}let a=i&&`invisible`,o;t[3]===a?o=t[4]:(o=q(a),t[3]=a,t[4]=o);let s;return t[5]===o?s=t[6]:(s=(0,Z.jsx)(g,{className:o}),t[5]=o,t[6]=s),s}function kv(e){return e===`reviewed`?`Reviewed`:e===`stale`?`Review again`:`Mark reviewed`}function Av(e){let t=(0,$.c)(3),{pending:n,unmarking:r}=e;if(n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(dt,{className:`animate-spin`}),t[0]=e):e=t[0],e}if(r){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(cs,{}),t[1]=e):e=t[1],e}let i;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(g,{}),t[2]=i):i=t[2],i}function jv(e,t,n){return e?t?`Unmarking…`:`Marking…`:n}function Mv(e){let t=(0,$.c)(11),{report:n}=e,r=n.failed.length,i=r>0?`alert`:`status`,a=r>0?`text-destructive`:`text-muted-foreground`,o;t[0]===a?o=t[1]:(o=q(`max-w-64 text-right text-2xs leading-tight`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=r>0&&(0,Z.jsx)(fr,{className:`mr-1 inline size-3`}),t[2]=r,t[3]=s);let c;t[4]===n?c=t[5]:(c=Ti(n),t[4]=n,t[5]=c);let l;return t[6]!==i||t[7]!==o||t[8]!==s||t[9]!==c?(l=(0,Z.jsxs)(`span`,{role:i,className:o,children:[s,c]}),t[6]=i,t[7]=o,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function Nv(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Fv,{...e,path:void 0}),t[0]=e,t[1]=n),n}function Pv(e){let t=(0,$.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({path:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,Z.jsx)(Fv,{...r,path:n}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}function Fv(e){let t=(0,$.c)(14),{scope:n,context:r,interaction:i,base:a,path:o,only:s,heading:c,fullHeight:l,onOpen:u}=e,d=l!==void 0&&l,f;t[0]!==r||t[1]!==d||t[2]!==c||t[3]!==i||t[4]!==u||t[5]!==s||t[6]!==o||t[7]!==n?(f=e=>(0,Z.jsx)(Iv,{scope:n,context:r,interaction:i,onOpen:u,branch:e,path:o,only:s,heading:c,fullHeight:d}),t[0]=r,t[1]=d,t[2]=c,t[3]=i,t[4]=u,t[5]=s,t[6]=o,t[7]=n,t[8]=f):f=t[8];let p;return t[9]!==a||t[10]!==r||t[11]!==n||t[12]!==f?(p=(0,Z.jsx)(Z_,{scope:n,context:r,base:a,children:f}),t[9]=a,t[10]=r,t[11]=n,t[12]=f,t[13]=p):p=t[13],p}function Iv(e){let t=(0,$.c)(33),{scope:n,context:r,interaction:i,branch:a,path:o,only:s,heading:c,fullHeight:l,onOpen:u}=e,d=l!==void 0&&l,f;t[0]===a?f=t[1]:(f=zi(a),t[0]=a,t[1]=f);let p=f,m=J_(n,r,p);if(a.base===null||a.base===void 0)return null;let h;t[2]!==a.files||t[3]!==s||t[4]!==o?(h=()=>s?a.files.filter(e=>s.includes(e.path)||e.oldPath!==void 0&&s.includes(e.oldPath)).map(Lv):o==null?void 0:[o],t[2]=a.files,t[3]=s,t[4]=o,t[5]=h):h=t[5];let g=h,_;t[6]!==a.files||t[7]!==m||t[8]!==g?(_=da(a.files,m,g()),t[6]=a.files,t[7]=m,t[8]=g,t[9]=_):_=t[9];let v=_;if(o!=null&&v.length===0){let e;t[10]===a.base.ref?e=t[11]:(e=Mp(a.base.ref),t[10]=a.base.ref,t[11]=e);let n=`${o} has no committed change since ${e}.`,r;return t[12]===n?r=t[13]:(r=(0,Z.jsx)(zn,{title:`Not changed on this branch`,description:n}),t[12]=n,t[13]=r),r}let y=o!=null,b=a.base.ref,x=a.head,S=a.mergeBaseOid??``,C=a.commits,w;t[14]===a?w=t[15]:(w=Xl(a),t[14]=a,t[15]=w);let T;t[16]!==a.base.ref||t[17]!==a.commits||t[18]!==a.head||t[19]!==w||t[20]!==S?(T={base:b,head:x,mergeBaseOid:S,commits:C,diffRange:w},t[16]=a.base.ref,t[17]=a.commits,t[18]=a.head,t[19]=w,t[20]=S,t[21]=T):T=t[21];let E;return t[22]!==r||t[23]!==d||t[24]!==c||t[25]!==i||t[26]!==v||t[27]!==u||t[28]!==p||t[29]!==n||t[30]!==T||t[31]!==y?(E=(0,Z.jsx)(Rv,{scope:n,context:r,interaction:i,onOpen:u,range:p,items:v,single:y,heading:c,fullHeight:d,branch:T}),t[22]=r,t[23]=d,t[24]=c,t[25]=i,t[26]=v,t[27]=u,t[28]=p,t[29]=n,t[30]=T,t[31]=y,t[32]=E):E=t[32],E}function Lv(e){return e.path}function Rv(e){let t=(0,$.c)(55),{scope:n,context:r,interaction:i,range:a,items:o,single:s,heading:c,fullHeight:l,branch:u,onOpen:d}=e,f=l!==void 0&&l,{connection:p}=r,m=Pt(xt(sa(n,p))),h=JSON.stringify([u.base,u.head.branch]),[g,_]=L(C_(JSON.stringify([p.environmentId,n.projectId,n.worktreeId,h]))),v=o.slice(0,g),y=ia(n,p,u.diffRange,v.map(Op)),b=JSON.stringify([u.diffRange,v.map(Bv)]),[x,S]=(0,Q.useState)({version:``,comparison:h,patches:new Map});if(!y.pending&&!y.failed&&x.version!==b){let e;t[0]===y.patches?e=t[1]:(e=e=>{let t=y.patches.get(Op(e).join(`\0`));return t?[[e.fingerprint,t]]:[]},t[0]=y.patches,t[1]=e),S({version:b,comparison:h,patches:new Map(v.flatMap(e))})}let C=e=>y.patches.get(Op(e).join(`\0`))??(x.comparison===h?x.patches.get(e.fingerprint):void 0),w;t[2]!==r||t[3]!==a||t[4]!==n?(w=(e,t)=>(0,Z.jsx)(Tv,{scope:n,context:r,path:e.path,fingerprint:e.fingerprint,status:e.reviewStatus,range:a,compact:t},`review:${e.path}`),t[2]=r,t[3]=a,t[4]=n,t[5]=w):w=t[5];let T=w,E;t[6]!==u.head.oid||t[7]!==T||t[8]!==C?(E=e=>{let t=qi(u.head.oid,e,C(e));return t==null?[]:[{...t,id:`branch:${e.path}`,review:{path:e.path,fingerprint:e.fingerprint,reviewed:e.reviewStatus===`reviewed`,stale:e.reviewStatus===`stale`,control:T(e,!0)}}]},t[6]=u.head.oid,t[7]=T,t[8]=C,t[9]=E):E=t[9];let D=v.flatMap(E),O=new Set(D.map(zv)),k=v.filter(e=>!O.has(e.path)),A=o.length-v.length,j=m?.changes.length??0,[M]=o,N=i.singleHeader||c!==void 0,P;t[10]!==M||t[11]!==d||t[12]!==s?(P=s&&M?(0,Z.jsx)(q_,{label:`Timeline`,iconOnly:!0,icon:ji,onClick:()=>d({kind:`timeline`,path:M.path})}):void 0,t[10]=M,t[11]=d,t[12]=s,t[13]=P):P=t[13];let F;t[14]!==r||t[15]!==T||t[16]!==M||t[17]!==c||t[18]!==i.toolbarTarget||t[19]!==o||t[20]!==a||t[21]!==n||t[22]!==s||t[23]!==N?(F=e=>s&&M&&N?null:s&&M?(0,Z.jsx)(Sv,{target:i.toolbarTarget,barActions:null,title:di(M.path),subtitle:`${M.path} · on the branch`,children:T(M,!1)}):N?(0,Z.jsxs)(Sv,{inline:!0,...c?{title:c.title,titleLabel:c.titleLabel}:{title:`All changes`},subtitle:R(o.length,`file`),children:[e,c?.after]}):(0,Z.jsxs)(Sv,{target:i.toolbarTarget,barActions:null,title:`Branch`,subtitle:`${R(o.length,`file`)} changed`,children:[e,(0,Z.jsx)(Dv,{scope:n,context:r,entries:o,range:a})]}),t[14]=r,t[15]=T,t[16]=M,t[17]=c,t[18]=i.toolbarTarget,t[19]=o,t[20]=a,t[21]=n,t[22]=s,t[23]=N,t[24]=F):F=t[24];let I;t[25]!==u||t[26]!==T||t[27]!==y.failed||t[28]!==y.retry||t[29]!==k||t[30]!==C||t[31]!==s||t[32]!==N||t[33]!==j?(I=()=>(0,Z.jsx)(Vv,{branch:u,single:s,singleHeader:N,uncommitted:j,omitted:k,patchOf:C,failed:y.failed,onRetry:y.retry,control:e=>T(e,!0)}),t[25]=u,t[26]=T,t[27]=y.failed,t[28]=y.retry,t[29]=k,t[30]=C,t[31]=s,t[32]=N,t[33]=j,t[34]=I):I=t[34];let z;t[35]!==r||t[36]!==D||t[37]!==f||t[38]!==i||t[39]!==a||t[40]!==n||t[41]!==P||t[42]!==F||t[43]!==I?(z=(0,Z.jsx)(dv,{fullHeight:f,scope:n,context:r,interaction:i,range:a,headerActions:P,entries:D,toolbar:F,header:I}),t[35]=r,t[36]=D,t[37]=f,t[38]=i,t[39]=a,t[40]=n,t[41]=P,t[42]=F,t[43]=I,t[44]=z):z=t[44];let B;t[45]!==_||t[46]!==g?(B=()=>_(g+25),t[45]=_,t[46]=g,t[47]=B):B=t[47];let V;t[48]!==y.pending||t[49]!==A||t[50]!==B?(V=(0,Z.jsx)(Cv,{more:A,pending:y.pending,onReadMore:B}),t[48]=y.pending,t[49]=A,t[50]=B,t[51]=V):V=t[51];let H;return t[52]!==z||t[53]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[z,V]}),t[52]=z,t[53]=V,t[54]=H):H=t[54],H}function zv(e){return e.path}function Bv(e){return e.fingerprint}function Vv(e){let t=(0,$.c)(26),{branch:n,single:r,singleHeader:i,uncommitted:a,omitted:o,patchOf:s,failed:c,onRetry:l,control:u}=e,d;t[0]===n.head.branch?d=t[1]:(d=n.head.branch===null||n.head.branch===void 0?`This commit`:Mp(n.head.branch),t[0]=n.head.branch,t[1]=d);let f=d;if(i&&!c&&o.length===0)return null;let p;t[2]!==n.base||t[3]!==n.commits||t[4]!==n.head.oid||t[5]!==n.mergeBaseOid||t[6]!==f||t[7]!==r||t[8]!==i?(p=!r&&!i&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`h2`,{className:`text-sm font-semibold`,children:[f,` since `,Mp(n.base)]}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-2xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:R(n.commits,`commit`)}),(0,Z.jsxs)(`span`,{children:[`from`,` `,(0,Z.jsx)(`span`,{className:`font-mono`,children:jp(n.mergeBaseOid)}),` `,`to `,(0,Z.jsx)(`span`,{className:`font-mono`,children:jp(n.head.oid)})]}),(0,Z.jsx)(nt,{variant:`secondary`,children:Mp(n.base)})]})]}),t[2]=n.base,t[3]=n.commits,t[4]=n.head.oid,t[5]=n.mergeBaseOid,t[6]=f,t[7]=r,t[8]=i,t[9]=p):p=t[9];let m;t[10]!==i||t[11]!==a?(m=a>0&&!i&&(0,Z.jsx)(`p`,{className:`mt-1 text-2xs text-muted-foreground`,children:`Uncommitted changes are not part of the branch review. Review them under Uncommitted.`}),t[10]=i,t[11]=a,t[12]=m):m=t[12];let h;t[13]!==c||t[14]!==l?(h=c&&(0,Z.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-xs text-muted-foreground`,children:[`Some patches could not be read.`,(0,Z.jsx)(Y,{size:`xs`,variant:`outline`,onClick:l,children:`Try again`})]}),t[13]=c,t[14]=l,t[15]=h):h=t[15];let g;t[16]!==u||t[17]!==c||t[18]!==o||t[19]!==s?(g=o.length>0&&(0,Z.jsx)(`ul`,{className:`mt-3 space-y-1.5`,"aria-label":`Changes without code preview`,children:o.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 rounded-lg border bg-muted/25 px-3 py-2 text-xs`,children:[u(e),(0,Z.jsx)(X,{className:`font-mono font-medium`,text:e.path}),(0,Z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.status,` ·`,` `,Wc(e,s(e),c)??`No code change`]})]},e.path))}),t[16]=u,t[17]=c,t[18]=o,t[19]=s,t[20]=g):g=t[20];let _;return t[21]!==p||t[22]!==m||t[23]!==h||t[24]!==g?(_=(0,Z.jsxs)(`section`,{className:`mx-4 mt-3 rounded-xl border px-4 py-3`,children:[p,m,h,g]}),t[21]=p,t[22]=m,t[23]=h,t[24]=g,t[25]=_):_=t[25],_}var Hv=e=>Op(e).join(`\0`);function Uv(e){let t=(0,$.c)(51),{scope:n,context:r,interaction:i,oid:a,onOpen:o}=e,{connection:s}=r,[c,l]=(0,Q.useState)(1),[,u]=(0,Q.useTransition)(),d=gh(s,n,a,c),f;t[0]!==s||t[1]!==n?(f=hh({connection:s,scope:n}),t[0]=s,t[1]=n,t[2]=f):f=t[2];let p=Pt(xt(N(f))),m=p?.snapshot?.head.kind===`attached`&&p.commits.some(e=>e.oid===a)?Mp(p.snapshot.head.ref):void 0,h=`${a}:${c}`,g;t[3]===h?g=t[4]:(g={of:h,shown:25},t[3]=h,t[4]=g);let[_,v]=(0,Q.useState)(g),y=_.of===`${a}:${c}`?_.shown:25,b;t[5]!==a||t[6]!==c||t[7]!==y?(b=()=>v({of:`${a}:${c}`,shown:y+25}),t[5]=a,t[6]=c,t[7]=y,t[8]=b):b=t[8];let x=b,S=d.files.slice(0,y),C=S.map(qv),w=$i(s,n,a,c,C),T;t[9]===w.patches?T=t[10]:(T=e=>w.patches.get(Hv(e)),t[9]=w.patches,t[10]=T);let E=T,D;t[11]!==a||t[12]!==c||t[13]!==E?(D=e=>{let t=qi(a,e,E(e));return t==null?[]:[{...t,id:`${t.id}:${c}`}]},t[11]=a,t[12]=c,t[13]=E,t[14]=D):D=t[14];let O=S.flatMap(D),k;t[15]!==a||t[16]!==E?(k=e=>(qi(a,e,E(e))??null)===null,t[15]=a,t[16]=E,t[17]=k):k=t[17];let A=S.filter(k),j=d.files.length-S.length,M;t[18]!==d.commit.subject||t[19]!==a?(M=d.commit.subject||`Commit ${jp(a)}`,t[18]=d.commit.subject,t[19]=a,t[20]=M):M=t[20];let P=M,F=new Map(O.map(Kv));for(let e of S)E(e)?.kind===`metadata-only`&&F.set(kp(e),{added:0,removed:0});let I=j===0&&d.files.every(e=>{let t=E(e);return F.has(kp(e))||t?.kind===`binary`})?[...F.values()].reduce(Gv,{added:0,removed:0}):void 0,L;t[21]===a?L=t[22]:(L=(0,Z.jsx)(q_,{label:`Copy hash`,icon:De,onClick:()=>ht(a,`commit id`)}),t[21]=a,t[22]=L);let R;t[23]===o?R=t[24]:(R=(0,Z.jsx)(q_,{label:`Open in graph`,icon:hr,onClick:()=>o({kind:`graph`})}),t[23]=o,t[24]=R);let z;t[25]!==R||t[26]!==L?(z=(0,Z.jsxs)(Z.Fragment,{children:[L,R]}),t[25]=R,t[26]=L,t[27]=z):z=t[27];let B=z,V;t[28]!==B||t[29]!==m||t[30]!==d.commit||t[31]!==i.toolbarTarget||t[32]!==a||t[33]!==c||t[34]!==u||t[35]!==P?(V=e=>(0,Z.jsxs)(`header`,{className:`mx-auto w-full max-w-commit px-7 pt-10`,children:[i.toolbarTarget?(0,iu.createPortal)(B,i.toolbarTarget):(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:B}),(0,Z.jsxs)(`div`,{className:`flex min-h-5.5 min-w-0 flex-wrap items-center gap-x-2 text-ui leading-5.5 font-medium text-muted-foreground`,children:[(0,Z.jsx)(pc,{className:`size-3.5 shrink-0`}),(0,Z.jsxs)(`span`,{children:[`Commit`,` `,(0,Z.jsx)(X,{text:a,disclose:`always`,className:`font-mono text-caption text-foreground`,children:jp(a)})]}),m&&(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[`on`,` `,(0,Z.jsx)(X,{text:m,className:`font-mono text-caption font-normal`})]})]}),(0,Z.jsx)(X,{text:P,render:(0,Z.jsx)(`h1`,{}),className:`mt-3 text-2xl leading-tight font-semibold tracking-tight`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[d.commit.parentOids.length>1&&(0,Z.jsx)(Ds,{value:String(c),onValueChange:e=>u(()=>l(Number(e))),children:(0,Z.jsx)(Ts,{children:d.commit.parentOids.map(Wv)})}),(0,Z.jsx)(q_,{label:`Copy message`,icon:De,onClick:()=>ht(Dp(d.commit),`commit message`)}),e]})]}),t[28]=B,t[29]=m,t[30]=d.commit,t[31]=i.toolbarTarget,t[32]=a,t[33]=c,t[34]=u,t[35]=P,t[36]=V):V=t[36];let H=()=>(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(Jv,{commit:d,branch:m,counts:F,total:I,omitted:A,patchOf:E,failed:w.failed,onRetry:w.retry})}),U;t[37]!==r||t[38]!==O||t[39]!==i||t[40]!==n||t[41]!==V||t[42]!==H?(U=(0,Z.jsx)(dv,{toolbar:V,framed:!0,scope:n,context:r,interaction:i,entries:O,header:H}),t[37]=r,t[38]=O,t[39]=i,t[40]=n,t[41]=V,t[42]=H,t[43]=U):U=t[43];let W;t[44]!==w.pending||t[45]!==j||t[46]!==x?(W=(0,Z.jsx)(Cv,{more:j,pending:w.pending,onReadMore:x}),t[44]=w.pending,t[45]=j,t[46]=x,t[47]=W):W=t[47];let G;return t[48]!==U||t[49]!==W?(G=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[U,W]}),t[48]=U,t[49]=W,t[50]=G):G=t[50],G}function Wv(e,t){return(0,Z.jsxs)(fo,{value:String(t+1),children:[ah(t+1),` parent ·`,` `,(0,Z.jsx)(`span`,{className:`font-mono`,children:jp(e)})]},e)}function Gv(e,t){return{added:e.added+t.added,removed:e.removed+t.removed}}function Kv(e){return[e.path,e.lineCounts]}function qv(e){return Op(e)}function Jv(e){let t=(0,$.c)(67),{commit:n,omitted:r,patchOf:i,failed:a,onRetry:o,branch:s,counts:c,total:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-5 shrink-0 place-items-center rounded-sm border border-border-strong text-foreground`,children:(0,Z.jsx)(Vc,{className:`size-3`})}),t[0]=u):u=t[0];let d;t[1]===n.commit.author.name?d=t[2]:(d=(0,Z.jsx)(X,{text:n.commit.author.name,className:`font-medium text-foreground`}),t[1]=n.commit.author.name,t[2]=d);let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),t[3]=f):f=t[3];let p;t[4]===n.commit.author.timestamp?p=t[5]:(p=ze(n.commit.author.timestamp),t[4]=n.commit.author.timestamp,t[5]=p);let m;t[6]===p?m=t[7]:(m=(0,Z.jsx)(`span`,{children:p}),t[6]=p,t[7]=m);let h;t[8]!==n.commit.parentOids||t[9]!==n.comparison.baseOid||t[10]!==n.comparison.kind||t[11]!==n.comparison.parentNumber?(h=n.comparison.kind===`parent`?(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`· `}),`parent`,` `,(0,Z.jsx)(`span`,{className:`font-mono text-caption leading-5 text-foreground`,children:jp(n.comparison.baseOid)}),n.commit.parentOids.length>1&&` (${ah(n.comparison.parentNumber)} parent of a merge)`]}):(0,Z.jsx)(`span`,{children:`root commit`}),t[8]=n.commit.parentOids,t[9]=n.comparison.baseOid,t[10]=n.comparison.kind,t[11]=n.comparison.parentNumber,t[12]=h):h=t[12];let g;t[13]!==d||t[14]!==m||t[15]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-ui leading-5 text-muted-foreground`,children:[u,d,f,m,h]}),t[13]=d,t[14]=m,t[15]=h,t[16]=g):g=t[16];let _;if(t[17]!==s||t[18]!==n.commit.refs){let e;t[20]===s?e=t[21]:(e=e=>e.kind!==`local-branch`||e.name!==s,t[20]=s,t[21]=e),_=Np(n.commit.refs).filter(e).map(Yv),t[17]=s,t[18]=n.commit.refs,t[19]=_}else _=t[19];let v;t[22]===_?v=t[23]:(v=(0,Z.jsx)(`div`,{className:`mt-2 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-caption text-muted-foreground`,children:_}),t[22]=_,t[23]=v);let y;t[24]===n.commit.body?y=t[25]:(y=n.commit.body!==null&&n.commit.body!==void 0&&(0,Z.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap text-ui leading-relaxed wrap-anywhere text-muted-foreground`,children:n.commit.body}),t[24]=n.commit.body,t[25]=y);let b;t[26]!==n.commit.bodyTruncated||t[27]!==n.commit.subjectTruncated?(b=(n.commit.subjectTruncated||n.commit.bodyTruncated)&&(0,Z.jsx)(`p`,{className:`mt-1 text-caption text-muted-foreground`,children:`Commit message truncated`}),t[26]=n.commit.bodyTruncated,t[27]=n.commit.subjectTruncated,t[28]=b):b=t[28];let x;t[29]===n.files.length?x=t[30]:(x=R(n.files.length,`file`),t[29]=n.files.length,t[30]=x);let S;t[31]===x?S=t[32]:(S=(0,Z.jsxs)(`span`,{children:[x,` changed`]}),t[31]=x,t[32]=S);let C;t[33]===l?C=t[34]:(C=l&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`mx-2 font-normal text-muted-foreground`,children:`·`}),(0,Z.jsx)($v,{count:l})]}),t[33]=l,t[34]=C);let w;t[35]!==n.files.length||t[36]!==a||t[37]!==l?(w=!l&&n.files.length>0&&(0,Z.jsx)(`span`,{className:`ml-2 font-normal text-muted-foreground`,children:a?`Line counts unavailable`:`Line counts incomplete`}),t[35]=n.files.length,t[36]=a,t[37]=l,t[38]=w):w=t[38];let T;t[39]!==S||t[40]!==C||t[41]!==w?(T=(0,Z.jsxs)(`p`,{className:`border-b pb-1.5 text-xs font-medium tabular-nums`,children:[S,C,w]}),t[39]=S,t[40]=C,t[41]=w,t[42]=T):T=t[42];let E;if(t[43]!==n.files||t[44]!==c||t[45]!==i){let e;t[47]!==c||t[48]!==i?(e=e=>(0,Z.jsxs)(`li`,{className:`flex h-8 min-w-0 items-center gap-2.5 rounded-sm pr-1.5 pl-1 text-caption leading-4`,children:[(0,Z.jsx)(`span`,{"aria-label":e.status,className:`w-4 shrink-0 text-center font-mono text-xs font-semibold text-brand`,children:e.status.slice(0,1).toUpperCase()}),(0,Z.jsx)(X,{text:Op(e).join(` → `),className:`flex-1 font-mono font-medium`}),(0,Z.jsx)($v,{count:c.get(kp(e))}),i(e)?.kind===`binary`&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Binary`})]},Hv(e)),t[47]=c,t[48]=i,t[49]=e):e=t[49],E=n.files.map(e),t[43]=n.files,t[44]=c,t[45]=i,t[46]=E}else E=t[46];let D;t[50]===E?D=t[51]:(D=(0,Z.jsx)(`ul`,{className:`max-h-64 divide-y overflow-y-auto border-b`,"aria-label":`Changed files`,children:E}),t[50]=E,t[51]=D);let O;t[52]!==T||t[53]!==D?(O=(0,Z.jsxs)(`section`,{"aria-label":`Files changed`,className:`mt-7`,children:[T,D]}),t[52]=T,t[53]=D,t[54]=O):O=t[54];let k;t[55]!==a||t[56]!==r||t[57]!==o||t[58]!==i?(k=r.length>0&&(0,Z.jsx)(Xv,{changes:r,patchOf:i,failed:a,onRetry:o}),t[55]=a,t[56]=r,t[57]=o,t[58]=i,t[59]=k):k=t[59];let A;return t[60]!==y||t[61]!==b||t[62]!==O||t[63]!==k||t[64]!==g||t[65]!==v?(A=(0,Z.jsxs)(`section`,{className:`mx-auto mt-1 mb-6 w-full max-w-commit min-w-0 px-7`,children:[g,v,y,b,O,k]}),t[60]=y,t[61]=b,t[62]=O,t[63]=k,t[64]=g,t[65]=v,t[66]=A):A=t[66],A}function Yv(e){return(0,Z.jsx)(X,{text:e.name,className:`font-mono`},`${e.kind}:${e.name}`)}function Xv(e){let t=(0,$.c)(15),{changes:n,patchOf:r,failed:i,onRetry:a}=e,o;t[0]!==i||t[1]!==a?(o=i&&(0,Z.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-xs text-muted-foreground`,children:[`Some patches could not be read.`,(0,Z.jsx)(Y,{size:`xs`,variant:`outline`,onClick:a,children:`Try again`})]}),t[0]=i,t[1]=a,t[2]=o):o=t[2];let s;if(t[3]!==n||t[4]!==i||t[5]!==r){let e;t[7]!==i||t[8]!==r?(e=e=>{let t=kp(e),n=r(e),a=Ar(e),o=Wc(e,n,i)??`No code change`;return(0,Z.jsxs)(`li`,{className:`rounded-lg border bg-muted/25 px-3 py-2 text-xs`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(X,{className:`font-mono font-medium`,text:t}),(0,Z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.status,` · `,o]})]}),a&&n?.kind===`text`&&(0,Z.jsx)(`pre`,{className:`mt-1 overflow-x-auto whitespace-pre-wrap font-mono text-2xs text-muted-foreground`,children:n.patch.split(`
|
|
26
|
+
`).filter(Qv).map(Zv).join(`
|
|
27
|
+
`)})]},`${e.oldPath}->${e.newPath}:${e.status}`)},t[7]=i,t[8]=r,t[9]=e):e=t[9],s=n.map(e),t[3]=n,t[4]=i,t[5]=r,t[6]=s}else s=t[6];let c;t[10]===s?c=t[11]:(c=(0,Z.jsx)(`ul`,{className:`mt-3 space-y-1.5`,"aria-label":`Changes without code preview`,children:s}),t[10]=s,t[11]=c);let l;return t[12]!==o||t[13]!==c?(l=(0,Z.jsxs)(Z.Fragment,{children:[o,c]}),t[12]=o,t[13]=c,t[14]=l):l=t[14],l}function Zv(e){return e.slice(1)}function Qv(e){return/^[+-]Subproject commit /.test(e)}function $v(e){let t=(0,$.c)(7),{count:n}=e;if(!n)return null;let r;t[0]===n.added?r=t[1]:(r=(0,Z.jsxs)(`span`,{className:`text-add-fg`,children:[`+`,n.added]}),t[0]=n.added,t[1]=r);let i;t[2]===n.removed?i=t[3]:(i=(0,Z.jsxs)(`span`,{className:`text-del-fg`,children:[`−`,n.removed]}),t[2]=n.removed,t[3]=i);let a;return t[4]!==r||t[5]!==i?(a=(0,Z.jsxs)(`span`,{className:`shrink-0 space-x-1 font-mono text-xs font-medium tabular-nums`,children:[r,i]}),t[4]=r,t[5]=i,t[6]=a):a=t[6],a}function ey(e){let t=(0,$.c)(39),{scope:n,context:r,label:i,items:a,controls:o,actions:s,actionsOpen:c,onActionsOpenChange:l}=e,[u,d]=(0,Q.useState)(),f;t[0]===a?f=t[1]:(f=a.filter(ty),t[0]=a,t[1]=f);let p=f.length,m;t[2]===a.length?m=t[3]:(m=R(a.length,`file`),t[2]=a.length,t[3]=m);let h=`${p} of ${m} reviewed`,g;t[4]===i?g=t[5]:(g=(0,Z.jsx)(`h2`,{className:`text-ui leading-4 font-medium text-foreground`,children:i}),t[4]=i,t[5]=g);let _=`File review actions: ${h}`,v;t[6]===_?v=t[7]:(v=(0,Z.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,className:`ml-auto`,"aria-label":_}),t[6]=_,t[7]=v);let y;t[8]!==h||t[9]!==v?(y=(0,Z.jsx)(vn,{render:v,children:h}),t[8]=h,t[9]=v,t[10]=y):y=t[10];let b;t[11]!==s||t[12]!==o.collapse?(b=(0,Z.jsxs)(mn,{"aria-label":`File review actions`,align:`end`,children:[o.collapse,s]}),t[11]=s,t[12]=o.collapse,t[13]=b):b=t[13];let x;t[14]!==c||t[15]!==l||t[16]!==y||t[17]!==b?(x=(0,Z.jsxs)(Jt,{open:c,onOpenChange:l,children:[y,b]}),t[14]=c,t[15]=l,t[16]=y,t[17]=b,t[18]=x):x=t[18];let S;t[19]!==g||t[20]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex min-h-6 flex-wrap items-center gap-x-3.5 gap-y-1 border-b pb-1.5 text-xs text-muted-foreground tabular-nums`,children:[g,x]}),t[19]=g,t[20]=x,t[21]=S):S=t[21];let C;if(t[22]!==r||t[23]!==o||t[24]!==a||t[25]!==u||t[26]!==n){let e;t[28]!==r||t[29]!==o||t[30]!==u||t[31]!==n?(e=e=>{let t=e.path.lastIndexOf(`/`)+1,i=o.counts.get(e.path);return(0,Z.jsxs)(`li`,{className:`box-content flex h-8 items-center gap-3 border-t pl-1 first:border-t-0 last:border-b`,children:[(0,Z.jsx)(Ev,{scope:n,context:r,path:e.path,fingerprint:e.fingerprint,status:e.reviewStatus,latest:u===e.path,onStart:()=>d(e.path)}),(0,Z.jsx)(X,{text:e.path,renderTrigger:(n,r)=>(0,Z.jsxs)(`button`,{type:`button`,"aria-label":`${e.path}${i?` +${i.additions} −${i.deletions}`:``}`,"aria-current":o.current===e.path?`true`:void 0,onClick:()=>o.open(e.path),className:`flex h-8 min-w-0 flex-1 items-center gap-3 rounded-sm px-1.5 text-left whitespace-nowrap text-foreground outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 font-mono text-caption leading-4`,children:[t>0&&r(e.path.slice(0,t),`shrink-[100] text-muted-foreground`,`start`),r(e.path.slice(t),`shrink-0 max-w-full`)]}),i&&(0,Z.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,Z.jsx)(lv,{counts:i})})]})})]},e.path)},t[28]=r,t[29]=o,t[30]=u,t[31]=n,t[32]=e):e=t[32],C=a.map(e),t[22]=r,t[23]=o,t[24]=a,t[25]=u,t[26]=n,t[27]=C}else C=t[27];let w;t[33]===C?w=t[34]:(w=(0,Z.jsx)(`ol`,{children:C}),t[33]=C,t[34]=w);let T;return t[35]!==i||t[36]!==w||t[37]!==S?(T=(0,Z.jsxs)(`section`,{"aria-label":i,className:`pb-3.25`,children:[S,w]}),t[35]=i,t[36]=w,t[37]=S,t[38]=T):T=t[38],T}function ty(e){return e.reviewStatus===`reviewed`}function ny(e){let t=(0,$.c)(41),{path:n,note:r,diff:i,children:a}=e,o,s,c,l,u,d,f,p,m,h;if(t[0]!==i?.hunks||t[1]!==n){let e=n.split(`/`);l=e.pop()??n;let r;t[12]===i?.hunks?r=t[13]:(r=i?.hunks.reduce(iy,0),t[12]=i?.hunks,t[13]=r),s=r;let a;t[14]===i?.hunks?a=t[15]:(a=i?.hunks.reduce(ry,0),t[14]=i?.hunks,t[15]=a),c=a,m=``,h=`@container/file-heading flex min-h-11 shrink-0 items-center gap-2.5 px-4 text-ui leading-[1.4] whitespace-nowrap text-foreground`,o=X,u=n,d=`min-w-0 font-mono text-[length:var(--text-caption)] leading-4 text-muted-foreground`,t[16]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(`h1`,{}),t[16]=f):f=t[16],p=e.length>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.join(` / `),` / `]}),t[0]=i?.hunks,t[1]=n,t[2]=o,t[3]=s,t[4]=c,t[5]=l,t[6]=u,t[7]=d,t[8]=f,t[9]=p,t[10]=m,t[11]=h}else o=t[2],s=t[3],c=t[4],l=t[5],u=t[6],d=t[7],f=t[8],p=t[9],m=t[10],h=t[11];let g;t[17]===l?g=t[18]:(g=(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:l}),t[17]=l,t[18]=g);let _;t[19]!==o||t[20]!==u||t[21]!==d||t[22]!==f||t[23]!==p||t[24]!==g?(_=(0,Z.jsxs)(o,{text:u,className:d,render:f,children:[p,g]}),t[19]=o,t[20]=u,t[21]=d,t[22]=f,t[23]=p,t[24]=g,t[25]=_):_=t[25];let v;t[26]===r?v=t[27]:(v=r&&(0,Z.jsx)(`span`,{className:`hidden shrink-0 text-xs text-muted-foreground @md/file-heading:inline`,children:r}),t[26]=r,t[27]=v);let y;t[28]!==s||t[29]!==c||t[30]!==i?(y=i&&(0,Z.jsxs)(`span`,{"aria-label":`${s} additions, ${c} deletions`,className:`font-mono text-xs font-medium tabular-nums`,children:[(0,Z.jsxs)(`span`,{className:`text-add-fg`,children:[`+`,s]}),` `,(0,Z.jsxs)(`span`,{className:`text-del-fg`,children:[`−`,c]})]}),t[28]=s,t[29]=c,t[30]=i,t[31]=y):y=t[31];let b;t[32]!==a||t[33]!==y?(b=(0,Z.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[y,a]}),t[32]=a,t[33]=y,t[34]=b):b=t[34];let x;return t[35]!==b||t[36]!==m||t[37]!==h||t[38]!==_||t[39]!==v?(x=(0,Z.jsxs)(`header`,{"data-file-heading":m,className:h,children:[_,v,b]}),t[35]=b,t[36]=m,t[37]=h,t[38]=_,t[39]=v,t[40]=x):x=t[40],x}function ry(e,t){return e+t.deletionLines}function iy(e,t){return e+t.additionLines}function ay(e,t,n){if(t===``)return[];let r=t.toLocaleLowerCase(),i=[],a=e.split(`
|
|
28
|
+
`);for(let[e,t]of a.entries()){let a=t.toLocaleLowerCase(),o=a.indexOf(r);for(;o!==-1;){if(i.length===n)return i;i.push({line:e+1,column:o}),o=a.indexOf(r,o+r.length)}}return i}function oy(e,t){return Math.max(0,Math.min(e,t-1))}function sy(e,t,n){return t===0?0:(oy(e,t)+n+t)%t}function cy(e,t,n){if(t===0)return`No results`;let r=t===n?`+`:``;return`${oy(e,t)+1} of ${t}${r}`}function ly(e){let t=(0,$.c)(65),{text:n,focusRequest:r,onReveal:i,onClose:a}=e,[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(0),u;t[0]!==o||t[1]!==n?(u=ay(n,o,Ie),t[0]=o,t[1]=n,t[2]=u):u=t[2];let d=u,[f,p]=(0,Q.useState)(),m;t[3]!==d||t[4]!==i?(m=(e,t)=>{let n=t===void 0?d:t;l(e);let r=n[e];r&&i(r.line)},t[3]=d,t[4]=i,t[5]=m):m=t[5];let h=m,g;t[6]!==c||t[7]!==d.length||t[8]!==h?(g=e=>h(sy(c,d.length,e)),t[6]=c,t[7]=d.length,t[8]=h,t[9]=g):g=t[9];let _=g,v;t[10]===a?v=t[11]:(v=e=>{e.key===`Escape`&&(e.preventDefault(),a())},t[10]=a,t[11]=v);let y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(Er,{children:(0,Z.jsx)(qn,{})}),t[12]=y):y=t[12];let b;t[13]!==r||t[14]!==f?(b=e=>{e&&f!==r&&(e.focus(),e.select(),p(r))},t[13]=r,t[14]=f,t[15]=b):b=t[15];let x;t[16]!==h||t[17]!==n?(x=e=>{s(e.target.value),h(0,ay(n,e.target.value,Ie))},t[16]=h,t[17]=n,t[18]=x):x=t[18];let S;t[19]===_?S=t[20]:(S=e=>{e.key===`Enter`&&(e.preventDefault(),_(e.shiftKey?-1:1))},t[19]=_,t[20]=S);let C;t[21]!==o||t[22]!==b||t[23]!==x||t[24]!==S?(C=(0,Z.jsx)(sr,{ref:b,"aria-label":`Find in file`,placeholder:`Find in file`,value:o,onChange:x,onKeyDown:S}),t[21]=o,t[22]=b,t[23]=x,t[24]=S,t[25]=C):C=t[25];let w;t[26]!==c||t[27]!==d.length||t[28]!==o?(w=o!==``&&(0,Z.jsx)(mr,{role:`status`,children:cy(c,d.length,1e4)}),t[26]=c,t[27]=d.length,t[28]=o,t[29]=w):w=t[29];let T=d.length===0,E;t[30]===_?E=t[31]:(E=()=>_(-1),t[30]=_,t[31]=E);let D;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(jn,{}),t[32]=D):D=t[32];let O;t[33]!==T||t[34]!==E?(O=(0,Z.jsx)(rn,{render:(0,Z.jsx)(Mr,{size:`icon-xs`,"aria-label":`Previous match`,disabled:T,onClick:E,children:D})}),t[33]=T,t[34]=E,t[35]=O):O=t[35];let k;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(bt,{role:`tooltip`,className:`break-all`,children:`Previous match`}),t[36]=k):k=t[36];let A;t[37]===O?A=t[38]:(A=(0,Z.jsxs)(Tn,{children:[O,k]}),t[37]=O,t[38]=A);let j=d.length===0,M;t[39]===_?M=t[40]:(M=()=>_(1),t[39]=_,t[40]=M);let N;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(Ae,{}),t[41]=N):N=t[41];let P;t[42]!==j||t[43]!==M?(P=(0,Z.jsx)(rn,{render:(0,Z.jsx)(Mr,{size:`icon-xs`,"aria-label":`Next match`,disabled:j,onClick:M,children:N})}),t[42]=j,t[43]=M,t[44]=P):P=t[44];let F;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(bt,{role:`tooltip`,className:`break-all`,children:`Next match`}),t[45]=F):F=t[45];let I;t[46]===P?I=t[47]:(I=(0,Z.jsxs)(Tn,{children:[P,F]}),t[46]=P,t[47]=I);let L;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(Mt,{}),t[48]=L):L=t[48];let R;t[49]===a?R=t[50]:(R=(0,Z.jsx)(rn,{render:(0,Z.jsx)(Mr,{size:`icon-xs`,"aria-label":`Close find`,onClick:a,children:L})}),t[49]=a,t[50]=R);let z;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(bt,{role:`tooltip`,className:`break-all`,children:`Close find`}),t[51]=z):z=t[51];let B;t[52]===R?B=t[53]:(B=(0,Z.jsxs)(Tn,{children:[R,z]}),t[52]=R,t[53]=B);let V;t[54]!==w||t[55]!==A||t[56]!==I||t[57]!==B?(V=(0,Z.jsxs)(Er,{align:`inline-end`,children:[w,A,I,B]}),t[54]=w,t[55]=A,t[56]=I,t[57]=B,t[58]=V):V=t[58];let H;t[59]!==V||t[60]!==C?(H=(0,Z.jsxs)(Cr,{className:`w-full max-w-sm`,children:[y,C,V]}),t[59]=V,t[60]=C,t[61]=H):H=t[61];let U;return t[62]!==H||t[63]!==v?(U=(0,Z.jsx)(`div`,{role:`search`,className:`flex shrink-0 justify-end border-b px-3 py-1.5`,onKeyDown:v,children:H}),t[62]=H,t[63]=v,t[64]=U):U=t[64],U}function uy(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=su(e.path)?(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-auto`,children:[(0,Z.jsx)(Sy,{...e}),(0,Z.jsx)(_y,{path:e.path,copy:!1,children:(0,Z.jsxs)(Mm,{className:`max-w-full flex-wrap justify-end`,children:[(0,Z.jsx)(vy,{path:e.path,onOpen:e.onOpen}),(0,Z.jsx)(yy,{path:e.path})]})}),(0,Z.jsx)(ra,{scope:e.scope,path:e.path,connection:e.context.connection})]}):(0,Z.jsx)(dy,{...e}),t[0]=e,t[1]=n),n}function dy(e){let t=(0,$.c)(16),n;t[0]===e.path?n=t[1]:(n=e.path.split(`/`).slice(0,-1).join(`/`),t[0]=e.path,t[1]=n);let r=n,{connection:i}=e.context,a=Fi(i,e.scope,r),o;t[2]===e.path?o=t[3]:(o=e.path.split(`/`).at(-1),t[2]=e.path,t[3]=o);let s=o,c;if(t[4]!==a.entries||t[5]!==s){let e;t[7]===s?e=t[8]:(e=e=>e.name===s,t[7]=s,t[8]=e),c=a.entries.find(e),t[4]=a.entries,t[5]=s,t[6]=c}else c=t[6];let l=c;if(l?.kind===`symlink`){let n=`Not followed: symlink to ${l.target??`an unknown target`}`,r;return t[9]!==e||t[10]!==n?(r=(0,Z.jsx)(fy,{...e,message:n}),t[9]=e,t[10]=n,t[11]=r):r=t[11],r}if(l?.kind===`submodule`){let n;return t[12]===e?n=t[13]:(n=(0,Z.jsx)(fy,{...e,message:`Not followed: submodule`}),t[12]=e,t[13]=n),n}let u;return t[14]===e?u=t[15]:(u=(0,Z.jsx)(py,{...e}),t[14]=e,t[15]=u),u}function fy(e){let t=(0,$.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({message:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===r?i=t[4]:(i=(0,Z.jsx)(Sy,{...r}),t[3]=r,t[4]=i);let a;t[5]===r.path?a=t[6]:(a=(0,Z.jsx)(_y,{path:r.path}),t[5]=r.path,t[6]=a);let o;t[7]===n?o=t[8]:(o=(0,Z.jsx)(`div`,{className:`grid min-h-48 flex-1 place-items-center p-6`,children:(0,Z.jsx)(zn,{title:`Not shown`,description:n})}),t[7]=n,t[8]=o);let s;return t[9]!==i||t[10]!==a||t[11]!==o?(s=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[i,a,o]}),t[9]=i,t[10]=a,t[11]=o,t[12]=s):s=t[12],s}function py(e){let t=(0,$.c)(24),{scope:n,context:r,interaction:i,path:a,onOpen:o}=e,{connection:s}=r,{file:c,draft:l,state:u,reset:d,edit:f}=us(s,n,a),p=`kind`in c;if(p&&u.owner===null&&u.text===u.savedText){let e;return t[0]!==r||t[1]!==c.reason||t[2]!==i||t[3]!==o||t[4]!==a||t[5]!==n?(e=(0,Z.jsx)(fy,{scope:n,context:r,interaction:i,onOpen:o,path:a,message:c.reason}),t[0]=r,t[1]=c.reason,t[2]=i,t[3]=o,t[4]=a,t[5]=n,t[6]=e):e=t[6],e}let m;t[7]===p?m=t[8]:(m=p&&(0,Z.jsx)(`p`,{role:`alert`,className:`border-b bg-graph-4/10 px-3.5 py-2 text-xs text-graph-4`,children:`The file is no longer readable. Your unsaved draft is still available below.`}),t[7]=p,t[8]=m);let h=p?u.savedText:c.text,g=p?u.fingerprint:c.contentFingerprint,_;t[9]!==r||t[10]!==l||t[11]!==f||t[12]!==i||t[13]!==o||t[14]!==a||t[15]!==d||t[16]!==n||t[17]!==u||t[18]!==h||t[19]!==g?(_=(0,Z.jsx)(my,{scope:n,context:r,interaction:i,path:a,text:h,contentFingerprint:g,draft:l,draftState:u,reset:d,edit:f,onOpen:o}),t[9]=r,t[10]=l,t[11]=f,t[12]=i,t[13]=o,t[14]=a,t[15]=d,t[16]=n,t[17]=u,t[18]=h,t[19]=g,t[20]=_):_=t[20];let v;return t[21]!==m||t[22]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[m,_]}),t[21]=m,t[22]=_,t[23]=v):v=t[23],v}function my(e){let t=(0,$.c)(87),{scope:n,context:r,interaction:i,path:a,text:o,contentFingerprint:s,draft:c,draftState:l,reset:u,edit:d,onOpen:f}=e,{preferences:p}=Ha(),{connection:m}=r,h=si(n,m),g;t[0]===a?g=t[1]:(g=by(a),t[0]=a,t[1]=g);let _=g,v;t[2]===a?v=t[3]:(v=[a],t[2]=a,t[3]=v);let y=X_(n,r,h,v)[0],b=y?.comparisons??[],x=b.find(hy)??b[0],S=x?Gc(x):void 0,C;t[4]!==a||t[5]!==y?(C=y?[{path:a,fingerprint:y.fingerprint}]:[],t[4]=a,t[5]=y,t[6]=C):C=t[6];let w=wi(n,m,y?.statusToken??``,C,S?[S]:[]),T=S?w.diffs.get(nr(S)):void 0,E=x&&x.scope!==`untracked`&&x.scope!==`unmerged`&&T?Bi(x,T)?.fileDiff:void 0,D=x&&`kind`in x?`${x.scope} · ${x.kind}`:x?.scope,O;if(t[7]!==h.changes||t[8]!==a){let e;t[10]===a?e=t[11]:(e=e=>e.path===a,t[10]=a,t[11]=e),O=h.changes.some(e),t[7]=h.changes,t[8]=a,t[9]=O}else O=t[9];let k=O,A;t[12]!==_||t[13]!==p?(A=()=>xy(_,p),t[12]=_,t[13]=p,t[14]=A):A=t[14];let[j,M]=(0,Q.useState)(A),{active:N}=i,[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(),[R,z]=(0,Q.useState)(),B=(0,Q.useId)();pi(c,B,s);let V=_===`code`||j===`source`,H;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>L(Date.now()),t[15]=H):H=t[15];let U=N&&V&&!P,W;t[16]===U?W=t[17]:(W={enabled:U,ignoreInputs:!1,conflictBehavior:`allow`},t[16]=U,t[17]=W),Co(yo.findInFile,H,W);let G=l.diskChanged.has(B)?`Changed on disk just now`:``,ee;t[18]===G?ee=t[19]:(ee=(0,Z.jsx)(`span`,{"aria-live":`polite`,className:`hidden text-xs text-muted-foreground xl:inline`,children:G}),t[18]=G,t[19]=ee);let te;t[20]!==_||t[21]!==j?(te=_!==`code`&&(0,Z.jsx)(Ds,{value:j,onValueChange:e=>{(e===`rendered`||e===`source`)&&M(e)},children:(0,Z.jsxs)(Ts,{children:[(0,Z.jsx)(fo,{value:`rendered`,children:_===`markdown`?`Reader`:`Preview`}),(0,Z.jsx)(fo,{value:`source`,children:`Source`})]})}),t[20]=_,t[21]=j,t[22]=te):te=t[22];let ne;t[23]!==ee||t[24]!==te?(ne=(0,Z.jsxs)(Z.Fragment,{children:[ee,te]}),t[23]=ee,t[24]=te,t[25]=ne):ne=t[25];let re=ne,ie;t[26]!==s||t[27]!==l.owner||t[28]!==l.savedText||t[29]!==l.text||t[30]!==d||t[31]!==B?(ie=s&&(0,Z.jsxs)(Tn,{children:[(0,Z.jsx)(rn,{render:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,disabled:l.owner!==null&&l.owner!==B,"aria-label":l.text===l.savedText?`Edit`:`Resume edit`,onClick:()=>{d(B)&&F(!0)}}),children:(0,Z.jsx)(it,{})}),(0,Z.jsx)(bt,{role:`tooltip`,children:l.owner!==null&&l.owner!==B?`Editing in another pane`:`Edit`})]}),t[26]=s,t[27]=l.owner,t[28]=l.savedText,t[29]=l.text,t[30]=d,t[31]=B,t[32]=ie):ie=t[32];let ae;t[33]!==k||t[34]!==f||t[35]!==a?(ae=k&&(0,Z.jsxs)(Tn,{children:[(0,Z.jsx)(rn,{render:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,"aria-label":`Open diff`,onClick:()=>f({kind:`change`,path:a})}),children:(0,Z.jsx)(xr,{})}),(0,Z.jsx)(bt,{role:`tooltip`,children:`Open diff`})]}),t[33]=k,t[34]=f,t[35]=a,t[36]=ae):ae=t[36];let K;t[37]!==i.toolbarTarget||t[38]!==f||t[39]!==a?(K=i.toolbarTarget===void 0&&(0,Z.jsx)(vy,{path:a,onOpen:f}),t[37]=i.toolbarTarget,t[38]=f,t[39]=a,t[40]=K):K=t[40];let oe;t[41]===a?oe=t[42]:(oe=(0,Z.jsx)(yy,{path:a}),t[41]=a,t[42]=oe);let q;t[43]!==ie||t[44]!==ae||t[45]!==K||t[46]!==oe?(q=(0,Z.jsxs)(Z.Fragment,{children:[ie,ae,K,oe]}),t[43]=ie,t[44]=ae,t[45]=K,t[46]=oe,t[47]=q):q=t[47];let se=q;if(P){let e;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>F(!1),t[48]=e):e=t[48];let n;t[49]!==s||t[50]!==u||t[51]!==o?(n=()=>{u(o,s??``),F(!1)},t[49]=s,t[50]=u,t[51]=o,t[52]=n):n=t[52];let r;t[53]===a?r=t[54]:(r=e=>(0,Z.jsx)(_y,{path:a,children:e}),t[53]=a,t[54]=r);let i;return t[55]!==N||t[56]!==k||t[57]!==c||t[58]!==l||t[59]!==B||t[60]!==a||t[61]!==n||t[62]!==r?(i=(0,Z.jsx)(Mi,{owner:B,path:a,draft:c,state:l,active:N,changed:k,onDone:e,onDiscard:n,renderToolbar:r}),t[55]=N,t[56]=k,t[57]=c,t[58]=l,t[59]=B,t[60]=a,t[61]=n,t[62]=r,t[63]=i):i=t[63],i}let ce;t[64]!==i.toolbarTarget||t[65]!==f||t[66]!==a||t[67]!==V?(ce=i.toolbarTarget&&!V&&(0,iu.createPortal)((0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(vy,{path:a,onOpen:f})}),i.toolbarTarget),t[64]=i.toolbarTarget,t[65]=f,t[66]=a,t[67]=V,t[68]=ce):ce=t[68];let le;t[69]!==se||t[70]!==r||t[71]!==E||t[72]!==I||t[73]!==R||t[74]!==i||t[75]!==_||t[76]!==re||t[77]!==j||t[78]!==D||t[79]!==f||t[80]!==a||t[81]!==n||t[82]!==o?(le=j===`rendered`&&_!==`code`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(_y,{path:a,copy:!1,children:[re,(0,Z.jsx)(Mm,{className:`max-w-full flex-wrap justify-end`,children:se})]}),(0,Z.jsx)(gy,{scope:n,context:r,path:a,kind:_,text:o})]}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[I!==void 0&&(0,Z.jsx)(ly,{text:o,focusRequest:I,onReveal:e=>z({line:e,nonce:Date.now()}),onClose:()=>L(void 0)}),(0,Z.jsxs)(ny,{path:a,note:D,diff:E,children:[re,se]}),(0,Z.jsx)(dv,{disableFileHeader:!0,compactThreads:!0,fileDiff:E,scope:n,context:r,interaction:i,headerActions:i.toolbarTarget===void 0?void 0:(0,Z.jsx)(vy,{path:a,onOpen:f}),...R===void 0?{}:{foundLine:R},entries:[{...$_(`file:${a}`,a,o)}]})]}),t[69]=se,t[70]=r,t[71]=E,t[72]=I,t[73]=R,t[74]=i,t[75]=_,t[76]=re,t[77]=j,t[78]=D,t[79]=f,t[80]=a,t[81]=n,t[82]=o,t[83]=le):le=t[83];let ue;return t[84]!==ce||t[85]!==le?(ue=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-card`,children:[ce,le]}),t[84]=ce,t[85]=le,t[86]=ue):ue=t[86],ue}function hy(e){return e.scope===`unstaged`}function gy(e){let t=(0,$.c)(8),{scope:n,context:r,path:i,kind:a,text:o}=e;if(a===`markdown`){let e;return t[0]===o?e=t[1]:(e=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,Z.jsx)(Or,{text:o,className:`mx-auto max-w-[78ch] px-6 py-6`})}),t[0]=o,t[1]=e),e}let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(`p`,{className:`border-b bg-muted/40 px-3.5 py-1.5 text-2xs text-muted-foreground`,children:`Sandboxed preview: scripts run, and cannot read Porcelain, your cookies or the review API, load anything from the network, submit a form, or move the page around them.`}),t[2]=s):s=t[2];let c;return t[3]!==r.connection||t[4]!==i||t[5]!==n||t[6]!==o?(c=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,children:[s,(0,Z.jsx)(Jn,{scope:n,path:i,html:o,connection:r.connection})]}),t[3]=r.connection,t[4]=i,t[5]=n,t[6]=o,t[7]=c):c=t[7],c}function _y(e){let t=(0,$.c)(7),{path:n,children:r,copy:i}=e,a=i===void 0||i,o;t[0]!==a||t[1]!==n?(o=a&&(0,Z.jsx)(yy,{path:n}),t[0]=a,t[1]=n,t[2]=o):o=t[2];let s;return t[3]!==r||t[4]!==n||t[5]!==o?(s=(0,Z.jsxs)(ny,{path:n,children:[r,o]}),t[3]=r,t[4]=n,t[5]=o,t[6]=s):s=t[6],s}function vy(e){let t=(0,$.c)(3),{path:n,onOpen:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,Z.jsx)(q_,{label:`Timeline`,iconOnly:!0,icon:ji,onClick:()=>r({kind:`timeline`,path:n})}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function yy(e){let t=(0,$.c)(8),{path:n}=e,r;t[0]===n?r=t[1]:(r=(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,"aria-label":`Copy path`,onClick:()=>ht(n,`path`)}),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(De,{}),t[2]=i):i=t[2];let a;t[3]===r?a=t[4]:(a=(0,Z.jsx)(rn,{render:r,children:i}),t[3]=r,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(bt,{role:`tooltip`,children:`Copy path`}),t[5]=o):o=t[5];let s;return t[6]===a?s=t[7]:(s=(0,Z.jsxs)(Tn,{children:[a,o]}),t[6]=a,t[7]=s),s}function by(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.mdx`)?`markdown`:t.endsWith(`.html`)||t.endsWith(`.htm`)?`html`:`code`}function xy(e,t){return e===`markdown`||e===`html`?t.documentsDefault:`source`}function Sy(e){let t=(0,$.c)(6),{interaction:n,path:r,onOpen:i}=e;if(!n.toolbarTarget)return null;let a;t[0]!==i||t[1]!==r?(a=(0,Z.jsx)(vy,{path:r,onOpen:i}),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o;return t[3]!==n.toolbarTarget||t[4]!==a?(o=(0,iu.createPortal)(a,n.toolbarTarget),t[3]=n.toolbarTarget,t[4]=a,t[5]=o):o=t[5],o}function Cy(e){return[...new Set(e)].join(`, `)}function wy(e){let t=(0,$.c)(37),{scope:n,context:r,interaction:i,paths:a,files:o,focus:s,header:c,headerActions:l,headerLeading:u,toolbar:d,footer:f,column:p,fullHeight:m}=e,h=o===void 0?[]:o,g=p!==void 0&&p,_=m!==void 0&&m,{connection:v}=r,[y,b]=(0,Q.useState)(),x;t[0]!==y||t[1]!==b?(x=(e,t)=>{y===e&&(b(void 0),t.focus({preventScroll:!0}),t.scrollIntoView({block:`start`}))},t[0]=y,t[1]=b,t[2]=x):x=t[2];let S=x;Y_(n,r);let C=si(n,v),w=$n(X_(n,r,C,a),h),T=w[0]?.statusToken??``,E=wi(n,v,T,w.flatMap(jy),w.flatMap(ky)),D=Tr(v,n,w.flatMap(Dy)),O;t[3]===E.diffs?O=t[4]:(O=e=>{let t=Gc(e);return t?E.diffs.get(nr(t)):void 0},t[3]=E.diffs,t[4]=O);let k=O,A=E.pending||D.pending,j=E.failed||D.failed,M=new Map(h.map(Ey)),N;t[5]!==k||t[6]!==D?(N=e=>{let t=e.comparisons.flatMap(e=>{if(e.scope===`unmerged`)return[`Conflict`];if(e.scope===`untracked`)return D.contents.has(e.path)?[]:[`Not readable`];if(!e.supported)return[`Unsupported comparison`];let t=k(e);return t?t.kind===`binary`?[`Binary change`]:t.kind===`omitted`?[`Content omitted: ${Hc(t.reason)}`]:Bi(e,t)?[]:[`No single-file textual patch`]:[]});return t.length>0?[{item:e,reasons:t}]:[]},t[5]=k,t[6]=D,t[7]=N):N=t[7];let P=w.flatMap(N),F=w.flatMap(e=>e.comparisons.flatMap(t=>{let i=wv(n,r,e);if(t.scope===`untracked`){let n=D.contents.get(t.path);return n===void 0?[]:[{...$_(Wr(t),e.path,n,M.get(e.path)??`untracked`),review:i}]}if(t.scope===`unmerged`||!t.supported)return[];let a=Py(k(t),s?.[e.path]),o=a?Bi(t,a):null,c=M.get(e.path);return o?[{...o,...c?{note:c}:{},review:i,discardScope:t.scope}]:[]})),I=new Set(F.map(Ty)),L=i.toolbarTarget!==void 0&&/^(file|change|branch|walkthrough-step):/.test(i.entry)&&F.length===0&&w.length===1?P[0]?.item:void 0,R=c||A||j||P.length>0?e=>(0,Z.jsxs)(Z.Fragment,{children:[c?.({...e,open:t=>{b(void 0),I.has(t)?e.open(t):b(t)}}),(A||j)&&(0,Z.jsx)(Fy,{failed:j,retry:()=>{E.retry(),D.retry()}}),P.length>0&&(0,Z.jsx)(Iy,{changes:P,column:g,onTarget:(e,t)=>{t&&S(e,t)},renderedPaths:I,scope:n,context:r,paneFile:!!L})]}):void 0,z;t[8]!==r||t[9]!==l||t[10]!==i.active||t[11]!==L||t[12]!==n?(z=L?(0,Z.jsx)(Ly,{scope:n,context:r,item:L,active:i.active,children:l}):void 0,t[8]=r,t[9]=l,t[10]=i.active,t[11]=L,t[12]=n,t[13]=z):z=t[13];let B;t[14]===f?B=t[15]:(B=f?{footer:f}:{},t[14]=f,t[15]=B);let V;t[16]===R?V=t[17]:(V=R?{header:R}:{},t[16]=R,t[17]=V);let H;t[18]===l?H=t[19]:(H=l?{headerActions:l}:{},t[18]=l,t[19]=H);let U;t[20]===u?U=t[21]:(U=u?{headerLeading:u}:{},t[20]=u,t[21]=U);let W;t[22]===d?W=t[23]:(W=d?{toolbar:d}:{},t[22]=d,t[23]=W);let G;return t[24]!==g||t[25]!==r||t[26]!==F||t[27]!==_||t[28]!==i||t[29]!==n||t[30]!==H||t[31]!==U||t[32]!==W||t[33]!==z||t[34]!==B||t[35]!==V?(G=(0,Z.jsx)(dv,{fullHeight:_,emptyActions:z,scope:n,context:r,interaction:i,entries:F,column:g,...B,...V,...H,...U,...W}),t[24]=g,t[25]=r,t[26]=F,t[27]=_,t[28]=i,t[29]=n,t[30]=H,t[31]=U,t[32]=W,t[33]=z,t[34]=B,t[35]=V,t[36]=G):G=t[36],G}function Ty(e){return e.path}function Ey(e){return[e.path,e.note]}function Dy(e){return e.comparisons.flatMap(Oy)}function Oy(e){return e.scope===`untracked`?[e.path]:[]}function ky(e){return e.comparisons.flatMap(Ay)}function Ay(e){let t=Gc(e);return t?[t]:[]}function jy(e){return e.comparisons.some(My)?[{path:e.path,fingerprint:e.fingerprint}]:[]}function My(e){return e.scope===`staged`||e.scope===`unstaged`}var Ny=new WeakMap;function Py(e,t){if(!e||!t?.length||e.kind!==`text`)return e;let n=t.map(e=>`${e.startLine}-${e.endLine}`).join(`,`),r=Ny.get(e),i=r?.get(n);if(i)return i;let a=Yl(e.patch,t),o=a?{...e,patch:a}:e;return r??=new Map,r.set(n,o),Ny.set(e,r),o}function Fy(e){let t=(0,$.c)(3),{failed:n,retry:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)(`section`,{className:`mx-4 mt-3 flex items-center gap-3 rounded-lg border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"aria-live":`polite`,children:n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:`The changes in this document could not be read.`}),(0,Z.jsx)(Y,{size:`xs`,variant:`outline`,onClick:r,children:`Load the changes again`})]}):(0,Z.jsx)(`span`,{children:`Loading changes…`})}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function Iy(e){let t=(0,$.c)(21),{changes:n,column:r,onTarget:i,renderedPaths:a,scope:o,context:s,paneFile:c}=e,l=!r&&`mx-4`,u;t[0]===l?u=t[1]:(u=q(`mt-3 rounded-lg border bg-muted/40 px-4 py-3`,l),t[0]=l,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(`p`,{className:`text-xs font-medium`,children:`Non-text content`}),t[2]=d):d=t[2];let f;if(t[3]!==n||t[4]!==s||t[5]!==i||t[6]!==c||t[7]!==a||t[8]!==o){let e;t[10]!==s||t[11]!==i||t[12]!==c||t[13]!==a||t[14]!==o?(e=e=>{let{item:t,reasons:n}=e;return(0,Z.jsxs)(`li`,{"aria-label":`${t.path}: ${Cy(n)}`,tabIndex:-1,ref:e=>i(t.path,e),className:`flex min-w-0 scroll-mt-3 flex-wrap items-center gap-2 outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Z.jsx)(X,{className:`min-w-0 basis-full`,text:t.path}),su(t.path)&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:`Current worktree image`}),(0,Z.jsx)(ra,{scope:o,path:t.path,connection:s.connection})]}),(0,Z.jsx)(nt,{variant:`outline`,className:`h-auto max-w-full text-left whitespace-normal`,children:Cy(n)}),!c&&!a.has(t.path)&&(0,Z.jsx)(Tv,{scope:o,context:s,path:t.path,fingerprint:t.fingerprint,status:t.reviewStatus,compact:!!t.fingerprint})]},t.path)},t[10]=s,t[11]=i,t[12]=c,t[13]=a,t[14]=o,t[15]=e):e=t[15],f=n.map(e),t[3]=n,t[4]=s,t[5]=i,t[6]=c,t[7]=a,t[8]=o,t[9]=f}else f=t[9];let p;t[16]===f?p=t[17]:(p=(0,Z.jsx)(`ul`,{className:`mt-2 flex flex-col gap-2 text-xs text-muted-foreground`,children:f}),t[16]=f,t[17]=p);let m;return t[18]!==u||t[19]!==p?(m=(0,Z.jsxs)(`section`,{className:u,children:[d,p]}),t[18]=u,t[19]=p,t[20]=m):m=t[20],m}function Ly(e){let t=(0,$.c)(17),{scope:n,context:r,item:i,active:a,children:o}=e,s=cv(n,r,Ry),c;t[0]!==r||t[1]!==i||t[2]!==n?(c=wv(n,r,i),t[0]=r,t[1]=i,t[2]=n,t[3]=c):c=t[3];let l=c,u;t[4]!==s||t[5]!==l?(u=()=>s.toggle(l),t[4]=s,t[5]=l,t[6]=u):u=t[6];let d=u,f;t[7]===a?f=t[8]:(f={enabled:a,ignoreInputs:!0},t[7]=a,t[8]=f),Co(yo.toggleReviewed,d,f);let p=l.reviewed?g:Fc,m=!l.fingerprint,h;t[9]!==p||t[10]!==m||t[11]!==l.reviewed||t[12]!==d?(h=(0,Z.jsx)(q_,{label:`Reviewed`,variant:`outline`,icon:p,shortcut:yo.toggleReviewed,disabled:m,pressed:l.reviewed,onClick:d}),t[9]=p,t[10]=m,t[11]=l.reviewed,t[12]=d,t[13]=h):h=t[13];let _;return t[14]!==o||t[15]!==h?(_=(0,Z.jsxs)(Z.Fragment,{children:[h,o]}),t[14]=o,t[15]=h,t[16]=_):_=t[16],_}function Ry(e){return xo.add(e)}var zy=Q.createContext(void 0);function By(){let e=Q.useContext(zy);if(e===void 0)throw Error(Ht(13));return e}var Vy={imageLoadingStatus:()=>null},Hy=Q.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,[o,s]=Q.useState(`idle`),c={imageLoadingStatus:o},l=Q.useMemo(()=>({imageLoadingStatus:o,setImageLoadingStatus:s}),[o,s]),u=wt(`span`,e,{state:c,ref:t,props:a,stateAttributesMapping:Vy});return(0,Z.jsx)(zy.Provider,{value:l,children:u})});function Uy(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i},o){let s=Q.useState(`idle`),c=s[1];return a(()=>{if(!o)return y;if(!e&&!i)return c(`error`),y;let a=!0,s=new window.Image,l=e=>()=>{a&&c(e)};return c(`loading`),s.onload=l(`loaded`),s.onerror=l(`error`),t&&(s.referrerPolicy=t),s.crossOrigin=n??null,r&&(s.sizes=r),i&&(s.srcset=i),e&&(s.src=e),s.complete&&c(s.naturalWidth>0?`loaded`:`error`),()=>{a=!1}},[o,e,i,r,n,t,c]),s}var Wy={...Vy,...qt},Gy=Q.forwardRef(function(e,t){let{className:n,render:r,onLoadingStatusChange:i,keepMounted:o=!1,style:s,sizes:c,srcSet:l,src:u,...d}=e,{setImageLoadingStatus:f}=By(),[p,m]=Uy(u,e,!o),h=p===`loaded`,{mounted:g,transitionStatus:_,setMounted:v}=he(h),y=Q.useRef(null),b=Q.useRef(!0);a(()=>{if(!o)return;let e=b.current;b.current=!1;let t=y.current;if(!t)return;if(!t.complete){m(`loading`);return}let n=t.naturalWidth>0?`loaded`:`error`;m(n),n===`loaded`&&e&&v(!0)},[o,u,l,c,d.crossOrigin,d.referrerPolicy,r,m,v]);let x=o?{"data-loading":p===`loading`?``:void 0,"data-error":p===`error`?``:void 0,"aria-hidden":p!==`loaded`||void 0,onLoad(){m(`loaded`)},onError(){m(`error`)}}:void 0,S=pe(e=>{i?.(e),f(e)});a(()=>{p!==`idle`&&S(p)},[p,S]),a(()=>()=>f(`idle`),[f]),be({enabled:!h,open:h,ref:y,onComplete(){h||v(!1)}});let C={imageLoadingStatus:p,transitionStatus:o&&_===`ending`?void 0:_},w=o||g,T={};c!==void 0&&(T.sizes=c),l!==void 0&&(T.srcSet=l),u!==void 0&&(T.src=u);let E=wt(`img`,e,{state:C,ref:[t,y],props:[x,d,T],stateAttributesMapping:Wy,enabled:w});return w?E:null}),Ky=Q.forwardRef(function(e,t){let{className:n,render:r,delay:i=0,style:a,...o}=e,{imageLoadingStatus:s}=By(),[c,l]=Q.useState(i===0),u=ke();return Q.useEffect(()=>(i>0?u.start(i,()=>l(!0)):l(!0),u.clear),[u,i]),wt(`span`,e,{state:{imageLoadingStatus:s},ref:t,props:o,stateAttributesMapping:Vy,enabled:s!==`loaded`&&(i===0||c)})});function qy({className:e,size:t=`default`,...n}){return(0,Z.jsx)(Hy,{"data-slot":`avatar`,"data-size":t,className:q(`group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten`,e),...n})}function Jy({className:e,...t}){return(0,Z.jsx)(Gy,{"data-slot":`avatar-image`,className:q(`aspect-square size-full rounded-full object-cover`,e),...t})}function Yy({className:e,...t}){return(0,Z.jsx)(Ky,{"data-slot":`avatar-fallback`,className:q(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t})}var Xy={open:xc,draft:Cc,merged:_c,closed:yc};function Zy(e){let t=(0,$.c)(10),{pull:n}=e,r;t[0]===n?r=t[1]:(r=Ya(n),t[0]=n,t[1]=r);let i=r,a=Xy[i],o;t[2]===a?o=t[3]:(o=(0,Z.jsx)(a,{"aria-hidden":`true`}),t[2]=a,t[3]=o);let s;t[4]===n?s=t[5]:(s=Qa(n),t[4]=n,t[5]=s);let c;return t[6]!==i||t[7]!==o||t[8]!==s?(c=(0,Z.jsxs)(nt,{variant:i,children:[o,s]}),t[6]=i,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function Qy(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(nt,{variant:`outline`,children:[(0,Z.jsx)(Ka,{"aria-hidden":`true`}),`GitHub unavailable`]}),e[0]=t):t=e[0],t}var $y={passed:(0,Z.jsx)(g,{"aria-hidden":`true`,strokeWidth:2.5,className:`size-3 shrink-0 text-add-fg`}),running:(0,Z.jsx)(dt,{"aria-hidden":`true`,className:`size-3 shrink-0`}),failed:(0,Z.jsx)(Mt,{"aria-hidden":`true`,strokeWidth:2.5,className:`size-3 shrink-0 text-del-fg`})};function eb(e){let t=(0,$.c)(6),{tone:n,label:r,className:i}=e,a;t[0]===i?a=t[1]:(a=q(`inline-flex items-center gap-1`,i),t[0]=i,t[1]=a);let o=n!==`none`&&$y[n],s;return t[2]!==r||t[3]!==a||t[4]!==o?(s=(0,Z.jsxs)(`span`,{className:a,children:[o,r]}),t[2]=r,t[3]=a,t[4]=o,t[5]=s):s=t[5],s}function tb(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground`,children:`·`}),e[0]=t):t=e[0],t}var nb={passed:`open`,failed:`closed`,none:`outline`};function rb(e){let t=(0,$.c)(63),{projectId:n,number:r,context:i,toolbarTarget:a,onBack:s,onFile:c}=e,l;t[0]!==i.connection||t[1]!==r||t[2]!==n?(l=St({connection:i.connection,projectId:n,number:r}),t[0]=i.connection,t[1]=r,t[2]=n,t[3]=l):l=t[3];let u=l,d=N(u),f=Hn(u),p;t[4]===d?p=t[5]:(p=Pt(xt(d)),t[4]=d,t[5]=p);let m=p;if($t(d)){let e;return t[6]!==s||t[7]!==f?(e=(0,Z.jsx)(Ce,{description:`The pull request could not be read.`,onRetry:f,onBack:s}),t[6]=s,t[7]=f,t[8]=e):e=t[8],e}if(!m){let e;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(o,{label:`Loading pull request`}),t[9]=e):e=t[9],e}if(m.kind===`unavailable`){let e;return t[10]!==s||t[11]!==d.waiting||t[12]!==f||t[13]!==m.reason?(e=(0,Z.jsx)(mb,{reason:m.reason,retrying:d.waiting,onRetry:f,onBack:s}),t[10]=s,t[11]=d.waiting,t[12]=f,t[13]=m.reason,t[14]=e):e=t[14],e}let h=m.pullRequest,g;t[15]!==i.connection||t[16]!==r||t[17]!==n||t[18]!==h.state?(g=h.state===`merged`||h.state===`closed`?(0,Z.jsx)(bi,{connection:i.connection,projectId:n,number:r}):void 0,t[15]=i.connection,t[16]=r,t[17]=n,t[18]=h.state,t[19]=g):g=t[19];let _;t[20]!==h.url||t[21]!==g||t[22]!==a?(_=(0,Z.jsx)(ab,{url:h.url,target:a,archive:g}),t[20]=h.url,t[21]=g,t[22]=a,t[23]=_):_=t[23];let v=`Pull request #${r}`,y;t[24]===h?y=t[25]:(y=(0,Z.jsx)(ob,{pull:h}),t[24]=h,t[25]=y);let b;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(`h2`,{children:`Description`}),t[26]=b):b=t[26];let x;t[27]===h.author?x=t[28]:(x=h.author&&(0,Z.jsx)(X,{text:`by ${h.author}`}),t[27]=h.author,t[28]=x);let S;t[29]!==h.author||t[30]!==h.createdAt?(S=h.author&&h.createdAt&&(0,Z.jsx)(tb,{}),t[29]=h.author,t[30]=h.createdAt,t[31]=S):S=t[31];let C;t[32]===h.createdAt?C=t[33]:(C=h.createdAt&&(0,Z.jsx)(`time`,{dateTime:h.createdAt,children:hb(h.createdAt)}),t[32]=h.createdAt,t[33]=C);let w;t[34]!==C||t[35]!==x||t[36]!==S?(w=(0,Z.jsxs)(`div`,{className:ib,children:[b,(0,Z.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-1.5 font-normal`,children:[x,S,C]})]}),t[34]=C,t[35]=x,t[36]=S,t[37]=w):w=t[37];let T;t[38]===h.description?T=t[39]:(T=h.description.trim()?(0,Z.jsx)(Or,{text:h.description,className:`pt-3.5 text-(length:--text-prose) leading-6 wrap-anywhere text-foreground-2 [&_h1]:text-foreground [&_h2]:text-foreground [&_h3]:text-base [&_h3]:leading-6 [&_h3]:text-foreground [&_code]:text-ui [&_code]:leading-5 [&_p]:leading-6 [&_p]:mt-1 [&_p]:mb-0 [&_ul]:mt-2 [&_ul]:mb-0 [&_ol]:mt-2 [&_ol]:mb-0 [&_li]:my-0 [&_h1]:mb-0 [&_h2]:mb-0 [&_h3]:mb-0 [&_h1]:tracking-pr-subheading [&_h2]:tracking-pr-subheading [&_h3]:tracking-pr-subheading [&_code]:rounded-sm [&_code]:px-1.25 [&_code]:py-px [&_code]:ring-1 [&_code]:ring-border [&_code]:ring-inset`}):(0,Z.jsx)(`p`,{className:`pt-3.5 text-ui text-muted-foreground`,children:`No description provided.`}),t[38]=h.description,t[39]=T);let E;t[40]!==w||t[41]!==T?(E=(0,Z.jsxs)(`section`,{"aria-label":`Description`,children:[w,T]}),t[40]=w,t[41]=T,t[42]=E):E=t[42];let D;t[43]!==s||t[44]!==c||t[45]!==h?(D=(0,Z.jsx)(cb,{pull:h,onBack:s,onFile:c}),t[43]=s,t[44]=c,t[45]=h,t[46]=D):D=t[46];let O;t[47]!==E||t[48]!==D?(O=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[E,D]}),t[47]=E,t[48]=D,t[49]=O):O=t[49];let k;t[50]===h?k=t[51]:(k=(0,Z.jsx)(`aside`,{"aria-label":`Checks and details`,className:`min-w-0 shrink-0 @min-4xl/pr:w-68`,children:(0,Z.jsx)(fb,{pull:h})}),t[50]=h,t[51]=k);let A;t[52]!==O||t[53]!==k?(A=(0,Z.jsxs)(`div`,{className:`mt-7 flex min-w-0 flex-col gap-x-11 gap-y-7 @min-4xl/pr:flex-row`,children:[O,k]}),t[52]=O,t[53]=k,t[54]=A):A=t[54];let j;t[55]!==d.waiting||t[56]!==A||t[57]!==v||t[58]!==y?(j=(0,Z.jsxs)(`article`,{"aria-busy":d.waiting,"aria-label":v,className:`mx-auto w-full max-w-280 min-w-0 px-4 pt-9 pb-12 text-ui @min-3xl/pr:px-7`,children:[y,A]}),t[55]=d.waiting,t[56]=A,t[57]=v,t[58]=y,t[59]=j):j=t[59];let M;return t[60]!==j||t[61]!==_?(M=(0,Z.jsxs)(`div`,{className:`@container/pr flex min-h-0 min-w-0 flex-1 flex-col overflow-auto`,children:[_,j]}),t[60]=j,t[61]=_,t[62]=M):M=t[62],M}var ib=`flex min-h-6 min-w-0 flex-wrap items-center gap-x-2 gap-y-1 border-b pb-1.5 text-xs leading-4 font-medium text-muted-foreground`;function ab(e){let t=(0,$.c)(21),{url:n,target:r,archive:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,nativeButton:!1,render:(0,Z.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`}),"aria-label":`Open on GitHub`,className:``}),t[0]=n,t[1]=a);let o=r!==void 0&&`hidden @min-3xl/pane:inline`,s;t[2]===o?s=t[3]:(s=q(o),t[2]=o,t[3]=s);let c;t[4]===s?c=t[5]:(c=(0,Z.jsx)(`span`,{className:s,children:`Open on GitHub`}),t[4]=s,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(h,{"aria-hidden":`true`,className:`size-3.5`}),t[6]=l):l=t[6];let u;t[7]!==a||t[8]!==c?(u=(0,Z.jsxs)(rn,{render:a,children:[c,l]}),t[7]=a,t[8]=c,t[9]=u):u=t[9];let d;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(bt,{children:`Open on GitHub`}),t[10]=d):d=t[10];let f;t[11]===u?f=t[12]:(f=(0,Z.jsxs)(Tn,{children:[u,d]}),t[11]=u,t[12]=f);let p;t[13]!==i||t[14]!==f?(p=(0,Z.jsxs)(Z.Fragment,{children:[i,f]}),t[13]=i,t[14]=f,t[15]=p):p=t[15];let m=p;if(r!==void 0){let e;return t[16]!==m||t[17]!==r?(e=r?(0,iu.createPortal)(m,r):null,t[16]=m,t[17]=r,t[18]=e):e=t[18],e}let g;return t[19]===m?g=t[20]:(g=(0,Z.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-end border-b px-3`,children:m}),t[19]=m,t[20]=g),g}function ob(e){let t=(0,$.c)(50),{pull:n}=e,r;t[0]===n.url?r=t[1]:(r=Ko(n.url)?.split(`/`).at(-1),t[0]=n.url,t[1]=r);let i=r,a,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(xc,{"aria-hidden":`true`,strokeWidth:1.75,className:`size-3.5 shrink-0`}),o=(0,Z.jsx)(`span`,{className:`shrink-0`,children:`Pull request`}),t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s;t[4]===i?s=t[5]:(s=i&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(tb,{}),(0,Z.jsx)(X,{text:i})]}),t[4]=i,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,Z.jsxs)(`div`,{className:`flex h-5.5 min-w-0 items-center gap-2 text-ui leading-5.5 font-medium text-muted-foreground`,children:[a,o,s]}),t[6]=s,t[7]=c);let l;t[8]===n.number?l=t[9]:(l=(0,Z.jsxs)(`span`,{className:`text-title-dim tabular-nums`,children:[`#`,n.number]}),t[8]=n.number,t[9]=l);let u;t[10]!==n.title||t[11]!==l?(u=(0,Z.jsxs)(`h1`,{className:`mt-3 text-4xl leading-10 font-semibold tracking-pr-title wrap-anywhere`,children:[l,` `,n.title]}),t[10]=n.title,t[11]=l,t[12]=u):u=t[12];let d;t[13]===n?d=t[14]:(d=(0,Z.jsx)(Zy,{pull:n}),t[13]=n,t[14]=d);let f;t[15]!==n.author||t[16]!==n.authorAvatarUrl?(f=n.author&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(lb,{author:n.author,url:n.authorAvatarUrl}),(0,Z.jsx)(X,{text:n.author,className:`font-medium text-foreground`}),(0,Z.jsx)(tb,{})]}),t[15]=n.author,t[16]=n.authorAvatarUrl,t[17]=f):f=t[17];let p;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(`span`,{tabIndex:0,className:`inline-flex max-w-full min-w-0 items-center gap-1.5 font-mono text-caption text-foreground outline-none`}),t[18]=p):p=t[18];let m;t[19]===n.baseBranch?m=t[20]:(m=(0,Z.jsx)(X,{text:n.baseBranch}),t[19]=n.baseBranch,t[20]=m);let h;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(Ys,{"aria-hidden":`true`,strokeWidth:1.75,className:`size-3 shrink-0 text-muted-foreground`}),t[21]=h):h=t[21];let g;t[22]===n.headBranch?g=t[23]:(g=(0,Z.jsx)(X,{text:n.headBranch}),t[22]=n.headBranch,t[23]=g);let _;t[24]!==m||t[25]!==g?(_=(0,Z.jsxs)(rn,{render:p,children:[m,h,g]}),t[24]=m,t[25]=g,t[26]=_):_=t[26];let v;t[27]!==n.baseBranch||t[28]!==n.headBranch?(v=(0,Z.jsxs)(bt,{children:[`Merges `,n.headBranch,` into `,n.baseBranch]}),t[27]=n.baseBranch,t[28]=n.headBranch,t[29]=v):v=t[29];let y;t[30]!==_||t[31]!==v?(y=(0,Z.jsxs)(Tn,{children:[_,v]}),t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(tb,{}),t[33]=b):b=t[33];let x;t[34]===n.updatedAt?x=t[35]:(x=hb(n.updatedAt),t[34]=n.updatedAt,t[35]=x);let S;t[36]===x?S=t[37]:(S=(0,Z.jsxs)(`span`,{children:[`updated `,x]}),t[36]=x,t[37]=S);let C;t[38]!==y||t[39]!==S||t[40]!==d||t[41]!==f?(C=(0,Z.jsxs)(`div`,{className:`mt-3.5 flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-2 text-ui leading-5 text-muted-foreground`,children:[d,f,y,b,S]}),t[38]=y,t[39]=S,t[40]=d,t[41]=f,t[42]=C):C=t[42];let w;t[43]===n.labels?w=t[44]:(w=n.labels.length>0&&(0,Z.jsx)(`ul`,{"aria-label":`Labels`,className:`mt-3 flex min-w-0 flex-wrap gap-1.5`,children:n.labels.map(sb)}),t[43]=n.labels,t[44]=w);let T;return t[45]!==C||t[46]!==w||t[47]!==c||t[48]!==u?(T=(0,Z.jsxs)(`header`,{className:`min-w-0`,children:[c,u,C,w]}),t[45]=C,t[46]=w,t[47]=c,t[48]=u,t[49]=T):T=t[49],T}function sb(e,t){return(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,children:(0,Z.jsx)(nt,{variant:`outline`,className:`max-w-full`,children:(0,Z.jsx)(X,{text:e.name})})},`${e.name}:${t}`)}function cb(e){let t=(0,$.c)(23),{pull:n,onBack:r,onFile:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`h2`,{children:`Conversation`}),t[0]=a):a=t[0];let o;t[1]===n.timeline.length?o=t[2]:(o=(0,Z.jsx)(`span`,{className:`font-normal tabular-nums`,children:n.timeline.length}),t[1]=n.timeline.length,t[2]=o);let s=`${n.url}#issue-comment-box`,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(In,{"aria-hidden":`true`,className:`size-3 shrink-0`}),t[3]=c):c=t[3];let l,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsxs)(`span`,{children:[`Comments on GitHub ·`,` `,(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:`reply there`})]}),u=(0,Z.jsx)(h,{"aria-hidden":`true`,className:`size-3 shrink-0`}),t[4]=l,t[5]=u):(l=t[4],u=t[5]);let d;t[6]===s?d=t[7]:(d=(0,Z.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:`ml-auto inline-flex max-w-full min-w-0 flex-wrap items-center gap-1 font-normal outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[c,l,u]}),t[6]=s,t[7]=d);let f;t[8]!==o||t[9]!==d?(f=(0,Z.jsxs)(`div`,{className:ib,children:[a,o,d]}),t[8]=o,t[9]=d,t[10]=f):f=t[10];let p;t[11]!==i||t[12]!==n.timeline?(p=n.timeline.length>0?(0,Z.jsx)(`ol`,{"aria-label":`Timeline`,className:`relative mt-3.5 flex min-w-0 flex-col gap-4 before:absolute before:top-4 before:bottom-2.5 before:left-2.5 before:w-px before:bg-border`,children:Yo(n.timeline).map(e=>{let{item:t,comments:n}=e;return(0,Z.jsx)(ub,{item:t,onFile:i,children:n.length>0&&(0,Z.jsx)(`ol`,{"aria-label":`Comments on review by ${t.author??`Unknown author`}`,className:`mt-3 flex min-w-0 flex-col gap-3 border-l pl-3`,children:n.map(e=>(0,Z.jsx)(ub,{item:e,onFile:i},e.id))})},t.id)})}):(0,Z.jsx)(`p`,{className:`pt-3.5 text-ui text-muted-foreground`,children:`No comments or reviews on GitHub yet.`}),t[11]=i,t[12]=n.timeline,t[13]=p):p=t[13];let m;t[14]===n.truncated?m=t[15]:(m=n.truncated&&(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Some labels or conversation items are not shown. Open on GitHub to see everything.`}),t[14]=n.truncated,t[15]=m);let g;t[16]===r?g=t[17]:(g=(0,Z.jsxs)(`p`,{className:`mt-4 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-xs leading-4 text-muted-foreground @min-3xl/pr:ml-7.5`,children:[`Questions about the change belong in its Walkthrough.`,(0,Z.jsx)(Y,{variant:`link`,size:`sm`,onClick:r,children:`Back to the worktree`})]}),t[16]=r,t[17]=g);let _;return t[18]!==m||t[19]!==g||t[20]!==f||t[21]!==p?(_=(0,Z.jsxs)(`section`,{"aria-label":`Conversation on GitHub`,className:`mt-7 min-w-0`,children:[f,p,m,g]}),t[18]=m,t[19]=g,t[20]=f,t[21]=p,t[22]=_):_=t[22],_}function lb(e){let t=(0,$.c)(9),{author:n,url:r}=e,i;t[0]===r?i=t[1]:(i=r&&(0,Z.jsx)(Jy,{src:r,alt:``}),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=n.slice(0,1).toUpperCase(),t[2]=n,t[3]=a);let o;t[4]===a?o=t[5]:(o=(0,Z.jsx)(Yy,{children:a}),t[4]=a,t[5]=o);let s;return t[6]!==i||t[7]!==o?(s=(0,Z.jsxs)(qy,{size:`sm`,"aria-hidden":`true`,children:[i,o]}),t[6]=i,t[7]=o,t[8]=s):s=t[8],s}function ub(e){let t=(0,$.c)(51),{item:n,onFile:r,children:i}=e,{dark:a}=To(),o;t[0]===n.reviewState?o=t[1]:(o=io(n.reviewState),t[0]=n.reviewState,t[1]=o);let s=o,c=n.author??`Unknown author`,l=n.line??n.originalLine,u=n.path,d=n.path===void 0?void 0:`${n.path}${l===void 0?``:`:${l}`}`,f;t[2]!==c||t[3]!==n.authorAvatarUrl?(f=(0,Z.jsx)(`div`,{className:`z-1 shrink-0 bg-background`,children:(0,Z.jsx)(lb,{author:c,url:n.authorAvatarUrl})}),t[2]=c,t[3]=n.authorAvatarUrl,t[4]=f):f=t[4];let p;t[5]===c?p=t[6]:(p=(0,Z.jsx)(X,{text:c,className:`text-ui leading-4.5 font-semibold text-foreground`}),t[5]=c,t[6]=p);let m;t[7]===s?m=t[8]:(m=s&&(0,Z.jsx)(nt,{variant:nb[s.tone],children:s.label}),t[7]=s,t[8]=m);let g=!s&&n.kind===`comment`?`commented · `:``,_;t[9]===n.time?_=t[10]:(_=hb(n.time),t[9]=n.time,t[10]=_);let v;t[11]!==g||t[12]!==_?(v=(0,Z.jsxs)(`span`,{children:[g,_]}),t[11]=g,t[12]=_,t[13]=v):v=t[13];let y;t[14]===n.url?y=t[15]:(y=(0,Z.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`}),t[14]=n.url,t[15]=y);let b=`Open this ${n.kind===`review`?`review`:`comment`} on GitHub`,x;t[16]!==y||t[17]!==b?(x=(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,nativeButton:!1,render:y,"aria-label":b,className:`ml-auto`}),t[16]=y,t[17]=b,t[18]=x):x=t[18];let S;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(h,{"aria-hidden":`true`,className:`size-3`}),t[19]=S):S=t[19];let C;t[20]===x?C=t[21]:(C=(0,Z.jsx)(rn,{render:x,children:S}),t[20]=x,t[21]=C);let w;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(bt,{children:`Open on GitHub`}),t[22]=w):w=t[22];let T;t[23]===C?T=t[24]:(T=(0,Z.jsxs)(Tn,{children:[C,w]}),t[23]=C,t[24]=T);let E;t[25]!==T||t[26]!==p||t[27]!==m||t[28]!==v?(E=(0,Z.jsxs)(`div`,{className:`flex min-h-5 min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs leading-4 text-muted-foreground`,children:[p,m,v,T]}),t[25]=T,t[26]=p,t[27]=m,t[28]=v,t[29]=E):E=t[29];let D;t[30]!==d||t[31]!==n.path||t[32]!==r||t[33]!==u?(D=d&&(0,Z.jsxs)(`div`,{className:`mt-2.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 rounded-t-lg border bg-muted px-2 py-1.5`,children:[r&&n.path!==void 0?(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,"aria-label":`Open ${d}`,className:`max-w-full min-w-0 justify-start`,onClick:()=>{u!==void 0&&r(u)},children:[(0,Z.jsx)(Rr,{"aria-hidden":`true`}),(0,Z.jsx)(X,{text:d})]}):(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono text-xs`,children:[(0,Z.jsx)(Rr,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Z.jsx)(X,{text:d})]}),(0,Z.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`review comment`})]}),t[30]=d,t[31]=n.path,t[32]=r,t[33]=u,t[34]=D):D=t[34];let O;t[35]!==a||t[36]!==n.diffHunk||t[37]!==u?(O=n.diffHunk&&(0,Z.jsx)(`div`,{role:`region`,"aria-label":`Code excerpt for ${u??`review comment`}`,className:`max-h-64 min-w-0 overflow-auto border-x`,children:(0,Z.jsx)(Pr,{file:{name:u??`review.diff`,contents:n.diffHunk,lang:`diff`},options:{theme:ms,preferredHighlighter:Mo,themeType:a?`dark`:`light`,disableFileHeader:!0,disableLineNumbers:!0,overflow:`wrap`}})}),t[35]=a,t[36]=n.diffHunk,t[37]=u,t[38]=O):O=t[38];let k;t[39]!==d||t[40]!==n.body?(k=n.body.trim()&&(0,Z.jsx)(Or,{text:n.body,className:q(`mt-1 text-sm leading-5.5 wrap-anywhere [&_p]:my-0 [&_p]:leading-5.5`,d&&`mt-0 rounded-b-lg border border-t-0 px-3 py-2.5 text-ui [&_p]:leading-4.75`)}),t[39]=d,t[40]=n.body,t[41]=k):k=t[41];let A;t[42]!==i||t[43]!==E||t[44]!==D||t[45]!==O||t[46]!==k?(A=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[E,D,O,k,i]}),t[42]=i,t[43]=E,t[44]=D,t[45]=O,t[46]=k,t[47]=A):A=t[47];let j;return t[48]!==A||t[49]!==f?(j=(0,Z.jsxs)(`li`,{className:`relative flex min-w-0 items-start gap-2.5`,children:[f,A]}),t[48]=A,t[49]=f,t[50]=j):j=t[50],j}var db={passed:{Icon:Wa,label:`Passed`,color:`text-add-fg`},failed:{Icon:rc,label:`Failed`,color:`text-del-fg`},running:{Icon:dt,label:`Running`,color:`text-muted-foreground`}};function fb(e){let t=(0,$.c)(34),{pull:n}=e,r;t[0]!==n.checks||t[1]!==n.checksSummary||t[2]!==n.checksTruncated?(r=to(n.checks,n.checksTruncated,n.checksSummary),t[0]=n.checks,t[1]=n.checksSummary,t[2]=n.checksTruncated,t[3]=r):r=t[3];let i=r,a;t[4]===n.mergeable?a=t[5]:(a=xa(n.mergeable),t[4]=n.mergeable,t[5]=a);let o=a,s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(`h2`,{children:`Checks`}),t[6]=s):s=t[6];let c=i.tone===`passed`?`${n.checks.length}${n.checksTruncated?`+`:``} passed`:i.label,l;t[7]!==i.tone||t[8]!==c?(l=(0,Z.jsxs)(`div`,{className:ib,children:[s,(0,Z.jsx)(eb,{tone:i.tone,label:c,className:`ml-auto text-foreground tabular-nums`})]}),t[7]=i.tone,t[8]=c,t[9]=l):l=t[9];let u;t[10]===n.checks?u=t[11]:(u=n.checks.length===0?(0,Z.jsx)(`p`,{className:`pt-3 text-ui text-muted-foreground`,children:`No checks reported by GitHub.`}):(0,Z.jsx)(`ul`,{className:`mt-1`,"aria-label":`Pull request checks`,children:n.checks.map(pb)}),t[10]=n.checks,t[11]=u);let d;t[12]===n.checksTruncated?d=t[13]:(d=n.checksTruncated&&(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`More checks are available on GitHub.`}),t[12]=n.checksTruncated,t[13]=d);let f;t[14]!==l||t[15]!==u||t[16]!==d?(f=(0,Z.jsxs)(`section`,{"aria-label":`GitHub checks`,children:[l,u,d]}),t[14]=l,t[15]=u,t[16]=d,t[17]=f):f=t[17];let p;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Head`}),t[18]=p):p=t[18];let m=n.headSha,h;t[19]===n.headSha?h=t[20]:(h=jp(n.headSha),t[19]=n.headSha,t[20]=h);let g;t[21]!==n.headSha||t[22]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex h-7 min-w-0 items-center gap-2`,children:[p,(0,Z.jsx)(`dd`,{className:`ml-auto min-w-0 font-mono text-caption font-medium`,children:(0,Z.jsx)(X,{text:m,disclose:`always`,children:h})})]}),t[21]=n.headSha,t[22]=h,t[23]=g):g=t[23];let _;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Mergeable`}),t[24]=_):_=t[24];let v;t[25]!==o.label||t[26]!==o.tone?(v=(0,Z.jsxs)(`div`,{className:`flex h-7 items-center gap-2 border-t`,children:[_,(0,Z.jsx)(`dd`,{className:`ml-auto font-medium`,children:(0,Z.jsx)(eb,{tone:o.tone,label:o.label,className:`gap-1.5`})})]}),t[25]=o.label,t[26]=o.tone,t[27]=v):v=t[27];let y;t[28]!==g||t[29]!==v?(y=(0,Z.jsxs)(`dl`,{"aria-label":`Merge`,className:`mt-5 border-y text-ui leading-4.5`,children:[g,v]}),t[28]=g,t[29]=v,t[30]=y):y=t[30];let b;return t[31]!==y||t[32]!==f?(b=(0,Z.jsxs)(Z.Fragment,{children:[f,y]}),t[31]=y,t[32]=f,t[33]=b):b=t[33],b}function pb(e,t){let n=ka(e),r=Ma(e.durationMs),a=db[n],o=a.Icon;return(0,Z.jsxs)(`li`,{className:`flex h-7 min-w-0 items-center gap-2 text-ui leading-4.5`,children:[(0,Z.jsx)(o,{role:`img`,"aria-label":a.label,className:q(`size-3.5 shrink-0`,a.color)}),(0,Z.jsx)(X,{text:e.name,className:`min-w-0 flex-1`}),r&&(0,Z.jsx)(`span`,{className:`shrink-0 text-xs leading-4 text-muted-foreground tabular-nums`,children:r}),e.detailsUrl&&(0,Z.jsxs)(Tn,{children:[(0,Z.jsxs)(rn,{render:(0,Z.jsx)(`a`,{href:e.detailsUrl,target:`_blank`,rel:`noreferrer`,"aria-label":`Details for ${e.name} on GitHub`,className:i({variant:`ghost`,size:`sm`})}),children:[`Details`,(0,Z.jsx)(h,{"aria-hidden":`true`,className:`size-2.75`})]}),(0,Z.jsxs)(bt,{children:[`Details for `,e.name,` on GitHub`]})]})]},`${e.name}:${t}`)}function mb(e){let t=(0,$.c)(28),{reason:n,retrying:r,onRetry:i,onBack:a}=e,o=Xe(),s;t[0]===n?s=t[1]:(s=po(n),t[0]=n,t[1]=s);let{description:c,action:l}=s,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(Qy,{}),t[2]=u):u=t[2];let d;t[3]!==l.kind||t[4]!==l.label||t[5]!==o?(d=l.kind===`settings`&&(0,Z.jsxs)(Y,{variant:`outline`,onClick:()=>void o({to:`/settings/$section`,params:{section:`git`}}),children:[(0,Z.jsx)(Pi,{}),l.label]}),t[3]=l.kind,t[4]=l.label,t[5]=o,t[6]=d):d=t[6];let f;t[7]!==l.kind||t[8]!==l.label||t[9]!==l.url?(f=l.kind===`install`&&(0,Z.jsxs)(Y,{variant:`outline`,nativeButton:!1,render:(0,Z.jsx)(`a`,{href:l.url,target:`_blank`,rel:`noreferrer`}),children:[(0,Z.jsx)(h,{}),l.label]}),t[7]=l.kind,t[8]=l.label,t[9]=l.url,t[10]=f):f=t[10];let p;t[11]!==l.kind||t[12]!==l.label||t[13]!==l.text?(p=l.kind===`copy`&&(0,Z.jsxs)(Y,{variant:`outline`,onClick:()=>ht(l.text,`command`),children:[(0,Z.jsx)(De,{}),l.label]}),t[11]=l.kind,t[12]=l.label,t[13]=l.text,t[14]=p):p=t[14];let m;t[15]!==l.kind||t[16]!==i||t[17]!==r?(m=l.kind!==`install`&&(0,Z.jsx)(Y,{variant:`outline`,disabled:r,onClick:i,children:`Try again`}),t[15]=l.kind,t[16]=i,t[17]=r,t[18]=m):m=t[18];let g;t[19]===a?g=t[20]:(g=(0,Z.jsx)(Y,{variant:`ghost`,onClick:a,children:`Back to the worktree`}),t[19]=a,t[20]=g);let _;return t[21]!==c||t[22]!==d||t[23]!==f||t[24]!==p||t[25]!==m||t[26]!==g?(_=(0,Z.jsxs)(zn,{title:`Pull request unavailable`,description:c,children:[u,d,f,p,m,g]}),t[21]=c,t[22]=d,t[23]=f,t[24]=p,t[25]=m,t[26]=g,t[27]=_):_=t[27],_}function hb(e){return Number.isFinite(Date.parse(e))?ze(e):`unknown time`}function gb(e){let t=(0,$.c)(53),{scope:n,context:r,document:i,onOpen:a,onBrowse:o,sideLabel:s,active:c,base:l,toolbarTarget:u,walkthrough:d,walkthroughCode:f,singleHeader:p,fileTarget:m}=e,h=c!==void 0&&c,g=p!==void 0&&p,_=n.worktreeId,v;t[0]===i?v=t[1]:(v=Up(i),t[0]=i,t[1]=v);let y;t[2]!==h||t[3]!==m||t[4]!==n.worktreeId||t[5]!==g||t[6]!==v||t[7]!==u?(y={toolbarTarget:u,active:h,worktreeId:_,entry:v,fileTarget:m,singleHeader:g},t[2]=h,t[3]=m,t[4]=n.worktreeId,t[5]=g,t[6]=v,t[7]=u,t[8]=y):y=t[8];let b;t[9]!==l||t[10]!==r||t[11]!==o||t[12]!==a||t[13]!==n||t[14]!==s||t[15]!==y?(b={base:l,scope:n,context:r,onOpen:a,onBrowse:o,sideLabel:s,interaction:y},t[9]=l,t[10]=r,t[11]=o,t[12]=a,t[13]=n,t[14]=s,t[15]=y,t[16]=b):b=t[16];let x=b;switch(i.kind){case`handoff`:{let e;return t[17]===x?e=t[18]:(e=(0,Z.jsx)(Cb,{...x}),t[17]=x,t[18]=e),e}case`walkthrough`:{let e;return t[19]!==d||t[20]!==x?(e=d?(0,Z.jsx)(d,{...x}):null,t[19]=d,t[20]=x,t[21]=e):e=t[21],e}case`all-changes`:{let e;return t[22]===x?e=t[23]:(e=(0,Z.jsx)(Cb,{...x}),t[22]=x,t[23]=e),e}case`specs`:{let e;return t[24]===x?e=t[25]:(e=(0,Z.jsx)(Cb,{...x,specsOnly:!0}),t[24]=x,t[25]=e),e}case`change`:{let e;return t[26]!==i.path||t[27]!==x?(e=(0,Z.jsx)(Tb,{...x,path:i.path}),t[26]=i.path,t[27]=x,t[28]=e):e=t[28],e}case`file`:{let e;return t[29]!==i.path||t[30]!==x?(e=(0,Z.jsx)(uy,{...x,path:i.path}),t[29]=i.path,t[30]=x,t[31]=e):e=t[31],e}case`commit`:{let e;return t[32]!==i.oid||t[33]!==x?(e=(0,Z.jsx)(Uv,{...x,oid:i.oid}),t[32]=i.oid,t[33]=x,t[34]=e):e=t[34],e}case`branch`:{let e;return t[35]===x?e=t[36]:(e=(0,Z.jsx)(Nv,{...x}),t[35]=x,t[36]=e),e}case`branch-file`:{let e;return t[37]!==i.path||t[38]!==x?(e=(0,Z.jsx)(Pv,{...x,path:i.path}),t[37]=i.path,t[38]=x,t[39]=e):e=t[39],e}case`walkthrough-step`:case`walkthrough-changes`:{let e;return t[40]!==f||t[41]!==i||t[42]!==x?(e=f?(0,Z.jsx)(f,{...x,document:i}):null,t[40]=f,t[41]=i,t[42]=x,t[43]=e):e=t[43],e}case`timeline`:{let e;return t[44]!==i.path||t[45]!==x?(e=(0,Z.jsx)(xb,{...x,path:i.path}),t[44]=i.path,t[45]=x,t[46]=e):e=t[46],e}case`graph`:{let e;return t[47]===x?e=t[48]:(e=(0,Z.jsx)(bb,{...x}),t[47]=x,t[48]=e),e}case`pull-request`:{let e;return t[49]!==r||t[50]!==i||t[51]!==u?(e=(0,Z.jsx)(_b,{document:i,context:r,toolbarTarget:u}),t[49]=r,t[50]=i,t[51]=u,t[52]=e):e=t[52],e}}}function _b(e){let t=(0,$.c)(13),{document:n,context:r,toolbarTarget:i}=e,a=fe(),o=Vt(),s;t[0]!==r||t[1]!==n.environmentId||t[2]!==a||t[3]!==o?(s=n.environmentId===void 0?r.connection:[a.connection,...o.map(vb)].find(e=>e.environmentId===n.environmentId),t[0]=r,t[1]=n.environmentId,t[2]=a,t[3]=o,t[4]=s):s=t[4];let c=s;if(!c){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(zn,{title:`Computer not paired`,description:`Pair this pull request's computer in Settings to read it.`}),t[5]=e):e=t[5],e}let l;t[6]===c?l=t[7]:(l={connection:c},t[6]=c,t[7]=l);let u;return t[8]!==n||t[9]!==a.connection.environmentId||t[10]!==l||t[11]!==i?(u=(0,Z.jsx)(yb,{document:n,context:l,localEnvironmentId:a.connection.environmentId,toolbarTarget:i}),t[8]=n,t[9]=a.connection.environmentId,t[10]=l,t[11]=i,t[12]=u):u=t[12],u}function vb(e){return e.connection}function yb(e){let t=(0,$.c)(17),{document:n,context:r,localEnvironmentId:i,toolbarTarget:a}=e,o=Xe(),s=K_(r.connection,n.projectId,n.number),c;t[0]!==s||t[1]!==r.connection||t[2]!==i||t[3]!==o?(c=e=>{if(!s){o({to:`/`});return}let t=s,n={entry:Up(e)};o(r.connection.environmentId===i?{to:`/$projectId/$worktreeId`,params:t,search:n}:{to:`/remotes/$environmentId/$projectId/$worktreeId`,params:{...t,environmentId:r.connection.environmentId},search:n})},t[0]=s,t[1]=r.connection,t[2]=i,t[3]=o,t[4]=c):c=t[4];let l=c,u;t[5]===l?u=t[6]:(u=()=>l({kind:`handoff`}),t[5]=l,t[6]=u);let d;t[7]!==s||t[8]!==l?(d=s?e=>l({kind:`file`,path:e}):void 0,t[7]=s,t[8]=l,t[9]=d):d=t[9];let f;return t[10]!==r||t[11]!==n.number||t[12]!==n.projectId||t[13]!==u||t[14]!==d||t[15]!==a?(f=(0,Z.jsx)(rb,{projectId:n.projectId,number:n.number,context:r,toolbarTarget:a,onBack:u,onFile:d}),t[10]=r,t[11]=n.number,t[12]=n.projectId,t[13]=u,t[14]=d,t[15]=a,t[16]=f):f=t[16],f}function bb(e){let t=(0,$.c)(7),{scope:n,context:r,onOpen:i,sideLabel:a}=e,o;t[0]===i?o=t[1]:(o=(e,t)=>i({kind:`commit`,oid:e},{toSide:t===!0}),t[0]=i,t[1]=o);let s;return t[2]!==r.connection||t[3]!==n||t[4]!==a||t[5]!==o?(s=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(Uh,{scope:n,connection:r.connection,sideLabel:a,onSelect:o})}),t[2]=r.connection,t[3]=n,t[4]=a,t[5]=o,t[6]=s):s=t[6],s}function xb(e){let t=(0,$.c)(17),{scope:n,context:r,path:i,onOpen:a,sideLabel:o}=e,s=`Timeline of ${i}`,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(ji,{className:`size-4 shrink-0`}),t[0]=c):c=t[0];let l;t[1]===i?l=t[2]:(l=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[c,(0,Z.jsx)(X,{text:i})]}),t[1]=i,t[2]=l);let u;t[3]!==s||t[4]!==l?(u=(0,Z.jsx)(Sv,{titleLabel:s,title:l,subtitle:`Commits that changed this file`}),t[3]=s,t[4]=l,t[5]=u):u=t[5];let d;t[6]===a?d=t[7]:(d=(e,t)=>a({kind:`commit`,oid:e.oid},{path:e.path,toSide:t===!0}),t[6]=a,t[7]=d);let f;t[8]!==r.connection||t[9]!==i||t[10]!==n||t[11]!==o||t[12]!==d?(f=(0,Z.jsx)(Gh,{scope:n,connection:r.connection,path:i,sideLabel:o,onSelect:d}),t[8]=r.connection,t[9]=i,t[10]=n,t[11]=o,t[12]=d,t[13]=f):f=t[13];let p;return t[14]!==u||t[15]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[u,f]}),t[14]=u,t[15]=f,t[16]=p):p=t[16],p}function Sb(e,t){return R(t,e?`uncommitted spec change`:`uncommitted change`)}function Cb(e){let t=(0,$.c)(68),{scope:n,context:r,interaction:i,onBrowse:a,specsOnly:o,only:s,heading:c,fullHeight:l}=e,u=o!==void 0&&o,[d,f]=(0,Q.useState)(!1),{connection:p}=r;Y_(n,r);let m=si(n,p),h=X_(n,r,m),g;t[0]!==s||t[1]!==u?(g=e=>s?s.includes(e):!u||eu(e),t[0]=s,t[1]=u,t[2]=g):g=t[2];let _=g,v,y,b,x,S,C,w,T,E,D;if(t[3]!==d||t[4]!==h||t[5]!==r||t[6]!==l||t[7]!==c||t[8]!==_||t[9]!==i||t[10]!==m||t[11]!==a||t[12]!==s||t[13]!==n||t[14]!==u){D=Symbol.for(`react.early_return_sentinel`);bb0:{let e;if(t[25]===_?e=t[26]:(e=e=>_(e.path),t[25]=_,t[26]=e),y=h.filter(e),b=i.singleHeader||c!==void 0,!u&&y.length===0&&d&&f(!1),s&&y.length===0){let e;t[27]===c?e=t[28]:(e=c&&(0,Z.jsx)(Sv,{inline:!0,title:c.title,titleLabel:c.titleLabel,children:c.after}),t[27]=c,t[28]=e);let n;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`p`,{className:`p-5 text-prose text-foreground-2`,children:`Nothing uncommitted in this step.`}),t[29]=n):n=t[29];let r;t[30]===e?r=t[31]:(r=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[e,n]}),t[30]=e,t[31]=r),D=r;break bb0}if(!u&&y.length===0){let e=m.branch?.name??`This worktree`,n;t[32]===e?n=t[33]:(n=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`font-mono text-foreground`,children:e}),` `,`matches its last commit. Browse files or history from the right.`]}),t[32]=e,t[33]=n);let r;t[34]===a?r=t[35]:(r=e=>a(`files`,e.currentTarget),t[34]=a,t[35]=r);let i;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Yn,{children:Ao(yo.surfaceFiles)}),t[36]=i):i=t[36];let o;t[37]===r?o=t[38]:(o=(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:r,children:[`Files `,i]}),t[37]=r,t[38]=o);let s;t[39]===a?s=t[40]:(s=e=>a(`history`,e.currentTarget),t[39]=a,t[40]=s);let c;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Yn,{children:Ao(yo.surfaceHistory)}),t[41]=c):c=t[41];let l;t[42]===s?l=t[43]:(l=(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:s,children:[`History `,c]}),t[42]=s,t[43]=l);let u;t[44]!==n||t[45]!==o||t[46]!==l?(u=(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-xl`,children:(0,Z.jsxs)(zn,{title:`No changes to review`,description:n,children:[o,l]})}),t[44]=n,t[45]=o,t[46]=l,t[47]=u):u=t[47],D=u;break bb0}E=`flex min-h-0 flex-1 flex-col`,v=wy,x=l,S=n,C=r,w=i,T=u||s?{paths:y.map(wb)}:{}}t[3]=d,t[4]=h,t[5]=r,t[6]=l,t[7]=c,t[8]=_,t[9]=i,t[10]=m,t[11]=a,t[12]=s,t[13]=n,t[14]=u,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S,t[20]=C,t[21]=w,t[22]=T,t[23]=E,t[24]=D}else v=t[15],y=t[16],b=t[17],x=t[18],S=t[19],C=t[20],w=t[21],T=t[22],E=t[23],D=t[24];if(D!==Symbol.for(`react.early_return_sentinel`))return D;let O=!b,k;t[48]!==d||t[49]!==y||t[50]!==r||t[51]!==c||t[52]!==n||t[53]!==b||t[54]!==u?(k=b?{toolbar:e=>(0,Z.jsxs)(Sv,{inline:!0,...c?{title:c.title,titleLabel:c.titleLabel}:{title:`All changes`},subtitle:Sb(u,y.length),children:[e,c?.after]})}:{header:e=>(0,Z.jsx)(`div`,{className:`pt-6`,children:(0,Z.jsx)(ey,{scope:n,context:r,label:Sb(u,y.length),items:y,controls:e,actionsOpen:d,onActionsOpenChange:f,actions:(0,Z.jsx)(Dv,{scope:n,context:r,entries:y})})})},t[48]=d,t[49]=y,t[50]=r,t[51]=c,t[52]=n,t[53]=b,t[54]=u,t[55]=k):k=t[55];let A;t[56]!==v||t[57]!==O||t[58]!==k||t[59]!==x||t[60]!==S||t[61]!==C||t[62]!==w||t[63]!==T?(A=(0,Z.jsx)(v,{fullHeight:x,scope:S,context:C,interaction:w,...T,column:O,...k}),t[56]=v,t[57]=O,t[58]=k,t[59]=x,t[60]=S,t[61]=C,t[62]=w,t[63]=T,t[64]=A):A=t[64];let j;return t[65]!==A||t[66]!==E?(j=(0,Z.jsx)(`div`,{className:E,children:A}),t[65]=A,t[66]=E,t[67]=j):j=t[67],j}function wb(e){return e.path}function Tb(e){let t=(0,$.c)(14),{scope:n,context:r,interaction:i,onOpen:a,path:o}=e,{connection:s}=r;Y_(n,r);let c=si(n,s),l;if(t[0]===o?l=t[1]:(l=[o],t[0]=o,t[1]=l),!X_(n,r,c,l).find(e=>e.path===o)){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(zn,{title:`Change no longer present`,description:`Choose a change that is still present in the current review.`}),t[2]=e):e=t[2],e}let u;t[3]!==r||t[4]!==i||t[5]!==a||t[6]!==o||t[7]!==n?(u=e=>(0,Z.jsx)(wy,{headerActions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q_,{label:`Timeline`,iconOnly:!0,icon:ji,onClick:()=>a({kind:`timeline`,path:o})}),i.singleHeader&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q_,{label:`Open file`,iconOnly:!0,icon:sc,onClick:()=>a({kind:`file`,path:o})}),e]})]}),headerLeading:i.singleHeader?void 0:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Y,{variant:`ghost`,size:`xs`,"aria-label":`Open file`,onClick:()=>a({kind:`file`,path:o}),children:[(0,Z.jsx)(sc,{}),(0,Z.jsx)(`span`,{className:`max-narrow:sr-only`,children:`Open file`})]}),e]}),scope:n,context:r,interaction:i,paths:[o]}),t[3]=r,t[4]=i,t[5]=a,t[6]=o,t[7]=n,t[8]=u):u=t[8];let d;return t[9]!==r||t[10]!==o||t[11]!==n||t[12]!==u?(d=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(Tm,{scope:n,context:r,path:o,variant:`quiet`,children:u})}),t[9]=r,t[10]=o,t[11]=n,t[12]=u,t[13]=d):d=t[13],d}var Eb=[{value:`uncommitted`,label:`Uncommitted`,Icon:xr},{value:`branch`,label:`Branch`,Icon:hr}];function Db(e){let t=(0,$.c)(6),{value:n,onValueChange:r}=e,i;t[0]===r?i=t[1]:(i=e=>{Di(e)&&r(e)},t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Ts,{"aria-label":`Compare`,children:Eb.map(Ob)}),t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==n?(o=(0,Z.jsx)(Ds,{className:`shrink-0`,value:n,onValueChange:i,children:a}),t[3]=i,t[4]=n,t[5]=o):o=t[5],o}function Ob(e){let{value:t,label:n,Icon:r}=e;return(0,Z.jsxs)(Tn,{children:[(0,Z.jsxs)(rn,{render:(0,Z.jsx)(fo,{value:t,"aria-label":n}),children:[(0,Z.jsx)(r,{className:`@min-3xl/pane:hidden`}),(0,Z.jsx)(`span`,{className:`hidden whitespace-nowrap @min-3xl/pane:inline`,children:n})]}),(0,Z.jsx)(bt,{children:n})]},t)}function kb(e){let t=(0,$.c)(80),{scope:n,connection:r,base:i,onBase:a,compact:o}=e,s=o!==void 0&&o,[c,l]=(0,Q.useState)(!1),u=hi(n,r,c),d=Ri(n,r,i),f,p,m,h,g,_,v,y,b,x,S,C,w,T,E;if(t[0]!==i||t[1]!==u.refresh||t[2]!==u.result||t[3]!==s||t[4]!==d.result||t[5]!==a||t[6]!==c){let e=Pt(xt(u.result)),n;t[22]===d.result?n=t[23]:(n=Pt(xt(d.result)),t[22]=d.result,t[23]=n);let r=i??n?.base?.ref,o;t[24]===r?o=t[25]:(o=r===void 0?`the default branch`:Mp(r),t[24]=r,t[25]=o);let D=o,O=e?.defaultRef??null,k=i??O,A=[{heading:`Local`,entries:e?.bases.filter(Mb)??[]},{heading:`Remote`,entries:e?.bases.filter(jb)??[]}].filter(Ab),j=e=>{a(e===O?void 0:e),l(!1)};h=Jt,g=c,_=l;let M=s?`max-w-24 @min-3xl/pane:max-w-40`:`w-full`,N;t[26]===M?N=t[27]:(N=q(`justify-between`,M),t[26]=M,t[27]=N);let P=`Compare against ${D}`,F;t[28]!==N||t[29]!==P?(F=(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,className:N,"aria-label":P,title:`Choose the branch this one is compared against`}),t[28]=N,t[29]=P,t[30]=F):F=t[30];let I=s&&`hidden @min-3xl/pane:block`,L;t[31]===I?L=t[32]:(L=q(`size-3.5 shrink-0 text-muted-foreground`,I),t[31]=I,t[32]=L);let R;t[33]===L?R=t[34]:(R=(0,Z.jsx)(hr,{className:L}),t[33]=L,t[34]=R);let z=`Against ${D}`,B=s&&`hidden @min-3xl/pane:inline`,V;t[35]===B?V=t[36]:(V=q(`text-muted-foreground`,B),t[35]=B,t[36]=V);let H;t[37]===V?H=t[38]:(H=(0,Z.jsxs)(`span`,{className:V,children:[`Against`,` `]}),t[37]=V,t[38]=H);let U;t[39]!==D||t[40]!==z||t[41]!==H?(U=(0,Z.jsxs)(X,{text:z,children:[H,D]}),t[39]=D,t[40]=z,t[41]=H,t[42]=U):U=t[42];let W;t[43]!==R||t[44]!==U?(W=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[R,U]}),t[43]=R,t[44]=U,t[45]=W):W=t[45];let G;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)($s,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[46]=G):G=t[46],t[47]!==F||t[48]!==W?(v=(0,Z.jsxs)(vn,{render:F,children:[W,G]}),t[47]=F,t[48]=W,t[49]=v):v=t[49],m=mn,T=`start`,E=`w-72`,p=Br,t[50]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(Ur,{"aria-label":`Find a base branch`,placeholder:`Find a branch`}),t[50]=w):w=t[50],f=tr,y=`Base branches`,t[51]===u.result?b=t[52]:(b=yn(u.result)&&(0,Z.jsx)(`p`,{role:`status`,className:`p-3 text-xs text-muted-foreground`,children:`Reading branches…`}),t[51]=u.result,t[52]=b),t[53]!==u.refresh||t[54]!==u.result?(x=$t(u.result)&&(0,Z.jsxs)(`div`,{className:`p-3 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`block`,children:`The branches could not be read.`}),(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,className:`mt-2`,onClick:u.refresh,children:`Try again`})]}),t[53]=u.refresh,t[54]=u.result,t[55]=x):x=t[55],t[56]===u.result?S=t[57]:(S=gt(u.result)&&(0,Z.jsx)(Qn,{children:`No branch matches.`}),t[56]=u.result,t[57]=S),C=A.map(e=>(0,Z.jsx)(ca,{heading:e.heading,children:e.entries.map(e=>(0,Z.jsxs)(ir,{value:e.name,"data-checked":e.ref===k,onSelect:()=>j(e.ref),children:[(0,Z.jsx)(X,{text:e.name}),e.ref===O&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`default`})]},e.ref))},e.heading)),t[0]=i,t[1]=u.refresh,t[2]=u.result,t[3]=s,t[4]=d.result,t[5]=a,t[6]=c,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S,t[18]=C,t[19]=w,t[20]=T,t[21]=E}else f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12],v=t[13],y=t[14],b=t[15],x=t[16],S=t[17],C=t[18],w=t[19],T=t[20],E=t[21];let D;t[58]!==f||t[59]!==y||t[60]!==b||t[61]!==x||t[62]!==S||t[63]!==C?(D=(0,Z.jsxs)(f,{"aria-label":y,children:[b,x,S,C]}),t[58]=f,t[59]=y,t[60]=b,t[61]=x,t[62]=S,t[63]=C,t[64]=D):D=t[64];let O;t[65]!==p||t[66]!==D||t[67]!==w?(O=(0,Z.jsxs)(p,{children:[w,D]}),t[65]=p,t[66]=D,t[67]=w,t[68]=O):O=t[68];let k;t[69]!==m||t[70]!==O||t[71]!==T||t[72]!==E?(k=(0,Z.jsx)(m,{align:T,className:E,children:O}),t[69]=m,t[70]=O,t[71]=T,t[72]=E,t[73]=k):k=t[73];let A;return t[74]!==h||t[75]!==g||t[76]!==_||t[77]!==v||t[78]!==k?(A=(0,Z.jsxs)(h,{open:g,onOpenChange:_,children:[v,k]}),t[74]=h,t[75]=g,t[76]=_,t[77]=v,t[78]=k,t[79]=A):A=t[79],A}function Ab(e){return e.entries.length>0}function jb(e){return e.remote}function Mb(e){return!e.remote}function Nb(e,t){let n=(0,$.c)(6),r;n[0]===e?r=n[1]:(r=b(e),n[0]=e,n[1]=r);let i;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={mode:`promiseExit`},n[2]=i):i=n[2];let a=c(r,i),o;return n[3]!==a||n[4]!==t?(o=e=>{a(t).then(t=>{bn(t)&&e()})},n[3]=a,n[4]=t,n[5]=o):o=n[5],o}var Pb=class extends Q.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}render(){return this.state.error?(0,Z.jsx)(Ce,{description:la(this.state.error),onRetry:()=>this.props.reset(()=>this.setState({error:null}))}):this.props.children}};function Fb(e){let t=(0,$.c)(9),{children:n,connection:r,scope:i,loadingLabel:a,documentKey:s}=e,c=a===void 0?`Loading review`:a,l=Nb(r,i),u;t[0]===c?u=t[1]:(u=(0,Z.jsx)(o,{label:c}),t[0]=c,t[1]=u);let d;t[2]!==n||t[3]!==s||t[4]!==l?(d=(0,Z.jsx)(Pb,{reset:l,children:n},s),t[2]=n,t[3]=s,t[4]=l,t[5]=d):d=t[5];let f;return t[6]!==u||t[7]!==d?(f=(0,Z.jsx)(Q.Suspense,{fallback:u,children:d}),t[6]=u,t[7]=d,t[8]=f):f=t[8],f}function Ib(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({layout:n,onSurface:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=zb(),t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=e=>(0,Z.jsx)(Vb,{...i,actionsTarget:e}),t[5]=i,t[6]=o);let s;return t[7]!==n||t[8]!==r||t[9]!==i.surface||t[10]!==o?(s=(0,Z.jsx)(Lb,{layout:n,surfaces:Rb,names:a,published:!1,surface:i.surface,onSurface:r,children:o}),t[7]=n,t[8]=r,t[9]=i.surface,t[10]=o,t[11]=s):s=t[11],s}function Lb(e){let t=(0,$.c)(19),{layout:n,surfaces:r,names:i,published:a,surface:o,onSurface:s,children:c}=e,{element:l,attach:u}=ha(),d;t[0]===u?d=t[1]:(d=(0,Z.jsx)(`div`,{ref:u,className:`ml-auto flex shrink-0 items-center gap-0.5`}),t[0]=u,t[1]=d);let f=d,p;t[2]!==l||t[3]!==c?(p=c(l),t[2]=l,t[3]=c,t[4]=p):p=t[4];let m=p,h=n===`docked`&&`motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-right-1 duration-150`,g;t[5]===h?g=t[6]:(g=q(`flex h-full min-h-0 flex-col overflow-hidden rounded-paper bg-card shadow-paper`,h),t[5]=h,t[6]=g);let _;t[7]!==m||t[8]!==n||t[9]!==i||t[10]!==s||t[11]!==a||t[12]!==o||t[13]!==r||t[14]!==f?(_=n===`docked`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-1 border-b pr-2.5 pl-4`,children:[(0,Z.jsx)(X,{className:`text-ui leading-5 font-semibold`,render:(0,Z.jsx)(`h2`,{}),text:i[o]}),f]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 text-sm`,children:m})]}):(0,Z.jsxs)(Ds,{value:o,onValueChange:e=>{ci(e)&&s(e)},className:`min-h-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-1 border-b px-1.5`,children:[(0,Z.jsx)(Ts,{className:`h-8 min-w-0 flex-1`,children:r.map(e=>(0,Z.jsx)(X,{propagateEscape:!0,text:i[e],renderTrigger:t=>(0,Z.jsxs)(fo,{value:e,className:`min-w-0`,children:[(0,Z.jsx)(Bb,{published:a,surface:e,className:`size-3.5 shrink-0`}),t]})},e))}),f]}),(0,Z.jsx)(No,{value:o,className:`min-h-0 overflow-hidden`,children:m})]}),t[7]=m,t[8]=n,t[9]=i,t[10]=s,t[11]=a,t[12]=o,t[13]=r,t[14]=f,t[15]=_):_=t[15];let v;return t[16]!==g||t[17]!==_?(v=(0,Z.jsx)(`aside`,{"aria-label":`Review sidebar`,"data-testid":`review-sidebar`,className:g,children:_}),t[16]=g,t[17]=_,t[18]=v):v=t[18],v}var Rb=[`files`,`changes`,`history`];function zb(){return Kp}function Bb(e){let t=(0,$.c)(7),{published:n,surface:r,className:i}=e;if(r===`files`){let e;return t[0]===i?e=t[1]:(e=(0,Z.jsx)(lc,{className:i}),t[0]=i,t[1]=e),e}if(r===`history`){let e;return t[2]===i?e=t[3]:(e=(0,Z.jsx)(ji,{className:i}),t[2]=i,t[3]=e),e}let a;return t[4]!==i||t[5]!==n?(a=n?(0,Z.jsx)(Tc,{className:i}):(0,Z.jsx)(xr,{className:i}),t[4]=i,t[5]=n,t[6]=a):a=t[6],a}function Vb(e){let t=(0,$.c)(38),{changesNavigation:n,guided:r,scope:i,context:a,worktreePath:o,surface:s,activeEntry:c,available:l,onOpen:u,sideLabel:d,changes:f,actionsTarget:p}=e;if(!l){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`div`,{className:`p-3`,children:(0,Z.jsx)(zn,{title:`Worktree unavailable`,description:`Restore the checkout and return to Porcelain to browse its files and Git state.`})}),t[0]=e):e=t[0],e}let m=s===`files`?`Loading files`:`Loading review`,h=`${i.worktreeId}:${s}`,g;t[1]!==n||t[2]!==c||t[3]!==f||t[4]!==a||t[5]!==r||t[6]!==u||t[7]!==i||t[8]!==d||t[9]!==s?(g=s===`changes`&&(0,Z.jsx)(n,{scope:i,context:a,activeEntry:c,onOpen:u,sideLabel:d,changeScope:f.scope,base:f.base,onChangeScope:f.onScope,onBase:f.onBase,allChanges:r?zp:{kind:`handoff`}}),t[1]=n,t[2]=c,t[3]=f,t[4]=a,t[5]=r,t[6]=u,t[7]=i,t[8]=d,t[9]=s,t[10]=g):g=t[10];let _;t[11]!==p||t[12]!==c||t[13]!==a.connection||t[14]!==u||t[15]!==i||t[16]!==d||t[17]!==s||t[18]!==o?(_=s===`files`&&(0,Z.jsx)(na,{scope:i,connection:a.connection,worktreePath:o,selected:c?.startsWith(`file:`)?c.slice(5):``,onOpen:u,sideLabel:d,actionsTarget:p}),t[11]=p,t[12]=c,t[13]=a.connection,t[14]=u,t[15]=i,t[16]=d,t[17]=s,t[18]=o,t[19]=_):_=t[19];let v;t[20]!==c||t[21]!==a.connection||t[22]!==u||t[23]!==i||t[24]!==d||t[25]!==s?(v=s===`history`&&(0,Z.jsx)(zh,{scope:i,connection:a.connection,selected:c?.startsWith(`commit:`)?c.slice(7):``,onSelect:(e,t)=>u({kind:`commit`,oid:e},{toSide:t===!0,preserveFocus:!0}),sideLabel:d,onOpenGraph:()=>u({kind:`graph`}),onOpenChanges:()=>u(zp)}),t[20]=c,t[21]=a.connection,t[22]=u,t[23]=i,t[24]=d,t[25]=s,t[26]=v):v=t[26];let y;t[27]!==a.connection||t[28]!==i||t[29]!==m||t[30]!==h||t[31]!==g||t[32]!==_||t[33]!==v?(y=(0,Z.jsxs)(Fb,{connection:a.connection,scope:i,loadingLabel:m,children:[g,_,v]},h),t[27]=a.connection,t[28]=i,t[29]=m,t[30]=h,t[31]=g,t[32]=_,t[33]=v,t[34]=y):y=t[34];let b=y,x;return t[35]!==b||t[36]!==s?(x=s===`changes`?(0,Z.jsx)(ti,{className:`h-full`,children:b}):(0,Z.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:b}),t[35]=b,t[36]=s,t[37]=x):x=t[37],x}var Hb={files:yo.surfaceFiles,changes:yo.surfaceChanges,history:yo.surfaceHistory};function Ub(e){let t=(0,$.c)(32),{surfaces:n,names:r,published:i,surface:a,open:o,onSelect:s,onHide:c,onToggle:l,toggleRef:u}=e,d=o?`Hide side panel`:`Show side panel`,f;if(t[0]!==r||t[1]!==c||t[2]!==s||t[3]!==o||t[4]!==i||t[5]!==a||t[6]!==n){let e;t[8]!==r||t[9]!==c||t[10]!==s||t[11]!==o||t[12]!==i||t[13]!==a?(e=e=>{let t=o&&a===e;return(0,Z.jsx)(`span`,{"data-selected":t||void 0,className:`workspace-choice inline-flex rounded-lg data-selected:text-foreground`,children:(0,Z.jsxs)(Tn,{children:[(0,Z.jsx)(rn,{render:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":r[e],"aria-pressed":t,"aria-keyshortcuts":Hb[e],onClick:()=>t?c():s(e)}),children:(0,Z.jsx)(Bb,{published:i,surface:e})}),(0,Z.jsxs)(bt,{side:`left`,children:[r[e],` `,(0,Z.jsx)(Yn,{children:Ao(Hb[e])})]})]})},e)},t[8]=r,t[9]=c,t[10]=s,t[11]=o,t[12]=i,t[13]=a,t[14]=e):e=t[14],f=n.map(e),t[0]=r,t[1]=c,t[2]=s,t[3]=o,t[4]=i,t[5]=a,t[6]=n,t[7]=f}else f=t[7];let p;t[15]!==l||t[16]!==o||t[17]!==d||t[18]!==u?(p=(0,Z.jsx)(Y,{ref:u,variant:`ghost`,size:`icon`,className:`mt-auto`,"aria-label":d,"aria-expanded":o,"aria-keyshortcuts":yo.toggleSidebar,onClick:l}),t[15]=l,t[16]=o,t[17]=d,t[18]=u,t[19]=p):p=t[19];let m;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(kc,{}),t[20]=m):m=t[20];let h;t[21]===p?h=t[22]:(h=(0,Z.jsx)(rn,{render:p,children:m}),t[21]=p,t[22]=h);let g;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(Yn,{children:Ao(yo.toggleSidebar)}),t[23]=g):g=t[23];let _;t[24]===d?_=t[25]:(_=(0,Z.jsxs)(bt,{side:`left`,children:[d,` `,g]}),t[24]=d,t[25]=_);let v;t[26]!==h||t[27]!==_?(v=(0,Z.jsxs)(Tn,{children:[h,_]}),t[26]=h,t[27]=_,t[28]=v):v=t[28];let y;return t[29]!==f||t[30]!==v?(y=(0,Z.jsxs)(`nav`,{"aria-label":`Side panel`,className:`flex w-11 shrink-0 flex-col items-center gap-1 pt-2.5 pb-2 pl-1 text-muted-foreground`,children:[f,v]}),t[29]=f,t[30]=v,t[31]=y):y=t[31],y}function Wb(e){let t=(0,$.c)(177),{worktree:n,projectId:r,search:i,onSearch:a,context:o,navigationTrigger:s,walkthrough:c,changesNavigation:l,walkthroughCode:u,firstDocument:d}=e,{open:f,setOpen:p}=O_(),[m,h]=(0,Q.useState)(!1),g=Gg(),[_,v]=(0,Q.useState)(g);_!==g&&(v(g),g&&m&&(p(!0),h(!1)));let y=ha(),b=ha(),x=ha(),{isMobile:S,open:C,openMobile:w}=kt(),T=i.surface??(d.guided?`changes`:`files`),E;t[0]!==r||t[1]!==n.id?(E={projectId:r,worktreeId:n.id},t[0]=r,t[1]=n.id,t[2]=E):E=t[2];let D=E,{saved:O,focused:k,setFocused:A}=x_(n.id),j=sa(D,o.connection),M=Ri(D,o.connection,i.base).result,N=Pt(xt(M))?.files.length===0&&(Pt(xt(j))?.changes.length??0)>0,P;t[3]===j?P=t[4]:(P=At(xt(j)),t[3]=j,t[4]=P);let F=P,I;t[5]!==O||t[6]!==i.entry||t[7]!==i.side?(I=!O&&!Wp(i.entry)&&!Wp(i.side),t[5]=O,t[6]=i.entry,t[7]=i.side,t[8]=I):I=t[8];let L=I,R=!L||!F&&!d.pending,z=d.title===`Walkthrough`?`walkthrough`:`handoff`,B=d.title===`Walkthrough`||(Pt(xt(j))?.changes.length??0)>0?z:null,V=m&&!g,H;t[9]!==B||t[10]!==d.companion||t[11]!==z||t[12]!==k||t[13]!==x.element||t[14]!==a||t[15]!==R||t[16]!==i.entry||t[17]!==i.side||t[18]!==A||t[19]!==V||t[20]!==n.id?(H={firstDocument:z,companion:d.companion,worktreeId:n.id,entry:i.entry,side:i.side,onSearch:a,fallback:B,focused:k,setFocused:A,ready:R,focusBoundary:x.element,focusBoundaryOpen:V},t[9]=B,t[10]=d.companion,t[11]=z,t[12]=k,t[13]=x.element,t[14]=a,t[15]=R,t[16]=i.entry,t[17]=i.side,t[18]=A,t[19]=V,t[20]=n.id,t[21]=H):H=t[21];let U=M_(H),W;t[22]!==k||t[23]!==U.split?(W=o_(Yb(U.split,k)),t[22]=k,t[23]=U.split,t[24]=W):W=t[24];let G=W,ee;t[25]!==f||t[26]!==y||t[27]!==p?(ee=()=>{f&&y.element?.focus(),p(Kb)},t[25]=f,t[26]=y,t[27]=p,t[28]=ee):ee=t[28];let te=ee,ne;t[29]!==g||t[30]!==te?(ne=()=>{g?te():h(Gb)},t[29]=g,t[30]=te,t[31]=ne):ne=t[31];let re;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(re={ignoreInputs:!0},t[32]=re):re=t[32],Co(yo.toggleSidebar,ne,re);let[ie,ae]=(0,Q.useState)(),K;t[33]!==g||t[34]!==k||t[35]!==U?(K=(e,t)=>{let n=Up(e),r=+(k===0),i=t?.toSide?r:U.open(k,n,t?.preserveFocus===!0&&g);ae(t?.path?{path:t.path,nonce:Date.now(),pane:i,key:n}:void 0),t?.toSide&&U.openToSide(k,n),h(!1)},t[33]=g,t[34]=k,t[35]=U,t[36]=K):K=t[36];let oe=K,q;t[37]===a?q=t[38]:(q=e=>{a({surface:e})},t[37]=a,t[38]=q);let se=q,ce;t[39]!==g||t[40]!==p||t[41]!==se?(ce=e=>{se(e),g?p(!0):h(!0)},t[39]=g,t[40]=p,t[41]=se,t[42]=ce):ce=t[42];let le=ce,ue;t[43]===le?ue=t[44]:(ue=()=>le(`changes`),t[43]=le,t[44]=ue);let de;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(de={ignoreInputs:!0},t[45]=de):de=t[45],Co(yo.surfaceChanges,ue,de);let J;t[46]===le?J=t[47]:(J=()=>le(`files`),t[46]=le,t[47]=J);let fe;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(fe={ignoreInputs:!0},t[48]=fe):fe=t[48],Co(yo.surfaceFiles,J,fe);let pe;t[49]===le?pe=t[50]:(pe=()=>le(`history`),t[49]=le,t[50]=pe);let me;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(me={ignoreInputs:!0},t[51]=me):me=t[51],Co(yo.surfaceHistory,pe,me);let he=ha(),ge;t[52]!==he||t[53]!==le?(ge=(e,t)=>{he.attach(t),le(e)},t[52]=he,t[53]=le,t[54]=ge):ge=t[54];let _e=ge,ve=i.scope??(d.guided&&!N?`branch`:`uncommitted`),ye,be;t[55]===a?(ye=t[56],be=t[57]):(ye=e=>a({scope:e}),be=e=>a({base:e}),t[55]=a,t[56]=ye,t[57]=be);let xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae,je,Me,Ne;if(t[58]!==_e||t[59]!==he||t[60]!==l||t[61]!==o||t[62]!==g||t[63]!==ie||t[64]!==d||t[65]!==k||t[66]!==U||t[67]!==m||t[68]!==x||t[69]!==b||t[70]!==s||t[71]!==S||t[72]!==C||t[73]!==w||t[74]!==L||t[75]!==a||t[76]!==oe||t[77]!==j||t[78]!==f||t[79]!==y||t[80]!==D||t[81]!==i.base||t[82]!==p||t[83]!==se||t[84]!==le||t[85]!==G||t[86]!==T||t[87]!==ve||t[88]!==ye||t[89]!==be||t[90]!==te||t[91]!==c||t[92]!==u||t[93]!==n.available||t[94]!==n.path){let e={scope:ve,onScope:ye,onBase:be},r=U.panes[k]?.active??void 0,_=t=>(0,Z.jsx)(Ib,{changesNavigation:l,guided:d.title===`Walkthrough`,layout:t,scope:D,context:o,worktreePath:n.path,surface:T,activeEntry:r,available:n.available,onSurface:se,onOpen:oe,sideLabel:G,changes:{...e,base:i.base,onBase:e=>a({base:e})}}),v;t[108]!==he||t[109]!==o||t[110]!==g||t[111]!==U||t[112]!==m||t[113]!==b||t[114]!==D?(v=e=>(0,Z.jsxs)(`div`,{"data-review-controls":``,className:`contents`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-5 w-px bg-border`}),(0,Z.jsx)(Rg,{scope:D,context:o}),(0,Z.jsxs)(Tn,{children:[(0,Z.jsx)(rn,{render:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,ref:e=>b.attach(e),className:`xl:hidden`,"aria-label":`Review`,"aria-haspopup":`dialog`,"aria-expanded":m&&!g,"aria-keyshortcuts":yo.toggleSidebar,onClick:()=>{he.attach(null),U.selectPane(e),h(!0)},children:(0,Z.jsx)(kc,{})})}),(0,Z.jsxs)(bt,{role:`tooltip`,className:`break-all`,children:[`Review `,(0,Z.jsx)(Yn,{children:Ao(yo.toggleSidebar)})]})]})]}),t[108]=he,t[109]=o,t[110]=g,t[111]=U,t[112]=m,t[113]=b,t[114]=D,t[115]=v):v=t[115];let E=v,O;t[116]===oe?O=t[117]:(O=e=>oe({kind:`file`,path:e}),t[116]=oe,t[117]=O),t[118]!==o.connection||t[119]!==U.bindQuickOpen||t[120]!==U.recentFiles||t[121]!==D||t[122]!==O?(Me=(0,Z.jsx)(Ii,{bindPopup:U.bindQuickOpen,openFiles:U.recentFiles,scope:D,connection:o.connection,onOpen:O}),t[118]=o.connection,t[119]=U.bindQuickOpen,t[120]=U.recentFiles,t[121]=D,t[122]=O,t[123]=Me):Me=t[123];let A=S?0:480,M;t[124]!==o||t[125]!==D?(M=(0,Z.jsx)(om,{scope:D,context:o}),t[124]=o,t[125]=D,t[126]=M):M=t[126];let N;t[127]!==o||t[128]!==oe||t[129]!==D?(N=(0,Z.jsx)(sm,{scope:D,context:o,onOpen:oe}),t[127]=o,t[128]=oe,t[129]=D,t[130]=N):N=t[130];let P=(0,Z.jsxs)(`section`,{"aria-label":`Review content`,className:`flex h-full min-w-0 flex-col overflow-hidden rounded-paper border bg-card`,children:[M,N,(0,Z.jsx)(qb,{walkthrough:c,walkthroughCode:u,firstDocument:d,changesNavigation:l,fileTarget:ie,scope:D,context:o,overview:j,needsDefault:L,layout:U,base:i.base,changes:e,focused:k,onOpen:oe,onBrowse:_e,navigationTrigger:s,navigatorIsMobile:S,navigatorOpen:C,navigatorOpenMobile:w,tabControls:E})]}),F;t[131]!==A||t[132]!==P?(F=(0,Z.jsx)(ai,{id:`review-document`,minSize:A,children:P}),t[131]=A,t[132]=P,t[133]=F):F=t[133];let I=f&&g&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Si,{"aria-label":`Document panes and side panel`,className:`w-2 bg-transparent after:w-2`}),(0,Z.jsx)(ai,{id:`review-sidebar`,defaultSize:320,minSize:260,maxSize:520,children:_(`docked`)})]}),R;t[134]!==F||t[135]!==I?(R=(0,Z.jsxs)(aa,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[F,I]}),t[134]=F,t[135]=I,t[136]=R):R=t[136];let z;t[137]!==g||t[138]!==f||t[139]!==y||t[140]!==p||t[141]!==le||t[142]!==T||t[143]!==te?(z=g&&(0,Z.jsx)(Ub,{surfaces:Rb,names:zb(),published:!1,surface:T,open:f,onSelect:le,onHide:()=>p(!1),onToggle:te,toggleRef:e=>y.attach(e)}),t[137]=g,t[138]=f,t[139]=y,t[140]=p,t[141]=le,t[142]=T,t[143]=te,t[144]=z):z=t[144],t[145]!==R||t[146]!==z?(Ne=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[R,z]}),t[145]=R,t[146]=z,t[147]=Ne):Ne=t[147],Se=rt,ke=m&&!g,Ae=h,t[148]===U?je=t[149]:(je=e=>{e||U.focusDestination()},t[148]=U,t[149]=je),xe=kn,t[150]!==U||t[151]!==x?(Ce=e=>{x.attach(e),e===null&&U.focusDestination()},t[150]=U,t[151]=x,t[152]=Ce):Ce=t[152],t[153]!==he.element||t[154]!==U||t[155]!==x.element||t[156]!==b.element?(we=()=>{if(U.hasDestinationFocus())return!1;let e=document.activeElement;return e===document.body||x.element?.contains(e)?he.element?.isConnected?he.element:b.element:!1},t[153]=he.element,t[154]=U,t[155]=x.element,t[156]=b.element,t[157]=we):we=t[157],Te=`w-[min(90vw,22rem)]!`,Ee=!1,t[158]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,Z.jsxs)(ut,{className:`sr-only`,children:[(0,Z.jsx)(Nn,{children:`Worktree review`}),(0,Z.jsx)(Fn,{children:`Choose a review surface and open a document.`})]}),t[158]=De):De=t[158],Oe=!g&&_(`sheet`),t[58]=_e,t[59]=he,t[60]=l,t[61]=o,t[62]=g,t[63]=ie,t[64]=d,t[65]=k,t[66]=U,t[67]=m,t[68]=x,t[69]=b,t[70]=s,t[71]=S,t[72]=C,t[73]=w,t[74]=L,t[75]=a,t[76]=oe,t[77]=j,t[78]=f,t[79]=y,t[80]=D,t[81]=i.base,t[82]=p,t[83]=se,t[84]=le,t[85]=G,t[86]=T,t[87]=ve,t[88]=ye,t[89]=be,t[90]=te,t[91]=c,t[92]=u,t[93]=n.available,t[94]=n.path,t[95]=xe,t[96]=Se,t[97]=Ce,t[98]=we,t[99]=Te,t[100]=Ee,t[101]=De,t[102]=Oe,t[103]=ke,t[104]=Ae,t[105]=je,t[106]=Me,t[107]=Ne}else xe=t[95],Se=t[96],Ce=t[97],we=t[98],Te=t[99],Ee=t[100],De=t[101],Oe=t[102],ke=t[103],Ae=t[104],je=t[105],Me=t[106],Ne=t[107];let Pe;t[159]!==xe||t[160]!==Ce||t[161]!==we||t[162]!==Te||t[163]!==Ee||t[164]!==De||t[165]!==Oe?(Pe=(0,Z.jsxs)(xe,{ref:Ce,finalFocus:we,className:Te,showCloseButton:Ee,children:[De,Oe]}),t[159]=xe,t[160]=Ce,t[161]=we,t[162]=Te,t[163]=Ee,t[164]=De,t[165]=Oe,t[166]=Pe):Pe=t[166];let Fe;t[167]!==Se||t[168]!==ke||t[169]!==Ae||t[170]!==je||t[171]!==Pe?(Fe=(0,Z.jsx)(Se,{open:ke,onOpenChange:Ae,onOpenChangeComplete:je,children:Pe}),t[167]=Se,t[168]=ke,t[169]=Ae,t[170]=je,t[171]=Pe,t[172]=Fe):Fe=t[172];let Ie;return t[173]!==Me||t[174]!==Ne||t[175]!==Fe?(Ie=(0,Z.jsxs)(Z.Fragment,{children:[Me,Ne,Fe]}),t[173]=Me,t[174]=Ne,t[175]=Fe,t[176]=Ie):Ie=t[176],Ie}function Gb(e){return!e}function Kb(e){return!e}function qb(e){let t=(0,$.c)(3),n=At(xt(e.overview));if(e.needsDefault&&n&&$t(e.overview))throw Dn(e.overview.cause);if(e.needsDefault&&(n||e.firstDocument.pending)){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(o,{label:`Loading review`}),t[0]=e):e=t[0],e}let r;return t[1]===e?r=t[2]:(r=(0,Z.jsx)(Jb,{...e}),t[1]=e,t[2]=r),r}function Jb(e){let t=(0,$.c)(52),{overview:n,walkthrough:r,changesNavigation:i,walkthroughCode:a,firstDocument:o,layout:s,fileTarget:c,scope:l,context:u,base:d,changes:f,focused:p,onOpen:m,onBrowse:h,navigationTrigger:g,navigatorIsMobile:_,navigatorOpen:v,navigatorOpenMobile:y,tabControls:b}=e,x;t[0]!==p||t[1]!==s.panes?(x=s.panes[p]??{tabs:[],pinned:[],active:null},t[0]=p,t[1]=s.panes,t[2]=x):x=t[2];let S=x,C=s.split||p===0,w;t[3]===C?w=t[4]:(w={ignoreInputs:!0,enabled:C},t[3]=C,t[4]=w);let T=w,E;t[5]!==p||t[6]!==s?(E=()=>s.step(p,1),t[5]=p,t[6]=s,t[7]=E):E=t[7],Co(yo.nextTab,E,T);let D;t[8]!==p||t[9]!==s?(D=()=>s.step(p,-1),t[8]=p,t[9]=s,t[10]=D):D=t[10],Co(yo.previousTab,D,T);let O;t[11]!==p||t[12]!==S.active||t[13]!==s?(O=()=>S.active!==null&&S.active!==void 0&&s.close(p,S.active),t[11]=p,t[12]=S.active,t[13]=s,t[14]=O):O=t[14],Co(yo.closeTab,O,T);let k;t[15]!==p||t[16]!==S.active||t[17]!==s?(k=()=>S.active!==null&&S.active!==void 0&&s.openToSide(p,S.active),t[15]=p,t[16]=S.active,t[17]=s,t[18]=k):k=t[18],Co(yo.openToSide,k,T);let A;t[19]!==d||t[20]!==f||t[21]!==i||t[22]!==u||t[23]!==c||t[24]!==o||t[25]!==p||t[26]!==s||t[27]!==g||t[28]!==_||t[29]!==v||t[30]!==y||t[31]!==h||t[32]!==m||t[33]!==n||t[34]!==l||t[35]!==b||t[36]!==r||t[37]!==a?(A=e=>({walkthrough:r,changesNavigation:i,walkthroughCode:a,firstDocument:o,fileTarget:c,index:e,changeCount:Pt(xt(n))?.changes.length??0,layout:s,split:s.split,focused:p===e,scope:l,context:u,base:d,changes:f,onOpen:m,onBrowse:h,navigationTrigger:g,navigatorIsMobile:_,navigatorOpen:v,navigatorOpenMobile:y,tabControls:b}),t[19]=d,t[20]=f,t[21]=i,t[22]=u,t[23]=c,t[24]=o,t[25]=p,t[26]=s,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=h,t[32]=m,t[33]=n,t[34]=l,t[35]=b,t[36]=r,t[37]=a,t[38]=A):A=t[38];let j=A,M=_?`vertical`:`horizontal`,N=_?200:320,P;t[39]===j?P=t[40]:(P=(0,Z.jsx)(Xb,{...j(0)}),t[39]=j,t[40]=P);let F;t[41]!==N||t[42]!==P?(F=(0,Z.jsx)(ai,{id:`pane-left`,minSize:N,children:P}),t[41]=N,t[42]=P,t[43]=F):F=t[43];let I;t[44]!==s.split||t[45]!==_||t[46]!==j?(I=s.split&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Si,{"aria-label":_?`Top and bottom document panes`:`Left and right document panes`,withHandle:!0}),(0,Z.jsx)(ai,{id:`pane-right`,minSize:_?200:320,children:(0,Z.jsx)(Xb,{...j(1)})})]}),t[44]=s.split,t[45]=_,t[46]=j,t[47]=I):I=t[47];let L;return t[48]!==F||t[49]!==I||t[50]!==M?(L=(0,Z.jsxs)(aa,{orientation:M,className:`min-h-0 flex-1`,children:[F,I]}),t[48]=F,t[49]=I,t[50]=M,t[51]=L):L=t[51],L}function Yb(e,t){return e?t===0?`left`:`right`:null}function Xb(e){let t=(0,$.c)(35),{changeCount:n,walkthrough:r,walkthroughCode:i,firstDocument:a,fileTarget:o,index:s,layout:c,split:l,focused:u,scope:d,context:f,base:p,changes:m,onOpen:h,onBrowse:g,navigationTrigger:_,navigatorIsMobile:v,navigatorOpen:y,navigatorOpenMobile:b,tabControls:x}=e,{element:S,attach:C}=ha(),w=c.panes[s]??{tabs:[],pinned:[],active:null},T=(0,Q.useDeferredValue)(w.active),E=w.active!==`handoff`&&w.tabs.includes(T??``)?T:w.active,D=E!==w.active,O=Wp(E??void 0),k;t[0]!==s||t[1]!==c?(k=e=>{let t=e.target;t instanceof Element&&e.currentTarget.contains(t)&&t.closest(`[data-review-controls]`)===null&&(e.type===`pointerdown`?c.selectPane(s):c.focusPane(s,t))},t[0]=s,t[1]=c,t[2]=k):k=t[2];let A=k,j;t[3]!==s||t[4]!==c?(j=e=>c.bindPane(s,e),t[3]=s,t[4]=c,t[5]=j):j=t[5];let M=l&&s===1&&`border-l`,N=s===1&&`motion-safe:animate-in motion-safe:fade-in-0 duration-150`,P;t[6]!==M||t[7]!==N?(P=q(`@container/pane relative flex h-full min-h-0 min-w-0 flex-col`,M,N),t[6]=M,t[7]=N,t[8]=P):P=t[8];let F;t[9]!==f.connection||t[10]!==d?(F={connection:f.connection,scope:d},t[9]=f.connection,t[10]=d,t[11]=F):F=t[11];let I;t[12]!==s||t[13]!==_||t[14]!==v||t[15]!==y||t[16]!==b?(I=s===0?(0,Z.jsxs)(Tn,{children:[(0,Z.jsx)(rn,{render:(0,Z.jsx)(`span`,{className:`inline-flex`}),children:(0,Z.jsx)(jt,{ref:e=>_.attach(e),"aria-label":`Toggle Sidebar`,"aria-expanded":v?b:y,"aria-keyshortcuts":Lo()===`mac`?`Meta+B`:`Control+B`,onClick:()=>{!v&&y&&requestAnimationFrame(()=>_.element?.focus())}})}),(0,Z.jsxs)(bt,{role:`tooltip`,className:`break-all`,children:[`Toggle Sidebar`,` `,(0,Z.jsx)(Yn,{children:Ao(yo.toggleNavigator)})]})]}):void 0,t[12]=s,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=I):I=t[17];let L=w.tabs,R=w.pinned,z;t[18]!==s||t[19]!==l?(z=Yb(l,s),t[18]=s,t[19]=l,t[20]=z):z=t[20];let B;t[21]!==s||t[22]!==c?(B=R_(c,s),t[21]=s,t[22]=c,t[23]=B):B=t[23];let V=O?.kind===`handoff`&&(0,Z.jsx)(Db,{value:m.scope,onValueChange:m.onScope}),H=(O?.kind===`branch`||O?.kind===`handoff`&&m.scope===`branch`)&&!a.guided&&(0,Z.jsx)(kb,{scope:d,connection:f.connection,base:p,onBase:m.onBase,compact:!0}),U;t[24]!==C||t[25]!==V||t[26]!==H?(U=(0,Z.jsxs)(`div`,{ref:C,"data-pane-controls":``,role:`toolbar`,"aria-label":`Document controls`,className:`flex items-center gap-1`,children:[V,H]}),t[24]=C,t[25]=V,t[26]=H,t[27]=U):U=t[27];let W;t[28]!==s||t[29]!==l||t[30]!==x?(W=(!l||s===1)&&x(s),t[28]=s,t[29]=l,t[30]=x,t[31]=W):W=t[31];let G;return t[32]!==U||t[33]!==W?(G=(0,Z.jsxs)(Z.Fragment,{children:[U,W]}),t[32]=U,t[33]=W,t[34]=G):G=t[34],(0,Z.jsxs)(`section`,{ref:j,"aria-label":l?`${s===0?`Left`:`Right`} pane`:void 0,"data-focused":u,"aria-busy":D,onPointerDownCapture:A,onFocusCapture:A,className:P,children:[(0,Z.jsx)(V_,{changeCount:n,commitContext:F,leading:I,tabs:L,pinned:R,active:E,side:z,...B,trailing:G}),O?.kind===`branch-file`&&!a.guided&&(0,Z.jsxs)(`div`,{role:`group`,"aria-label":`Branch comparison`,className:`flex items-center gap-2 border-b px-3.5 py-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:`Branch comparison`}),(0,Z.jsx)(kb,{scope:d,connection:f.connection,base:p,onBase:m.onBase,compact:!0})]}),w.tabs.filter(e=>e===E||e===`walkthrough`).map(e=>{let t=Wp(e);if(!t)return null;let n=e===E,c=t;return t.kind===`handoff`&&(c={kind:m.scope===`branch`?`branch`:`all-changes`}),(0,Z.jsx)(`div`,{"aria-hidden":!n,inert:!n||D,className:q(`flex min-h-0 flex-1 flex-col overflow-hidden`,!n&&`pointer-events-none invisible absolute opacity-0 inset-x-0 top-12 bottom-0`),children:(0,Z.jsx)(Fb,{documentKey:e,connection:f.connection,scope:d,children:(0,Z.jsx)(gb,{walkthrough:r,walkthroughCode:i,singleHeader:a.guided,scope:d,context:f,document:c,sideLabel:o_(Yb(l,s)),base:p,onOpen:h,onBrowse:g,active:n&&u&&!D,toolbarTarget:n&&!D?S:null,fileTarget:n&&o?.pane===s&&o.key===E?o:void 0})})},t.kind===`walkthrough`?`walkthrough`:`document`)})]})}var Zb={open:xr,review:g,"open-to-side":Yr,"open-file":sc,timeline:ji,"copy-relative":De,discard:zc,"expand-all":$s,"collapse-all":Zs};function Qb(e){let t=(0,$.c)(2),{action:n}=e,r=Zb[n.id],i;return t[0]===r?i=t[1]:(i=(0,Z.jsx)(r,{}),t[0]=r,t[1]=i),i}function $b(e){let t=(0,$.c)(46),{actions:n,label:r,description:i,onAction:a,children:o}=e,s=(0,Q.useId)(),[c,l]=(0,Q.useState)(!1),u;t[0]===a?u=t[1]:(u=e=>{e===`open-to-side`&&(0,iu.flushSync)(()=>l(!0)),a(e)},t[0]=a,t[1]=u);let d=u,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>{e&&l(!1)},t[2]=f):f=t[2];let p=f,m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(`div`,{className:`min-w-0`}),t[3]=m):m=t[3];let h;t[4]!==i||t[5]!==s?(h=i&&(0,Z.jsx)(`span`,{id:s,className:`sr-only`,children:i}),t[4]=i,t[5]=s,t[6]=h):h=t[6];let g=i?s:void 0,_;t[7]!==r||t[8]!==g?(_=(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,className:`shrink-0`,"aria-label":r,"aria-describedby":g}),t[7]=r,t[8]=g,t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Xn,{}),t[10]=v):v=t[10];let y;t[11]===_?y=t[12]:(y=(0,Z.jsx)(rn,{render:(0,Z.jsx)(sn,{render:_,children:v})}),t[11]=_,t[12]=y);let b;t[13]===r?b=t[14]:(b=(0,Z.jsx)(bt,{role:`tooltip`,className:`break-all`,children:r}),t[13]=r,t[14]=b);let x;t[15]!==y||t[16]!==b?(x=(0,Z.jsxs)(Tn,{children:[y,b]}),t[15]=y,t[16]=b,t[17]=x):x=t[17];let S=!c,C;if(t[18]!==d||t[19]!==n){let e;t[21]===d?e=t[22]:(e=e=>(0,Z.jsxs)(On,{disabled:e.disabled,variant:e.destructive?`destructive`:`default`,onClick:()=>d(e.id),children:[(0,Z.jsx)(Qb,{action:e}),e.label]},e.id),t[21]=d,t[22]=e),C=n.map(e),t[18]=d,t[19]=n,t[20]=C}else C=t[20];let w;t[23]!==S||t[24]!==C?(w=(0,Z.jsx)(yt,{align:`end`,finalFocus:S,children:C}),t[23]=S,t[24]=C,t[25]=w):w=t[25];let T;t[26]!==x||t[27]!==w||t[28]!==h?(T=(0,Z.jsxs)(nn,{onOpenChange:p,children:[h,x,w]}),t[26]=x,t[27]=w,t[28]=h,t[29]=T):T=t[29];let E;t[30]!==o||t[31]!==T?(E=o(T),t[30]=o,t[31]=T,t[32]=E):E=t[32];let D;t[33]===E?D=t[34]:(D=(0,Z.jsx)(Ji,{render:m,children:E}),t[33]=E,t[34]=D);let O=!c,k;if(t[35]!==d||t[36]!==n){let e;t[38]===d?e=t[39]:(e=e=>(0,Z.jsxs)(Zr,{disabled:e.disabled,variant:e.destructive?`destructive`:`default`,onClick:()=>d(e.id),children:[(0,Z.jsx)(Qb,{action:e}),e.label]},e.id),t[38]=d,t[39]=e),k=n.map(e),t[35]=d,t[36]=n,t[37]=k}else k=t[37];let A;t[40]!==O||t[41]!==k?(A=(0,Z.jsx)(Kr,{finalFocus:O,children:k}),t[40]=O,t[41]=k,t[42]=A):A=t[42];let j;return t[43]!==D||t[44]!==A?(j=(0,Z.jsxs)(dr,{onOpenChange:p,children:[D,A]}),t[43]=D,t[44]=A,t[45]=j):j=t[45],j}var ex=`flex w-full min-w-0 items-center gap-1.5 rounded-lg px-2 py-1 text-left text-caption transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:font-medium`;function tx(e){let t=(0,$.c)(30),{path:n,document:r,note:i,scopes:a,changeStatus:o,reviewStatus:s,active:c,onOpen:l,sideLabel:u,onReview:d,canReview:f,onDiscard:p,indented:m}=e,h=m!==void 0&&m,g;t[0]===n?g=t[1]:(g=di(n),t[0]=n,t[1]=g);let _;t[2]===a?_=t[3]:(_=a.length>0?` · ${a.join(` + `)}`:``,t[2]=a,t[3]=_);let v=`${g}${_}`,y;t[4]!==r||t[5]!==p||t[6]!==l||t[7]!==d||t[8]!==n?(y=e=>{bb10:switch(e){case`review`:d();break bb10;case`open`:l(r);break bb10;case`open-to-side`:l(r,{toSide:!0});break bb10;case`open-file`:l({kind:`file`,path:n});break bb10;case`timeline`:l({kind:`timeline`,path:n});break bb10;case`copy-relative`:ht(n,`relative path`);break bb10;case`discard`:p?.()}},t[4]=r,t[5]=p,t[6]=l,t[7]=d,t[8]=n,t[9]=y):y=t[9];let b=y,x=`Actions for ${n}`,S=p!==void 0,C;t[10]!==f||t[11]!==s||t[12]!==u||t[13]!==S?(C=ru({kind:`file`,status:s,canReview:f,sideLabel:u,canDiscard:S}),t[10]=f,t[11]=s,t[12]=u,t[13]=S,t[14]=C):C=t[14];let w;t[15]!==c||t[16]!==o||t[17]!==r||t[18]!==h||t[19]!==v||t[20]!==i||t[21]!==l||t[22]!==n||t[23]!==s?(w=e=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":c,"aria-label":v,"aria-description":rx(o,s),title:i==null?n:`${n}\n${i}`,className:q(ex,`flex-1 text-muted-foreground`,h&&`pl-7`,c&&`bg-accent font-medium text-foreground`),onClick:e=>l(r,{toSide:e.altKey}),children:[(0,Z.jsx)(nx,{status:o,reviewStatus:s}),(0,Z.jsx)(gi,{path:n,className:`size-3.5 shrink-0`}),(0,Z.jsx)(X,{className:q(`min-w-0 flex-1 `,s===`reviewed`&&`line-through decoration-muted-foreground/40`),text:di(n)})]}),e]}),t[15]=c,t[16]=o,t[17]=r,t[18]=h,t[19]=v,t[20]=i,t[21]=l,t[22]=n,t[23]=s,t[24]=w):w=t[24];let T;return t[25]!==b||t[26]!==x||t[27]!==C||t[28]!==w?(T=(0,Z.jsx)($b,{label:x,actions:C,onAction:b,children:w}),t[25]=b,t[26]=x,t[27]=C,t[28]=w,t[29]=T):T=t[29],T}function nx(e){let t=(0,$.c)(16),{status:n,reviewStatus:r}=e,i=r??`unreviewed`,a;t[0]!==r||t[1]!==n?(a=rx(n,r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s=n===void 0&&`bg-muted-foreground/60`,c=(n===`added`||n===`untracked`)&&`bg-graph-2`,l=n===`modified`&&`bg-graph-4`,u=n===`deleted`&&`bg-destructive`,d=n===`renamed`&&`bg-graph-1`,f;t[3]!==s||t[4]!==c||t[5]!==l||t[6]!==u||t[7]!==d?(f=q(`size-1.5 rounded-full`,s,c,l,u,d),t[3]=s,t[4]=c,t[5]=l,t[6]=u,t[7]=d,t[8]=f):f=t[8];let p;t[9]===f?p=t[10]:(p=(0,Z.jsx)(`span`,{className:f}),t[9]=f,t[10]=p);let m;return t[11]!==o||t[12]!==i||t[13]!==n||t[14]!==p?(m=(0,Z.jsx)(`span`,{role:`img`,"aria-label":o,className:`grid w-3.5 shrink-0 place-items-center`,"data-review-state":i,"data-change-status":n,title:o,children:p}),t[11]=o,t[12]=i,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function rx(e,t){return`${e===void 0?`Change type unavailable`:Da[e].label} · ${ix(t)}`}function ix(e){return e===`reviewed`?`Reviewed`:e===`stale`?`Changed since review`:`Not reviewed`}function ax(e){let t=(0,$.c)(17),{label:n,active:r,onOpen:i,className:a,plain:o,children:s}=e,c=a===void 0?ex:a;if(o!==void 0&&o){let e;return t[0]!==r||t[1]!==s||t[2]!==c||t[3]!==n||t[4]!==i?(e=(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center`,children:(0,Z.jsx)(`button`,{type:`button`,className:c,"aria-pressed":r,"aria-label":n,onClick:i,children:s})}),t[0]=r,t[1]=s,t[2]=c,t[3]=n,t[4]=i,t[5]=e):e=t[5],e}let l=`Actions for ${n}`,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=ru({kind:`section`}),t[6]=u):u=t[6];let d;t[7]!==r||t[8]!==s||t[9]!==c||t[10]!==i?(d=e=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,Z.jsx)(`button`,{type:`button`,className:c,"aria-pressed":r,onClick:i,children:s}),e]}),t[7]=r,t[8]=s,t[9]=c,t[10]=i,t[11]=d):d=t[11];let f;return t[12]!==i||t[13]!==l||t[14]!==u||t[15]!==d?(f=(0,Z.jsx)($b,{label:l,actions:u,onAction:i,children:d}),t[12]=i,t[13]=l,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function ox(e){let t=(0,$.c)(15),{name:n,count:r,expanded:i,onExpanded:a,onAll:o,action:s,children:c}=e,l=i?Ae:f,u;t[0]!==l||t[1]!==r||t[2]!==i||t[3]!==n||t[4]!==a?(u=e=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:ex,"aria-label":n,"aria-expanded":i,onClick:()=>a(!i),children:[(0,Z.jsx)(X,{className:`min-w-0 flex-1`,text:`${n} · ${R(r,`file`)}`}),(0,Z.jsx)(l,{className:`size-3.5 shrink-0`})]}),e]}),t[0]=l,t[1]=r,t[2]=i,t[3]=n,t[4]=a,t[5]=u):u=t[5];let d=u,p;t[6]!==s||t[7]!==n||t[8]!==o||t[9]!==d?(p=s?d(s):(0,Z.jsx)($b,{label:`Actions for ${n}`,actions:ru({kind:`group`}),onAction:e=>o(e===`expand-all`),children:d}),t[6]=s,t[7]=n,t[8]=o,t[9]=d,t[10]=p):p=t[10];let m=i&&c,h;return t[11]!==n||t[12]!==p||t[13]!==m?(h=(0,Z.jsxs)(`section`,{"aria-label":n,className:`mt-3 border-t pt-2`,children:[p,m]}),t[11]=n,t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function sx(e){let t=(0,$.c)(17),{label:n,value:r,options:i,onValue:a,className:o}=e,s;t[0]===o?s=t[1]:(s=q(`shrink-0`,o),t[0]=o,t[1]=s);let c;t[2]!==a||t[3]!==i?(c=e=>{let t=i.find(t=>t.value===e);t&&a(t.value)},t[2]=a,t[3]=i,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=i.map(cx),t[5]=i,t[6]=l);let u;t[7]!==n||t[8]!==l?(u=(0,Z.jsx)(Ts,{"aria-label":n,className:`w-full`,children:l}),t[7]=n,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==c||t[11]!==u||t[12]!==r?(d=(0,Z.jsx)(Ds,{value:r,onValueChange:c,children:u}),t[10]=c,t[11]=u,t[12]=r,t[13]=d):d=t[13];let f;return t[14]!==s||t[15]!==d?(f=(0,Z.jsx)(`div`,{className:s,children:d}),t[14]=s,t[15]=d,t[16]=f):f=t[16],f}function cx(e){return(0,Z.jsx)(fo,{value:e.value,className:`min-w-0`,children:e.label},e.value)}function lx(e){let t=(0,$.c)(16),{scope:n,context:r,base:i,activeEntry:a,onOpen:o,sideLabel:s,onBase:c,grouping:l}=e,u;t[0]!==i||t[1]!==r.connection||t[2]!==c||t[3]!==n?(u=(0,Z.jsx)(`div`,{className:`shrink-0 px-2 pt-2`,children:(0,Z.jsx)(kb,{scope:n,connection:r.connection,base:i,onBase:c})}),t[0]=i,t[1]=r.connection,t[2]=c,t[3]=n,t[4]=u):u=t[4];let d;t[5]!==a||t[6]!==i||t[7]!==r||t[8]!==l||t[9]!==o||t[10]!==n||t[11]!==s?(d=(0,Z.jsx)(ux,{scope:n,context:r,base:i,activeEntry:a,onOpen:o,sideLabel:s,grouping:l}),t[5]=a,t[6]=i,t[7]=r,t[8]=l,t[9]=o,t[10]=n,t[11]=s,t[12]=d):d=t[12];let f;return t[13]!==u||t[14]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[u,d]}),t[13]=u,t[14]=d,t[15]=f):f=t[15],f}function ux(e){let t=(0,$.c)(12),{scope:n,context:r,base:i,activeEntry:a,onOpen:o,sideLabel:s,grouping:c}=e,l;t[0]!==a||t[1]!==r||t[2]!==c||t[3]!==o||t[4]!==n||t[5]!==s?(l=e=>(0,Z.jsx)(dx,{scope:n,context:r,branch:e,activeEntry:a,onOpen:o,sideLabel:s,grouping:c}),t[0]=a,t[1]=r,t[2]=c,t[3]=o,t[4]=n,t[5]=s,t[6]=l):l=t[6];let u;return t[7]!==i||t[8]!==r||t[9]!==n||t[10]!==l?(u=(0,Z.jsx)(Z_,{scope:n,context:r,base:i,children:l}),t[7]=i,t[8]=r,t[9]=n,t[10]=l,t[11]=u):u=t[11],u}function dx(e){let t=(0,$.c)(53),{scope:n,context:r,branch:i,activeEntry:a,onOpen:o,sideLabel:s,grouping:c}=e,l=Ss(r.connection),u;t[0]===i?u=t[1]:(u=zi(i),t[0]=i,t[1]=u);let d=u,f=J_(n,r,d),p=cv(n,r,fx,d);if(i.base===null||i.base===void 0)return null;let m,h,g,_,v,y,b;if(t[2]!==c||t[3]!==a||t[4]!==i.base.ref||t[5]!==i.commits||t[6]!==i.files||t[7]!==i.head.branch||t[8]!==r||t[9]!==f||t[10]!==o||t[11]!==p||t[12]!==n||t[13]!==s||t[14]!==l){let e=da(i.files,f),u;t[22]===i.head.branch?u=t[23]:(u=i.head.branch===null||i.head.branch===void 0?`this commit`:Mp(i.head.branch),t[22]=i.head.branch,t[23]=u);let d=u,x;t[24]===i.commits?x=t[25]:(x=R(i.commits,`commit`),t[24]=i.commits,t[25]=x);let S=x,C=c?`All changes`:`All branch changes`,w;t[26]!==a||t[27]!==o||t[28]!==p||t[29]!==s?(w=e=>(0,Z.jsx)(tx,{path:e.path,document:{kind:`branch-file`,path:e.path},note:e.status,changeStatus:Es(e),scopes:[e.status],reviewStatus:e.reviewStatus,active:a===Up({kind:`branch-file`,path:e.path}),onOpen:o,sideLabel:s,canReview:e.fingerprint!==null&&e.fingerprint!==void 0,onReview:()=>p.toggle({path:e.path,reviewed:e.reviewStatus===`reviewed`,fingerprint:e.fingerprint})},e.path),t[26]=a,t[27]=o,t[28]=p,t[29]=s,t[30]=w):w=t[30];let T=w;m=ti,b=`h-0 min-h-0 flex-1`,h=`p-2 pr-3`;let E;t[31]===i.base.ref?E=t[32]:(E=Mp(i.base.ref),t[31]=i.base.ref,t[32]=E),t[33]!==S||t[34]!==d||t[35]!==E?(g=(0,Z.jsxs)(`p`,{className:`px-2 pb-1.5 text-2xs text-muted-foreground`,children:[S,` on `,d,` since `,E]}),t[33]=S,t[34]=d,t[35]=E,t[36]=g):g=t[36];let D;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=Up(Vp),t[37]=D):D=t[37];let O;t[38]===o?O=t[39]:(O=()=>o(Vp),t[38]=o,t[39]=O);let k;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(hr,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[40]=k):k=t[40];let A;t[41]===C?A=t[42]:(A=(0,Z.jsx)(X,{className:`min-w-0 flex-1`,text:C}),t[41]=C,t[42]=A),_=(0,Z.jsxs)(ax,{label:C,active:a===D,onOpen:O,plain:c!==void 0,children:[k,A,(0,Z.jsx)(`span`,{className:`ml-auto text-2xs text-muted-foreground tabular-nums`,children:e.length})]}),v=e.length===0&&(0,Z.jsxs)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:[`No changes since `,Mp(i.base.ref)]}),y=c?(0,Z.jsx)(c,{scope:n,context:r,items:e,row:T,activeEntry:a,onOpen:o}):tu(e,l).map(T),t[2]=c,t[3]=a,t[4]=i.base.ref,t[5]=i.commits,t[6]=i.files,t[7]=i.head.branch,t[8]=r,t[9]=f,t[10]=o,t[11]=p,t[12]=n,t[13]=s,t[14]=l,t[15]=m,t[16]=h,t[17]=g,t[18]=_,t[19]=v,t[20]=y,t[21]=b}else m=t[15],h=t[16],g=t[17],_=t[18],v=t[19],y=t[20],b=t[21];let x;t[43]!==h||t[44]!==g||t[45]!==_||t[46]!==v||t[47]!==y?(x=(0,Z.jsxs)(`div`,{className:h,children:[g,_,v,y]}),t[43]=h,t[44]=g,t[45]=_,t[46]=v,t[47]=y,t[48]=x):x=t[48];let S;return t[49]!==m||t[50]!==b||t[51]!==x?(S=(0,Z.jsx)(m,{className:b,children:x}),t[49]=m,t[50]=b,t[51]=x,t[52]=S):S=t[52],S}function fx(e){return xo.add(e)}var px=[{value:`uncommitted`,label:`Uncommitted`},{value:`branch`,label:`Branch`}];function mx(e){let t=(0,$.c)(29),{grouping:n,scope:r,context:i,activeEntry:a,onOpen:o,sideLabel:s,changeScope:c,base:l,onChangeScope:u,onBase:d,allChanges:f}=e,{connection:p}=i;Y_(r,i);let m=si(r,p),h=X_(r,i,m),g=c===`branch`,_;t[0]!==c||t[1]!==u?(_=(0,Z.jsx)(sx,{label:`Changes to review`,className:`px-2.5 pt-3`,value:c,onValue:u,options:px}),t[0]=c,t[1]=u,t[2]=_):_=t[2];let v;t[3]!==a||t[4]!==l||t[5]!==g||t[6]!==i||t[7]!==n?.branch||t[8]!==d||t[9]!==o||t[10]!==r||t[11]!==s?(v=g&&(0,Z.jsx)(lx,{scope:r,context:i,base:l,activeEntry:a,onOpen:o,sideLabel:s,onBase:d,grouping:n?.branch}),t[3]=a,t[4]=l,t[5]=g,t[6]=i,t[7]=n?.branch,t[8]=d,t[9]=o,t[10]=r,t[11]=s,t[12]=v):v=t[12];let y;t[13]!==a||t[14]!==f||t[15]!==l||t[16]!==g||t[17]!==h||t[18]!==i||t[19]!==n?.uncommitted||t[20]!==m||t[21]!==o||t[22]!==r||t[23]!==s?(y=!g&&(0,Z.jsx)(hx,{scope:r,context:i,activeEntry:a,onOpen:o,sideLabel:s,list:m,changes:h,grouping:n?.uncommitted,allChanges:f,base:l}),t[13]=a,t[14]=f,t[15]=l,t[16]=g,t[17]=h,t[18]=i,t[19]=n?.uncommitted,t[20]=m,t[21]=o,t[22]=r,t[23]=s,t[24]=y):y=t[24];let b;return t[25]!==_||t[26]!==v||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[_,v,y]}),t[25]=_,t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function hx(e){let t=(0,$.c)(16),{scope:n,context:r,activeEntry:i,onOpen:a,sideLabel:o,list:s,changes:c,grouping:l,allChanges:u,base:d}=e,f=Ss(r.connection),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p={changes:!0,specs:!1},t[0]=p):p=t[0];let[m,h]=(0,Q.useState)(p),g=s.changes.map(bx),_=f?g.filter(yx):g,v=f?g.filter(eu):[],y=new Map(c.map(vx)),b=Cs(s.changes),x=cv(n,r,_x),[S,C]=(0,Q.useState)(null),w=()=>l?(0,Z.jsx)(l,{base:d,scope:n,context:r,paths:g,row:T,activeEntry:i,onOpen:a}):(0,Z.jsx)(ax,{label:`All changes`,active:i===Up(u),onOpen:()=>a(u),children:`All changes`}),T=e=>(0,Z.jsx)(tx,{path:e,document:{kind:`change`,path:e},note:void 0,changeStatus:b.files.get(e),scopes:[...new Set(s.changes.find(t=>t.path===e)?.comparisons.map(gx))],reviewStatus:y.get(e)?.reviewStatus,active:i===Up({kind:`change`,path:e}),onOpen:a,sideLabel:o,canReview:y.get(e)?.fingerprint!==null&&y.get(e)?.fingerprint!==void 0,onReview:()=>x.toggle({path:e,reviewed:y.get(e)?.reviewStatus===`reviewed`,fingerprint:y.get(e)?.fingerprint}),onDiscard:()=>C(t=>({path:e,nonce:(t?.nonce??0)+1}))},e),E=ti,D;t[1]===w?D=t[2]:(D=w(),t[1]=w,t[2]=D);let O=!l&&g.length===0&&(0,Z.jsx)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:`No changes`}),k=!l&&_.length>0&&(0,Z.jsx)(ox,{name:`Changed files`,count:_.length,expanded:m.changes,onExpanded:e=>h(t=>({...t,changes:e})),onAll:e=>h({changes:e,specs:e}),children:_.map(T)}),A=!l&&v.length>0&&(0,Z.jsxs)(ox,{name:`Specs`,count:v.length,expanded:m.specs,onExpanded:e=>h(t=>({...t,specs:e})),onAll:e=>h({changes:e,specs:e}),children:[(0,Z.jsx)(ax,{label:`Open all specs`,active:i===`specs`,onOpen:()=>a(Bp),children:`Open all specs`}),v.map(T)]}),j;t[3]!==r||t[4]!==S||t[5]!==n?(j=S&&(0,Z.jsx)(Tm,{scope:n,context:r,path:S.path,signal:S.nonce,hiddenTrigger:!0}),t[3]=r,t[4]=S,t[5]=n,t[6]=j):j=t[6];let M;t[7]!==D||t[8]!==O||t[9]!==k||t[10]!==A||t[11]!==j?(M=(0,Z.jsxs)(`div`,{className:`px-2.5 pt-2 pb-3`,children:[D,O,k,A,j]}),t[7]=D,t[8]=O,t[9]=k,t[10]=A,t[11]=j,t[12]=M):M=t[12];let N;return t[13]!==E||t[14]!==M?(N=(0,Z.jsx)(E,{className:`h-0 min-h-0 flex-1`,children:M}),t[13]=E,t[14]=M,t[15]=N):N=t[15],N}function gx(e){return e.scope}function _x(e){return xo.add(e)}function vx(e){return[e.path,e]}function yx(e){return!eu(e)}function bx(e){return e.path}function xx(e){let t={projectId:e.projectId,worktreeId:e.worktreeId};return e.remote===null?fn({to:`/$projectId/$worktreeId`,params:t}):fn({to:`/remotes/$environmentId/$projectId/$worktreeId`,params:{environmentId:e.remote,...t}})}function Sx(e,t){let n=(0,$.c)(2),r=Gi(e,t,Cx),i;return n[0]===r?i=n[1]:(i=()=>r?r():ui.openWithPayload({remote:null}),n[0]=r,n[1]=i),i}function Cx(e){return xo.add({title:`Could not open the project`,description:Pe(e),type:`error`})}function wx(e){let t=(0,$.c)(10),{connection:n,empty:r}=e,i=Xe(),a=Vt(),o;t[0]!==r||t[1]!==i?(o=e=>i({...xx(e),replace:r}),t[0]=r,t[1]=i,t[2]=o):o=t[2];let s=o,c=Sx(n,s),l;t[3]!==i||t[4]!==c?(l=ue(e=>{typeof e!=`object`&&(e===`open-settings`?i({to:`/settings/$section`,params:{section:Vi}}):c())}),t[3]=i,t[4]=c,t[5]=l):l=t[5],ie(l);let u;return t[6]!==n||t[7]!==s||t[8]!==a?(u=(0,Z.jsx)(_r,{connection:n,remotes:a,onOpened:s}),t[6]=n,t[7]=s,t[8]=a,t[9]=u):u=t[9],u}export{Up as _,ax as a,jc as b,Cb as c,Z_ as d,k_ as f,zp as g,Nm as h,mx as i,Nv as l,Mm as m,Sx as n,Wb as o,j_ as p,xx as r,Fb as s,wx as t,Sv as u,Jp as v,Cp as y};
|