@eliya-oss/agent-diff 0.1.0-alpha.213 → 0.1.0-alpha.214
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/CHANGELOG.md +15 -0
- package/dist/main.js +1 -1
- package/dist/web/nitro.json +1 -1
- package/dist/web/public/assets/{_deck-BDC_r92m.js → _deck-DLPaCZHB.js} +1 -1
- package/dist/web/public/assets/{_point-I_vt1otH.js → _point-DGgnI5q4.js} +1 -1
- package/dist/web/public/assets/{index-X7OFY5bM.js → index-oNjROFCr.js} +2 -2
- package/dist/web/public/assets/{review-DE0jDEPH.js → review-CGsPT_rg.js} +1 -1
- package/dist/web/public/assets/{review-block-CbmQ0t4L.js → review-block-CI0NAJOA.js} +5 -5
- package/dist/web/public/assets/{routes-CYn3-ePX.js → routes-Di06fdPG.js} +1 -1
- package/dist/web/public/assets/{viewed-store-CuareBUI.js → viewed-store-BLrOojG-.js} +1 -1
- package/dist/web/server/{_deck-x23t7F7l.mjs → _deck-DmLMT9SU.mjs} +3 -3
- package/dist/web/server/{_point-CaM245BE.mjs → _point-D43Au7kX.mjs} +4 -4
- package/dist/web/server/_ssr/{review-e0zRsKyC.mjs → review-BBTKlgae.mjs} +3 -3
- package/dist/web/server/_ssr/{review-block-C-oUK43P.mjs → review-block-CcuLs3GF.mjs} +70 -25
- package/dist/web/server/_ssr/{router-DH6_gEUb.mjs → router-C7mfWdAY.mjs} +7 -7
- package/dist/web/server/_ssr/{routes-BP_s9iFs.mjs → routes-CjMG5VFL.mjs} +2 -2
- package/dist/web/server/_ssr/shortcuts-B7llaLLc.mjs +1 -1
- package/dist/web/server/_ssr/ssr.mjs +2 -2
- package/dist/web/server/_ssr/{viewed-store-RX0hDmiV.mjs → viewed-store-Bjoo5Exy.mjs} +2 -2
- package/dist/web/server/{_tanstack-start-manifest_v-D8_4kgre.mjs → _tanstack-start-manifest_v-X_vXTCyT.mjs} +8 -8
- package/dist/web/server/index.mjs +49 -49
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./rolldown-runtime-XKyaHtl9.js";import{A as r,C as i,D as a,E as o,M as s,N as c,O as l,P as u,S as d,T as f,X as p,Y as m,_ as h,b as g,c as _,g as v,h as y,j as b,k as x,kt as S,l as C,m as w,o as T,p as E,s as D,v as O,w as k,x as A,y as ee}from"./decks.functions-tXNTG2sC.js";import{$ as j,$t as M,A as N,An as P,B as te,Bn as F,C as I,Cn as L,Ct as ne,D as re,Dn as ie,Dt as ae,E as oe,En as se,Et as ce,F as le,Fn as R,Ft as ue,Gn as de,H as fe,Hn as pe,Ht as me,I as he,In as ge,J as _e,Jn as z,K as ve,Kn as ye,L as be,Ln as B,Lt as xe,M as Se,Mn as V,Mt as Ce,N as we,O as Te,Ot as Ee,P as De,Pn as Oe,Pt as ke,Q as Ae,R as je,Rn as H,Rt as Me,S as Ne,St as Pe,T as Fe,Tn as Ie,U as Le,Ut as Re,V as ze,Vn as Be,Wn as Ve,Wt as He,X as Ue,Xt as We,Y as Ge,Yn as Ke,Z as qe,_ as Je,_n as Ye,_t as Xe,a as Ze,an as Qe,at as $e,b as et,bn as tt,bt as nt,c as rt,cn as it,ct as at,dn as ot,dt as st,en as ct,et as lt,f as ut,fn as dt,ft,g as pt,gt as mt,h as ht,hn as gt,i as _t,in as U,it as vt,jn as yt,k as bt,kn as xt,kt as St,l as Ct,ln as wt,lt as Tt,m as Et,mn as Dt,n as Ot,nn as kt,nt as At,on as jt,ot as Mt,p as Nt,pn as Pt,pt as Ft,qn as It,r as Lt,rn as Rt,rt as zt,s as Bt,sn as Vt,st as Ht,t as Ut,tn as Wt,tt as Gt,u as Kt,un as qt,ut as Jt,v as Yt,vn as Xt,vt as Zt,w as Qt,x as $t,xn as W,xt as en,yn as tn,yt as nn,z as rn,zn as an,zt as on}from"./use-window-event-BDUVK1pJ.js";import{C as sn,E as cn,S as ln,T as un,a as dn,b as fn,c as pn,h as mn,l as hn,m as gn,n as _n,o as vn,p as yn,r as bn,t as xn,u as Sn,w as Cn}from"./shortcuts-BsNWbUaT.js";import{C as wn,D as Tn,E as En,O as Dn,S as On,T as kn,_ as An,a as jn,c as Mn,d as Nn,f as Pn,g as Fn,h as In,i as Ln,l as Rn,m as zn,o as Bn,p as Vn,s as Hn,u as Un,v as Wn,w as Gn,x as Kn,y as qn}from"./index-X7OFY5bM.js";var Jn={name:`arrow-down-to-line`,size:24,node:[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]};Jn.node;var Yn=z(Jn),Xn={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Xn.node;var Zn=z(Xn),Qn={name:`arrow-up-to-line`,size:24,node:[[`path`,{d:`M5 3h14`,key:`7usisc`}],[`path`,{d:`m18 13-6-6-6 6`,key:`1kf1n9`}],[`path`,{d:`M12 7v14`,key:`1akyts`}]]};Qn.node;var $n=z(Qn),er={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};er.node;var tr=z(er),nr={name:`check-check`,size:24,node:[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]};nr.node;var rr=z(nr),ir={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};ir.node;var ar=z(ir),or={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};or.node;var sr=z(or),cr={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};cr.node;var lr=z(cr),ur={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};ur.node;var dr=z(ur),fr={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`}]]};fr.node;var pr=z(fr),mr={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`}]]};mr.node;var hr=z(mr),gr={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};gr.node;var _r=z(gr),vr={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};vr.node;var yr=z(vr),br={name:`clipboard-copy`,size:24,node:[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2`,key:`4jdomd`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v4`,key:`3hqy98`}],[`path`,{d:`M21 14H11`,key:`1bme5i`}],[`path`,{d:`m15 10-4 4 4 4`,key:`5dvupr`}]]};br.node;var xr=z(br),Sr={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};Sr.node;var Cr=z(Sr),wr={name:`corner-down-left`,size:24,node:[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]};wr.node;var Tr=z(wr),Er={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Er.node;var Dr=z(Er),Or={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Or.node;var kr=z(Or),Ar={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`}]]};Ar.node;var jr=z(Ar),Mr={name:`folder-open`,size:24,node:[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]};Mr.node;var Nr=z(Mr),Pr={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};Pr.node;var Fr=z(Pr),Ir={name:`git-compare`,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`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]};Ir.node;var Lr=z(Ir),Rr={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`}]]};Rr.node;var zr=z(Rr),Br={name:`keyboard`,size:24,node:[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]};Br.node;var Vr=z(Br),Hr={name:`layers-2`,size:24,node:[[`path`,{d:`M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74z`,key:`15q6uc`}],[`path`,{d:`m20 14.285 1.5.845a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74l1.5-.845`,key:`byia6g`}]]};Hr.node;var Ur=z(Hr),Wr={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Wr.node;var Gr=z(Wr),Kr={name:`list-filter`,size:24,node:[[`path`,{d:`M2 5h20`,key:`1fs1ex`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M9 19h6`,key:`456am0`}]]};Kr.node;var qr=z(Kr),Jr={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};Jr.node;var Yr=z(Jr),Xr={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};Xr.node;var Zr=z(Xr),Qr={name:`locate-fixed`,size:24,node:[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};Qr.node;var $r=z(Qr),ei={name:`maximize-2`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]};ei.node;var ti=z(ei),ni={name:`message-square-plus`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]};ni.node;var ri=z(ni),ii={name:`messages-square`,size:24,node:[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]};ii.node;var ai=z(ii),oi={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};oi.node;var si=z(oi),ci={name:`pin`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]};ci.node;var li=z(ci),ui={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};ui.node;var di=z(ui),fi={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};fi.node;var pi=z(fi),mi={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};mi.node;var hi=z(mi),gi={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};gi.node;var _i=z(gi),vi={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};vi.node;var yi=z(vi),bi={name:`sparkle`,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`}]]};bi.node;var xi=z(bi),Si={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`]};Si.node;var Ci=z(Si),wi={name:`square-arrow-out-up-right`,size:24,node:[[`path`,{d:`M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6`,key:`y09zxi`}],[`path`,{d:`m21 3-9 9`,key:`mpx6sq`}],[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}]],aliases:[`arrow-up-right-from-square`]};wi.node;var Ti=z(wi),Ei={name:`square-dashed-text`,size:24,node:[[`path`,{d:`M14 21h1`,key:`v9vybs`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M21 14v1`,key:`169vum`}],[`path`,{d:`M21 19a2 2 0 0 1-2 2`,key:`1j7049`}],[`path`,{d:`M21 9v1`,key:`mxsmne`}],[`path`,{d:`M3 14v1`,key:`vnatye`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M7 16h6`,key:`1vyc9m`}],[`path`,{d:`M7 8h8`,key:`1jbsf9`}],[`path`,{d:`M9 21h1`,key:`15o7lz`}],[`path`,{d:`M9 3h1`,key:`1yesri`}]],aliases:[`text-selection`,`text-select`]};Ei.node;var Di=z(Ei),Oi={name:`square-terminal`,size:24,node:[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]],aliases:[`terminal-square`]};Oi.node;var ki=z(Oi),Ai={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Ai.node;var ji=z(Ai),Mi={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};Mi.node;var Ni=z(Mi),Pi={name:`text-wrap`,size:24,node:[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]],aliases:[`wrap-text`]};Pi.node;var Fi=z(Pi),Ii={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Ii.node;var Li=z(Ii),Ri={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`]};Ri.node;var zi=z(Ri),Bi={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};Bi.node;var Vi=z(Bi),G=t(S(),1),Hi=0;function Ui(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(Hi);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),ie;let o=requestAnimationFrame(a);return Hi=o,()=>{Hi===o&&(cancelAnimationFrame(o),Hi=0)}}var Wi={inert:new WeakMap,"aria-hidden":new WeakMap},Gi=`data-base-ui-inert`,Ki={inert:new WeakSet,"aria-hidden":new WeakSet},qi=new WeakMap,Ji=0;function Yi(e){return Ki[e]}function Xi(e){return e?It(e)?e.host:Xi(e.parentNode):null}var Zi=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=Xi(t);return e.contains(n)?n:null}).filter(e=>e!=null),Qi=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},$i=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{F(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function ea(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=Zi(t,e),l=i?$i(t,Qi(c),new Set(c)):[],u=[],d=[];if(a){let e=Wi[a],n=Yi(a);s=n,o=e;let r=Zi(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);$i(t,Qi(i),new Set(i)).forEach(t=>{let r=t.getAttribute(a),i=r!==null&&r!==`false`,o=(e.get(t)||0)+1;e.set(t,o),u.push(t),o===1&&i&&n.add(t),i||t.setAttribute(a,a===`inert`?``:`true`)})}return i&&l.forEach(e=>{let t=(qi.get(e)||0)+1;qi.set(e,t),d.push(e),t===1&&e.setAttribute(Gi,``)}),Ji+=1,()=>{o&&u.forEach(e=>{let t=(o.get(e)||0)-1;o.set(e,t),t||(!s?.has(e)&&a&&e.removeAttribute(a),s?.delete(e))}),i&&d.forEach(e=>{let t=(qi.get(e)||0)-1;qi.set(e,t),t||e.removeAttribute(Gi)}),--Ji,Ji||(Wi.inert=new WeakMap,Wi[`aria-hidden`]=new WeakMap,Ki.inert=new WeakSet,Ki[`aria-hidden`]=new WeakSet,qi=new WeakMap)}}function ta(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=V(e[0]).body;return ea(e,a,n,r,{mark:i})}var K=m();function na(e,t){let n=pe(Qe(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var ra=20,ia=[];function aa(){ia=ia.filter(e=>e.deref()?.isConnected)}function oa(e){aa(),e&&F(e)!==`body`&&(ia.push(new WeakRef(e)),ia.length>ra&&(ia=ia.slice(-20)))}function sa(){return aa(),ia[ia.length-1]?.deref()}function ca(e){return e?$e(e)?e:Mt(e)[0]||e:null}function la(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=j(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return $e(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function ua(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:c=!0,openInteractionType:l=``,nextFocusableElement:u,previousFocusableElement:d,beforeContentFocusGuardRef:f,externalTree:p,getInsideElements:m}=e,h=`rootStore`in t?t.rootStore:t,g=h.useState(`open`),_=h.useState(`domReferenceElement`),v=h.useState(`floatingElement`),{events:y,dataRef:b}=h.context,x=H(()=>b.current.floatingContext?.nodeId),S=i===!1,C=Me(_)&&S,w=Zt(i),T=Zt(a),E=Zt(l),D=Zt(g),O=te(p),k=Le(),A=G.useRef(!1),ee=G.useRef(!1),j=G.useRef(!1),M=G.useRef(null),N=G.useRef(``),P=G.useRef(``),I=G.useRef(null),L=G.useRef(null),ne=xt(I,f,k?.beforeInsideRef),re=xt(L,k?.afterInsideRef),ie=gt(),ae=gt(),oe=Xe(),se=k!=null,R=xe(v),ue=H((e=R)=>e?Mt(e):[]),de=H(()=>m?.().filter(e=>e!=null)??[]);G.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&U(R,Rt(V(R)))&&ue().length===0&&!C&&wt(e)}let t=V(R);return nt(t,`keydown`,e)},[r,R,s,C,ue]),G.useEffect(()=>{if(r||!g)return;let e=V(R);function t(){j.current=!1}function n(e){let t=Qe(e),n=de(),r=U(v,t)||U(_,t)||U(k?.portalNode,t)||n.some(e=>e===t||U(e,t));j.current=!r,P.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(ee.current=!0,ae.start(0,()=>{ee.current=!1}))}function i(){P.current=`keyboard`}return nn(nt(e,`pointerdown`,n,!0),nt(e,`pointerup`,t,!0),nt(e,`pointercancel`,t,!0),nt(e,`keydown`,i,!0),t)},[r,v,_,R,g,k,ae,de]),G.useEffect(()=>{if(r||!c)return;let e=V(R);function t(){ee.current=!0,ae.start(0,()=>{ee.current=!1})}function n(e){let t=Qe(e);$e(t)&&(M.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=Qe(t);s&&n==null&&i!=null&&U(v,i)&&oa(i),queueMicrotask(()=>{let a=x(),c=h.context.triggerElements,l=de(),f=n?.hasAttribute(Ue(`focus-guard`))&&[I.current,L.current,k?.beforeInsideRef.current,k?.afterInsideRef.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,le(d),le(u)].includes(n),p=!(U(_,n)||U(v,n)||U(n,v)||U(k?.portalNode,n)||l.some(e=>e===n||U(e,n))||c.hasMatchingElement(e=>U(e,n))||f||O&&(Ae(O.nodesRef.current,a).find(e=>U(e.context?.elements.floating,n)||U(e.context?.elements.domReference,n))||qe(O.nodesRef.current,a).find(e=>[e.context?.elements.floating,xe(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===_&&R&&la(R),o&&r!==_&&!Jt(i)&&Rt(e)===e.body){if(Ve(R)&&(R.focus(),o===`popup`)){oe.request(()=>{R.focus()});return}let e=ue(),t=M.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||R;Ve(n)&&n.focus()}b.current.insideReactTree?b.current.insideReactTree=!1:(C||!s)&&n&&p&&!ee.current&&(C||n!==sa())&&(A.current=!0,h.setOpen(!1,en(ce,t)))})}function a(){j.current||(b.current.insideReactTree=!0,ie.start(0,()=>{b.current.insideReactTree=!1}))}let l=Ve(_)?_:null;if(v||l)return nn(l&&nt(l,`focusout`,i),l&&nt(l,`pointerdown`,t),v&&nt(v,`focusin`,n),v&&nt(v,`focusout`,i),v&&k&&nt(v,`focusout`,a,!0))},[r,_,v,R,s,O,k,h,c,o,ue,C,x,b,ie,ae,oe,u,d,de]),G.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(k?.portalNode?.querySelectorAll(`[${Ue(`portal`)}]`)||[]),t=(O?qe(O.nodesRef.current,x()):[]).find(e=>Me(e.context?.elements.domReference||null))?.context?.elements.domReference,n=ta([v,...e,I.current,L.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,...de(),t,le(d),le(u),C?_:null].filter(e=>e!=null),{ariaHidden:s||C,mark:!1}),i=ta([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,s,k,C,O,x,u,d,de]),B(()=>{if(!g||r||!Ve(R))return;N.current=``,P.current=``;let e=V(R),t=Rt(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(E.current||``):n;if(r===void 0||r===!1||U(R,t))return;let i=null,a=()=>(i??=ue(R),i[0]||R),o;o=r===!0||r===null?a():le(r),o||=a();let s=U(R,Rt(e));Ui(o,{preventScroll:o===R,shouldFocus(){if(!D.current)return!1;if(s)return!0;let t=Rt(e);return!(t!==o&&U(R,t))}})})},[r,g,R,ue,w,E,D]),B(()=>{if(r||!R)return;let e=V(R),t=Rt(e),n=E.current==null;oa(t);function i(e){if(e.open||(N.current=na(e.nativeEvent,P.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(A.current=!0),e.reason===`outside-press`){if(e.nested)A.current=!1;else if(Vt(e.nativeEvent)||it(e.nativeEvent))A.current=!1;else{let e=!1;V(R).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?A.current=!1:A.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&F(t)!==`body`?t:null,s=n?o||a:a||o;return s||=sa()||null,typeof i==`boolean`?s:le(i)||s||null}return()=>{y.off(`openchange`,i);let t=Rt(e),n=de(),r=U(v,t)||n.some(e=>e===t||U(e,t))||O&&Ae(O.nodesRef.current,x(),!1).some(e=>U(e.context?.elements.floating,t)),o=T.current,s=N.current,c=a(s);queueMicrotask(()=>{let n=ca(c),i=typeof o!=`boolean`;if(o&&!A.current&&Ve(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}A.current=!1})}},[r,v,R,T,E,y,O,_,x,de]),B(()=>{if(!ot||g||!v)return;let e=Rt(V(v));Ve(e)&&on(e)&&U(v,e)&&e.blur()},[g,v]),B(()=>{if(!r&&k)return k.setFocusManagerState({modal:s,closeOnFocusOut:c,open:g,onOpenChange:h.setOpen,domReference:_}),()=>{k.setFocusManagerState(null)}},[r,k,s,g,h,c,_]),B(()=>{if(!r&&R)return la(R),()=>{queueMicrotask(aa)}},[r,R]);let fe=!r&&(!s||!C)&&(se||s);return(0,K.jsxs)(G.Fragment,{children:[fe&&(0,K.jsx)(Ft,{"data-type":`inside`,ref:ne,onFocus:e=>{if(s){let e=ue();Ui(e[e.length-1])}else k?.portalNode&&(A.current=!1,vt(e,k.portalNode)?lt(_)?.focus():le(d??k.beforeOutsideRef)?.focus())}}),n,fe&&(0,K.jsx)(Ft,{"data-type":`inside`,ref:re,onFocus:e=>{s?Ui(ue()[0]):k?.portalNode&&(c&&(A.current=!0),vt(e,k.portalNode)?Gt(_)?.focus():le(u??k.afterOutsideRef)?.focus())}})]})}function da(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=ue}=t,l=`rootStore`in e?e.rootStore:e,u=l.context.dataRef,d=G.useRef(void 0),f=Xe(),p=gt(),m=G.useMemo(()=>{function e(e,t,n,r){let i=en(c,t,n);e&&r===`touch`&&s>0?p.start(s,()=>{l.setOpen(!0,i)}):l.setOpen(e,i)}function t(e,t,n){let r=u.current.openEvent,a=l.select(`domReferenceElement`)!==t;return e&&a||!e||!i?!0:r&&o?!n(r.type):!1}return{onPointerDown(e){d.current=jt(e.pointerType,!0)&&it(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=d.current,o=n.nativeEvent,s=l.select(`open`);if(n.button!==0||r===`click`||jt(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),u=Qe(o);if(on(u)){e(c,o,u,i);return}let p=n.currentTarget;f.request(()=>{e(c,o,p,i)})},onClick(n){if(r===`mousedown-only`)return;let i=d.current;r===`mousedown`&&i?d.current=void 0:jt(i,!0)&&a||e(t(l.select(`open`),n.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),n.nativeEvent,n.currentTarget,i)},onKeyDown(){d.current=void 0}}},[u,r,a,c,l,o,i,f,p,s]);return G.useMemo(()=>n?{reference:m}:se,[n,m])}var fa=`Escape`;function pa(e){return ot&&e.movementX===0&&e.movementY===0}function ma(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function ha(e,t){return ma(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function ga(e,t,n){return ma(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function _a(e,t,n){return ma(t,n?e===ct:e===Wt,e===M)}function va(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===fa:ma(t,n?e===Wt:e===ct,e===kt)}function ya(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,parentOrientation:_,id:v,resetOnPointerLeave:y=!0,externalTree:b,grid:x}=t,S=x!=null,C=`rootStore`in e?e.rootStore:e,w=C.useState(`open`),T=C.useState(`floatingElement`),E=C.useState(`domReferenceElement`),D=C.context.dataRef,O=xe(T),k=Me(E),A=Zt(O),ee=rn(),j=te(b),M=G.useRef(f),N=G.useRef(o??-1),P=G.useRef(null),F=G.useRef(!0),I=H(e=>{i(N.current===-1?null:N.current,e)}),L=G.useRef(!!T),ne=G.useRef(w),re=G.useRef(!1),ie=G.useRef(!1),ae=G.useRef(null),oe=Zt(h),se=Zt(w),le=Zt(o),R=Zt(y),ue=Xe(),de=Xe(),fe=H(()=>{function e(e){d?j?.events.emit(`virtualfocus`,e):ae.current=Ui(e,{sync:re.current,preventScroll:!0})}let t=n.current[N.current],r=ie.current;t&&e(t),(re.current?e=>e():e=>ue.request(e))(()=>{let i=n.current[N.current]||t;i&&(t||e(i),z&&(r||!F.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});B(()=>{D.current.orientation=g},[D,g]),B(()=>{a&&(w&&T?(N.current=o??-1,M.current&&o!=null&&(ie.current=!0,I())):L.current&&(N.current=-1,I()))},[a,w,T,o,I]),B(()=>{if(a){if(!w)re.current=!1;else if(T){if(r==null){if(re.current=!1,le.current!=null)return;if(L.current&&(N.current=-1,fe()),(!ne.current||!L.current)&&M.current&&(P.current!=null||M.current===!0&&P.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>de.request(e):queueMicrotask)(t),e+=1):(N.current=P.current==null||ga(P.current,g,u)||l?Tt(n):at(n),P.current=null,I())};t()}}else st(n.current,r)||(N.current=r,fe(),ie.current=!1)}}},[a,w,T,r,le,l,n,g,u,I,fe,de]),B(()=>{if(!a||T||!j||d||!L.current)return;let e=j.nodesRef.current,t=e.find(e=>e.id===ee)?.context?.elements.floating,n=Rt(V(E??t??null)),r=e.some(e=>e.context&&U(e.context.elements.floating,n));t&&!r&&F.current&&t.focus({preventScroll:!0})},[a,T,E,j,ee,d]),B(()=>{ne.current=w,L.current=!!T}),B(()=>{w||(P.current=null,M.current=f)},[w,f]);let pe=r!=null,me=H(e=>{if(!se.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(N.current!==t||r!==t)&&(N.current=t,I(e))}),he=H(()=>_??j?.nodesRef.current.find(e=>e.id===ee)?.context?.dataRef?.current.orientation),ge=H(()=>Tt(n,oe.current)),_e=H(e=>{if(F.current=!1,re.current=!0,e.which===229||!se.current&&e.currentTarget===A.current)return;if(l&&va(e.key,g,u,S)){ha(e.key,he())||wt(e),C.setOpen(!1,en(St,e.nativeEvent)),Ve(E)&&(d?j?.events.emit(`virtualfocus`,E):E.focus());return}let t=N.current,r=Tt(n,h),i=at(n,h);if(k||(e.key===`Home`&&(wt(e),N.current=r,I(e)),e.key===`End`&&(wt(e),N.current=i,I(e))),x!=null){let t=x(e,N.current,n,g,c,u,h,r,i);if(t!=null&&(N.current=t,I(e)),g===`both`)return}if(ha(e.key,g)){if(wt(e),w&&!d&&Rt(e.currentTarget.ownerDocument)===e.currentTarget){N.current=ga(e.key,g,u)?r:i,I(e);return}ga(e.key,g,u)?c?t>=i?s&&t!==n.current.length?N.current=-1:(re.current=!1,N.current=r):N.current=Ht(n.current,{startingIndex:t,disabledIndices:h}):N.current=Math.min(i,Ht(n.current,{startingIndex:t,disabledIndices:h})):c?t<=r?s&&t!==-1?N.current=n.current.length:(re.current=!1,N.current=i):N.current=Ht(n.current,{startingIndex:t,decrement:!0,disabledIndices:h}):N.current=Math.max(r,Ht(n.current,{startingIndex:t,decrement:!0,disabledIndices:h})),st(n.current,N.current)&&(N.current=-1),I(e)}}),z=G.useMemo(()=>({onFocus(e){re.current=!0,me(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){pa(e)||(re.current=!0,ie.current=!1,p&&me(e))},onPointerLeave(e){if(!se.current||!F.current||e.pointerType===`touch`)return;re.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&R.current&&(ae.current?.(),ae.current=null,N.current=-1,I(e),!d)){let e=A.current,t=Rt(V(e));e&&U(e,t)&&e.focus({preventScroll:!0})}}}),[me,se,A,p,n,I,R,d]),ve=G.useMemo(()=>d&&w&&pe&&{"aria-activedescendant":`${v}-${r}`},[d,w,pe,v,r]),ye=G.useMemo(()=>({...k?{}:ve,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&w&&!d){let t=Qe(e.nativeEvent);if(t&&!U(A.current,t))return;wt(e),C.setOpen(!1,en(ce,e.nativeEvent)),Ve(E)&&E.focus()}else _e(e)},onPointerMove(e){pa(e)||(F.current=!0)}}),[ve,_e,A,k,C,w,d,E]),be=G.useMemo(()=>{function e(e){C.setOpen(!0,en(St,e.nativeEvent,e.currentTarget))}function t(e){f===`auto`&&Vt(e.nativeEvent)&&(M.current=!d)}function n(e){M.current=f,f===`auto`&&it(e.nativeEvent)&&(M.current=!0)}return{onKeyDown(t){let n=C.select(`open`);F.current=!1;let r=t.key.startsWith(`Arrow`),i=_a(t.key,he(),u),a=ha(t.key,g),o=(l?i:a)||t.key===`Enter`||t.key.trim()===``;if(d&&n)return _e(t);if(n||m||!r){if(o){let e=ha(t.key,he());P.current=l&&e?null:t.key}l?i&&(wt(t),n?(N.current=ge(),I(t)):e(t)):a&&(le.current!=null&&(N.current=le.current),wt(t),!n&&m?e(t):_e(t),n&&I(t))}},onFocus(e){C.select(`open`)&&!d&&(N.current=-1,I(e))},onPointerDown:n,onPointerEnter:n,onMouseDown:t,onClick:t}},[_e,f,ge,l,I,C,m,g,he,u,le,d]),Se=G.useMemo(()=>({...ve,...be}),[ve,be]);return G.useMemo(()=>a?{reference:Se,floating:ye,item:z,trigger:be}:{},[a,Se,ye,be,z])}function ba(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=`rootStore`in e?e.rootStore:e,f=d.useState(`open`),p=gt(),m=G.useRef(``),h=G.useRef(u??i??-1),g=G.useRef(null),_=H(e=>{function t(e){return r?.current[e]}function c(e){let n=t(e);return n&&!Jt(n)||n?.matches(`:disabled`)?!1:o==null||!ft(Ie,e,o)}function d(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&c(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(wt(e),s?.(!0)),m.current.length>0&&m.current[0]!==` `&&d(_,m.current)===-1&&e.key!==` `&&s?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(wt(e),s?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&c(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,s?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=d(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,s?.(!1)):(a?.(b),g.current=b)}),v=H(e=>{let t=e.relatedTarget,n=d.select(`domReferenceElement`),r=d.select(`floatingElement`);U(n,t)||U(r,t)||(p.clear(),m.current=``,h.current=g.current,s?.(!1))});B(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``))},[f,u,p]);let y=G.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return G.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var xa=t(Ke(),1),Sa=({attachments:e,onRemove:t})=>e.length===0?null:(0,K.jsx)(`ul`,{"aria-label":`Attached screenshots`,className:`m-0 flex list-none flex-wrap gap-2 p-0`,children:e.map(e=>(0,K.jsxs)(`li`,{className:`relative size-14 animate-enter`,children:[(0,K.jsx)(`img`,{alt:`Pasted screenshot`,className:W(`size-14 rounded-md border border-border object-cover`,e.path===null&&`opacity-50`,e.hasFailed&&`border-sign-del`),src:e.preview}),e.path===null&&!e.hasFailed?(0,K.jsx)(Zr,{"aria-label":`Uploading`,className:`absolute inset-0 m-auto size-4 animate-spin text-foreground`}):null,(0,K.jsx)(`span`,{className:`absolute -inset-e-2 -top-2`,children:(0,K.jsx)(On,{label:`Remove screenshot`,onClick:()=>{t(e.id)},size:`icon-xs`,type:`button`,variant:`outline`,children:(0,K.jsx)(Vi,{})})})]},e.id))}),Ca=`review-draft|`,wa=new Map,Ta=e=>{let t=wa.get(e);if(t!==void 0)return t;try{return sessionStorage.getItem(Ca+e)??``}catch{return``}},Ea=(e,t)=>{wa.set(e,t);try{t===``?sessionStorage.removeItem(Ca+e):sessionStorage.setItem(Ca+e,t)}catch{}},Da=16,Oa=2,ka=()=>typeof crypto.randomUUID==`function`?crypto.randomUUID():Array.from(crypto.getRandomValues(new Uint8Array(Da)),e=>e.toString(Da).padStart(Oa,`0`)).join(``),Aa=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],ja=e=>Aa.includes(e),Ma=async e=>{let t=new Uint8Array(await e.arrayBuffer());return btoa(Array.from(t,e=>String.fromCodePoint(e)).join(``))},Na=e=>[...e?.items??[]].filter(e=>e.kind===`file`&&ja(e.type)).flatMap(e=>e.getAsFile()??[]),Pa=async(e,t)=>{let n=ja(t.type)?t.type:`image/png`,{path:r}=await E({data:{deck:e,type:n,data:await Ma(t)}});return r},Fa=e=>``,Ia=e=>({id:ka(),preview:URL.createObjectURL(e),path:null,hasFailed:!1}),La=(e,t)=>[e.trim(),...t.flatMap(e=>e.path===null?[]:[Fa(e.path)])].filter(e=>e!==``).join(`
|
|
1
|
+
import{n as e,r as t,t as n}from"./rolldown-runtime-XKyaHtl9.js";import{A as r,C as i,D as a,E as o,M as s,N as c,O as l,P as u,S as d,T as f,X as p,Y as m,_ as h,b as g,c as _,g as v,h as y,j as b,k as x,kt as S,l as C,m as w,o as T,p as E,s as D,v as O,w as k,x as A,y as ee}from"./decks.functions-tXNTG2sC.js";import{$ as j,$t as M,A as N,An as P,B as te,Bn as F,C as I,Cn as L,Ct as ne,D as re,Dn as ie,Dt as ae,E as oe,En as se,Et as ce,F as le,Fn as R,Ft as ue,Gn as de,H as fe,Hn as pe,Ht as me,I as he,In as ge,J as _e,Jn as z,K as ve,Kn as ye,L as be,Ln as B,Lt as xe,M as Se,Mn as V,Mt as Ce,N as we,O as Te,Ot as Ee,P as De,Pn as Oe,Pt as ke,Q as Ae,R as je,Rn as H,Rt as Me,S as Ne,St as Pe,T as Fe,Tn as Ie,U as Le,Ut as Re,V as ze,Vn as Be,Wn as Ve,Wt as He,X as Ue,Xt as We,Y as Ge,Yn as Ke,Z as qe,_ as Je,_n as Ye,_t as Xe,a as Ze,an as Qe,at as $e,b as et,bn as tt,bt as nt,c as rt,cn as it,ct as at,dn as ot,dt as st,en as ct,et as lt,f as ut,fn as dt,ft,g as pt,gt as mt,h as ht,hn as gt,i as _t,in as U,it as vt,jn as yt,k as bt,kn as xt,kt as St,l as Ct,ln as wt,lt as Tt,m as Et,mn as Dt,n as Ot,nn as kt,nt as At,on as jt,ot as Mt,p as Nt,pn as Pt,pt as Ft,qn as It,r as Lt,rn as Rt,rt as zt,s as Bt,sn as Vt,st as Ht,t as Ut,tn as Wt,tt as Gt,u as Kt,un as qt,ut as Jt,v as Yt,vn as Xt,vt as Zt,w as Qt,x as $t,xn as W,xt as en,yn as tn,yt as nn,z as rn,zn as an,zt as on}from"./use-window-event-BDUVK1pJ.js";import{C as sn,E as cn,S as ln,T as un,a as dn,b as fn,c as pn,h as mn,l as hn,m as gn,n as _n,o as vn,p as yn,r as bn,t as xn,u as Sn,w as Cn}from"./shortcuts-BsNWbUaT.js";import{C as wn,D as Tn,E as En,O as Dn,S as On,T as kn,_ as An,a as jn,c as Mn,d as Nn,f as Pn,g as Fn,h as In,i as Ln,l as Rn,m as zn,o as Bn,p as Vn,s as Hn,u as Un,v as Wn,w as Gn,x as Kn,y as qn}from"./index-oNjROFCr.js";var Jn={name:`arrow-down-to-line`,size:24,node:[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]};Jn.node;var Yn=z(Jn),Xn={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Xn.node;var Zn=z(Xn),Qn={name:`arrow-up-to-line`,size:24,node:[[`path`,{d:`M5 3h14`,key:`7usisc`}],[`path`,{d:`m18 13-6-6-6 6`,key:`1kf1n9`}],[`path`,{d:`M12 7v14`,key:`1akyts`}]]};Qn.node;var $n=z(Qn),er={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};er.node;var tr=z(er),nr={name:`check-check`,size:24,node:[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]};nr.node;var rr=z(nr),ir={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};ir.node;var ar=z(ir),or={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};or.node;var sr=z(or),cr={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};cr.node;var lr=z(cr),ur={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};ur.node;var dr=z(ur),fr={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`}]]};fr.node;var pr=z(fr),mr={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`}]]};mr.node;var hr=z(mr),gr={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};gr.node;var _r=z(gr),vr={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};vr.node;var yr=z(vr),br={name:`clipboard-copy`,size:24,node:[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2`,key:`4jdomd`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v4`,key:`3hqy98`}],[`path`,{d:`M21 14H11`,key:`1bme5i`}],[`path`,{d:`m15 10-4 4 4 4`,key:`5dvupr`}]]};br.node;var xr=z(br),Sr={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};Sr.node;var Cr=z(Sr),wr={name:`corner-down-left`,size:24,node:[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]};wr.node;var Tr=z(wr),Er={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Er.node;var Dr=z(Er),Or={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Or.node;var kr=z(Or),Ar={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`}]]};Ar.node;var jr=z(Ar),Mr={name:`folder-open`,size:24,node:[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]};Mr.node;var Nr=z(Mr),Pr={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};Pr.node;var Fr=z(Pr),Ir={name:`git-compare`,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`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]};Ir.node;var Lr=z(Ir),Rr={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`}]]};Rr.node;var zr=z(Rr),Br={name:`keyboard`,size:24,node:[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]};Br.node;var Vr=z(Br),Hr={name:`layers-2`,size:24,node:[[`path`,{d:`M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74z`,key:`15q6uc`}],[`path`,{d:`m20 14.285 1.5.845a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74l1.5-.845`,key:`byia6g`}]]};Hr.node;var Ur=z(Hr),Wr={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Wr.node;var Gr=z(Wr),Kr={name:`list-filter`,size:24,node:[[`path`,{d:`M2 5h20`,key:`1fs1ex`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M9 19h6`,key:`456am0`}]]};Kr.node;var qr=z(Kr),Jr={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};Jr.node;var Yr=z(Jr),Xr={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};Xr.node;var Zr=z(Xr),Qr={name:`locate-fixed`,size:24,node:[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};Qr.node;var $r=z(Qr),ei={name:`maximize-2`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]};ei.node;var ti=z(ei),ni={name:`message-square-plus`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]};ni.node;var ri=z(ni),ii={name:`messages-square`,size:24,node:[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]};ii.node;var ai=z(ii),oi={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};oi.node;var si=z(oi),ci={name:`pin`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]};ci.node;var li=z(ci),ui={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};ui.node;var di=z(ui),fi={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};fi.node;var pi=z(fi),mi={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};mi.node;var hi=z(mi),gi={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};gi.node;var _i=z(gi),vi={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};vi.node;var yi=z(vi),bi={name:`sparkle`,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`}]]};bi.node;var xi=z(bi),Si={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`]};Si.node;var Ci=z(Si),wi={name:`square-arrow-out-up-right`,size:24,node:[[`path`,{d:`M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6`,key:`y09zxi`}],[`path`,{d:`m21 3-9 9`,key:`mpx6sq`}],[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}]],aliases:[`arrow-up-right-from-square`]};wi.node;var Ti=z(wi),Ei={name:`square-dashed-text`,size:24,node:[[`path`,{d:`M14 21h1`,key:`v9vybs`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M21 14v1`,key:`169vum`}],[`path`,{d:`M21 19a2 2 0 0 1-2 2`,key:`1j7049`}],[`path`,{d:`M21 9v1`,key:`mxsmne`}],[`path`,{d:`M3 14v1`,key:`vnatye`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M7 16h6`,key:`1vyc9m`}],[`path`,{d:`M7 8h8`,key:`1jbsf9`}],[`path`,{d:`M9 21h1`,key:`15o7lz`}],[`path`,{d:`M9 3h1`,key:`1yesri`}]],aliases:[`text-selection`,`text-select`]};Ei.node;var Di=z(Ei),Oi={name:`square-terminal`,size:24,node:[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]],aliases:[`terminal-square`]};Oi.node;var ki=z(Oi),Ai={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Ai.node;var ji=z(Ai),Mi={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};Mi.node;var Ni=z(Mi),Pi={name:`text-wrap`,size:24,node:[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]],aliases:[`wrap-text`]};Pi.node;var Fi=z(Pi),Ii={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Ii.node;var Li=z(Ii),Ri={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`]};Ri.node;var zi=z(Ri),Bi={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};Bi.node;var Vi=z(Bi),G=t(S(),1),Hi=0;function Ui(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(Hi);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),ie;let o=requestAnimationFrame(a);return Hi=o,()=>{Hi===o&&(cancelAnimationFrame(o),Hi=0)}}var Wi={inert:new WeakMap,"aria-hidden":new WeakMap},Gi=`data-base-ui-inert`,Ki={inert:new WeakSet,"aria-hidden":new WeakSet},qi=new WeakMap,Ji=0;function Yi(e){return Ki[e]}function Xi(e){return e?It(e)?e.host:Xi(e.parentNode):null}var Zi=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=Xi(t);return e.contains(n)?n:null}).filter(e=>e!=null),Qi=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},$i=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{F(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function ea(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=Zi(t,e),l=i?$i(t,Qi(c),new Set(c)):[],u=[],d=[];if(a){let e=Wi[a],n=Yi(a);s=n,o=e;let r=Zi(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);$i(t,Qi(i),new Set(i)).forEach(t=>{let r=t.getAttribute(a),i=r!==null&&r!==`false`,o=(e.get(t)||0)+1;e.set(t,o),u.push(t),o===1&&i&&n.add(t),i||t.setAttribute(a,a===`inert`?``:`true`)})}return i&&l.forEach(e=>{let t=(qi.get(e)||0)+1;qi.set(e,t),d.push(e),t===1&&e.setAttribute(Gi,``)}),Ji+=1,()=>{o&&u.forEach(e=>{let t=(o.get(e)||0)-1;o.set(e,t),t||(!s?.has(e)&&a&&e.removeAttribute(a),s?.delete(e))}),i&&d.forEach(e=>{let t=(qi.get(e)||0)-1;qi.set(e,t),t||e.removeAttribute(Gi)}),--Ji,Ji||(Wi.inert=new WeakMap,Wi[`aria-hidden`]=new WeakMap,Ki.inert=new WeakSet,Ki[`aria-hidden`]=new WeakSet,qi=new WeakMap)}}function ta(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=V(e[0]).body;return ea(e,a,n,r,{mark:i})}var K=m();function na(e,t){let n=pe(Qe(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var ra=20,ia=[];function aa(){ia=ia.filter(e=>e.deref()?.isConnected)}function oa(e){aa(),e&&F(e)!==`body`&&(ia.push(new WeakRef(e)),ia.length>ra&&(ia=ia.slice(-20)))}function sa(){return aa(),ia[ia.length-1]?.deref()}function ca(e){return e?$e(e)?e:Mt(e)[0]||e:null}function la(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=j(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return $e(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function ua(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:c=!0,openInteractionType:l=``,nextFocusableElement:u,previousFocusableElement:d,beforeContentFocusGuardRef:f,externalTree:p,getInsideElements:m}=e,h=`rootStore`in t?t.rootStore:t,g=h.useState(`open`),_=h.useState(`domReferenceElement`),v=h.useState(`floatingElement`),{events:y,dataRef:b}=h.context,x=H(()=>b.current.floatingContext?.nodeId),S=i===!1,C=Me(_)&&S,w=Zt(i),T=Zt(a),E=Zt(l),D=Zt(g),O=te(p),k=Le(),A=G.useRef(!1),ee=G.useRef(!1),j=G.useRef(!1),M=G.useRef(null),N=G.useRef(``),P=G.useRef(``),I=G.useRef(null),L=G.useRef(null),ne=xt(I,f,k?.beforeInsideRef),re=xt(L,k?.afterInsideRef),ie=gt(),ae=gt(),oe=Xe(),se=k!=null,R=xe(v),ue=H((e=R)=>e?Mt(e):[]),de=H(()=>m?.().filter(e=>e!=null)??[]);G.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&U(R,Rt(V(R)))&&ue().length===0&&!C&&wt(e)}let t=V(R);return nt(t,`keydown`,e)},[r,R,s,C,ue]),G.useEffect(()=>{if(r||!g)return;let e=V(R);function t(){j.current=!1}function n(e){let t=Qe(e),n=de(),r=U(v,t)||U(_,t)||U(k?.portalNode,t)||n.some(e=>e===t||U(e,t));j.current=!r,P.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(ee.current=!0,ae.start(0,()=>{ee.current=!1}))}function i(){P.current=`keyboard`}return nn(nt(e,`pointerdown`,n,!0),nt(e,`pointerup`,t,!0),nt(e,`pointercancel`,t,!0),nt(e,`keydown`,i,!0),t)},[r,v,_,R,g,k,ae,de]),G.useEffect(()=>{if(r||!c)return;let e=V(R);function t(){ee.current=!0,ae.start(0,()=>{ee.current=!1})}function n(e){let t=Qe(e);$e(t)&&(M.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=Qe(t);s&&n==null&&i!=null&&U(v,i)&&oa(i),queueMicrotask(()=>{let a=x(),c=h.context.triggerElements,l=de(),f=n?.hasAttribute(Ue(`focus-guard`))&&[I.current,L.current,k?.beforeInsideRef.current,k?.afterInsideRef.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,le(d),le(u)].includes(n),p=!(U(_,n)||U(v,n)||U(n,v)||U(k?.portalNode,n)||l.some(e=>e===n||U(e,n))||c.hasMatchingElement(e=>U(e,n))||f||O&&(Ae(O.nodesRef.current,a).find(e=>U(e.context?.elements.floating,n)||U(e.context?.elements.domReference,n))||qe(O.nodesRef.current,a).find(e=>[e.context?.elements.floating,xe(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===_&&R&&la(R),o&&r!==_&&!Jt(i)&&Rt(e)===e.body){if(Ve(R)&&(R.focus(),o===`popup`)){oe.request(()=>{R.focus()});return}let e=ue(),t=M.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||R;Ve(n)&&n.focus()}b.current.insideReactTree?b.current.insideReactTree=!1:(C||!s)&&n&&p&&!ee.current&&(C||n!==sa())&&(A.current=!0,h.setOpen(!1,en(ce,t)))})}function a(){j.current||(b.current.insideReactTree=!0,ie.start(0,()=>{b.current.insideReactTree=!1}))}let l=Ve(_)?_:null;if(v||l)return nn(l&&nt(l,`focusout`,i),l&&nt(l,`pointerdown`,t),v&&nt(v,`focusin`,n),v&&nt(v,`focusout`,i),v&&k&&nt(v,`focusout`,a,!0))},[r,_,v,R,s,O,k,h,c,o,ue,C,x,b,ie,ae,oe,u,d,de]),G.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(k?.portalNode?.querySelectorAll(`[${Ue(`portal`)}]`)||[]),t=(O?qe(O.nodesRef.current,x()):[]).find(e=>Me(e.context?.elements.domReference||null))?.context?.elements.domReference,n=ta([v,...e,I.current,L.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,...de(),t,le(d),le(u),C?_:null].filter(e=>e!=null),{ariaHidden:s||C,mark:!1}),i=ta([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,s,k,C,O,x,u,d,de]),B(()=>{if(!g||r||!Ve(R))return;N.current=``,P.current=``;let e=V(R),t=Rt(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(E.current||``):n;if(r===void 0||r===!1||U(R,t))return;let i=null,a=()=>(i??=ue(R),i[0]||R),o;o=r===!0||r===null?a():le(r),o||=a();let s=U(R,Rt(e));Ui(o,{preventScroll:o===R,shouldFocus(){if(!D.current)return!1;if(s)return!0;let t=Rt(e);return!(t!==o&&U(R,t))}})})},[r,g,R,ue,w,E,D]),B(()=>{if(r||!R)return;let e=V(R),t=Rt(e),n=E.current==null;oa(t);function i(e){if(e.open||(N.current=na(e.nativeEvent,P.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(A.current=!0),e.reason===`outside-press`){if(e.nested)A.current=!1;else if(Vt(e.nativeEvent)||it(e.nativeEvent))A.current=!1;else{let e=!1;V(R).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?A.current=!1:A.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&F(t)!==`body`?t:null,s=n?o||a:a||o;return s||=sa()||null,typeof i==`boolean`?s:le(i)||s||null}return()=>{y.off(`openchange`,i);let t=Rt(e),n=de(),r=U(v,t)||n.some(e=>e===t||U(e,t))||O&&Ae(O.nodesRef.current,x(),!1).some(e=>U(e.context?.elements.floating,t)),o=T.current,s=N.current,c=a(s);queueMicrotask(()=>{let n=ca(c),i=typeof o!=`boolean`;if(o&&!A.current&&Ve(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}A.current=!1})}},[r,v,R,T,E,y,O,_,x,de]),B(()=>{if(!ot||g||!v)return;let e=Rt(V(v));Ve(e)&&on(e)&&U(v,e)&&e.blur()},[g,v]),B(()=>{if(!r&&k)return k.setFocusManagerState({modal:s,closeOnFocusOut:c,open:g,onOpenChange:h.setOpen,domReference:_}),()=>{k.setFocusManagerState(null)}},[r,k,s,g,h,c,_]),B(()=>{if(!r&&R)return la(R),()=>{queueMicrotask(aa)}},[r,R]);let fe=!r&&(!s||!C)&&(se||s);return(0,K.jsxs)(G.Fragment,{children:[fe&&(0,K.jsx)(Ft,{"data-type":`inside`,ref:ne,onFocus:e=>{if(s){let e=ue();Ui(e[e.length-1])}else k?.portalNode&&(A.current=!1,vt(e,k.portalNode)?lt(_)?.focus():le(d??k.beforeOutsideRef)?.focus())}}),n,fe&&(0,K.jsx)(Ft,{"data-type":`inside`,ref:re,onFocus:e=>{s?Ui(ue()[0]):k?.portalNode&&(c&&(A.current=!0),vt(e,k.portalNode)?Gt(_)?.focus():le(u??k.afterOutsideRef)?.focus())}})]})}function da(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=ue}=t,l=`rootStore`in e?e.rootStore:e,u=l.context.dataRef,d=G.useRef(void 0),f=Xe(),p=gt(),m=G.useMemo(()=>{function e(e,t,n,r){let i=en(c,t,n);e&&r===`touch`&&s>0?p.start(s,()=>{l.setOpen(!0,i)}):l.setOpen(e,i)}function t(e,t,n){let r=u.current.openEvent,a=l.select(`domReferenceElement`)!==t;return e&&a||!e||!i?!0:r&&o?!n(r.type):!1}return{onPointerDown(e){d.current=jt(e.pointerType,!0)&&it(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=d.current,o=n.nativeEvent,s=l.select(`open`);if(n.button!==0||r===`click`||jt(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),u=Qe(o);if(on(u)){e(c,o,u,i);return}let p=n.currentTarget;f.request(()=>{e(c,o,p,i)})},onClick(n){if(r===`mousedown-only`)return;let i=d.current;r===`mousedown`&&i?d.current=void 0:jt(i,!0)&&a||e(t(l.select(`open`),n.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),n.nativeEvent,n.currentTarget,i)},onKeyDown(){d.current=void 0}}},[u,r,a,c,l,o,i,f,p,s]);return G.useMemo(()=>n?{reference:m}:se,[n,m])}var fa=`Escape`;function pa(e){return ot&&e.movementX===0&&e.movementY===0}function ma(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function ha(e,t){return ma(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function ga(e,t,n){return ma(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function _a(e,t,n){return ma(t,n?e===ct:e===Wt,e===M)}function va(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===fa:ma(t,n?e===Wt:e===ct,e===kt)}function ya(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,parentOrientation:_,id:v,resetOnPointerLeave:y=!0,externalTree:b,grid:x}=t,S=x!=null,C=`rootStore`in e?e.rootStore:e,w=C.useState(`open`),T=C.useState(`floatingElement`),E=C.useState(`domReferenceElement`),D=C.context.dataRef,O=xe(T),k=Me(E),A=Zt(O),ee=rn(),j=te(b),M=G.useRef(f),N=G.useRef(o??-1),P=G.useRef(null),F=G.useRef(!0),I=H(e=>{i(N.current===-1?null:N.current,e)}),L=G.useRef(!!T),ne=G.useRef(w),re=G.useRef(!1),ie=G.useRef(!1),ae=G.useRef(null),oe=Zt(h),se=Zt(w),le=Zt(o),R=Zt(y),ue=Xe(),de=Xe(),fe=H(()=>{function e(e){d?j?.events.emit(`virtualfocus`,e):ae.current=Ui(e,{sync:re.current,preventScroll:!0})}let t=n.current[N.current],r=ie.current;t&&e(t),(re.current?e=>e():e=>ue.request(e))(()=>{let i=n.current[N.current]||t;i&&(t||e(i),z&&(r||!F.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});B(()=>{D.current.orientation=g},[D,g]),B(()=>{a&&(w&&T?(N.current=o??-1,M.current&&o!=null&&(ie.current=!0,I())):L.current&&(N.current=-1,I()))},[a,w,T,o,I]),B(()=>{if(a){if(!w)re.current=!1;else if(T){if(r==null){if(re.current=!1,le.current!=null)return;if(L.current&&(N.current=-1,fe()),(!ne.current||!L.current)&&M.current&&(P.current!=null||M.current===!0&&P.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>de.request(e):queueMicrotask)(t),e+=1):(N.current=P.current==null||ga(P.current,g,u)||l?Tt(n):at(n),P.current=null,I())};t()}}else st(n.current,r)||(N.current=r,fe(),ie.current=!1)}}},[a,w,T,r,le,l,n,g,u,I,fe,de]),B(()=>{if(!a||T||!j||d||!L.current)return;let e=j.nodesRef.current,t=e.find(e=>e.id===ee)?.context?.elements.floating,n=Rt(V(E??t??null)),r=e.some(e=>e.context&&U(e.context.elements.floating,n));t&&!r&&F.current&&t.focus({preventScroll:!0})},[a,T,E,j,ee,d]),B(()=>{ne.current=w,L.current=!!T}),B(()=>{w||(P.current=null,M.current=f)},[w,f]);let pe=r!=null,me=H(e=>{if(!se.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(N.current!==t||r!==t)&&(N.current=t,I(e))}),he=H(()=>_??j?.nodesRef.current.find(e=>e.id===ee)?.context?.dataRef?.current.orientation),ge=H(()=>Tt(n,oe.current)),_e=H(e=>{if(F.current=!1,re.current=!0,e.which===229||!se.current&&e.currentTarget===A.current)return;if(l&&va(e.key,g,u,S)){ha(e.key,he())||wt(e),C.setOpen(!1,en(St,e.nativeEvent)),Ve(E)&&(d?j?.events.emit(`virtualfocus`,E):E.focus());return}let t=N.current,r=Tt(n,h),i=at(n,h);if(k||(e.key===`Home`&&(wt(e),N.current=r,I(e)),e.key===`End`&&(wt(e),N.current=i,I(e))),x!=null){let t=x(e,N.current,n,g,c,u,h,r,i);if(t!=null&&(N.current=t,I(e)),g===`both`)return}if(ha(e.key,g)){if(wt(e),w&&!d&&Rt(e.currentTarget.ownerDocument)===e.currentTarget){N.current=ga(e.key,g,u)?r:i,I(e);return}ga(e.key,g,u)?c?t>=i?s&&t!==n.current.length?N.current=-1:(re.current=!1,N.current=r):N.current=Ht(n.current,{startingIndex:t,disabledIndices:h}):N.current=Math.min(i,Ht(n.current,{startingIndex:t,disabledIndices:h})):c?t<=r?s&&t!==-1?N.current=n.current.length:(re.current=!1,N.current=i):N.current=Ht(n.current,{startingIndex:t,decrement:!0,disabledIndices:h}):N.current=Math.max(r,Ht(n.current,{startingIndex:t,decrement:!0,disabledIndices:h})),st(n.current,N.current)&&(N.current=-1),I(e)}}),z=G.useMemo(()=>({onFocus(e){re.current=!0,me(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){pa(e)||(re.current=!0,ie.current=!1,p&&me(e))},onPointerLeave(e){if(!se.current||!F.current||e.pointerType===`touch`)return;re.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&R.current&&(ae.current?.(),ae.current=null,N.current=-1,I(e),!d)){let e=A.current,t=Rt(V(e));e&&U(e,t)&&e.focus({preventScroll:!0})}}}),[me,se,A,p,n,I,R,d]),ve=G.useMemo(()=>d&&w&&pe&&{"aria-activedescendant":`${v}-${r}`},[d,w,pe,v,r]),ye=G.useMemo(()=>({...k?{}:ve,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&w&&!d){let t=Qe(e.nativeEvent);if(t&&!U(A.current,t))return;wt(e),C.setOpen(!1,en(ce,e.nativeEvent)),Ve(E)&&E.focus()}else _e(e)},onPointerMove(e){pa(e)||(F.current=!0)}}),[ve,_e,A,k,C,w,d,E]),be=G.useMemo(()=>{function e(e){C.setOpen(!0,en(St,e.nativeEvent,e.currentTarget))}function t(e){f===`auto`&&Vt(e.nativeEvent)&&(M.current=!d)}function n(e){M.current=f,f===`auto`&&it(e.nativeEvent)&&(M.current=!0)}return{onKeyDown(t){let n=C.select(`open`);F.current=!1;let r=t.key.startsWith(`Arrow`),i=_a(t.key,he(),u),a=ha(t.key,g),o=(l?i:a)||t.key===`Enter`||t.key.trim()===``;if(d&&n)return _e(t);if(n||m||!r){if(o){let e=ha(t.key,he());P.current=l&&e?null:t.key}l?i&&(wt(t),n?(N.current=ge(),I(t)):e(t)):a&&(le.current!=null&&(N.current=le.current),wt(t),!n&&m?e(t):_e(t),n&&I(t))}},onFocus(e){C.select(`open`)&&!d&&(N.current=-1,I(e))},onPointerDown:n,onPointerEnter:n,onMouseDown:t,onClick:t}},[_e,f,ge,l,I,C,m,g,he,u,le,d]),Se=G.useMemo(()=>({...ve,...be}),[ve,be]);return G.useMemo(()=>a?{reference:Se,floating:ye,item:z,trigger:be}:{},[a,Se,ye,be,z])}function ba(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=`rootStore`in e?e.rootStore:e,f=d.useState(`open`),p=gt(),m=G.useRef(``),h=G.useRef(u??i??-1),g=G.useRef(null),_=H(e=>{function t(e){return r?.current[e]}function c(e){let n=t(e);return n&&!Jt(n)||n?.matches(`:disabled`)?!1:o==null||!ft(Ie,e,o)}function d(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&c(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(wt(e),s?.(!0)),m.current.length>0&&m.current[0]!==` `&&d(_,m.current)===-1&&e.key!==` `&&s?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(wt(e),s?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&c(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,s?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=d(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,s?.(!1)):(a?.(b),g.current=b)}),v=H(e=>{let t=e.relatedTarget,n=d.select(`domReferenceElement`),r=d.select(`floatingElement`);U(n,t)||U(r,t)||(p.clear(),m.current=``,h.current=g.current,s?.(!1))});B(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``))},[f,u,p]);let y=G.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return G.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var xa=t(Ke(),1),Sa=({attachments:e,onRemove:t})=>e.length===0?null:(0,K.jsx)(`ul`,{"aria-label":`Attached screenshots`,className:`m-0 flex list-none flex-wrap gap-2 p-0`,children:e.map(e=>(0,K.jsxs)(`li`,{className:`relative size-14 animate-enter`,children:[(0,K.jsx)(`img`,{alt:`Pasted screenshot`,className:W(`size-14 rounded-md border border-border object-cover`,e.path===null&&`opacity-50`,e.hasFailed&&`border-sign-del`),src:e.preview}),e.path===null&&!e.hasFailed?(0,K.jsx)(Zr,{"aria-label":`Uploading`,className:`absolute inset-0 m-auto size-4 animate-spin text-foreground`}):null,(0,K.jsx)(`span`,{className:`absolute -inset-e-2 -top-2`,children:(0,K.jsx)(On,{label:`Remove screenshot`,onClick:()=>{t(e.id)},size:`icon-xs`,type:`button`,variant:`outline`,children:(0,K.jsx)(Vi,{})})})]},e.id))}),Ca=`review-draft|`,wa=new Map,Ta=e=>{let t=wa.get(e);if(t!==void 0)return t;try{return sessionStorage.getItem(Ca+e)??``}catch{return``}},Ea=(e,t)=>{wa.set(e,t);try{t===``?sessionStorage.removeItem(Ca+e):sessionStorage.setItem(Ca+e,t)}catch{}},Da=16,Oa=2,ka=()=>typeof crypto.randomUUID==`function`?crypto.randomUUID():Array.from(crypto.getRandomValues(new Uint8Array(Da)),e=>e.toString(Da).padStart(Oa,`0`)).join(``),Aa=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],ja=e=>Aa.includes(e),Ma=async e=>{let t=new Uint8Array(await e.arrayBuffer());return btoa(Array.from(t,e=>String.fromCodePoint(e)).join(``))},Na=e=>[...e?.items??[]].filter(e=>e.kind===`file`&&ja(e.type)).flatMap(e=>e.getAsFile()??[]),Pa=async(e,t)=>{let n=ja(t.type)?t.type:`image/png`,{path:r}=await E({data:{deck:e,type:n,data:await Ma(t)}});return r},Fa=e=>``,Ia=e=>({id:ka(),preview:URL.createObjectURL(e),path:null,hasFailed:!1}),La=(e,t)=>[e.trim(),...t.flatMap(e=>e.path===null?[]:[Fa(e.path)])].filter(e=>e!==``).join(`
|
|
2
2
|
|
|
3
3
|
`),Ra=e=>{let[t,n]=(0,G.useState)([]),r=(e,t)=>{n(n=>n.map(n=>n.id===e?{...n,...t}:n))},i=async(t,n)=>{try{r(n.id,{path:await Pa(e,t)})}catch{r(n.id,{hasFailed:!0})}};return{attachments:t,add:e=>{let t=e.map(e=>({file:e,attachment:Ia(e)}));n(e=>[...e,...t.map(({attachment:e})=>e)]);for(let{file:e,attachment:n}of t)i(e,n)},remove:e=>{n(t=>t.filter(t=>t.id!==e))},clear:()=>{n([])}}},za=e=>e.some(e=>e.path===null&&!e.hasFailed),Ba=(e,t,n)=>{let[r,i]=(0,G.useState)(()=>n===void 0?``:Ta(n)),a=e=>{i(e),n!==void 0&&Ea(n,e)},[o,s]=(0,G.useState)(!1),{attachments:c,add:l,remove:u,clear:d}=Ra(e),f=La(r,c),p=f!==``&&!o&&!za(c);return{text:r,setText:a,attachments:c,remove:u,canSend:p,submit:async()=>{p&&(s(!0),await t(f),s(!1),a(``),d())},paste:e=>{let t=Na(e.clipboardData);t.length===0?dn(e):(e.preventDefault(),l(t))}}},Va=176,Ha=e=>{e.style.height=`auto`,e.style.height=`${String(Math.min(e.scrollHeight,Va))}px`},Ua=e=>{e.focus(),e.setSelectionRange(e.value.length,e.value.length)},Wa={card:{form:`grid cursor-text gap-2 rounded-xl border border-border bg-composer px-3 pt-2.5 pb-2 transition-colors duration-150 ease-out focus-within:border-muted-foreground hover:border-subtle`,text:`max-h-44 min-h-6 resize-none overflow-y-auto bg-transparent text-sm/6 text-foreground outline-none placeholder:text-subtle`},phone:{form:`flex cursor-text flex-wrap items-end gap-1`,text:`max-h-44 min-h-6 min-w-0 flex-1 resize-none overflow-y-auto bg-transparent pb-2.5 text-base text-foreground outline-none placeholder:text-subtle`}},Ga=({isDisabled:e,label:t})=>(0,K.jsx)(`button`,{"aria-label":t,className:`grid size-11 shrink-0 press place-items-center disabled:opacity-40`,disabled:e,type:`submit`,children:(0,K.jsx)(`span`,{className:`grid size-8.5 place-items-center rounded-full bg-accent text-accent-foreground`,children:(0,K.jsx)(tr,{"aria-hidden":!0,className:`size-4.5`,strokeWidth:2.5})})}),Ka=new WeakSet,qa=(e,t)=>n=>{e.current=n,n!==null&&(Ha(n),t&&!Ka.has(n)&&(Ka.add(n),Ua(n)))},Ja=e=>(e.ctrlKey||e.metaKey)&&e.key===`s`||e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing,Ya=({submit:e,cancel:t})=>n=>{Ja(n)&&(n.preventDefault(),e()),n.key===`Escape`&&t?.()},Xa=({deck:e,placeholder:t,submitLabel:n,isFocused:r=!1,onSubmit:i,onCancel:a,draftKey:o,look:s=`card`})=>{let{text:c,setText:l,attachments:u,remove:d,canSend:f,submit:p,paste:m}=Ba(e,i,o),h=s===`phone`,g=(0,G.useRef)(null),_=(0,G.useRef)(null);return(0,K.jsxs)(`form`,{className:Wa[s].form,onPointerDown:e=>{(e.target===e.currentTarget||e.target===_.current)&&g.current!==null&&(e.preventDefault(),Ua(g.current))},onSubmit:e=>{e.preventDefault(),p()},children:[(0,K.jsx)(Sa,{attachments:u,onRemove:d}),(0,K.jsx)(`textarea`,{"aria-label":t,className:Wa[s].text,onChange:e=>{l(e.target.value),Ha(e.target)},onKeyDown:Ya({submit:p,cancel:a}),onPaste:m,placeholder:t,ref:qa(g,r),rows:1,value:c}),h?(0,K.jsx)(Ga,{isDisabled:!f,label:n}):null,(0,K.jsxs)(`div`,{className:h?`hidden`:`flex items-center justify-end gap-2`,ref:_,children:[a===void 0?null:(0,K.jsx)(On,{label:`Cancel`,onClick:a,shortcut:xn.close,size:`icon-sm`,type:`button`,children:(0,K.jsx)(Vi,{})}),(0,K.jsx)(On,{disabled:!f,label:n,shortcut:xn.send,size:`icon-sm`,type:`submit`,children:(0,K.jsx)(Tr,{})})]})]})};function Za(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Qa=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$a=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eo={};function to(e,t){return((t||eo).jsx?$a:Qa).test(e)}var no=/[ \t\n\f\r]/g;function ro(e){return typeof e==`object`?e.type===`text`&&io(e.value):io(e)}function io(e){return e.replace(no,``)===``}var ao=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};ao.prototype.normal={},ao.prototype.property={},ao.prototype.space=void 0;function oo(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new ao(n,r,t)}function so(e){return e.toLowerCase()}var co=class{constructor(e,t){this.attribute=t,this.property=e}};co.prototype.attribute=``,co.prototype.booleanish=!1,co.prototype.boolean=!1,co.prototype.commaOrSpaceSeparated=!1,co.prototype.commaSeparated=!1,co.prototype.defined=!1,co.prototype.mustUseProperty=!1,co.prototype.number=!1,co.prototype.overloadedBoolean=!1,co.prototype.property=``,co.prototype.spaceSeparated=!1,co.prototype.space=void 0;var lo=e({boolean:()=>q,booleanish:()=>fo,commaOrSpaceSeparated:()=>ho,commaSeparated:()=>mo,number:()=>J,overloadedBoolean:()=>po,spaceSeparated:()=>Y}),uo=0,q=go(),fo=go(),po=go(),J=go(),Y=go(),mo=go(),ho=go();function go(){return 2**++uo}var _o=Object.keys(lo),vo=class extends co{constructor(e,t,n,r){let i=-1;if(super(e,t),yo(this,`space`,r),typeof n==`number`)for(;++i<_o.length;){let e=_o[i];yo(this,_o[i],(n&lo[e])===lo[e])}}};vo.prototype.defined=!0;function yo(e,t,n){n&&(e[t]=n)}function bo(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new vo(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[so(r)]=r,n[so(a.attribute)]=r}return new ao(t,n,e.space)}var xo=bo({properties:{ariaActiveDescendant:null,ariaAtomic:fo,ariaAutoComplete:null,ariaBusy:fo,ariaChecked:fo,ariaColCount:J,ariaColIndex:J,ariaColSpan:J,ariaControls:Y,ariaCurrent:null,ariaDescribedBy:Y,ariaDetails:null,ariaDisabled:fo,ariaDropEffect:Y,ariaErrorMessage:null,ariaExpanded:fo,ariaFlowTo:Y,ariaGrabbed:fo,ariaHasPopup:null,ariaHidden:fo,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Y,ariaLevel:J,ariaLive:null,ariaModal:fo,ariaMultiLine:fo,ariaMultiSelectable:fo,ariaOrientation:null,ariaOwns:Y,ariaPlaceholder:null,ariaPosInSet:J,ariaPressed:fo,ariaReadOnly:fo,ariaRelevant:null,ariaRequired:fo,ariaRoleDescription:Y,ariaRowCount:J,ariaRowIndex:J,ariaRowSpan:J,ariaSelected:fo,ariaSetSize:J,ariaSort:null,ariaValueMax:J,ariaValueMin:J,ariaValueNow:J,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function So(e,t){return t in e?e[t]:t}function Co(e,t){return So(e,t.toLowerCase())}var wo=bo({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:mo,acceptCharset:Y,accessKey:Y,action:null,allow:null,allowFullScreen:q,allowPaymentRequest:q,allowUserMedia:q,alpha:q,alt:null,as:null,async:q,autoCapitalize:null,autoComplete:Y,autoFocus:q,autoPlay:q,blocking:Y,capture:null,charSet:null,checked:q,cite:null,className:Y,closedBy:null,colorSpace:null,cols:J,colSpan:J,command:null,commandFor:null,content:null,contentEditable:fo,controls:q,controlsList:Y,coords:J|mo,crossOrigin:null,data:null,dateTime:null,decoding:null,default:q,defer:q,dir:null,dirName:null,disabled:q,download:po,draggable:fo,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:q,formTarget:null,headers:Y,height:J,hidden:po,high:J,href:null,hrefLang:null,htmlFor:Y,httpEquiv:Y,id:null,imageSizes:null,imageSrcSet:null,inert:q,inputMode:null,integrity:null,is:null,isMap:q,itemId:null,itemProp:Y,itemRef:Y,itemScope:q,itemType:Y,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:q,low:J,manifest:null,max:null,maxLength:J,media:null,method:null,min:null,minLength:J,multiple:q,muted:q,name:null,nonce:null,noModule:q,noValidate:q,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:q,optimum:J,pattern:null,ping:Y,placeholder:null,playsInline:q,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:q,referrerPolicy:null,rel:Y,required:q,reversed:q,rows:J,rowSpan:J,sandbox:Y,scope:null,scoped:q,seamless:q,selected:q,shadowRootClonable:q,shadowRootCustomElementRegistry:q,shadowRootDelegatesFocus:q,shadowRootMode:null,shadowRootSerializable:q,shape:null,size:J,sizes:null,slot:null,span:J,spellCheck:fo,src:null,srcDoc:null,srcLang:null,srcSet:null,start:J,step:null,style:null,tabIndex:J,target:null,title:null,translate:null,type:null,typeMustMatch:q,useMap:null,value:fo,width:J,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Y,axis:null,background:null,bgColor:null,border:J,borderColor:null,bottomMargin:J,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:q,declare:q,event:null,face:null,frame:null,frameBorder:null,hSpace:J,leftMargin:J,link:null,longDesc:null,lowSrc:null,marginHeight:J,marginWidth:J,noResize:q,noHref:q,noShade:q,noWrap:q,object:null,profile:null,prompt:null,rev:null,rightMargin:J,rules:null,scheme:null,scrolling:fo,standby:null,summary:null,text:null,topMargin:J,valueType:null,version:null,vAlign:null,vLink:null,vSpace:J,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:q,disablePictureInPicture:q,disableRemotePlayback:q,exportParts:mo,part:Y,prefix:null,property:null,results:J,security:null,unselectable:null},space:`html`,transform:Co}),To=bo({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:ho,accentHeight:J,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:J,amplitude:J,arabicForm:null,ascent:J,attributeName:null,attributeType:null,azimuth:J,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:J,by:null,calcMode:null,capHeight:J,className:Y,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:J,diffuseConstant:J,direction:null,display:null,dur:null,divisor:J,dominantBaseline:null,download:q,dx:null,dy:null,edgeMode:null,editable:null,elevation:J,enableBackground:null,end:null,event:null,exponent:J,externalResourcesRequired:null,fill:null,fillOpacity:J,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:mo,g2:mo,glyphName:mo,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:J,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:J,horizOriginX:J,horizOriginY:J,id:null,ideographic:J,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:J,k:J,k1:J,k2:J,k3:J,k4:J,kernelMatrix:ho,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:J,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:J,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:J,overlineThickness:J,paintOrder:null,panose1:null,path:null,pathLength:J,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Y,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:J,pointsAtY:J,pointsAtZ:J,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ho,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ho,rev:ho,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ho,requiredFeatures:ho,requiredFonts:ho,requiredFormats:ho,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:J,specularExponent:J,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:J,strikethroughThickness:J,string:null,stroke:null,strokeDashArray:ho,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:J,strokeOpacity:J,strokeWidth:null,style:null,surfaceScale:J,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ho,tabIndex:J,tableValues:null,target:null,targetX:J,targetY:J,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ho,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:J,underlineThickness:J,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:J,values:null,vAlphabetic:J,vMathematical:J,vectorEffect:null,vHanging:J,vIdeographic:J,version:null,vertAdvY:J,vertOriginX:J,vertOriginY:J,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:J,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:So}),Eo=bo({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),Do=bo({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Co}),Oo=bo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),ko={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},Ao=/[A-Z]/g,jo=/-[a-z]/g,Mo=/^data[-\w.:]+$/i;function No(e,t){let n=so(t),r=t,i=co;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Mo.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(jo,Fo);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!jo.test(e)){let n=e.replace(Ao,Po);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=vo}return new i(r,t)}function Po(e){return`-`+e.toLowerCase()}function Fo(e){return e.charAt(1).toUpperCase()}var Io=oo([xo,wo,Eo,Do,Oo],`html`),Lo=oo([xo,To,Eo,Do,Oo],`svg`);function Ro(e){return e.join(` `).trim()}var zo=/\/\*(?:[^*]|\*(?!\/))*\*\//g,Bo=/\n/g,Vo=/^\s*/,Ho=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Uo=/^:\s*/,Wo=/^((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|url\((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|[^)]*)\)|[^};])+)/,Go=/^[;\s]*/,Ko=`
|
|
4
4
|
`,qo=`/`,Jo=`*`,Yo=``,Xo=`comment`,Zo=`declaration`;function Qo(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var n=1,r=1;function i(e){var t=e.match(Bo);t&&(n+=t.length);var i=e.lastIndexOf(Ko);r=~i?e.length-i:r+e.length}function a(){var e={line:n,column:r};return function(t){return t.position=new o(e),l(),t}}function o(e){this.start=e,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function s(i){var a=Error(t.source+`:`+n+`:`+r+`: `+i);if(a.reason=i,a.filename=t.source,a.line=n,a.column=r,a.source=e,!t.silent)throw a}function c(t){var n=t.exec(e);if(n){var r=n[0];return i(r),e=e.slice(r.length),n}}function l(){c(Vo)}function u(e){for(var t;t=d();)e.push(t);return e}function d(){var t=a();if(qo==e.charAt(0)&&Jo==e.charAt(1)){for(var n=2;Yo!=e.charAt(n)&&(Jo!=e.charAt(n)||qo!=e.charAt(n+1));)++n;if(n+=2,Yo===e.charAt(n-1))return s(`End of comment missing`);var o=e.slice(2,n-2);return r+=2,i(o),e=e.slice(n),r+=2,t({type:Xo,comment:o})}}function f(){var e=a(),t=c(Ho);if(t){if(d(),!c(Uo))return s(`property missing ':'`);var n=c(Wo),r=e({type:Zo,property:t[0].replace(zo,Yo).trim(),value:n?n[0].replace(zo,Yo).trim():Yo});return c(Go),r}}function p(){var e=[];u(e);for(var t;t=f();)e.push(t),u(e);return e}return l(),p()}function $o(e,t){let n=null;if(!e||typeof e!=`string`)return n;let r=Qo(e),i=typeof t==`function`;return r.forEach(e=>{if(e.type!==`declaration`)return;let{property:r,value:a}=e;i?t(r,a,e):a&&(n??={},n[r]=a)}),n}var es=ns(`end`),ts=ns(`start`);function ns(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function rs(e){let t=ts(e),n=es(e);if(t&&n)return{start:t,end:n}}function is(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?os(e.position):`start`in e||`end`in e?os(e):`line`in e||`column`in e?as(e):``}function as(e){return ss(e&&e.line)+`:`+ss(e&&e.column)}function os(e){return as(e&&e.start)+`-`+as(e&&e.end)}function ss(e){return e&&typeof e==`number`?e:1}var cs=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=is(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Object.defineProperties(cs.prototype,{file:{configurable:!0,enumerable:!0,value:``,writable:!0},name:{configurable:!0,enumerable:!0,value:``,writable:!0},reason:{configurable:!0,enumerable:!0,value:``,writable:!0},message:{configurable:!0,enumerable:!0,value:``,writable:!0},stack:{configurable:!0,enumerable:!0,value:``,writable:!0},column:{configurable:!0,enumerable:!0,writable:!0},line:{configurable:!0,enumerable:!0,writable:!0},ancestors:{configurable:!0,enumerable:!0,writable:!0},cause:{configurable:!0,enumerable:!0,writable:!0},fatal:{configurable:!0,enumerable:!0,writable:!0},place:{configurable:!0,enumerable:!0,writable:!0},ruleId:{configurable:!0,enumerable:!0,writable:!0},source:{configurable:!0,enumerable:!0,writable:!0}});var ls={}.hasOwnProperty,us=new Map,ds=/[A-Z]/g,fs=/-([a-z])/g,ps=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),ms=new Set([`td`,`th`]),hs=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function gs(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=Ds(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Es(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?Lo:Io,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=_s(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function _s(e,t,n){if(t.type===`element`)return vs(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return ys(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return xs(e,t,n);if(t.type===`mdxjsEsm`)return bs(e,t);if(t.type===`root`)return Ss(e,t,n);if(t.type===`text`)return Cs(e,t)}function vs(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Lo,e.schema=i),e.ancestors.push(t);let a=Ns(e,t.tagName,!1),o=Os(e,t),s=As(e,t);return ps.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!ro(e)})),ws(e,o,a,t),Ts(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function ys(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Ps(e,t.position)}function bs(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ps(e,t.position)}function xs(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Lo,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:Ns(e,t.name,!0),o=ks(e,t),s=As(e,t);return ws(e,o,a,t),Ts(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Ss(e,t,n){let r={};return Ts(r,As(e,t)),e.create(t,e.Fragment,r,n)}function Cs(e,t){return t.value}function ws(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Ts(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Es(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function Ds(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=ts(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Os(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&ls.call(t.properties,i)){let a=js(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&ms.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function ks(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else Ps(e,t.position)}else{let{name:i}=r,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else Ps(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function As(e,t){let n=[],r=-1,i=e.passKeys?new Map:us;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=_s(e,a,o);s!==void 0&&n.push(s)}return n}function js(e,t,n){if(n==null||typeof n==`number`&&Number.isNaN(n))return;let r=No(e.schema,t);return Array.isArray(n)&&(n=r.commaSeparated?Za(n):Ro(n)),r.property===`style`?[`style`,typeof n==`object`?e.stylePropertyNameCase===`dom`?n:Fs(n):Ms(e,String(n))]:[e.elementAttributeNameCase===`react`&&r.space?ko[r.property]||r.property:r.attribute,n]}function Ms(e,t){let n={};try{$o(t,function(t,r){if(t&&r){let i=t;i.slice(0,2)!==`--`&&(i=i.toLowerCase(),e.stylePropertyNameCase===`dom`&&(i.slice(0,4)===`-ms-`&&(i=i.slice(1)),i=i.replace(fs,Rs))),n[i]=r}})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new cs("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=hs+`#cannot-parse-style-attribute`,r}return n}function Ns(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=to(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=to(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return ls.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Ps(e)}function Ps(e,t){let n=new cs("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=hs+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function Fs(e){let t={},n;for(n in e)ls.call(e,n)&&(t[Is(n)]=e[n]);return t}function Is(e){if(e.slice(0,2)===`--`)return e;let t=e.replace(ds,Ls);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function Ls(e){return`-`+e.toLowerCase()}function Rs(e,t){return t.toUpperCase()}var zs={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},Bs={};function Vs(e,t){let n=t||Bs;return Hs(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function Hs(e,t,n){if(Ws(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return Us(e.children,t,n)}return Array.isArray(e)?Us(e,t,n):``}function Us(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=Hs(e[i],t,n);return r.join(``)}function Ws(e){return!!(e&&typeof e==`object`)}var Gs=document.createElement(`i`);function Ks(e){let t=`&`+e+`;`;Gs.innerHTML=t;let n=Gs.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function qs(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Js(e,t){return e.length>0?(qs(e,e.length,0,t),e):t}var Ys={}.hasOwnProperty;function Xs(e){let t={},n=-1;for(;++n<e.length;)Zs(t,e[n]);return t}function Zs(e,t){let n;for(n in t){let r=(Ys.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){Ys.call(r,a)||(r[a]=[]);let e=i[a];Qs(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Qs(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);qs(e,0,0,r)}function $s(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function ec(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var tc=uc(/[A-Za-z]/),nc=uc(/[\dA-Za-z]/),rc=uc(/[#-'*+\--9=?A-Z^-~]/);function ic(e){return e!==null&&(e<32||e===127)}var ac=uc(/\d/),oc=uc(/[\dA-Fa-f]/),sc=uc(/[!-/:-@[-`{-~]/);function X(e){return e!==null&&e<-2}function Z(e){return e!==null&&(e<0||e===32)}function Q(e){return e===-2||e===-1||e===32}var cc=uc(/\p{P}|\p{S}/u),lc=uc(/\s/);function uc(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function dc(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&nc(e.charCodeAt(n+1))&&nc(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function $(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Q(r)?(e.enter(n),s(r)):t(r)}function s(r){return Q(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function fc(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&Q(t)?(e.enter(r),c(t)):l(t)}function c(t){return Q(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var pc={tokenize:mc};function mc(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null)e.consume(n);else return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),$(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null)e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);else return X(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var hc=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){gc(this,e,t,n,!1)}addBefore(e,t,n){gc(this,e,t,n,!0)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function gc(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var _c={tokenize:yc},vc={tokenize:bc};function yc(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;let c=new hc;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(vc,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(vc,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null)i&&v(),_(0),e.consume(n);else return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null)g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);else return X(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;let l=new hc;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function bc(e,t,n){return $(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function xc(e){if(e===null||Z(e)||lc(e))return 1;if(cc(e))return 2}function Sc(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var Cc={name:`attention`,resolveAll:wc,tokenize:Tc};function wc(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o={...e[i][1].end},s={...e[n][1].start};Ec(o,-a),Ec(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:{...e[i][1].end}},l={type:a>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:s},u={type:a>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[n][1].start}},d={type:a>1?`strong`:`emphasis`,start:{...c.start},end:{...l.end}};e[i][1].end={...c.start},e[n][1].start={...l.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=Js(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=Js(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=Js(r,Sc(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=Js(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=Js(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),qs(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Tc(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=xc(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=xc(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Ec(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Dc={name:`autolink`,tokenize:Oc};function Oc(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return tc(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||nc(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||nc(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||ic(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):rc(t)?(e.consume(t),l):n(t)}function u(e){return nc(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||nc(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var kc={partial:!0,tokenize:Ac};function Ac(e,t,n){return r;function r(t){return Q(t)?$(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||X(e)?t(e):n(e)}}var jc={continuation:{tokenize:Nc},exit:Pc,name:`blockQuote`,tokenize:Mc};function Mc(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Q(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Nc(e,t,n){let r=this;return i;function i(t){return Q(t)?$(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(jc,t,n)(r)}}function Pc(e){e.exit(`blockQuote`)}var Fc={name:`characterEscape`,tokenize:Ic};function Ic(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return sc(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var Lc={name:`characterReference`,tokenize:Rc};function Rc(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=nc,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=oc,u):(e.enter(`characterReferenceValue`),a=7,o=ac,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===nc&&!Ks(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var zc={partial:!0,tokenize:Bc};function Bc(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var Vc={concrete:!0,name:`codeFenced`,tokenize:Hc};function Hc(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Q(t)?$(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||X(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(zc,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||X(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),$(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||X(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||X(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Q(t)?$(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||X(t)?e.check(zc,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||X(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Q(t)?$(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Q(t)?$(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||X(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var Uc={name:`codeIndented`,tokenize:Gc},Wc={partial:!0,tokenize:Kc};function Gc(e,t,n){return r;function r(t){return e.enter(`codeIndented`),fc(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):X(t)?e.attempt(Wc,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||X(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function Kc(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):X(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):fc(e,t,a,`linePrefix`,4,4)(o)}function a(e){return X(e)?i(e):n(e)}}var qc={name:`codeText`,previous:Yc,resolve:Jc,tokenize:Xc};function Jc(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Yc(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function Xc(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):X(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||X(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var Zc=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&Qc(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Qc(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Qc(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);Qc(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Qc(this.left,t.reverse())}}}};function Qc(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function $c(e){let t={},n=-1,r,i,a,o,s,c,l,u=new Zc(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,el(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return qs(e,0,1/0,u.slice(0)),!l}function el(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var tl={resolve:rl,tokenize:il},nl={partial:!0,tokenize:al};function rl(e){return $c(e),e}function il(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):X(t)?e.check(nl,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function al(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),$(e,a,`linePrefix`)}function a(i){if(i===null||X(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function ol(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||ic(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||X(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||Z(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||ic(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function sl(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):X(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||X(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!Q(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function cl(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):X(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),$(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||X(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function ll(e,t){let n;return r;function r(i){return X(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Q(i)?$(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var ul={name:`definition`,tokenize:fl},dl={partial:!0,tokenize:pl};function fl(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return sl.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=ec(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return Z(t)?ll(e,l)(t):l(t)}function l(t){return ol(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(dl,d,d)(t)}function d(t){return Q(t)?$(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||X(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function pl(e,t,n){return r;function r(t){return Z(t)?ll(e,i)(t):n(t)}function i(t){return cl(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Q(t)?$(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||X(e)?t(e):n(e)}}var ml={name:`hardBreakEscape`,tokenize:hl};function hl(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return X(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var gl={name:`headingAtx`,resolve:_l,tokenize:vl};function _l(e,t){let n=e.length-2,r=3;if(e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r){let i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`};qs(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function vl(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||Z(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||X(n)?(e.exit(`atxHeading`),t(n)):Q(n)?$(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||Z(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var yl=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),bl=[`pre`,`script`,`style`,`textarea`],xl={concrete:!0,name:`htmlFlow`,resolveTo:Cl,tokenize:wl},Sl={partial:!0,tokenize:Tl};function Cl(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function wl(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:te):tc(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):tc(a)?(e.consume(a),i=4,r.interrupt?t:te):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:te):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return tc(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||Z(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&bl.includes(l)?(i=1,r.interrupt?t(s):O(s)):yl.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||nc(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return Q(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||tc(t)?(e.consume(t),b):Q(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||nc(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Q(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Q(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||X(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||Z(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Q(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||X(t)?O(t):Q(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),j):t===60&&i===1?(e.consume(t),M):t===62&&i===4?(e.consume(t),F):t===63&&i===3?(e.consume(t),te):t===93&&i===5?(e.consume(t),P):X(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Sl,I,k)(t)):t===null||X(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(zc,A,I)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ee}function ee(t){return t===null||X(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function j(t){return t===45?(e.consume(t),te):O(t)}function M(t){return t===47?(e.consume(t),o=``,N):O(t)}function N(t){if(t===62){let n=o.toLowerCase();return bl.includes(n)?(e.consume(t),F):O(t)}return tc(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),N):O(t)}function P(t){return t===93?(e.consume(t),te):O(t)}function te(t){return t===62?(e.consume(t),F):t===45&&i===2?(e.consume(t),te):O(t)}function F(t){return t===null||X(t)?(e.exit(`htmlFlowData`),I(t)):(e.consume(t),F)}function I(n){return e.exit(`htmlFlow`),t(n)}}function Tl(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(kc,t,n)}}var El={name:`htmlText`,tokenize:Dl};function Dl(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):tc(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):tc(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):X(t)?(o=d,M(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?j(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):X(t)?(o=h,M(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?j(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?j(t):X(t)?(o=v,M(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):X(t)?(o=y,M(t)):(e.consume(t),y)}function b(e){return e===62?j(e):y(e)}function x(t){return tc(t)?(e.consume(t),S):n(t)}function S(t){return t===45||nc(t)?(e.consume(t),S):C(t)}function C(t){return X(t)?(o=C,M(t)):Q(t)?(e.consume(t),C):j(t)}function w(t){return t===45||nc(t)?(e.consume(t),w):t===47||t===62||Z(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),j):t===58||t===95||tc(t)?(e.consume(t),E):X(t)?(o=T,M(t)):Q(t)?(e.consume(t),T):j(t)}function E(t){return t===45||t===46||t===58||t===95||nc(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):X(t)?(o=D,M(t)):Q(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):X(t)?(o=O,M(t)):Q(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,ee):t===null?n(t):X(t)?(o=k,M(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||Z(t)?T(t):(e.consume(t),A)}function ee(e){return e===47||e===62||Z(e)?T(e):n(e)}function j(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function M(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),N}function N(t){return Q(t)?$(e,P,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):P(t)}function P(t){return e.enter(`htmlTextData`),o(t)}}var Ol={name:`labelEnd`,resolveAll:Ml,resolveTo:Nl,tokenize:Pl},kl={tokenize:Fl},Al={tokenize:Il},jl={tokenize:Ll};function Ml(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&qs(e,0,e.length,n),e}function Nl(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:`label`,start:{...e[i][1].start},end:{...e[a][1].end}},l={type:`labelText`,start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[[`enter`,s,t],[`enter`,c,t]],o=Js(o,e.slice(i+1,i+r+3)),o=Js(o,[[`enter`,l,t]]),o=Js(o,Sc(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=Js(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=Js(o,e.slice(a+1)),o=Js(o,[[`exit`,s,t]]),qs(e,i,e.length,o),e}function Pl(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(ec(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(kl,u,o?u:d)(t):t===91?e.attempt(Al,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(jl,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function Fl(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return Z(t)?ll(e,a)(t):a(t)}function a(t){return t===41?u(t):ol(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return Z(t)?ll(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?cl(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return Z(t)?ll(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Il(e,t,n){let r=this;return i;function i(t){return sl.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(ec(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Ll(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var Rl={name:`labelStartImage`,resolveAll:Ol.resolveAll,tokenize:zl};function zl(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var Bl={name:`labelStartLink`,resolveAll:Ol.resolveAll,tokenize:Vl};function Vl(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var Hl={name:`lineEnding`,tokenize:Ul};function Ul(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),$(e,t,`linePrefix`)}}var Wl={name:`thematicBreak`,tokenize:Gl};function Gl(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||X(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Q(t)?$(e,s,`whitespace`)(t):s(t))}}var Kl={continuation:{tokenize:Xl},exit:Ql,name:`list`,tokenize:Yl},ql={partial:!0,tokenize:$l},Jl={partial:!0,tokenize:Zl};function Yl(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:ac(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(Wl,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return ac(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(kc,r.interrupt?n:u,e.attempt(ql,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Q(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function Xl(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(kc,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,$(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Q(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Jl,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,$(e,e.attempt(Kl,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function Zl(e,t,n){let r=this;return $(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function Ql(e){e.exit(this.containerState.type)}function $l(e,t,n){let r=this;return $(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Q(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var eu={name:`setextUnderline`,resolveTo:tu,tokenize:nu};function tu(e,t){let n=new hc,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end={...e[o][1].end}):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function nu(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Q(t)?$(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||X(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var ru={tokenize:iu};function iu(e){let t=this,n=e.attempt(kc,r,e.attempt(this.parser.constructs.flowInitial,i,$(e,e.attempt(this.parser.constructs.flow,i,e.attempt(tl,i)),`linePrefix`)));return n;function r(r){if(r===null)e.consume(r);else return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null)e.consume(r);else return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var au={resolveAll:lu()},ou=cu(`string`),su=cu(`text`);function cu(e){return{resolveAll:lu(e===`text`?uu:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null)t.consume(e);else return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function lu(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):t[r]&&t[r][1].type===`data`||(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function uu(e,t){let n=new hc,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var du=e({attentionMarkers:()=>yu,contentInitial:()=>pu,disable:()=>bu,document:()=>fu,flow:()=>hu,flowInitial:()=>mu,insideSpan:()=>vu,string:()=>gu,text:()=>_u}),fu={42:Kl,43:Kl,45:Kl,48:Kl,49:Kl,50:Kl,51:Kl,52:Kl,53:Kl,54:Kl,55:Kl,56:Kl,57:Kl,62:jc},pu={91:ul},mu={[-2]:Uc,[-1]:Uc,32:Uc},hu={35:gl,42:Wl,45:[eu,Wl],60:xl,61:eu,95:Wl,96:Vc,126:Vc},gu={38:Lc,92:Fc},_u={[-5]:Hl,[-4]:Hl,[-3]:Hl,33:Rl,38:Lc,42:Cc,60:[Dc,El],91:Bl,92:[ml,Fc],93:Ol,95:Cc,96:qc},vu={null:[Cc,au]},yu={null:[42,95]},bu={null:[]};function xu(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=Js(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Sc(a,l.events,l),l.events):[]}function f(e,t){return Cu(p(e),t)}function p(e){return Su(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){X(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&qs(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Su(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Cu(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
@@ -41,7 +41,7 @@ import{n as e,r as t,t as n}from"./rolldown-runtime-XKyaHtl9.js";import{A as r,C
|
|
|
41
41
|
`),Pw=(e,t)=>[`I stopped your headless run and took this session over in my terminal. Carry on answering the review of ${t} in ${e}, as before:`,...Mw(e),`Keep listening until I say the review is done. Do not push or open pull requests unless I ask.`].join(`
|
|
42
42
|
`),Fw=({resume:e,interactive:t,worktree:n,branch:r})=>e===null?Iw(t,n,r):`cd ${jw(n)} && ${e} ${jw(Pw(n,r))}`,Iw=(e,t,n)=>`cd ${jw(t)} && ${e} ${jw(Nw(t,n))}`,Lw=G.createContext(void 0);function Rw(e){let t=G.useContext(Lw);if(t===void 0&&!e)throw Error(R(33));return t}var zw=G.createContext(void 0);function Bw(e){let t=G.useContext(zw);if(t===void 0&&!e)throw Error(R(36));return t}var Vw=G.createContext(void 0);function Hw(e=!0){let t=G.useContext(Vw);if(t===void 0&&!e)throw Error(R(25));return t}function Uw(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:l}=a.useState(`floatingTreeRoot`),u=a.useState(`open`),d=Hw(!0),f=d!==void 0;return G.useMemo(()=>({id:r,role:`menuitem`,tabIndex:u&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&l.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&l.emit(`close`,{domEvent:e,reason:Ee})},onMouseUp(e){if(d){let t=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,f&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||f&&!Pt&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&yt(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}var Ww={type:`regular-item`};function Gw(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=G.useRef(null),{getButtonProps:d,buttonRef:f}=P({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Uw({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=G.useCallback(e=>ge(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=xt(u,f);return G.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Kw=G.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=ny({guess:!0,label:a}),f=Rw(!0),p=Bt(i),{store:m}=Bw(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Gw({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:Ww});return L(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),qw=G.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=Bw(),{side:c,align:l}=Rw(),u=db(!0)!=null,d=s.useState(`open`),f=s.useState(`transitionStatus`),p=s.useState(`popupProps`),m=s.useState(`mounted`),h=s.useState(`instantType`),g=s.useState(`activeTriggerElement`),_=s.useState(`parent`),v=s.useState(`lastOpenChangeReason`),y=s.useState(`rootId`),b=s.useState(`floatingRootContext`),x=s.useState(`floatingTreeRoot`),S=s.useState(`closeDelay`),C=s.useState(`hoverEnabled`),w=s.useState(`disabled`),T=s.useState(`openMethod`),E=_.type===`context-menu`;bt({open:d,ref:s.context.popupRef,onComplete(){d&&s.context.onOpenChangeComplete?.(!0)}}),G.useEffect(()=>{function e(e){s.setOpen(!1,en(e.reason,e.domEvent))}return x.events.on(`close`,e),()=>{x.events.off(`close`,e)}},[x.events,s]),Kt(b,{enabled:C&&!w&&!E&&_.type!==`menubar`,closeDelay:S});let D=s.useStateSetter(`popupElement`),O={transitionStatus:f,side:c,align:l,open:d,nested:_.type===`menu`,instant:h},k=L(`div`,e,{state:O,ref:[t,s.context.popupRef,D],stateAttributesMapping:Re,props:[p,{onKeyDown(e){u&&Ng.has(e.key)&&e.stopPropagation()}},Lt(f),o,{"data-rootownerid":y}]}),A=_.type===void 0||E;return(g||_.type===`menubar`&&v!==`outside-press`)&&(A=!0),(0,K.jsx)(ua,{context:b,openInteractionType:T,modal:E,disabled:!m,returnFocus:a===void 0?A:a,initialFocus:_.type!==`menu`,restoreFocus:!0,externalTree:_.type===`menubar`?void 0:x,previousFocusableElement:g,nextFocusableElement:_.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:_.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:k})}),Jw=G.createContext(void 0);function Yw(){let e=G.useContext(Jw);if(e===void 0)throw Error(R(32));return e}var Xw=G.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=Bw();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,K.jsx)(Jw.Provider,{value:n,children:(0,K.jsx)(fe,{ref:t,...r,portalOwnerRole:o})})}),Zw=G.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=ve,style:g,..._}=e,{store:v}=Bw(),y=Yw(),b=Hw(!0),x=v.useState(`parent`),S=v.useState(`floatingRootContext`),C=v.useState(`floatingTreeRoot`),w=v.useState(`mounted`),T=v.useState(`open`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`activeTriggerElement`),k=v.useState(`transitionStatus`),A=v.useState(`positionerElement`),ee=v.useState(`instantType`),j=v.useState(`adaptiveOrigin`),M=v.useState(`lastOpenChangeReason`),P=v.useState(`floatingNodeId`),te=v.useState(`floatingParentNodeId`),F=S.useState(`domReferenceElement`),I=G.useRef(null),L=N(A),ne=n,re=c,ie=l,ae=s,oe=h;x.type===`context-menu`&&(ne=n??x.context?.anchor,ae??=`start`,!o&&ae!==`center`&&(ie=e.alignOffset??2,re=e.sideOffset??-5));let se=o,ce=ae;x.type===`menu`?(se??=`inline-end`,ce??=`start`,oe=e.collisionAvoidance??_e):x.type===`menubar`&&(se??=x.context.orientation===`vertical`?`inline-end`:`bottom`,ce??=`start`);let le=x.type===`context-menu`,R=_t({anchor:ne,floatingRootContext:S,positionMethod:b?`fixed`:r,mounted:w,side:se,sideOffset:re,align:ce,alignOffset:ie,arrowPadding:le?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:P,keepMounted:y,disableAnchorTracking:m,collisionAvoidance:oe,shift:le?{crossAxis:!(`side`in oe&&oe.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:C,adaptiveOrigin:j});G.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===P&&v.set(`hoverEnabled`,!1),e.nodeId!==P&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,en(Ce)))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[v,C.events,P]),G.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,en(t))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[C.events,v]);let ue=gt();G.useEffect(()=>{T||ue.clear()},[T,ue]),G.useEffect(()=>{function e(e){if(T&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&O&&O!==e.target){let e=v.select(`closeDelay`);e>0?ue.isStarted()||ue.start(e,()=>{v.setOpen(!1,en(Ce))}):v.setOpen(!1,en(Ce))}else ue.clear()}}return C.events.on(`itemhover`,e),()=>{C.events.off(`itemhover`,e)}},[C.events,T,O,v,ue]),G.useEffect(()=>{let e={open:T,nodeId:P,parentNodeId:te,reason:v.select(`lastOpenChangeReason`)};C.events.emit(`menuopenchange`,e)},[C.events,T,v,P,te]),B(()=>{let e=F,t=I.current;if(e&&(I.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return L(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[F,L,v]);let de={open:T,side:R.side,align:R.align,anchorHidden:R.anchorHidden,nested:x.type===`menu`,instant:ee},fe=x.type===`menubar`&&x.context.modal;cb(T&&(fe||E&&M!==`trigger-hover`),D===`touch`,A,O);let pe=Ot(e,de,{styles:R.positionerStyles,transitionStatus:k,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!w,inert:!T}),me=w&&x.type!==`menu`&&(x.type!==`menubar`&&E&&M!==`trigger-hover`||x.type===`menubar`&&x.context.modal),ge=null;return x.type===`menubar`?ge=x.context.contentElement:x.type===void 0&&(ge=O),(0,K.jsxs)(Lw.Provider,{value:R,children:[me&&(0,K.jsx)(Gg,{ref:x.type===`context-menu`||x.type===`nested-context-menu`?x.context.internalBackdropRef:null,inert:Tn(!T),cutout:ge}),(0,K.jsx)(he,{id:P,children:(0,K.jsx)(ay,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,children:pe})})]})}),Qw=G.createContext(null);function $w(e){let t=G.useContext(Qw);if(t===null&&!e)throw Error(R(5));return t}var eT={...ht,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},tT=class extends we{constructor(e,t,n=!1){let r=new pt,i=rT(r,t,n,e);super(i,nT(r),eT),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef}else e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function nT(e){return{positionerRef:G.createRef(),popupRef:G.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:G.createRef(),beforeContentFocusGuardRef:G.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function rT(e,t,n=!1,r){return{...Et(e,t,n),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new ze,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:se,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var iT=G.createContext(void 0);function aT(){return G.useContext(iT)}var oT=Ye(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:l=`vertical`,actionsRef:u,closeParentOnEsc:d=!1,handle:f,triggerId:p,defaultTriggerId:m=null,highlightItemOnHover:h=!0}=e,g=Hw(!0),_=Bw(!0),v=$w(!0),y=aT(),b=G.useMemo(()=>y&&_?{type:`menu`,store:_.store}:v?{type:`menubar`,context:v}:g&&!_?{type:`context-menu`,context:g}:{type:void 0},[g,_,v,y]),x=Ge(),S=Ge(),C=rn(),w=b.type===`menu`?b.store:void 0,T=(n??a)&&w?.state.transitionStatus===`starting`,E=an(()=>T?w?.state.instantType:void 0).current,D=sT({open:a,openProp:n,activeTriggerId:m,triggerIdProp:p,parent:b,disabled:o,highlightItemOnHover:h,modal:b.type===void 0?s:void 0,rootId:x,instantType:E},S,C!=null);D.useControlledProp(`openProp`,n),D.useControlledProp(`triggerIdProp`,p),D.useContextCallback(`onOpenChangeComplete`,i);let O=D.useState(`floatingTreeRoot`),k=je(O),A=D.useState(`open`),ee=D.useState(`activeTriggerElement`),j=D.useState(`positionerElement`),M=D.useState(`hoverEnabled`),P=D.useState(`disabled`),te=D.useState(`lastOpenChangeReason`),F=D.useState(`parent`),L=D.useState(`activeIndex`),ne=D.useState(`payload`),re=D.useState(`floatingParentNodeId`),ie=G.useRef(null),oe=G.useRef(F.type!==`context-menu`),ce=gt(),le=G.useRef(!0),R=gt(),ue=re!=null,{openMethod:de,triggerProps:fe}=h_(A);D.useSyncedValues({disabled:o,highlightItemOnHover:h,modal:F.type===void 0?s:void 0,openMethod:de,rootId:x}),I(D);let{forceUnmount:pe,transitionStatus:me}=Qt(A,D,()=>{D.set(`allowMouseEnter`,!1)},T),he=N(D.context.popupRef);G.useEffect(()=>{if(E===void 0)return;let e=()=>{D.state.instantType===E&&D.set(`instantType`,void 0)};if(!A){e();return}if(me!==void 0)return;if(D.context.popupRef.current==null){e();return}let t=new AbortController;return he(e,t.signal),()=>{t.abort()}},[E,A,me,he,D]),B(()=>{g&&!_?D.update({parent:{type:`context-menu`,context:g},floatingNodeId:k,floatingParentNodeId:C}):_&&D.update({floatingNodeId:k,floatingParentNodeId:C})},[g,_,k,C,D]),G.useEffect(()=>{A||(ie.current=null),F.type===`context-menu`&&(A?ce.start(500,()=>{oe.current=!0}):(ce.clear(),oe.current=!1))},[ce,A,F.type]),B(()=>{!A&&!M&&D.set(`hoverEnabled`,!0)},[A,M,D]);let _e=H((e,t)=>{let n=t.reason;if(!e&&!D.select(`open`)||A===e&&t.trigger===ee&&te===n)return;let i=et(t);if(!e&&t.trigger==null&&(t.trigger=ee??void 0),r?.(e,t),t.isCanceled)return;D.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!le.current)return;e&&n===`trigger-focus`?(le.current=!1,R.start(300,()=>{le.current=!0})):(le.current=!0,R.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null);ie.current=t.event;let c=Ne(D.state,e,t.trigger,i());c.openChangeReason=n,c.instantType=F.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:o||s?o?`click`:`dismiss`:void 0,D.update(c)}),z=Se({popupStore:D,floatingRootContext:D.state.floatingRootContext,floatingId:S,nested:C!=null,onOpenChange:_e}),ve=z.context.events;B(()=>{let e=({open:e,eventDetails:t})=>_e(e,t);return ve.on(`setOpen`,e),()=>{ve?.off(`setOpen`,e)}},[ve,_e]);let ye=G.useCallback(()=>{D.setOpen(!1,en(ae))},[D]);G.useImperativeHandle(u,()=>({unmount:pe,close:ye}),[pe,ye]);let xe;F.type===`context-menu`&&(xe=F.context),G.useImperativeHandle(xe?.positionerRef,()=>j,[j]),G.useImperativeHandle(xe?.actionsRef,()=>({setOpen:_e}),[_e]);let V=De(z,{enabled:!P,bubbles:{escapeKey:d&&F.type===`menu`},outsidePress(){return F.type!==`context-menu`||ie.current?.type===`contextmenu`||oe.current},externalTree:ue?O:void 0}),Ce=Ze(),we=G.useCallback(e=>{D.select(`activeIndex`)!==e&&D.set(`activeIndex`,e)},[D]),Te=ya(z,{enabled:!P,listRef:D.context.itemDomElements,activeIndex:L,nested:F.type!==void 0,loopFocus:c,orientation:l,parentOrientation:F.type===`menubar`?F.context.orientation:void 0,rtl:Ce===`rtl`,disabledIndices:Ie,onNavigate:we,openOnArrowKeyDown:F.type!==`context-menu`,externalTree:ue?O:void 0,focusItemOnHover:h}),Ee=G.useCallback(e=>{D.context.typingRef.current=e},[D]),Oe=ba(z,{enabled:!P,listRef:D.context.itemLabels,elementsRef:D.context.itemDomElements,activeIndex:L,resetMs:500,onMatch:e=>{A&&e!==L&&D.set(`activeIndex`,e)},onTyping:Ee}),ke=G.useMemo(()=>{let e=ge(Oe.reference,Te.reference,V.reference,{onMouseMove(){D.set(`allowMouseEnter`,!0)}},fe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=A,e},[D,Oe.reference,Te.reference,V.reference,fe,A]),Ae=G.useMemo(()=>{let e=ge(Te.trigger,V.trigger,fe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Te.trigger,V.trigger,fe]);an(()=>(D.update({inactiveTriggerProps:Ae}),null));let Me=G.useMemo(()=>ge(Je,{id:S,role:`menu`,"aria-orientation":l===`horizontal`?`horizontal`:void 0,"aria-labelledby":ee?.id,onMouseMove(){D.set(`allowMouseEnter`,!0),F.type===`menu`&&D.set(`hoverEnabled`,!1)},onClick(){D.select(`hoverEnabled`)&&D.set(`hoverEnabled`,!1)},onKeyDown(e){let t=D.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Oe.floating,Te.floating,V.floating),[ee,S,l,F.type,D,Oe.floating,Te.floating,V.floating]),Pe=Te.item??se;Fe(D,{floatingRootContext:z,activeTriggerProps:ke,inactiveTriggerProps:Ae,popupProps:Me,itemProps:Pe});let Le=G.useMemo(()=>({store:D,parent:b}),[D,b]),Re=(0,K.jsxs)(zw.Provider,{value:Le,children:[f&&(0,K.jsx)(Yt,{handle:f,store:D}),typeof t==`function`?t({payload:ne}):t]});return F.type===void 0||F.type===`context-menu`?(0,K.jsx)(be,{externalTree:O,children:Re}):Re});function sT(e,t,n){return an(()=>new tT(e,t,n)).current}var cT=5;function lT(e,t){let n=uT(t);return e.clientX>=n.left-cT&&e.clientX<=n.right+cT&&e.clientY>=n.top-cT&&e.clientY<=n.bottom+cT}function uT(e){let t=e.getBoundingClientRect(),n=pe(e);if(qt)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function dT(e){if(Ve(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!de(e))return dT(Be(e))}function fT(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=G.useRef(!1);return G.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,V(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:se,[t,n,r])}var pT=Xt(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=Bw(!0),h=Nt(d)??m?.store;if(!h)throw Error(R(85));let g=Bt(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=G.useRef(null),S=hT(),C=Oe(!0),w=te(),T=G.useMemo(()=>w??new ze,[w]),E=je(T),D=rn(),{registerTrigger:O,isMountedByThisTrigger:k}=Te(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:E,floatingParentNodeId:D,keyboardEventRelay:C?.relayKeyboardEvent}),A=S.type===`menubar`,ee=h.useState(`disabled`),j=a||ee||A&&S.context.disabled,{getButtonProps:M,buttonRef:N}=P({disabled:j,native:o});G.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let F=G.useRef(null),I=gt(),ne=H(e=>{if(!F.current)return;I.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;U(F.current,t)||U(h.select(`positionerElement`),t)||t===F.current||t!=null&&dT(t)===h.select(`rootId`)||lT(e,F.current)||T.events.emit(`close`,{domEvent:e,reason:Pe})});G.useEffect(()=>{y&&h.select(`lastOpenChangeReason`)===`trigger-hover`&&V(F.current).addEventListener(`mouseup`,ne,{once:!0})},[y,ne,h]);let re=A&&S.context.hasSubmenuOpen,ie=Ct(v,{enabled:(c??re)&&!j&&(!A||re&&!k),handleClose:rt({blockPointerEvents:!A}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),ae=mT(y,h.select(`lastOpenChangeReason`)),oe=da(v,{enabled:!j,event:y&&A?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&ae}),ce=ut(v,{enabled:!j&&re}),le=fT({open:y,enabled:A,mouseDownAction:`open`}),ue=G.useMemo(()=>ge(ce.reference,oe.reference),[ce.reference,oe.reference]),de=h.useState(`triggerProps`,k),{preFocusGuardRef:fe,handlePreFocusGuardFocus:pe,handleFocusTargetFocus:me}=tb(h,x),he={disabled:j,open:y},_e=[F,t,N,O,x],z=[ue,ie??se,de,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(I.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),V(e.currentTarget).addEventListener(`mouseup`,ne,{once:!0}))}},A?{role:`menuitem`}:{},le,p,M],ve=L(`button`,e,{enabled:!A,stateAttributesMapping:He,state:he,ref:_e,props:z});return A?(0,K.jsx)(iy,{tag:`button`,render:n,className:r,style:i,state:he,refs:_e,props:z,stateAttributesMapping:He}):y?(0,K.jsxs)(G.Fragment,{children:[(0,K.jsx)(Ft,{ref:fe,onFocus:pe},`${g}-pre-focus-guard`),(0,K.jsx)(G.Fragment,{children:ve},g),(0,K.jsx)(Ft,{ref:h.context.triggerFocusTargetRef,onFocus:me},`${g}-post-focus-guard`)]}):(0,K.jsx)(G.Fragment,{children:ve},g)});function mT(e,t){let n=gt(),[r,i]=G.useState(!1);return B(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function hT(){let e=$w(!0);return G.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var gT=G.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return L(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function _T({...e}){return(0,K.jsx)(oT,{"data-slot":`dropdown-menu`,...e})}function vT({...e}){return(0,K.jsx)(pT,{"data-slot":`dropdown-menu-trigger`,...e})}function yT({className:e,align:t=`end`,sideOffset:n=6,...r}){return(0,K.jsx)(Xw,{children:(0,K.jsx)(Zw,{align:t,className:`isolate z-50`,sideOffset:n,children:(0,K.jsx)(qw,{className:W(`min-w-48 pop-menu rounded-lg border border-border bg-popover p-1 text-sm text-popover-foreground shadow-md outline-none`,e),"data-slot":`dropdown-menu-content`,...r})})})}function bT({className:e,...t}){return(0,K.jsx)(Kw,{className:W(`flex items-center gap-2 rounded-md px-2 py-1.5 transition-colors duration-150 ease-out outline-none select-none data-highlighted:bg-secondary data-highlighted:text-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground`,e),"data-slot":`dropdown-menu-item`,...t})}function xT({className:e,...t}){return(0,K.jsx)(gT,{className:W(`-mx-1 my-1 h-px bg-border`,e),"data-slot":`dropdown-menu-separator`,...t})}function ST({className:e,...t}){return(0,K.jsx)(`span`,{className:W(`ms-auto text-xs text-subtle`,e),"data-slot":`dropdown-menu-shortcut`,...t})}var CT=()=>{let e=qn();return async(t,n)=>{await navigator.clipboard.writeText(t),e.add({title:n})}},wT=async({model:e,copy:t})=>{let{listener:n,branch:r}=e,i=n?.run??null,a=n?.worktree??null,o=n?.agents.find(e=>e.label===i?.agent)??null;a!==null&&i!==null&&o!==null&&(await t(Fw({resume:i.resume,interactive:o.interactive,worktree:a,branch:r}),`Resume command copied · paste it in a terminal`),await e.handleStop())},TT=({model:e,copy:t})=>e.listener?.run?.state===`running`&&e.listener.worktree!==null?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(bT,{disabled:e.isBusy,onClick:()=>{wT({model:e,copy:t})},children:[(0,K.jsx)(ki,{}),`Take over in your terminal`]}),(0,K.jsx)(xT,{})]}):null,ET=e=>e.agents.find(t=>t.id===e.chosen)??null,DT=({model:e,isHeard:t,onSettings:n})=>{let r=CT(),{listener:i,isBusy:a,branch:o}=e;if(i===null)return null;let s=ET(i),c=i.agents.filter(e=>e.isInstalled&&e.id!==s?.id),{worktree:l}=i;return(0,K.jsxs)(_T,{children:[(0,K.jsx)(vT,{render:(0,K.jsx)(Dn,{"aria-label":`Agent options`,size:`icon-xs`,variant:`ghost`,children:(0,K.jsx)(sr,{})})}),(0,K.jsxs)(yT,{children:[(0,K.jsx)(TT,{copy:r,model:e}),t?null:c.map(t=>(0,K.jsxs)(bT,{disabled:a||l===null,onClick:()=>void e.handleStart(t.id),children:[(0,K.jsx)(di,{}),`Start a headless ${t.label}`]},t.id)),t||c.length===0?null:(0,K.jsx)(xT,{}),(0,K.jsxs)(bT,{disabled:l===null,onClick:()=>{l!==null&&r(Nw(l,o),`Prompt copied: paste it to your agent`)},children:[(0,K.jsx)(xr,{}),`Copy a prompt for your agent`]}),s===null?null:(0,K.jsxs)(bT,{disabled:l===null,onClick:()=>{l!==null&&r(Iw(s.interactive,l,o),`Command copied: paste it in a terminal to open ${s.label}`)},children:[(0,K.jsx)(ki,{}),`Copy a terminal command for ${s.label}`]}),(0,K.jsx)(xT,{}),(0,K.jsxs)(bT,{onClick:n,children:[(0,K.jsx)(yi,{}),`Agent settings…`]})]})]})},OT=e=>{let t=CT(),n=e.listener,{listener:r}=n,i=r?.worktree??null;if(r===null||i===null)return[];let a=ET(r),o=r.run?.state===`running`;return[{id:`start`,icon:Ci,label:`Start ${a?.label??`an agent`}`,note:`It reads your comments and answers them in the background`,isShown:!o&&!r.isListening&&a!==null,onPress:()=>{a!==null&&n.handleStart(a.id)}},{id:`take-over`,icon:ki,label:`Take over in your terminal`,note:`Copies a command that resumes its session, and stops it here`,isShown:o,onPress:()=>{wT({model:n,copy:t})}},{id:`stop`,icon:ji,label:`Stop ${r.run?.agent??`the agent`}`,isShown:o,onPress:()=>{n.handleStop()}},{id:`terminal`,icon:ki,label:`Copy a terminal command`,note:`Opens ${a?.label??`the agent`} in this worktree, already listening`,isShown:!o&&a!==null,onPress:()=>{a!==null&&t(Iw(a.interactive,i,n.branch),`Command copied · paste it in a terminal`)}}]},kT=`[data-review-diff]`,AT=`[data-review-row]`,jT=100,MT=()=>{let e=document.querySelector(kT);if(e===null)return null;let{top:t}=e.getBoundingClientRect(),n=[...e.querySelectorAll(AT)].find(e=>e.getBoundingClientRect().bottom>t);return n===void 0?null:{diff:e,row:n,at:n.getBoundingClientRect().top}},NT=e=>{let t=MT();Rn(e),t!==null&&(t.diff.scrollTop+=t.row.getBoundingClientRect().top-t.at),In({codeSize:e})},PT=()=>{let{codeSize:e}=Un();return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`label`,{className:`flex min-h-14 items-center gap-3 px-3.5`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Code size`}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:`w-4 text-center text-xs text-muted-foreground`,children:`A`}),(0,K.jsx)(`input`,{"aria-valuetext":`${String(e)} pixels`,className:`code-size-range min-w-0 flex-1`,max:Nn.max,min:Nn.min,ref:t=>{let n=(e-Nn.min)/(Nn.max-Nn.min);t?.style.setProperty(`--fill`,`${String(n*jT)}%`)},onChange:e=>{NT(Number(e.currentTarget.value))},step:1,type:`range`,value:e}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:`w-4 text-center text-lg text-muted-foreground`,children:`A`})]})})},FT=({isOn:e})=>(0,K.jsx)(`span`,{"aria-hidden":!0,className:`relative h-7 w-16 shrink-0 rounded-full bg-foreground/16 transition-colors duration-200 data-on:bg-sign-add`,"data-on":e?``:void 0,children:(0,K.jsx)(`span`,{className:`absolute inset-s-0.5 top-0.5 h-6 w-9.5 switch-thumb rounded-full bg-white shadow-sm`})}),IT=({action:e})=>{let t=e.icon,n=e.isOn!==void 0;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"aria-checked":n?e.isOn:void 0,className:`flex min-h-13 w-full items-center gap-3 px-3.5 py-1.5 text-start text-base/5 text-foreground transition-colors duration-150 active:bg-foreground/8`,onClick:()=>{e.onPress()},role:n?`switch`:void 0,type:`button`,children:[(0,K.jsx)(`span`,{className:`grid size-7.5 shrink-0 place-items-center rounded-lg bg-foreground/9`,children:(0,K.jsx)(t,{className:`size-4.5`})}),(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,K.jsx)(`span`,{children:e.label}),e.note===void 0?null:(0,K.jsx)(`span`,{className:`text-ui text-muted-foreground`,children:e.note})]}),e.value===void 0?null:(0,K.jsx)(`span`,{className:`max-w-32 truncate font-mono text-ui text-muted-foreground`,children:e.value}),n?(0,K.jsx)(FT,{isOn:e.isOn===!0}):(0,K.jsx)(cn,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})})},LT=({title:e,actions:t,extra:n=null})=>{let r=t.filter(e=>e.isShown!==!1);return r.length===0?null:(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`h3`,{className:`m-0 px-4 pt-3.5 pb-1.5 text-ui font-normal text-muted-foreground`,children:e}),(0,K.jsxs)(`ul`,{className:`m-0 list-none more-group p-0`,children:[r.map(e=>(0,K.jsx)(IT,{action:e},e.id)),n]})]})},RT=(e,{present:t,isShown:n})=>{let r=new Set(t);return e.map((e,t)=>{let i=e.files.filter(e=>r.has(e));return{kind:`layer`,key:pw(t),index:t,address:e.address,ticket:e.ticket,title:e.title,all:i,files:i.filter(e=>n(t,e))}})},zT=(e,t)=>{let n=[];return e.forEach(e=>{let{ticket:r}=e,i=n.find(e=>e.kind===`ticket`&&e.number===r),a=t.find(e=>e.number===r);r===null||a===void 0?n.push(e):i?.kind===`ticket`?i.groups.push(e):n.push({kind:`ticket`,key:mw(r),number:r,title:a.title,groups:[e]})}),n},BT=e=>e.kind===`ticket`?e.groups:[e],VT=(e,{depth:t,isOpen:n})=>[{kind:`dir`,key:e.key,label:e.title,full:e.key,depth:t},...n(e)?e.files.map(n=>({kind:`file`,key:hw(e.index,n),path:n,label:QC(n),depth:t+1})):[]],HT=(e,t)=>e.flatMap(e=>e.kind===`layer`?VT(e,{depth:0,isOpen:t}):[{kind:`dir`,key:e.key,label:e.title,full:e.key,depth:0},...t(e)?e.groups.flatMap(e=>VT(e,{depth:1,isOpen:t})):[]]),UT=e=>e.flatMap(e=>BT(e).flatMap(e=>e.files.map(t=>hw(e.index,t)))),WT=(e,{isDone:t,isOpen:n,isReadOpen:r})=>{let i=e.filter(e=>t(e)),a=e.filter(e=>!t(e));if(i.length===0)return{rows:HT(e,n),order:UT(e),done:i,rest:a};let o={kind:`dir`,key:xw,label:`${String(i.length)} ${i.length===1?`layer`:`layers`} read`,full:xw,depth:0},s=r?[...i,...a]:a;return{rows:[o,...HT(s,n)],order:UT(s),done:i,rest:a}},GT=/(?<=\.)\s+(?=[A-Z`?@(])/u,KT=/^[-•·*]\s+/u,qT=/\*\*(?<words>[^*]+)\*\*/gu,JT=/^Read\b/u,YT=e=>e.replaceAll(qT,`$<words>`),XT=e=>(e.includes(`
|
|
43
43
|
`)?e.split(`
|
|
44
|
-
`):e.split(GT)).map(e=>YT(e.trim().replace(KT,``))).filter(e=>e!==``),ZT=(e,t)=>{let[n,...r]=XT(e);return n===void 0?null:{lead:n,points:r.filter(e=>!JT.test(e)),howTo:r.filter(e=>JT.test(e)),path:t}},QT=e=>{let[t]=e.prose;return t===void 0?null:ZT(t.markdown,t.path)},$T=(e,t)=>e.prose.slice(1).filter(e=>e.path===t).toSorted((e,t)=>e.line-t.line||Number(e.after)-Number(t.after)),eE=/(?<code>`[^`]+`|\?\w+=|@[A-Z]\w+|\b(?:GET|POST|PUT|PATCH|DELETE)\b|\b[a-z]+[A-Z]\w*|\b[A-Z][a-z\d]+[A-Z]\w*|(?:[\w.:-]*\/)+[\w.:-]+|\b[\w-]+\.(?:ts|tsx|js|json|md|ya?ml)\b)/u,tE=2,nE=({text:e,isChipped:t=!1})=>e.split(eE).map((e,n)=>n%tE===1?(0,K.jsx)(`code`,{className:t?`note-code`:`font-mono text-foreground`,children:e.replaceAll("`",``)},`${String(n)}:${e}`):e),rE=({className:e})=>(0,K.jsx)(`svg`,{"aria-hidden":!0,className:e,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:1.3,viewBox:`0 0 14 14`,children:(0,K.jsx)(`path`,{d:`M3 4h8M3 7h8M3 10h5`})}),iE=({intro:e,isPart:t=!1,isIntroShown:n,onOpenIntro:r})=>e===null?null:(0,K.jsxs)(`button`,{className:W(`mt-0.5 mb-1 grid w-full gap-0.5 rounded-md py-1.5 pe-2 text-start text-ui text-muted-foreground hover:bg-row-hover hover:text-foreground max-md:text-sm`,t?`ps-10.5`:`ps-8`),onClick:r,type:`button`,children:[(0,K.jsx)(`span`,{children:(0,K.jsx)(nE,{text:e.lead})}),(0,K.jsx)(`span`,{className:`text-xs text-subtle`,children:n?`Intro is open`:`Read the intro`})]}),aE=e=>`${String(e)} ${e===1?`line`:`lines`}`,oE=e=>`${String(e)} ${e===1?`place`:`places`}`,sE=(e,t)=>{let n=e.at===``?``:`, ${pn(e.at,t)} ago`;return e.deleted?`Deleted since you reviewed it${n}`:e.kept?`${aE(e.added+e.removed)} in ${oE(e.places)} since you reviewed it${n}`:`Changed since you reviewed it${n}`},cE=()=>(0,K.jsxs)(`svg`,{"aria-hidden":!0,className:`size-3`,fill:`none`,viewBox:`0 0 12 12`,children:[(0,K.jsx)(`path`,{d:`M10.4 4.2A4.9 4.9 0 1 0 10.9 7.6`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.3`}),(0,K.jsx)(`path`,{d:`M10.9 1.6 10.6 4.5 7.8 4.1`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.3`}),(0,K.jsx)(`path`,{d:`M3.9 6.2 5.4 7.7 8 4.9`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.4`})]}),lE=({since:e})=>{let t=vn();return(0,K.jsxs)(Gn,{children:[(0,K.jsxs)(En,{render:(0,K.jsx)(`span`,{className:`inline-flex text-muted-foreground`}),children:[(0,K.jsx)(cE,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Changed since review`})]}),(0,K.jsx)(kn,{children:(0,K.jsxs)(`span`,{className:`grid gap-0.5`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:`Changed since review`}),(0,K.jsx)(`span`,{children:sE(e,t)})]})})]})},uE={added:{Icon:pi,label:()=>`New file`,tone:`text-sign-add`},deleted:{Icon:si,label:()=>`Deleted file`,tone:`text-sign-del`},renamed:{Icon:Zn,label:e=>`Renamed from ${e}`,tone:`text-subtle`},copied:{Icon:Cr,label:e=>`Copied from ${e}`,tone:`text-subtle`}},dE=({file:e})=>{if(e.status===`modified`)return null;let{Icon:t,label:n,tone:r}=uE[e.status],i=n(e.previousPath);return(0,K.jsxs)(Gn,{children:[(0,K.jsxs)(En,{render:(0,K.jsx)(`span`,{className:W(`inline-flex shrink-0`,r)}),children:[(0,K.jsx)(t,{"aria-hidden":!0,className:`size-3`}),(0,K.jsx)(`span`,{className:`sr-only`,children:i})]}),(0,K.jsx)(kn,{children:i})]})},fE=[{short:`bin`,label:`Binary file`,isOn:e=>e.isBinary},{short:`gen`,label:`Generated file`,isOn:e=>e.isGenerated}],pE=({file:e})=>fE.filter(t=>t.isOn(e)).map(e=>(0,K.jsxs)(Gn,{children:[(0,K.jsx)(En,{render:(0,K.jsx)(`span`,{className:`shrink-0 text-subtle`}),children:e.short}),(0,K.jsx)(kn,{children:e.label})]},e.short)),mE=12,hE=(e,t,n)=>({count:e.all.length,read:e.all.filter(t=>n(e.index,t)).length,added:t?.added??0,removed:t?.removed??0,isDone:t?.isDone??!1}),gE=({size:e})=>(0,K.jsxs)(`span`,{className:`text-xs/4 text-subtle tabular-nums`,children:[`${String(e.count)} ${e.count===1?`file`:`files`}`,e.count===0?null:(0,K.jsxs)(K.Fragment,{children:[` · `,(0,K.jsx)(`span`,{className:`text-sign-add`,children:`+${kS(e.added)}`}),e.removed===0?null:(0,K.jsx)(`span`,{className:`text-sign-del`,children:` −${kS(e.removed)}`})]})]}),_E=()=>(0,K.jsx)(ar,{"aria-label":`read`,className:`size-3 text-success in-aria-expanded:max-md:text-accent-foreground`,strokeWidth:3}),vE=({layer:e,size:t})=>t.isDone?(0,K.jsx)(_E,{}):e.isRemainder?`·`:e.address,yE=e=>{let{layer:t,size:n,isOpen:r,isCursor:i}=e,a=t.ticket!==null,{isDone:o}=n;return(0,K.jsxs)(`button`,{"aria-expanded":r,"data-pinned":r?``:void 0,className:W(`flex min-w-0 items-start gap-2 rounded-lg py-1.5 text-start hover:bg-row-hover`,`w-full px-2`,r&&`sticky top-12 z-2 bg-secondary hover:bg-secondary data-stuck:rounded-none data-stuck:shadow-pinned`,r&&(a?`data-stuck:bleed-part`:`data-stuck:bleed`),i&&`bg-secondary transition-none hover:bg-secondary`,i&&!a&&`tree-cursor`),"data-open-row":r?``:void 0,onClick:e.onPick,ref:e.register(e.group.key),title:t.title,type:`button`,children:[(0,K.jsx)(`span`,{className:W(`grid h-5 shrink-0 items-center font-mono text-xs text-subtle tabular-nums`,a?`w-6.5 justify-items-start`:`w-4.5 justify-items-center`,r&&`max-md:rounded-full max-md:bg-accent max-md:text-accent-foreground`,r&&(a?`max-md:h-5.5 max-md:justify-items-center max-md:text-2xs`:`max-md:size-6`)),children:vE(e)}),(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-px`,children:[(0,K.jsx)(`span`,{className:W(`text-ui wrap-break-word`,r&&`max-md:text-base max-md:font-semibold`,r||!o&&i?`font-medium text-foreground`:`text-muted-foreground`,o&&!r&&`text-subtle`),children:t.title}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`flex-1`,children:(0,K.jsx)(gE,{size:n})}),(0,K.jsx)(Bb,{threads:t}),(0,K.jsx)(`span`,{className:`font-mono text-xs text-subtle tabular-nums`,children:n.count===0?`—`:`${String(n.read)}/${String(n.count)}`}),(0,K.jsx)(cn,{"aria-hidden":!0,className:`size-3 turn text-subtle`})]})]})]})},bE=({name:e})=>e.length<=mE?(0,K.jsx)(`span`,{className:`name-fit`,children:e}):(0,K.jsxs)(`span`,{className:`name-fit`,children:[(0,K.jsx)(`span`,{className:`name-head`,children:e.slice(0,-12)}),(0,K.jsx)(`span`,{className:`shrink-0`,children:e.slice(-12)})]}),xE=({file:e,part:t})=>e!==void 0&&(t?.added??0)===0&&(t?.removed??0)===0?(0,K.jsx)(dE,{file:e}):(0,K.jsx)(`span`,{className:`shrink-0 text-sign-add tabular-nums`,children:`+${kS(t?.added??0)}`}),SE=({path:e,props:t})=>{let n=hw(t.group.index,e),r=t.isReadIn(t.group.index,e),i=t.block.layers[t.group.index],a=Ab(i,e),o=t.files.get(e),s=r?void 0:t.block.since.find(t=>t.path===e),c=i!==void 0&&$T(i,e).length>0,l=t.cursor===n;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"aria-current":l?`true`:void 0,"aria-label":r?`${QC(e)}, read`:void 0,className:W(`relative flex h-6 w-full min-w-0 items-center gap-1.5 rounded-md ps-7 pe-2 text-start font-mono text-xs hover:bg-row-hover max-md:h-11 max-md:text-sm`,r?`text-muted-foreground`:`text-foreground`,l&&`bg-secondary transition-none hover:bg-secondary`,l&&(i?.ticket??null)===null&&`tree-cursor`),onClick:()=>{t.onPickFile(n,e)},ref:t.register(n),title:e,type:`button`,children:[a.open>0?(0,K.jsx)(`span`,{className:`absolute inset-s-2.5 top-1/2 -translate-y-1/2`,children:(0,K.jsx)(zb,{said:jb(a),stand:a.stand})}):null,(0,K.jsx)(bE,{name:QC(e)}),c?(0,K.jsx)(rE,{className:`size-3.5 shrink-0 text-subtle`}):null,r?(0,K.jsx)(ar,{"aria-hidden":!0,className:`size-3 shrink-0 text-success`,strokeWidth:3}):null,s===void 0?null:(0,K.jsx)(lE,{since:s}),r||s!==void 0?null:(0,K.jsx)(xE,{file:o,part:i?.parts.find(t=>t.path===e)})]})})},CE=e=>{let t=(e.block.layers[e.group.index]?.ticket??null)!==null,n=e.group.files.map((t,n)=>({path:t,folder:Sw(t),isNewFolder:n===0||Sw(e.group.files[n-1]??``)!==Sw(t)}));return(0,K.jsx)(`ul`,{className:W(`m-0 list-none pt-1 pb-1.5 max-md:mt-2 max-md:mb-3 max-md:more-group max-md:py-1 max-md:ps-0`,t?`ps-3.5 max-md:ms-3 max-md:me-1`:`ps-1.5 max-md:mx-1`),children:n.map(({path:t,folder:n,isNewFolder:r})=>(0,K.jsxs)(`div`,{className:`contents`,children:[r&&n!==``?(0,K.jsxs)(`li`,{className:`flex items-center gap-1.5 ps-4 pt-2 pb-0.5 font-mono text-2xs text-subtle`,title:`${n}/`,children:[(0,K.jsx)(Fr,{"aria-hidden":!0,className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:ww(n)})]}):null,(0,K.jsx)(SE,{path:t,props:e})]},t))})},wE=e=>({count:e.files.length,added:e.added,removed:e.removed}),TE=({rowKey:e,ticket:t,isOpen:n,isCursor:r,onPick:i,register:a})=>(0,K.jsxs)(`button`,{"aria-expanded":n,className:W(`flex w-full min-w-0 items-start gap-2 rounded-lg px-2 py-1.5 text-start hover:bg-row-hover`,r&&`bg-secondary transition-none hover:bg-secondary`),onClick:i,ref:a(e),title:t.title,type:`button`,children:[(0,K.jsx)(`span`,{className:`grid h-5 w-4.5 shrink-0 place-items-center font-mono text-xs text-subtle tabular-nums`,children:t.isDone?(0,K.jsx)(ar,{"aria-label":`read`,className:`size-3 text-success`,strokeWidth:3}):t.address}),(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-px`,children:[(0,K.jsx)(`span`,{className:W(`text-ui wrap-break-word`,n||r?`text-foreground`:`text-muted-foreground`,r&&`font-medium`,t.isDone&&!n&&!r&&`text-subtle`),children:t.title}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`flex-1`,children:(0,K.jsx)(gE,{size:wE(t)})}),n?null:(0,K.jsx)(Bb,{threads:t}),(0,K.jsxs)(`span`,{className:`font-mono text-xs text-subtle tabular-nums`,children:[`${String(t.sublayersDone)}/${String(t.sublayers)}`,(0,K.jsx)(`span`,{className:`font-sans`,children:` parts`})]}),(0,K.jsx)(cn,{"aria-hidden":!0,className:`size-3 turn text-subtle`})]})]})]}),EE=({row:e,onPick:t})=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:W(`flex min-h-14 w-full items-center gap-2.5 py-1.5 pe-3.5 text-start transition-colors duration-150 active:bg-foreground/8`,e.isPart?`ps-10`:`ps-3.5`),onClick:()=>{t(e.key)},type:`button`,children:[(0,K.jsx)(`span`,{className:W(`grid h-6 shrink-0 place-items-center rounded-full font-mono`,e.isPart?`w-7.5 text-xs`:`w-6 text-sm`,e.isHere?`bg-accent text-accent-foreground`:`text-subtle`),children:e.isRead&&!e.isHere?(0,K.jsx)(ar,{"aria-label":`read`,className:`size-3.5 text-success`,strokeWidth:3}):e.number}),(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-base/5`,children:e.title}),(0,K.jsx)(gE,{size:e.size})]}),e.threads.open>0?(0,K.jsx)(zb,{said:jb(e.threads),stand:e.threads.stand}):null,(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-sm text-subtle tabular-nums`,children:e.count})]})}),DE=({props:e})=>{let{model:t,block:n}=e,r=yw(e.state.cursor),i=vw(e.state.cursor)??t.groups.find(t=>t.all.includes(e.state.selected))?.index,a=e=>{let a=hE(e,n.layers[e.index],t.marks.isReadIn),o=n.layers[e.index];return{key:e.key,number:o?.isRemainder===!0?`·`:e.address,title:e.title,size:a,threads:o??Ob,count:a.count===0?`—`:`${String(a.read)}/${String(a.count)}`,isRead:a.isDone,isHere:r===null&&e.index===i,isPart:e.ticket!==null}},o=[];return t.entries.forEach(e=>{let t=e.kind===`ticket`?n.tickets.find(t=>t.number===e.number):void 0;t!==void 0&&o.push({key:mw(t.number),number:t.address,title:t.title,size:wE(t),threads:Ob,count:`${String(t.sublayersDone)}/${String(t.sublayers)}`,isRead:t.isDone,isHere:r===t.number,isPart:!1}),BT(e).forEach(e=>{o.push(a(e))})}),(0,K.jsx)(`ul`,{className:`m-0 mx-2 mb-10 list-none more-group p-0`,children:o.map(t=>(0,K.jsx)(EE,{onPick:e.onPickLayer,row:t},t.key))})},OE=e=>e.state.focus===`diff`&&e.file!==void 0,kE=7,AE=e=>e===void 0?`automatic`:/^[\da-f]{40}$/u.test(e)?e.slice(0,kE):e,jE=({key:e,props:t})=>[e(`b`,{icon:Lr,label:`Compare against`,value:AE(t.block.base.label)}),e(`/`,{icon:un,label:`Search the branch`}),e(`p`,{icon:zr,label:`Open the pull request`,isShown:t.hasPull}),e(`L`,{icon:Yr,label:`New reading order`,note:`Ask the agent to regroup the files into layers`})],ME=({key:e,props:t})=>[e(`a`,{icon:ai,label:`Review panel`}),e(`D`,{icon:rr,label:`Settle what is read`,note:`Close answered threads on files you reviewed`}),e(`C`,{icon:_i,label:`Send ${String(t.draftCount)} held notes`,note:`Post them to the pull request as one review`,isShown:t.draftCount>0})],NE=({key:e,props:t})=>[e(`m`,{icon:_r,label:`Reviewed`,isOn:t.isReviewed,isShown:t.file!==void 0}),e(`s`,{icon:Gr,label:`Group by layer`,note:`Read the files in the order the agent suggests`,isOn:t.state.isLayered||t.state.wantsLayers}),e(`f`,{icon:kr,label:`Hide read files`,isOn:t.state.isHidingReviewed})],PE=({key:e,props:t})=>[e(`}`,{icon:Yn,label:`Next change`,isShown:OE(t)}),e(`{`,{icon:$n,label:`Previous change`,isShown:OE(t)}),e(`n`,{icon:sr,label:`Next comment`,isShown:OE(t)}),e(`N`,{icon:dr,label:`Previous comment`,isShown:OE(t)}),e(`V`,{icon:Di,label:`Select the change`,note:`Pick every line of the change under the cursor`,isShown:OE(t)})],FE=({key:e,props:t,isNoted:n,isOthersShown:r})=>t.state.isLayered?[e(`I`,{icon:Ni,label:`Layer notes`,note:`The layer's intro and each file's note over its code`,isOn:n}),e(`O`,{icon:Ur,label:`Other layers`,note:`Other layers' lines in place, quiet, rather than folded`,isOn:r})]:[],IE=e=>{let{key:t,props:n,isScoped:r}=e;return[t(`w`,{icon:Fi,label:`Wrap long lines`,isOn:n.state.isWrapped}),t(`+`,{icon:hr,label:`More context`,note:`Show more unchanged lines around each change`}),t(`-`,{icon:pr,label:`Less context`}),t(`F`,{icon:jr,label:`Whole file`,isOn:n.state.context===`whole`}),t(`S`,{icon:li,label:`Pin the scope`,note:`Keep the function you are in above the code`,isOn:r}),...FE(e)]},LE=({key:e})=>[e(`?`,{icon:Vr,label:`Theme, editor and keys`,note:`Warm, black or light; where lines open`})],RE=({props:e,onPress:t,footer:n})=>{let{isScoped:r,isNoted:i,isOthersShown:a}=Un(),o=OT(e),s={props:e,isScoped:r,isNoted:i,isOthersShown:a,key:(e,n)=>({id:e,...n,onPress:()=>{t(e)}})};return(0,K.jsxs)(`div`,{className:`grid gap-1 px-2 pb-10`,children:[(0,K.jsx)(LT,{actions:jE(s),title:`Branch`}),(0,K.jsx)(LT,{actions:o,title:`Agent`}),(0,K.jsx)(LT,{actions:ME(s),title:`Comments`}),(0,K.jsx)(LT,{actions:NE(s),title:`Files`}),(0,K.jsx)(LT,{actions:PE(s),title:`Move`}),(0,K.jsx)(LT,{actions:IE(s),extra:(0,K.jsx)(PT,{}),title:`Diff`}),(0,K.jsx)(LT,{actions:LE(s),title:`Settings`}),n]})},zE=`flex w-full min-w-0 items-start gap-2 rounded-md px-2 py-1.5 text-start transition-colors duration-150 ease-out outline-none hover:bg-secondary focus-visible:bg-secondary`,BE=({text:e})=>(0,K.jsx)(`p`,{className:`m-0 px-4 py-6 text-center text-sm text-subtle`,children:e}),VE=(e,t)=>e.trim()===``?`Type to search the files this branch changes`:t===null?`Searching…`:t.length===0?`No matches`:null,HE=e=>{let t={deck:e.deck,point:e.view.id,branch:e.block.branch},[n,r]=(0,G.useState)(``),[i,a]=(0,G.useState)([]),o=(0,G.useRef)(0);return{term:n,matches:i,find:async e=>{o.current+=1;let n=o.current;if(r(e),a(e.trim()===``?[]:null),e.trim()===``)return;let i=await tC({data:{...t,term:e}});n===o.current&&a(i)}}},UE=({term:e,onTerm:t,onEnter:n})=>(0,K.jsx)(`div`,{className:`shrink-0 border-b border-border p-2`,children:(0,K.jsxs)(`label`,{className:`flex h-9 cursor-text items-center gap-2 rounded-lg border border-border bg-composer px-2.5 text-sm transition-colors duration-150 ease-out focus-within:border-muted-foreground hover:border-subtle`,children:[(0,K.jsx)(un,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-subtle`}),(0,K.jsx)(`input`,{"aria-label":`Search this branch`,className:`min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-subtle [&::-webkit-search-cancel-button]:hidden`,onChange:e=>{t(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),n())},"data-autofocus":!0,onPaste:dn,placeholder:`Search this branch`,type:`search`,value:e})]})}),WE=({props:e,onOpen:t})=>{let{term:n,matches:r,find:i}=HE(e),a=VE(n,r);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(UE,{onEnter:()=>{let[e]=r??[];e!==void 0&&t(e.path)},onTerm:e=>void i(e),term:n}),(0,K.jsxs)(R_,{children:[a===null?null:(0,K.jsx)(BE,{text:a}),(0,K.jsx)(`ul`,{className:`m-0 grid list-none gap-0.5 p-2`,children:(r??[]).map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(`button`,{"aria-label":`${e.path} line ${String(e.line)}: ${e.text.trim()}`,className:zE,onClick:()=>{t(e.path)},type:`button`,children:(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,K.jsx)(`span`,{className:`truncate rtl-ellipsis font-mono text-xs/5 text-muted-foreground`,children:(0,K.jsx)(`bdi`,{children:`${e.path}:${String(e.line)}`})}),(0,K.jsx)(`span`,{className:W(`truncate font-mono text-xs/5 whitespace-pre`,e.changed?`text-foreground`:`text-subtle`),children:e.text.trim()})]})})},`${e.path}:${String(e.line)}`))})]}),(0,K.jsxs)(z_,{children:[(0,K.jsx)(tn,{children:`↵`}),(0,K.jsx)(`span`,{children:`opens the first match`})]})]})},GE=40,KE=8,qE=e=>e.length===GE?e.slice(0,KE):e,JE=({title:e,said:t,isCurrent:n,isFirst:r=!1,onPick:i})=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"aria-current":n?`true`:void 0,className:zE,"data-autofocus":r?!0:void 0,onClick:i,type:`button`,children:[(0,K.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center text-success`,children:n?(0,K.jsx)(ar,{"aria-hidden":!0,className:`size-3.5`}):null}),(0,K.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,K.jsx)(`span`,{className:`truncate font-mono text-xs/5 text-foreground`,children:e}),t===``?null:(0,K.jsx)(`span`,{className:`text-xs text-subtle`,children:t})]})]})}),YE=e=>/^[\da-f]{7,40}$/u.test(e),XE=({text:e})=>(0,K.jsx)(`li`,{"aria-hidden":!0,className:`px-2 pt-2.5 pb-1 text-2xs font-medium text-subtle`,children:e}),ZE=({props:e,onDone:t})=>{let n={deck:e.deck,point:e.view.id,branch:e.block.branch},r=e.block.base.label,i=Tw(()=>$S({data:n}),`${n.deck}|${n.point}|${n.branch}`),a=async r=>{t(),await eC({data:{...n,ref:r}}),await e.refresh(!0)};return(0,K.jsxs)(`ul`,{className:`m-0 grid list-none gap-0.5 p-2`,children:[(0,K.jsx)(JE,{isCurrent:!1,isFirst:!0,onPick:()=>void a(null),said:`The branch it is stacked on`,title:`automatic`}),i===null?(0,K.jsx)(BE,{text:`Reading the refs…`}):null,[{title:`Commits`,refs:(i??[]).filter(e=>YE(e.ref))},{title:`Branches`,refs:(i??[]).filter(e=>!YE(e.ref))}].map(e=>e.refs.length===0?null:(0,K.jsxs)(G.Fragment,{children:[(0,K.jsx)(XE,{text:e.title}),e.refs.map(e=>(0,K.jsx)(JE,{isCurrent:e.ref===r,onPick:()=>void a(e.ref),said:e.said,title:qE(e.ref)},e.ref))]},e.title))]})},QE={base:`Compare against`,search:`Search this branch`,keys:`Keys`,more:`Actions`,layers:`Layers`},$E=({props:e,phone:t,onOpen:n})=>{let{state:r,setState:i}=e,[a,o]=(0,G.useState)(r.dialog),s=(0,G.useRef)(null);r.dialog!==null&&r.dialog!==a&&o(r.dialog);let c=()=>{i({...r,dialog:null})};return(0,K.jsx)(j_,{onOpenChange:e=>{e||c()},open:r.dialog!==null,children:(0,K.jsxs)(I_,{"data-review-dialog":a??``,initialFocus:()=>s.current?.querySelector(`[data-autofocus]`)??s.current,finalFocus:()=>document.querySelector(`[data-owns-keys]`),ref:s,variant:`sheet`,children:[(0,K.jsx)(L_,{title:a===null?``:QE[a]}),a===`keys`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(R_,{children:(0,K.jsx)(Ow,{})}),(0,K.jsxs)(z_,{children:[(0,K.jsx)(kw,{}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:`mx-2 h-4 w-px bg-border`}),(0,K.jsx)(Aw,{})]})]}):null,a===`more`?(0,K.jsx)(R_,{children:(0,K.jsx)(RE,{onPress:t.handlePress,props:t})}):null,a===`layers`?(0,K.jsx)(R_,{children:(0,K.jsx)(DE,{props:t})}):null,a===`base`?(0,K.jsx)(R_,{children:(0,K.jsx)(ZE,{onDone:c,props:e})}):null,a===`search`?(0,K.jsx)(WE,{onOpen:e=>{c(),n(e)},props:e}):null]})})},eD=({agent:e,isPicked:t,onPick:n})=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"aria-current":t?`true`:void 0,className:W(zE,!e.isInstalled&&`opacity-60`),"data-autofocus":t?!0:void 0,onClick:n,type:`button`,children:[(0,K.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center text-success`,children:t?(0,K.jsx)(ar,{"aria-hidden":!0,className:`size-3.5`}):null}),(0,K.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-sm text-foreground`,children:e.label}),(0,K.jsx)(`span`,{className:`truncate font-mono text-xs text-subtle`,children:e.isInstalled?e.path??e.bin:`not found in your shell`})]})]})}),tD=({label:e,hint:t,value:n,fallback:r,onChange:i})=>(0,K.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,K.jsxs)(`span`,{className:`flex items-baseline justify-between gap-3 text-xs text-muted-foreground`,children:[(0,K.jsx)(`span`,{children:e}),n===r?null:(0,K.jsx)(`button`,{className:`text-subtle hover:text-foreground`,onClick:e=>{e.preventDefault(),i(r)},type:`button`,children:`Reset`})]}),(0,K.jsx)(`textarea`,{className:`min-h-14 resize-y rounded-lg border border-border bg-composer px-2.5 py-2 font-mono text-xs/5 text-foreground outline-none focus:border-muted-foreground`,onChange:e=>{i(e.target.value)},onPaste:dn,spellCheck:!1,value:n}),(0,K.jsx)(`span`,{className:`text-xs text-subtle`,children:t})]}),nD=({model:e,onDone:t})=>{let{listener:n}=e,[r,i]=(0,G.useState)(n?.chosen??`claude`),[a,o]=(0,G.useState)({});if(n===null)return null;let s=n.agents.find(e=>e.id===r),c=a[r]??{headless:s?.headless??``,interactive:s?.interactive??``},l=(e,t)=>{o({...a,[r]:{...c,[e]:t}})},u=async()=>{await e.handleSave({agent:r,...c}),t()};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(R_,{children:[(0,K.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-2 gap-0.5 p-2`,children:n.agents.map(e=>(0,K.jsx)(eD,{agent:e,isPicked:e.id===r,onPick:()=>{i(e.id)}},e.id))}),s===void 0?null:(0,K.jsxs)(`div`,{className:`grid gap-4 border-t border-border p-4`,children:[(0,K.jsx)(tD,{fallback:s.defaultHeadless,hint:`Runs in the review’s worktree, in your shell, so aliases work. The prompt is added last.`,label:`Headless command`,onChange:e=>{l(`headless`,e)},value:c.headless}),(0,K.jsx)(tD,{fallback:s.defaultInteractive,hint:`What “Copy a terminal command” starts. The prompt is added last.`,label:`Terminal command`,onChange:e=>{l(`interactive`,e)},value:c.interactive})]})]}),(0,K.jsxs)(z_,{children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:n.configPath}),(0,K.jsx)(Dn,{disabled:e.isBusy,onClick:()=>void u(),size:`sm`,children:`Save`})]})]})},rD=({model:e,isOpen:t,onOpenChange:n})=>(0,K.jsx)(j_,{onOpenChange:n,open:t,children:(0,K.jsxs)(I_,{variant:`sheet`,children:[(0,K.jsx)(L_,{title:`Agent`}),t?(0,K.jsx)(nD,{model:e,onDone:()=>{n(!1)}}):null]})}),iD=({listener:e},t)=>{let n=new Set(e?.takenLately);return t.filter(e=>n.has(e.id)&&e.stand===`waiting`).length},aD=e=>`An agent is working on ${String(e)} ${e===1?`comment`:`comments`}`,oD=({listener:e},t)=>{let n=e?.run;return n?.state===`running`?e?.isListening===!0?`A headless ${n.agent} is listening`:`A headless ${n.agent} is working`:e?.isListening===!0?`An agent is listening`:t>0?aD(t):`No agent is watching this review`},sD=(e,t)=>({working:iD(e,t),waiting:t.filter(e=>e.stand===`filed`).length}),cD=100,lD=({done:e,total:t,className:n})=>(0,K.jsx)(`span`,{"aria-hidden":!0,className:W(`h-0.75 overflow-hidden rounded-full bg-secondary`,n),children:(0,K.jsx)(`span`,{className:`progress-fill`,ref:n=>{n?.style.setProperty(`--fill`,`${String(t===0?0:e*cD/t)}%`)}})}),uD={files:`rail`,diff:`diff`,panel:`panel`},dD=(e,t)=>e.querySelector(`:scope > [data-review-${uD[t]}]`),fD=e=>e!==null&&Object.hasOwn(uD,e),pD=()=>{let e=document.querySelector(`[data-phone-view]`),t=e?.dataset.phoneView??null;if(e===null||!fD(t))return;let n=dD(e,t),r=globalThis.matchMedia(`(prefers-reduced-motion: reduce)`).matches;for(let e of n===null?[]:[n,...n.querySelectorAll(`*`)])e.scrollTop>0&&e.scrollTo({top:0,behavior:r?`auto`:`smooth`})},mD={lead:`diff`,pile:null,threadAt:null,isBackToThreads:!1},hD=e=>e.isPanelOpen?`panel`:e.focus===`diff`?`diff`:`files`,gD=e=>e.isPanelOpen?{...e,isPanelOpen:!1}:{...e,focus:`tree`,anchor:null},_D=e=>({...e,isPanelOpen:!1,focus:`diff`}),vD=e=>vw(e.cursor),yD=(e,t)=>e.layerOpen[t]??(t!==`layer:read`&&e.cursor.startsWith(`${t}:`)),bD=(e,{key:t,groups:n})=>{let r=n.find(e=>e.key===t)?.ticket??null,i=r===null?null:mw(r),a=Object.fromEntries(Object.entries({...e.layerOpen,[t]:!0}).filter(([e])=>e!==i));return{...e,dialog:null,cursor:t,layerOpen:a}},xD=(e,t)=>{if(t.kind===`layer`)return yD(e,t.key);let n=vw(e.cursor);return e.layerOpen[t.key]??t.groups.some(e=>e.index===n)},SD=(e,t,n)=>({...e,layerOpen:{...e.layerOpen,[t]:n}}),CD=e=>e.split(`/`).slice(0,-1).map((e,t,n)=>n.slice(0,t+1).join(`/`)),wD=e=>{let[t=``]=e.order;return{selected:t,cursor:`file:${t}`,collapsed:new Set,isHidingReviewed:!1,isLayered:!1,wantsLayers:!1,layerOpen:{},isPanelOpen:!1,dialog:null,focus:`tree`,row:0,anchor:null,context:3,opened:{},runs:{},isWrapped:!1,settledAt:null,...mD}},TD=(e,t)=>e.has(t)?new Set([...e].filter(e=>e!==t)):new Set([...e,t]),ED=(e,t,n)=>{let r=n.find(e=>e.key===t),i=r===void 0?yD(e,t):xD(e,r);return SD({...e,cursor:t},t,!i)},DD=(e,t,n=[])=>t.kind===`file`?{...e,selected:t.path,cursor:t.key,row:0,anchor:null}:e.isLayered?ED(e,t.key,n):{...e,collapsed:TD(e.collapsed,t.full),cursor:t.key},OD=(e,{rows:t,offset:n})=>{let r=t.findIndex(t=>t.key===e.cursor),i=t[Math.min(t.length-1,Math.max(0,r+n))];return i===void 0?e:i.kind===`file`?{...e,selected:i.path,cursor:i.key,row:0,anchor:null}:{...e,cursor:i.key}},kD=(e,t)=>e.find(e=>e.kind===`file`&&e.path===t)?.key??`file:${t}`,AD=(e,{order:t,offset:n,rows:r})=>{let i=t[t.indexOf(e.selected)+n];return i===void 0?e:{...e,selected:i,cursor:kD(r,i),row:0,anchor:null}},jD=(e,{order:t,offset:n})=>{let r=t.indexOf(e.cursor),i=t[(r===-1?t.findIndex(t=>t.endsWith(`:${e.selected}`)):r)+n];if(i===void 0)return e;let a=vw(i)??0;return{...e,cursor:i,selected:i.slice(`layer:${String(a)}:`.length),row:0,anchor:null}},MD=(e,t)=>e.isLayered?jD(e,t):AD(e,t),ND=(e,{rowsFor:t,layerOf:n})=>{let r={...e,isLayered:!e.isLayered,collapsed:new Set,layerOpen:{}};return r.isLayered?{...r,cursor:`layer:${String(n(e.selected))}:${e.selected}`}:{...r,cursor:kD(t(r),e.selected)}},PD=(e,t)=>t.hasLayers?ND(e,t):{...e,wantsLayers:!e.wantsLayers},FD=(e,t)=>{if(e.cursor===`layer:read`||yw(e.cursor)!==null)return SD(e,e.cursor,t);let n=vD(e);if(n===null)return e;let r=`layer:${String(n)}`,i=SD(e,r,t);return t?i:{...i,cursor:r}},ID=7,LD=e=>e===void 0?`its stacked parent`:/^[\da-f]{40}$/u.test(e)?e.slice(0,ID):e,RD=()=>(0,K.jsx)(`span`,{"aria-hidden":!0,className:`h-4 w-px shrink-0 bg-border`}),zD=({count:e,total:t})=>(0,K.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-2 whitespace-nowrap tabular-nums`,children:[(0,K.jsx)(lD,{className:`w-14`,done:e,total:t}),`${String(e)} of ${String(t)} reviewed`]}),BD=({children:e,block:t,pull:n,onBase:r,onKeys:i,total:a,reviewedCount:o,isZoomed:s,onToggleZoom:c,lead:l})=>(0,K.jsxs)(`div`,{className:`flex h-11 min-w-0 items-center gap-3 bg-wash ps-4 pe-2.5 text-xs text-muted-foreground max-md:hidden`,children:[(0,K.jsx)(`span`,{className:`truncate font-mono text-ui font-medium text-foreground`,children:t.branch}),(0,K.jsxs)(`button`,{className:`inline-flex shrink-0 press items-center gap-1 font-mono whitespace-nowrap text-subtle hover:text-foreground`,onClick:r,title:`Change what this branch is compared against (b)`,type:`button`,children:[`vs ${LD(t.base.label)}`,(0,K.jsx)(sr,{"aria-hidden":!0,className:`size-3`})]}),n===null?null:(0,K.jsx)(`a`,{className:`shrink-0 press font-mono whitespace-nowrap text-subtle hover:text-foreground`,href:n.url,rel:`noopener noreferrer`,target:`_blank`,title:`Open the pull request (p)`,children:`#${String(n.number)}`}),l,(0,K.jsx)(`span`,{className:`ms-auto`}),(0,K.jsx)(zD,{count:o,total:a}),e===void 0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(RD,{}),e]}),(0,K.jsx)(RD,{}),(0,K.jsx)(wn,{keys:[`?`],label:`Every key`,side:`left`,children:(0,K.jsx)(`button`,{className:`inline-flex shrink-0 press items-center gap-1.5 whitespace-nowrap text-subtle hover:text-foreground`,onClick:i,type:`button`,children:`Keys`})}),c===void 0?null:(0,K.jsx)(On,{label:s?`Close`:`Zoom`,onClick:c,shortcut:s?xn.close:xn.zoom,size:`icon-sm`,children:s?(0,K.jsx)(Vi,{}):(0,K.jsx)(ti,{})})]}),VD=e=>e.slice(e.lastIndexOf(`/`)+1),HD=2,UD=e=>{let t=e.split(`/`);return t.length>HD?`…/${t.slice(-2).join(`/`)}`:e},WD=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`))),GD=`grid size-11 shrink-0 place-items-center rounded-full text-foreground glass press aria-pressed:bg-accent/28`,KD=({onMore:e})=>(0,K.jsx)(`button`,{"aria-label":`More actions`,className:GD,onClick:e,type:`button`,children:(0,K.jsx)(Dr,{className:`size-5.5`})}),qD=({className:e,children:t})=>(0,K.jsx)(`button`,{className:`min-w-0 flex-1 text-start ${e}`,onClick:pD,type:`button`,children:t}),JD=({label:e,onBack:t})=>(0,K.jsx)(`button`,{"aria-label":e,className:GD,onClick:t,type:`button`,children:(0,K.jsx)(lr,{className:`size-5.5`})}),YD=e=>{let t=e.state.isLayered?e.model.groups.find(t=>e.file!==void 0&&t.all.includes(e.file.path)):void 0;return t===void 0||e.file===void 0?`${String(e.position)} of ${String(e.total)}`:`${String(t.all.indexOf(e.file.path)+1)} of ${String(t.all.length)} in layer ${t.address}`},XD=e=>(0,K.jsxs)(`div`,{className:`grid gap-2.5 bg-background px-4 py-3 md:hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(qD,{className:`truncate font-mono text-lg/6 font-semibold`,children:e.block.branch}),(0,K.jsx)(`button`,{"aria-label":e.state.isHidingReviewed?`Show read files`:`Hide read files`,"aria-pressed":e.state.isHidingReviewed,className:GD,onClick:()=>{e.handlePress(`f`)},type:`button`,children:(0,K.jsx)(qr,{className:`size-5`})}),(0,K.jsx)(KD,{onMore:e.onMore})]}),e.state.isLayered?null:(0,K.jsx)(lD,{className:`h-1 w-full`,done:e.reviewedCount,total:e.reviewTotal}),(0,K.jsxs)(`div`,{className:`flex min-h-6 items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-ui text-muted-foreground tabular-nums`,children:`${String(e.reviewedCount)} of ${String(e.reviewTotal)} reviewed`}),e.nextUnreviewed===null?null:(0,K.jsxs)(`button`,{className:`-my-2.5 -me-1 inline-flex min-h-11 press items-center gap-0.5 px-1 text-ui font-medium text-claude`,onClick:()=>{e.nextUnreviewed!==null&&e.onOpen(e.nextUnreviewed)},type:`button`,children:[`Next unreviewed`,(0,K.jsx)(cn,{"aria-hidden":!0,className:`size-4`,strokeWidth:2.25})]})]}),(0,K.jsx)(`span`,{className:e.state.isLayered?`hidden`:void 0,children:(0,K.jsxs)(`button`,{className:`inline-flex h-8 press items-center gap-1.5 rounded-full bg-secondary px-3 font-mono text-xs text-muted-foreground`,onClick:()=>{e.handlePress(`b`)},type:`button`,children:[`vs ${LD(e.block.base.label)}`,(0,K.jsx)(sr,{"aria-hidden":!0,className:`size-3.5`})]})})]}),ZD=e=>{let t=hD(e.state);if(t===`files`)return(0,K.jsx)(XD,{...e});let n=e.file===void 0?``:WD(e.file.path);return(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 bg-background px-3 pt-3 pb-2.5 md:hidden`,children:[(0,K.jsx)(JD,{label:t===`panel`?`Close the review panel`:`Back to the files`,onBack:e.onBack}),t===`diff`&&e.file!==void 0?(0,K.jsxs)(qD,{className:`grid gap-0.5`,children:[(0,K.jsx)(`span`,{className:`truncate font-mono text-base/5 font-semibold`,children:VD(e.file.path)}),(0,K.jsx)(`span`,{className:`truncate font-mono text-xs text-muted-foreground tabular-nums`,children:[n===``?``:UD(n),YD(e)].filter(Boolean).join(` · `)})]}):(0,K.jsx)(qD,{className:`truncate text-lg font-semibold`,children:`Review`}),(0,K.jsx)(KD,{onMore:e.onMore})]})},QD=({listener:e})=>{let t=e?.run;return t==null||t.state===`running`?t?.lines.at(-1)??``:t.state===`stopped`?`Stopped`:`Ended: ${t.lines.at(-1)??``}`},$D=({lines:e})=>(0,K.jsx)(gn,{children:(0,K.jsxs)(`ol`,{className:`m-0 grid max-h-48 list-none gap-0.5 overflow-auto border-b border-border bg-wash px-3 py-2 font-mono text-xs/5 text-muted-foreground`,children:[e.length===0?(0,K.jsx)(`li`,{className:`text-subtle`,children:`Nothing yet`}):null,e.map((e,t)=>(0,K.jsx)(`li`,{className:`wrap-break-word`,children:e},`${String(t)}-${e}`))]})}),eO=({note:e,isFailure:t})=>e===``?null:(0,K.jsx)(Kn,{label:e,children:(0,K.jsx)(`span`,{className:W(`max-w-64 truncate`,t?`text-destructive`:`text-subtle`),children:e})}),tO=({model:e,threads:t})=>{let{listener:n,isBusy:r,failure:i}=e,[a,o]=(0,G.useState)(!1),s=n?.run??null,c=s?.state===`running`,{working:l,waiting:u}=sD(e,t),d=n?.isListening===!0||c||l>0;if(n===null)return null;let f=ET(n);return(0,K.jsxs)(`span`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[d||f===null?null:(0,K.jsxs)(Dn,{disabled:r||n.worktree===null,onClick:()=>void e.handleStart(f.id),size:`xs`,title:`${oD(e,l)}${u>0?` · ${String(u)} waiting`:``}. Start a headless ${f.label} to answer it.`,variant:`outline`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`me-0.5 size-1.5 rounded-full bg-subtle`}),`Start agent`]}),d?(0,K.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-success`}),(0,K.jsx)(`span`,{className:`truncate text-foreground`,children:oD(e,l)})]}):null,d||s!==null||i!==null?(0,K.jsx)(eO,{isFailure:i!==null,note:i??QD(e)}):null,s===null?null:(0,K.jsx)(`span`,{className:`shrink-0`,children:(0,K.jsx)(mn,{size:`sm`,children:`Log`})}),c?(0,K.jsx)(Dn,{disabled:r,onClick:()=>void e.handleStop(),size:`xs`,variant:`ghost`,children:`Stop`}):null,(0,K.jsx)(DT,{isHeard:d,model:e,onSettings:()=>{o(!0)}}),(0,K.jsx)(rD,{isOpen:a,model:e,onOpenChange:o})]})},nO=({model:e,phone:t,...n})=>(0,K.jsxs)(yn,{children:[(0,K.jsx)(ZD,{...t}),(0,K.jsx)(BD,{...n,children:(0,K.jsx)(tO,{model:e,threads:n.block.threads})}),(0,K.jsx)($D,{lines:e.listener?.run?.lines??[]})]}),rO=[{mode:`since`,label:`Since review`},{mode:`full`,label:`Full diff`}],iO=({mode:e,onMode:t})=>(0,K.jsx)(wn,{keys:[`r`],label:`Since review or full diff`,children:(0,K.jsx)(`fieldset`,{className:`m-0 inline-flex shrink-0 gap-0.5 rounded-md border-0 bg-secondary p-0.5 max-md:w-full`,children:rO.map(n=>(0,K.jsx)(`button`,{"aria-pressed":e===n.mode,className:W(`h-6 press rounded-sm px-2.5 text-xs text-muted-foreground max-md:h-9 max-md:flex-1 max-md:text-sm`,e===n.mode&&`bg-background font-medium text-foreground shadow-sm`),onClick:()=>{t(n.mode)},type:`button`,children:n.label},n.mode))})}),aO=({since:e,mode:t,onMode:n})=>{let r=vn();return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border px-3 py-1.5 text-xs text-muted-foreground max-md:flex-wrap max-md:px-4 max-md:py-2`,children:[(0,K.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center gap-1.5 max-md:flex-wrap max-md:gap-y-0.5`,children:[(0,K.jsx)(cE,{}),(0,K.jsx)(`span`,{className:`font-medium whitespace-nowrap text-foreground`,children:`Changed since review`}),(0,K.jsx)(`span`,{className:`truncate max-md:basis-full max-md:ps-4.5 max-md:whitespace-normal`,children:sE(e,r)})]}),t===null?null:(0,K.jsx)(iO,{mode:t,onMode:n})]})},oO=/^\d+\.\s*/u,sO=(e,t)=>`${e.branch}|${t.title}`,cO=(e,t)=>`${e.branch}|ticket|${t.title}`,lO=(e,t)=>e.tickets.find(e=>e.number===t.ticket),uO=(e,t)=>{let n=QT(t)?.path;return e.files.some(e=>e.path===n)?n:t.files.find(t=>e.files.some(e=>e.path===t))},dO=(e,t)=>{let[n]=t.layers,r=n===void 0?void 0:e.layers[n-1];return n===void 0||r===void 0?null:{index:n-1,layer:r}},fO=(e,t)=>e.files.filter(e=>t.files.includes(e.path)),pO=(e,t)=>{let n=fO(e,t),r=n.filter(e=>$T(t,e.path).length>0).length;return{count:n.length,added:t.added,detail:`${String(r)} of ${String(n.length)} files have a note`}},mO=({sublayers:e,sublayersDone:t})=>t===0?`${String(e)} parts, none read yet`:t===e?`Every part read`:`${String(t)} of ${String(e)} parts read`,hO=(e,t)=>{let n=lO(e,t);return n===void 0||t.sublayer===null?`Layer ${t.address} of ${String(e.topLevel)}`:`Layer ${t.address} · part ${String(t.sublayer)} of ${String(n.sublayers)} in ${n.title}`},gO=(e,t,n)=>{let r=lO(e,t);return r!==void 0&&dO(e,r)?.layer===t&&ZT(r.note,``)!==null&&!n.includes(cO(e,r))},_O=(e,t)=>{let n=lO(e,t);n!==void 0&&dO(e,n)?.layer===t&&zn(cO(e,n),!0),zn(sO(e,t),!1)},vO=({points:e})=>e.length===0?null:(0,K.jsx)(`ul`,{className:`m-0 grid list-none gap-1.25 p-0`,children:e.map(e=>(0,K.jsxs)(`li`,{className:`flex gap-2.5 text-sm text-pretty text-muted-foreground max-md:text-base`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`mt-2.25 size-1 shrink-0 rounded-full bg-subtle`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(nE,{isChipped:!0,text:e})})]},e))}),yO=({block:e,ticket:t})=>(0,K.jsx)(`ul`,{className:`m-0 mt-0.5 grid list-none gap-0.5 p-0`,children:t.layers.map(t=>{let n=e.layers[t-1];return n===void 0?null:(0,K.jsxs)(`li`,{className:`flex items-baseline gap-2 text-sm/5.5 text-muted-foreground max-md:text-base`,children:[(0,K.jsx)(`span`,{className:`w-7.5 shrink-0 font-mono text-xs/5.5 text-subtle`,children:n.address}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1`,children:n.title}),(0,K.jsxs)(`span`,{className:`shrink-0 text-xs whitespace-nowrap text-subtle tabular-nums`,children:[`${String(fO(e,n).length)} files · `,(0,K.jsx)(`span`,{className:`text-sign-add`,children:`+${kS(n.added)}`})]})]},n.address)})}),bO=({intro:e,facts:t,onFold:n})=>(0,K.jsxs)(`div`,{className:`flex flex-col gap-3.5 border-s border-border ps-5 max-md:border-s-0 max-md:border-t max-md:ps-0 max-md:pt-4`,children:[e.howTo.length===0?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`m-0 mb-1 text-xs text-subtle`,children:`How to read it`}),e.howTo.map(e=>(0,K.jsx)(`p`,{className:`m-0 text-sm text-foreground max-md:text-base`,children:(0,K.jsx)(nE,{isChipped:!0,text:e})},e))]}),(0,K.jsxs)(`p`,{className:`m-0 grid gap-0.75 text-xs text-muted-foreground tabular-nums`,children:[(0,K.jsxs)(`span`,{children:[`${String(t.count)} files · `,(0,K.jsx)(`span`,{className:`text-sign-add`,children:`+${kS(t.added)}`})]}),(0,K.jsx)(`span`,{children:t.detail})]}),(0,K.jsx)(`button`,{className:`inline-flex h-7.5 press items-center self-start rounded-md bg-foreground/9 px-3 text-ui font-medium hover:bg-foreground/14 max-md:h-12 max-md:justify-center max-md:self-stretch max-md:text-base`,onClick:n,type:`button`,children:`Got it`})]}),xO=e=>(0,K.jsxs)(`section`,{"aria-label":`Layer ${e.address} intro`,className:`mx-5 mt-4 layer-intro animate-enter rounded-xl border border-border bg-wash px-5 pt-4.5 pb-4 max-md:mx-3 max-md:mt-3 max-md:p-4`,children:[(0,K.jsxs)(`div`,{className:`grid max-w-155 content-start gap-2`,children:[(0,K.jsx)(`p`,{className:`m-0 text-xs text-subtle tabular-nums`,children:e.eyebrow}),(0,K.jsx)(`h2`,{className:`m-0 text-lg font-semibold tracking-tight text-balance`,children:e.title.replace(oO,``)}),(0,K.jsx)(`p`,{className:`m-0 mb-0.5 text-base text-foreground max-md:text-base`,children:(0,K.jsx)(nE,{isChipped:!0,text:e.intro.lead})}),e.children]}),(0,K.jsx)(bO,{facts:e.facts,intro:e.intro,onFold:e.onFold})]}),SO=({address:e,title:t,lead:n,onOpen:r})=>(0,K.jsx)(`div`,{className:`px-5 pt-3 max-md:px-3`,children:(0,K.jsxs)(`button`,{className:`flex h-9 w-full items-center gap-2.5 rounded-lg border border-border bg-wash px-3 text-start text-ui text-muted-foreground hover:bg-row-hover hover:text-foreground max-md:h-11`,onClick:r,type:`button`,children:[(0,K.jsx)(`span`,{className:`font-mono text-xs text-subtle`,children:e}),(0,K.jsx)(`b`,{className:`font-medium whitespace-nowrap text-foreground`,children:t.replace(oO,``).split(`:`)[0]}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),(0,K.jsx)(`span`,{className:`text-xs whitespace-nowrap text-subtle`,children:`Show intro`})]})}),CO=e=>`${e.after?`After`:`Before`} line ${String(e.line)}`,wO=({notes:e})=>(0,K.jsx)(`aside`,{"aria-label":`Note on this file`,className:`mx-5 mt-3 grid file-note animate-enter gap-2 rounded-lg bg-foreground/4.5 px-4 pt-3 pb-3.25 max-md:mx-3`,children:e.map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`m-0 mb-1 flex items-center gap-1.5 font-mono text-2xs text-subtle`,children:[(0,K.jsx)(rE,{className:`size-3 shrink-0`}),CO(e)]}),(0,K.jsx)(`p`,{className:`m-0 max-w-160 text-sm text-pretty max-md:text-base`,children:(0,K.jsx)(nE,{isChipped:!0,text:YT(e.markdown.trim())})})]},`${String(e.line)}:${String(e.after)}:${e.markdown}`))}),TO=(e,t)=>{let n=t.isLayered?vw(t.cursor):null,r=n===null?void 0:e.layers[n];return r===void 0||r.isRemainder||n===null?null:{index:n,layer:r}},EO=({block:e,layer:t})=>{let{introsFolded:n}=Un(),r=QT(t),i=sO(e,t);return r===null?null:gO(e,t,n)||n.includes(i)?(0,K.jsx)(SO,{address:t.address,lead:r.lead,onOpen:()=>{_O(e,t)},title:t.title}):(0,K.jsx)(xO,{address:t.address,eyebrow:hO(e,t),facts:pO(e,t),intro:r,onFold:()=>{zn(i,!0)},title:t.title,children:(0,K.jsx)(vO,{points:r.points})})},DO=({block:e,ticket:t,path:n})=>{let{introsFolded:r}=Un(),i=ZT(t.note,n),a=cO(e,t);return i===null?null:r.includes(a)?(0,K.jsx)(SO,{address:t.address,lead:i.lead,onOpen:()=>{zn(a,!1)},title:t.title}):(0,K.jsxs)(xO,{address:t.address,eyebrow:`Layer ${t.address} of ${String(e.topLevel)} · ${String(t.sublayers)} parts`,facts:{count:t.files.length,added:t.added,detail:mO(t)},intro:i,onFold:()=>{zn(a,!0)},title:t.title,children:[(0,K.jsx)(vO,{points:i.points}),(0,K.jsx)(yO,{block:e,ticket:t})]})},OO=({block:e,layer:t,path:n})=>{let r=lO(e,t),i=r!==void 0&&dO(e,r)?.layer===t;return(0,K.jsxs)(K.Fragment,{children:[i?(0,K.jsx)(DO,{block:e,path:n,ticket:r}):null,(0,K.jsx)(EO,{block:e,layer:t})]})},kO=({block:e,state:t,path:n})=>{let{isNoted:r}=Un(),i=TO(e,t),a=i===null?[]:$T(i.layer,n);return!r||i===null?null:(0,K.jsxs)(K.Fragment,{children:[uO(e,i.layer)===n?(0,K.jsx)(OO,{block:e,layer:i.layer,path:n}):null,a.length===0?null:(0,K.jsx)(wO,{notes:a})]})},AO=({block:e,index:t,selected:n,onPickFile:r})=>{let{isNoted:i,introsFolded:a}=Un(),o=e.layers[t],s=o===void 0?void 0:uO(e,o),c=o!==void 0&&i&&!a.includes(sO(e,o))&&!gO(e,o,a)&&n===s;return(0,K.jsx)(iE,{intro:o===void 0?null:QT(o),isIntroShown:c,isPart:(o?.ticket??null)!==null,onOpenIntro:()=>{o!==void 0&&s!==void 0&&(_O(e,o),In({isNoted:!0}),r(hw(t,s),s))}})},jO=({block:e,ticket:t,selected:n,onPickFile:r})=>{let{isNoted:i,introsFolded:a}=Un(),o=dO(e,t),s=o===null?void 0:uO(e,o.layer),c=cO(e,t);return(0,K.jsx)(iE,{intro:ZT(t.note,s??``),isIntroShown:i&&!a.includes(c)&&n===s,onOpenIntro:()=>{o!==null&&s!==void 0&&(zn(c,!1),In({isNoted:!0}),r(hw(o.index,s),s))}})},MO=[{side:`old`,label:`Before`},{side:`new`,label:`After`}],NO=(e,t)=>{let n=new URLSearchParams({point:e.point,branch:e.block.branch,side:t,file:t===`old`?e.file.previousPath:e.file.path,sha:t===`old`?e.block.base.sha:e.block.head.sha});return`/decks/${encodeURIComponent(e.deck)}/review-image?${n.toString()}`},PO=e=>{let{image:t}=e.file;if(t===null)return null;let n=MO.filter(({side:e})=>t[e]);return(0,K.jsx)(`div`,{className:`mb-3 grid gap-3 rounded-md border border-border p-3 sm:grid-cols-2`,children:n.map(({side:t,label:n})=>(0,K.jsxs)(`figure`,{className:`m-0 grid content-start gap-1.5`,children:[(0,K.jsx)(`figcaption`,{className:`text-xs text-subtle`,children:n}),(0,K.jsx)(`img`,{alt:`${e.file.path}, ${n.toLowerCase()}`,className:`max-h-80 max-w-full justify-self-start rounded-sm bg-shot object-contain`,src:NO(e,t)})]},t))})},FO=({path:e,view:t,getSince:n,cursor:r})=>{let i=r===null?null:vw(r),a=n(e),o=a!==void 0&&GC(a,i)?a:void 0;return o===void 0?null:(0,K.jsx)(aO,{mode:t.modeOf(e),onMode:n=>{t.setMode(e,n)},since:o})},IO=/`(?<code>[^`]+)`|\[(?<label>[^\]]+)\]\((?<url>https?:\/\/[^)\s]+)\)|\*(?<em>[^*\s][^*]*)\*/gu,LO=(e,t)=>{let{code:n,label:r,url:i,em:a}=e;return n===void 0?i===void 0?(0,K.jsx)(`em`,{children:a},t):(0,K.jsx)(`a`,{className:`text-claude hover:underline`,href:i,rel:`noreferrer`,target:`_blank`,children:r},t):(0,K.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono`,children:n},t)},RO=({text:e})=>{let t=[...e.matchAll(IO)];return t.length===0?e:t.flatMap((n,r)=>{let i=t[r-1],a=i===void 0?0:i.index+i[0].length,o=n.index+n[0].length,s=[e.slice(a,n.index),LO(n.groups??{},o)];return r===t.length-1&&s.push(e.slice(o)),s})},zO=e=>e.split(/\n\s*\n/u).map(e=>e.replaceAll(/\s*\n\s*/gu,` `).trim()).filter(e=>e!==``),BO=({text:e})=>zO(e).map(e=>(0,K.jsx)(`p`,{className:`m-0`,children:(0,K.jsx)(RO,{text:e})},e)),VO=({tag:e})=>{if(e.name===`example`)return(0,K.jsx)(`pre`,{className:`m-0 font-mono text-xs/5 whitespace-pre-wrap text-foreground`,children:e.text});let[t=``,...n]=e.text.split(/\s+/u),r=e.name===`param`&&t!==``;return(0,K.jsxs)(`span`,{children:[r?(0,K.jsx)(`code`,{className:`me-1.5 font-mono text-foreground`,children:t}):null,(0,K.jsx)(RO,{text:(r?n.join(` `):e.text).replaceAll(/\s*\n\s*/gu,` `)})]})},HO=({hover:e})=>{let t=e.tags.filter(e=>e.text!==``),n=e.tags.filter(e=>e.text===``);return e.documentation===``&&e.tags.length===0?null:(0,K.jsxs)(`div`,{className:`grid gap-2 border-t border-border px-3 py-2.5 text-xs/5 text-muted-foreground`,children:[e.documentation===``?null:(0,K.jsx)(BO,{text:e.documentation}),t.length===0?null:(0,K.jsx)(`dl`,{className:`m-0 grid tag-rows gap-x-3 gap-y-1`,children:t.map((e,t)=>(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`font-mono text-subtle`,children:e.name}),(0,K.jsx)(`dd`,{className:`m-0 min-w-0 wrap-break-word`,children:(0,K.jsx)(VO,{tag:e})})]},`${e.name}-${String(t)}`))}),n.length===0?null:(0,K.jsx)(`p`,{className:`m-0 flex flex-wrap gap-1`,children:n.map(e=>(0,K.jsx)(`span`,{className:`rounded-sm bg-muted px-1.5 font-mono text-2xs text-subtle`,children:e.name},e.name))})]})},UO=2,WO=e=>{let t=e.lastIndexOf(`node_modules/`);if(t===-1)return e;let n=e.slice(t+13).split(`/`),r=n[0]?.startsWith(`@`)===!0?UO:1;return`${n.slice(0,r).join(`/`)} · ${n.slice(r).join(`/`)}`},GO=({definition:e,canJump:t,onJump:n})=>{let r=`${WO(e.path)}:${String(e.line)}`;return(0,K.jsx)(`p`,{className:`m-0 truncate border-t border-border px-3 py-1.5 font-mono text-xs/5 text-subtle`,title:`${e.path}:${String(e.line)}`,children:t(e.path)?(0,K.jsx)(`button`,{className:`text-start break-all hover-text`,onClick:()=>{n(e.path,e.line)},type:`button`,children:r}):r})},KO=({hover:e,canJump:t,onJump:n})=>(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`pre`,{className:`m-0 px-3 py-2 font-mono text-xs/5 wrap-break-word whitespace-pre-wrap`,dangerouslySetInnerHTML:{__html:e.html}}),(0,K.jsx)(HO,{hover:e}),e.definition===null?null:(0,K.jsx)(GO,{canJump:t,definition:e.definition,onJump:n})]}),qO=({shown:e,isOpen:t,canJump:n,onJump:r,onEnter:i,onLeave:a,onClose:o})=>(0,K.jsx)(hn,{onOpenChange:e=>{e||o()},open:t,children:e===null?null:(0,K.jsx)(Sn,{align:`start`,anchor:e.anchor,onMouseEnter:i,onMouseLeave:a,side:`bottom`,sideOffset:4,size:`code`,children:(0,K.jsx)(KO,{canJump:n,hover:e.hover,onJump:r})})}),JO=250,YO=120,XO=4500,ZO=6,QO=e=>{clearTimeout(e.asking?.timer),e.asking?.controller.abort(),e.asking=null},$O=async(e,{point:t,signal:n,left:r=ZO})=>{let i=performance.now(),a=await e(t,n);return a===null&&performance.now()-i>=XO&&r>1&&!n.aborted?$O(e,{point:t,signal:n,left:r-1}):a},ek=()=>{let e=(0,G.useRef)({asking:null,closing:void 0});return(0,G.useEffect)(()=>{let{current:t}=e;return()=>{clearTimeout(t.closing),QO(t)}},[]),{askingKey:()=>e.current.asking?.key,stopAsking:()=>{QO(e.current)},startAsking:t=>{QO(e.current),e.current.asking=t},keepOpen:()=>{clearTimeout(e.current.closing)},closeAfter:t=>{clearTimeout(e.current.closing),e.current.closing=setTimeout(t,YO)}}},tk=e=>{let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(!1),a=ek(),o=()=>{a.closeAfter(()=>{i(!1)})},s=async(t,r)=>{try{let o=await $O(e,{point:t,signal:r.signal});!r.signal.aborted&&o!==null&&(a.keepOpen(),n({key:t.key,hover:o,anchor:t.anchor}),i(!0))}catch{i(!1)}},c=e=>{let t=new AbortController,n=setTimeout(()=>{s(e,t)},JO);a.startAsking({key:e.key,timer:n,controller:t})},l=e=>r&&e.key===t?.key;return{shown:t,isOpen:r,handleEnter:a.keepOpen,point:e=>{(e===null||e.key!==a.askingKey())&&(e!==null&&l(e)?a.keepOpen():(a.stopAsking(),o(),e!==null&&c(e)))},handleLeave:()=>{a.stopAsking(),o()},handleClose:()=>{a.stopAsking(),a.keepOpen(),i(!1)}}},nk=/\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs)$/u,rk=/[\p{ID_Start}$_][\p{ID_Continue}$]*/gu;k({deck:b(),point:b(),branch:b(),path:a(b(),g(1)),line:a(i(),h(),A(1)),column:a(i(),h(),A(0))});var ik=e=>nk.test(e),ak=(e,t)=>{let n=[...e.matchAll(rk)].map(e=>({start:e.index,end:e.index+e[0].length}));return n.find(e=>e.start<=t&&t<e.end)??n.find(e=>e.end===t)??null},ok=`.token.comment, .token.string, .token.number`,sk=({clientX:e,clientY:t})=>{let n=document.caretPositionFromPoint(e,t);return n===null?null:{node:n.offsetNode,offset:n.offset}},ck=e=>{let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[];for(let e=t.nextNode();e!==null;e=t.nextNode())e instanceof Text&&n.push(e);return n},lk=(e,t)=>{let n=t.node instanceof Text?e.indexOf(t.node):-1;return n===-1?null:e.slice(0,n).reduce((e,t)=>e+t.length,0)+t.offset},uk=(e,t)=>{let n=t;for(let t of e){if(n<=t.length)return{node:t,at:n};n-=t.length}return null},dk=(e,{start:t,end:n})=>{let r=uk(e,t),i=uk(e,n);if(r===null||i===null)return null;let a=document.createRange();return a.setStart(r.node,r.at),a.setEnd(i.node,i.at),a},fk=(e,{clientX:t,clientY:n})=>[...e.getClientRects()].some(e=>t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom),pk=(e,t)=>{let n=sk(t);if(n===null||n.node.parentElement?.closest(ok)!==null)return null;let r=ck(e),i=lk(r,n),a=i===null?null:ak(e.textContent,i),o=a===null?null:dk(r,a);return a===null||o===null||!fk(o,t)?null:{word:a,range:o}},mk=(e,{line:t,pointer:n})=>{let r=pk(e,n);return r===null?null:{key:`${String(t)}:${String(r.word.start)}`,line:t,column:r.word.start,anchor:{getBoundingClientRect:()=>r.range.getBoundingClientRect(),contextElement:e}}},hk=u({method:`GET`}).handler(p(`81aea6d919e4c199dc875a22e9a9e4ad10e816bce0e36d084895c08d36390b40`)),gk=(e,t)=>{let n=e.target instanceof Element?e.target.closest(`[data-code]`):null,r=n?.closest(`[data-review-row]`)?.dataset.reviewRow,i=r===void 0?void 0:t.rows[Number(r)];return n===null||i===void 0||i.op===`del`||i.new===null?null:{code:n,line:i.new}},_k=({deck:e,point:t,branch:n,file:r})=>{let i=tk((i,a)=>hk({data:{deck:e,point:t,branch:n,path:r?.path??``,line:i.line,column:i.column},signal:a})),a=r!==void 0&&r.newSha!==null&&ik(r.path);return{hover:i,handleMove:e=>{if(!(e.target instanceof Node)||!e.currentTarget.contains(e.target))return;let t=a&&e.buttons===0?gk(e,r):null;i.point(t===null?null:mk(t.code,{line:t.line,pointer:e}))}}},vk=[],yk={op:`gap`,old:null,new:null,code:``,html:``},bk=e=>e.op===`add`||e.op===`del`,xk=e=>e?.new??e?.old??0,Sk=(e,t)=>{let n=xk(t);return t.op!==`gap`&&n>=e[0]&&n<=e[1]},Ck=(e,t)=>{let[n]=t.layers??[],r=n===void 0?void 0:e[n-1];return r===void 0||r.isRemainder||n===void 0?null:{layer:r.address,title:r.title}},wk=(e,{index:t,rows:n,runs:r=vk,isAllShown:i=!1})=>{let a=e=>e.layers?.includes(t+1)===!0;return!n.some(e=>a(e))||n.every(e=>!bk(e)||a(e))?void 0:{key:`${String(t)}|${i?`all`:r.flat().join(`,`)}`,isMine:a,isQuiet:e=>bk(e)&&!a(e)&&(i||e.quietIn?.includes(t+1)===!0),runOf:e=>r.find(t=>Sk(t,e)),said:t=>{let n=Ck(e,t);return n===null?`that no layer claims`:`from layer ${n.layer}`},quietOf:t=>{let n=Ck(e,t);return{layer:n?.layer??null,title:n?.title??`No layer claims these lines`,place:`one`}}}},Tk=(e,t)=>e!==void 0&&bk(t)&&!e.isMine(t)&&!e.isQuiet(t)&&e.runOf(t)===void 0,Ek=(e,t,n)=>{let[r]=e,i=e.length===1?`line`:`lines`,a=[xk(r),xk(e.at(-1))];return{...yk,code:`${String(e.length)} ${i} ${r===void 0?``:t.said(r)}`,others:{range:a,count:e.length,isOpen:n}}},Dk=(e,t)=>t===void 0||!bk(e)||t.isMine(e)||!t.isQuiet(e)&&t.runOf(e)===void 0?e:{...e,quiet:t.quietOf(e)},Ok=(e,{row:t,rows:n,claim:r})=>{let i=r.runOf(t),a=e.at(-1);if(i===void 0||a!==void 0&&r.runOf(a)===i)return;let o=n.filter(e=>bk(e)&&Sk(i,e)&&!r.isMine(e));e.push({...Ek(o,r,!0),others:{range:i,count:o.length,isOpen:!0}})},kk=(e,t)=>{let n=e.at(-1),{quiet:r}=t;if(r===void 0||n?.others?.isOpen!==!0&&n?.quiet?.layer!==r.layer)e.push(t);else{if(n.quiet!==void 0){let t=n.quiet.place===`one`?`top`:`mid`;e[e.length-1]={...n,quiet:{...n.quiet,place:t}}}e.push({...t,quiet:{...r,place:`end`}})}},Ak=(e,{row:t,rows:n,claim:r})=>{r!==void 0&&Ok(e,{row:t,rows:n,claim:r}),kk(e,Dk(t,r))},jk=(e,t)=>e.some(([e,n])=>e===t[0]&&n===t[1])?e.filter(([e,n])=>e!==t[0]||n!==t[1]):[...e,t],Mk=[3,10,25,60],Nk=[],Pk=(e,t)=>t.op===`ctx`&&t.new!==null&&e.some(([e,n])=>t.new!==null&&t.new>=e&&t.new<=n),Fk=(e,{context:t,isShown:n})=>{let r=e.map(()=>!1),i=-1/0;e.forEach((e,a)=>{i=n(e)?a:i,r[a]=a-i<=t});let a=1/0;for(let i=e.length-1;i>=0;--i)a=n(e[i]??yk)?i:a,r[i]=r[i]===!0||a-i<=t;return r},Ik=(e,t)=>{let n=e[0]?.new,r=e.at(-1)?.new;return n==null||r==null?yk:{...yk,fold:{first:n,last:r,count:e.length,...t}}},Lk=(e,{claim:t,isTop:n,isBottom:r})=>{let i=e.filter(e=>bk(e)),[a]=i;return a===void 0?Ik(e,{isTop:n,isBottom:r}):t===void 0?yk:Ek(i,t,!1)},Rk=(e,{context:t,claim:n,opened:r})=>{let i=Fk(e,{context:t,isShown:e=>bk(e)&&!Tk(n,e)}),a=[],o=[],s=e=>{a.push(Lk(o,{claim:n,isTop:a.length===0,isBottom:e})),o=[]};return e.forEach((t,c)=>{i[c]!==!0&&!Pk(r,t)||Tk(n,t)?o.push(t):(o.length>0&&s(!1),Ak(a,{row:t,rows:e,claim:n}))}),o.length>0&&s(!0),a},zk=new WeakMap,Bk=(e,t,{claim:n,opened:r=Nk}={})=>{if(t===`whole`)return e;let i=zk.get(e)??new Map,a=`${String(t)}|${n?.key??``}|${r.flat().join(`,`)}`,o=i.get(a)??Rk(e,{context:t,claim:n,opened:r});return i.set(a,o),zk.set(e,i),o},Vk=(e,{context:t,layers:n,cursor:r,opened:i,runs:a=vk,isAllShown:o=!1})=>{let s=r===null?null:vw(r),c=s===null?void 0:wk(n,{index:s,rows:e.rows,runs:a,isAllShown:o});return Bk(e.rows,t,{claim:c,opened:i})},Hk=10,Uk=e=>{let t=e?.fold;return t===void 0?null:t.count<=Hk?[t.first,t.last]:t.isTop?[t.last-Hk+1,t.last]:[t.first,t.first+Hk-1]},Wk=(e,{path:t,range:n})=>({...e,[t]:[...e[t]??Nk,n]}),Gk=(e,t)=>{let n=[...Mk,`whole`],r=Math.max(0,n.indexOf(e));return n[Math.min(n.length-1,Math.max(0,r+t))]??e},Kk=({state:e,setState:t})=>(0,G.useCallback)(({range:n,index:r,isWhole:i})=>{let a=n[1]-n[0]+1,o=i?a-1:a;t({...e,opened:Wk(e.opened,{path:e.selected,range:n}),row:e.row>r?e.row+o:e.row})},[e,t]),qk=(e,{range:t,index:n,count:r,isOpen:i})=>{let a=jk(e.runs[e.selected]??[],t),o=e.row>n+(i?r:0),s=i&&e.row>n?n:e.row;return{...e,runs:{...e.runs,[e.selected]:a},row:o?e.row+(i?-r:r):s}},Jk=({state:e,setState:t})=>(0,G.useCallback)(n=>{t(qk(e,n))},[e,t]),Yk=e=>({openFold:Kk(e),toggleRun:Jk(e)}),Xk=new WeakMap,Zk=e=>{if(e.file===void 0)return[];let t=Xk.get(e.file.rows)??new Map,n=`${e.worktree??``}|${e.file.path}|${e.file.status}|${e.editor}`,r=t.get(n)??Uy(e);return t.set(n,r),Xk.set(e.file.rows,t),r},Qk=(e,t)=>{let n=e.state.isLayered?vw(e.state.cursor):null,r=(n===null?[]:e.block.layers[n]?.parts??[]).find(e=>e.path===t.path),i=r===void 0||t.isSince===!0?t:r;return{added:i.added,removed:i.removed}},$k=(e,t)=>{let[n,r]=e?.split(`#`)??[];return n===t&&r!==void 0?Number(r):null},eA=(e,t,n)=>{let r=xy(e),i=t?.path??``,a=(0,G.useCallback)(e=>{let{state:t,setState:n}=r.current;n(e===null?{...t,settledAt:null}:{...t,settledAt:`${i}#${String(e)}`,focus:`diff`,row:e,anchor:null})},[r,i]);return{count:n,openRow:$k(e.state.settledAt,i),onOpen:a}},tA=(e,t)=>{let{editor:n}=Un(),r=eA(e,t,e.block.fileMarks.find(e=>e.path===t?.path)?.settled??0);return{counts:t===void 0?{added:0,removed:0}:Qk(e,t),editorLinks:Zk({worktree:e.block.worktree,file:t,editor:n}),editorFolder:zy(e.block.worktree,n),settled:r,lineMarks:Pb({lineMarks:e.block.lineMarks,threads:e.block.threads,drafts:e.extras.drafts,path:t?.path??``,rows:t?.rows??[],layer:e.state.isLayered?vw(e.state.cursor):null})}},nA=(e,t)=>{let n=(0,G.useRef)(t);(0,G.useEffect)(()=>{n.current=t}),(0,G.useEffect)(()=>{e!==``&&n.current()},[e])},rA=({lines:e,htmlOf:t,opOf:n,oldOf:r,onPick:i,panRef:a})=>e.length===0?null:(0,K.jsx)(`nav`,{"aria-label":`Scope`,className:`scope-stack font-mono code-size`,"data-review-scope":!0,ref:a,children:(0,K.jsx)(`div`,{className:`flex w-max min-w-full flex-col-reverse`,children:e.toReversed().map((e,a)=>(0,K.jsxs)(`button`,{className:`scope-line diff-row text-start`,"data-scope-depth":e.depth,"data-scope-last":a===0||void 0,"data-scope-line":e.line,"data-scope-op":n(e.line),onClick:()=>{i(e.line)},title:`Go to line ${String(e.line)}`,type:`button`,children:[(0,K.jsx)(`span`,{className:`diff-sticky diff-at-lead`}),(0,K.jsx)(`span`,{className:`diff-sticky diff-at-old pe-2 text-end text-subtle tabular-nums`,children:r(e.line)}),(0,K.jsx)(`span`,{className:`diff-sticky diff-at-new pe-2 text-end text-subtle tabular-nums`,children:e.line}),(0,K.jsx)(`span`,{className:`diff-sticky diff-at-sign`}),(0,K.jsxs)(`span`,{className:`pe-4 whitespace-pre pre-tab`,children:[(0,K.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t(e.line)}}),e.isElided?(0,K.jsx)(`span`,{className:`text-subtle`,children:` ⋯`}):null]})]},e.line))})}),iA=2,aA=(e,t)=>{let n=e.slice(t).find(e=>e.new!==null);return n===void 0?e.slice(0,t).findLast(e=>e.new!==null)?.new??null:n.new},oA=(e,t)=>{let n=[];if(t<=1||t>e.length)return n;for(let r=e[t-1]??0;r>0;r=e[r-1]??0)n.unshift(r);return n},sA=(e,t)=>{let n=e.map((e,t)=>({line:e,depth:t,isElided:!1}));if(n.length<=t||t<iA)return n.slice(0,t);let[r]=n;return r===void 0?[]:[{...r,isElided:!0},...n.slice(n.length-(t-1))]},cA=(e,t,n)=>{if(t===n)return!0;for(let r=e[t-1]??0;r>0;r=e[r-1]??0)if(r===n)return!0;return!1},lA=e=>new Set(e.filter(e=>e>0)),uA=(e,t,n)=>t.has(n)?[...oA(e,n),n]:oA(e,n),dA=`[data-review-row]`,fA=`[data-review-head]`,pA=`[data-scope-line]`,mA=1,hA=2,gA=32,_A=50,vA={lines:[],push:0,height:0},yA=e=>[...e.querySelectorAll(dA)],bA=e=>Number(e.dataset.reviewRow??``),xA=e=>{let t=e.querySelector(fA),n=(t??e).getBoundingClientRect();return t===null?n.top:n.bottom},SA=(e,t)=>{let n=e.querySelector(pA);if(n!==null)return n.getBoundingClientRect().height;let r=t.slice(0,_A).map(e=>e.getBoundingClientRect().height);return r.length===0?0:Math.min(...r)},CA=(e,t,n)=>{let r=lA(e.enclosedBy),i=new Map;return t.forEach((t,a)=>{let o=e.rows[bA(t)]?.new??null;o!==null&&uA(e.enclosedBy,r,o).forEach(e=>{i.has(e)||i.set(e,n[a]??0)})}),i},wA=({container:e,grid:t},n)=>{let r=yA(t),i=t.getBoundingClientRect().top,a=lA(n.enclosedBy),o=r.map(e=>e.getBoundingClientRect()),s=o.map(e=>e.top-i);return{tops:s,bottoms:o.map(e=>e.bottom-i),lines:r.map(e=>aA(n.rows,bA(e))),openers:r.map(e=>{let t=n.rows[bA(e)]?.new??null;return t!==null&&a.has(t)}),firstTops:CA(n,r,s),lineHeight:SA(e,r)}},TA=(e,t,n)=>{let r=0,i=e;for(;r<i;){let e=Math.floor((r+i)/hA),a=t(e)>n;r=a?r:e+1,i=a?e:i}return r},EA=(e,t,{row:n,top:r})=>{let i=e.lines[n]??null;if(i===null)return[];let a=oA(t.enclosedBy,i);return(e.openers[n]??!1)&&(e.tops[n]??0)<r-mA?[...a,i]:a},DA=(e,t)=>t.every((t,n)=>e[n]===t),OA=e=>Math.min(e,3),kA=(e,t,{top:n,depth:r})=>{let i=n+OA(r)*e.lineHeight,a=TA(e.bottoms.length,t=>e.bottoms[t]??0,i);return{row:a,slotTop:i,chain:EA(e,t,{row:a,top:i})}},AA=(e,t,n)=>(e.firstTops.get(t)??1/0)<n-mA,jA=(e,t,n)=>{let r=[],i=0;for(let a=0;a<gA;a+=1){let{row:o,slotTop:s,chain:c}=kA(e,t,{top:n,depth:a}),l=c[a];if(l===void 0||!DA(c,r)||!AA(e,l,s))break;r.push(l),i=o}return{pinned:r,probe:i}},MA=(e,t,{scope:n,from:r,bottom:i})=>{for(let a=r;a<e.tops.length&&(e.tops[a]??0)<i;a+=1){let r=e.lines[a]??null;if(r!==null&&!cA(t.enclosedBy,r,n))return Math.min(0,(e.tops[a]??0)-i)}return 0},NA=(e,t,n)=>{if(t.enclosedBy.length===0||e.lineHeight===0)return vA;let{pinned:r,probe:i}=jA(e,t,n),a=r.at(-1);if(a===void 0)return vA;let o=sA(r,4),s=o.length*e.lineHeight;return{lines:o,push:MA(e,t,{scope:a,from:i,bottom:n+s}),height:s}},PA=(e,t)=>xA(e)-t.getBoundingClientRect().top,FA=e=>Math.max(xA(e),...[...e.querySelectorAll(pA)].map(e=>e.getBoundingClientRect().bottom)),IA=e=>{let t=yA(e);return t[TA(t.length,e=>t[e]?.getBoundingClientRect().bottom??0,FA(e)+mA)]??null},LA=e=>e.map(e=>`${String(e.line)}${e.isElided?`+`:``}`).join(`,`),RA=(e,t)=>LA(e)===LA(t),zA=(e,t,n)=>{let r=lA(t.enclosedBy);return new Set(e.flatMap(e=>{let i=bA(e)<n?t.rows[bA(e)]?.new??null:null;return i===null?[]:uA(t.enclosedBy,r,i)}))},BA=(e,t,n)=>{let r=aA(t.rows,n);if(!Vn().isScoped||t.enclosedBy.length===0||r===null)return 0;let i=yA(e),a=zA(i,t,n);return sA(oA(t.enclosedBy,r).filter(e=>a.has(e)),4).length*SA(e,i)},VA=(e,t,n)=>{let r=e.querySelector(`[data-review-row="${String(n)}"]`);r!==null&&(e.scrollTop+=Math.floor(r.getBoundingClientRect().top-xA(e)-BA(e,t,n)))},HA=e=>e.querySelector(fA)?.getBoundingClientRect().height??0,UA=()=>{},WA=(e,t)=>{let n=(0,G.useRef)(t),r=(0,G.useRef)(null),i=(0,G.useRef)(()=>{r.current??=requestAnimationFrame(()=>{r.current=null,n.current()})});return(0,G.useEffect)(()=>{n.current=t,i.current()}),(0,G.useEffect)(()=>{if(e===null)return UA;let t=i.current;e.addEventListener(`scroll`,t,{passive:!0});let n=new ResizeObserver(t);return n.observe(e),()=>{e.removeEventListener(`scroll`,t),n.disconnect(),r.current!==null&&(cancelAnimationFrame(r.current),r.current=null)}},[e]),()=>{i.current()}},GA=()=>{},KA=(e,t)=>{let n=(0,G.useRef)(t);(0,G.useEffect)(()=>{n.current=t}),(0,G.useEffect)(()=>{if(e===null)return GA;let t=new ResizeObserver(()=>{n.current()});return t.observe(e),()=>{t.disconnect()}},[e])},qA=`[data-scope-line]`,JA=`[data-scope-last]`,YA=(e,t)=>{let n=[...e.querySelectorAll(qA)],r=e.querySelector(JA);n.forEach(e=>{let n=e===r&&t<0?`translateY(${String(t)}px)`:``;e.style.transform!==n&&(e.style.transform=n)})},XA=(e,t)=>{let n=`${String(Math.round(HA(e)+t))}px`;e.style.scrollPaddingTop!==n&&(e.style.scrollPaddingTop=n)},ZA=(e,t)=>{let n=(0,G.useRef)(null),r=(0,G.useRef)(!0);return{markDirty:()=>{r.current=!0},read:()=>{if(e===null||!t)return vA;let i={rows:e.file.rows,enclosedBy:e.file.enclosedBy};return(r.current||n.current?.key!==e.file.fingerprint)&&(n.current={key:e.file.fingerprint,value:wA({container:e.container,grid:e.grid},i)},r.current=!1),NA(n.current.value,i,PA(e.container,e.grid))}}},QA=(e,{grid:t,file:n})=>{let{isScoped:r}=Un(),[i,a]=(0,G.useState)([]),o=(0,G.useRef)([]),s=ZA(e===null||t===null||n===void 0?null:{container:e,grid:t,file:n},r),c=WA(e,()=>{if(e===null)return;let t=s.read();RA(t.lines,o.current)||(o.current=t.lines,(0,xa.flushSync)(()=>{a(t.lines)})),YA(e,t.push),XA(e,t.height)});return KA(t,()=>{s.markDirty(),c()}),i},$A=({props:e,file:t,container:n})=>{let{state:r,setState:i}=e,[a,o]=(0,G.useState)(null),s=t?.rows??[],c=a===null?-1:s.findIndex(e=>e.new===a),l=`${t?.fingerprint??``}|${String(r.context)}|${String(r.isWrapped)}`;return nA(c===-1?``:`${String(a)}|${l}`,()=>{n!==null&&t!==void 0&&VA(n,t,c),o(null)}),e=>{o(e),!s.some(t=>t.new===e)&&r.context!==`whole`&&i({...r,context:`whole`})}},ej=()=>{let e=(0,G.useRef)({node:null,left:0});return{panRef:(0,G.useCallback)(t=>{e.current.node=t,t!==null&&(t.scrollLeft=e.current.left)},[]),handleCodeScroll:t=>{e.current.left=t,e.current.node!==null&&(e.current.node.scrollLeft=t)}}},tj=e=>{let t=new WeakMap;return n=>{let r=n?.rows??[],i=t.get(r);if(i!==void 0)return i;let a=new Map(r.flatMap(t=>t.new===null?[]:[[t.new,e(t)]]));return t.set(r,a),a}},nj=tj(e=>e.html),rj=tj(e=>e.op),ij=tj(e=>e.old),aj=({props:e,file:t,whole:n})=>{let[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(null),s=QA(r,{grid:a,file:t}),c=$A({props:e,file:t,whole:n,container:r}),{panRef:l,handleCodeScroll:u}=ej(),d=nj(n),f=rj(t),p=ij(n);return{setContainer:i,setGrid:o,handleCodeScroll:u,stack:(0,K.jsx)(rA,{htmlOf:e=>d.get(e)??``,lines:s,oldOf:e=>p.get(e)??null,onPick:c,opOf:e=>f.get(e)??`ctx`,panRef:l})}},oj=({failure:e,onDismiss:t})=>e===null?null:(0,K.jsxs)(`p`,{className:`m-0 flex items-start justify-between gap-3 border-b border-border px-3 py-2 text-sm text-destructive`,role:`alert`,children:[(0,K.jsx)(`span`,{children:e}),(0,K.jsx)(`button`,{className:`shrink-0 text-subtle hover:text-foreground`,onClick:t,type:`button`,children:`Dismiss`})]}),sj=({from:e})=>e.map((e,t)=>e.failure===null?null:(0,K.jsx)(oj,{failure:e.failure,onDismiss:e.handleDismissFailure},`${String(t)}:${e.failure}`)),cj={added:`New file`,modified:`Changed`,deleted:`Deleted file`,renamed:`Renamed`,copied:`Copied`},lj=({file:e,counts:t})=>(0,K.jsxs)(`p`,{className:`m-0 flex gap-2 px-4 pt-1 pb-2.5 text-ui text-muted-foreground tabular-nums md:hidden`,children:[(0,K.jsx)(`span`,{className:`font-mono text-sign-add`,children:`+${String(t.added)}`}),t.removed>0?(0,K.jsx)(`span`,{className:`font-mono text-sign-del`,children:`−${String(t.removed)}`}):null,(0,K.jsx)(`span`,{children:cj[e.status]})]}),uj=({file:e})=>(e.status===`renamed`||e.status===`copied`)&&e.added===0&&e.removed===0?(0,K.jsxs)(`p`,{className:`m-0 px-5 py-4 text-sm text-muted-foreground max-md:px-4`,children:[`${e.status===`renamed`?`Moved`:`Copied`} from `,(0,K.jsx)(`code`,{className:`font-mono text-foreground`,children:e.previousPath}),` with no changes: git paired the two files because their content is the same.`]}):null,dj=({block:e,file:t,state:n})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(kO,{block:e,path:t.path,state:n}),(0,K.jsx)(uj,{file:t})]}),fj=({props:e,file:t,marks:n})=>(0,K.jsx)(FO,{cursor:e.state.isLayered?e.state.cursor:null,getSince:n.getSince,path:t.path,view:e.sinceView}),pj=({props:e,file:t,whole:n,comments:r,marks:i,acts:a,selection:o,jump:s,headActions:c})=>{let{block:l,deck:u,view:d,state:f}=e,p=_k({deck:u,point:d.id,branch:l.branch,file:t}),m=aj({props:e,file:t,whole:n}),{editorFolder:h,counts:g,..._}=tA(e,t),{openFold:v,toggleRun:y}=Yk(e),b=t!==void 0&&o!==null&&e.isFileLoaded(t.path);return(0,K.jsx)(`div`,{className:`min-h-0 min-w-0 review-diff`,"data-editor-folder":h??void 0,"data-review-diff":!0,ref:n=>{m.setContainer(n),n!==null&&b&&e.onDiffShown(n,t)},children:b?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(sj,{from:[r,i,a]}),(0,K.jsx)(fj,{file:t,marks:i,props:e}),(0,K.jsx)(lj,{counts:g,file:t}),(0,K.jsx)(PO,{block:l,deck:u,file:t,point:d.id}),(0,K.jsx)(`div`,{onMouseLeave:p.hover.handleLeave,onMouseMove:p.handleMove,children:(0,K.jsx)(US,{..._,headActions:c,isFramed:!1,lead:(0,K.jsx)(dj,{block:l,file:t,state:f}),counts:g,onOpenFold:v,onToggleRun:y,actions:r.actions,deck:u,file:t,onCodeScroll:m.handleCodeScroll,rowsRef:m.setGrid,scope:m.stack,live:r.live,revision:r.revision,cursorRow:f.focus===`diff`?f.row:null,isWrapped:f.isWrapped,selection:o})}),(0,K.jsx)(qO,{canJump:s.canJump,isOpen:p.hover.isOpen,onClose:p.hover.handleClose,onEnter:p.hover.handleEnter,onJump:(e,t)=>{p.hover.handleClose(),s.handleJump(e,t)},onLeave:p.hover.handleLeave,shown:p.hover.shown})]}):(0,K.jsx)(`p`,{className:`m-0 p-3 text-sm text-subtle`,children:l.error??(t===void 0?`No file selected`:`Reading ${t.path}…`)})},f.selected)},mj={key:`e`,keys:[`e`]},hj=({isOn:e,label:t,said:n,shortcutKey:r,onToggle:i})=>(0,K.jsx)(wn,{keys:[r],label:n,side:`bottom`,children:(0,K.jsxs)(`button`,{"aria-pressed":e,className:`group inline-flex h-6 items-center gap-1.75 rounded-md px-2 text-xs text-muted-foreground hover:bg-secondary hover:text-foreground`,"data-on":e?``:void 0,onClick:i,type:`button`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`relative h-4 w-6.5 rounded-full bg-secondary transition-colors duration-200 group-data-on:bg-sign-add`,children:(0,K.jsx)(`span`,{className:`absolute inset-s-0.5 top-0.5 size-3 rounded-full bg-muted-foreground transition-transform duration-200 ease-out group-data-on:translate-x-2.5 group-data-on:bg-white`})}),t]})}),gj=()=>{let{isNoted:e,isOthersShown:t}=Un();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(hj,{isOn:e,label:`Notes`,onToggle:Fn,said:`Layer notes over the code`,shortcutKey:`I`}),(0,K.jsx)(hj,{isOn:t,label:`Other layers`,onToggle:An,said:`Other layers' lines in place, quiet, rather than folded`,shortcutKey:`O`})]})},_j=({isReviewed:e,isLayered:t,canOpen:n,onPress:r})=>(0,K.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 font-sans`,children:[t?(0,K.jsx)(gj,{}):null,(0,K.jsx)(wn,{keys:[`m`],side:`bottom`,children:(0,K.jsxs)(`button`,{"aria-pressed":e,className:`inline-flex h-6 press items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground hover:bg-secondary hover:text-foreground aria-pressed:text-success`,onClick:()=>{r(`m`)},type:`button`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:W(`grid size-3.25 place-items-center rounded-sm border transition-colors duration-150`,e?`border-success bg-success text-background`:`border-input`),children:(0,K.jsx)(ar,{className:`size-2.5 icon-swap`,"data-off":e?void 0:``,strokeWidth:3})}),e?`Reviewed`:`Mark reviewed`]})}),n?(0,K.jsx)(On,{label:`Open in editor`,onClick:()=>{r(`e`)},shortcut:mj,size:`icon-xs`,children:(0,K.jsx)(Ti,{})}):null]}),vj={remarks:`Remarks`,dismissed:`Dismissed`,held:`Waiting to be sent`,asked:`Waiting on you`,filed:`Not picked up`,with:`Picked up, no answer`,answered:`Answered, not settled`,movedOn:`The branch moved past these`,settled:`Settled`,removed:`Removed`},yj=[`remarks`,`held`,`asked`,`filed`,`with`,`answered`,`movedOn`,`settled`,`removed`,`dismissed`],bj=({threads:e,remarks:t,drafts:n,isTheirs:r,pile:i})=>{let a=new Map(yj.map(e=>[e,[]]));return t.filter(e=>e.state!==`accepted`).forEach(e=>{a.get(e.state===`dismissed`?`dismissed`:`remarks`)?.push({kind:`remark`,remark:e})}),n.forEach(e=>{a.get(`held`)?.push({kind:`draft`,draft:e})}),e.forEach(e=>{a.get(i?.get(e.id)??e.section)?.push({kind:`thread`,thread:e})}),yj.flatMap(e=>{let t=a.get(e)??[],n=e===`held`&&r?`Held for the author`:vj[e];return t.length===0?[]:[{key:e,title:n,entries:t}]})},xj=e=>e.kind===`thread`?e.thread:e.kind===`remark`?e.remark:e.draft,Sj=e=>{if(e.kind===`thread`&&e.thread.isAboutBranch)return{file:``,label:`Reading order`,line:0};let t=xj(e),n=t.file.split(`/`).at(-1)??t.file,r=t.start===t.end?String(t.end):`${String(t.start)}-${String(t.end)}`;return{file:t.file,label:`${n}:${r}`,line:t.start}},Cj=e=>xj(e).body.split(`
|
|
45
|
-
`)[0]??``,
|
|
46
|
-
`)[0]??``},
|
|
47
|
-
`)[0]}),(0,K.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`${String(n)} messages`})]})},iM=e=>{let t=e.pile.map(e=>e.id),n=e.current===void 0?t.length:t.indexOf(e.current.id);return t.slice(0,n).filter(t=>!Pj(e.found.get(t)))},aM=(e,t)=>e.left===0?`Every thread is handled`:t.length>0?null:`${String(e.left)} left`,oM=({lead:e,onTurn:t})=>{let n=iM(e),r=aM(e,n);return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-1 pt-4 text-xs text-subtle`,children:[r===null?(0,K.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground`,onClick:()=>{e.pick(n[0]??null)},type:`button`,children:`${String(n.length)} skipped above`}):(0,K.jsx)(`span`,{children:r}),(0,K.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,K.jsxs)(`button`,{className:`inline-flex items-center gap-1.5 hover:text-foreground`,onClick:t,type:`button`,children:[(0,K.jsx)(tn,{children:`T`}),`goes back to the diff`]})]})},sM=e=>e.reduce((e,t)=>{let n=e.at(-1);return n?.section===t.section?n.ids.push(t.id):e.push({section:t.section,ids:[t.id]}),e},[]),cM=({onTurn:e,...t})=>{let{lead:n}=t,r=sM(n.pile),i=n.current?.id??``;nA(i,()=>{requestAnimationFrame(()=>{document.querySelector(`[data-thread-card="${CSS.escape(i)}"]`)?.scrollIntoView({block:`start`,behavior:`smooth`})})});let a=n.pile.find(e=>e.id===n.current?.id)?.section??r[0]?.section;return(0,K.jsxs)(`div`,{className:`min-h-0 min-w-0 review-diff`,"data-review-threads":!0,children:[(0,K.jsxs)(`div`,{className:`sticky top-0 z-4 flex h-11 items-center gap-2.5 border-b border-border bg-background ps-5 pe-3 text-xs`,children:[a===void 0?(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Nothing needs you`}):(0,K.jsx)(`span`,{className:W(`font-medium`,nM[a]),children:tM(a)}),(0,K.jsx)(`span`,{className:`text-subtle tabular-nums`,children:`${String(n.left)} left`}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsx)(wn,{keys:[`↵`],children:(0,K.jsx)(`button`,{className:`inline-flex h-6 items-center gap-1.5 rounded-md px-2 text-muted-foreground hover:bg-secondary hover:text-foreground disabled:opacity-50`,disabled:n.current===void 0||n.current.isAboutBranch,onClick:()=>{n.showInDiff()},type:`button`,children:`Show in the diff`})})]}),(0,K.jsxs)(`div`,{className:`grid gap-2.5 px-4 pt-3 pb-24`,children:[r.map((e,r)=>(0,K.jsxs)(`section`,{className:`grid gap-2.5`,children:[r===0?null:(0,K.jsx)(`h3`,{className:`m-0 -mx-4 mt-3 border-t border-border px-5 pt-3 pb-0.5 text-xs font-medium`,children:(0,K.jsx)(`span`,{className:nM[e.section],children:tM(e.section)})}),e.ids.map(e=>{let r=n.found.get(e);return r===void 0?null:r.isSettled?(0,K.jsx)(rM,{lead:n,thread:r},e):(0,K.jsx)($j,{...t,thread:r},e)})]},`${e.section}:${String(r)}`)),(0,K.jsx)(oM,{lead:n,onTurn:e})]})]})},lM=`inline-flex h-6 items-center gap-1.5 rounded-md px-2.5 font-medium text-muted-foreground hover:text-foreground aria-pressed:bg-secondary aria-pressed:text-foreground`,uM=({isThreads:e,left:t,onTurn:n})=>(0,K.jsx)(wn,{keys:[`T`],label:`The diff, or every thread that needs you, in the middle`,children:(0,K.jsxs)(`fieldset`,{className:`m-0 inline-flex min-w-0 shrink-0 items-center gap-0.5 rounded-lg border border-border bg-background p-0.5`,children:[(0,K.jsx)(`legend`,{className:`sr-only`,children:`What fills the middle`}),(0,K.jsx)(`button`,{"aria-pressed":!e,className:lM,onClick:e?n:void 0,type:`button`,children:`Diff`}),(0,K.jsxs)(`button`,{"aria-pressed":e,className:lM,onClick:e?void 0:n,type:`button`,children:[`Threads`,(0,K.jsx)(`span`,{className:`font-normal text-subtle tabular-nums`,children:`${String(t)} left`})]})]})}),dM=({props:e,pane:t,lead:n,onPress:r})=>{let{state:i}=e,a=n.turn;return n.isOn?(0,K.jsx)(cM,{actions:t.comments.actions,deck:e.deck,lead:n,live:t.comments.live,onTurn:a,revision:t.comments.revision}):(0,K.jsx)(pj,{acts:t.acts,comments:t.comments,file:t.file,headActions:(0,K.jsx)(_j,{canOpen:e.block.worktree!==null&&t.file?.status!==`deleted`,isLayered:i.isLayered,isReviewed:t.file!==void 0&&t.model.isReadHere(t.file.path),onPress:r}),jump:t.jump,marks:t.model.marks,props:e,selection:t.selection,whole:t.model.files.get(i.selected)})},fM=(e,t,n)=>`${String(e)} ${e===1?t:n}`,pM=e=>e.state!==`accepted`&&e.state!==`dismissed`,mM={title:`Nothing needs you`,rest:``},hM=(e,t)=>e+t===0?mM:{title:fM(e,`remark`,`remarks`),rest:t===0?``:`· ${fM(t,`note`,`notes`)} held for the author`},gM=({asked:e,unread:t})=>{let n=`${fM(t,`answer`,`answers`)} to read`;return e>0?{title:fM(e,`question`,`questions`),rest:t>0?`· ${n}`:``}:t>0?{title:n,rest:``}:mM},_M=({counts:e,remarks:t,drafts:n,isTheirs:r})=>r?hM(t.filter(e=>pM(e)).length,n.length):e===null?null:gM(e),vM=({counts:e,remarks:t,isTheirs:n})=>n?t.filter(e=>pM(e)).length:e?.asked??0,yM=({label:e,hint:t,isFilled:n=!1,onClick:r})=>{let i=(0,K.jsx)(`button`,{className:W(`inline-flex h-7 shrink-0 press items-center gap-1.5 rounded-md border px-2.5 text-xs font-medium max-md:h-11 max-md:rounded-full max-md:px-4 max-md:text-sm`,n?`border-accent bg-accent text-accent-foreground`:`border-border bg-background hover:bg-row-hover`),onClick:r,type:`button`,children:e});return t===void 0?i:(0,K.jsx)(wn,{keys:[t],children:i})},bM=({entry:e})=>{let t=Sj(e),n=Dj(e);return(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs/4.5 text-subtle max-md:text-sm/5`,children:[(0,K.jsxs)(`span`,{className:W(`truncate`,t.file===``?``:`font-mono`),title:t.file,children:[e.kind===`remark`?`${e.remark.by} · `:``,t.label]}),n===null?null:(0,K.jsx)(`span`,{className:`ms-auto shrink-0 tabular-nums`,children:(0,K.jsx)(ux,{at:n})})]})},xM=({entry:e})=>e.kind===`thread`?(0,K.jsx)(`span`,{className:W(`grid h-4.5 w-4 shrink-0 place-items-center`,Fb[e.thread.stand]),children:(0,K.jsx)(Rb,{stand:e.thread.stand})}):null,SM=({entry:e,sectionKey:t,isOn:n,onPick:r,tools:i})=>{let a=wj.has(t);return(0,K.jsxs)(`div`,{className:`group/row relative px-1.5`,children:[(0,K.jsxs)(`button`,{className:W(`flex w-full animate-enter gap-2 rounded-lg px-2 pt-2 pb-2.5 text-start transition-colors duration-150 max-md:px-3`,n?`bg-line-selected`:`group-hover/row:bg-row-hover`,a?`max-md:min-h-20`:`max-md:min-h-14`),"data-panel-entry":jj(e),onClick:r,type:`button`,children:[t===`movedOn`?(0,K.jsx)(xM,{entry:e}):null,(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,K.jsx)(bM,{entry:e}),(0,K.jsx)(`span`,{className:W(`text-ui transition-colors duration-300 max-md:text-base/6`,a?`line-clamp-2`:`line-clamp-1`,Oj(e)?`text-foreground`:`text-subtle`),children:Ej(e)})]})]}),i===void 0?null:(0,K.jsx)(`div`,{className:W(`pointer-events-none absolute inset-e-3 top-1 flex items-center gap-0.5 rounded-md opacity-0 transition-opacity duration-150 group-focus-within/row:pointer-events-auto group-focus-within/row:opacity-100 group-hover/row:pointer-events-auto group-hover/row:opacity-100 max-md:hidden`,n?`bg-line-selected`:`bg-row-hover`),children:i})]})},CM={asked:`text-stand-asked`,answered:`text-stand-answered`,filed:`text-stand-filed`,with:`text-stand-waiting`},wM=({section:e,count:t=e.entries.length,children:n})=>(0,K.jsxs)(`h3`,{className:`m-0 px-3.5 pt-5 pb-1.5 text-xs/4.5 font-medium text-muted-foreground max-md:px-5 max-md:text-sm`,children:[(0,K.jsx)(`span`,{className:CM[e.key],children:e.title}),(0,K.jsx)(`span`,{className:`ms-1.5 font-normal text-subtle tabular-nums`,children:t}),n]}),TM=(e,t)=>e.kind!==`thread`||t?.has(e.thread.id)!==!0||!Pj(e.thread)?null:Vb[e.thread.isSettled?`settled`:e.thread.stand],EM=({entry:e,isOn:t,said:n,onPick:r})=>(0,K.jsx)(`div`,{className:`px-1.5`,children:(0,K.jsxs)(`button`,{className:W(`flex h-7.5 w-full items-center gap-2 rounded-lg px-2 text-start text-xs text-subtle`,t?`bg-line-selected`:`hover:bg-row-hover`),"data-panel-entry":jj(e),onClick:r,type:`button`,children:[(0,K.jsx)(xM,{entry:e}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:Sj(e).label}),(0,K.jsx)(`span`,{className:`shrink-0`,children:n})]})}),DM=({said:e})=>e===null?null:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 px-3.5 pt-3.5 pb-1 max-md:px-5 max-md:pt-4`,children:[(0,K.jsx)(`b`,{className:`text-sm/5 font-semibold max-md:text-3xl/9 max-md:font-bold`,children:e.title}),e.rest===``?null:(0,K.jsx)(`span`,{className:`text-xs text-subtle max-md:text-base`,children:e.rest})]}),OM=[[`j k`,`move`],[`↵`,`open`],[`d`,`settle`],[`D`,`settle what is read`],[`X`,`remove`],[`esc`,`back to the diff`]],kM=()=>(0,K.jsx)(`div`,{className:`absolute inset-x-2 top-1 z-10 key-hint flex-wrap gap-x-3 gap-y-1 rounded-md border border-border bg-popover px-3 py-2 text-xs text-muted-foreground shadow-md max-md:hidden`,children:OM.map(([e,t])=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(`kbd`,{className:`font-mono`,children:e}),t]},t))}),AM=()=>(0,K.jsxs)(`div`,{className:`grid gap-1 px-4 py-7 text-ui text-muted-foreground`,children:[(0,K.jsx)(`b`,{className:`text-sm font-semibold text-foreground`,children:`No comments yet`}),`Select lines in the diff and press c to write one. Each comment you send lands here, under where it stands.`]}),jM=({remark:e,acts:t,onWrite:n})=>e.state===`dismissed`?(0,K.jsx)(yM,{label:`Restore`,onClick:()=>{t.remark(e,`restore`)}}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(yM,{isFilled:!0,label:`Accept`,onClick:()=>{t.remark(e,`accept`)}}),(0,K.jsx)(yM,{label:`Dismiss`,onClick:()=>{t.remark(e,`dismiss`)}}),(0,K.jsx)(yM,{label:`Reply`,onClick:n})]}),MM=({draft:e,acts:t,onWrite:n})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(yM,{label:`Reword`,onClick:n}),(0,K.jsx)(yM,{label:`Drop`,onClick:()=>{t.draft(e,null)}})]}),NM=({entry:e,acts:t,deck:n})=>{let[r,i]=(0,G.useState)(!1);if(e.kind===`thread`)return null;let a=()=>{i(!0)};return(0,K.jsxs)(`div`,{className:`mb-2 px-3.5`,children:[(0,K.jsx)(Cb,{isOpen:r,children:(0,K.jsx)(Xa,{deck:n,draftKey:`panel:${jj(e)}`,isFocused:!0,onCancel:()=>{i(!1)},onSubmit:async n=>{i(!1),await(e.kind===`remark`?t.remark(e.remark,`reply`,n):t.draft(e.draft,n))},placeholder:e.kind===`draft`?`Reword the note`:`Write back to the remark`,submitLabel:e.kind===`draft`?`Save`:`Reply`})}),(0,K.jsx)(Cb,{isOpen:!r,children:(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.kind===`remark`?(0,K.jsx)(jM,{acts:t,onWrite:a,remark:e.remark}):(0,K.jsx)(MM,{acts:t,draft:e.draft,onWrite:a})})})]})},PM=({label:e,onClick:t,children:n})=>(0,K.jsxs)(Gn,{children:[(0,K.jsx)(En,{render:(0,K.jsx)(`button`,{"aria-label":e,className:`grid size-6 press place-items-center rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground`,onClick:t,type:`button`}),children:n}),(0,K.jsx)(kn,{children:e})]}),FM=e=>{let{thread:t}=e;if(!Aj(e))return`Go to line ${String(t.start)}`;let n=t.file.split(`/`).at(-1)??t.file;return`Open in ${t.layerAddress===null?n:`layer ${t.layerAddress}`}, near line ${String(t.start)}`},IM=new Set([`answered`,`asked`]),LM=({entry:e,acts:t,tools:n})=>{let{thread:r}=e;return(0,K.jsxs)(K.Fragment,{children:[r.file===``?null:(0,K.jsx)(PM,{label:FM(e),onClick:()=>{n.go(r)},children:(0,K.jsx)($r,{"aria-hidden":!0,className:`size-3.5`})}),IM.has(r.stand)&&!r.isSettled?(0,K.jsx)(PM,{label:`Settle`,onClick:()=>{n.settle(r)},children:(0,K.jsx)(ar,{"aria-hidden":!0,className:`size-3.5`})}):null,(0,K.jsx)(PM,{label:`Remove`,onClick:()=>{t.remove(r)},children:(0,K.jsx)(Li,{"aria-hidden":!0,className:`size-3.5`})})]})},RM=({entry:e,acts:t,tools:n})=>e.kind===`thread`?e.thread.state===`removed`?null:(0,K.jsx)(LM,{acts:t,entry:e,tools:n}):e.kind===`draft`?(0,K.jsx)(PM,{label:`Drop`,onClick:()=>{t.draft(e.draft,null)},children:(0,K.jsx)(Li,{"aria-hidden":!0,className:`size-3.5`})}):e.remark.state===`dismissed`?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(PM,{label:`Accept`,onClick:()=>{t.remark(e.remark,`accept`)},children:(0,K.jsx)(ar,{"aria-hidden":!0,className:`size-3.5`})}),(0,K.jsx)(PM,{label:`Dismiss`,onClick:()=>{t.remark(e.remark,`dismiss`)},children:(0,K.jsx)(Vi,{"aria-hidden":!0,className:`size-3.5`})})]}),zM=e=>e.at||(e.turns[0]?.at??``),BM=(e,t)=>e.turns.find(e=>e.voice===`agent`&&e.at>=t)?.at,VM=(e,t)=>{let{seenAt:n,...r}=e;return t===void 0?r:{...r,seenAt:t}},HM=(e,{point:t,revision:n})=>{let r=zM(e);return VM({id:e.id,point:t,revision:n,path:e.file,side:e.side,start:e.start,end:e.end,code:e.snippet,body:e.body,author:`you`,parent:null,at:r,resolved:e.isSettled,stand:e.stand,doing:e.doing,isOutdated:e.isOutdated?!0:void 0},BM(e,r))},UM=e=>e.state!==`removed`&&!e.isMovedPast&&!e.isAboutBranch,WM=(e,t)=>{let n=HM(e,t);return{root:n,replies:e.turns.map((t,r)=>VM({...n,id:`${e.id}~${String(r)}`,body:t.body,author:t.voice===`agent`?`claude`:`you`,parent:e.id,at:t.at,choices:t.choices},t.voice===`agent`?void 0:BM(e,t.at)))}},GM=(e,t)=>e.flatMap(e=>{if(!UM(e))return[];let{root:n,replies:r}=WM(e,t);return[n,...r]}),KM=({point:e,live:t,block:n})=>{let r=fn(t,e),i=n.threads.filter(e=>e.isTaken).map(e=>e.id);return{revision:r,live:{...t,seen:[...t.seen,...i],comments:GM(n.threads,{point:e,revision:r})}}},qM=(e,t)=>{let{root:n,replies:r}=WM(e,t),i=new Set(r.map(e=>e.body)),a=t.comments.filter(t=>t.parent===e.id&&!i.has(t.body));return{root:n,replies:[...r,...a],isOutdated:!1}},JM=(e,t)=>{let n=e.findIndex(e=>jj(e)===t.list.cursor);return r=>{let i=e[Math.min(e.length-1,Math.max(0,n===-1?0:n+r))];i!==void 0&&t.go(i,t.list.open!==null&&Aj(i))}},YM=({flat:e,state:t})=>e.find(e=>jj(e)===t.list.cursor),XM=e=>{let t=YM(e);return t?.kind===`thread`?t.thread:null},ZM=e=>{let t=YM(e);t!==void 0&&(e.state.go(t,!0),!Aj(t)&&t.kind===`thread`&&e.props.onLeave())},QM=e=>{let t=JM(e.flat,e.state),n=XM(e),{state:r,props:i}=e;return new Map([[`j`,()=>{t(1)}],[`ArrowDown`,()=>{t(1)}],[`k`,()=>{t(-1)}],[`ArrowUp`,()=>{t(-1)}],[`Enter`,()=>{ZM(e)}],[`Escape`,()=>{r.list.open===null?i.onLeave():r.setList({...r.list,open:null})}],[`d`,()=>{n!==null&&e.settle(n)}],[`X`,()=>{n!==null&&i.acts.remove(n)}]])},$M=e=>e.metaKey||e.ctrlKey||e.altKey,eN=e=>e instanceof Element&&e.closest(`textarea, input, [contenteditable]`)!==null,tN=(e,t)=>{Ut(`keydown`,n=>{let r=e.current,i=QM(t).get(n.key);i===void 0||t.props.threads!==void 0||r?.contains(document.activeElement)!==!0||$M(n)||eN(n.target)||(n.preventDefault(),i())}),nA(`panel`,()=>{bb()||e.current?.focus({preventScroll:!0})}),nA(t.state.list.open??``,()=>{requestAnimationFrame(()=>{e.current?.querySelector(`[data-open-card]`)?.scrollIntoView({block:`nearest`,behavior:`smooth`})})})},nN=(e,t)=>qM(e,{point:t.point,revision:t.comments.revision,comments:t.comments.live.comments}),rN=e=>e.filter(e=>!Tj.has(e.key)).flatMap(e=>e.entries),iN=e=>{let[t,n]=(0,G.useState)({cursor:null,open:null,folds:{}}),[r,i]=(0,G.useState)(null),a=t=>{t.unread>0&&e.acts.read(t)},o=(e,r)=>{n({...t,cursor:r}),i({id:e.id,isReplying:!1}),a(e)},s=(r,{key:i,isInPanel:s,isWalking:c})=>{bb()?o(r,i):s?(e.onCardOpen(),n({...t,cursor:i,open:c||t.open!==r.id?r.id:null}),a(r)):(n({...t,cursor:i,open:null}),e.onJump(r))};return{list:t,setList:n,sheet:r,setSheet:i,go:(r,i)=>{let a=jj(r);r.kind===`thread`&&e.threads?.pile.has(r.thread.id)===!0?(n({...t,cursor:a,open:null}),e.threads.onPick(r.thread)):r.kind===`thread`?s(r.thread,{key:a,isInPanel:Aj(r),isWalking:i}):n({...t,cursor:a,open:null})},read:a}},aN=(e,t)=>{let n=bj({...e.shown,isTheirs:e.isTheirs,pile:e.threads?.pile}),r=rN(n),{actions:i}=e.comments,a=iN(e),o=e.threads===void 0?a:{...a,list:{...a.list,cursor:e.threads.at,open:null}};return tN(t,{flat:r,state:o,props:e,settle:t=>{i.handleResolve(nN(t,e).root,!t.isSettled)}}),{sections:n,flat:r,actions:i,state:o}},oN=({thread:e,props:t,actions:n})=>{let r=e.file.split(`/`).at(-1)??e.file,i=`Open in ${e.layerAddress===null?r:`layer ${e.layerAddress}`}, near line ${String(e.start)}`,a=nN(e,t);return(0,K.jsx)(`div`,{className:`mx-1.5 mb-2 grid gap-1.5 font-sans`,"data-open-card":!0,children:(0,K.jsx)(Cx,{actions:n,deck:t.deck,isCurrent:!0,live:t.comments.live,revision:t.comments.revision,headAction:e.file===``?null:(0,K.jsxs)(Gn,{children:[(0,K.jsx)(En,{render:(0,K.jsx)(`button`,{"aria-label":i,className:`-me-1.5 grid size-6 place-items-center rounded-md text-muted-foreground hover:bg-row-hover hover:text-foreground`,onClick:()=>{t.onShowLayer(e)},type:`button`}),children:(0,K.jsx)($r,{"aria-hidden":!0,className:`size-3.5`})}),(0,K.jsx)(kn,{children:i})]}),thread:{...a,isOutdated:a.root.code!==``}})})},sN=e=>e.kind===`thread`&&e.thread.unread===0,cN=({title:e,count:t,isOpen:n,className:r,onToggle:i})=>(0,K.jsx)(`div`,{className:W(`px-1.5`,r),children:(0,K.jsxs)(`button`,{className:`flex h-8.5 w-full items-center gap-2 rounded-lg px-2 text-xs font-medium text-muted-foreground hover:bg-row-hover max-md:h-12 max-md:px-3 max-md:text-base`,onClick:i,type:`button`,children:[(0,K.jsx)(cn,{"aria-hidden":!0,className:W(`size-3 text-subtle transition-transform duration-180 ease-(--e-out) max-md:size-4`,n&&`rotate-90`)}),e,(0,K.jsx)(`span`,{className:`font-normal text-subtle tabular-nums`,children:t})]})}),lN=(e,t)=>{e.setList({...e.list,folds:{...e.list.folds,[t]:e.list.folds[t]!==!0}})},uN=({entry:e,sectionKey:t,...n})=>{let{props:r,state:i,actions:a}=n,o=jj(e),s=i.list.cursor===o,c=e.kind===`thread`&&i.list.open===e.thread.id,l=TM(e,r.threads?.pile);return l===null?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(SM,{entry:e,isOn:s,onPick:()=>{i.go(e,!1)},sectionKey:t,tools:(0,K.jsx)(RM,{acts:r.acts,entry:e,tools:{go:t=>{e.kind===`thread`&&!Aj(e)?i.go(e,!1):r.onShowLayer(t)},settle:e=>{a.handleResolve(nN(e,r).root,!0)}}})}),e.kind===`thread`?(0,K.jsx)(Cb,{isOpen:c,children:c?(0,K.jsx)(oN,{actions:a,props:r,thread:e.thread}):null}):null,s?(0,K.jsx)(NM,{acts:r.acts,deck:r.deck,entry:e}):null]}):(0,K.jsx)(EM,{entry:e,isOn:s,onPick:()=>{i.go(e,!1)},said:l})},dN=({section:e,...t})=>{let n=e.entries.filter(e=>!sN(e)).length,r=e.key===`movedOn`,i=r?e.entries.filter(sN):[],a=t.state.list.folds.read===!0,o=e.entries.filter(e=>TM(e,t.props.threads?.pile)===null).length;return(0,K.jsxs)(`section`,{children:[(0,K.jsx)(wM,{count:o,section:e,children:r&&n>0&&t.props.threads===void 0?(0,K.jsx)(`span`,{className:`font-normal text-subtle`,children:` · ${String(n)} new`}):null}),e.entries.map(n=>(0,K.jsx)(`div`,{className:W(r&&sN(n)&&!a&&`max-md:hidden`),children:(0,K.jsx)(uN,{entry:n,sectionKey:e.key,...t})},jj(n))),i.length>0?(0,K.jsx)(cN,{className:`md:hidden`,count:i.length,isOpen:a,onToggle:()=>{lN(t.state,`read`)},title:`Read`}):null]})},fN=({section:e,props:t,state:n})=>{let r=n.list.folds[e.key]===!0,i=e=>{e.kind===`thread`?e.thread.state===`removed`?t.acts.remove(e.thread):t.acts.settle(e.thread):e.kind===`remark`&&t.acts.remark(e.remark,`restore`)};return(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`div`,{className:`mx-3.5 mt-3 mb-1 h-px bg-border max-md:mx-5`}),(0,K.jsx)(cN,{count:e.entries.length,isOpen:r,onToggle:()=>{lN(n,e.key)},title:e.title}),(0,K.jsx)(Cb,{isOpen:r,children:e.entries.map(t=>(0,K.jsx)(`div`,{className:`px-1.5`,children:(0,K.jsxs)(`button`,{className:`grid w-full animate-enter gap-0.5 rounded-lg px-2 py-1.5 text-start hover:bg-row-hover`,onClick:()=>{i(t)},type:`button`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-subtle`,children:[(0,K.jsx)(`span`,{className:`truncate font-mono`,children:Sj(t).label}),(0,K.jsx)(`span`,{className:`ms-auto shrink-0`,children:e.key===`settled`?`Reopen`:`Restore`})]}),(0,K.jsx)(`span`,{className:`line-clamp-1 text-ui text-subtle`,children:Ej(t)})]})},jj(t)))})]})},pN=({props:e})=>{let t=e.threads===void 0?e.shown.threads.filter(e=>e.isSettleable).length:0,n=e.shown.drafts.length;return t===0&&n===0?null:(0,K.jsxs)(`div`,{className:`flex animate-enter flex-wrap gap-2 border-t border-border px-2.5 py-2 max-md:px-4`,children:[n>0?(0,K.jsx)(yM,{hint:`C`,isFilled:!0,label:`Send ${String(n)}${e.isTheirs?` to the pull request`:``}`,onClick:()=>{e.acts.sendDrafts()}}):null,t>0?(0,K.jsx)(yM,{hint:`D`,label:`Settle ${String(t)} read`,onClick:()=>{e.acts.settleRead()}}):null]})},mN=({props:e,panel:t})=>{let{state:n,flat:r,actions:i}=t,a=r.flatMap(e=>e.kind===`thread`?[e.thread]:[]),o=a.find(e=>e.id===n.sheet?.id);return o===void 0?null:(0,K.jsx)(eS,{canSettle:o.stand===`answered`||o.stand===`asked`,isOpen:!0,isReplying:n.sheet?.isReplying===!0,onClose:()=>{n.setSheet(null)},onNext:()=>{let e=a[a.indexOf(o)+1];n.setSheet(e===void 0?null:{id:e.id,isReplying:!1}),e!==void 0&&n.read(e)},onReply:e=>{n.setSheet({id:o.id,isReplying:e})},props:{deck:e.deck,thread:nN(o,e),live:e.comments.live,revision:e.comments.revision,actions:i}})},hN=e=>{let t=(0,G.useRef)(null),n=aN(e,t),r=_M({counts:e.block.threadCounts,remarks:e.shown.remarks,drafts:e.shown.drafts,isTheirs:e.isTheirs}),i=e.threads===void 0?r:{title:`${String(e.threads.left)} left`,rest:``};return(0,K.jsxs)(`aside`,{"aria-label":`Review`,className:`flex min-h-0 flex-col outline-none`,"data-review-panel":!0,ref:t,tabIndex:-1,children:[(0,K.jsx)(DM,{said:i}),(0,K.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,K.jsx)(kM,{}),(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto pb-3`,children:[n.sections.length===0?(0,K.jsx)(AM,{}):null,n.sections.map(t=>Tj.has(t.key)?(0,K.jsx)(fN,{props:e,section:t,state:n.state},t.key):(0,K.jsx)(dN,{actions:n.actions,props:e,section:t,state:n.state},t.key))]})]}),(0,K.jsx)(pN,{props:e}),(0,K.jsx)(mN,{panel:n,props:e})]})},gN=({props:e,pane:t,paneRef:n,lead:r})=>{let{state:i,setState:a}=e;return(0,K.jsx)(hN,{acts:t.acts,block:e.block,comments:t.comments,deck:e.deck,isLayered:i.isLayered,isTheirs:e.extras.pull?.theirs===!0,onJump:r.isOn?r.showInDiff:t.threadJump.handleJump,onCardOpen:()=>{a({...i,focus:`tree`})},onLeave:()=>{a(i.isBackToThreads?{...i,lead:`threads`,isBackToThreads:!1}:{...i,focus:`diff`}),n.current?.focus({preventScroll:!0})},onShowLayer:t.threadJump.handleShowLayer,point:e.view.id,railLayer:i.isLayered?vw(i.cursor):null,shown:t.shown,threads:r.panel})},_N=()=>{let e=(0,G.useRef)(0);return(0,G.useEffect)(()=>{let t=()=>{e.current=Date.now()};return document.addEventListener(`touchmove`,t,{passive:!0}),document.addEventListener(`wheel`,t,{passive:!0}),()=>{document.removeEventListener(`touchmove`,t),document.removeEventListener(`wheel`,t)}},[]),e},vN=6,yN=24,bN=800,xN=e=>{let[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(e),a=(0,G.useRef)(new WeakMap),o=_N();return e!==r&&(i(e),n(!1)),{isHidden:t,handleScroll:e=>{if(!(e instanceof HTMLElement))return;let t=e.scrollTop,r=t-(a.current.get(e)??t);a.current.set(e,t),Date.now()-o.current>bN||(t<yN||r<-6?n(!1):r>vN&&n(!0))}}},SN=(e,t,n)=>{let r=e.indexOf(t);return[...e.slice(r+1),...e.slice(0,Math.max(0,r))].find(e=>!n(e))??null},CN=e=>e=>{let t=e?.querySelector(`[aria-current="page"]`);e!==null&&t!=null&&(e.style.setProperty(`--pill-x`,`${String(t.offsetLeft)}px`),e.style.setProperty(`--pill-w`,`${String(t.offsetWidth)}px`))},wN=()=>{if(typeof navigator.vibrate==`function`){navigator.vibrate(1);return}let e=document.createElement(`label`);e.innerHTML=`<input type="checkbox" switch>`,e.style.display=`none`,document.body.append(e),e.click(),e.remove()},TN=24,EN=8,DN=.35,ON=.35,kN=28,AN=.6,jN=100,MN=260,NN=`translate ${String(MN)}ms var(--e-drawer), opacity ${String(MN)}ms var(--e-drawer)`,PN=420,FN=()=>globalThis.matchMedia(`(display-mode: standalone)`).matches||`standalone`in navigator&&navigator.standalone===!0,IN=()=>globalThis.matchMedia(`(max-width: 767px)`).matches,LN=(e,t)=>{let{shown:n,under:r}=e;if(n===null||r===null)return;let i=Math.min(1,Math.max(0,t/n.offsetWidth));n.style.translate=`${String(i*jN)}% 0`,r.style.translate=`${String((i-1)*kN)}% 0`,r.style.opacity=String(AN+.4*i)},RN=e=>{for(let t of[e.shown,e.under])t?.style.removeProperty(`translate`),t?.style.removeProperty(`opacity`),t?.style.removeProperty(`transition`);e.shown!==null&&delete e.shown.dataset.backTop,delete e.box.dataset.backDrag},zN=e=>{e.box.dataset.swiped=``,e.back.onBack(),globalThis.requestAnimationFrame(()=>{RN(e)}),globalThis.setTimeout(()=>{delete e.box.dataset.swiped},PN)},BN=(e,t)=>{let n=e.shown?.offsetWidth??0,r=t/Math.max(1,Date.now()-e.at),i=t>n*DN||r>ON;for(let t of[e.shown,e.under])t?.style.setProperty(`transition`,NN);LN(e,i?n:0),i&&wN(),globalThis.setTimeout(()=>{i?zN(e):RN(e)},MN)},VN=e=>{let t=e.back.getViews();e.shown=t===null?null:dD(e.box,t.shown),e.under=t===null?null:dD(e.box,t.back),t===null||e.shown===null||e.under===null?e.phase=`idle`:(e.box.dataset.backDrag=t.back,e.shown.dataset.backTop=``,e.phase=`drag`)},HN=(e,t)=>{let[n]=e.touches;return e.touches.length===1&&n!==void 0&&n.clientX<=TN&&IN()&&FN()&&t.getViews()!==null},UN=(e,t)=>{let n={box:e,back:t,phase:`idle`,left:0,top:0,at:0,shown:null,under:null};return{handleStart:e=>{let[r]=e.touches;n.phase=HN(e,t)?`maybe`:`idle`,n.left=r?.clientX??0,n.top=r?.clientY??0,n.at=Date.now()},handleMove:e=>{let[t]=e.touches,r=(t?.clientX??n.left)-n.left,i=Math.abs((t?.clientY??n.top)-n.top);n.phase===`maybe`&&Math.max(r,i)>EN&&(r>i?VN(n):n.phase=`idle`),n.phase===`drag`&&(e.preventDefault(),LN(n,r))},handleEnd:e=>{let[t]=e.changedTouches;n.phase===`drag`&&BN(n,(t?.clientX??n.left)-n.left),n.phase=`idle`}}},WN=(e,t)=>{let{handleStart:n,handleMove:r,handleEnd:i}=UN(e,t);return e.addEventListener(`touchstart`,n,{passive:!0}),e.addEventListener(`touchmove`,r,{passive:!1}),e.addEventListener(`touchend`,i),e.addEventListener(`touchcancel`,i),()=>{e.removeEventListener(`touchstart`,n),e.removeEventListener(`touchmove`,r),e.removeEventListener(`touchend`,i),e.removeEventListener(`touchcancel`,i)}},GN=(e,t)=>{let n=xy({views:e,onBack:t});return(0,G.useCallback)(e=>e===null?void 0:WN(e,{getViews:()=>n.current.views,onBack:()=>{n.current.onBack()}}),[n])},KN=u({method:`GET`}).handler(p(`0606210e0df9e9467c6143a764ada1aaa034b2a0ed02cb9b03d64eed35e9c04a`)),qN=u({method:`POST`}).handler(p(`f401f5330e10ad3b2c602ae49981f226d7e57c8b2b638d0840a197a7d6125be6`)),JN=u({method:`POST`}).handler(p(`0883f654ee97f193b16da01fd0bc3688daa5e3a37bb245da03045b353099be05`)),YN=u({method:`POST`}).handler(p(`8d0f02766ecedce1b5d9b39c4524dd1912bd1780e2056ab3f564a5062bf0517c`)),XN=e=>typeof e==`object`&&!!e&&`agents`in e&&`takenLately`in e,ZN=(e,t)=>JSON.stringify(e)===JSON.stringify(t),QN=e=>{let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(!1),{deck:s,point:c,branch:l}=e,u=(0,G.useCallback)(async()=>{try{let e=await KN({data:{deck:s,point:c,branch:l}});n(t=>ZN(t,e)?t:e)}catch{n(null)}},[s,c,l]);(0,G.useEffect)(()=>{let e={isCurrent:!0};(async()=>{let t=await KN({data:{deck:s,point:c,branch:l}});e.isCurrent&&n(e=>e??t)})();let t=EC(`${s}|${c}|${l}`,e=>{let t=JSON.parse(e);XN(t)&&n(e=>ZN(e,t)?e:t)});return()=>{e.isCurrent=!1,t()}},[s,c,l]);let d=async e=>{o(!0),i(null);try{let t=await e();i(t.ok?null:t.error??`It did not start`)}catch(e){i(e instanceof Error?e.message:String(e))}finally{await u(),o(!1)}};return{branch:l,listener:t,failure:r,isBusy:a,handleStart:e=>d(()=>qN({data:{deck:s,point:c,branch:l,agent:e}})),handleStop:()=>d(()=>JN({data:{deck:s,point:c,branch:l}})),handleSave:e=>d(()=>YN({data:e}))}},$N=80,eP=600,tP=2,nP=24,rP=e=>e instanceof Element?e.closest(`[data-code-scroll]`):null,iP=e=>{let{0:t}=e.touches;if(e.touches.length!==1||t===void 0||t.clientX<nP||t.clientX>window.innerWidth-nP)return null;let n=rP(e.target),r=n?.scrollLeft??0,i=n===null?0:n.scrollWidth-n.clientWidth;return{left:t.clientX,top:t.clientY,at:e.timeStamp,isAtStart:r<=1,isAtEnd:r>=i-1}},aP=(e,t)=>{let{0:n}=t.changedTouches;if(n===void 0||t.timeStamp-e.at>eP)return null;let r=n.clientX-e.left,i=n.clientY-e.top;return Math.abs(r)<$N||Math.abs(r)<tP*Math.abs(i)?null:r<0?e.isAtEnd?1:null:e.isAtStart?-1:null},oP=e=>{let t=(0,G.useRef)(null);return{handleTouchStart:e=>{t.current=iP(e)},handleTouchEnd:n=>{let r=t.current;t.current=null;let i=r===null?null:aP(r,n);i!==null&&e(i)}}},sP=(e,t)=>{let{block:n,state:r,setState:i}=e,a=hD(r),o=QN({deck:e.deck,point:e.view.id,branch:n.branch}),s=xN(a),c=oP(e=>{a===`diff`&&(wN(),t.press(e===1?`]`:`[`))}),l=()=>{t.selection?.handleCancel(),i(gD(r))},u=GN(a===`files`?null:{shown:a,back:hD(gD(r))},l);return{phone:{block:n,state:r,file:t.file,position:t.model.position,total:t.model.total,reviewTotal:t.model.reviewTotal,reviewedCount:t.model.marks.count,isReviewed:t.model.marks.isReviewed(r.selected),hasLayers:t.model.hasLayers,hasPull:e.extras.pull!==null,draftCount:t.shown.drafts.length,unreadCount:vM({counts:n.threadCounts,remarks:t.shown.remarks,isTheirs:e.extras.pull?.theirs===!0}),nextUnreviewed:SN(n.order,r.selected,t.model.marks.isReviewed),isBarHidden:s.isHidden||(t.selection?.composerAt??null)!==null,listener:o,model:t.model,onPickLayer:e=>{i(bD(r,{key:e,groups:t.model.groups}))},handlePress:e=>{e===`m`&&wN(),t.press(e)},onOpen:t.handleOpen,onBack:l,onMore:()=>{i({...r,dialog:`more`})}},view:a,swipe:c,backRef:u,handleBarScroll:s.handleScroll}},cP=`grid size-12 shrink-0 place-items-center rounded-full text-foreground glass press disabled:opacity-40`,lP=({label:e,isDisabled:t=!1,onClick:n,children:r})=>(0,K.jsx)(`button`,{"aria-label":e,className:cP,disabled:t,onClick:n,type:`button`,children:r}),uP=({icon:e,label:t,isCurrent:n,badge:r=0,onClick:i})=>(0,K.jsxs)(`button`,{"aria-current":n?`page`:void 0,className:`phone-tab press`,onClick:i,type:`button`,children:[(0,K.jsx)(e,{className:`size-5 shrink-0`}),t,r>0?(0,K.jsx)(`span`,{"aria-label":`${String(r)} unread`,className:`grid h-4.5 min-w-4.5 place-items-center rounded-full bg-accent px-1.25 text-2xs font-semibold text-accent-foreground tabular-nums`,children:r}):null]}),dP=({props:e})=>{let t=qn(),n=e.state.anchor!==null;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(lP,{isDisabled:e.position<=1,label:`Previous file`,onClick:()=>{e.handlePress(`[`)},children:(0,K.jsx)(lr,{className:`size-5.5`})}),(0,K.jsxs)(`div`,{className:`flex h-12 min-w-0 flex-1 items-center justify-center gap-0.5 rounded-full px-1 glass`,children:[(0,K.jsxs)(`button`,{"aria-pressed":e.isReviewed,className:`phone-tab press aria-pressed:text-foreground`,onClick:()=>{e.handlePress(`m`)},type:`button`,children:[(0,K.jsxs)(`span`,{className:`relative grid size-5 shrink-0 place-items-center`,children:[(0,K.jsx)(yr,{className:`absolute size-5 icon-swap`,"data-off":e.isReviewed?``:void 0}),(0,K.jsx)(_r,{className:`absolute size-5 icon-swap text-success`,"data-off":e.isReviewed?void 0:``})]}),`Reviewed`]}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:`h-5 w-px shrink-0 bg-foreground/12`}),(0,K.jsxs)(`button`,{className:`phone-tab press text-foreground`,onClick:()=>{n?e.handlePress(`c`):t.add({title:`Tap a line number to pick the lines to comment on`})},type:`button`,children:[(0,K.jsx)(ri,{className:`size-5 shrink-0`}),`Comment`]})]}),(0,K.jsx)(lP,{isDisabled:e.position>=e.total,label:`Next file`,onClick:()=>{e.handlePress(`]`)},children:(0,K.jsx)(cn,{className:`size-5.5`})})]})},fP=({props:e})=>{let t=e.state.isPanelOpen;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`nav`,{"aria-label":`Sections`,className:`tab-pill flex h-12 items-center gap-0.5 rounded-full px-1 glass`,ref:CN(t),children:[(0,K.jsx)(uP,{icon:Nr,isCurrent:!t,label:`Files`,onClick:()=>{t&&e.handlePress(`a`)}}),(0,K.jsx)(uP,{badge:e.unreadCount,icon:ai,isCurrent:t,label:`Review`,onClick:()=>{t||e.handlePress(`a`)}})]}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsx)(lP,{label:`Search the branch`,onClick:()=>{e.handlePress(`/`)},children:(0,K.jsx)(un,{className:`size-5`})})]})},pP=e=>(0,K.jsx)(`div`,{className:`phone-bar md:hidden`,"data-hidden":e.isBarHidden||e.state.dialog!==null?``:void 0,children:hD(e.state)===`diff`?(0,K.jsx)(dP,{props:e}):(0,K.jsx)(fP,{props:e})}),mP=({title:e,said:t,isAsked:n,onReorder:r,action:i=`Reorder`,whileAsked:a=`Asked the agent for a new order; it shows here when written`})=>(0,K.jsxs)(`div`,{className:`mb-2 flex animate-enter items-start gap-2.5 rounded-lg bg-foreground/6 p-2.5`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`grid h-5 w-3.5 shrink-0 place-items-center`,children:(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground`})}),(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-ui font-medium`,children:e}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n?a:t})]}),n?(0,K.jsxs)(`span`,{className:`inline-flex h-6 shrink-0 items-center gap-1.5 px-2 text-xs font-medium text-success`,children:[(0,K.jsx)(ar,{"aria-hidden":!0,className:`size-3`,strokeWidth:3}),`Asked`]}):(0,K.jsx)(wn,{keys:[`L`],children:(0,K.jsx)(`button`,{className:`inline-flex h-6 shrink-0 press items-center gap-1.5 rounded-md bg-foreground/9 px-2 text-xs font-medium`,onClick:r,type:`button`,children:i})})]}),hP=e=>{let t=e.block.threads.find(e=>e.stand===`asked`),[n]=t?.layers??[],r=e.groups.find(e=>n!==void 0&&e.index===n-1);return t===void 0||r===void 0||t.layers.some(t=>e.isHere(t))?null:(0,K.jsxs)(`button`,{className:`mb-2 flex w-full animate-enter items-start gap-2.5 rounded-lg border border-stand-asked/40 p-2.5 text-start transition-colors duration-150 hover:bg-row-hover`,onClick:()=>{e.onPickFile(hw(r.index,t.file),t.file)},type:`button`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`grid h-5 w-3.5 shrink-0 place-items-center text-stand-asked`,children:`◉`}),(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-ui font-medium`,children:`Up next: a question for you`}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`in ${r.address} · ${r.title}, before the plan’s next layer`})]}),(0,K.jsx)(Zn,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`})]})},gP=({block:e,isAsked:t,onReorder:n})=>{if(e.isLayersStale)return(0,K.jsx)(mP,{isAsked:t,onReorder:n,said:`The branch moved on after it was written`,title:`Order is out of date`});let r=e.unclaimedLines;return r===0?null:(0,K.jsx)(mP,{isAsked:t,onReorder:n,said:`No layer claims them yet; a new order places them`,title:`${String(r)} changed ${r===1?`line is`:`lines are`} in no layer`})},_P=({files:e,isAsked:t,onAsk:n})=>(0,K.jsx)(mP,{action:`Write them`,isAsked:t,onReorder:n,said:`The agent can split these ${String(e)} files into layers to read in order, each with a note on how to read it`,title:t?`An agent is writing layers`:`No layers yet`,whileAsked:`They show here when written; keep reading meanwhile`}),vP=({said:e,name:t,size:n,isPart:r=!1,onPick:i})=>(0,K.jsx)(`div`,{className:W(r&&`ps-6.5`),children:(0,K.jsx)(wn,{keys:[`]`],children:(0,K.jsxs)(`button`,{"data-keep-visible":!0,className:`my-1.5 ms-6 next-layer animate-enter items-center gap-x-2 rounded-lg border border-border bg-background px-2.5 py-2 text-start hover:bg-row-hover`,onClick:i,type:`button`,children:[(0,K.jsx)(`span`,{className:`text-xs text-subtle`,children:e}),(0,K.jsx)(Zn,{"aria-hidden":!0,className:`row-span-3 size-3.5 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`text-ui font-medium`,children:t}),(0,K.jsx)(gE,{size:n})]})})}),yP=(e,t)=>[...e.querySelectorAll(`[data-pinned]`)].filter(e=>e!==t).reduce((e,t)=>e+t.offsetHeight,0),bP=(e,t)=>{let n=e.getBoundingClientRect().top-e.scrollTop,r=t.getBoundingClientRect(),i=e.querySelector(`[data-keep-visible]`),a=i===null?0:i.getBoundingClientRect().bottom-n;return{top:r.top-n,bottom:Math.max(r.bottom-n,a)}},xP=(e,t)=>{let{top:n,bottom:r}=bP(e,t),i=yP(e,t);n-i<e.scrollTop?e.scrollTop=n-i:r>e.scrollTop+e.clientHeight&&(e.scrollTop=r-e.clientHeight)},SP=e=>{let t=(0,G.useRef)(null),n=(0,G.useRef)(new Map);return(0,G.useEffect)(()=>{let r=t.current,i=n.current.get(e);r&&i&&xP(r,i)},[e]),{containerRef:t,register:(0,G.useCallback)(e=>t=>{t===null?n.current.delete(e):n.current.set(e,t)},[])}},CP=e=>{let t=[];return e.forEach(e=>{let n=t.at(-1);n?.[1]===e-1?n[1]=e:t.push([e,e])}),t.map(([e,t])=>e===t?String(e):`${String(e)}–${String(t)}`).join(`, `)},wP=(e,t)=>{let n=e.files.at(-1);return n!==void 0&&t===hw(e.index,n)},TP=({paths:e})=>e.length===0?null:(0,K.jsxs)(`ul`,{className:`m-0 list-none ps-8.5 pe-2 pb-1.5`,children:[(0,K.jsx)(`li`,{className:`pt-1 text-xs/5 text-subtle`,children:`gone since the order was written`}),e.map(e=>(0,K.jsx)(`li`,{className:`truncate font-mono text-xs/5 text-subtle line-through`,title:e,children:e.slice(e.lastIndexOf(`/`)+1)},e))]}),EP=({group:e,props:t,register:n})=>{let r=t.block.layers[e.index]?.vanished??[];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(AO,{block:t.block,index:e.index,onPickFile:t.onPickFile,selected:t.state.selected}),e.all.length===0?(0,K.jsx)(`p`,{className:`m-0 ps-8.5 pe-2 pb-2 text-xs text-subtle`,children:`Nothing left in this diff: its files changed after the order was written.`}):null,e.files.length>0?(0,K.jsx)(CE,{block:t.block,cursor:t.state.cursor,files:t.files,group:e,isReadIn:t.isReadIn,onPickFile:t.onPickFile,register:n}):null,(0,K.jsx)(TP,{paths:r})]})},DP=({group:e,props:t,register:n})=>{let r=t.block.layers[e.index],i=yD(t.state,e.key);return r===void 0?null:(0,K.jsxs)(`div`,{className:W(`mb-0.5`,e.ticket!==null&&`ps-6.5`),children:[(0,K.jsx)(yE,{group:e,isCursor:t.state.cursor===e.key,isOpen:i,layer:r,onPick:()=>{t.onPickLayer(e.key)},register:n,size:hE(e,t.block.layers[e.index],t.isReadIn)}),(0,K.jsx)(`div`,{className:`fold`,"data-open":i?``:void 0,inert:!i,children:(0,K.jsx)(`div`,{children:(0,K.jsx)(EP,{group:e,props:t,register:n})})})]})},OP=(e,t)=>{let n=e.flatMap(e=>BT(e)),r=n.find(e=>wP(e,t));if(r===void 0)return null;let i=n[n.indexOf(r)+1];if(i!==void 0&&r.ticket!==null&&i.ticket===r.ticket)return{key:i.key,said:`End of part ${r.address} · up next`,isPart:!0};let a=e[e.findIndex(e=>BT(e).includes(r))+1];return a===void 0?null:{key:a.key,said:r.ticket===null?`End of this layer · up next`:`End of layer ${String(r.ticket)} · up next`,isPart:!1}},kP=(e,t)=>e?.key===t,AP=({group:e,...t})=>kP(t.upNext,e.key)?(0,K.jsx)(vP,{isPart:t.upNext.isPart,name:`${e.address} · ${e.title}`,onPick:()=>{t.props.onPickLayer(e.key)},said:t.upNext.said,size:hE(e,t.props.block.layers[e.index],t.props.isReadIn)}):(0,K.jsx)(DP,{group:e,props:t.props,register:t.register}),jP=({entry:e,ticket:t,...n})=>{let{props:r}=n,i=xD(r.state,e),a=e.groups.some(e=>yD(r.state,e.key));return(0,K.jsxs)(`div`,{className:`mb-0.5`,children:[(0,K.jsx)(TE,{isCursor:r.state.cursor===e.key,isOpen:i,onPick:()=>{r.onPickLayer(e.key)},register:n.register,rowKey:e.key,ticket:t}),(0,K.jsx)(`div`,{className:`fold`,"data-open":i?``:void 0,inert:!i,children:(0,K.jsxs)(`div`,{children:[a?null:(0,K.jsx)(jO,{block:r.block,onPickFile:r.onPickFile,selected:r.state.selected,ticket:t}),e.groups.map(e=>(0,K.jsx)(AP,{group:e,...n},e.key))]})})]})},MP=({entry:e,...t})=>{if(e.kind===`layer`)return(0,K.jsx)(AP,{group:e,...t});let n=t.props.block.tickets.find(t=>t.number===e.number);return n===void 0?null:kP(t.upNext,e.key)?(0,K.jsx)(vP,{name:`${n.address} · ${n.title}`,onPick:()=>{t.props.onPickLayer(e.key)},said:t.upNext.said,size:wE(n)}):(0,K.jsx)(jP,{entry:e,ticket:n,...t})},NP=100,PP=({state:e,groups:t,block:n})=>{let r=yw(e.cursor);if(r!==null)return{index:null,ticket:r};let i=vw(e.cursor)??t.find(t=>t.all.includes(e.selected))?.index??0;return{index:i,ticket:n.layers[i]?.ticket??null}},FP=(e,t)=>e.index===null?t.ticket===e.ticket:t.index===e.index,IP=(e,t)=>e.tickets.find(e=>e.number===t),LP=(e,t)=>{let n=t.index===null?void 0:e.layers[t.index],r=t.ticket===null?void 0:IP(e,t.ticket),i=`of ${String(e.topLevel)}`;if(n?.isRemainder===!0)return`Not in any layer`;if(r===void 0)return`Layer ${n?.address??`1`} ${i}`;let a=n?.sublayer??null;return a===null?`Layer ${r.address} ${i}`:`Layer ${r.address} ${i} · part ${String(a)} of ${String(r.sublayers)}`},RP=(e,t)=>{e?.style.setProperty(`--size`,String(Math.max(t.count,1))),e?.style.setProperty(`--fill`,`${String(t.count===0?0:t.read*NP/t.count)}%`)},zP=({group:e,size:t,here:n})=>(0,K.jsx)(`span`,{className:`layer-seg`,"data-here":FP(n,e)?``:void 0,ref:e=>{RP(e,t)}}),BP=({entries:e,here:t,sizeOf:n})=>(0,K.jsx)(`div`,{"aria-hidden":!0,className:`flex gap-0.5`,children:e.map(e=>e.kind===`layer`?(0,K.jsx)(zP,{group:e,here:t,size:n(e)},e.key):(0,K.jsx)(`span`,{className:`layer-tk`,ref:t=>{let r=e.groups.reduce((e,t)=>e+n(t).count,0);t?.style.setProperty(`--size`,String(Math.max(r,1)))},children:e.groups.map(e=>(0,K.jsx)(zP,{group:e,here:t,size:n(e)},e.key))},e.key))}),VP=e=>{let t=t=>hE(t,e.block.layers[t.index],e.isReadIn),n=e.groups.map(e=>t(e));return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`sticky -top-2 z-3 -mx-2 -mt-2 grid h-14 content-center gap-2 border-b border-border bg-wash px-4`,"data-pinned":!0,children:[(0,K.jsx)(BP,{entries:e.entries,here:e.here,sizeOf:t}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-subtle tabular-nums`,children:[(0,K.jsx)(`span`,{children:LP(e.block,e.here)}),(0,K.jsx)(`span`,{className:`max-md:hidden`,children:`${String(n.reduce((e,t)=>e+t.read,0))} of ${String(n.reduce((e,t)=>e+t.count,0))} files`}),(0,K.jsxs)(`button`,{className:`-my-3 inline-flex min-h-11 press items-center gap-0.5 text-sm font-medium text-claude md:hidden`,onClick:e.onAllLayers,type:`button`,children:[`All layers`,(0,K.jsx)(cn,{"aria-hidden":!0,className:`size-4`})]})]})]}),e.block.summary===``?null:(0,K.jsx)(`p`,{className:`mx-2 mt-2.5 mb-2 line-clamp-2 text-xs text-muted-foreground`,title:e.block.summary,children:e.block.summary})]})},HP=[],UP=[],WP=(e,t)=>t.kind===`ticket`?e.tickets.find(e=>e.number===t.number)?.isDone===!0:e.layers[t.index]?.isDone===!0,GP=(e,t)=>e.key===t||BT(e).some(e=>e.index===vw(t)),KP=(e,t)=>yD(e,`layer:read`)||t.some(t=>GP(t,e.cursor)),qP=(e,{state:t,present:n,shown:r,isShownIn:i})=>{if(!t.isLayered||e.layers.length===0)return{rows:dw(r,t.collapsed),order:fw(r),groups:HP,entries:UP,done:UP};let a=RT(e.layers,{present:n,isShown:i}),o=zT(a,e.tickets),s=t=>WP(e,t),c=WT(o,{isDone:s,isOpen:e=>xD(t,e),isReadOpen:KP(t,o.filter(e=>s(e)))});return{rows:c.rows,order:c.order,groups:a,entries:o,done:c.done}},JP=e=>e.isLayered?vw(e.cursor):null,YP=e=>({...e,isHidingReviewed:!1,layerOpen:{...e.layerOpen,[xw]:!0}}),XP=e=>{let t=e.querySelector(`[data-open-row]`);if(t!==null){let n=t.getBoundingClientRect().top-e.getBoundingClientRect().top;t.toggleAttribute(`data-stuck`,n<=57)}},ZP=(e,t)=>t.kind===`ticket`?e.tickets.find(e=>e.number===t.number)?.files.length??0:t.all.length,QP=({props:e,register:t})=>{let n=KP(e.state,e.done),r=e.done.reduce((t,n)=>t+ZP(e.block,n),0),i=e.state.cursor===xw,a=e.done.map(e=>e.kind===`ticket`?e.number:Number(e.address));return(0,K.jsxs)(`button`,{"aria-expanded":n,className:`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-ui text-subtle hover:bg-row-hover ${i?`tree-cursor bg-secondary`:``}`,onClick:()=>{e.onPickLayer(xw)},ref:t(xw),type:`button`,children:[(0,K.jsx)(`span`,{className:`grid w-4.5 shrink-0 place-items-center`,children:(0,K.jsx)(ar,{"aria-hidden":!0,className:`size-3 text-success`,strokeWidth:3})}),(0,K.jsx)(`span`,{className:`flex-1`,children:`${e.done.length===1?`Layer`:`Layers`} ${CP(a)} read`}),(0,K.jsx)(`span`,{className:`text-xs tabular-nums`,children:`${String(r)} files`}),(0,K.jsx)(cn,{"aria-hidden":!0,className:`size-3 turn`})]})},$P=e=>{let{containerRef:t,register:n}=SP(e.state.cursor),r=PP(e),i=new Set(e.done.map(e=>e.key)),a=e.entries.filter(e=>!i.has(e.key)),o=KP(e.state,e.done),s=OP(o?[...e.done,...a]:a,e.state.cursor),c=t=>(0,K.jsx)(MP,{entry:t,props:e,register:n,upNext:s},t.key);return(0,K.jsxs)(`nav`,{"aria-label":`Layers`,className:`min-h-0 overflow-auto p-2`,"data-review-rail":!0,onScroll:e=>{XP(e.currentTarget)},ref:t,children:[(0,K.jsx)(VP,{...e,here:r}),(0,K.jsx)(gP,{block:e.block,isAsked:e.isReorderAsked,onReorder:e.onReorder}),(0,K.jsx)(hP,{block:e.block,groups:e.groups,isHere:t=>{let n=e.groups[t-1];return n!==void 0&&FP(r,n)},onPickFile:e.onPickFile}),e.done.length>0?(0,K.jsx)(QP,{props:e,register:n}):null,e.done.length>0?(0,K.jsx)(`div`,{className:`fold`,"data-open":o?``:void 0,inert:!o,children:(0,K.jsx)(`div`,{children:e.done.map(e=>c(e))})}):null,a.map(e=>c(e))]})},eF=30,tF=80,nF=e=>e*Number(getComputedStyle(document.documentElement).fontSize.replace(`px`,``)),rF=(e,t)=>t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop,iF=(e,{top:t,height:n,inset:r,covered:i})=>{t<e.scrollTop+i?e.scrollTop=t-r:t+n>e.scrollTop+e.clientHeight&&(e.scrollTop=t+n-e.clientHeight)},aF=({total:e,rowRem:t,activeKey:n,activeIndex:r,activeInset:i=0,getCovered:a})=>{let o=(0,G.useRef)(null),[s,c]=(0,G.useState)(null),l=(0,G.useRef)(null),u=(0,G.useCallback)(()=>{let e=o.current;if(e===null)return;let n=nF(t),r=Math.floor(e.scrollTop/n),i=Math.ceil(e.clientHeight/n)+1;c(e=>e?.first===r&&e.count===i?e:{first:r,count:i})},[t]);(0,G.useLayoutEffect)(()=>{let e=o.current;if(e===null)return;let t=new ResizeObserver(u);return t.observe(e),u(),()=>{t.disconnect()}},[u]),(0,G.useLayoutEffect)(()=>{let e=o.current,s=e?.querySelector(`:scope > ul`);if(!e||!s||r<0||l.current===n)return;let c=nF(t);l.current=n,iF(e,{top:rF(e,s)+r*c,height:c,inset:i/t*c,covered:a?.(e)??0}),u()},[n,r,i,a,t,u]);let d=s===null?0:Math.max(0,s.first-eF),f=s===null?Math.min(e,tF):Math.min(e,s.first+s.count+eF);return{containerRef:o,start:Math.min(d,f),end:f,before:`${String(Math.min(d,f)*t)}rem`,after:`${String((e-f)*t)}rem`,onScroll:u}},oF=1.5,sF=2.5,cF=()=>Sb()?sF:oF,lF=e=>{let t=[],n=[],r=[];e.forEach((e,i)=>{for(let t=r.at(-1);t!==void 0&&t.depth>=e.depth;t=r.at(-1))n[t.index]=i-1,r.pop();t[i]=r.at(-1)?.index??-1,n[i]=i,r.push({index:i,depth:e.depth})});for(let{index:t}of r)n[t]=e.length-1;return{parent:t,end:n}},uF=({parent:e,end:t},n)=>{let r=[],i=(t[n]??n)>n?n:e[n]??-1;for(let t=i;t>=0;t=e[t]??-1)r.unshift(t);return r},dF={rows:[],push:0},fF=e=>e*Number(getComputedStyle(document.documentElement).fontSize.replace(`px`,``)),pF=e=>e.querySelector(`ul`)?.offsetTop??0,mF=(e,t,n)=>{let r=[];for(let i=0;i<5;i+=1){let a=Math.floor((t+i*n)/n),o=a<0||a>=e.parent.length?[]:uF(e,a),s=o[i];if(s===void 0||i>0&&o[i-1]!==r[i-1])return r;r.push(s)}return r},hF=(e,t,n)=>{let r=fF(n),i=e.scrollTop-pF(e),a=mF(t,i,r),o=a.at(-1);if(o===void 0)return dF;let s=((t.end[o]??o)+1)*r-i;return{rows:a,push:Math.max(0,a.length*r-s)}},gF=e=>{let{top:t}=e.getBoundingClientRect();return Math.max(0,...[...e.querySelectorAll(`[data-tree-pin]`)].map(e=>e.getBoundingClientRect().bottom-t))},_F=(e,t)=>e.push===t.push&&e.rows.length===t.rows.length&&e.rows.every((e,n)=>e===t.rows[n]),vF=({container:e,rows:t,rowRem:n})=>{let r=(0,G.useMemo)(()=>lF(t),[t]),[i,a]=(0,G.useState)(dF);return WA(e,()=>{let t=e===null?dF:hF(e,r,n);a(e=>_F(e,t)?e:t)}),i.rows.length===0||e===null?null:(0,K.jsx)(`div`,{className:`sticky -top-1 z-3 h-0`,children:i.rows.map((r,a)=>{let o=t[r];if(o===void 0)return null;let s=a===i.rows.length-1;return(0,K.jsxs)(`button`,{className:`absolute inset-x-2 flex h-6 w-full min-w-0 items-center gap-1.5 review-indent py-0.5 pe-2 text-start font-mono text-xs/5 text-subtle tree-pin hover:text-foreground max-md:h-10 max-md:text-sm`,"data-tree-pin":!0,"data-tree-pin-last":s?``:void 0,onClick:()=>{e.scrollTop=pF(e)+(r-a)*fF(n)},ref:e=>{e?.style.setProperty(`--depth`,String(o.depth)),e?.style.setProperty(`top`,`${String(a*n)}rem`),e?.style.setProperty(`z-index`,String(5-a)),e?.style.setProperty(`transform`,s&&i.push>0?`translateY(${String(-i.push)}px)`:``)},tabIndex:-1,title:`Scroll to ${o.label}`,type:`button`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`inline-flex w-3.5 shrink-0 justify-center`,children:(0,K.jsx)(cn,{className:`size-3 rotate-90`})}),(0,K.jsx)(`span`,{className:W(`min-w-0 flex-1 truncate`,o.key.startsWith(`layer:`)&&`font-sans font-medium text-muted-foreground`),children:o.label})]},o.key)})})},yF=({row:e,isCollapsed:t,isReviewed:n,since:r})=>(0,K.jsxs)(`span`,{"aria-hidden":!0,className:`inline-flex w-3.5 shrink-0 justify-center text-subtle`,children:[e.kind===`dir`?(0,K.jsx)(cn,{className:W(`size-3 transition-transform duration-150`,!t&&`rotate-90`)}):null,e.kind===`file`&&n?(0,K.jsx)(ar,{className:`size-3 text-success`}):null,e.kind===`file`&&r!==void 0?(0,K.jsx)(lE,{since:r}):null]}),bF=({row:e,isCursor:t,isSelected:n,isCollapsed:r,isReviewed:i,since:a,file:o,threads:s,onPick:c})=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"aria-current":n?`true`:void 0,"aria-label":e.kind===`file`&&i?`${e.label}, reviewed`:void 0,className:W(`flex h-6 w-full min-w-0 items-center gap-1.5 rounded-md py-0.5 pe-2 text-start font-mono text-xs/5 text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:bg-secondary focus-visible:text-foreground max-md:h-10 max-md:text-sm`,i&&!n&&`text-subtle`,n&&`bg-secondary text-foreground`,t&&`tree-cursor transition-none`,`review-indent`),onClick:c,ref:t=>{t?.style.setProperty(`--depth`,String(e.depth))},type:`button`,children:[(0,K.jsx)(yF,{isCollapsed:r,isReviewed:i,row:e,since:a}),(0,K.jsx)(`span`,{className:W(`min-w-0 flex-1 truncate`,e.kind===`dir`&&`text-subtle`,e.key.startsWith(`layer:`)&&`font-sans font-medium text-muted-foreground`),children:e.label}),o?(0,K.jsx)(pE,{file:o}):null,o?(0,K.jsx)(dE,{file:o}):null,(0,K.jsx)(zb,{said:jb(s),stand:s.stand})]})}),xF=({rows:e,cursor:t,selected:n,collapsed:r,files:i,isReviewed:a,getSince:o,getThreads:s,onPick:c})=>{let l=cF(),u=e.findIndex(e=>e.key===t),[d,f]=(0,G.useState)(null),{containerRef:p,start:m,end:h,before:g,after:_,onScroll:v}=aF({total:e.length,rowRem:l,activeKey:t,activeIndex:u,activeInset:Math.min(e[u]?.depth??0,5)*l,getCovered:gF}),y=(0,G.useCallback)(e=>{p.current=e,f(e)},[p]);return(0,K.jsxs)(`nav`,{"aria-label":`Changed files`,className:`relative min-h-0 overflow-auto px-2 py-1`,"data-review-rail":!0,onScroll:v,ref:y,children:[(0,K.jsx)(vF,{container:d,rowRem:l,rows:e}),(0,K.jsx)(`ul`,{className:`m-0 list-none p-0 pt-(--before) pb-(--after)`,ref:e=>{e?.style.setProperty(`--before`,g),e?.style.setProperty(`--after`,_)},children:e.slice(m,h).map(e=>(0,K.jsx)(bF,{threads:e.kind===`file`?s(e.path):Ob,file:e.kind===`file`?i.get(e.path):void 0,isCollapsed:e.kind===`dir`&&r.has(e.full),isCursor:e.key===t,isReviewed:e.kind===`file`&&a(e.path),since:e.kind===`file`?o(e.path):void 0,isSelected:e.kind===`file`&&e.path===n,onPick:()=>{c(e)},row:e},e.key))})]})},SF=(e,t)=>e.wantsLayers?{...e,wantsLayers:!1,isLayered:!0,collapsed:new Set,layerOpen:{},cursor:hw(t(e.selected),e.selected)}:e,CF=e=>`${String(e)} ${e===1?`layer`:`layers`}`,wF=({count:e,isAsked:t,state:n,setState:r,layerOf:i})=>{let a=qn();nA(e>0?`layers`:``,()=>{n.wantsLayers?(r(SF(n,i)),a.add({title:`Layers are written`,description:`${CF(e)}, in reading order`})):t&&a.add({title:`Layers are written`,description:`${CF(e)} · s shows them`})})},TF=(e,t)=>e.find(e=>e.key===t),EF=({block:e,state:t,setState:n,model:r,acts:i})=>{if(wF({count:e.layers.length,isAsked:i.layersAsked===``,state:t,setState:n,layerOf:r.layerOf}),t.isLayered&&r.hasLayers)return(0,K.jsx)($P,{block:e,done:r.done,entries:r.entries,files:r.files,groups:r.groups,isReadIn:r.marks.isReadIn,onAllLayers:()=>{n({...t,dialog:`layers`})},isReorderAsked:i.failure===null&&i.layersAsked===bw(e.layers),onReorder:()=>{i.askLayers(e.layers)},onPickFile:(e,r)=>{let i={...t,cursor:e,selected:r};n(bb()?_D(i):i)},onPickLayer:e=>{let t=TF(r.rows,e);t!==void 0&&r.handlePick(t)},state:t});let a=(0,K.jsx)(xF,{collapsed:t.collapsed,cursor:t.cursor,files:r.files,getSince:r.marks.getSince,getThreads:r.getThreads,isReviewed:r.marks.isReviewed,onPick:r.handlePick,rows:r.rows,selected:t.selected});return t.wantsLayers&&!r.hasLayers?(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-col`,"data-review-rail-box":!0,children:[(0,K.jsx)(`div`,{className:`px-2 pt-2`,children:(0,K.jsx)(_P,{files:e.files.length,isAsked:i.failure===null&&i.layersAsked===bw(e.layers),onAsk:()=>{i.askLayers(e.layers)}})}),a]}):a},DF=(e,t,{threads:n,rows:r})=>{let i=n.find(e=>e.id===t);return i===void 0||i.file===``?{...e,threadAt:t}:{...e,threadAt:t,selected:i.file,cursor:e.isLayered?e.cursor:kD(r,i.file),row:0,anchor:null}},OF=(e,t)=>{if(e.lead===`threads`)return{...e,lead:`diff`,isBackToThreads:!1};let n=e.pile!==null&&Lj(e.pile,t.threads)>0,r=n&&e.pile!==null?e.pile:Fj(t.threads),i=t.threads.find(t=>t.id===e.threadAt),a=n&&!Pj(i)?e.threadAt:Bj(r,t.threads);return DF({...e,lead:`threads`,pile:r,isPanelOpen:!0,isBackToThreads:!1},a,t)},kF=e=>e instanceof Error?e.message:String(e),AF=(e,t)=>n=>({...n,threads:n.threads.map(n=>n.id===e?t(n):n)}),jF=(e,t)=>n=>({...n,remarks:n.remarks.flatMap(n=>{if(n.id!==e)return[n];let r=t(n);return r===null?[]:[r]})}),MF=(e,t)=>n=>({...n,drafts:n.drafts.flatMap(n=>n.id===e?t===null?[]:[{...n,body:t}]:[n])}),NF=e=>({...e,isSettled:!0,isSettleable:!1,stand:`settled`,section:`settled`}),PF=e=>({...e,state:`removed`,isSettleable:!1,stand:`gone`,section:`removed`}),FF=e=>{let t=e.turns.at(-1)?.voice===`agent`?`answered`:`filed`;return{...e,isSettled:!1,stand:t,section:e.isMovedPast?`movedOn`:t}},IF=e=>t=>({...t,unread:0,isSettleable:!1,turns:[...t.turns,{voice:`reviewer`,body:e,at:new Date().toISOString()}]}),LF=e=>({...e,threads:e.threads.map(e=>e.isSettleable?NF(e):e)}),RF=e=>(t,n=``)=>()=>YS({data:{...e,act:t,id:n}}),zF=()=>{let[e,t]=(0,G.useState)(null);return{asked:e,mark:e=>{t(bw(e))}}},BF=e=>{let t=async(t,n)=>{let r=Date.now()+Math.random();e(e=>[...e,{key:r,change:t}]);try{await n()}finally{e(e=>e.filter(e=>e.key!==r))}};return{echoResolve:(e,n,r)=>t(AF(e,n?NF:FF),r),echoReply:(e,n,r)=>t(AF(e,IF(n)),r)}},VF=(e,t)=>{let[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(null),o=zF(),s=async(e,n,i)=>{let o=Date.now()+Math.random();a(null),r(t=>[...t,{key:o,change:e}]);try{await n(),await t()}catch(e){a(`${i}: ${kF(e)}`)}finally{r(e=>e.filter(e=>e.key!==o))}},c=RF(e);return{failure:i,handleDismissFailure:()=>{a(null)},shown:e=>n.reduce((e,t)=>t.change(e),e),...BF(r),settle:t=>s(AF(t.id,e=>e.isSettled?FF(e):NF(e)),()=>aC({data:{...e,id:t.id,settled:!t.isSettled}}),t.isSettled?`The thread was not taken back`:`The thread was not settled`),remove:e=>{let t=e.state===`removed`;return s(AF(e.id,e=>t?{...e,state:`sent`}:PF(e)),c(t?`restore`:`remove`,e.id),t?`The comment was not restored`:`The comment was not removed`)},read:e=>s(AF(e.id,e=>({...e,unread:0})),c(`read`,e.id),`The answer was not marked read`),settleRead:()=>s(LF,c(`settleRead`),`Nothing was settled`),layersAsked:o.asked,askLayers:async e=>{o.mark(e),await s(e=>e,c(`askLayers`),`The agent was not asked`)},sendDrafts:()=>s(e=>({...e,drafts:[]}),c(`sendDrafts`),`The notes were not sent`),remark:(t,n,r)=>s(jF(t.id,e=>n===`accept`?null:n===`reply`?e:{...e,state:n===`dismiss`?`dismissed`:`waiting`}),()=>nC({data:{...e,id:t.id,act:n,body:r??``}}),`The remark was not ${n===`reply`?`answered`:`${n}ed`}`),draft:(t,n)=>s(MF(t.id,n),()=>rC({data:{...e,id:t.id,body:n}}),n===null?`The note was not dropped`:`The note was not reworded`)}},HF=(e,t)=>e.author===t.author&&e.parent===t.parent&&e.path===t.path&&e.side===t.side&&e.start===t.start&&e.end===t.end&&e.body.trim()===t.body.trim(),UF=(e,t,n)=>e.find(e=>t.id!==null&&e.id===t.id)??e.find(e=>!n.has(e.id)&&!t.earlier.includes(e.id)&&HF(e,t.comment)),WF=(e,t)=>{let n=new Map;for(let r of t){let t=UF(e,r,n);t!==void 0&&n.set(t.id,r.key)}return n},GF=(e,{id:t,resolved:n})=>e.map(e=>e.id===t?{...e,resolved:n}:e),KF=(e,t,n)=>{let r=WF(e,t),i=new Set(r.values()),a=e.map(e=>{let t=r.get(e.id);return t===void 0?e:{...e,key:t}}),o=t.filter(e=>!e.isSettled&&!i.has(e.key)).map(e=>e.comment);return n.reduce((e,t)=>GF(e,t),[...a,...o])},qF=()=>`pending:${ka()}`,JF=(e,t)=>{let n=qF(),r={...e,id:n,key:n,author:`you`,at:new Date().toISOString()};return{key:n,comment:r,earlier:t.filter(e=>HF(e,r)).map(e=>e.id),id:null,isSettled:!1}},YF=e=>e instanceof Error?e.message:String(e),XF=e=>{let[t,n]=(0,G.useState)([]),[r,i]=(0,G.useState)([]),[a,o]=(0,G.useState)(null),s=(e,t)=>{n(n=>n.map(n=>n.key===e?{...n,...t}:n))};return{failure:a,write:async(t,r,i)=>{o(null),n(e=>[...e,t]);try{s(t.key,{id:await r()}),await e(),s(t.key,{isSettled:!0})}catch(e){n(e=>e.filter(e=>e.key!==t.key)),o(`${i}: ${YF(e)}`)}},settle:async({id:t,resolved:n},r,a)=>{let s={key:qF(),id:t,resolved:n};o(null),i(e=>[...e,s]);try{await r(),await e()}catch(e){o(`${a}: ${YF(e)}`)}finally{i(e=>e.filter(e=>e.key!==s.key))}},shown:e=>KF(e,t,r),dismiss:()=>{o(null)}}},ZF=e=>({...by(e),code:``,parent:null,resolved:!1}),QF=e=>{let t=KS(),n=XF(e.refresh),r=KM(e),i={...r.live,comments:n.shown(r.live.comments)},a=WS(i.comments),o={deck:e.deck,point:e.point,branch:e.block.branch},s=(e,t)=>{let{seenAt:i,key:a,...s}=e;return n.write(JF({...s,body:t,parent:e.id,resolved:!1},r.live.comments),async()=>(await iC({data:{...o,id:e.id,body:t}}),null),`Your reply did not reach adiff ("${t}")`)},c={...a,handleReply:(e,t)=>(s(e,t),Promise.resolve()),handleResolve:async(e,t)=>{await n.settle({id:e.id,resolved:t},()=>aC({data:{...o,id:e.id,settled:t}}),t?`The thread was not resolved`:`The thread was not reopened`)}};return{revision:r.revision,live:i,actions:c,sendReply:s,forFile:(i,a)=>{let{path:s,rows:c,isNewOnly:l}=a,u=t.forFile(i,c,l);return{...u,path:s,handlePost:i=>{let a=u.selected?yy(c,u.selected,l):null;if(a===null)return Promise.resolve();let d={from:vy(a.from),to:vy(a.to)},f=JF({...ZF(a),point:e.point,revision:r.revision,path:s,body:i},r.live.comments);return t.clear(),n.write(f,async()=>(await JS({data:{...o,path:s,...d,body:i}})).id,`Your comment did not reach adiff ("${i}")`),Promise.resolve()}}},failure:n.failure,handleDismissFailure:n.dismiss}},$F=e=>e!==void 0&&(e.op!==`gap`||e.others!==void 0),eI=e=>e?.op===`add`||e?.op===`del`,tI=(e,t)=>Math.min(Math.max(0,t),Math.max(0,e.length-1)),nI=(e,t,n)=>{let r=tI(e,t+n);for(;!$F(e[r])&&r>0&&r<e.length-1;)r+=Math.sign(n);return tI(e,r)},rI=(e,t)=>eI(e[t])&&!eI(e[t-1]),iI=(e,t,n)=>{for(let r=t+n;r>=0&&r<e.length;r+=n)if(rI(e,r))return r;return t},aI=(e,t,n)=>(n===1?e.filter(e=>e>t):e.filter(e=>e<t).toReversed())[0]??t,oI=(e,t)=>{if(!eI(e[t]))return[t,t];let n=t,r=t;for(;eI(e[n-1]);)--n;for(;eI(e[r+1]);)r+=1;return[n,r]},sI=(e,t)=>[Math.min(e,t),Math.max(e,t)],cI=(e,t,n)=>{let[r,i]=sI(t,n);return e.selection?.handleMark?.(r,i),{...e.state,anchor:t,row:n}},lI=(e,t)=>e.state.anchor===null?{...e.state,row:t}:cI(e,e.state.anchor,t),uI=(e,t)=>cI(e,e.state.anchor??e.state.row,nI(e.rows,e.state.row,t)),dI=e=>{let[t,n]=sI(e.state.anchor??e.state.row,e.state.row);return e.selection?.handleCompose?.(t,n),{...e.state,anchor:null}},fI=e=>e.state.anchor===null?cI(e,e.state.row,e.state.row):(e.selection?.handleCancel(),{...e.state,anchor:null}),pI=e=>{let[t,n]=oI(e.rows,e.state.row);return cI(e,t,n)},mI=e=>e.state.anchor!==null||e.selection?.selected!==null?(e.selection?.handleCancel(),{...e.state,anchor:null}):{...e.state,focus:`tree`},hI=({rows:e,settledRows:t,state:n})=>{let r=e[n.row]?.others;if(r!==void 0&&!r.isOpen)return qk(n,{...r,index:n.row});let i=Uk(e[n.row]);return i===null?t.includes(n.row)?{...n,settledAt:`${n.selected}#${String(n.row)}`}:n:{...n,opened:Wk(n.opened,{path:n.selected,range:i})}},gI=(e,t)=>{let n=e.findLastIndex((e,n)=>n<=t&&e.others?.isOpen===!0),r=e[n]?.others;return r===void 0||t>n+r.count?void 0:{...r,index:n}},_I=(e,t)=>({...e,context:t,opened:{...e.opened,[e.selected]:[]}}),vI=(e,t)=>{let{rows:n,threadRows:r,state:i}=t,a=gI(n,i.row);return e===`h`&&a!==void 0?()=>qk(i,a):new Map([[`j`,()=>lI(t,nI(n,i.row,1))],[`ArrowDown`,()=>lI(t,nI(n,i.row,1))],[`k`,()=>lI(t,nI(n,i.row,-1))],[`ArrowUp`,()=>lI(t,nI(n,i.row,-1))],[`g`,()=>lI(t,0)],[`G`,()=>lI(t,Math.max(0,n.length-1))],[`}`,()=>lI(t,iI(n,i.row,1))],[`{`,()=>lI(t,iI(n,i.row,-1))],[`n`,()=>lI(t,aI(r,i.row,1))],[`N`,()=>lI(t,aI(r,i.row,-1))],[`v`,()=>fI(t)],[`V`,()=>pI(t)],[`c`,()=>dI(t)],[`Enter`,()=>dI(t)],[`Escape`,()=>mI(t)],[`l`,()=>hI(t)]]).get(e)},yI=(e,t)=>{if(!(!e.shiftKey||e.key!==`ArrowDown`&&e.key!==`ArrowUp`))return()=>uI(t,e.key===`ArrowDown`?1:-1)},bI=(e,t)=>new Map([[`w`,()=>({...t,isWrapped:!t.isWrapped})],[`+`,()=>({...t,context:Gk(t.context,1)})],[`=`,()=>({...t,context:Gk(t.context,1)})],[`-`,()=>_I(t,Gk(t.context,-1))],[`_`,()=>_I(t,Gk(t.context,-1))],[`F`,()=>t.context===`whole`?_I(t,3):{...t,context:`whole`}],[`Tab`,()=>({...t,focus:t.focus===`tree`?`diff`:`tree`})]]).get(e),xI=(e,{rows:t,order:n,state:r,hasLayers:i,rowsFor:a,layerOf:o,onTurn:s})=>new Map([[`T`,s],[`j`,()=>OD(r,{rows:t,offset:1})],[`ArrowDown`,()=>OD(r,{rows:t,offset:1})],[`k`,()=>OD(r,{rows:t,offset:-1})],[`ArrowUp`,()=>OD(r,{rows:t,offset:-1})],[`]`,()=>MD(r,{order:n,offset:1,rows:t})],[`M`,()=>MD(r,{order:n,offset:1,rows:t})],[`[`,()=>MD(r,{order:n,offset:-1,rows:t})],[`f`,()=>({...r,isHidingReviewed:!r.isHidingReviewed})],[`a`,()=>({...r,isPanelOpen:!r.isPanelOpen})],[`b`,()=>({...r,dialog:`base`})],[`/`,()=>({...r,dialog:`search`})],[`?`,()=>({...r,dialog:`keys`})],[`s`,()=>PD(r,{rowsFor:a,layerOf:o,hasLayers:i})],...r.isLayered?[[`h`,()=>FD(r,!1)],[`l`,()=>FD(r,!0)]]:[]]).get(e),SI=(e,t)=>new Map([[`m`,()=>{t.onToggleReviewed(t.state.isLayered?vD(t.state):null)}],[`M`,()=>{t.onToggleReviewed(t.state.isLayered?vD(t.state):null)}],[`z`,()=>{t.onToggleZoom?.()}],[`p`,t.onOpenPull],[`L`,t.onAskLayers],[`D`,t.onSettleRead],[`C`,t.onSendDrafts],[`r`,t.onToggleSince],[`S`,Wn],[`I`,Fn],[`O`,An],[`e`,()=>{Wy({...t.shown,row:t.state.row})}],[`s`,()=>{t.paneRef.current?.focus({preventScroll:!0})}]]).get(e),CI=e=>kj.has(e.key)&&(document.activeElement?.closest(`[data-review-panel]`)??null)!==null,wI=new Set([`j`,`k`,`ArrowDown`,`ArrowUp`,`[`,`]`,`d`,`Enter`,`R`]),TI=(e,{paneRef:t,isZoomed:n,state:r})=>r.dialog===null&&!CI(e)&&!(r.lead===`threads`&&wI.has(e.key))&&!bn(e.target)&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&(n||t.current?.contains(document.activeElement)===!0),EI=(e,t)=>{t.focus===`diff`&&requestAnimationFrame(()=>{e.current?.querySelector(`[data-review-row="${String(t.row)}"]`)?.scrollIntoView({block:`nearest`})})},DI=new Set([`j`,`k`,`ArrowDown`,`ArrowUp`]),OI=(e,{state:t,diff:n})=>e.key===`Escape`&&t.lead===`diff`&&t.isBackToThreads&&t.anchor===null&&(n.selection?.composerAt??null)===null?()=>({...t,lead:`threads`,isBackToThreads:!1}):void 0,kI=(e,t)=>{let n={...t.diff,state:t.state};if(t.state.focus===`diff`){let t=yI(e,n)??vI(e.key,n);if(t!==void 0)return t}let r=bI(e.key,t.state);return r===void 0?t.state.focus===`diff`&&DI.has(e.key)?void 0:xI(e.key,t):r},AI=(e,t)=>OI(e,t)??kI(e,t),jI=(e,t)=>{let n=AI(e,t),r=SI(e.key,t);if(n!==void 0||r!==void 0){if(e.preventDefault(),n!==void 0){let e=n();t.setState(e),EI(t.paneRef,e)}r?.()}},MI=(e,t)=>{let{target:n}=e;if(!bb()||!(n instanceof Element)||t.current?.contains(n)!==!0||n.closest(`[data-code], a:not([data-line-link]), button`)!==null)return null;let r=n.closest(`[data-review-diff] [data-review-row]`)?.dataset.reviewRow;return r===void 0?null:Number(r)},NI=(e,{state:t,setState:n,diff:r})=>{let{selection:i}=r;if(i?.composerAt!==null)return;let a=t.anchor??e;t.anchor===e&&t.row===e?(i.handleCancel(),n({...t,anchor:null,row:e})):(i.handleMark?.(Math.min(a,e),Math.max(a,e)),n({...t,focus:`diff`,anchor:a,row:e}))},PI=e=>(Ut(`keydown`,t=>{TI(t,e)&&jI(t,e)}),Ut(`click`,t=>{let n=MI(t,e.paneRef);n!==null&&NI(n,e)}),t=>{let n={key:t,shiftKey:!1,preventDefault:()=>{}},r={...e,state:{...e.state,dialog:null}};e.state.dialog!==null&&AI(n,r)===void 0&&e.setState(r.state),jI(n,r)}),FI=(e,t)=>t.tickets.length===0||e.isRemainder?e.title:`${e.address} ${e.title}`,II=(e,{after:t,index:n})=>{let r=t?.layers[n];if(t===null||r?.isDone!==!0||e.layers[n]?.isDone===!0)return null;let i=t.tickets.find(e=>e.number===r.ticket),a=e.tickets.find(e=>e.number===r.ticket)?.isDone===!0,o=i!==void 0&&i.isDone&&!a?i:void 0,s=o===void 0?n:Math.max(n,...o.layers.map(e=>e-1)),c=t.layers.find((e,t)=>t>s&&e.files.length>0);return{title:`Layer ${o?.address??r.address} read`,description:c===void 0?`Every layer is read`:`Next: ${FI(c,t)}`}},LI=`*`,RI=(e,t)=>`${e===null?LI:String(e)}:${t}`,zI=e=>e instanceof Error?e.message:String(e),BI=(e,t)=>e.layers.filter(e=>e.files.includes(t)).length,VI=(e,t)=>new Set([...e.reviewed,...e.order].filter(e=>t(e))).size,HI=({deck:e,point:t,block:n,refresh:r,onLayers:i})=>{let[a,o]=(0,G.useState)(new Map),[s,c]=(0,G.useState)(null),l=e=>a.get(RI(null,e))??n.reviewed.includes(e),u=e=>l(e)?void 0:n.since.find(t=>t.path===e),d=(e,t)=>{let r=a.get(RI(null,t));return r===void 0?a.get(RI(e,t))??(l(t)||n.layers[e]?.read.includes(t)===!0):r},f=(e,t)=>a.get(RI(e,t))??a.get(RI(null,t))??n.layers[e]?.parts.find(e=>e.path===t)?.isRead===!0,p=async(e,t,n)=>{c(null),o(n=>new Map([...n,[e,t]]));try{let{told:e}=await n();return i(e),await r(),e}catch(e){return c(`The file was not marked: ${zI(e)}`),null}finally{o(t=>new Map([...t].filter(([t])=>t!==e)))}};return{isReviewed:l,getSince:u,isReadIn:d,isPartRead:f,toggle:(r,i)=>{let a=i!==null&&BI(n,r)>1,o=n.files.find(e=>e.path===r)?.blob??``,s={deck:e,point:t,branch:n.branch,path:r,blob:o};return a?p(RI(i,r),!d(i,r),()=>C({data:{...s,layer:n.layers[i]?.address??String(i+1)}})):p(RI(null,r),!l(r),()=>C({data:{...s,layer:null}}))},count:VI(n,l),failure:s,handleDismissFailure:()=>{c(null)}}},UI=e=>{let{deck:t,view:n,block:r,state:i,setState:a,refresh:o,onLayers:s}=e,c=HI({deck:t,point:n.id,block:r,refresh:o,onLayers:s}),l=qn(),u=e=>e.isHidingReviewed?r.order.filter(t=>!c.isReviewed(t)||t===e.selected):r.order,d=e=>qP(r,{state:e,present:r.order,shown:u(e),isShownIn:(t,n)=>!e.isHidingReviewed||n===e.selected||!c.isPartRead(t,n)}),{rows:f,order:p,groups:m,entries:h,done:g}=d(i),_=e=>Math.max(0,r.layers.findIndex(t=>t.files.includes(e))),v=d(YP(i)).order,y=v.indexOf(i.isLayered?i.cursor:i.selected);return{marks:c,rows:f,order:p,groups:m,entries:h,done:g,hasLayers:r.layers.length>0,rowsFor:e=>d(e).rows,layerOf:_,isReadHere:e=>{let t=JP(i);return t===null?c.isReviewed(e):c.isReadIn(t,e)},toggleReviewed:async(e,t)=>{let n=II({layers:r.layers,tickets:r.tickets},{after:await c.toggle(e,t),index:t??_(e)});n!==null&&l.add(n)},position:y===-1?0:y+1,total:v.length,reviewTotal:r.total,files:new Map(r.files.map(e=>[e.path,e])),getThreads:e=>kb(r.fileMarks,e),handleOpen:e=>{let t={...i,selected:e,cursor:`file:${e}`,row:0,anchor:null};a(bb()?_D(t):t)},handlePick:e=>{let t=DD(i,e,h);a(e.kind===`file`&&bb()?_D(t):t)}}},WI=(e,t)=>{let n=vw(e.cursor);if(n!==null&&t.layers.includes(n+1))return n;let[r]=t.layers;return r===void 0?null:r-1},GI=`near:`,KI=e=>{if(!e.startsWith(GI))return null;let t=e.slice(5),n=t.lastIndexOf(`:`);return{path:t.slice(0,n),line:Number(t.slice(n+1))}},qI=(e,t)=>n=>{let r=KI(n);if(r===null)return t.get(n);if(r.path!==e.path)return;let i=e.rows.findIndex(e=>e.new!==null&&e.new>=r.line);return i===-1?e.rows.findLastIndex(e=>e.new!==null):i},JI=({props:e,rowOf:t,paneRef:n})=>{let{state:r,setState:i}=e,[a,o]=(0,G.useState)(null),s=a===null?void 0:t(a);return nA(s===void 0?``:`${a??``}@${String(s)}`,()=>{s!==void 0&&(o(null),i({...r,row:s,anchor:null,focus:`diff`}),requestAnimationFrame(()=>{n.current?.querySelector(`[data-review-diff] [data-review-row="${String(s)}"]`)?.scrollIntoView({block:`center`,behavior:`smooth`})}))}),{handleJump:(e,t={})=>{let n=r.isLayered?WI(r,e):null;o(e.id),i({...r,...t,selected:e.file,cursor:n===null?`file:${e.file}`:hw(n,e.file),anchor:null})},handleShowLayer:(e,t={})=>{if(e.file===``)return;let[n]=e.layers;o(`${GI}${e.file}:${String(e.start)}`),i({...r,...t,isLayered:n!==void 0,selected:e.file,cursor:n===void 0?`file:${e.file}`:hw(n-1,e.file),row:0,anchor:null})}}},YI=({threads:e,shown:t,acts:n})=>{let r=e.filter(e=>t.includes(e.id)&&e.unread>0&&e.state!==`removed`);nA(r.map(e=>e.id).join(`|`),()=>{r.forEach(e=>{n.read(e)})})},XI=({props:e,model:t,comments:n,isAllShown:r})=>{let i=t.files.get(e.state.selected);if(i===void 0||!e.isFileLoaded(i.path))return{file:i,selection:null,threadRows:[],settledRows:[],shownThreads:[],rowOf:()=>void 0};let{state:a,block:o}=e,s=Vk(i,{context:a.context,opened:a.opened[i.path]??[],runs:a.runs[i.path]??[],isAllShown:r,layers:o.layers,cursor:a.isLayered?a.cursor:null}),c={...i,rows:s},l=hy(my(c.rows,{comments:n.live.comments,path:c.path,revision:n.revision}).byRow);return{file:c,selection:n.forFile(`${String(e.blockIndex)}:${c.path}`,{path:c.path,rows:c.rows,isNewOnly:c.isSince===!0}),threadRows:[...l.open.keys()],settledRows:[...l.settled.keys()],shownThreads:[...l.open.values()].flat().map(e=>e.root.id),rowOf:qI(c,new Map([...l.open.entries()].flatMap(([e,t])=>t.map(t=>[t.root.id,e]))))}},ZI=e=>{let{isOthersShown:t}=Un();return XI({...e,isAllShown:t})},QI=(e,t)=>e?.rows.findIndex(e=>e.new===t)??-1,$I=(e,t)=>{if(e===null||t.shown?.path!==e.path||!t.props.isFileLoaded(e.path))return``;let n=`${e.path}:${String(e.line)}`;return e.row===null?`open:${n}`:`scroll:${n}:${String(e.row)}`},eL=({props:e,shown:t,whole:n},r)=>{let i=QI(t,r),a=QI(n,r),o=i===-1?Math.max(0,a):i,s=i===-1&&a!==-1?`whole`:e.state.context;return e.setState({...e.state,context:s,focus:`diff`,row:o,anchor:null}),o},tL=(e,t)=>{e.current?.querySelector(`[data-review-row="${String(t)}"]`)?.scrollIntoView({block:`center`}),e.current?.focus({preventScroll:!0})},nL=e=>{let[t,n]=(0,G.useState)(null),{props:r,paneRef:i}=e,a=new Set(r.block.files.map(e=>e.path));return nA($I(t,e),()=>{t?.row===null?n({...t,row:eL(e,t.line)}):t!==null&&(tL(i,t.row),n(null))}),{canJump:e=>a.has(e),handleJump:(t,r)=>{e.onOpen(t),n({path:t,line:r,row:null})}}},rL=(e,t)=>{let n=qn(),r=(n,r)=>t.echoResolve(n.id,r,()=>e.actions.handleResolve(n,r));return{...e,actions:{...e.actions,handleResolve:async(e,t)=>{t&&n.add({title:`Settled`,actionProps:{children:`Undo`,onClick:()=>{r(e,!1)}}}),await r(e,t)},handleReply:(n,r)=>(t.echoReply(n.id,r,()=>e.sendReply(n,r)),Promise.resolve())}}},iL=(e,t)=>e.shown({threads:t,remarks:[],drafts:[]}).threads,aL=(e,t)=>{let{deck:n,view:r,block:i,state:a,setState:o,isZoomed:s,onToggleZoom:c}=e,l=QF({deck:n,point:r.id,live:e.live,block:i,refresh:e.refresh}),u=UI({...e,live:l.live}),d=VF({deck:n,point:r.id,branch:i.branch},e.refresh),f=ZI({props:e,model:u,comments:l}),{file:p,selection:m,threadRows:h,settledRows:g,shownThreads:_}=f,v=nL({props:e,shown:p,whole:u.files.get(a.selected),paneRef:t,onOpen:u.handleOpen});YI({threads:i.threads,shown:_,acts:d});let y=PI({paneRef:t,isZoomed:s,rows:u.rows,order:u.order,hasLayers:u.hasLayers,rowsFor:u.rowsFor,layerOf:u.layerOf,state:a,setState:o,onToggleReviewed:e=>{u.toggleReviewed(a.selected,e)},onToggleZoom:c,onOpenPull:()=>{let t=e.extras.pull?.url;t!==void 0&&window.open(t,`_blank`,`noopener`)},onAskLayers:()=>{d.askLayers(i.layers)},onSettleRead:()=>{d.settleRead()},onSendDrafts:()=>{d.sendDrafts()},onTurn:()=>OF(a,{threads:iL(d,i.threads),rows:u.rows}),onToggleSince:()=>{let t=e.sinceView.modeOf(a.selected);t!==null&&e.sinceView.setMode(a.selected,t===`since`?`full`:`since`)},shown:{worktree:i.worktree,file:p},diff:{rows:p?.rows??[],threadRows:h,settledRows:g,selection:m}});return{comments:rL(l,d),model:u,acts:d,shown:d.shown({threads:i.threads,remarks:e.extras.remarks,drafts:e.extras.drafts}),handleOpen:u.handleOpen,threadJump:JI({props:e,rowOf:f.rowOf,paneRef:t}),press:y,jump:v,file:p,selection:m}},oL=k({id:b(),file:b(),start:i(),end:i(),at:b(),snippet:b(),isMovedPast:y(),isOutdated:y()});k({deck:b(),point:b(),branch:b(),threads:w(oL)});var sL=e=>({id:e.id,file:e.file,start:e.start,end:e.end,at:e.at,snippet:e.snippet,isMovedPast:e.isMovedPast,isOutdated:e.isOutdated}),cL={key:``,found:{}},lL=(e,{threads:t,isOn:n})=>{let[r,i]=(0,G.useState)(cL),a=new Map(e.block.files.map(e=>[e.path,e.fingerprint])),o=n&&t.length>0?[e.block.head.sha,...t.map(e=>`${e.id}@${a.get(e.file)??``}`)].join(`|`):``,s=xy(o);return nA(o,()=>{let{deck:n,view:r,block:a}=e,c=t.map(e=>sL(e));(async()=>{try{let e=await ZS({data:{deck:n,point:r.id,branch:a.branch,threads:c}});s.current===o&&i({key:o,found:e})}catch{}})()}),r.found},uL=e=>e.metaKey||e.ctrlKey||e.altKey,dL=(e,t)=>t.isOn&&wI.has(e.key)&&!t.isDialogOpen&&!uL(e)&&!bn(e.target)&&(t.isZoomed||t.paneRef.current?.contains(document.activeElement)===!0),fL=e=>{Ut(`keydown`,t=>{let n=e.keys.get(t.key);n!==void 0&&dL(t,e)&&(t.preventDefault(),n(t))})},pL=300,mL=({props:e,pane:t},n)=>{let{state:r}=e,i=r.pile??[],a=t.shown.threads,o=new Map(a.map(e=>[e.id,e]));return{isOn:r.lead===`threads`&&!n,pile:i,found:o,all:a,current:r.threadAt===null?void 0:o.get(r.threadAt),threads:i.flatMap(e=>{let t=o.get(e.id);return t===void 0?[]:[t]})}},hL=({props:e,pane:t},n)=>(r,i=null)=>{let{state:a,setState:o}=e,{threads:s}=t.shown,c=s.find(e=>e.id===r);r!==null&&r!==a.threadAt&&(i!==null&&n.mark(i),o(DF(a,r,{threads:s,rows:t.model.rows})),c!==void 0&&c.unread>0&&t.acts.read(c))},gL=({pane:e},t)=>(n=t.current)=>{if(n===void 0||n.isAboutBranch)return;let r={lead:`diff`,isBackToThreads:!0,threadAt:n.id};n.isMovedPast?e.threadJump.handleShowLayer(n,r):e.threadJump.handleJump(n,r)},_L=(e,{view:t,moved:n})=>{let{props:r,pane:i,paneRef:a}=e,{threads:o}=i.shown,s=r.state.threadAt,c=hL(e,n),l=e=>qM(e,{point:r.view.id,revision:i.comments.revision,comments:i.comments.live.comments});return{pick:c,placed:l,showInDiff:gL(e,t),step:(e,n)=>{c(Vj(t.pile,{threads:o,at:s,offset:e}),n)},section:(e,n)=>{c(Hj(t.pile,{threads:o,at:s,offset:e}),n)},settle:e=>{t.current===void 0||e-n.at<pL||(i.comments.actions.handleResolve(l(t.current).root,!0),c(Vj(t.pile,{threads:o,at:t.current.id,offset:1}),e))},reply:()=>{a.current?.querySelector(`[data-thread-current] [data-reply-open]`)?.click()},turn:()=>{r.setState(OF(r.state,{threads:o,rows:i.model.rows}))}}},vL=e=>new Map([[`j`,t=>{e.step(1,t.timeStamp)}],[`ArrowDown`,t=>{e.step(1,t.timeStamp)}],[`k`,t=>{e.step(-1,t.timeStamp)}],[`ArrowUp`,t=>{e.step(-1,t.timeStamp)}],[`]`,t=>{e.section(1,t.timeStamp)}],[`[`,t=>{e.section(-1,t.timeStamp)}],[`d`,t=>{e.settle(t.timeStamp)}],[`Enter`,()=>{e.showInDiff()}],[`R`,e.reply]]),yL=(e,{view:t,acts:n})=>{let r=Uj(e.state.pile);return t.isOn&&r!==void 0?{pile:r,at:t.current?.id??null,left:Lj(t.pile,t.all),onPick:e=>{n.pick(e.id)}}:void 0},bL=e=>{let{props:t,paneRef:n}=e,[r,i]=(0,G.useState)(0),a=mL(e,Sb()),o=lL(t,{threads:a.threads,isOn:a.isOn}),s=_L(e,{view:a,moved:{at:r,mark:e=>{i(e)}}});return fL({isOn:a.isOn,isZoomed:t.isZoomed,isDialogOpen:t.state.dialog!==null,paneRef:n,keys:vL(s)}),{...a,...s,code:o,left:Lj(a.pile,a.all),waiting:Fj(a.all).length,panel:yL(t,{view:a,acts:s})}},xL=`review-height rounded-md border border-border max-md:rounded-none max-md:border-0`,SL=e=>{let{block:t,state:n,setState:r,isZoomed:i,onToggleZoom:a}=e,o=(0,G.useRef)(null),s=aL(e,o),c=bL({props:e,pane:s,paneRef:o}),l=c.turn,{phone:u,view:d,swipe:f,backRef:p,handleBarScroll:m}=sP(e,s);return(0,K.jsxs)(`section`,{"aria-label":`Review of ${t.branch}`,className:`flex min-h-0 flex-col overflow-clip bg-wash outline-none ${i?`size-full`:xL}`,"data-owns-keys":!0,onScrollCapture:t=>{e.onScroll(t.currentTarget,s.selection===null?null:s.file??null),m(t.target)},ref:o,tabIndex:-1,children:[(0,K.jsx)(nO,{block:t,isZoomed:i,lead:(0,K.jsx)(uM,{isThreads:c.isOn,left:c.isOn?c.left:c.waiting,onTurn:l}),onBase:()=>{r({...n,dialog:`base`})},onKeys:()=>{r({...n,dialog:`keys`})},onToggleZoom:a,phone:u,pull:e.extras.pull,reviewedCount:s.model.marks.count,model:u.listener,total:s.model.reviewTotal}),(0,K.jsxs)(`div`,{className:`relative min-h-0 flex-1 ${n.isPanelOpen?`review-columns-panel`:`review-columns`}`,"data-phone-view":d,onTouchEnd:f.handleTouchEnd,onTouchStart:f.handleTouchStart,ref:p,children:[(0,K.jsx)(EF,{block:t,model:s.model,acts:s.acts,setState:r,state:n}),(0,K.jsx)(dM,{lead:c,onPress:u.handlePress,pane:s,props:e}),n.isPanelOpen?(0,K.jsx)(gN,{lead:c,pane:s,paneRef:o,props:e}):null]}),(0,K.jsx)(pP,{...u}),(0,K.jsx)($E,{onOpen:s.handleOpen,phone:u,props:e})]})},CL=(e,t)=>{let n=(0,G.useRef)({onMount:e,onUnmount:t});(0,G.useEffect)(()=>{n.current={onMount:e,onUnmount:t}}),(0,G.useLayoutEffect)(()=>(n.current.onMount(),()=>{n.current.onUnmount()}),[])},wL=e=>{let t=(0,G.useRef)(e);(0,G.useEffect)(()=>{t.current=e}),(0,G.useEffect)(()=>{let e=()=>{t.current()},n=()=>{document.visibilityState===`hidden`&&t.current()};return globalThis.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,n),()=>{globalThis.removeEventListener(`pagehide`,e),document.removeEventListener(`visibilitychange`,n)}},[])},TL=`review-deck-review`,EL=k({old:d(i()),new:d(i())}),DL=k({path:b(),fingerprint:b(),top:i(),line:d(EL)}),OL=k({version:O(1),head:b(),isZoomed:y(),selected:b(),cursor:b(),collapsed:w(b()),isHidingReviewed:y(),isLayered:y(),layerOpen:l(b(),y()),isPanelOpen:y(),focus:o([`tree`,`diff`]),row:i(),context:c([i(),O(`whole`)]),opened:f(l(b(),w(s([i(),i()]))),{}),isWrapped:y(),lead:f(o([`diff`,`threads`]),`diff`),pile:f(d(w(k({id:b(),section:o([`asked`,`answered`,`movedOn`])}))),null),threadAt:f(d(b()),null),scroll:d(DL),rail:i()}),kL=({deck:e,point:t,blockIndex:n,branch:r})=>[TL,e,t,String(n),r].join(`|`),AL=e=>{try{let t=r(OL,JSON.parse(sessionStorage.getItem(e)??`null`));return t.success?t.output:null}catch{return null}},jL=(e,t)=>{try{return sessionStorage.setItem(e,JSON.stringify(t)),!0}catch{return!1}},ML=(e,t)=>e.includes(t)?t:e.find(e=>e>t)??e.at(-1)??``,NL=(e,t)=>Math.max(0,e.layers.findIndex(e=>e.files.includes(t))),PL=(e,{selected:t,isLayered:n})=>n?`layer:${String(NL(e,t))}:${t}`:`file:${t}`,FL=(e,t)=>{let n=wD(t),r=ML(t.order,e.selected);if(r===``)return{state:n,isZoomed:e.isZoomed,scroll:null,rail:0};let i=r===e.selected&&e.head===t.head.sha,a=e.isLayered&&t.layers.length>0,o=new Set(CD(r));return{state:{...n,selected:r,cursor:i?e.cursor:PL(t,{selected:r,isLayered:a}),collapsed:new Set(e.collapsed.filter(e=>!o.has(e))),isHidingReviewed:e.isHidingReviewed,isLayered:a,layerOpen:i?e.layerOpen:{},isPanelOpen:e.isPanelOpen,focus:e.focus,row:i?e.row:0,context:e.context,opened:e.head===t.head.sha?e.opened:{},isWrapped:e.isWrapped,lead:e.lead,pile:e.pile,threadAt:e.threadAt},isZoomed:e.isZoomed,scroll:e.scroll?.path===r?e.scroll:null,rail:e.rail}},IL=(e,{head:t,isZoomed:n,scroll:r,rail:i})=>({version:1,head:t,isZoomed:n,selected:e.selected,cursor:e.cursor,collapsed:[...e.collapsed],isHidingReviewed:e.isHidingReviewed,isLayered:e.isLayered,layerOpen:{...e.layerOpen},isPanelOpen:e.isPanelOpen,focus:e.focus,row:e.row,context:e.context,opened:Object.fromEntries(Object.entries(e.opened).map(([e,t])=>[e,t.map(([e,t])=>[e,t])])),isWrapped:e.isWrapped,lead:e.lead,pile:e.pile===null?null:e.pile.map(e=>({...e})),threadAt:e.threadAt,scroll:r,rail:i}),LL=(e,t)=>{let{reviewRow:n=``}=IA(e)?.dataset??{},r=n===``?void 0:t.rows[Number(n)];return{path:t.path,fingerprint:t.fingerprint,top:e.scrollTop,line:r===void 0?null:{old:r.old,new:r.new}}},RL=(e,t)=>t.new!==null&&e.new!==null?Math.abs(e.new-t.new):t.old!==null&&e.old!==null?Math.abs(e.old-t.old):1/0,zL=(e,t)=>e.reduce((e,n,r)=>{let i=RL(n,t);return i<e.distance?{index:r,distance:i}:e},{index:-1,distance:1/0}).index,BL=(e,t,n)=>{let r=n===null?-1:zL(t.rows,n);r===-1?e.scrollTop=0:VA(e,t,r)},VL=(e,{scroll:t,file:n})=>{t.fingerprint===n.fingerprint?e.scrollTop=t.top:BL(e,n,t.line)},HL=3e3,UL=[`touchstart`,`wheel`,`keydown`,`pointerdown`],WL=(e,{scroll:t,file:n})=>{let r={isFirst:!0},i=new ResizeObserver(()=>{r.isFirst?r.isFirst=!1:t.line===null?e.scrollTop=t.top:BL(e,n,t.line)});return i.observe(e.querySelector(`[data-review-rows]`)??e),i},GL=(e,t)=>{for(let t of e.getAnimations())t.finish();VL(e,t);let n=WL(e,t),r=()=>{n.disconnect();for(let e of UL)globalThis.removeEventListener(e,r,!0)};for(let e of UL)globalThis.addEventListener(e,r,{capture:!0,passive:!0});globalThis.setTimeout(r,HL)},KL=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),qL=(e,t)=>{let n=vw(e.cursor);return n!==null&&e.cursor===hw(n,e.selected)?n:Math.max(0,t.findIndex(t=>t.files.includes(e.selected)))},JL=(e,t,n)=>{if(t.selected===e.selected&&t.isLayered===e.isLayered)return t;if(!t.isLayered){let e=new Set(CD(t.selected));return{...t,collapsed:new Set([...t.collapsed].filter(t=>!e.has(t)))}}let r=qL(t,n),i=n[r]?.ticket??null,a=KL(t.layerOpen,pw(r));return{...t,cursor:hw(r,t.selected),layerOpen:i===null?a:KL(a,mw(i))}},YL=250,XL=`[data-review-diff]`,ZL=`[data-review-rail]`,QL=(e,t)=>{let n=e.closest(`section`)?.querySelector(ZL);n!=null&&(n.scrollTop=t)},$L=(e,t,n)=>{let r=(0,G.useRef)(null),i=()=>{let{state:r,...i}=n.current;jL(e,IL(r,{...i,head:t}))};return{save:i,flush:()=>{r.current!==null&&(clearTimeout(r.current.id),r.current.measure(),r.current=null),i()},later:e=>{r.current===null?r.current={measure:e,id:setTimeout(()=>{r.current?.measure(),r.current=null,i()},YL)}:r.current.measure=e}}},eR=(e,t)=>{bb()&&(e.current.state={...e.current.state,isWrapped:!0},t(e.current.state))},tR=(e,t)=>{let[n,r]=(0,G.useState)(()=>wD(t)),[i,a]=(0,G.useState)(!1),o=(0,G.useRef)({state:n,isZoomed:!1,scroll:null,rail:0}),s=(0,G.useRef)(null),c=$L(kL(e),t.head.sha,o);return CL(()=>{let n=AL(kL(e));if(n===null){eR(o,r),Mn();return}let i=FL(n,t);s.current={path:i.state.selected,scroll:i.scroll,rail:i.rail},o.current=i,r(i.state),a(i.isZoomed)},()=>{o.current.isZoomed=!1,c.flush()}),wL(c.flush),{state:n,isZoomed:i,setState:e=>{let n=JL(o.current.state,e,t.layers);s.current=null,Mn(),o.current.state=n,r(n),c.save()},setIsZoomed:e=>{o.current.isZoomed=e,a(e),c.save()},handleScroll:(e,t)=>{c.later(()=>{let n=e.querySelector(XL);o.current.rail=e.querySelector(ZL)?.scrollTop??0,o.current.scroll=n===null||t===null?o.current.scroll:LL(n,t)})},handleDiffShown:(e,t)=>{let n=s.current;n?.path===t.path&&(s.current=null,n.scroll!==null&&GL(e,{scroll:n.scroll,file:t}),QL(e,n.rail),Mn())}}},nR=({branch:e,isFullPage:t})=>(0,K.jsxs)(`div`,{className:W(`grid place-items-center rounded-md border border-border text-sm text-subtle`,t?`size-full`:`review-height`),children:[`Reading `,e,`…`]}),rR=({outline:e,refresh:t,extras:n,stub:r,isFullPage:i=!1,...a})=>{let o=tR({deck:a.deck,point:a.view.id,blockIndex:a.blockIndex,branch:r.branch},e),{state:s,isZoomed:c,setState:l,setIsZoomed:u}=o,d=zC(e),f=XC({deck:a.deck,point:a.view.id,branch:r.branch},{outline:e,selected:s.selected,layer:s.isLayered?vw(s.cursor):null}),p={...e,kind:`review`,title:r.title,files:f.files,layers:d.layers,tickets:d.tickets,threads:d.threads},m={...a,block:p,state:s,setState:l,refresh:t,onLayers:d.handleLayers,extras:n.extras,isFileLoaded:f.isFileLoaded,sinceView:f.sinceView,onToggleZoom:()=>{u(!c)},onScroll:o.handleScroll,onDiffShown:o.handleDiffShown};return i?(0,K.jsx)(SL,{...m,isZoomed:!0,onToggleZoom:void 0}):(0,K.jsxs)(K.Fragment,{children:[c?(0,K.jsx)(`div`,{className:`grid review-height place-items-center rounded-md border border-dashed border-border text-sm text-subtle`,children:`Zoomed in · Esc to close`}):(0,K.jsx)(SL,{...m,isZoomed:!1}),(0,K.jsx)(j_,{onOpenChange:u,open:c,children:(0,K.jsxs)(I_,{"data-review-zoom":!0,initialFocus:!1,children:[(0,K.jsxs)(N_,{children:[`Review of `,r.branch]}),(0,K.jsx)(SL,{...m,isZoomed:!0})]})})]})},iR=e=>{let{stub:t}=e,n=sC({deck:e.deck,point:e.view.id,branch:t.branch}),{outline:r,refresh:i}=RC({deck:e.deck,point:e.view.id,branch:t.branch,kept:t.outline},e=>e.includes(`other`)?n.refresh():Promise.resolve());return(0,K.jsxs)(`div`,{className:W(`grid grid-cols-1 gap-3`,e.isFullPage===!0&&`h-full grid-rows-1`),children:[t.title===void 0?null:(0,K.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:t.title}),r===null?(0,K.jsx)(nR,{branch:t.branch,isFullPage:e.isFullPage===!0}):(0,K.jsx)(rR,{...e,extras:n,outline:r,refresh:i})]})};export{p_ as A,Rg as B,iy as C,H_ as D,Kv as E,Ng as F,jr as G,Ti as H,Mg as I,ar as J,Dr as K,Fg as L,Ag as M,jg as N,W_ as O,Og as P,Pg as R,ay as S,Jv as T,di as U,Xa as V,ti as W,Zn as Y,zy as _,ST as a,my as b,KS as c,aS as d,uS as f,Ry as g,My as h,bT as i,kg as j,G_ as k,WS as l,rS as m,_T as n,vT as o,lS as p,Cr as q,yT as r,gT as s,iR as t,US as u,Vy as v,$v as w,by as x,yy as y,Lg as z};
|
|
44
|
+
`):e.split(GT)).map(e=>YT(e.trim().replace(KT,``))).filter(e=>e!==``),ZT=(e,t)=>{let[n,...r]=XT(e);return n===void 0?null:{lead:n,points:r.filter(e=>!JT.test(e)),howTo:r.filter(e=>JT.test(e)),path:t}},QT=e=>{let[t]=e.prose;return t===void 0?null:ZT(t.markdown,t.path)},$T=(e,t)=>e.prose.slice(1).filter(e=>e.path===t).toSorted((e,t)=>e.line-t.line||Number(e.after)-Number(t.after)),eE=/(?<code>`[^`]+`|\?\w+=|@[A-Z]\w+|\b(?:GET|POST|PUT|PATCH|DELETE)\b|\b[a-z]+[A-Z]\w*|\b[A-Z][a-z\d]+[A-Z]\w*|(?:[\w.:-]*\/)+[\w.:-]+|\b[\w-]+\.(?:ts|tsx|js|json|md|ya?ml)\b)/u,tE=2,nE=({text:e,isChipped:t=!1})=>e.split(eE).map((e,n)=>n%tE===1?(0,K.jsx)(`code`,{className:t?`note-code`:`font-mono text-foreground`,children:e.replaceAll("`",``)},`${String(n)}:${e}`):e),rE=({className:e})=>(0,K.jsx)(`svg`,{"aria-hidden":!0,className:e,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:1.3,viewBox:`0 0 14 14`,children:(0,K.jsx)(`path`,{d:`M3 4h8M3 7h8M3 10h5`})}),iE=({intro:e,isPart:t=!1,isIntroShown:n,onOpenIntro:r})=>e===null?null:(0,K.jsxs)(`button`,{className:W(`mt-0.5 mb-1 grid w-full gap-0.5 rounded-md py-1.5 pe-2 text-start text-ui text-muted-foreground hover:bg-row-hover hover:text-foreground max-md:text-sm`,t?`ps-10.5`:`ps-8`),onClick:r,type:`button`,children:[(0,K.jsx)(`span`,{children:(0,K.jsx)(nE,{text:e.lead})}),(0,K.jsx)(`span`,{className:`text-xs text-subtle`,children:n?`Intro is open`:`Read the intro`})]}),aE=e=>`${String(e)} ${e===1?`line`:`lines`}`,oE=e=>`${String(e)} ${e===1?`place`:`places`}`,sE=(e,t)=>{let n=e.at===``?``:`, ${pn(e.at,t)} ago`;return e.deleted?`Deleted since you reviewed it${n}`:e.kept?`${aE(e.added+e.removed)} in ${oE(e.places)} since you reviewed it${n}`:`Changed since you reviewed it${n}`},cE=()=>(0,K.jsxs)(`svg`,{"aria-hidden":!0,className:`size-3`,fill:`none`,viewBox:`0 0 12 12`,children:[(0,K.jsx)(`path`,{d:`M10.4 4.2A4.9 4.9 0 1 0 10.9 7.6`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.3`}),(0,K.jsx)(`path`,{d:`M10.9 1.6 10.6 4.5 7.8 4.1`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.3`}),(0,K.jsx)(`path`,{d:`M3.9 6.2 5.4 7.7 8 4.9`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.4`})]}),lE=({since:e})=>{let t=vn();return(0,K.jsxs)(Gn,{children:[(0,K.jsxs)(En,{render:(0,K.jsx)(`span`,{className:`inline-flex text-muted-foreground`}),children:[(0,K.jsx)(cE,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Changed since review`})]}),(0,K.jsx)(kn,{children:(0,K.jsxs)(`span`,{className:`grid gap-0.5`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:`Changed since review`}),(0,K.jsx)(`span`,{children:sE(e,t)})]})})]})},uE={added:{Icon:pi,label:()=>`New file`,tone:`text-sign-add`},deleted:{Icon:si,label:()=>`Deleted file`,tone:`text-sign-del`},renamed:{Icon:Zn,label:e=>`Renamed from ${e}`,tone:`text-subtle`},copied:{Icon:Cr,label:e=>`Copied from ${e}`,tone:`text-subtle`}},dE=({file:e})=>{if(e.status===`modified`)return null;let{Icon:t,label:n,tone:r}=uE[e.status],i=n(e.previousPath);return(0,K.jsxs)(Gn,{children:[(0,K.jsxs)(En,{render:(0,K.jsx)(`span`,{className:W(`inline-flex shrink-0`,r)}),children:[(0,K.jsx)(t,{"aria-hidden":!0,className:`size-3`}),(0,K.jsx)(`span`,{className:`sr-only`,children:i})]}),(0,K.jsx)(kn,{children:i})]})},fE=[{short:`bin`,label:`Binary file`,isOn:e=>e.isBinary},{short:`gen`,label:`Generated file`,isOn:e=>e.isGenerated}],pE=({file:e})=>fE.filter(t=>t.isOn(e)).map(e=>(0,K.jsxs)(Gn,{children:[(0,K.jsx)(En,{render:(0,K.jsx)(`span`,{className:`shrink-0 text-subtle`}),children:e.short}),(0,K.jsx)(kn,{children:e.label})]},e.short)),mE=12,hE=(e,t,n)=>({count:e.all.length,read:e.all.filter(t=>n(e.index,t)).length,added:t?.added??0,removed:t?.removed??0,isDone:t?.isDone??!1}),gE=({size:e})=>(0,K.jsxs)(`span`,{className:`text-xs/4 text-subtle tabular-nums`,children:[`${String(e.count)} ${e.count===1?`file`:`files`}`,e.count===0?null:(0,K.jsxs)(K.Fragment,{children:[` · `,(0,K.jsx)(`span`,{className:`text-sign-add`,children:`+${kS(e.added)}`}),e.removed===0?null:(0,K.jsx)(`span`,{className:`text-sign-del`,children:` −${kS(e.removed)}`})]})]}),_E=()=>(0,K.jsx)(ar,{"aria-label":`read`,className:`size-3 text-success in-aria-expanded:max-md:text-accent-foreground`,strokeWidth:3}),vE=({layer:e,size:t})=>t.isDone?(0,K.jsx)(_E,{}):e.isRemainder?`·`:e.address,yE=e=>{let{layer:t,size:n,isOpen:r,isCursor:i}=e,a=t.ticket!==null,{isDone:o}=n;return(0,K.jsxs)(`button`,{"aria-expanded":r,"data-pinned":r?``:void 0,className:W(`flex min-w-0 items-start gap-2 rounded-lg py-1.5 text-start hover:bg-row-hover`,`w-full px-2`,r&&`sticky top-12 z-2 bg-secondary hover:bg-secondary data-stuck:rounded-none data-stuck:shadow-pinned`,r&&(a?`data-stuck:bleed-part`:`data-stuck:bleed`),i&&`bg-secondary transition-none hover:bg-secondary`,i&&!a&&`tree-cursor`),"data-open-row":r?``:void 0,onClick:e.onPick,ref:e.register(e.group.key),title:t.title,type:`button`,children:[(0,K.jsx)(`span`,{className:W(`grid h-5 shrink-0 items-center font-mono text-xs text-subtle tabular-nums`,a?`w-6.5 justify-items-start`:`w-4.5 justify-items-center`,r&&`max-md:rounded-full max-md:bg-accent max-md:text-accent-foreground`,r&&(a?`max-md:h-5.5 max-md:justify-items-center max-md:text-2xs`:`max-md:size-6`)),children:vE(e)}),(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-px`,children:[(0,K.jsx)(`span`,{className:W(`text-ui wrap-break-word`,r&&`max-md:text-base max-md:font-semibold`,r||!o&&i?`font-medium text-foreground`:`text-muted-foreground`,o&&!r&&`text-subtle`),children:t.title}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`flex-1`,children:(0,K.jsx)(gE,{size:n})}),(0,K.jsx)(Bb,{threads:t}),(0,K.jsx)(`span`,{className:`font-mono text-xs text-subtle tabular-nums`,children:n.count===0?`—`:`${String(n.read)}/${String(n.count)}`}),(0,K.jsx)(cn,{"aria-hidden":!0,className:`size-3 turn text-subtle`})]})]})]})},bE=({name:e})=>e.length<=mE?(0,K.jsx)(`span`,{className:`name-fit`,children:e}):(0,K.jsxs)(`span`,{className:`name-fit`,children:[(0,K.jsx)(`span`,{className:`name-head`,children:e.slice(0,-12)}),(0,K.jsx)(`span`,{className:`shrink-0`,children:e.slice(-12)})]}),xE=({file:e,part:t})=>e!==void 0&&(t?.added??0)===0&&(t?.removed??0)===0?(0,K.jsx)(dE,{file:e}):(0,K.jsx)(`span`,{className:`shrink-0 text-sign-add tabular-nums`,children:`+${kS(t?.added??0)}`}),SE=({path:e,props:t})=>{let n=hw(t.group.index,e),r=t.isReadIn(t.group.index,e),i=t.block.layers[t.group.index],a=Ab(i,e),o=t.files.get(e),s=r?void 0:t.block.since.find(t=>t.path===e),c=i!==void 0&&$T(i,e).length>0,l=t.cursor===n;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"aria-current":l?`true`:void 0,"aria-label":r?`${QC(e)}, read`:void 0,className:W(`relative flex h-6 w-full min-w-0 items-center gap-1.5 rounded-md ps-7 pe-2 text-start font-mono text-xs hover:bg-row-hover max-md:h-11 max-md:text-sm`,r?`text-muted-foreground`:`text-foreground`,l&&`bg-secondary transition-none hover:bg-secondary`,l&&(i?.ticket??null)===null&&`tree-cursor`),onClick:()=>{t.onPickFile(n,e)},ref:t.register(n),title:e,type:`button`,children:[a.open>0?(0,K.jsx)(`span`,{className:`absolute inset-s-2.5 top-1/2 -translate-y-1/2`,children:(0,K.jsx)(zb,{said:jb(a),stand:a.stand})}):null,(0,K.jsx)(bE,{name:QC(e)}),c?(0,K.jsx)(rE,{className:`size-3.5 shrink-0 text-subtle`}):null,r?(0,K.jsx)(ar,{"aria-hidden":!0,className:`size-3 shrink-0 text-success`,strokeWidth:3}):null,s===void 0?null:(0,K.jsx)(lE,{since:s}),r||s!==void 0?null:(0,K.jsx)(xE,{file:o,part:i?.parts.find(t=>t.path===e)})]})})},CE=e=>{let t=(e.block.layers[e.group.index]?.ticket??null)!==null,n=e.group.files.map((t,n)=>({path:t,folder:Sw(t),isNewFolder:n===0||Sw(e.group.files[n-1]??``)!==Sw(t)}));return(0,K.jsx)(`ul`,{className:W(`m-0 list-none pt-1 pb-1.5 max-md:mt-2 max-md:mb-3 max-md:more-group max-md:py-1 max-md:ps-0`,t?`ps-3.5 max-md:ms-3 max-md:me-1`:`ps-1.5 max-md:mx-1`),children:n.map(({path:t,folder:n,isNewFolder:r})=>(0,K.jsxs)(`div`,{className:`contents`,children:[r&&n!==``?(0,K.jsxs)(`li`,{className:`flex items-center gap-1.5 ps-4 pt-2 pb-0.5 font-mono text-2xs text-subtle`,title:`${n}/`,children:[(0,K.jsx)(Fr,{"aria-hidden":!0,className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:ww(n)})]}):null,(0,K.jsx)(SE,{path:t,props:e})]},t))})},wE=e=>({count:e.files.length,added:e.added,removed:e.removed}),TE=({rowKey:e,ticket:t,isOpen:n,isCursor:r,onPick:i,register:a})=>(0,K.jsxs)(`button`,{"aria-expanded":n,className:W(`flex w-full min-w-0 items-start gap-2 rounded-lg px-2 py-1.5 text-start hover:bg-row-hover`,r&&`bg-secondary transition-none hover:bg-secondary`),onClick:i,ref:a(e),title:t.title,type:`button`,children:[(0,K.jsx)(`span`,{className:`grid h-5 w-4.5 shrink-0 place-items-center font-mono text-xs text-subtle tabular-nums`,children:t.isDone?(0,K.jsx)(ar,{"aria-label":`read`,className:`size-3 text-success`,strokeWidth:3}):t.address}),(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-px`,children:[(0,K.jsx)(`span`,{className:W(`text-ui wrap-break-word`,n||r?`text-foreground`:`text-muted-foreground`,r&&`font-medium`,t.isDone&&!n&&!r&&`text-subtle`),children:t.title}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`flex-1`,children:(0,K.jsx)(gE,{size:wE(t)})}),n?null:(0,K.jsx)(Bb,{threads:t}),(0,K.jsxs)(`span`,{className:`font-mono text-xs text-subtle tabular-nums`,children:[`${String(t.sublayersDone)}/${String(t.sublayers)}`,(0,K.jsx)(`span`,{className:`font-sans`,children:` parts`})]}),(0,K.jsx)(cn,{"aria-hidden":!0,className:`size-3 turn text-subtle`})]})]})]}),EE=({row:e,onPick:t})=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:W(`flex min-h-14 w-full items-center gap-2.5 py-1.5 pe-3.5 text-start transition-colors duration-150 active:bg-foreground/8`,e.isPart?`ps-10`:`ps-3.5`),onClick:()=>{t(e.key)},type:`button`,children:[(0,K.jsx)(`span`,{className:W(`grid h-6 shrink-0 place-items-center rounded-full font-mono`,e.isPart?`w-7.5 text-xs`:`w-6 text-sm`,e.isHere?`bg-accent text-accent-foreground`:`text-subtle`),children:e.isRead&&!e.isHere?(0,K.jsx)(ar,{"aria-label":`read`,className:`size-3.5 text-success`,strokeWidth:3}):e.number}),(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-base/5`,children:e.title}),(0,K.jsx)(gE,{size:e.size})]}),e.threads.open>0?(0,K.jsx)(zb,{said:jb(e.threads),stand:e.threads.stand}):null,(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-sm text-subtle tabular-nums`,children:e.count})]})}),DE=({props:e})=>{let{model:t,block:n}=e,r=yw(e.state.cursor),i=vw(e.state.cursor)??t.groups.find(t=>t.all.includes(e.state.selected))?.index,a=e=>{let a=hE(e,n.layers[e.index],t.marks.isReadIn),o=n.layers[e.index];return{key:e.key,number:o?.isRemainder===!0?`·`:e.address,title:e.title,size:a,threads:o??Ob,count:a.count===0?`—`:`${String(a.read)}/${String(a.count)}`,isRead:a.isDone,isHere:r===null&&e.index===i,isPart:e.ticket!==null}},o=[];return t.entries.forEach(e=>{let t=e.kind===`ticket`?n.tickets.find(t=>t.number===e.number):void 0;t!==void 0&&o.push({key:mw(t.number),number:t.address,title:t.title,size:wE(t),threads:Ob,count:`${String(t.sublayersDone)}/${String(t.sublayers)}`,isRead:t.isDone,isHere:r===t.number,isPart:!1}),BT(e).forEach(e=>{o.push(a(e))})}),(0,K.jsx)(`ul`,{className:`m-0 mx-2 mb-10 list-none more-group p-0`,children:o.map(t=>(0,K.jsx)(EE,{onPick:e.onPickLayer,row:t},t.key))})},OE=e=>e.state.focus===`diff`&&e.file!==void 0,kE=7,AE=e=>e===void 0?`automatic`:/^[\da-f]{40}$/u.test(e)?e.slice(0,kE):e,jE=({key:e,props:t})=>[e(`b`,{icon:Lr,label:`Compare against`,value:AE(t.block.base.label)}),e(`/`,{icon:un,label:`Search the branch`}),e(`p`,{icon:zr,label:`Open the pull request`,isShown:t.hasPull}),e(`L`,{icon:Yr,label:`New reading order`,note:`Ask the agent to regroup the files into layers`})],ME=({key:e,props:t})=>[e(`a`,{icon:ai,label:`Review panel`}),e(`D`,{icon:rr,label:`Settle what is read`,note:`Close answered threads on files you reviewed`}),e(`C`,{icon:_i,label:`Send ${String(t.draftCount)} held notes`,note:`Post them to the pull request as one review`,isShown:t.draftCount>0})],NE=({key:e,props:t})=>[e(`m`,{icon:_r,label:`Reviewed`,isOn:t.isReviewed,isShown:t.file!==void 0}),e(`s`,{icon:Gr,label:`Group by layer`,note:`Read the files in the order the agent suggests`,isOn:t.state.isLayered||t.state.wantsLayers}),e(`f`,{icon:kr,label:`Hide read files`,isOn:t.state.isHidingReviewed})],PE=({key:e,props:t})=>[e(`}`,{icon:Yn,label:`Next change`,isShown:OE(t)}),e(`{`,{icon:$n,label:`Previous change`,isShown:OE(t)}),e(`n`,{icon:sr,label:`Next comment`,isShown:OE(t)}),e(`N`,{icon:dr,label:`Previous comment`,isShown:OE(t)}),e(`V`,{icon:Di,label:`Select the change`,note:`Pick every line of the change under the cursor`,isShown:OE(t)})],FE=({key:e,props:t,isNoted:n,isOthersShown:r})=>t.state.isLayered?[e(`I`,{icon:Ni,label:`Layer notes`,note:`The layer's intro and each file's note over its code`,isOn:n}),e(`O`,{icon:Ur,label:`Other layers`,note:`Other layers' lines in place, quiet, rather than folded`,isOn:r})]:[],IE=e=>{let{key:t,props:n,isScoped:r}=e;return[t(`w`,{icon:Fi,label:`Wrap long lines`,isOn:n.state.isWrapped}),t(`+`,{icon:hr,label:`More context`,note:`Show more unchanged lines around each change`}),t(`-`,{icon:pr,label:`Less context`}),t(`F`,{icon:jr,label:`Whole file`,isOn:n.state.context===`whole`}),t(`S`,{icon:li,label:`Pin the scope`,note:`Keep the function you are in above the code`,isOn:r}),...FE(e)]},LE=({key:e})=>[e(`?`,{icon:Vr,label:`Theme, editor and keys`,note:`Warm, black or light; where lines open`})],RE=({props:e,onPress:t,footer:n})=>{let{isScoped:r,isNoted:i,isOthersShown:a}=Un(),o=OT(e),s={props:e,isScoped:r,isNoted:i,isOthersShown:a,key:(e,n)=>({id:e,...n,onPress:()=>{t(e)}})};return(0,K.jsxs)(`div`,{className:`grid gap-1 px-2 pb-10`,children:[(0,K.jsx)(LT,{actions:jE(s),title:`Branch`}),(0,K.jsx)(LT,{actions:o,title:`Agent`}),(0,K.jsx)(LT,{actions:ME(s),title:`Comments`}),(0,K.jsx)(LT,{actions:NE(s),title:`Files`}),(0,K.jsx)(LT,{actions:PE(s),title:`Move`}),(0,K.jsx)(LT,{actions:IE(s),extra:(0,K.jsx)(PT,{}),title:`Diff`}),(0,K.jsx)(LT,{actions:LE(s),title:`Settings`}),n]})},zE=`flex w-full min-w-0 items-start gap-2 rounded-md px-2 py-1.5 text-start transition-colors duration-150 ease-out outline-none hover:bg-secondary focus-visible:bg-secondary`,BE=({text:e})=>(0,K.jsx)(`p`,{className:`m-0 px-4 py-6 text-center text-sm text-subtle`,children:e}),VE=(e,t)=>e.trim()===``?`Type to search the files this branch changes`:t===null?`Searching…`:t.length===0?`No matches`:null,HE=e=>{let t={deck:e.deck,point:e.view.id,branch:e.block.branch},[n,r]=(0,G.useState)(``),[i,a]=(0,G.useState)([]),o=(0,G.useRef)(0);return{term:n,matches:i,find:async e=>{o.current+=1;let n=o.current;if(r(e),a(e.trim()===``?[]:null),e.trim()===``)return;let i=await tC({data:{...t,term:e}});n===o.current&&a(i)}}},UE=({term:e,onTerm:t,onEnter:n})=>(0,K.jsx)(`div`,{className:`shrink-0 border-b border-border p-2`,children:(0,K.jsxs)(`label`,{className:`flex h-9 cursor-text items-center gap-2 rounded-lg border border-border bg-composer px-2.5 text-sm transition-colors duration-150 ease-out focus-within:border-muted-foreground hover:border-subtle`,children:[(0,K.jsx)(un,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-subtle`}),(0,K.jsx)(`input`,{"aria-label":`Search this branch`,className:`min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-subtle [&::-webkit-search-cancel-button]:hidden`,onChange:e=>{t(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),n())},"data-autofocus":!0,onPaste:dn,placeholder:`Search this branch`,type:`search`,value:e})]})}),WE=({props:e,onOpen:t})=>{let{term:n,matches:r,find:i}=HE(e),a=VE(n,r);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(UE,{onEnter:()=>{let[e]=r??[];e!==void 0&&t(e.path)},onTerm:e=>void i(e),term:n}),(0,K.jsxs)(R_,{children:[a===null?null:(0,K.jsx)(BE,{text:a}),(0,K.jsx)(`ul`,{className:`m-0 grid list-none gap-0.5 p-2`,children:(r??[]).map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(`button`,{"aria-label":`${e.path} line ${String(e.line)}: ${e.text.trim()}`,className:zE,onClick:()=>{t(e.path)},type:`button`,children:(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,K.jsx)(`span`,{className:`truncate rtl-ellipsis font-mono text-xs/5 text-muted-foreground`,children:(0,K.jsx)(`bdi`,{children:`${e.path}:${String(e.line)}`})}),(0,K.jsx)(`span`,{className:W(`truncate font-mono text-xs/5 whitespace-pre`,e.changed?`text-foreground`:`text-subtle`),children:e.text.trim()})]})})},`${e.path}:${String(e.line)}`))})]}),(0,K.jsxs)(z_,{children:[(0,K.jsx)(tn,{children:`↵`}),(0,K.jsx)(`span`,{children:`opens the first match`})]})]})},GE=40,KE=8,qE=e=>e.length===GE?e.slice(0,KE):e,JE=({title:e,said:t,isCurrent:n,isFirst:r=!1,onPick:i})=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"aria-current":n?`true`:void 0,className:zE,"data-autofocus":r?!0:void 0,onClick:i,type:`button`,children:[(0,K.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center text-success`,children:n?(0,K.jsx)(ar,{"aria-hidden":!0,className:`size-3.5`}):null}),(0,K.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,K.jsx)(`span`,{className:`truncate font-mono text-xs/5 text-foreground`,children:e}),t===``?null:(0,K.jsx)(`span`,{className:`text-xs text-subtle`,children:t})]})]})}),YE=e=>/^[\da-f]{7,40}$/u.test(e),XE=({text:e})=>(0,K.jsx)(`li`,{"aria-hidden":!0,className:`px-2 pt-2.5 pb-1 text-2xs font-medium text-subtle`,children:e}),ZE=({props:e,onDone:t})=>{let n={deck:e.deck,point:e.view.id,branch:e.block.branch},r=e.block.base.label,i=Tw(()=>$S({data:n}),`${n.deck}|${n.point}|${n.branch}`),a=async r=>{t(),await eC({data:{...n,ref:r}}),await e.refresh(!0)};return(0,K.jsxs)(`ul`,{className:`m-0 grid list-none gap-0.5 p-2`,children:[(0,K.jsx)(JE,{isCurrent:!1,isFirst:!0,onPick:()=>void a(null),said:`The branch it is stacked on`,title:`automatic`}),i===null?(0,K.jsx)(BE,{text:`Reading the refs…`}):null,[{title:`Commits`,refs:(i??[]).filter(e=>YE(e.ref))},{title:`Branches`,refs:(i??[]).filter(e=>!YE(e.ref))}].map(e=>e.refs.length===0?null:(0,K.jsxs)(G.Fragment,{children:[(0,K.jsx)(XE,{text:e.title}),e.refs.map(e=>(0,K.jsx)(JE,{isCurrent:e.ref===r,onPick:()=>void a(e.ref),said:e.said,title:qE(e.ref)},e.ref))]},e.title))]})},QE={base:`Compare against`,search:`Search this branch`,keys:`Keys`,more:`Actions`,layers:`Layers`},$E=({props:e,phone:t,onOpen:n})=>{let{state:r,setState:i}=e,[a,o]=(0,G.useState)(r.dialog),s=(0,G.useRef)(null);r.dialog!==null&&r.dialog!==a&&o(r.dialog);let c=()=>{i({...r,dialog:null})};return(0,K.jsx)(j_,{onOpenChange:e=>{e||c()},open:r.dialog!==null,children:(0,K.jsxs)(I_,{"data-review-dialog":a??``,initialFocus:()=>s.current?.querySelector(`[data-autofocus]`)??s.current,finalFocus:()=>document.querySelector(`[data-owns-keys]`),ref:s,variant:`sheet`,children:[(0,K.jsx)(L_,{title:a===null?``:QE[a]}),a===`keys`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(R_,{children:(0,K.jsx)(Ow,{})}),(0,K.jsxs)(z_,{children:[(0,K.jsx)(kw,{}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:`mx-2 h-4 w-px bg-border`}),(0,K.jsx)(Aw,{})]})]}):null,a===`more`?(0,K.jsx)(R_,{children:(0,K.jsx)(RE,{onPress:t.handlePress,props:t})}):null,a===`layers`?(0,K.jsx)(R_,{children:(0,K.jsx)(DE,{props:t})}):null,a===`base`?(0,K.jsx)(R_,{children:(0,K.jsx)(ZE,{onDone:c,props:e})}):null,a===`search`?(0,K.jsx)(WE,{onOpen:e=>{c(),n(e)},props:e}):null]})})},eD=({agent:e,isPicked:t,onPick:n})=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"aria-current":t?`true`:void 0,className:W(zE,!e.isInstalled&&`opacity-60`),"data-autofocus":t?!0:void 0,onClick:n,type:`button`,children:[(0,K.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center text-success`,children:t?(0,K.jsx)(ar,{"aria-hidden":!0,className:`size-3.5`}):null}),(0,K.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-sm text-foreground`,children:e.label}),(0,K.jsx)(`span`,{className:`truncate font-mono text-xs text-subtle`,children:e.isInstalled?e.path??e.bin:`not found in your shell`})]})]})}),tD=({label:e,hint:t,value:n,fallback:r,onChange:i})=>(0,K.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,K.jsxs)(`span`,{className:`flex items-baseline justify-between gap-3 text-xs text-muted-foreground`,children:[(0,K.jsx)(`span`,{children:e}),n===r?null:(0,K.jsx)(`button`,{className:`text-subtle hover:text-foreground`,onClick:e=>{e.preventDefault(),i(r)},type:`button`,children:`Reset`})]}),(0,K.jsx)(`textarea`,{className:`min-h-14 resize-y rounded-lg border border-border bg-composer px-2.5 py-2 font-mono text-xs/5 text-foreground outline-none focus:border-muted-foreground`,onChange:e=>{i(e.target.value)},onPaste:dn,spellCheck:!1,value:n}),(0,K.jsx)(`span`,{className:`text-xs text-subtle`,children:t})]}),nD=({model:e,onDone:t})=>{let{listener:n}=e,[r,i]=(0,G.useState)(n?.chosen??`claude`),[a,o]=(0,G.useState)({});if(n===null)return null;let s=n.agents.find(e=>e.id===r),c=a[r]??{headless:s?.headless??``,interactive:s?.interactive??``},l=(e,t)=>{o({...a,[r]:{...c,[e]:t}})},u=async()=>{await e.handleSave({agent:r,...c}),t()};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(R_,{children:[(0,K.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-2 gap-0.5 p-2`,children:n.agents.map(e=>(0,K.jsx)(eD,{agent:e,isPicked:e.id===r,onPick:()=>{i(e.id)}},e.id))}),s===void 0?null:(0,K.jsxs)(`div`,{className:`grid gap-4 border-t border-border p-4`,children:[(0,K.jsx)(tD,{fallback:s.defaultHeadless,hint:`Runs in the review’s worktree, in your shell, so aliases work. The prompt is added last.`,label:`Headless command`,onChange:e=>{l(`headless`,e)},value:c.headless}),(0,K.jsx)(tD,{fallback:s.defaultInteractive,hint:`What “Copy a terminal command” starts. The prompt is added last.`,label:`Terminal command`,onChange:e=>{l(`interactive`,e)},value:c.interactive})]})]}),(0,K.jsxs)(z_,{children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:n.configPath}),(0,K.jsx)(Dn,{disabled:e.isBusy,onClick:()=>void u(),size:`sm`,children:`Save`})]})]})},rD=({model:e,isOpen:t,onOpenChange:n})=>(0,K.jsx)(j_,{onOpenChange:n,open:t,children:(0,K.jsxs)(I_,{variant:`sheet`,children:[(0,K.jsx)(L_,{title:`Agent`}),t?(0,K.jsx)(nD,{model:e,onDone:()=>{n(!1)}}):null]})}),iD=({listener:e},t)=>{let n=new Set(e?.takenLately);return t.filter(e=>n.has(e.id)&&e.stand===`waiting`).length},aD=e=>`An agent is working on ${String(e)} ${e===1?`comment`:`comments`}`,oD=({listener:e},t)=>{let n=e?.run;return n?.state===`running`?e?.isListening===!0?`A headless ${n.agent} is listening`:`A headless ${n.agent} is working`:e?.isListening===!0?`An agent is listening`:t>0?aD(t):`No agent is watching this review`},sD=(e,t)=>({working:iD(e,t),waiting:t.filter(e=>e.stand===`filed`).length}),cD=100,lD=({done:e,total:t,className:n})=>(0,K.jsx)(`span`,{"aria-hidden":!0,className:W(`h-0.75 overflow-hidden rounded-full bg-secondary`,n),children:(0,K.jsx)(`span`,{className:`progress-fill`,ref:n=>{n?.style.setProperty(`--fill`,`${String(t===0?0:e*cD/t)}%`)}})}),uD={files:`rail`,diff:`diff`,panel:`panel`},dD=(e,t)=>e.querySelector(`:scope > [data-review-${uD[t]}]`),fD=e=>e!==null&&Object.hasOwn(uD,e),pD=()=>{let e=document.querySelector(`[data-phone-view]`),t=e?.dataset.phoneView??null;if(e===null||!fD(t))return;let n=dD(e,t),r=globalThis.matchMedia(`(prefers-reduced-motion: reduce)`).matches;for(let e of n===null?[]:[n,...n.querySelectorAll(`*`)])e.scrollTop>0&&e.scrollTo({top:0,behavior:r?`auto`:`smooth`})},mD={lead:`diff`,pile:null,threadAt:null,isBackToThreads:!1},hD=e=>e.isPanelOpen?`panel`:e.focus===`diff`?`diff`:`files`,gD=e=>e.isPanelOpen?{...e,isPanelOpen:!1}:{...e,focus:`tree`,anchor:null},_D=e=>({...e,isPanelOpen:!1,focus:`diff`}),vD=e=>vw(e.cursor),yD=(e,t)=>e.layerOpen[t]??(t!==`layer:read`&&e.cursor.startsWith(`${t}:`)),bD=(e,{key:t,groups:n})=>{let r=n.find(e=>e.key===t)?.ticket??null,i=r===null?null:mw(r),a=Object.fromEntries(Object.entries({...e.layerOpen,[t]:!0}).filter(([e])=>e!==i));return{...e,dialog:null,cursor:t,layerOpen:a}},xD=(e,t)=>{if(t.kind===`layer`)return yD(e,t.key);let n=vw(e.cursor);return e.layerOpen[t.key]??t.groups.some(e=>e.index===n)},SD=(e,t,n)=>({...e,layerOpen:{...e.layerOpen,[t]:n}}),CD=e=>e.split(`/`).slice(0,-1).map((e,t,n)=>n.slice(0,t+1).join(`/`)),wD=e=>{let[t=``]=e.order;return{selected:t,cursor:`file:${t}`,collapsed:new Set,isHidingReviewed:!1,isLayered:!1,wantsLayers:!1,layerOpen:{},isPanelOpen:!1,dialog:null,focus:`tree`,row:0,anchor:null,context:3,opened:{},runs:{},isWrapped:!1,settledAt:null,...mD}},TD=(e,t)=>e.has(t)?new Set([...e].filter(e=>e!==t)):new Set([...e,t]),ED=(e,t,n)=>{let r=n.find(e=>e.key===t),i=r===void 0?yD(e,t):xD(e,r);return SD({...e,cursor:t},t,!i)},DD=(e,t,n=[])=>t.kind===`file`?{...e,selected:t.path,cursor:t.key,row:0,anchor:null}:e.isLayered?ED(e,t.key,n):{...e,collapsed:TD(e.collapsed,t.full),cursor:t.key},OD=(e,{rows:t,offset:n})=>{let r=t.findIndex(t=>t.key===e.cursor),i=t[Math.min(t.length-1,Math.max(0,r+n))];return i===void 0?e:i.kind===`file`?{...e,selected:i.path,cursor:i.key,row:0,anchor:null}:{...e,cursor:i.key}},kD=(e,t)=>e.find(e=>e.kind===`file`&&e.path===t)?.key??`file:${t}`,AD=(e,{order:t,offset:n,rows:r})=>{let i=t[t.indexOf(e.selected)+n];return i===void 0?e:{...e,selected:i,cursor:kD(r,i),row:0,anchor:null}},jD=(e,{order:t,offset:n})=>{let r=t.indexOf(e.cursor),i=t[(r===-1?t.findIndex(t=>t.endsWith(`:${e.selected}`)):r)+n];if(i===void 0)return e;let a=vw(i)??0;return{...e,cursor:i,selected:i.slice(`layer:${String(a)}:`.length),row:0,anchor:null}},MD=(e,t)=>e.isLayered?jD(e,t):AD(e,t),ND=(e,{rowsFor:t,layerOf:n})=>{let r={...e,isLayered:!e.isLayered,collapsed:new Set,layerOpen:{}};return r.isLayered?{...r,cursor:`layer:${String(n(e.selected))}:${e.selected}`}:{...r,cursor:kD(t(r),e.selected)}},PD=(e,t)=>t.hasLayers?ND(e,t):{...e,wantsLayers:!e.wantsLayers},FD=(e,t)=>{if(e.cursor===`layer:read`||yw(e.cursor)!==null)return SD(e,e.cursor,t);let n=vD(e);if(n===null)return e;let r=`layer:${String(n)}`,i=SD(e,r,t);return t?i:{...i,cursor:r}},ID=7,LD=e=>e===void 0?`its stacked parent`:/^[\da-f]{40}$/u.test(e)?e.slice(0,ID):e,RD=()=>(0,K.jsx)(`span`,{"aria-hidden":!0,className:`h-4 w-px shrink-0 bg-border`}),zD=({count:e,total:t})=>(0,K.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-2 whitespace-nowrap tabular-nums`,children:[(0,K.jsx)(lD,{className:`w-14`,done:e,total:t}),`${String(e)} of ${String(t)} reviewed`]}),BD=({children:e,block:t,pull:n,onBase:r,onKeys:i,total:a,reviewedCount:o,isZoomed:s,onToggleZoom:c,lead:l})=>(0,K.jsxs)(`div`,{className:`flex h-11 min-w-0 items-center gap-3 bg-wash ps-4 pe-2.5 text-xs text-muted-foreground max-md:hidden`,children:[(0,K.jsx)(`span`,{className:`truncate font-mono text-ui font-medium text-foreground`,children:t.branch}),(0,K.jsxs)(`button`,{className:`inline-flex shrink-0 press items-center gap-1 font-mono whitespace-nowrap text-subtle hover:text-foreground`,onClick:r,title:`Change what this branch is compared against (b)`,type:`button`,children:[`vs ${LD(t.base.label)}`,(0,K.jsx)(sr,{"aria-hidden":!0,className:`size-3`})]}),n===null?null:(0,K.jsx)(`a`,{className:`shrink-0 press font-mono whitespace-nowrap text-subtle hover:text-foreground`,href:n.url,rel:`noopener noreferrer`,target:`_blank`,title:`Open the pull request (p)`,children:`#${String(n.number)}`}),l,(0,K.jsx)(`span`,{className:`ms-auto`}),(0,K.jsx)(zD,{count:o,total:a}),e===void 0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(RD,{}),e]}),(0,K.jsx)(RD,{}),(0,K.jsx)(wn,{keys:[`?`],label:`Every key`,side:`left`,children:(0,K.jsx)(`button`,{className:`inline-flex shrink-0 press items-center gap-1.5 whitespace-nowrap text-subtle hover:text-foreground`,onClick:i,type:`button`,children:`Keys`})}),c===void 0?null:(0,K.jsx)(On,{label:s?`Close`:`Zoom`,onClick:c,shortcut:s?xn.close:xn.zoom,size:`icon-sm`,children:s?(0,K.jsx)(Vi,{}):(0,K.jsx)(ti,{})})]}),VD=e=>e.slice(e.lastIndexOf(`/`)+1),HD=2,UD=e=>{let t=e.split(`/`);return t.length>HD?`…/${t.slice(-2).join(`/`)}`:e},WD=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`))),GD=`grid size-11 shrink-0 place-items-center rounded-full text-foreground glass press aria-pressed:bg-accent/28`,KD=({onMore:e})=>(0,K.jsx)(`button`,{"aria-label":`More actions`,className:GD,onClick:e,type:`button`,children:(0,K.jsx)(Dr,{className:`size-5.5`})}),qD=({className:e,children:t})=>(0,K.jsx)(`button`,{className:`min-w-0 flex-1 text-start ${e}`,onClick:pD,type:`button`,children:t}),JD=({label:e,onBack:t})=>(0,K.jsx)(`button`,{"aria-label":e,className:GD,onClick:t,type:`button`,children:(0,K.jsx)(lr,{className:`size-5.5`})}),YD=e=>{let t=e.state.isLayered?e.model.groups.find(t=>e.file!==void 0&&t.all.includes(e.file.path)):void 0;return t===void 0||e.file===void 0?`${String(e.position)} of ${String(e.total)}`:`${String(t.all.indexOf(e.file.path)+1)} of ${String(t.all.length)} in layer ${t.address}`},XD=e=>(0,K.jsxs)(`div`,{className:`grid gap-2.5 bg-background px-4 py-3 md:hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(qD,{className:`truncate font-mono text-lg/6 font-semibold`,children:e.block.branch}),(0,K.jsx)(`button`,{"aria-label":e.state.isHidingReviewed?`Show read files`:`Hide read files`,"aria-pressed":e.state.isHidingReviewed,className:GD,onClick:()=>{e.handlePress(`f`)},type:`button`,children:(0,K.jsx)(qr,{className:`size-5`})}),(0,K.jsx)(KD,{onMore:e.onMore})]}),e.state.isLayered?null:(0,K.jsx)(lD,{className:`h-1 w-full`,done:e.reviewedCount,total:e.reviewTotal}),(0,K.jsxs)(`div`,{className:`flex min-h-6 items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-ui text-muted-foreground tabular-nums`,children:`${String(e.reviewedCount)} of ${String(e.reviewTotal)} reviewed`}),e.nextUnreviewed===null?null:(0,K.jsxs)(`button`,{className:`-my-2.5 -me-1 inline-flex min-h-11 press items-center gap-0.5 px-1 text-ui font-medium text-claude`,onClick:()=>{e.nextUnreviewed!==null&&e.onOpen(e.nextUnreviewed)},type:`button`,children:[`Next unreviewed`,(0,K.jsx)(cn,{"aria-hidden":!0,className:`size-4`,strokeWidth:2.25})]})]}),(0,K.jsx)(`span`,{className:e.state.isLayered?`hidden`:void 0,children:(0,K.jsxs)(`button`,{className:`inline-flex h-8 press items-center gap-1.5 rounded-full bg-secondary px-3 font-mono text-xs text-muted-foreground`,onClick:()=>{e.handlePress(`b`)},type:`button`,children:[`vs ${LD(e.block.base.label)}`,(0,K.jsx)(sr,{"aria-hidden":!0,className:`size-3.5`})]})})]}),ZD=e=>{let t=hD(e.state);if(t===`files`)return(0,K.jsx)(XD,{...e});let n=e.file===void 0?``:WD(e.file.path);return(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 bg-background px-3 pt-3 pb-2.5 md:hidden`,children:[(0,K.jsx)(JD,{label:t===`panel`?`Close the review panel`:`Back to the files`,onBack:e.onBack}),t===`diff`&&e.file!==void 0?(0,K.jsxs)(qD,{className:`grid gap-0.5`,children:[(0,K.jsx)(`span`,{className:`truncate font-mono text-base/5 font-semibold`,children:VD(e.file.path)}),(0,K.jsx)(`span`,{className:`truncate font-mono text-xs text-muted-foreground tabular-nums`,children:[n===``?``:UD(n),YD(e)].filter(Boolean).join(` · `)})]}):(0,K.jsx)(qD,{className:`truncate text-lg font-semibold`,children:`Review`}),(0,K.jsx)(KD,{onMore:e.onMore})]})},QD=({listener:e})=>{let t=e?.run;return t==null||t.state===`running`?t?.lines.at(-1)??``:t.state===`stopped`?`Stopped`:`Ended: ${t.lines.at(-1)??``}`},$D=({lines:e})=>(0,K.jsx)(gn,{children:(0,K.jsxs)(`ol`,{className:`m-0 grid max-h-48 list-none gap-0.5 overflow-auto border-b border-border bg-wash px-3 py-2 font-mono text-xs/5 text-muted-foreground`,children:[e.length===0?(0,K.jsx)(`li`,{className:`text-subtle`,children:`Nothing yet`}):null,e.map((e,t)=>(0,K.jsx)(`li`,{className:`wrap-break-word`,children:e},`${String(t)}-${e}`))]})}),eO=({note:e,isFailure:t})=>e===``?null:(0,K.jsx)(Kn,{label:e,children:(0,K.jsx)(`span`,{className:W(`max-w-64 truncate`,t?`text-destructive`:`text-subtle`),children:e})}),tO=({model:e,threads:t})=>{let{listener:n,isBusy:r,failure:i}=e,[a,o]=(0,G.useState)(!1),s=n?.run??null,c=s?.state===`running`,{working:l,waiting:u}=sD(e,t),d=n?.isListening===!0||c||l>0;if(n===null)return null;let f=ET(n);return(0,K.jsxs)(`span`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[d||f===null?null:(0,K.jsxs)(Dn,{disabled:r||n.worktree===null,onClick:()=>void e.handleStart(f.id),size:`xs`,title:`${oD(e,l)}${u>0?` · ${String(u)} waiting`:``}. Start a headless ${f.label} to answer it.`,variant:`outline`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`me-0.5 size-1.5 rounded-full bg-subtle`}),`Start agent`]}),d?(0,K.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-success`}),(0,K.jsx)(`span`,{className:`truncate text-foreground`,children:oD(e,l)})]}):null,d||s!==null||i!==null?(0,K.jsx)(eO,{isFailure:i!==null,note:i??QD(e)}):null,s===null?null:(0,K.jsx)(`span`,{className:`shrink-0`,children:(0,K.jsx)(mn,{size:`sm`,children:`Log`})}),c?(0,K.jsx)(Dn,{disabled:r,onClick:()=>void e.handleStop(),size:`xs`,variant:`ghost`,children:`Stop`}):null,(0,K.jsx)(DT,{isHeard:d,model:e,onSettings:()=>{o(!0)}}),(0,K.jsx)(rD,{isOpen:a,model:e,onOpenChange:o})]})},nO=({model:e,phone:t,...n})=>(0,K.jsxs)(yn,{children:[(0,K.jsx)(ZD,{...t}),(0,K.jsx)(BD,{...n,children:(0,K.jsx)(tO,{model:e,threads:n.block.threads})}),(0,K.jsx)($D,{lines:e.listener?.run?.lines??[]})]}),rO=[{mode:`since`,label:`Since review`},{mode:`full`,label:`Full diff`}],iO=({mode:e,onMode:t})=>(0,K.jsx)(wn,{keys:[`r`],label:`Since review or full diff`,children:(0,K.jsx)(`fieldset`,{className:`m-0 inline-flex shrink-0 gap-0.5 rounded-md border-0 bg-secondary p-0.5 max-md:w-full`,children:rO.map(n=>(0,K.jsx)(`button`,{"aria-pressed":e===n.mode,className:W(`h-6 press rounded-sm px-2.5 text-xs text-muted-foreground max-md:h-9 max-md:flex-1 max-md:text-sm`,e===n.mode&&`bg-background font-medium text-foreground shadow-sm`),onClick:()=>{t(n.mode)},type:`button`,children:n.label},n.mode))})}),aO=({since:e,mode:t,onMode:n})=>{let r=vn();return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border px-3 py-1.5 text-xs text-muted-foreground max-md:flex-wrap max-md:px-4 max-md:py-2`,children:[(0,K.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center gap-1.5 max-md:flex-wrap max-md:gap-y-0.5`,children:[(0,K.jsx)(cE,{}),(0,K.jsx)(`span`,{className:`font-medium whitespace-nowrap text-foreground`,children:`Changed since review`}),(0,K.jsx)(`span`,{className:`truncate max-md:basis-full max-md:ps-4.5 max-md:whitespace-normal`,children:sE(e,r)})]}),t===null?null:(0,K.jsx)(iO,{mode:t,onMode:n})]})},oO=/^\d+\.\s*/u,sO=(e,t)=>`${e.branch}|${t.title}`,cO=(e,t)=>`${e.branch}|ticket|${t.title}`,lO=(e,t)=>e.tickets.find(e=>e.number===t.ticket),uO=(e,t)=>{let n=QT(t)?.path;return e.files.some(e=>e.path===n)?n:t.files.find(t=>e.files.some(e=>e.path===t))},dO=(e,t)=>{let[n]=t.layers,r=n===void 0?void 0:e.layers[n-1];return n===void 0||r===void 0?null:{index:n-1,layer:r}},fO=(e,t)=>e.files.filter(e=>t.files.includes(e.path)),pO=(e,t)=>{let n=fO(e,t),r=n.filter(e=>$T(t,e.path).length>0).length;return{count:n.length,added:t.added,detail:`${String(r)} of ${String(n.length)} files have a note`}},mO=({sublayers:e,sublayersDone:t})=>t===0?`${String(e)} parts, none read yet`:t===e?`Every part read`:`${String(t)} of ${String(e)} parts read`,hO=(e,t)=>{let n=lO(e,t);return n===void 0||t.sublayer===null?`Layer ${t.address} of ${String(e.topLevel)}`:`Layer ${t.address} · part ${String(t.sublayer)} of ${String(n.sublayers)} in ${n.title}`},gO=(e,t,n)=>{let r=lO(e,t);return r!==void 0&&dO(e,r)?.layer===t&&ZT(r.note,``)!==null&&!n.includes(cO(e,r))},_O=(e,t)=>{let n=lO(e,t);n!==void 0&&dO(e,n)?.layer===t&&zn(cO(e,n),!0),zn(sO(e,t),!1)},vO=({points:e})=>e.length===0?null:(0,K.jsx)(`ul`,{className:`m-0 grid list-none gap-1.25 p-0`,children:e.map(e=>(0,K.jsxs)(`li`,{className:`flex gap-2.5 text-sm text-pretty text-muted-foreground max-md:text-base`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`mt-2.25 size-1 shrink-0 rounded-full bg-subtle`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(nE,{isChipped:!0,text:e})})]},e))}),yO=({block:e,ticket:t})=>(0,K.jsx)(`ul`,{className:`m-0 mt-0.5 grid list-none gap-0.5 p-0`,children:t.layers.map(t=>{let n=e.layers[t-1];return n===void 0?null:(0,K.jsxs)(`li`,{className:`flex items-baseline gap-2 text-sm/5.5 text-muted-foreground max-md:text-base`,children:[(0,K.jsx)(`span`,{className:`w-7.5 shrink-0 font-mono text-xs/5.5 text-subtle`,children:n.address}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1`,children:n.title}),(0,K.jsxs)(`span`,{className:`shrink-0 text-xs whitespace-nowrap text-subtle tabular-nums`,children:[`${String(fO(e,n).length)} files · `,(0,K.jsx)(`span`,{className:`text-sign-add`,children:`+${kS(n.added)}`})]})]},n.address)})}),bO=({intro:e,facts:t,onFold:n})=>(0,K.jsxs)(`div`,{className:`flex flex-col gap-3.5 border-s border-border ps-5 max-md:border-s-0 max-md:border-t max-md:ps-0 max-md:pt-4`,children:[e.howTo.length===0?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`m-0 mb-1 text-xs text-subtle`,children:`How to read it`}),e.howTo.map(e=>(0,K.jsx)(`p`,{className:`m-0 text-sm text-foreground max-md:text-base`,children:(0,K.jsx)(nE,{isChipped:!0,text:e})},e))]}),(0,K.jsxs)(`p`,{className:`m-0 grid gap-0.75 text-xs text-muted-foreground tabular-nums`,children:[(0,K.jsxs)(`span`,{children:[`${String(t.count)} files · `,(0,K.jsx)(`span`,{className:`text-sign-add`,children:`+${kS(t.added)}`})]}),(0,K.jsx)(`span`,{children:t.detail})]}),(0,K.jsx)(`button`,{className:`inline-flex h-7.5 press items-center self-start rounded-md bg-foreground/9 px-3 text-ui font-medium hover:bg-foreground/14 max-md:h-12 max-md:justify-center max-md:self-stretch max-md:text-base`,onClick:n,type:`button`,children:`Got it`})]}),xO=e=>(0,K.jsxs)(`section`,{"aria-label":`Layer ${e.address} intro`,className:`mx-5 mt-4 layer-intro animate-enter rounded-xl border border-border bg-wash px-5 pt-4.5 pb-4 max-md:mx-3 max-md:mt-3 max-md:p-4`,children:[(0,K.jsxs)(`div`,{className:`grid max-w-155 content-start gap-2`,children:[(0,K.jsx)(`p`,{className:`m-0 text-xs text-subtle tabular-nums`,children:e.eyebrow}),(0,K.jsx)(`h2`,{className:`m-0 text-lg font-semibold tracking-tight text-balance`,children:e.title.replace(oO,``)}),(0,K.jsx)(`p`,{className:`m-0 mb-0.5 text-base text-foreground max-md:text-base`,children:(0,K.jsx)(nE,{isChipped:!0,text:e.intro.lead})}),e.children]}),(0,K.jsx)(bO,{facts:e.facts,intro:e.intro,onFold:e.onFold})]}),SO=({address:e,title:t,lead:n,onOpen:r})=>(0,K.jsx)(`div`,{className:`px-5 pt-3 max-md:px-3`,children:(0,K.jsxs)(`button`,{className:`flex h-9 w-full items-center gap-2.5 rounded-lg border border-border bg-wash px-3 text-start text-ui text-muted-foreground hover:bg-row-hover hover:text-foreground max-md:h-11`,onClick:r,type:`button`,children:[(0,K.jsx)(`span`,{className:`font-mono text-xs text-subtle`,children:e}),(0,K.jsx)(`b`,{className:`font-medium whitespace-nowrap text-foreground`,children:t.replace(oO,``).split(`:`)[0]}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),(0,K.jsx)(`span`,{className:`text-xs whitespace-nowrap text-subtle`,children:`Show intro`})]})}),CO=e=>`${e.after?`After`:`Before`} line ${String(e.line)}`,wO=({notes:e})=>(0,K.jsx)(`aside`,{"aria-label":`Note on this file`,className:`mx-5 mt-3 grid file-note animate-enter gap-2 rounded-lg bg-foreground/4.5 px-4 pt-3 pb-3.25 max-md:mx-3`,children:e.map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`m-0 mb-1 flex items-center gap-1.5 font-mono text-2xs text-subtle`,children:[(0,K.jsx)(rE,{className:`size-3 shrink-0`}),CO(e)]}),(0,K.jsx)(`p`,{className:`m-0 max-w-160 text-sm text-pretty max-md:text-base`,children:(0,K.jsx)(nE,{isChipped:!0,text:YT(e.markdown.trim())})})]},`${String(e.line)}:${String(e.after)}:${e.markdown}`))}),TO=(e,t)=>{let n=t.isLayered?vw(t.cursor):null,r=n===null?void 0:e.layers[n];return r===void 0||r.isRemainder||n===null?null:{index:n,layer:r}},EO=({block:e,layer:t})=>{let{introsFolded:n}=Un(),r=QT(t),i=sO(e,t);return r===null?null:gO(e,t,n)||n.includes(i)?(0,K.jsx)(SO,{address:t.address,lead:r.lead,onOpen:()=>{_O(e,t)},title:t.title}):(0,K.jsx)(xO,{address:t.address,eyebrow:hO(e,t),facts:pO(e,t),intro:r,onFold:()=>{zn(i,!0)},title:t.title,children:(0,K.jsx)(vO,{points:r.points})})},DO=({block:e,ticket:t,path:n})=>{let{introsFolded:r}=Un(),i=ZT(t.note,n),a=cO(e,t);return i===null?null:r.includes(a)?(0,K.jsx)(SO,{address:t.address,lead:i.lead,onOpen:()=>{zn(a,!1)},title:t.title}):(0,K.jsxs)(xO,{address:t.address,eyebrow:`Layer ${t.address} of ${String(e.topLevel)} · ${String(t.sublayers)} parts`,facts:{count:t.files.length,added:t.added,detail:mO(t)},intro:i,onFold:()=>{zn(a,!0)},title:t.title,children:[(0,K.jsx)(vO,{points:i.points}),(0,K.jsx)(yO,{block:e,ticket:t})]})},OO=({block:e,layer:t,path:n})=>{let r=lO(e,t),i=r!==void 0&&dO(e,r)?.layer===t;return(0,K.jsxs)(K.Fragment,{children:[i?(0,K.jsx)(DO,{block:e,path:n,ticket:r}):null,(0,K.jsx)(EO,{block:e,layer:t})]})},kO=({block:e,state:t,path:n})=>{let{isNoted:r}=Un(),i=TO(e,t),a=i===null?[]:$T(i.layer,n);return!r||i===null?null:(0,K.jsxs)(K.Fragment,{children:[uO(e,i.layer)===n?(0,K.jsx)(OO,{block:e,layer:i.layer,path:n}):null,a.length===0?null:(0,K.jsx)(wO,{notes:a})]})},AO=({block:e,index:t,selected:n,onPickFile:r})=>{let{isNoted:i,introsFolded:a}=Un(),o=e.layers[t],s=o===void 0?void 0:uO(e,o),c=o!==void 0&&i&&!a.includes(sO(e,o))&&!gO(e,o,a)&&n===s;return(0,K.jsx)(iE,{intro:o===void 0?null:QT(o),isIntroShown:c,isPart:(o?.ticket??null)!==null,onOpenIntro:()=>{o!==void 0&&s!==void 0&&(_O(e,o),In({isNoted:!0}),r(hw(t,s),s))}})},jO=({block:e,ticket:t,selected:n,onPickFile:r})=>{let{isNoted:i,introsFolded:a}=Un(),o=dO(e,t),s=o===null?void 0:uO(e,o.layer),c=cO(e,t);return(0,K.jsx)(iE,{intro:ZT(t.note,s??``),isIntroShown:i&&!a.includes(c)&&n===s,onOpenIntro:()=>{o!==null&&s!==void 0&&(zn(c,!1),In({isNoted:!0}),r(hw(o.index,s),s))}})},MO=[{side:`old`,label:`Before`},{side:`new`,label:`After`}],NO=(e,t)=>{let n=new URLSearchParams({point:e.point,branch:e.block.branch,side:t,file:t===`old`?e.file.previousPath:e.file.path,sha:t===`old`?e.block.base.sha:e.block.head.sha});return`/decks/${encodeURIComponent(e.deck)}/review-image?${n.toString()}`},PO=e=>{let{image:t}=e.file;if(t===null)return null;let n=MO.filter(({side:e})=>t[e]);return(0,K.jsx)(`div`,{className:`mb-3 grid gap-3 rounded-md border border-border p-3 sm:grid-cols-2`,children:n.map(({side:t,label:n})=>(0,K.jsxs)(`figure`,{className:`m-0 grid content-start gap-1.5`,children:[(0,K.jsx)(`figcaption`,{className:`text-xs text-subtle`,children:n}),(0,K.jsx)(`img`,{alt:`${e.file.path}, ${n.toLowerCase()}`,className:`max-h-80 max-w-full justify-self-start rounded-sm bg-shot object-contain`,src:NO(e,t)})]},t))})},FO=({path:e,view:t,getSince:n,cursor:r})=>{let i=r===null?null:vw(r),a=n(e),o=a!==void 0&&GC(a,i)?a:void 0;return o===void 0?null:(0,K.jsx)(aO,{mode:t.modeOf(e),onMode:n=>{t.setMode(e,n)},since:o})},IO=/`(?<code>[^`]+)`|\[(?<label>[^\]]+)\]\((?<url>https?:\/\/[^)\s]+)\)|\*(?<em>[^*\s][^*]*)\*/gu,LO=(e,t)=>{let{code:n,label:r,url:i,em:a}=e;return n===void 0?i===void 0?(0,K.jsx)(`em`,{children:a},t):(0,K.jsx)(`a`,{className:`text-claude hover:underline`,href:i,rel:`noreferrer`,target:`_blank`,children:r},t):(0,K.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono`,children:n},t)},RO=({text:e})=>{let t=[...e.matchAll(IO)];return t.length===0?e:t.flatMap((n,r)=>{let i=t[r-1],a=i===void 0?0:i.index+i[0].length,o=n.index+n[0].length,s=[e.slice(a,n.index),LO(n.groups??{},o)];return r===t.length-1&&s.push(e.slice(o)),s})},zO=e=>e.split(/\n\s*\n/u).map(e=>e.replaceAll(/\s*\n\s*/gu,` `).trim()).filter(e=>e!==``),BO=({text:e})=>zO(e).map(e=>(0,K.jsx)(`p`,{className:`m-0`,children:(0,K.jsx)(RO,{text:e})},e)),VO=({tag:e})=>{if(e.name===`example`)return(0,K.jsx)(`pre`,{className:`m-0 font-mono text-xs/5 whitespace-pre-wrap text-foreground`,children:e.text});let[t=``,...n]=e.text.split(/\s+/u),r=e.name===`param`&&t!==``;return(0,K.jsxs)(`span`,{children:[r?(0,K.jsx)(`code`,{className:`me-1.5 font-mono text-foreground`,children:t}):null,(0,K.jsx)(RO,{text:(r?n.join(` `):e.text).replaceAll(/\s*\n\s*/gu,` `)})]})},HO=({hover:e})=>{let t=e.tags.filter(e=>e.text!==``),n=e.tags.filter(e=>e.text===``);return e.documentation===``&&e.tags.length===0?null:(0,K.jsxs)(`div`,{className:`grid gap-2 border-t border-border px-3 py-2.5 text-xs/5 text-muted-foreground`,children:[e.documentation===``?null:(0,K.jsx)(BO,{text:e.documentation}),t.length===0?null:(0,K.jsx)(`dl`,{className:`m-0 grid tag-rows gap-x-3 gap-y-1`,children:t.map((e,t)=>(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`font-mono text-subtle`,children:e.name}),(0,K.jsx)(`dd`,{className:`m-0 min-w-0 wrap-break-word`,children:(0,K.jsx)(VO,{tag:e})})]},`${e.name}-${String(t)}`))}),n.length===0?null:(0,K.jsx)(`p`,{className:`m-0 flex flex-wrap gap-1`,children:n.map(e=>(0,K.jsx)(`span`,{className:`rounded-sm bg-muted px-1.5 font-mono text-2xs text-subtle`,children:e.name},e.name))})]})},UO=2,WO=e=>{let t=e.lastIndexOf(`node_modules/`);if(t===-1)return e;let n=e.slice(t+13).split(`/`),r=n[0]?.startsWith(`@`)===!0?UO:1;return`${n.slice(0,r).join(`/`)} · ${n.slice(r).join(`/`)}`},GO=({definition:e,canJump:t,onJump:n})=>{let r=`${WO(e.path)}:${String(e.line)}`;return(0,K.jsx)(`p`,{className:`m-0 truncate border-t border-border px-3 py-1.5 font-mono text-xs/5 text-subtle`,title:`${e.path}:${String(e.line)}`,children:t(e.path)?(0,K.jsx)(`button`,{className:`text-start break-all hover-text`,onClick:()=>{n(e.path,e.line)},type:`button`,children:r}):r})},KO=({hover:e,canJump:t,onJump:n})=>(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`pre`,{className:`m-0 px-3 py-2 font-mono text-xs/5 wrap-break-word whitespace-pre-wrap`,dangerouslySetInnerHTML:{__html:e.html}}),(0,K.jsx)(HO,{hover:e}),e.definition===null?null:(0,K.jsx)(GO,{canJump:t,definition:e.definition,onJump:n})]}),qO=({shown:e,isOpen:t,canJump:n,onJump:r,onEnter:i,onLeave:a,onClose:o})=>(0,K.jsx)(hn,{onOpenChange:e=>{e||o()},open:t,children:e===null?null:(0,K.jsx)(Sn,{align:`start`,anchor:e.anchor,onMouseEnter:i,onMouseLeave:a,side:`bottom`,sideOffset:4,size:`code`,children:(0,K.jsx)(KO,{canJump:n,hover:e.hover,onJump:r})})}),JO=250,YO=120,XO=4500,ZO=6,QO=e=>{clearTimeout(e.asking?.timer),e.asking?.controller.abort(),e.asking=null},$O=async(e,{point:t,signal:n,left:r=ZO})=>{let i=performance.now(),a=await e(t,n);return a===null&&performance.now()-i>=XO&&r>1&&!n.aborted?$O(e,{point:t,signal:n,left:r-1}):a},ek=()=>{let e=(0,G.useRef)({asking:null,closing:void 0});return(0,G.useEffect)(()=>{let{current:t}=e;return()=>{clearTimeout(t.closing),QO(t)}},[]),{askingKey:()=>e.current.asking?.key,stopAsking:()=>{QO(e.current)},startAsking:t=>{QO(e.current),e.current.asking=t},keepOpen:()=>{clearTimeout(e.current.closing)},closeAfter:t=>{clearTimeout(e.current.closing),e.current.closing=setTimeout(t,YO)}}},tk=e=>{let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(!1),a=ek(),o=()=>{a.closeAfter(()=>{i(!1)})},s=async(t,r)=>{try{let o=await $O(e,{point:t,signal:r.signal});!r.signal.aborted&&o!==null&&(a.keepOpen(),n({key:t.key,hover:o,anchor:t.anchor}),i(!0))}catch{i(!1)}},c=e=>{let t=new AbortController,n=setTimeout(()=>{s(e,t)},JO);a.startAsking({key:e.key,timer:n,controller:t})},l=e=>r&&e.key===t?.key;return{shown:t,isOpen:r,handleEnter:a.keepOpen,point:e=>{(e===null||e.key!==a.askingKey())&&(e!==null&&l(e)?a.keepOpen():(a.stopAsking(),o(),e!==null&&c(e)))},handleLeave:()=>{a.stopAsking(),o()},handleClose:()=>{a.stopAsking(),a.keepOpen(),i(!1)}}},nk=/\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs)$/u,rk=/[\p{ID_Start}$_][\p{ID_Continue}$]*/gu;k({deck:b(),point:b(),branch:b(),path:a(b(),g(1)),line:a(i(),h(),A(1)),column:a(i(),h(),A(0))});var ik=e=>nk.test(e),ak=(e,t)=>{let n=[...e.matchAll(rk)].map(e=>({start:e.index,end:e.index+e[0].length}));return n.find(e=>e.start<=t&&t<e.end)??n.find(e=>e.end===t)??null},ok=`.token.comment, .token.string, .token.number`,sk=({clientX:e,clientY:t})=>{let n=document.caretPositionFromPoint(e,t);return n===null?null:{node:n.offsetNode,offset:n.offset}},ck=e=>{let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[];for(let e=t.nextNode();e!==null;e=t.nextNode())e instanceof Text&&n.push(e);return n},lk=(e,t)=>{let n=t.node instanceof Text?e.indexOf(t.node):-1;return n===-1?null:e.slice(0,n).reduce((e,t)=>e+t.length,0)+t.offset},uk=(e,t)=>{let n=t;for(let t of e){if(n<=t.length)return{node:t,at:n};n-=t.length}return null},dk=(e,{start:t,end:n})=>{let r=uk(e,t),i=uk(e,n);if(r===null||i===null)return null;let a=document.createRange();return a.setStart(r.node,r.at),a.setEnd(i.node,i.at),a},fk=(e,{clientX:t,clientY:n})=>[...e.getClientRects()].some(e=>t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom),pk=(e,t)=>{let n=sk(t);if(n===null||n.node.parentElement?.closest(ok)!==null)return null;let r=ck(e),i=lk(r,n),a=i===null?null:ak(e.textContent,i),o=a===null?null:dk(r,a);return a===null||o===null||!fk(o,t)?null:{word:a,range:o}},mk=(e,{line:t,pointer:n})=>{let r=pk(e,n);return r===null?null:{key:`${String(t)}:${String(r.word.start)}`,line:t,column:r.word.start,anchor:{getBoundingClientRect:()=>r.range.getBoundingClientRect(),contextElement:e}}},hk=u({method:`GET`}).handler(p(`81aea6d919e4c199dc875a22e9a9e4ad10e816bce0e36d084895c08d36390b40`)),gk=(e,t)=>{let n=e.target instanceof Element?e.target.closest(`[data-code]`):null,r=n?.closest(`[data-review-row]`)?.dataset.reviewRow,i=r===void 0?void 0:t.rows[Number(r)];return n===null||i===void 0||i.op===`del`||i.new===null?null:{code:n,line:i.new}},_k=({deck:e,point:t,branch:n,file:r})=>{let i=tk((i,a)=>hk({data:{deck:e,point:t,branch:n,path:r?.path??``,line:i.line,column:i.column},signal:a})),a=r!==void 0&&r.newSha!==null&&ik(r.path);return{hover:i,handleMove:e=>{if(!(e.target instanceof Node)||!e.currentTarget.contains(e.target))return;let t=a&&e.buttons===0?gk(e,r):null;i.point(t===null?null:mk(t.code,{line:t.line,pointer:e}))}}},vk=[],yk={op:`gap`,old:null,new:null,code:``,html:``},bk=e=>e.op===`add`||e.op===`del`,xk=e=>e?.new??e?.old??0,Sk=(e,t)=>{let n=xk(t);return t.op!==`gap`&&n>=e[0]&&n<=e[1]},Ck=(e,t)=>{let[n]=t.layers??[],r=n===void 0?void 0:e[n-1];return r===void 0||r.isRemainder||n===void 0?null:{layer:r.address,title:r.title}},wk=(e,{index:t,rows:n,runs:r=vk,isAllShown:i=!1})=>{let a=e=>e.layers?.includes(t+1)===!0;return!n.some(e=>a(e))||n.every(e=>!bk(e)||a(e))?void 0:{key:`${String(t)}|${i?`all`:r.flat().join(`,`)}`,isMine:a,isQuiet:e=>bk(e)&&!a(e)&&(i||e.quietIn?.includes(t+1)===!0),runOf:e=>r.find(t=>Sk(t,e)),said:t=>{let n=Ck(e,t);return n===null?`that no layer claims`:`from layer ${n.layer}`},quietOf:t=>{let n=Ck(e,t);return{layer:n?.layer??null,title:n?.title??`No layer claims these lines`,place:`one`}}}},Tk=(e,t)=>e!==void 0&&bk(t)&&!e.isMine(t)&&!e.isQuiet(t)&&e.runOf(t)===void 0,Ek=(e,t,n)=>{let[r]=e,i=e.length===1?`line`:`lines`,a=[xk(r),xk(e.at(-1))];return{...yk,code:`${String(e.length)} ${i} ${r===void 0?``:t.said(r)}`,others:{range:a,count:e.length,isOpen:n}}},Dk=(e,t)=>t===void 0||!bk(e)||t.isMine(e)||!t.isQuiet(e)&&t.runOf(e)===void 0?e:{...e,quiet:t.quietOf(e)},Ok=(e,{row:t,rows:n,claim:r})=>{let i=r.runOf(t),a=e.at(-1);if(i===void 0||a!==void 0&&r.runOf(a)===i)return;let o=n.filter(e=>bk(e)&&Sk(i,e)&&!r.isMine(e));e.push({...Ek(o,r,!0),others:{range:i,count:o.length,isOpen:!0}})},kk=(e,t)=>{let n=e.at(-1),{quiet:r}=t;if(r===void 0||n?.others?.isOpen!==!0&&n?.quiet?.layer!==r.layer)e.push(t);else{if(n.quiet!==void 0){let t=n.quiet.place===`one`?`top`:`mid`;e[e.length-1]={...n,quiet:{...n.quiet,place:t}}}e.push({...t,quiet:{...r,place:`end`}})}},Ak=(e,{row:t,rows:n,claim:r})=>{r!==void 0&&Ok(e,{row:t,rows:n,claim:r}),kk(e,Dk(t,r))},jk=(e,t)=>e.some(([e,n])=>e===t[0]&&n===t[1])?e.filter(([e,n])=>e!==t[0]||n!==t[1]):[...e,t],Mk=(e,{rows:t,line:n})=>{let r=t.find(e=>e.new===n);return r===void 0||!bk(r)||e.some(e=>Sk(e,r))?e:[...e,[n,n]]},Nk=[3,10,25,60],Pk=[],Fk=(e,t)=>t.op===`ctx`&&t.new!==null&&e.some(([e,n])=>t.new!==null&&t.new>=e&&t.new<=n),Ik=(e,{context:t,isShown:n})=>{let r=e.map(()=>!1),i=-1/0;e.forEach((e,a)=>{i=n(e)?a:i,r[a]=a-i<=t});let a=1/0;for(let i=e.length-1;i>=0;--i)a=n(e[i]??yk)?i:a,r[i]=r[i]===!0||a-i<=t;return r},Lk=(e,t)=>{let n=e[0]?.new,r=e.at(-1)?.new;return n==null||r==null?yk:{...yk,fold:{first:n,last:r,count:e.length,...t}}},Rk=(e,{claim:t,isTop:n,isBottom:r})=>{let i=e.filter(e=>bk(e)),[a]=i;return a===void 0?Lk(e,{isTop:n,isBottom:r}):t===void 0?yk:Ek(i,t,!1)},zk=(e,{context:t,claim:n,opened:r})=>{let i=Ik(e,{context:t,isShown:e=>bk(e)&&!Tk(n,e)}),a=[],o=[],s=e=>{a.push(Rk(o,{claim:n,isTop:a.length===0,isBottom:e})),o=[]};return e.forEach((t,c)=>{i[c]!==!0&&!Fk(r,t)||Tk(n,t)?o.push(t):(o.length>0&&s(!1),Ak(a,{row:t,rows:e,claim:n}))}),o.length>0&&s(!0),a},Bk=new WeakMap,Vk=(e,t,{claim:n,opened:r=Pk}={})=>{if(t===`whole`&&n===void 0)return e;let i=t===`whole`?1/0:t,a=Bk.get(e)??new Map,o=`${String(t)}|${n?.key??``}|${r.flat().join(`,`)}`,s=a.get(o)??zk(e,{context:i,claim:n,opened:r});return a.set(o,s),Bk.set(e,a),s},Hk=(e,{context:t,layers:n,cursor:r,opened:i,runs:a=vk,isAllShown:o=!1})=>{let s=r===null?null:vw(r),c=s===null?void 0:wk(n,{index:s,rows:e.rows,runs:a,isAllShown:o});return Vk(e.rows,t,{claim:c,opened:i})},Uk=10,Wk=e=>{let t=e?.fold;return t===void 0?null:t.count<=Uk?[t.first,t.last]:t.isTop?[t.last-Uk+1,t.last]:[t.first,t.first+Uk-1]},Gk=(e,{path:t,range:n})=>({...e,[t]:[...e[t]??Pk,n]}),Kk=(e,t)=>{let n=[...Nk,`whole`],r=Math.max(0,n.indexOf(e));return n[Math.min(n.length-1,Math.max(0,r+t))]??e},qk=({state:e,setState:t})=>(0,G.useCallback)(({range:n,index:r,isWhole:i})=>{let a=n[1]-n[0]+1,o=i?a-1:a;t({...e,opened:Gk(e.opened,{path:e.selected,range:n}),row:e.row>r?e.row+o:e.row})},[e,t]),Jk=(e,{range:t,index:n,count:r,isOpen:i})=>{let a=jk(e.runs[e.selected]??[],t),o=e.row>n+(i?r:0),s=i&&e.row>n?n:e.row;return{...e,runs:{...e.runs,[e.selected]:a},row:o?e.row+(i?-r:r):s}},Yk=({state:e,setState:t})=>(0,G.useCallback)(n=>{t(Jk(e,n))},[e,t]),Xk=e=>({openFold:qk(e),toggleRun:Yk(e)}),Zk=(e,{path:t,line:n,rows:r})=>({...e,context:`whole`,runs:{...e.runs,[t]:Mk(e.runs[t]??vk,{rows:r,line:n})}}),Qk=new WeakMap,$k=e=>{if(e.file===void 0)return[];let t=Qk.get(e.file.rows)??new Map,n=`${e.worktree??``}|${e.file.path}|${e.file.status}|${e.editor}`,r=t.get(n)??Uy(e);return t.set(n,r),Qk.set(e.file.rows,t),r},eA=(e,t)=>{let n=e.state.isLayered?vw(e.state.cursor):null,r=(n===null?[]:e.block.layers[n]?.parts??[]).find(e=>e.path===t.path),i=r===void 0||t.isSince===!0?t:r;return{added:i.added,removed:i.removed}},tA=(e,t)=>{let[n,r]=e?.split(`#`)??[];return n===t&&r!==void 0?Number(r):null},nA=(e,t,n)=>{let r=xy(e),i=t?.path??``,a=(0,G.useCallback)(e=>{let{state:t,setState:n}=r.current;n(e===null?{...t,settledAt:null}:{...t,settledAt:`${i}#${String(e)}`,focus:`diff`,row:e,anchor:null})},[r,i]);return{count:n,openRow:tA(e.state.settledAt,i),onOpen:a}},rA=(e,t)=>{let{editor:n}=Un(),r=nA(e,t,e.block.fileMarks.find(e=>e.path===t?.path)?.settled??0);return{counts:t===void 0?{added:0,removed:0}:eA(e,t),editorLinks:$k({worktree:e.block.worktree,file:t,editor:n}),editorFolder:zy(e.block.worktree,n),settled:r,lineMarks:Pb({lineMarks:e.block.lineMarks,threads:e.block.threads,drafts:e.extras.drafts,path:t?.path??``,rows:t?.rows??[],layer:e.state.isLayered?vw(e.state.cursor):null})}},iA=(e,t)=>{let n=(0,G.useRef)(t);(0,G.useEffect)(()=>{n.current=t}),(0,G.useEffect)(()=>{e!==``&&n.current()},[e])},aA=({lines:e,htmlOf:t,opOf:n,oldOf:r,onPick:i,panRef:a})=>e.length===0?null:(0,K.jsx)(`nav`,{"aria-label":`Scope`,className:`scope-stack font-mono code-size`,"data-review-scope":!0,ref:a,children:(0,K.jsx)(`div`,{className:`flex w-max min-w-full flex-col-reverse`,children:e.toReversed().map((e,a)=>(0,K.jsxs)(`button`,{className:`scope-line diff-row text-start`,"data-scope-depth":e.depth,"data-scope-last":a===0||void 0,"data-scope-line":e.line,"data-scope-op":n(e.line),onClick:()=>{i(e.line)},title:`Go to line ${String(e.line)}`,type:`button`,children:[(0,K.jsx)(`span`,{className:`diff-sticky diff-at-lead`}),(0,K.jsx)(`span`,{className:`diff-sticky diff-at-old pe-2 text-end text-subtle tabular-nums`,children:r(e.line)}),(0,K.jsx)(`span`,{className:`diff-sticky diff-at-new pe-2 text-end text-subtle tabular-nums`,children:e.line}),(0,K.jsx)(`span`,{className:`diff-sticky diff-at-sign`}),(0,K.jsxs)(`span`,{className:`pe-4 whitespace-pre pre-tab`,children:[(0,K.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t(e.line)}}),e.isElided?(0,K.jsx)(`span`,{className:`text-subtle`,children:` ⋯`}):null]})]},e.line))})}),oA=2,sA=(e,t)=>{let n=e.slice(t).find(e=>e.new!==null);return n===void 0?e.slice(0,t).findLast(e=>e.new!==null)?.new??null:n.new},cA=(e,t)=>{let n=[];if(t<=1||t>e.length)return n;for(let r=e[t-1]??0;r>0;r=e[r-1]??0)n.unshift(r);return n},lA=(e,t)=>{let n=e.map((e,t)=>({line:e,depth:t,isElided:!1}));if(n.length<=t||t<oA)return n.slice(0,t);let[r]=n;return r===void 0?[]:[{...r,isElided:!0},...n.slice(n.length-(t-1))]},uA=(e,t,n)=>{if(t===n)return!0;for(let r=e[t-1]??0;r>0;r=e[r-1]??0)if(r===n)return!0;return!1},dA=e=>new Set(e.filter(e=>e>0)),fA=(e,t,n)=>t.has(n)?[...cA(e,n),n]:cA(e,n),pA=`[data-review-row]`,mA=`[data-review-head]`,hA=`[data-scope-line]`,gA=1,_A=2,vA=32,yA=50,bA={lines:[],push:0,height:0},xA=e=>[...e.querySelectorAll(pA)],SA=e=>Number(e.dataset.reviewRow??``),CA=e=>{let t=e.querySelector(mA),n=(t??e).getBoundingClientRect();return t===null?n.top:n.bottom},wA=(e,t)=>{let n=e.querySelector(hA);if(n!==null)return n.getBoundingClientRect().height;let r=t.slice(0,yA).map(e=>e.getBoundingClientRect().height);return r.length===0?0:Math.min(...r)},TA=(e,t,n)=>{let r=dA(e.enclosedBy),i=new Map;return t.forEach((t,a)=>{let o=e.rows[SA(t)]?.new??null;o!==null&&fA(e.enclosedBy,r,o).forEach(e=>{i.has(e)||i.set(e,n[a]??0)})}),i},EA=({container:e,grid:t},n)=>{let r=xA(t),i=t.getBoundingClientRect().top,a=dA(n.enclosedBy),o=r.map(e=>e.getBoundingClientRect()),s=o.map(e=>e.top-i);return{tops:s,bottoms:o.map(e=>e.bottom-i),lines:r.map(e=>sA(n.rows,SA(e))),openers:r.map(e=>{let t=n.rows[SA(e)]?.new??null;return t!==null&&a.has(t)}),firstTops:TA(n,r,s),lineHeight:wA(e,r)}},DA=(e,t,n)=>{let r=0,i=e;for(;r<i;){let e=Math.floor((r+i)/_A),a=t(e)>n;r=a?r:e+1,i=a?e:i}return r},OA=(e,t,{row:n,top:r})=>{let i=e.lines[n]??null;if(i===null)return[];let a=cA(t.enclosedBy,i);return(e.openers[n]??!1)&&(e.tops[n]??0)<r-gA?[...a,i]:a},kA=(e,t)=>t.every((t,n)=>e[n]===t),AA=e=>Math.min(e,3),jA=(e,t,{top:n,depth:r})=>{let i=n+AA(r)*e.lineHeight,a=DA(e.bottoms.length,t=>e.bottoms[t]??0,i);return{row:a,slotTop:i,chain:OA(e,t,{row:a,top:i})}},MA=(e,t,n)=>(e.firstTops.get(t)??1/0)<n-gA,NA=(e,t,n)=>{let r=[],i=0;for(let a=0;a<vA;a+=1){let{row:o,slotTop:s,chain:c}=jA(e,t,{top:n,depth:a}),l=c[a];if(l===void 0||!kA(c,r)||!MA(e,l,s))break;r.push(l),i=o}return{pinned:r,probe:i}},PA=(e,t,{scope:n,from:r,bottom:i})=>{for(let a=r;a<e.tops.length&&(e.tops[a]??0)<i;a+=1){let r=e.lines[a]??null;if(r!==null&&!uA(t.enclosedBy,r,n))return Math.min(0,(e.tops[a]??0)-i)}return 0},FA=(e,t,n)=>{if(t.enclosedBy.length===0||e.lineHeight===0)return bA;let{pinned:r,probe:i}=NA(e,t,n),a=r.at(-1);if(a===void 0)return bA;let o=lA(r,4),s=o.length*e.lineHeight;return{lines:o,push:PA(e,t,{scope:a,from:i,bottom:n+s}),height:s}},IA=(e,t)=>CA(e)-t.getBoundingClientRect().top,LA=e=>Math.max(CA(e),...[...e.querySelectorAll(hA)].map(e=>e.getBoundingClientRect().bottom)),RA=e=>{let t=xA(e);return t[DA(t.length,e=>t[e]?.getBoundingClientRect().bottom??0,LA(e)+gA)]??null},zA=e=>e.map(e=>`${String(e.line)}${e.isElided?`+`:``}`).join(`,`),BA=(e,t)=>zA(e)===zA(t),VA=(e,t,n)=>{let r=dA(t.enclosedBy);return new Set(e.flatMap(e=>{let i=SA(e)<n?t.rows[SA(e)]?.new??null:null;return i===null?[]:fA(t.enclosedBy,r,i)}))},HA=(e,t,n)=>{let r=sA(t.rows,n);if(!Vn().isScoped||t.enclosedBy.length===0||r===null)return 0;let i=xA(e),a=VA(i,t,n);return lA(cA(t.enclosedBy,r).filter(e=>a.has(e)),4).length*wA(e,i)},UA=(e,t,n)=>{let r=e.querySelector(`[data-review-row="${String(n)}"]`);r!==null&&(e.scrollTop+=Math.floor(r.getBoundingClientRect().top-CA(e)-HA(e,t,n)))},WA=e=>e.querySelector(mA)?.getBoundingClientRect().height??0,GA=()=>{},KA=(e,t)=>{let n=(0,G.useRef)(t),r=(0,G.useRef)(null),i=(0,G.useRef)(()=>{r.current??=requestAnimationFrame(()=>{r.current=null,n.current()})});return(0,G.useEffect)(()=>{n.current=t,i.current()}),(0,G.useEffect)(()=>{if(e===null)return GA;let t=i.current;e.addEventListener(`scroll`,t,{passive:!0});let n=new ResizeObserver(t);return n.observe(e),()=>{e.removeEventListener(`scroll`,t),n.disconnect(),r.current!==null&&(cancelAnimationFrame(r.current),r.current=null)}},[e]),()=>{i.current()}},qA=()=>{},JA=(e,t)=>{let n=(0,G.useRef)(t);(0,G.useEffect)(()=>{n.current=t}),(0,G.useEffect)(()=>{if(e===null)return qA;let t=new ResizeObserver(()=>{n.current()});return t.observe(e),()=>{t.disconnect()}},[e])},YA=`[data-scope-line]`,XA=`[data-scope-last]`,ZA=(e,t)=>{let n=[...e.querySelectorAll(YA)],r=e.querySelector(XA);n.forEach(e=>{let n=e===r&&t<0?`translateY(${String(t)}px)`:``;e.style.transform!==n&&(e.style.transform=n)})},QA=(e,t)=>{let n=`${String(Math.round(WA(e)+t))}px`;e.style.scrollPaddingTop!==n&&(e.style.scrollPaddingTop=n)},$A=(e,t)=>{let n=(0,G.useRef)(null),r=(0,G.useRef)(!0);return{markDirty:()=>{r.current=!0},read:()=>{if(e===null||!t)return bA;let i={rows:e.file.rows,enclosedBy:e.file.enclosedBy};return(r.current||n.current?.key!==e.file.fingerprint)&&(n.current={key:e.file.fingerprint,value:EA({container:e.container,grid:e.grid},i)},r.current=!1),FA(n.current.value,i,IA(e.container,e.grid))}}},ej=(e,{grid:t,file:n})=>{let{isScoped:r}=Un(),[i,a]=(0,G.useState)([]),o=(0,G.useRef)([]),s=$A(e===null||t===null||n===void 0?null:{container:e,grid:t,file:n},r),c=KA(e,()=>{if(e===null)return;let t=s.read();BA(t.lines,o.current)||(o.current=t.lines,(0,xa.flushSync)(()=>{a(t.lines)})),ZA(e,t.push),QA(e,t.height)});return JA(t,()=>{s.markDirty(),c()}),i},tj=({props:e,file:t,whole:n,container:r})=>{let{state:i,setState:a}=e,[o,s]=(0,G.useState)(null),c=t?.rows??[],l=o===null?-1:c.findIndex(e=>e.new===o),u=`${t?.fingerprint??``}|${String(i.context)}|${String(i.isWrapped)}`;return iA(l===-1?``:`${String(o)}|${u}`,()=>{r!==null&&t!==void 0&&UA(r,t,l),s(null)}),e=>{s(e),c.some(t=>t.new===e)||a(Zk(i,{path:i.selected,line:e,rows:n?.rows??[]}))}},nj=()=>{let e=(0,G.useRef)({node:null,left:0});return{panRef:(0,G.useCallback)(t=>{e.current.node=t,t!==null&&(t.scrollLeft=e.current.left)},[]),handleCodeScroll:t=>{e.current.left=t,e.current.node!==null&&(e.current.node.scrollLeft=t)}}},rj=e=>{let t=new WeakMap;return n=>{let r=n?.rows??[],i=t.get(r);if(i!==void 0)return i;let a=new Map(r.flatMap(t=>t.new===null?[]:[[t.new,e(t)]]));return t.set(r,a),a}},ij=rj(e=>e.html),aj=rj(e=>e.op),oj=rj(e=>e.old),sj=({props:e,file:t,whole:n})=>{let[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(null),s=ej(r,{grid:a,file:t}),c=tj({props:e,file:t,whole:n,container:r}),{panRef:l,handleCodeScroll:u}=nj(),d=ij(n),f=aj(t),p=oj(n);return{setContainer:i,setGrid:o,handleCodeScroll:u,stack:(0,K.jsx)(aA,{htmlOf:e=>d.get(e)??``,lines:s,oldOf:e=>p.get(e)??null,onPick:c,opOf:e=>f.get(e)??`ctx`,panRef:l})}},cj=({failure:e,onDismiss:t})=>e===null?null:(0,K.jsxs)(`p`,{className:`m-0 flex items-start justify-between gap-3 border-b border-border px-3 py-2 text-sm text-destructive`,role:`alert`,children:[(0,K.jsx)(`span`,{children:e}),(0,K.jsx)(`button`,{className:`shrink-0 text-subtle hover:text-foreground`,onClick:t,type:`button`,children:`Dismiss`})]}),lj=({from:e})=>e.map((e,t)=>e.failure===null?null:(0,K.jsx)(cj,{failure:e.failure,onDismiss:e.handleDismissFailure},`${String(t)}:${e.failure}`)),uj={added:`New file`,modified:`Changed`,deleted:`Deleted file`,renamed:`Renamed`,copied:`Copied`},dj=({file:e,counts:t})=>(0,K.jsxs)(`p`,{className:`m-0 flex gap-2 px-4 pt-1 pb-2.5 text-ui text-muted-foreground tabular-nums md:hidden`,children:[(0,K.jsx)(`span`,{className:`font-mono text-sign-add`,children:`+${String(t.added)}`}),t.removed>0?(0,K.jsx)(`span`,{className:`font-mono text-sign-del`,children:`−${String(t.removed)}`}):null,(0,K.jsx)(`span`,{children:uj[e.status]})]}),fj=({file:e})=>(e.status===`renamed`||e.status===`copied`)&&e.added===0&&e.removed===0?(0,K.jsxs)(`p`,{className:`m-0 px-5 py-4 text-sm text-muted-foreground max-md:px-4`,children:[`${e.status===`renamed`?`Moved`:`Copied`} from `,(0,K.jsx)(`code`,{className:`font-mono text-foreground`,children:e.previousPath}),` with no changes: git paired the two files because their content is the same.`]}):null,pj=({block:e,file:t,state:n})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(kO,{block:e,path:t.path,state:n}),(0,K.jsx)(fj,{file:t})]}),mj=({props:e,file:t,marks:n})=>(0,K.jsx)(FO,{cursor:e.state.isLayered?e.state.cursor:null,getSince:n.getSince,path:t.path,view:e.sinceView}),hj=({props:e,file:t,whole:n,comments:r,marks:i,acts:a,selection:o,jump:s,headActions:c})=>{let{block:l,deck:u,view:d,state:f}=e,p=_k({deck:u,point:d.id,branch:l.branch,file:t}),m=sj({props:e,file:t,whole:n}),{editorFolder:h,counts:g,..._}=rA(e,t),{openFold:v,toggleRun:y}=Xk(e),b=t!==void 0&&o!==null&&e.isFileLoaded(t.path);return(0,K.jsx)(`div`,{className:`min-h-0 min-w-0 review-diff`,"data-editor-folder":h??void 0,"data-review-diff":!0,ref:n=>{m.setContainer(n),n!==null&&b&&e.onDiffShown(n,t)},children:b?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(lj,{from:[r,i,a]}),(0,K.jsx)(mj,{file:t,marks:i,props:e}),(0,K.jsx)(dj,{counts:g,file:t}),(0,K.jsx)(PO,{block:l,deck:u,file:t,point:d.id}),(0,K.jsx)(`div`,{onMouseLeave:p.hover.handleLeave,onMouseMove:p.handleMove,children:(0,K.jsx)(US,{..._,headActions:c,isFramed:!1,lead:(0,K.jsx)(pj,{block:l,file:t,state:f}),counts:g,onOpenFold:v,onToggleRun:y,actions:r.actions,deck:u,file:t,onCodeScroll:m.handleCodeScroll,rowsRef:m.setGrid,scope:m.stack,live:r.live,revision:r.revision,cursorRow:f.focus===`diff`?f.row:null,isWrapped:f.isWrapped,selection:o})}),(0,K.jsx)(qO,{canJump:s.canJump,isOpen:p.hover.isOpen,onClose:p.hover.handleClose,onEnter:p.hover.handleEnter,onJump:(e,t)=>{p.hover.handleClose(),s.handleJump(e,t)},onLeave:p.hover.handleLeave,shown:p.hover.shown})]}):(0,K.jsx)(`p`,{className:`m-0 p-3 text-sm text-subtle`,children:l.error??(t===void 0?`No file selected`:`Reading ${t.path}…`)})},f.selected)},gj={key:`e`,keys:[`e`]},_j=({isOn:e,label:t,said:n,shortcutKey:r,onToggle:i})=>(0,K.jsx)(wn,{keys:[r],label:n,side:`bottom`,children:(0,K.jsxs)(`button`,{"aria-pressed":e,className:`group inline-flex h-6 items-center gap-1.75 rounded-md px-2 text-xs text-muted-foreground hover:bg-secondary hover:text-foreground`,"data-on":e?``:void 0,onClick:i,type:`button`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`relative h-4 w-6.5 rounded-full bg-secondary transition-colors duration-200 group-data-on:bg-sign-add`,children:(0,K.jsx)(`span`,{className:`absolute inset-s-0.5 top-0.5 size-3 rounded-full bg-muted-foreground transition-transform duration-200 ease-out group-data-on:translate-x-2.5 group-data-on:bg-white`})}),t]})}),vj=()=>{let{isNoted:e,isOthersShown:t}=Un();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_j,{isOn:e,label:`Notes`,onToggle:Fn,said:`Layer notes over the code`,shortcutKey:`I`}),(0,K.jsx)(_j,{isOn:t,label:`Other layers`,onToggle:An,said:`Other layers' lines in place, quiet, rather than folded`,shortcutKey:`O`})]})},yj=({isReviewed:e,isLayered:t,canOpen:n,onPress:r})=>(0,K.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 font-sans`,children:[t?(0,K.jsx)(vj,{}):null,(0,K.jsx)(wn,{keys:[`m`],side:`bottom`,children:(0,K.jsxs)(`button`,{"aria-pressed":e,className:`inline-flex h-6 press items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground hover:bg-secondary hover:text-foreground aria-pressed:text-success`,onClick:()=>{r(`m`)},type:`button`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:W(`grid size-3.25 place-items-center rounded-sm border transition-colors duration-150`,e?`border-success bg-success text-background`:`border-input`),children:(0,K.jsx)(ar,{className:`size-2.5 icon-swap`,"data-off":e?void 0:``,strokeWidth:3})}),e?`Reviewed`:`Mark reviewed`]})}),n?(0,K.jsx)(On,{label:`Open in editor`,onClick:()=>{r(`e`)},shortcut:gj,size:`icon-xs`,children:(0,K.jsx)(Ti,{})}):null]}),bj={remarks:`Remarks`,dismissed:`Dismissed`,held:`Waiting to be sent`,asked:`Waiting on you`,filed:`Not picked up`,with:`Picked up, no answer`,answered:`Answered, not settled`,movedOn:`The branch moved past these`,settled:`Settled`,removed:`Removed`},xj=[`remarks`,`held`,`asked`,`filed`,`with`,`answered`,`movedOn`,`settled`,`removed`,`dismissed`],Sj=({threads:e,remarks:t,drafts:n,isTheirs:r,pile:i})=>{let a=new Map(xj.map(e=>[e,[]]));return t.filter(e=>e.state!==`accepted`).forEach(e=>{a.get(e.state===`dismissed`?`dismissed`:`remarks`)?.push({kind:`remark`,remark:e})}),n.forEach(e=>{a.get(`held`)?.push({kind:`draft`,draft:e})}),e.forEach(e=>{a.get(i?.get(e.id)??e.section)?.push({kind:`thread`,thread:e})}),xj.flatMap(e=>{let t=a.get(e)??[],n=e===`held`&&r?`Held for the author`:bj[e];return t.length===0?[]:[{key:e,title:n,entries:t}]})},Cj=e=>e.kind===`thread`?e.thread:e.kind===`remark`?e.remark:e.draft,wj=e=>{if(e.kind===`thread`&&e.thread.isAboutBranch)return{file:``,label:`Reading order`,line:0};let t=Cj(e),n=t.file.split(`/`).at(-1)??t.file,r=t.start===t.end?String(t.end):`${String(t.start)}-${String(t.end)}`;return{file:t.file,label:`${n}:${r}`,line:t.start}},Tj=e=>Cj(e).body.split(`
|
|
45
|
+
`)[0]??``,Ej=new Set([`remarks`,`asked`,`with`,`answered`]),Dj=new Set([`settled`,`removed`,`dismissed`]),Oj=e=>{if(e.kind!==`thread`)return Tj(e);let{thread:t}=e;return(t.doing?.body??t.turns.at(-1)?.body??t.body).split(`
|
|
46
|
+
`)[0]??``},kj=e=>{if(e.kind!==`thread`)return null;let{thread:t}=e;return t.doing?.at??t.turns.at(-1)?.at??t.at},Aj=e=>e.kind===`thread`?e.thread.unread>0||e.thread.stand===`asked`:e.kind===`remark`&&e.remark.state!==`dismissed`,jj=new Set([`j`,`k`,`ArrowDown`,`ArrowUp`,`Enter`,`Escape`,`d`,`X`]),Mj=e=>e.kind===`thread`&&(e.thread.isMovedPast||e.thread.isAboutBranch),Nj=e=>Cj(e).id,Pj=new Set([`asked`,`answered`,`movedOn`]),Fj=e=>Pj.has(e),Ij=e=>e===void 0||e.isSettled||e.state===`removed`||e.turns.at(-1)?.voice===`reviewer`||e.stand!==`asked`&&e.stand!==`answered`,Lj=e=>Sj({threads:e,remarks:[],drafts:[],isTheirs:!1}).flatMap(({key:e,entries:t})=>Fj(e)?t.flatMap(t=>t.kind===`thread`&&!Ij(t.thread)?[{id:t.thread.id,section:e}]:[]):[]),Rj=e=>new Map(e.map(e=>[e.id,e])),zj=(e,t)=>{let n=Rj(t);return e.filter(e=>!Ij(n.get(e.id))).length},Bj=e=>e!==void 0&&!e.isSettled&&e.state!==`removed`,Vj=(e,t)=>{let n=Rj(t);return e.filter(e=>Bj(n.get(e.id)))},Hj=(e,t)=>{let n=Rj(t);return e.find(e=>!Ij(n.get(e.id)))?.id??null},Uj=(e,{threads:t,at:n,offset:r})=>{let i=Vj(e,t);if(n===null)return(r>0?i[0]:i.at(-1))?.id??null;let a=e.map(e=>e.id),o=a.indexOf(n),s=i.filter(e=>a.indexOf(e.id)>o),c=i.filter(e=>a.indexOf(e.id)<o);return(r>0?s[r-1]:c.at(r))?.id??null},Wj=(e,{threads:t,at:n,offset:r})=>{let i=Vj(e,t),a=[...new Set(i.map(e=>e.section))],o=e.find(e=>e.id===n)?.section??a[0],s=o===void 0?-1:a.indexOf(o),c=e=>i.find(t=>t.section===e)?.id??null;if(r>0)return c(a[s+1])??n;let l=c(o);return l!==n&&l!==null?l:c(a[s-1])??n},Gj=e=>e===null?void 0:new Map(e.map(e=>[e.id,e.section])),Kj=e=>{let t=e.lastIndexOf(`/`)+1;return{dir:e.slice(0,t),base:e.slice(t)}},qj=e=>e.start===e.end?String(e.start):`${String(e.start)}–${String(e.end)}`,Jj=({thread:e})=>{if(e.isAboutBranch)return(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Reading order`});let{dir:t,base:n}=Kj(e.file);return(0,K.jsxs)(`span`,{className:`min-w-0 truncate font-mono`,title:e.file,children:[(0,K.jsx)(`span`,{className:`text-subtle`,children:t}),(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,K.jsx)(`span`,{className:`text-subtle`,children:`:${qj(e)}`})]})},Yj=({children:e})=>(0,K.jsx)(`span`,{className:`shrink-0 rounded-sm bg-secondary px-1.5 text-2xs whitespace-nowrap text-muted-foreground`,children:e}),Xj=e=>{let t=Kj(e.file).base;return e.isMovedPast?`Open in ${e.layerAddress===null?t:`layer ${e.layerAddress}`}, near line ${String(e.start)}`:`Open in the diff, at line ${String(e.start)}`},Zj=e=>e.start===e.end?`line ${String(e.start)} is gone`:`lines ${qj(e)} are gone`,Qj={changed:`Changed since you commented`,before:`Before the change`,now:null},$j={add:`+`,del:`−`,ctx:``,gap:``},eM=({code:e,stand:t})=>{let n=Qj[e.said];return(0,K.jsxs)(`div`,{className:`border-b border-border bg-background py-1.5`,children:[n===null?null:(0,K.jsx)(`div`,{className:`px-3 pt-0.5 pb-1.5 text-xs text-subtle`,children:n}),(0,K.jsx)(`div`,{className:`grid font-mono text-xs/5`,children:e.rows.map((n,r)=>(0,K.jsxs)(`div`,{className:W(`thread-code-row`,n.op===`add`&&`bg-line-add`,n.op===`del`&&`bg-line-del`),children:[(0,K.jsx)(`span`,{className:W(`grid place-items-center`,Fb[t]),children:e.marked[r]===!0?(0,K.jsx)(Rb,{stand:t}):null}),(0,K.jsx)(`span`,{className:`pe-1.5 text-end text-subtle tabular-nums`,children:n.old??``}),(0,K.jsx)(`span`,{className:`pe-1.5 text-end text-subtle tabular-nums`,children:n.new??``}),(0,K.jsx)(`span`,{className:W(`text-center`,n.op===`add`&&`text-sign-add`,n.op===`del`&&`text-sign-del`),children:$j[n.op]}),(0,K.jsx)(`span`,{className:`overflow-hidden pe-3 text-ellipsis whitespace-pre`,dangerouslySetInnerHTML:{__html:n.html}})]},`${n.op}:${String(n.old)}:${String(n.new)}`))})]})},tM=({thread:e,lead:t,...n})=>{let r=t.placed(e),i=Ub(r.root,r.replies),a=t.code[e.id],o=t.current?.id===e.id,s=r.replies.length+1,c=r.replies.at(-1)?.at??r.root.at;return(0,K.jsxs)(`article`,{className:W(`grid scroll-mt-14 overflow-hidden rounded-lg border bg-wash font-sans text-sm`,o&&`border-foreground/22`,!o&&i===`asked`&&`border-stand-asked/45`,!o&&i!==`asked`&&`border-border`),"data-thread-card":e.id,"data-thread-current":o?``:void 0,onFocusCapture:()=>{t.pick(e.id)},children:[(0,K.jsxs)(`div`,{className:`flex h-8 min-w-0 items-center gap-1.5 border-b border-border px-3 text-xs`,children:[(0,K.jsx)(Wb,{stand:i}),(0,K.jsx)(`button`,{className:`flex min-w-0 items-center text-start`,onClick:()=>{t.pick(e.id)},type:`button`,children:(0,K.jsx)(Jj,{thread:e})}),e.isMovedPast?(0,K.jsx)(Yj,{children:Zj(e)}):null,e.isOutdated&&!e.isMovedPast?(0,K.jsx)(Yj,{children:`Code changed`}):null,(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-subtle tabular-nums`,children:`${String(s)} ${s===1?`message`:`messages`} ·`}),(0,K.jsx)(`span`,{className:`shrink-0`,children:(0,K.jsx)(ux,{at:c})}),e.isAboutBranch?null:(0,K.jsx)(`span`,{className:`-me-1.5 shrink-0`,children:(0,K.jsx)(On,{label:Xj(e),onClick:()=>{t.showInDiff(e)},size:`icon-xs`,variant:`ghost`,children:(0,K.jsx)($r,{})})})]}),a===void 0?null:(0,K.jsx)(eM,{code:a,stand:i}),(0,K.jsx)(bx,{...n,isCurrent:o,thread:{...r,isOutdated:a===void 0&&r.isOutdated}})]})},nM={asked:`Waiting on you`,answered:`Answered, not settled`,movedOn:`The branch moved past these`},rM=e=>nM[e],iM={asked:`text-stand-asked`,answered:`text-stand-answered`,movedOn:`text-foreground`},aM=({thread:e,lead:t})=>{let n=e.turns.length+1;return(0,K.jsxs)(`button`,{className:`flex h-8 min-w-0 items-center gap-2 rounded-lg border border-border bg-wash px-3 text-start text-xs text-subtle`,onClick:()=>{t.showInDiff(e)},type:`button`,children:[(0,K.jsx)(`span`,{className:W(`inline-grid shrink-0`,Fb.settled),children:(0,K.jsx)(Rb,{stand:`settled`})}),(0,K.jsx)(`span`,{className:`shrink-0`,children:`Settled`}),(0,K.jsx)(`span`,{className:`shrink-0 font-mono`,children:e.isAboutBranch?`Reading order`:`${Kj(e.file).base}:${qj(e)}`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:e.body.split(`
|
|
47
|
+
`)[0]}),(0,K.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`${String(n)} messages`})]})},oM=e=>{let t=e.pile.map(e=>e.id),n=e.current===void 0?t.length:t.indexOf(e.current.id);return t.slice(0,n).filter(t=>!Ij(e.found.get(t)))},sM=(e,t)=>e.left===0?`Every thread is handled`:t.length>0?null:`${String(e.left)} left`,cM=({lead:e,onTurn:t})=>{let n=oM(e),r=sM(e,n);return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-1 pt-4 text-xs text-subtle`,children:[r===null?(0,K.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground`,onClick:()=>{e.pick(n[0]??null)},type:`button`,children:`${String(n.length)} skipped above`}):(0,K.jsx)(`span`,{children:r}),(0,K.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,K.jsxs)(`button`,{className:`inline-flex items-center gap-1.5 hover:text-foreground`,onClick:t,type:`button`,children:[(0,K.jsx)(tn,{children:`T`}),`goes back to the diff`]})]})},lM=e=>e.reduce((e,t)=>{let n=e.at(-1);return n?.section===t.section?n.ids.push(t.id):e.push({section:t.section,ids:[t.id]}),e},[]),uM=({onTurn:e,...t})=>{let{lead:n}=t,r=lM(n.pile),i=n.current?.id??``;iA(i,()=>{requestAnimationFrame(()=>{document.querySelector(`[data-thread-card="${CSS.escape(i)}"]`)?.scrollIntoView({block:`start`,behavior:`smooth`})})});let a=n.pile.find(e=>e.id===n.current?.id)?.section??r[0]?.section;return(0,K.jsxs)(`div`,{className:`min-h-0 min-w-0 review-diff`,"data-review-threads":!0,children:[(0,K.jsxs)(`div`,{className:`sticky top-0 z-4 flex h-11 items-center gap-2.5 border-b border-border bg-background ps-5 pe-3 text-xs`,children:[a===void 0?(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Nothing needs you`}):(0,K.jsx)(`span`,{className:W(`font-medium`,iM[a]),children:rM(a)}),(0,K.jsx)(`span`,{className:`text-subtle tabular-nums`,children:`${String(n.left)} left`}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsx)(wn,{keys:[`↵`],children:(0,K.jsx)(`button`,{className:`inline-flex h-6 items-center gap-1.5 rounded-md px-2 text-muted-foreground hover:bg-secondary hover:text-foreground disabled:opacity-50`,disabled:n.current===void 0||n.current.isAboutBranch,onClick:()=>{n.showInDiff()},type:`button`,children:`Show in the diff`})})]}),(0,K.jsxs)(`div`,{className:`grid gap-2.5 px-4 pt-3 pb-24`,children:[r.map((e,r)=>(0,K.jsxs)(`section`,{className:`grid gap-2.5`,children:[r===0?null:(0,K.jsx)(`h3`,{className:`m-0 -mx-4 mt-3 border-t border-border px-5 pt-3 pb-0.5 text-xs font-medium`,children:(0,K.jsx)(`span`,{className:iM[e.section],children:rM(e.section)})}),e.ids.map(e=>{let r=n.found.get(e);return r===void 0?null:r.isSettled?(0,K.jsx)(aM,{lead:n,thread:r},e):(0,K.jsx)(tM,{...t,thread:r},e)})]},`${e.section}:${String(r)}`)),(0,K.jsx)(cM,{lead:n,onTurn:e})]})]})},dM=`inline-flex h-6 items-center gap-1.5 rounded-md px-2.5 font-medium text-muted-foreground hover:text-foreground aria-pressed:bg-secondary aria-pressed:text-foreground`,fM=({isThreads:e,left:t,onTurn:n})=>(0,K.jsx)(wn,{keys:[`T`],label:`The diff, or every thread that needs you, in the middle`,children:(0,K.jsxs)(`fieldset`,{className:`m-0 inline-flex min-w-0 shrink-0 items-center gap-0.5 rounded-lg border border-border bg-background p-0.5`,children:[(0,K.jsx)(`legend`,{className:`sr-only`,children:`What fills the middle`}),(0,K.jsx)(`button`,{"aria-pressed":!e,className:dM,onClick:e?n:void 0,type:`button`,children:`Diff`}),(0,K.jsxs)(`button`,{"aria-pressed":e,className:dM,onClick:e?void 0:n,type:`button`,children:[`Threads`,(0,K.jsx)(`span`,{className:`font-normal text-subtle tabular-nums`,children:`${String(t)} left`})]})]})}),pM=({props:e,pane:t,lead:n,onPress:r})=>{let{state:i}=e,a=n.turn;return n.isOn?(0,K.jsx)(uM,{actions:t.comments.actions,deck:e.deck,lead:n,live:t.comments.live,onTurn:a,revision:t.comments.revision}):(0,K.jsx)(hj,{acts:t.acts,comments:t.comments,file:t.file,headActions:(0,K.jsx)(yj,{canOpen:e.block.worktree!==null&&t.file?.status!==`deleted`,isLayered:i.isLayered,isReviewed:t.file!==void 0&&t.model.isReadHere(t.file.path),onPress:r}),jump:t.jump,marks:t.model.marks,props:e,selection:t.selection,whole:t.model.files.get(i.selected)})},mM=(e,t,n)=>`${String(e)} ${e===1?t:n}`,hM=e=>e.state!==`accepted`&&e.state!==`dismissed`,gM={title:`Nothing needs you`,rest:``},_M=(e,t)=>e+t===0?gM:{title:mM(e,`remark`,`remarks`),rest:t===0?``:`· ${mM(t,`note`,`notes`)} held for the author`},vM=({asked:e,unread:t})=>{let n=`${mM(t,`answer`,`answers`)} to read`;return e>0?{title:mM(e,`question`,`questions`),rest:t>0?`· ${n}`:``}:t>0?{title:n,rest:``}:gM},yM=({counts:e,remarks:t,drafts:n,isTheirs:r})=>r?_M(t.filter(e=>hM(e)).length,n.length):e===null?null:vM(e),bM=({counts:e,remarks:t,isTheirs:n})=>n?t.filter(e=>hM(e)).length:e?.asked??0,xM=({label:e,hint:t,isFilled:n=!1,onClick:r})=>{let i=(0,K.jsx)(`button`,{className:W(`inline-flex h-7 shrink-0 press items-center gap-1.5 rounded-md border px-2.5 text-xs font-medium max-md:h-11 max-md:rounded-full max-md:px-4 max-md:text-sm`,n?`border-accent bg-accent text-accent-foreground`:`border-border bg-background hover:bg-row-hover`),onClick:r,type:`button`,children:e});return t===void 0?i:(0,K.jsx)(wn,{keys:[t],children:i})},SM=({entry:e})=>{let t=wj(e),n=kj(e);return(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs/4.5 text-subtle max-md:text-sm/5`,children:[(0,K.jsxs)(`span`,{className:W(`truncate`,t.file===``?``:`font-mono`),title:t.file,children:[e.kind===`remark`?`${e.remark.by} · `:``,t.label]}),n===null?null:(0,K.jsx)(`span`,{className:`ms-auto shrink-0 tabular-nums`,children:(0,K.jsx)(ux,{at:n})})]})},CM=({entry:e})=>e.kind===`thread`?(0,K.jsx)(`span`,{className:W(`grid h-4.5 w-4 shrink-0 place-items-center`,Fb[e.thread.stand]),children:(0,K.jsx)(Rb,{stand:e.thread.stand})}):null,wM=({entry:e,sectionKey:t,isOn:n,onPick:r,tools:i})=>{let a=Ej.has(t);return(0,K.jsxs)(`div`,{className:`group/row relative px-1.5`,children:[(0,K.jsxs)(`button`,{className:W(`flex w-full animate-enter gap-2 rounded-lg px-2 pt-2 pb-2.5 text-start transition-colors duration-150 max-md:px-3`,n?`bg-line-selected`:`group-hover/row:bg-row-hover`,a?`max-md:min-h-20`:`max-md:min-h-14`),"data-panel-entry":Nj(e),onClick:r,type:`button`,children:[t===`movedOn`?(0,K.jsx)(CM,{entry:e}):null,(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,K.jsx)(SM,{entry:e}),(0,K.jsx)(`span`,{className:W(`text-ui transition-colors duration-300 max-md:text-base/6`,a?`line-clamp-2`:`line-clamp-1`,Aj(e)?`text-foreground`:`text-subtle`),children:Oj(e)})]})]}),i===void 0?null:(0,K.jsx)(`div`,{className:W(`pointer-events-none absolute inset-e-3 top-1 flex items-center gap-0.5 rounded-md opacity-0 transition-opacity duration-150 group-focus-within/row:pointer-events-auto group-focus-within/row:opacity-100 group-hover/row:pointer-events-auto group-hover/row:opacity-100 max-md:hidden`,n?`bg-line-selected`:`bg-row-hover`),children:i})]})},TM={asked:`text-stand-asked`,answered:`text-stand-answered`,filed:`text-stand-filed`,with:`text-stand-waiting`},EM=({section:e,count:t=e.entries.length,children:n})=>(0,K.jsxs)(`h3`,{className:`m-0 px-3.5 pt-5 pb-1.5 text-xs/4.5 font-medium text-muted-foreground max-md:px-5 max-md:text-sm`,children:[(0,K.jsx)(`span`,{className:TM[e.key],children:e.title}),(0,K.jsx)(`span`,{className:`ms-1.5 font-normal text-subtle tabular-nums`,children:t}),n]}),DM=(e,t)=>e.kind!==`thread`||t?.has(e.thread.id)!==!0||!Ij(e.thread)?null:Vb[e.thread.isSettled?`settled`:e.thread.stand],OM=({entry:e,isOn:t,said:n,onPick:r})=>(0,K.jsx)(`div`,{className:`px-1.5`,children:(0,K.jsxs)(`button`,{className:W(`flex h-7.5 w-full items-center gap-2 rounded-lg px-2 text-start text-xs text-subtle`,t?`bg-line-selected`:`hover:bg-row-hover`),"data-panel-entry":Nj(e),onClick:r,type:`button`,children:[(0,K.jsx)(CM,{entry:e}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:wj(e).label}),(0,K.jsx)(`span`,{className:`shrink-0`,children:n})]})}),kM=({said:e})=>e===null?null:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 px-3.5 pt-3.5 pb-1 max-md:px-5 max-md:pt-4`,children:[(0,K.jsx)(`b`,{className:`text-sm/5 font-semibold max-md:text-3xl/9 max-md:font-bold`,children:e.title}),e.rest===``?null:(0,K.jsx)(`span`,{className:`text-xs text-subtle max-md:text-base`,children:e.rest})]}),AM=[[`j k`,`move`],[`↵`,`open`],[`d`,`settle`],[`D`,`settle what is read`],[`X`,`remove`],[`esc`,`back to the diff`]],jM=()=>(0,K.jsx)(`div`,{className:`absolute inset-x-2 top-1 z-10 key-hint flex-wrap gap-x-3 gap-y-1 rounded-md border border-border bg-popover px-3 py-2 text-xs text-muted-foreground shadow-md max-md:hidden`,children:AM.map(([e,t])=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(`kbd`,{className:`font-mono`,children:e}),t]},t))}),MM=()=>(0,K.jsxs)(`div`,{className:`grid gap-1 px-4 py-7 text-ui text-muted-foreground`,children:[(0,K.jsx)(`b`,{className:`text-sm font-semibold text-foreground`,children:`No comments yet`}),`Select lines in the diff and press c to write one. Each comment you send lands here, under where it stands.`]}),NM=({remark:e,acts:t,onWrite:n})=>e.state===`dismissed`?(0,K.jsx)(xM,{label:`Restore`,onClick:()=>{t.remark(e,`restore`)}}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(xM,{isFilled:!0,label:`Accept`,onClick:()=>{t.remark(e,`accept`)}}),(0,K.jsx)(xM,{label:`Dismiss`,onClick:()=>{t.remark(e,`dismiss`)}}),(0,K.jsx)(xM,{label:`Reply`,onClick:n})]}),PM=({draft:e,acts:t,onWrite:n})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(xM,{label:`Reword`,onClick:n}),(0,K.jsx)(xM,{label:`Drop`,onClick:()=>{t.draft(e,null)}})]}),FM=({entry:e,acts:t,deck:n})=>{let[r,i]=(0,G.useState)(!1);if(e.kind===`thread`)return null;let a=()=>{i(!0)};return(0,K.jsxs)(`div`,{className:`mb-2 px-3.5`,children:[(0,K.jsx)(Cb,{isOpen:r,children:(0,K.jsx)(Xa,{deck:n,draftKey:`panel:${Nj(e)}`,isFocused:!0,onCancel:()=>{i(!1)},onSubmit:async n=>{i(!1),await(e.kind===`remark`?t.remark(e.remark,`reply`,n):t.draft(e.draft,n))},placeholder:e.kind===`draft`?`Reword the note`:`Write back to the remark`,submitLabel:e.kind===`draft`?`Save`:`Reply`})}),(0,K.jsx)(Cb,{isOpen:!r,children:(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.kind===`remark`?(0,K.jsx)(NM,{acts:t,onWrite:a,remark:e.remark}):(0,K.jsx)(PM,{acts:t,draft:e.draft,onWrite:a})})})]})},IM=({label:e,onClick:t,children:n})=>(0,K.jsxs)(Gn,{children:[(0,K.jsx)(En,{render:(0,K.jsx)(`button`,{"aria-label":e,className:`grid size-6 press place-items-center rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground`,onClick:t,type:`button`}),children:n}),(0,K.jsx)(kn,{children:e})]}),LM=e=>{let{thread:t}=e;if(!Mj(e))return`Go to line ${String(t.start)}`;let n=t.file.split(`/`).at(-1)??t.file;return`Open in ${t.layerAddress===null?n:`layer ${t.layerAddress}`}, near line ${String(t.start)}`},RM=new Set([`answered`,`asked`]),zM=({entry:e,acts:t,tools:n})=>{let{thread:r}=e;return(0,K.jsxs)(K.Fragment,{children:[r.file===``?null:(0,K.jsx)(IM,{label:LM(e),onClick:()=>{n.go(r)},children:(0,K.jsx)($r,{"aria-hidden":!0,className:`size-3.5`})}),RM.has(r.stand)&&!r.isSettled?(0,K.jsx)(IM,{label:`Settle`,onClick:()=>{n.settle(r)},children:(0,K.jsx)(ar,{"aria-hidden":!0,className:`size-3.5`})}):null,(0,K.jsx)(IM,{label:`Remove`,onClick:()=>{t.remove(r)},children:(0,K.jsx)(Li,{"aria-hidden":!0,className:`size-3.5`})})]})},BM=({entry:e,acts:t,tools:n})=>e.kind===`thread`?e.thread.state===`removed`?null:(0,K.jsx)(zM,{acts:t,entry:e,tools:n}):e.kind===`draft`?(0,K.jsx)(IM,{label:`Drop`,onClick:()=>{t.draft(e.draft,null)},children:(0,K.jsx)(Li,{"aria-hidden":!0,className:`size-3.5`})}):e.remark.state===`dismissed`?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(IM,{label:`Accept`,onClick:()=>{t.remark(e.remark,`accept`)},children:(0,K.jsx)(ar,{"aria-hidden":!0,className:`size-3.5`})}),(0,K.jsx)(IM,{label:`Dismiss`,onClick:()=>{t.remark(e.remark,`dismiss`)},children:(0,K.jsx)(Vi,{"aria-hidden":!0,className:`size-3.5`})})]}),VM=e=>e.at||(e.turns[0]?.at??``),HM=(e,t)=>e.turns.find(e=>e.voice===`agent`&&e.at>=t)?.at,UM=(e,t)=>{let{seenAt:n,...r}=e;return t===void 0?r:{...r,seenAt:t}},WM=(e,{point:t,revision:n})=>{let r=VM(e);return UM({id:e.id,point:t,revision:n,path:e.file,side:e.side,start:e.start,end:e.end,code:e.snippet,body:e.body,author:`you`,parent:null,at:r,resolved:e.isSettled,stand:e.stand,doing:e.doing,isOutdated:e.isOutdated?!0:void 0},HM(e,r))},GM=e=>e.state!==`removed`&&!e.isMovedPast&&!e.isAboutBranch,KM=(e,t)=>{let n=WM(e,t);return{root:n,replies:e.turns.map((t,r)=>UM({...n,id:`${e.id}~${String(r)}`,body:t.body,author:t.voice===`agent`?`claude`:`you`,parent:e.id,at:t.at,choices:t.choices},t.voice===`agent`?void 0:HM(e,t.at)))}},qM=(e,t)=>e.flatMap(e=>{if(!GM(e))return[];let{root:n,replies:r}=KM(e,t);return[n,...r]}),JM=({point:e,live:t,block:n})=>{let r=fn(t,e),i=n.threads.filter(e=>e.isTaken).map(e=>e.id);return{revision:r,live:{...t,seen:[...t.seen,...i],comments:qM(n.threads,{point:e,revision:r})}}},YM=(e,t)=>{let{root:n,replies:r}=KM(e,t),i=new Set(r.map(e=>e.body)),a=t.comments.filter(t=>t.parent===e.id&&!i.has(t.body));return{root:n,replies:[...r,...a],isOutdated:!1}},XM=(e,t)=>{let n=e.findIndex(e=>Nj(e)===t.list.cursor);return r=>{let i=e[Math.min(e.length-1,Math.max(0,n===-1?0:n+r))];i!==void 0&&t.go(i,t.list.open!==null&&Mj(i))}},ZM=({flat:e,state:t})=>e.find(e=>Nj(e)===t.list.cursor),QM=e=>{let t=ZM(e);return t?.kind===`thread`?t.thread:null},$M=e=>{let t=ZM(e);t!==void 0&&(e.state.go(t,!0),!Mj(t)&&t.kind===`thread`&&e.props.onLeave())},eN=e=>{let t=XM(e.flat,e.state),n=QM(e),{state:r,props:i}=e;return new Map([[`j`,()=>{t(1)}],[`ArrowDown`,()=>{t(1)}],[`k`,()=>{t(-1)}],[`ArrowUp`,()=>{t(-1)}],[`Enter`,()=>{$M(e)}],[`Escape`,()=>{r.list.open===null?i.onLeave():r.setList({...r.list,open:null})}],[`d`,()=>{n!==null&&e.settle(n)}],[`X`,()=>{n!==null&&i.acts.remove(n)}]])},tN=e=>e.metaKey||e.ctrlKey||e.altKey,nN=e=>e instanceof Element&&e.closest(`textarea, input, [contenteditable]`)!==null,rN=(e,t)=>{Ut(`keydown`,n=>{let r=e.current,i=eN(t).get(n.key);i===void 0||t.props.threads!==void 0||r?.contains(document.activeElement)!==!0||tN(n)||nN(n.target)||(n.preventDefault(),i())}),iA(`panel`,()=>{bb()||e.current?.focus({preventScroll:!0})}),iA(t.state.list.open??``,()=>{requestAnimationFrame(()=>{e.current?.querySelector(`[data-open-card]`)?.scrollIntoView({block:`nearest`,behavior:`smooth`})})})},iN=(e,t)=>YM(e,{point:t.point,revision:t.comments.revision,comments:t.comments.live.comments}),aN=e=>e.filter(e=>!Dj.has(e.key)).flatMap(e=>e.entries),oN=e=>{let[t,n]=(0,G.useState)({cursor:null,open:null,folds:{}}),[r,i]=(0,G.useState)(null),a=t=>{t.unread>0&&e.acts.read(t)},o=(e,r)=>{n({...t,cursor:r}),i({id:e.id,isReplying:!1}),a(e)},s=(r,{key:i,isInPanel:s,isWalking:c})=>{bb()?o(r,i):s?(e.onCardOpen(),n({...t,cursor:i,open:c||t.open!==r.id?r.id:null}),a(r)):(n({...t,cursor:i,open:null}),e.onJump(r))};return{list:t,setList:n,sheet:r,setSheet:i,go:(r,i)=>{let a=Nj(r);r.kind===`thread`&&e.threads?.pile.has(r.thread.id)===!0?(n({...t,cursor:a,open:null}),e.threads.onPick(r.thread)):r.kind===`thread`?s(r.thread,{key:a,isInPanel:Mj(r),isWalking:i}):n({...t,cursor:a,open:null})},read:a}},sN=(e,t)=>{let n=Sj({...e.shown,isTheirs:e.isTheirs,pile:e.threads?.pile}),r=aN(n),{actions:i}=e.comments,a=oN(e),o=e.threads===void 0?a:{...a,list:{...a.list,cursor:e.threads.at,open:null}};return rN(t,{flat:r,state:o,props:e,settle:t=>{i.handleResolve(iN(t,e).root,!t.isSettled)}}),{sections:n,flat:r,actions:i,state:o}},cN=({thread:e,props:t,actions:n})=>{let r=e.file.split(`/`).at(-1)??e.file,i=`Open in ${e.layerAddress===null?r:`layer ${e.layerAddress}`}, near line ${String(e.start)}`,a=iN(e,t);return(0,K.jsx)(`div`,{className:`mx-1.5 mb-2 grid gap-1.5 font-sans`,"data-open-card":!0,children:(0,K.jsx)(Cx,{actions:n,deck:t.deck,isCurrent:!0,live:t.comments.live,revision:t.comments.revision,headAction:e.file===``?null:(0,K.jsxs)(Gn,{children:[(0,K.jsx)(En,{render:(0,K.jsx)(`button`,{"aria-label":i,className:`-me-1.5 grid size-6 place-items-center rounded-md text-muted-foreground hover:bg-row-hover hover:text-foreground`,onClick:()=>{t.onShowLayer(e)},type:`button`}),children:(0,K.jsx)($r,{"aria-hidden":!0,className:`size-3.5`})}),(0,K.jsx)(kn,{children:i})]}),thread:{...a,isOutdated:a.root.code!==``}})})},lN=e=>e.kind===`thread`&&e.thread.unread===0,uN=({title:e,count:t,isOpen:n,className:r,onToggle:i})=>(0,K.jsx)(`div`,{className:W(`px-1.5`,r),children:(0,K.jsxs)(`button`,{className:`flex h-8.5 w-full items-center gap-2 rounded-lg px-2 text-xs font-medium text-muted-foreground hover:bg-row-hover max-md:h-12 max-md:px-3 max-md:text-base`,onClick:i,type:`button`,children:[(0,K.jsx)(cn,{"aria-hidden":!0,className:W(`size-3 text-subtle transition-transform duration-180 ease-(--e-out) max-md:size-4`,n&&`rotate-90`)}),e,(0,K.jsx)(`span`,{className:`font-normal text-subtle tabular-nums`,children:t})]})}),dN=(e,t)=>{e.setList({...e.list,folds:{...e.list.folds,[t]:e.list.folds[t]!==!0}})},fN=({entry:e,sectionKey:t,...n})=>{let{props:r,state:i,actions:a}=n,o=Nj(e),s=i.list.cursor===o,c=e.kind===`thread`&&i.list.open===e.thread.id,l=DM(e,r.threads?.pile);return l===null?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(wM,{entry:e,isOn:s,onPick:()=>{i.go(e,!1)},sectionKey:t,tools:(0,K.jsx)(BM,{acts:r.acts,entry:e,tools:{go:t=>{e.kind===`thread`&&!Mj(e)?i.go(e,!1):r.onShowLayer(t)},settle:e=>{a.handleResolve(iN(e,r).root,!0)}}})}),e.kind===`thread`?(0,K.jsx)(Cb,{isOpen:c,children:c?(0,K.jsx)(cN,{actions:a,props:r,thread:e.thread}):null}):null,s?(0,K.jsx)(FM,{acts:r.acts,deck:r.deck,entry:e}):null]}):(0,K.jsx)(OM,{entry:e,isOn:s,onPick:()=>{i.go(e,!1)},said:l})},pN=({section:e,...t})=>{let n=e.entries.filter(e=>!lN(e)).length,r=e.key===`movedOn`,i=r?e.entries.filter(lN):[],a=t.state.list.folds.read===!0,o=e.entries.filter(e=>DM(e,t.props.threads?.pile)===null).length;return(0,K.jsxs)(`section`,{children:[(0,K.jsx)(EM,{count:o,section:e,children:r&&n>0&&t.props.threads===void 0?(0,K.jsx)(`span`,{className:`font-normal text-subtle`,children:` · ${String(n)} new`}):null}),e.entries.map(n=>(0,K.jsx)(`div`,{className:W(r&&lN(n)&&!a&&`max-md:hidden`),children:(0,K.jsx)(fN,{entry:n,sectionKey:e.key,...t})},Nj(n))),i.length>0?(0,K.jsx)(uN,{className:`md:hidden`,count:i.length,isOpen:a,onToggle:()=>{dN(t.state,`read`)},title:`Read`}):null]})},mN=({section:e,props:t,state:n})=>{let r=n.list.folds[e.key]===!0,i=e=>{e.kind===`thread`?e.thread.state===`removed`?t.acts.remove(e.thread):t.acts.settle(e.thread):e.kind===`remark`&&t.acts.remark(e.remark,`restore`)};return(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`div`,{className:`mx-3.5 mt-3 mb-1 h-px bg-border max-md:mx-5`}),(0,K.jsx)(uN,{count:e.entries.length,isOpen:r,onToggle:()=>{dN(n,e.key)},title:e.title}),(0,K.jsx)(Cb,{isOpen:r,children:e.entries.map(t=>(0,K.jsx)(`div`,{className:`px-1.5`,children:(0,K.jsxs)(`button`,{className:`grid w-full animate-enter gap-0.5 rounded-lg px-2 py-1.5 text-start hover:bg-row-hover`,onClick:()=>{i(t)},type:`button`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-subtle`,children:[(0,K.jsx)(`span`,{className:`truncate font-mono`,children:wj(t).label}),(0,K.jsx)(`span`,{className:`ms-auto shrink-0`,children:e.key===`settled`?`Reopen`:`Restore`})]}),(0,K.jsx)(`span`,{className:`line-clamp-1 text-ui text-subtle`,children:Oj(t)})]})},Nj(t)))})]})},hN=({props:e})=>{let t=e.threads===void 0?e.shown.threads.filter(e=>e.isSettleable).length:0,n=e.shown.drafts.length;return t===0&&n===0?null:(0,K.jsxs)(`div`,{className:`flex animate-enter flex-wrap gap-2 border-t border-border px-2.5 py-2 max-md:px-4`,children:[n>0?(0,K.jsx)(xM,{hint:`C`,isFilled:!0,label:`Send ${String(n)}${e.isTheirs?` to the pull request`:``}`,onClick:()=>{e.acts.sendDrafts()}}):null,t>0?(0,K.jsx)(xM,{hint:`D`,label:`Settle ${String(t)} read`,onClick:()=>{e.acts.settleRead()}}):null]})},gN=({props:e,panel:t})=>{let{state:n,flat:r,actions:i}=t,a=r.flatMap(e=>e.kind===`thread`?[e.thread]:[]),o=a.find(e=>e.id===n.sheet?.id);return o===void 0?null:(0,K.jsx)(eS,{canSettle:o.stand===`answered`||o.stand===`asked`,isOpen:!0,isReplying:n.sheet?.isReplying===!0,onClose:()=>{n.setSheet(null)},onNext:()=>{let e=a[a.indexOf(o)+1];n.setSheet(e===void 0?null:{id:e.id,isReplying:!1}),e!==void 0&&n.read(e)},onReply:e=>{n.setSheet({id:o.id,isReplying:e})},props:{deck:e.deck,thread:iN(o,e),live:e.comments.live,revision:e.comments.revision,actions:i}})},_N=e=>{let t=(0,G.useRef)(null),n=sN(e,t),r=yM({counts:e.block.threadCounts,remarks:e.shown.remarks,drafts:e.shown.drafts,isTheirs:e.isTheirs}),i=e.threads===void 0?r:{title:`${String(e.threads.left)} left`,rest:``};return(0,K.jsxs)(`aside`,{"aria-label":`Review`,className:`flex min-h-0 flex-col outline-none`,"data-review-panel":!0,ref:t,tabIndex:-1,children:[(0,K.jsx)(kM,{said:i}),(0,K.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,K.jsx)(jM,{}),(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto pb-3`,children:[n.sections.length===0?(0,K.jsx)(MM,{}):null,n.sections.map(t=>Dj.has(t.key)?(0,K.jsx)(mN,{props:e,section:t,state:n.state},t.key):(0,K.jsx)(pN,{actions:n.actions,props:e,section:t,state:n.state},t.key))]})]}),(0,K.jsx)(hN,{props:e}),(0,K.jsx)(gN,{panel:n,props:e})]})},vN=({props:e,pane:t,paneRef:n,lead:r})=>{let{state:i,setState:a}=e;return(0,K.jsx)(_N,{acts:t.acts,block:e.block,comments:t.comments,deck:e.deck,isLayered:i.isLayered,isTheirs:e.extras.pull?.theirs===!0,onJump:r.isOn?r.showInDiff:t.threadJump.handleJump,onCardOpen:()=>{a({...i,focus:`tree`})},onLeave:()=>{a(i.isBackToThreads?{...i,lead:`threads`,isBackToThreads:!1}:{...i,focus:`diff`}),n.current?.focus({preventScroll:!0})},onShowLayer:t.threadJump.handleShowLayer,point:e.view.id,railLayer:i.isLayered?vw(i.cursor):null,shown:t.shown,threads:r.panel})},yN=()=>{let e=(0,G.useRef)(0);return(0,G.useEffect)(()=>{let t=()=>{e.current=Date.now()};return document.addEventListener(`touchmove`,t,{passive:!0}),document.addEventListener(`wheel`,t,{passive:!0}),()=>{document.removeEventListener(`touchmove`,t),document.removeEventListener(`wheel`,t)}},[]),e},bN=6,xN=24,SN=800,CN=e=>{let[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(e),a=(0,G.useRef)(new WeakMap),o=yN();return e!==r&&(i(e),n(!1)),{isHidden:t,handleScroll:e=>{if(!(e instanceof HTMLElement))return;let t=e.scrollTop,r=t-(a.current.get(e)??t);a.current.set(e,t),Date.now()-o.current>SN||(t<xN||r<-6?n(!1):r>bN&&n(!0))}}},wN=(e,t,n)=>{let r=e.indexOf(t);return[...e.slice(r+1),...e.slice(0,Math.max(0,r))].find(e=>!n(e))??null},TN=e=>e=>{let t=e?.querySelector(`[aria-current="page"]`);e!==null&&t!=null&&(e.style.setProperty(`--pill-x`,`${String(t.offsetLeft)}px`),e.style.setProperty(`--pill-w`,`${String(t.offsetWidth)}px`))},EN=()=>{if(typeof navigator.vibrate==`function`){navigator.vibrate(1);return}let e=document.createElement(`label`);e.innerHTML=`<input type="checkbox" switch>`,e.style.display=`none`,document.body.append(e),e.click(),e.remove()},DN=24,ON=8,kN=.35,AN=.35,jN=28,MN=.6,NN=100,PN=260,FN=`translate ${String(PN)}ms var(--e-drawer), opacity ${String(PN)}ms var(--e-drawer)`,IN=420,LN=()=>globalThis.matchMedia(`(display-mode: standalone)`).matches||`standalone`in navigator&&navigator.standalone===!0,RN=()=>globalThis.matchMedia(`(max-width: 767px)`).matches,zN=(e,t)=>{let{shown:n,under:r}=e;if(n===null||r===null)return;let i=Math.min(1,Math.max(0,t/n.offsetWidth));n.style.translate=`${String(i*NN)}% 0`,r.style.translate=`${String((i-1)*jN)}% 0`,r.style.opacity=String(MN+.4*i)},BN=e=>{for(let t of[e.shown,e.under])t?.style.removeProperty(`translate`),t?.style.removeProperty(`opacity`),t?.style.removeProperty(`transition`);e.shown!==null&&delete e.shown.dataset.backTop,delete e.box.dataset.backDrag},VN=e=>{e.box.dataset.swiped=``,e.back.onBack(),globalThis.requestAnimationFrame(()=>{BN(e)}),globalThis.setTimeout(()=>{delete e.box.dataset.swiped},IN)},HN=(e,t)=>{let n=e.shown?.offsetWidth??0,r=t/Math.max(1,Date.now()-e.at),i=t>n*kN||r>AN;for(let t of[e.shown,e.under])t?.style.setProperty(`transition`,FN);zN(e,i?n:0),i&&EN(),globalThis.setTimeout(()=>{i?VN(e):BN(e)},PN)},UN=e=>{let t=e.back.getViews();e.shown=t===null?null:dD(e.box,t.shown),e.under=t===null?null:dD(e.box,t.back),t===null||e.shown===null||e.under===null?e.phase=`idle`:(e.box.dataset.backDrag=t.back,e.shown.dataset.backTop=``,e.phase=`drag`)},WN=(e,t)=>{let[n]=e.touches;return e.touches.length===1&&n!==void 0&&n.clientX<=DN&&RN()&&LN()&&t.getViews()!==null},GN=(e,t)=>{let n={box:e,back:t,phase:`idle`,left:0,top:0,at:0,shown:null,under:null};return{handleStart:e=>{let[r]=e.touches;n.phase=WN(e,t)?`maybe`:`idle`,n.left=r?.clientX??0,n.top=r?.clientY??0,n.at=Date.now()},handleMove:e=>{let[t]=e.touches,r=(t?.clientX??n.left)-n.left,i=Math.abs((t?.clientY??n.top)-n.top);n.phase===`maybe`&&Math.max(r,i)>ON&&(r>i?UN(n):n.phase=`idle`),n.phase===`drag`&&(e.preventDefault(),zN(n,r))},handleEnd:e=>{let[t]=e.changedTouches;n.phase===`drag`&&HN(n,(t?.clientX??n.left)-n.left),n.phase=`idle`}}},KN=(e,t)=>{let{handleStart:n,handleMove:r,handleEnd:i}=GN(e,t);return e.addEventListener(`touchstart`,n,{passive:!0}),e.addEventListener(`touchmove`,r,{passive:!1}),e.addEventListener(`touchend`,i),e.addEventListener(`touchcancel`,i),()=>{e.removeEventListener(`touchstart`,n),e.removeEventListener(`touchmove`,r),e.removeEventListener(`touchend`,i),e.removeEventListener(`touchcancel`,i)}},qN=(e,t)=>{let n=xy({views:e,onBack:t});return(0,G.useCallback)(e=>e===null?void 0:KN(e,{getViews:()=>n.current.views,onBack:()=>{n.current.onBack()}}),[n])},JN=u({method:`GET`}).handler(p(`0606210e0df9e9467c6143a764ada1aaa034b2a0ed02cb9b03d64eed35e9c04a`)),YN=u({method:`POST`}).handler(p(`f401f5330e10ad3b2c602ae49981f226d7e57c8b2b638d0840a197a7d6125be6`)),XN=u({method:`POST`}).handler(p(`0883f654ee97f193b16da01fd0bc3688daa5e3a37bb245da03045b353099be05`)),ZN=u({method:`POST`}).handler(p(`8d0f02766ecedce1b5d9b39c4524dd1912bd1780e2056ab3f564a5062bf0517c`)),QN=e=>typeof e==`object`&&!!e&&`agents`in e&&`takenLately`in e,$N=(e,t)=>JSON.stringify(e)===JSON.stringify(t),eP=e=>{let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(!1),{deck:s,point:c,branch:l}=e,u=(0,G.useCallback)(async()=>{try{let e=await JN({data:{deck:s,point:c,branch:l}});n(t=>$N(t,e)?t:e)}catch{n(null)}},[s,c,l]);(0,G.useEffect)(()=>{let e={isCurrent:!0};(async()=>{let t=await JN({data:{deck:s,point:c,branch:l}});e.isCurrent&&n(e=>e??t)})();let t=EC(`${s}|${c}|${l}`,e=>{let t=JSON.parse(e);QN(t)&&n(e=>$N(e,t)?e:t)});return()=>{e.isCurrent=!1,t()}},[s,c,l]);let d=async e=>{o(!0),i(null);try{let t=await e();i(t.ok?null:t.error??`It did not start`)}catch(e){i(e instanceof Error?e.message:String(e))}finally{await u(),o(!1)}};return{branch:l,listener:t,failure:r,isBusy:a,handleStart:e=>d(()=>YN({data:{deck:s,point:c,branch:l,agent:e}})),handleStop:()=>d(()=>XN({data:{deck:s,point:c,branch:l}})),handleSave:e=>d(()=>ZN({data:e}))}},tP=80,nP=600,rP=2,iP=24,aP=e=>e instanceof Element?e.closest(`[data-code-scroll]`):null,oP=e=>{let{0:t}=e.touches;if(e.touches.length!==1||t===void 0||t.clientX<iP||t.clientX>window.innerWidth-iP)return null;let n=aP(e.target),r=n?.scrollLeft??0,i=n===null?0:n.scrollWidth-n.clientWidth;return{left:t.clientX,top:t.clientY,at:e.timeStamp,isAtStart:r<=1,isAtEnd:r>=i-1}},sP=(e,t)=>{let{0:n}=t.changedTouches;if(n===void 0||t.timeStamp-e.at>nP)return null;let r=n.clientX-e.left,i=n.clientY-e.top;return Math.abs(r)<tP||Math.abs(r)<rP*Math.abs(i)?null:r<0?e.isAtEnd?1:null:e.isAtStart?-1:null},cP=e=>{let t=(0,G.useRef)(null);return{handleTouchStart:e=>{t.current=oP(e)},handleTouchEnd:n=>{let r=t.current;t.current=null;let i=r===null?null:sP(r,n);i!==null&&e(i)}}},lP=(e,t)=>{let{block:n,state:r,setState:i}=e,a=hD(r),o=eP({deck:e.deck,point:e.view.id,branch:n.branch}),s=CN(a),c=cP(e=>{a===`diff`&&(EN(),t.press(e===1?`]`:`[`))}),l=()=>{t.selection?.handleCancel(),i(gD(r))},u=qN(a===`files`?null:{shown:a,back:hD(gD(r))},l);return{phone:{block:n,state:r,file:t.file,position:t.model.position,total:t.model.total,reviewTotal:t.model.reviewTotal,reviewedCount:t.model.marks.count,isReviewed:t.model.marks.isReviewed(r.selected),hasLayers:t.model.hasLayers,hasPull:e.extras.pull!==null,draftCount:t.shown.drafts.length,unreadCount:bM({counts:n.threadCounts,remarks:t.shown.remarks,isTheirs:e.extras.pull?.theirs===!0}),nextUnreviewed:wN(n.order,r.selected,t.model.marks.isReviewed),isBarHidden:s.isHidden||(t.selection?.composerAt??null)!==null,listener:o,model:t.model,onPickLayer:e=>{i(bD(r,{key:e,groups:t.model.groups}))},handlePress:e=>{e===`m`&&EN(),t.press(e)},onOpen:t.handleOpen,onBack:l,onMore:()=>{i({...r,dialog:`more`})}},view:a,swipe:c,backRef:u,handleBarScroll:s.handleScroll}},uP=`grid size-12 shrink-0 place-items-center rounded-full text-foreground glass press disabled:opacity-40`,dP=({label:e,isDisabled:t=!1,onClick:n,children:r})=>(0,K.jsx)(`button`,{"aria-label":e,className:uP,disabled:t,onClick:n,type:`button`,children:r}),fP=({icon:e,label:t,isCurrent:n,badge:r=0,onClick:i})=>(0,K.jsxs)(`button`,{"aria-current":n?`page`:void 0,className:`phone-tab press`,onClick:i,type:`button`,children:[(0,K.jsx)(e,{className:`size-5 shrink-0`}),t,r>0?(0,K.jsx)(`span`,{"aria-label":`${String(r)} unread`,className:`grid h-4.5 min-w-4.5 place-items-center rounded-full bg-accent px-1.25 text-2xs font-semibold text-accent-foreground tabular-nums`,children:r}):null]}),pP=({props:e})=>{let t=qn(),n=e.state.anchor!==null;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dP,{isDisabled:e.position<=1,label:`Previous file`,onClick:()=>{e.handlePress(`[`)},children:(0,K.jsx)(lr,{className:`size-5.5`})}),(0,K.jsxs)(`div`,{className:`flex h-12 min-w-0 flex-1 items-center justify-center gap-0.5 rounded-full px-1 glass`,children:[(0,K.jsxs)(`button`,{"aria-pressed":e.isReviewed,className:`phone-tab press aria-pressed:text-foreground`,onClick:()=>{e.handlePress(`m`)},type:`button`,children:[(0,K.jsxs)(`span`,{className:`relative grid size-5 shrink-0 place-items-center`,children:[(0,K.jsx)(yr,{className:`absolute size-5 icon-swap`,"data-off":e.isReviewed?``:void 0}),(0,K.jsx)(_r,{className:`absolute size-5 icon-swap text-success`,"data-off":e.isReviewed?void 0:``})]}),`Reviewed`]}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:`h-5 w-px shrink-0 bg-foreground/12`}),(0,K.jsxs)(`button`,{className:`phone-tab press text-foreground`,onClick:()=>{n?e.handlePress(`c`):t.add({title:`Tap a line number to pick the lines to comment on`})},type:`button`,children:[(0,K.jsx)(ri,{className:`size-5 shrink-0`}),`Comment`]})]}),(0,K.jsx)(dP,{isDisabled:e.position>=e.total,label:`Next file`,onClick:()=>{e.handlePress(`]`)},children:(0,K.jsx)(cn,{className:`size-5.5`})})]})},mP=({props:e})=>{let t=e.state.isPanelOpen;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`nav`,{"aria-label":`Sections`,className:`tab-pill flex h-12 items-center gap-0.5 rounded-full px-1 glass`,ref:TN(t),children:[(0,K.jsx)(fP,{icon:Nr,isCurrent:!t,label:`Files`,onClick:()=>{t&&e.handlePress(`a`)}}),(0,K.jsx)(fP,{badge:e.unreadCount,icon:ai,isCurrent:t,label:`Review`,onClick:()=>{t||e.handlePress(`a`)}})]}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsx)(dP,{label:`Search the branch`,onClick:()=>{e.handlePress(`/`)},children:(0,K.jsx)(un,{className:`size-5`})})]})},hP=e=>(0,K.jsx)(`div`,{className:`phone-bar md:hidden`,"data-hidden":e.isBarHidden||e.state.dialog!==null?``:void 0,children:hD(e.state)===`diff`?(0,K.jsx)(pP,{props:e}):(0,K.jsx)(mP,{props:e})}),gP=({title:e,said:t,isAsked:n,onReorder:r,action:i=`Reorder`,whileAsked:a=`Asked the agent for a new order; it shows here when written`})=>(0,K.jsxs)(`div`,{className:`mb-2 flex animate-enter items-start gap-2.5 rounded-lg bg-foreground/6 p-2.5`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`grid h-5 w-3.5 shrink-0 place-items-center`,children:(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground`})}),(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-ui font-medium`,children:e}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n?a:t})]}),n?(0,K.jsxs)(`span`,{className:`inline-flex h-6 shrink-0 items-center gap-1.5 px-2 text-xs font-medium text-success`,children:[(0,K.jsx)(ar,{"aria-hidden":!0,className:`size-3`,strokeWidth:3}),`Asked`]}):(0,K.jsx)(wn,{keys:[`L`],children:(0,K.jsx)(`button`,{className:`inline-flex h-6 shrink-0 press items-center gap-1.5 rounded-md bg-foreground/9 px-2 text-xs font-medium`,onClick:r,type:`button`,children:i})})]}),_P=e=>{let t=e.block.threads.find(e=>e.stand===`asked`),[n]=t?.layers??[],r=e.groups.find(e=>n!==void 0&&e.index===n-1);return t===void 0||r===void 0||t.layers.some(t=>e.isHere(t))?null:(0,K.jsxs)(`button`,{className:`mb-2 flex w-full animate-enter items-start gap-2.5 rounded-lg border border-stand-asked/40 p-2.5 text-start transition-colors duration-150 hover:bg-row-hover`,onClick:()=>{e.onPickFile(hw(r.index,t.file),t.file)},type:`button`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`grid h-5 w-3.5 shrink-0 place-items-center text-stand-asked`,children:`◉`}),(0,K.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-ui font-medium`,children:`Up next: a question for you`}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`in ${r.address} · ${r.title}, before the plan’s next layer`})]}),(0,K.jsx)(Zn,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`})]})},vP=({block:e,isAsked:t,onReorder:n})=>{if(e.isLayersStale)return(0,K.jsx)(gP,{isAsked:t,onReorder:n,said:`The branch moved on after it was written`,title:`Order is out of date`});let r=e.unclaimedLines;return r===0?null:(0,K.jsx)(gP,{isAsked:t,onReorder:n,said:`No layer claims them yet; a new order places them`,title:`${String(r)} changed ${r===1?`line is`:`lines are`} in no layer`})},yP=({files:e,isAsked:t,onAsk:n})=>(0,K.jsx)(gP,{action:`Write them`,isAsked:t,onReorder:n,said:`The agent can split these ${String(e)} files into layers to read in order, each with a note on how to read it`,title:t?`An agent is writing layers`:`No layers yet`,whileAsked:`They show here when written; keep reading meanwhile`}),bP=({said:e,name:t,size:n,isPart:r=!1,onPick:i})=>(0,K.jsx)(`div`,{className:W(r&&`ps-6.5`),children:(0,K.jsx)(wn,{keys:[`]`],children:(0,K.jsxs)(`button`,{"data-keep-visible":!0,className:`my-1.5 ms-6 next-layer animate-enter items-center gap-x-2 rounded-lg border border-border bg-background px-2.5 py-2 text-start hover:bg-row-hover`,onClick:i,type:`button`,children:[(0,K.jsx)(`span`,{className:`text-xs text-subtle`,children:e}),(0,K.jsx)(Zn,{"aria-hidden":!0,className:`row-span-3 size-3.5 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`text-ui font-medium`,children:t}),(0,K.jsx)(gE,{size:n})]})})}),xP=(e,t)=>[...e.querySelectorAll(`[data-pinned]`)].filter(e=>e!==t).reduce((e,t)=>e+t.offsetHeight,0),SP=(e,t)=>{let n=e.getBoundingClientRect().top-e.scrollTop,r=t.getBoundingClientRect(),i=e.querySelector(`[data-keep-visible]`),a=i===null?0:i.getBoundingClientRect().bottom-n;return{top:r.top-n,bottom:Math.max(r.bottom-n,a)}},CP=(e,t)=>{let{top:n,bottom:r}=SP(e,t),i=xP(e,t);n-i<e.scrollTop?e.scrollTop=n-i:r>e.scrollTop+e.clientHeight&&(e.scrollTop=r-e.clientHeight)},wP=e=>{let t=(0,G.useRef)(null),n=(0,G.useRef)(new Map);return(0,G.useEffect)(()=>{let r=t.current,i=n.current.get(e);r&&i&&CP(r,i)},[e]),{containerRef:t,register:(0,G.useCallback)(e=>t=>{t===null?n.current.delete(e):n.current.set(e,t)},[])}},TP=e=>{let t=[];return e.forEach(e=>{let n=t.at(-1);n?.[1]===e-1?n[1]=e:t.push([e,e])}),t.map(([e,t])=>e===t?String(e):`${String(e)}–${String(t)}`).join(`, `)},EP=(e,t)=>{let n=e.files.at(-1);return n!==void 0&&t===hw(e.index,n)},DP=({paths:e})=>e.length===0?null:(0,K.jsxs)(`ul`,{className:`m-0 list-none ps-8.5 pe-2 pb-1.5`,children:[(0,K.jsx)(`li`,{className:`pt-1 text-xs/5 text-subtle`,children:`gone since the order was written`}),e.map(e=>(0,K.jsx)(`li`,{className:`truncate font-mono text-xs/5 text-subtle line-through`,title:e,children:e.slice(e.lastIndexOf(`/`)+1)},e))]}),OP=({group:e,props:t,register:n})=>{let r=t.block.layers[e.index]?.vanished??[];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(AO,{block:t.block,index:e.index,onPickFile:t.onPickFile,selected:t.state.selected}),e.all.length===0?(0,K.jsx)(`p`,{className:`m-0 ps-8.5 pe-2 pb-2 text-xs text-subtle`,children:`Nothing left in this diff: its files changed after the order was written.`}):null,e.files.length>0?(0,K.jsx)(CE,{block:t.block,cursor:t.state.cursor,files:t.files,group:e,isReadIn:t.isReadIn,onPickFile:t.onPickFile,register:n}):null,(0,K.jsx)(DP,{paths:r})]})},kP=({group:e,props:t,register:n})=>{let r=t.block.layers[e.index],i=yD(t.state,e.key);return r===void 0?null:(0,K.jsxs)(`div`,{className:W(`mb-0.5`,e.ticket!==null&&`ps-6.5`),children:[(0,K.jsx)(yE,{group:e,isCursor:t.state.cursor===e.key,isOpen:i,layer:r,onPick:()=>{t.onPickLayer(e.key)},register:n,size:hE(e,t.block.layers[e.index],t.isReadIn)}),(0,K.jsx)(`div`,{className:`fold`,"data-open":i?``:void 0,inert:!i,children:(0,K.jsx)(`div`,{children:(0,K.jsx)(OP,{group:e,props:t,register:n})})})]})},AP=(e,t)=>{let n=e.flatMap(e=>BT(e)),r=n.find(e=>EP(e,t));if(r===void 0)return null;let i=n[n.indexOf(r)+1];if(i!==void 0&&r.ticket!==null&&i.ticket===r.ticket)return{key:i.key,said:`End of part ${r.address} · up next`,isPart:!0};let a=e[e.findIndex(e=>BT(e).includes(r))+1];return a===void 0?null:{key:a.key,said:r.ticket===null?`End of this layer · up next`:`End of layer ${String(r.ticket)} · up next`,isPart:!1}},jP=(e,t)=>e?.key===t,MP=({group:e,...t})=>jP(t.upNext,e.key)?(0,K.jsx)(bP,{isPart:t.upNext.isPart,name:`${e.address} · ${e.title}`,onPick:()=>{t.props.onPickLayer(e.key)},said:t.upNext.said,size:hE(e,t.props.block.layers[e.index],t.props.isReadIn)}):(0,K.jsx)(kP,{group:e,props:t.props,register:t.register}),NP=({entry:e,ticket:t,...n})=>{let{props:r}=n,i=xD(r.state,e),a=e.groups.some(e=>yD(r.state,e.key));return(0,K.jsxs)(`div`,{className:`mb-0.5`,children:[(0,K.jsx)(TE,{isCursor:r.state.cursor===e.key,isOpen:i,onPick:()=>{r.onPickLayer(e.key)},register:n.register,rowKey:e.key,ticket:t}),(0,K.jsx)(`div`,{className:`fold`,"data-open":i?``:void 0,inert:!i,children:(0,K.jsxs)(`div`,{children:[a?null:(0,K.jsx)(jO,{block:r.block,onPickFile:r.onPickFile,selected:r.state.selected,ticket:t}),e.groups.map(e=>(0,K.jsx)(MP,{group:e,...n},e.key))]})})]})},PP=({entry:e,...t})=>{if(e.kind===`layer`)return(0,K.jsx)(MP,{group:e,...t});let n=t.props.block.tickets.find(t=>t.number===e.number);return n===void 0?null:jP(t.upNext,e.key)?(0,K.jsx)(bP,{name:`${n.address} · ${n.title}`,onPick:()=>{t.props.onPickLayer(e.key)},said:t.upNext.said,size:wE(n)}):(0,K.jsx)(NP,{entry:e,ticket:n,...t})},FP=100,IP=({state:e,groups:t,block:n})=>{let r=yw(e.cursor);if(r!==null)return{index:null,ticket:r};let i=vw(e.cursor)??t.find(t=>t.all.includes(e.selected))?.index??0;return{index:i,ticket:n.layers[i]?.ticket??null}},LP=(e,t)=>e.index===null?t.ticket===e.ticket:t.index===e.index,RP=(e,t)=>e.tickets.find(e=>e.number===t),zP=(e,t)=>{let n=t.index===null?void 0:e.layers[t.index],r=t.ticket===null?void 0:RP(e,t.ticket),i=`of ${String(e.topLevel)}`;if(n?.isRemainder===!0)return`Not in any layer`;if(r===void 0)return`Layer ${n?.address??`1`} ${i}`;let a=n?.sublayer??null;return a===null?`Layer ${r.address} ${i}`:`Layer ${r.address} ${i} · part ${String(a)} of ${String(r.sublayers)}`},BP=(e,t)=>{e?.style.setProperty(`--size`,String(Math.max(t.count,1))),e?.style.setProperty(`--fill`,`${String(t.count===0?0:t.read*FP/t.count)}%`)},VP=({group:e,size:t,here:n})=>(0,K.jsx)(`span`,{className:`layer-seg`,"data-here":LP(n,e)?``:void 0,ref:e=>{BP(e,t)}}),HP=({entries:e,here:t,sizeOf:n})=>(0,K.jsx)(`div`,{"aria-hidden":!0,className:`flex gap-0.5`,children:e.map(e=>e.kind===`layer`?(0,K.jsx)(VP,{group:e,here:t,size:n(e)},e.key):(0,K.jsx)(`span`,{className:`layer-tk`,ref:t=>{let r=e.groups.reduce((e,t)=>e+n(t).count,0);t?.style.setProperty(`--size`,String(Math.max(r,1)))},children:e.groups.map(e=>(0,K.jsx)(VP,{group:e,here:t,size:n(e)},e.key))},e.key))}),UP=e=>{let t=t=>hE(t,e.block.layers[t.index],e.isReadIn),n=e.groups.map(e=>t(e));return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`sticky -top-2 z-3 -mx-2 -mt-2 grid h-14 content-center gap-2 border-b border-border bg-wash px-4`,"data-pinned":!0,children:[(0,K.jsx)(HP,{entries:e.entries,here:e.here,sizeOf:t}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-subtle tabular-nums`,children:[(0,K.jsx)(`span`,{children:zP(e.block,e.here)}),(0,K.jsx)(`span`,{className:`max-md:hidden`,children:`${String(n.reduce((e,t)=>e+t.read,0))} of ${String(n.reduce((e,t)=>e+t.count,0))} files`}),(0,K.jsxs)(`button`,{className:`-my-3 inline-flex min-h-11 press items-center gap-0.5 text-sm font-medium text-claude md:hidden`,onClick:e.onAllLayers,type:`button`,children:[`All layers`,(0,K.jsx)(cn,{"aria-hidden":!0,className:`size-4`})]})]})]}),e.block.summary===``?null:(0,K.jsx)(`p`,{className:`mx-2 mt-2.5 mb-2 line-clamp-2 text-xs text-muted-foreground`,title:e.block.summary,children:e.block.summary})]})},WP=[],GP=[],KP=(e,t)=>t.kind===`ticket`?e.tickets.find(e=>e.number===t.number)?.isDone===!0:e.layers[t.index]?.isDone===!0,qP=(e,t)=>e.key===t||BT(e).some(e=>e.index===vw(t)),JP=(e,t)=>yD(e,`layer:read`)||t.some(t=>qP(t,e.cursor)),YP=(e,{state:t,present:n,shown:r,isShownIn:i})=>{if(!t.isLayered||e.layers.length===0)return{rows:dw(r,t.collapsed),order:fw(r),groups:WP,entries:GP,done:GP};let a=RT(e.layers,{present:n,isShown:i}),o=zT(a,e.tickets),s=t=>KP(e,t),c=WT(o,{isDone:s,isOpen:e=>xD(t,e),isReadOpen:JP(t,o.filter(e=>s(e)))});return{rows:c.rows,order:c.order,groups:a,entries:o,done:c.done}},XP=e=>e.isLayered?vw(e.cursor):null,ZP=e=>({...e,isHidingReviewed:!1,layerOpen:{...e.layerOpen,[xw]:!0}}),QP=e=>{let t=e.querySelector(`[data-open-row]`);if(t!==null){let n=t.getBoundingClientRect().top-e.getBoundingClientRect().top;t.toggleAttribute(`data-stuck`,n<=57)}},$P=(e,t)=>t.kind===`ticket`?e.tickets.find(e=>e.number===t.number)?.files.length??0:t.all.length,eF=({props:e,register:t})=>{let n=JP(e.state,e.done),r=e.done.reduce((t,n)=>t+$P(e.block,n),0),i=e.state.cursor===xw,a=e.done.map(e=>e.kind===`ticket`?e.number:Number(e.address));return(0,K.jsxs)(`button`,{"aria-expanded":n,className:`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-ui text-subtle hover:bg-row-hover ${i?`tree-cursor bg-secondary`:``}`,onClick:()=>{e.onPickLayer(xw)},ref:t(xw),type:`button`,children:[(0,K.jsx)(`span`,{className:`grid w-4.5 shrink-0 place-items-center`,children:(0,K.jsx)(ar,{"aria-hidden":!0,className:`size-3 text-success`,strokeWidth:3})}),(0,K.jsx)(`span`,{className:`flex-1`,children:`${e.done.length===1?`Layer`:`Layers`} ${TP(a)} read`}),(0,K.jsx)(`span`,{className:`text-xs tabular-nums`,children:`${String(r)} files`}),(0,K.jsx)(cn,{"aria-hidden":!0,className:`size-3 turn`})]})},tF=e=>{let{containerRef:t,register:n}=wP(e.state.cursor),r=IP(e),i=new Set(e.done.map(e=>e.key)),a=e.entries.filter(e=>!i.has(e.key)),o=JP(e.state,e.done),s=AP(o?[...e.done,...a]:a,e.state.cursor),c=t=>(0,K.jsx)(PP,{entry:t,props:e,register:n,upNext:s},t.key);return(0,K.jsxs)(`nav`,{"aria-label":`Layers`,className:`min-h-0 overflow-auto p-2`,"data-review-rail":!0,onScroll:e=>{QP(e.currentTarget)},ref:t,children:[(0,K.jsx)(UP,{...e,here:r}),(0,K.jsx)(vP,{block:e.block,isAsked:e.isReorderAsked,onReorder:e.onReorder}),(0,K.jsx)(_P,{block:e.block,groups:e.groups,isHere:t=>{let n=e.groups[t-1];return n!==void 0&&LP(r,n)},onPickFile:e.onPickFile}),e.done.length>0?(0,K.jsx)(eF,{props:e,register:n}):null,e.done.length>0?(0,K.jsx)(`div`,{className:`fold`,"data-open":o?``:void 0,inert:!o,children:(0,K.jsx)(`div`,{children:e.done.map(e=>c(e))})}):null,a.map(e=>c(e))]})},nF=30,rF=80,iF=e=>e*Number(getComputedStyle(document.documentElement).fontSize.replace(`px`,``)),aF=(e,t)=>t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop,oF=(e,{top:t,height:n,inset:r,covered:i})=>{t<e.scrollTop+i?e.scrollTop=t-r:t+n>e.scrollTop+e.clientHeight&&(e.scrollTop=t+n-e.clientHeight)},sF=({total:e,rowRem:t,activeKey:n,activeIndex:r,activeInset:i=0,getCovered:a})=>{let o=(0,G.useRef)(null),[s,c]=(0,G.useState)(null),l=(0,G.useRef)(null),u=(0,G.useCallback)(()=>{let e=o.current;if(e===null)return;let n=iF(t),r=Math.floor(e.scrollTop/n),i=Math.ceil(e.clientHeight/n)+1;c(e=>e?.first===r&&e.count===i?e:{first:r,count:i})},[t]);(0,G.useLayoutEffect)(()=>{let e=o.current;if(e===null)return;let t=new ResizeObserver(u);return t.observe(e),u(),()=>{t.disconnect()}},[u]),(0,G.useLayoutEffect)(()=>{let e=o.current,s=e?.querySelector(`:scope > ul`);if(!e||!s||r<0||l.current===n)return;let c=iF(t);l.current=n,oF(e,{top:aF(e,s)+r*c,height:c,inset:i/t*c,covered:a?.(e)??0}),u()},[n,r,i,a,t,u]);let d=s===null?0:Math.max(0,s.first-nF),f=s===null?Math.min(e,rF):Math.min(e,s.first+s.count+nF);return{containerRef:o,start:Math.min(d,f),end:f,before:`${String(Math.min(d,f)*t)}rem`,after:`${String((e-f)*t)}rem`,onScroll:u}},cF=1.5,lF=2.5,uF=()=>Sb()?lF:cF,dF=e=>{let t=[],n=[],r=[];e.forEach((e,i)=>{for(let t=r.at(-1);t!==void 0&&t.depth>=e.depth;t=r.at(-1))n[t.index]=i-1,r.pop();t[i]=r.at(-1)?.index??-1,n[i]=i,r.push({index:i,depth:e.depth})});for(let{index:t}of r)n[t]=e.length-1;return{parent:t,end:n}},fF=({parent:e,end:t},n)=>{let r=[],i=(t[n]??n)>n?n:e[n]??-1;for(let t=i;t>=0;t=e[t]??-1)r.unshift(t);return r},pF={rows:[],push:0},mF=e=>e*Number(getComputedStyle(document.documentElement).fontSize.replace(`px`,``)),hF=e=>e.querySelector(`ul`)?.offsetTop??0,gF=(e,t,n)=>{let r=[];for(let i=0;i<5;i+=1){let a=Math.floor((t+i*n)/n),o=a<0||a>=e.parent.length?[]:fF(e,a),s=o[i];if(s===void 0||i>0&&o[i-1]!==r[i-1])return r;r.push(s)}return r},_F=(e,t,n)=>{let r=mF(n),i=e.scrollTop-hF(e),a=gF(t,i,r),o=a.at(-1);if(o===void 0)return pF;let s=((t.end[o]??o)+1)*r-i;return{rows:a,push:Math.max(0,a.length*r-s)}},vF=e=>{let{top:t}=e.getBoundingClientRect();return Math.max(0,...[...e.querySelectorAll(`[data-tree-pin]`)].map(e=>e.getBoundingClientRect().bottom-t))},yF=(e,t)=>e.push===t.push&&e.rows.length===t.rows.length&&e.rows.every((e,n)=>e===t.rows[n]),bF=({container:e,rows:t,rowRem:n})=>{let r=(0,G.useMemo)(()=>dF(t),[t]),[i,a]=(0,G.useState)(pF);return KA(e,()=>{let t=e===null?pF:_F(e,r,n);a(e=>yF(e,t)?e:t)}),i.rows.length===0||e===null?null:(0,K.jsx)(`div`,{className:`sticky -top-1 z-3 h-0`,children:i.rows.map((r,a)=>{let o=t[r];if(o===void 0)return null;let s=a===i.rows.length-1;return(0,K.jsxs)(`button`,{className:`absolute inset-x-2 flex h-6 w-full min-w-0 items-center gap-1.5 review-indent py-0.5 pe-2 text-start font-mono text-xs/5 text-subtle tree-pin hover:text-foreground max-md:h-10 max-md:text-sm`,"data-tree-pin":!0,"data-tree-pin-last":s?``:void 0,onClick:()=>{e.scrollTop=hF(e)+(r-a)*mF(n)},ref:e=>{e?.style.setProperty(`--depth`,String(o.depth)),e?.style.setProperty(`top`,`${String(a*n)}rem`),e?.style.setProperty(`z-index`,String(5-a)),e?.style.setProperty(`transform`,s&&i.push>0?`translateY(${String(-i.push)}px)`:``)},tabIndex:-1,title:`Scroll to ${o.label}`,type:`button`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`inline-flex w-3.5 shrink-0 justify-center`,children:(0,K.jsx)(cn,{className:`size-3 rotate-90`})}),(0,K.jsx)(`span`,{className:W(`min-w-0 flex-1 truncate`,o.key.startsWith(`layer:`)&&`font-sans font-medium text-muted-foreground`),children:o.label})]},o.key)})})},xF=({row:e,isCollapsed:t,isReviewed:n,since:r})=>(0,K.jsxs)(`span`,{"aria-hidden":!0,className:`inline-flex w-3.5 shrink-0 justify-center text-subtle`,children:[e.kind===`dir`?(0,K.jsx)(cn,{className:W(`size-3 transition-transform duration-150`,!t&&`rotate-90`)}):null,e.kind===`file`&&n?(0,K.jsx)(ar,{className:`size-3 text-success`}):null,e.kind===`file`&&r!==void 0?(0,K.jsx)(lE,{since:r}):null]}),SF=({row:e,isCursor:t,isSelected:n,isCollapsed:r,isReviewed:i,since:a,file:o,threads:s,onPick:c})=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"aria-current":n?`true`:void 0,"aria-label":e.kind===`file`&&i?`${e.label}, reviewed`:void 0,className:W(`flex h-6 w-full min-w-0 items-center gap-1.5 rounded-md py-0.5 pe-2 text-start font-mono text-xs/5 text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:bg-secondary focus-visible:text-foreground max-md:h-10 max-md:text-sm`,i&&!n&&`text-subtle`,n&&`bg-secondary text-foreground`,t&&`tree-cursor transition-none`,`review-indent`),onClick:c,ref:t=>{t?.style.setProperty(`--depth`,String(e.depth))},type:`button`,children:[(0,K.jsx)(xF,{isCollapsed:r,isReviewed:i,row:e,since:a}),(0,K.jsx)(`span`,{className:W(`min-w-0 flex-1 truncate`,e.kind===`dir`&&`text-subtle`,e.key.startsWith(`layer:`)&&`font-sans font-medium text-muted-foreground`),children:e.label}),o?(0,K.jsx)(pE,{file:o}):null,o?(0,K.jsx)(dE,{file:o}):null,(0,K.jsx)(zb,{said:jb(s),stand:s.stand})]})}),CF=({rows:e,cursor:t,selected:n,collapsed:r,files:i,isReviewed:a,getSince:o,getThreads:s,onPick:c})=>{let l=uF(),u=e.findIndex(e=>e.key===t),[d,f]=(0,G.useState)(null),{containerRef:p,start:m,end:h,before:g,after:_,onScroll:v}=sF({total:e.length,rowRem:l,activeKey:t,activeIndex:u,activeInset:Math.min(e[u]?.depth??0,5)*l,getCovered:vF}),y=(0,G.useCallback)(e=>{p.current=e,f(e)},[p]);return(0,K.jsxs)(`nav`,{"aria-label":`Changed files`,className:`relative min-h-0 overflow-auto px-2 py-1`,"data-review-rail":!0,onScroll:v,ref:y,children:[(0,K.jsx)(bF,{container:d,rowRem:l,rows:e}),(0,K.jsx)(`ul`,{className:`m-0 list-none p-0 pt-(--before) pb-(--after)`,ref:e=>{e?.style.setProperty(`--before`,g),e?.style.setProperty(`--after`,_)},children:e.slice(m,h).map(e=>(0,K.jsx)(SF,{threads:e.kind===`file`?s(e.path):Ob,file:e.kind===`file`?i.get(e.path):void 0,isCollapsed:e.kind===`dir`&&r.has(e.full),isCursor:e.key===t,isReviewed:e.kind===`file`&&a(e.path),since:e.kind===`file`?o(e.path):void 0,isSelected:e.kind===`file`&&e.path===n,onPick:()=>{c(e)},row:e},e.key))})]})},wF=(e,t)=>e.wantsLayers?{...e,wantsLayers:!1,isLayered:!0,collapsed:new Set,layerOpen:{},cursor:hw(t(e.selected),e.selected)}:e,TF=e=>`${String(e)} ${e===1?`layer`:`layers`}`,EF=({count:e,isAsked:t,state:n,setState:r,layerOf:i})=>{let a=qn();iA(e>0?`layers`:``,()=>{n.wantsLayers?(r(wF(n,i)),a.add({title:`Layers are written`,description:`${TF(e)}, in reading order`})):t&&a.add({title:`Layers are written`,description:`${TF(e)} · s shows them`})})},DF=(e,t)=>e.find(e=>e.key===t),OF=({block:e,state:t,setState:n,model:r,acts:i})=>{if(EF({count:e.layers.length,isAsked:i.layersAsked===``,state:t,setState:n,layerOf:r.layerOf}),t.isLayered&&r.hasLayers)return(0,K.jsx)(tF,{block:e,done:r.done,entries:r.entries,files:r.files,groups:r.groups,isReadIn:r.marks.isReadIn,onAllLayers:()=>{n({...t,dialog:`layers`})},isReorderAsked:i.failure===null&&i.layersAsked===bw(e.layers),onReorder:()=>{i.askLayers(e.layers)},onPickFile:(e,r)=>{let i={...t,cursor:e,selected:r};n(bb()?_D(i):i)},onPickLayer:e=>{let t=DF(r.rows,e);t!==void 0&&r.handlePick(t)},state:t});let a=(0,K.jsx)(CF,{collapsed:t.collapsed,cursor:t.cursor,files:r.files,getSince:r.marks.getSince,getThreads:r.getThreads,isReviewed:r.marks.isReviewed,onPick:r.handlePick,rows:r.rows,selected:t.selected});return t.wantsLayers&&!r.hasLayers?(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-col`,"data-review-rail-box":!0,children:[(0,K.jsx)(`div`,{className:`px-2 pt-2`,children:(0,K.jsx)(yP,{files:e.files.length,isAsked:i.failure===null&&i.layersAsked===bw(e.layers),onAsk:()=>{i.askLayers(e.layers)}})}),a]}):a},kF=(e,t,{threads:n,rows:r})=>{let i=n.find(e=>e.id===t);return i===void 0||i.file===``?{...e,threadAt:t}:{...e,threadAt:t,selected:i.file,cursor:e.isLayered?e.cursor:kD(r,i.file),row:0,anchor:null}},AF=(e,t)=>{if(e.lead===`threads`)return{...e,lead:`diff`,isBackToThreads:!1};let n=e.pile!==null&&zj(e.pile,t.threads)>0,r=n&&e.pile!==null?e.pile:Lj(t.threads),i=t.threads.find(t=>t.id===e.threadAt),a=n&&!Ij(i)?e.threadAt:Hj(r,t.threads);return kF({...e,lead:`threads`,pile:r,isPanelOpen:!0,isBackToThreads:!1},a,t)},jF=e=>e instanceof Error?e.message:String(e),MF=(e,t)=>n=>({...n,threads:n.threads.map(n=>n.id===e?t(n):n)}),NF=(e,t)=>n=>({...n,remarks:n.remarks.flatMap(n=>{if(n.id!==e)return[n];let r=t(n);return r===null?[]:[r]})}),PF=(e,t)=>n=>({...n,drafts:n.drafts.flatMap(n=>n.id===e?t===null?[]:[{...n,body:t}]:[n])}),FF=e=>({...e,isSettled:!0,isSettleable:!1,stand:`settled`,section:`settled`}),IF=e=>({...e,state:`removed`,isSettleable:!1,stand:`gone`,section:`removed`}),LF=e=>{let t=e.turns.at(-1)?.voice===`agent`?`answered`:`filed`;return{...e,isSettled:!1,stand:t,section:e.isMovedPast?`movedOn`:t}},RF=e=>t=>({...t,unread:0,isSettleable:!1,turns:[...t.turns,{voice:`reviewer`,body:e,at:new Date().toISOString()}]}),zF=e=>({...e,threads:e.threads.map(e=>e.isSettleable?FF(e):e)}),BF=e=>(t,n=``)=>()=>YS({data:{...e,act:t,id:n}}),VF=()=>{let[e,t]=(0,G.useState)(null);return{asked:e,mark:e=>{t(bw(e))}}},HF=e=>{let t=async(t,n)=>{let r=Date.now()+Math.random();e(e=>[...e,{key:r,change:t}]);try{await n()}finally{e(e=>e.filter(e=>e.key!==r))}};return{echoResolve:(e,n,r)=>t(MF(e,n?FF:LF),r),echoReply:(e,n,r)=>t(MF(e,RF(n)),r)}},UF=(e,t)=>{let[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(null),o=VF(),s=async(e,n,i)=>{let o=Date.now()+Math.random();a(null),r(t=>[...t,{key:o,change:e}]);try{await n(),await t()}catch(e){a(`${i}: ${jF(e)}`)}finally{r(e=>e.filter(e=>e.key!==o))}},c=BF(e);return{failure:i,handleDismissFailure:()=>{a(null)},shown:e=>n.reduce((e,t)=>t.change(e),e),...HF(r),settle:t=>s(MF(t.id,e=>e.isSettled?LF(e):FF(e)),()=>aC({data:{...e,id:t.id,settled:!t.isSettled}}),t.isSettled?`The thread was not taken back`:`The thread was not settled`),remove:e=>{let t=e.state===`removed`;return s(MF(e.id,e=>t?{...e,state:`sent`}:IF(e)),c(t?`restore`:`remove`,e.id),t?`The comment was not restored`:`The comment was not removed`)},read:e=>s(MF(e.id,e=>({...e,unread:0})),c(`read`,e.id),`The answer was not marked read`),settleRead:()=>s(zF,c(`settleRead`),`Nothing was settled`),layersAsked:o.asked,askLayers:async e=>{o.mark(e),await s(e=>e,c(`askLayers`),`The agent was not asked`)},sendDrafts:()=>s(e=>({...e,drafts:[]}),c(`sendDrafts`),`The notes were not sent`),remark:(t,n,r)=>s(NF(t.id,e=>n===`accept`?null:n===`reply`?e:{...e,state:n===`dismiss`?`dismissed`:`waiting`}),()=>nC({data:{...e,id:t.id,act:n,body:r??``}}),`The remark was not ${n===`reply`?`answered`:`${n}ed`}`),draft:(t,n)=>s(PF(t.id,n),()=>rC({data:{...e,id:t.id,body:n}}),n===null?`The note was not dropped`:`The note was not reworded`)}},WF=(e,t)=>e.author===t.author&&e.parent===t.parent&&e.path===t.path&&e.side===t.side&&e.start===t.start&&e.end===t.end&&e.body.trim()===t.body.trim(),GF=(e,t,n)=>e.find(e=>t.id!==null&&e.id===t.id)??e.find(e=>!n.has(e.id)&&!t.earlier.includes(e.id)&&WF(e,t.comment)),KF=(e,t)=>{let n=new Map;for(let r of t){let t=GF(e,r,n);t!==void 0&&n.set(t.id,r.key)}return n},qF=(e,{id:t,resolved:n})=>e.map(e=>e.id===t?{...e,resolved:n}:e),JF=(e,t,n)=>{let r=KF(e,t),i=new Set(r.values()),a=e.map(e=>{let t=r.get(e.id);return t===void 0?e:{...e,key:t}}),o=t.filter(e=>!e.isSettled&&!i.has(e.key)).map(e=>e.comment);return n.reduce((e,t)=>qF(e,t),[...a,...o])},YF=()=>`pending:${ka()}`,XF=(e,t)=>{let n=YF(),r={...e,id:n,key:n,author:`you`,at:new Date().toISOString()};return{key:n,comment:r,earlier:t.filter(e=>WF(e,r)).map(e=>e.id),id:null,isSettled:!1}},ZF=e=>e instanceof Error?e.message:String(e),QF=e=>{let[t,n]=(0,G.useState)([]),[r,i]=(0,G.useState)([]),[a,o]=(0,G.useState)(null),s=(e,t)=>{n(n=>n.map(n=>n.key===e?{...n,...t}:n))};return{failure:a,write:async(t,r,i)=>{o(null),n(e=>[...e,t]);try{s(t.key,{id:await r()}),await e(),s(t.key,{isSettled:!0})}catch(e){n(e=>e.filter(e=>e.key!==t.key)),o(`${i}: ${ZF(e)}`)}},settle:async({id:t,resolved:n},r,a)=>{let s={key:YF(),id:t,resolved:n};o(null),i(e=>[...e,s]);try{await r(),await e()}catch(e){o(`${a}: ${ZF(e)}`)}finally{i(e=>e.filter(e=>e.key!==s.key))}},shown:e=>JF(e,t,r),dismiss:()=>{o(null)}}},$F=e=>({...by(e),code:``,parent:null,resolved:!1}),eI=e=>{let t=KS(),n=QF(e.refresh),r=JM(e),i={...r.live,comments:n.shown(r.live.comments)},a=WS(i.comments),o={deck:e.deck,point:e.point,branch:e.block.branch},s=(e,t)=>{let{seenAt:i,key:a,...s}=e;return n.write(XF({...s,body:t,parent:e.id,resolved:!1},r.live.comments),async()=>(await iC({data:{...o,id:e.id,body:t}}),null),`Your reply did not reach adiff ("${t}")`)},c={...a,handleReply:(e,t)=>(s(e,t),Promise.resolve()),handleResolve:async(e,t)=>{await n.settle({id:e.id,resolved:t},()=>aC({data:{...o,id:e.id,settled:t}}),t?`The thread was not resolved`:`The thread was not reopened`)}};return{revision:r.revision,live:i,actions:c,sendReply:s,forFile:(i,a)=>{let{path:s,rows:c,isNewOnly:l}=a,u=t.forFile(i,c,l);return{...u,path:s,handlePost:i=>{let a=u.selected?yy(c,u.selected,l):null;if(a===null)return Promise.resolve();let d={from:vy(a.from),to:vy(a.to)},f=XF({...$F(a),point:e.point,revision:r.revision,path:s,body:i},r.live.comments);return t.clear(),n.write(f,async()=>(await JS({data:{...o,path:s,...d,body:i}})).id,`Your comment did not reach adiff ("${i}")`),Promise.resolve()}}},failure:n.failure,handleDismissFailure:n.dismiss}},tI=e=>e!==void 0&&(e.op!==`gap`||e.others!==void 0),nI=e=>e?.op===`add`||e?.op===`del`,rI=(e,t)=>Math.min(Math.max(0,t),Math.max(0,e.length-1)),iI=(e,t,n)=>{let r=rI(e,t+n);for(;!tI(e[r])&&r>0&&r<e.length-1;)r+=Math.sign(n);return rI(e,r)},aI=(e,t)=>nI(e[t])&&!nI(e[t-1]),oI=(e,t,n)=>{for(let r=t+n;r>=0&&r<e.length;r+=n)if(aI(e,r))return r;return t},sI=(e,t,n)=>(n===1?e.filter(e=>e>t):e.filter(e=>e<t).toReversed())[0]??t,cI=(e,t)=>{if(!nI(e[t]))return[t,t];let n=t,r=t;for(;nI(e[n-1]);)--n;for(;nI(e[r+1]);)r+=1;return[n,r]},lI=(e,t)=>[Math.min(e,t),Math.max(e,t)],uI=(e,t,n)=>{let[r,i]=lI(t,n);return e.selection?.handleMark?.(r,i),{...e.state,anchor:t,row:n}},dI=(e,t)=>e.state.anchor===null?{...e.state,row:t}:uI(e,e.state.anchor,t),fI=(e,t)=>uI(e,e.state.anchor??e.state.row,iI(e.rows,e.state.row,t)),pI=e=>{let[t,n]=lI(e.state.anchor??e.state.row,e.state.row);return e.selection?.handleCompose?.(t,n),{...e.state,anchor:null}},mI=e=>e.state.anchor===null?uI(e,e.state.row,e.state.row):(e.selection?.handleCancel(),{...e.state,anchor:null}),hI=e=>{let[t,n]=cI(e.rows,e.state.row);return uI(e,t,n)},gI=e=>e.state.anchor!==null||e.selection?.selected!==null?(e.selection?.handleCancel(),{...e.state,anchor:null}):{...e.state,focus:`tree`},_I=({rows:e,settledRows:t,state:n})=>{let r=e[n.row]?.others;if(r!==void 0&&!r.isOpen)return Jk(n,{...r,index:n.row});let i=Wk(e[n.row]);return i===null?t.includes(n.row)?{...n,settledAt:`${n.selected}#${String(n.row)}`}:n:{...n,opened:Gk(n.opened,{path:n.selected,range:i})}},vI=(e,t)=>{let n=e.findLastIndex((e,n)=>n<=t&&e.others?.isOpen===!0),r=e[n]?.others;return r===void 0||t>n+r.count?void 0:{...r,index:n}},yI=(e,t)=>({...e,context:t,opened:{...e.opened,[e.selected]:[]}}),bI=(e,t)=>{let{rows:n,threadRows:r,state:i}=t,a=vI(n,i.row);return e===`h`&&a!==void 0?()=>Jk(i,a):new Map([[`j`,()=>dI(t,iI(n,i.row,1))],[`ArrowDown`,()=>dI(t,iI(n,i.row,1))],[`k`,()=>dI(t,iI(n,i.row,-1))],[`ArrowUp`,()=>dI(t,iI(n,i.row,-1))],[`g`,()=>dI(t,0)],[`G`,()=>dI(t,Math.max(0,n.length-1))],[`}`,()=>dI(t,oI(n,i.row,1))],[`{`,()=>dI(t,oI(n,i.row,-1))],[`n`,()=>dI(t,sI(r,i.row,1))],[`N`,()=>dI(t,sI(r,i.row,-1))],[`v`,()=>mI(t)],[`V`,()=>hI(t)],[`c`,()=>pI(t)],[`Enter`,()=>pI(t)],[`Escape`,()=>gI(t)],[`l`,()=>_I(t)]]).get(e)},xI=(e,t)=>{if(!(!e.shiftKey||e.key!==`ArrowDown`&&e.key!==`ArrowUp`))return()=>fI(t,e.key===`ArrowDown`?1:-1)},SI=(e,t)=>new Map([[`w`,()=>({...t,isWrapped:!t.isWrapped})],[`+`,()=>({...t,context:Kk(t.context,1)})],[`=`,()=>({...t,context:Kk(t.context,1)})],[`-`,()=>yI(t,Kk(t.context,-1))],[`_`,()=>yI(t,Kk(t.context,-1))],[`F`,()=>t.context===`whole`?yI(t,3):{...t,context:`whole`}],[`Tab`,()=>({...t,focus:t.focus===`tree`?`diff`:`tree`})]]).get(e),CI=(e,{rows:t,order:n,state:r,hasLayers:i,rowsFor:a,layerOf:o,onTurn:s})=>new Map([[`T`,s],[`j`,()=>OD(r,{rows:t,offset:1})],[`ArrowDown`,()=>OD(r,{rows:t,offset:1})],[`k`,()=>OD(r,{rows:t,offset:-1})],[`ArrowUp`,()=>OD(r,{rows:t,offset:-1})],[`]`,()=>MD(r,{order:n,offset:1,rows:t})],[`M`,()=>MD(r,{order:n,offset:1,rows:t})],[`[`,()=>MD(r,{order:n,offset:-1,rows:t})],[`f`,()=>({...r,isHidingReviewed:!r.isHidingReviewed})],[`a`,()=>({...r,isPanelOpen:!r.isPanelOpen})],[`b`,()=>({...r,dialog:`base`})],[`/`,()=>({...r,dialog:`search`})],[`?`,()=>({...r,dialog:`keys`})],[`s`,()=>PD(r,{rowsFor:a,layerOf:o,hasLayers:i})],...r.isLayered?[[`h`,()=>FD(r,!1)],[`l`,()=>FD(r,!0)]]:[]]).get(e),wI=(e,t)=>new Map([[`m`,()=>{t.onToggleReviewed(t.state.isLayered?vD(t.state):null)}],[`M`,()=>{t.onToggleReviewed(t.state.isLayered?vD(t.state):null)}],[`z`,()=>{t.onToggleZoom?.()}],[`p`,t.onOpenPull],[`L`,t.onAskLayers],[`D`,t.onSettleRead],[`C`,t.onSendDrafts],[`r`,t.onToggleSince],[`S`,Wn],[`I`,Fn],[`O`,An],[`e`,()=>{Wy({...t.shown,row:t.state.row})}],[`s`,()=>{t.paneRef.current?.focus({preventScroll:!0})}]]).get(e),TI=e=>jj.has(e.key)&&(document.activeElement?.closest(`[data-review-panel]`)??null)!==null,EI=new Set([`j`,`k`,`ArrowDown`,`ArrowUp`,`[`,`]`,`d`,`Enter`,`R`]),DI=(e,{paneRef:t,isZoomed:n,state:r})=>r.dialog===null&&!TI(e)&&!(r.lead===`threads`&&EI.has(e.key))&&!bn(e.target)&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&(n||t.current?.contains(document.activeElement)===!0),OI=(e,t)=>{t.focus===`diff`&&requestAnimationFrame(()=>{e.current?.querySelector(`[data-review-row="${String(t.row)}"]`)?.scrollIntoView({block:`nearest`})})},kI=new Set([`j`,`k`,`ArrowDown`,`ArrowUp`]),AI=(e,{state:t,diff:n})=>e.key===`Escape`&&t.lead===`diff`&&t.isBackToThreads&&t.anchor===null&&(n.selection?.composerAt??null)===null?()=>({...t,lead:`threads`,isBackToThreads:!1}):void 0,jI=(e,t)=>{let n={...t.diff,state:t.state};if(t.state.focus===`diff`){let t=xI(e,n)??bI(e.key,n);if(t!==void 0)return t}let r=SI(e.key,t.state);return r===void 0?t.state.focus===`diff`&&kI.has(e.key)?void 0:CI(e.key,t):r},MI=(e,t)=>AI(e,t)??jI(e,t),NI=(e,t)=>{let n=MI(e,t),r=wI(e.key,t);if(n!==void 0||r!==void 0){if(e.preventDefault(),n!==void 0){let e=n();t.setState(e),OI(t.paneRef,e)}r?.()}},PI=(e,t)=>{let{target:n}=e;if(!bb()||!(n instanceof Element)||t.current?.contains(n)!==!0||n.closest(`[data-code], a:not([data-line-link]), button`)!==null)return null;let r=n.closest(`[data-review-diff] [data-review-row]`)?.dataset.reviewRow;return r===void 0?null:Number(r)},FI=(e,{state:t,setState:n,diff:r})=>{let{selection:i}=r;if(i?.composerAt!==null)return;let a=t.anchor??e;t.anchor===e&&t.row===e?(i.handleCancel(),n({...t,anchor:null,row:e})):(i.handleMark?.(Math.min(a,e),Math.max(a,e)),n({...t,focus:`diff`,anchor:a,row:e}))},II=e=>(Ut(`keydown`,t=>{DI(t,e)&&NI(t,e)}),Ut(`click`,t=>{let n=PI(t,e.paneRef);n!==null&&FI(n,e)}),t=>{let n={key:t,shiftKey:!1,preventDefault:()=>{}},r={...e,state:{...e.state,dialog:null}};e.state.dialog!==null&&MI(n,r)===void 0&&e.setState(r.state),NI(n,r)}),LI=(e,t)=>t.tickets.length===0||e.isRemainder?e.title:`${e.address} ${e.title}`,RI=(e,{after:t,index:n})=>{let r=t?.layers[n];if(t===null||r?.isDone!==!0||e.layers[n]?.isDone===!0)return null;let i=t.tickets.find(e=>e.number===r.ticket),a=e.tickets.find(e=>e.number===r.ticket)?.isDone===!0,o=i!==void 0&&i.isDone&&!a?i:void 0,s=o===void 0?n:Math.max(n,...o.layers.map(e=>e-1)),c=t.layers.find((e,t)=>t>s&&e.files.length>0);return{title:`Layer ${o?.address??r.address} read`,description:c===void 0?`Every layer is read`:`Next: ${LI(c,t)}`}},zI=`*`,BI=(e,t)=>`${e===null?zI:String(e)}:${t}`,VI=e=>e instanceof Error?e.message:String(e),HI=(e,t)=>e.layers.filter(e=>e.files.includes(t)).length,UI=(e,t)=>new Set([...e.reviewed,...e.order].filter(e=>t(e))).size,WI=({deck:e,point:t,block:n,refresh:r,onLayers:i})=>{let[a,o]=(0,G.useState)(new Map),[s,c]=(0,G.useState)(null),l=e=>a.get(BI(null,e))??n.reviewed.includes(e),u=e=>l(e)?void 0:n.since.find(t=>t.path===e),d=(e,t)=>{let r=a.get(BI(null,t));return r===void 0?a.get(BI(e,t))??(l(t)||n.layers[e]?.read.includes(t)===!0):r},f=(e,t)=>a.get(BI(e,t))??a.get(BI(null,t))??n.layers[e]?.parts.find(e=>e.path===t)?.isRead===!0,p=async(e,t,n)=>{c(null),o(n=>new Map([...n,[e,t]]));try{let{told:e}=await n();return i(e),await r(),e}catch(e){return c(`The file was not marked: ${VI(e)}`),null}finally{o(t=>new Map([...t].filter(([t])=>t!==e)))}};return{isReviewed:l,getSince:u,isReadIn:d,isPartRead:f,toggle:(r,i)=>{let a=i!==null&&HI(n,r)>1,o=n.files.find(e=>e.path===r)?.blob??``,s={deck:e,point:t,branch:n.branch,path:r,blob:o};return a?p(BI(i,r),!d(i,r),()=>C({data:{...s,layer:n.layers[i]?.address??String(i+1)}})):p(BI(null,r),!l(r),()=>C({data:{...s,layer:null}}))},count:UI(n,l),failure:s,handleDismissFailure:()=>{c(null)}}},GI=e=>{let{deck:t,view:n,block:r,state:i,setState:a,refresh:o,onLayers:s}=e,c=WI({deck:t,point:n.id,block:r,refresh:o,onLayers:s}),l=qn(),u=e=>e.isHidingReviewed?r.order.filter(t=>!c.isReviewed(t)||t===e.selected):r.order,d=e=>YP(r,{state:e,present:r.order,shown:u(e),isShownIn:(t,n)=>!e.isHidingReviewed||n===e.selected||!c.isPartRead(t,n)}),{rows:f,order:p,groups:m,entries:h,done:g}=d(i),_=e=>Math.max(0,r.layers.findIndex(t=>t.files.includes(e))),v=d(ZP(i)).order,y=v.indexOf(i.isLayered?i.cursor:i.selected);return{marks:c,rows:f,order:p,groups:m,entries:h,done:g,hasLayers:r.layers.length>0,rowsFor:e=>d(e).rows,layerOf:_,isReadHere:e=>{let t=XP(i);return t===null?c.isReviewed(e):c.isReadIn(t,e)},toggleReviewed:async(e,t)=>{let n=RI({layers:r.layers,tickets:r.tickets},{after:await c.toggle(e,t),index:t??_(e)});n!==null&&l.add(n)},position:y===-1?0:y+1,total:v.length,reviewTotal:r.total,files:new Map(r.files.map(e=>[e.path,e])),getThreads:e=>kb(r.fileMarks,e),handleOpen:e=>{let t={...i,selected:e,cursor:`file:${e}`,row:0,anchor:null};a(bb()?_D(t):t)},handlePick:e=>{let t=DD(i,e,h);a(e.kind===`file`&&bb()?_D(t):t)}}},KI=(e,t)=>{let n=vw(e.cursor);if(n!==null&&t.layers.includes(n+1))return n;let[r]=t.layers;return r===void 0?null:r-1},qI=`near:`,JI=e=>{if(!e.startsWith(qI))return null;let t=e.slice(5),n=t.lastIndexOf(`:`);return{path:t.slice(0,n),line:Number(t.slice(n+1))}},YI=(e,t)=>n=>{let r=JI(n);if(r===null)return t.get(n);if(r.path!==e.path)return;let i=e.rows.findIndex(e=>e.new!==null&&e.new>=r.line);return i===-1?e.rows.findLastIndex(e=>e.new!==null):i},XI=({props:e,rowOf:t,paneRef:n})=>{let{state:r,setState:i}=e,[a,o]=(0,G.useState)(null),s=a===null?void 0:t(a);return iA(s===void 0?``:`${a??``}@${String(s)}`,()=>{s!==void 0&&(o(null),i({...r,row:s,anchor:null,focus:`diff`}),requestAnimationFrame(()=>{n.current?.querySelector(`[data-review-diff] [data-review-row="${String(s)}"]`)?.scrollIntoView({block:`center`,behavior:`smooth`})}))}),{handleJump:(e,t={})=>{let n=r.isLayered?KI(r,e):null;o(e.id),i({...r,...t,selected:e.file,cursor:n===null?`file:${e.file}`:hw(n,e.file),anchor:null})},handleShowLayer:(e,t={})=>{if(e.file===``)return;let[n]=e.layers;o(`${qI}${e.file}:${String(e.start)}`),i({...r,...t,isLayered:n!==void 0,selected:e.file,cursor:n===void 0?`file:${e.file}`:hw(n-1,e.file),row:0,anchor:null})}}},ZI=({threads:e,shown:t,acts:n})=>{let r=e.filter(e=>t.includes(e.id)&&e.unread>0&&e.state!==`removed`);iA(r.map(e=>e.id).join(`|`),()=>{r.forEach(e=>{n.read(e)})})},QI=({props:e,model:t,comments:n,isAllShown:r})=>{let i=t.files.get(e.state.selected);if(i===void 0||!e.isFileLoaded(i.path))return{file:i,selection:null,threadRows:[],settledRows:[],shownThreads:[],rowOf:()=>void 0};let{state:a,block:o}=e,s=Hk(i,{context:a.context,opened:a.opened[i.path]??[],runs:a.runs[i.path]??[],isAllShown:r,layers:o.layers,cursor:a.isLayered?a.cursor:null}),c={...i,rows:s},l=hy(my(c.rows,{comments:n.live.comments,path:c.path,revision:n.revision}).byRow);return{file:c,selection:n.forFile(`${String(e.blockIndex)}:${c.path}`,{path:c.path,rows:c.rows,isNewOnly:c.isSince===!0}),threadRows:[...l.open.keys()],settledRows:[...l.settled.keys()],shownThreads:[...l.open.values()].flat().map(e=>e.root.id),rowOf:YI(c,new Map([...l.open.entries()].flatMap(([e,t])=>t.map(t=>[t.root.id,e]))))}},$I=e=>{let{isOthersShown:t}=Un();return QI({...e,isAllShown:t})},eL=(e,t)=>e?.rows.findIndex(e=>e.new===t)??-1,tL=(e,t)=>{let n=`${e.path}:${String(e.line)}`;if(e.row!==null)return`scroll:${n}:${String(e.row)}`;if(!e.isWidened)return`open:${n}`;let r=eL(t,e.line);return r===-1?``:`found:${n}:${String(r)}`},nL=(e,t)=>e===null||t.shown?.path!==e.path?``:t.props.isFileLoaded(e.path)?tL(e,t.shown):``,rL=({props:e,shown:t,whole:n},r)=>{let i=eL(t,r.line);if(i===-1&&!r.isWidened&&eL(n,r.line)!==-1&&n!==void 0)return e.setState(Zk(e.state,{path:r.path,line:r.line,rows:n.rows})),{...r,isWidened:!0};let a=Math.max(0,i);return e.setState({...e.state,focus:`diff`,row:a,anchor:null}),{...r,row:a}},iL=(e,t)=>{e.current?.querySelector(`[data-review-row="${String(t)}"]`)?.scrollIntoView({block:`center`}),e.current?.focus({preventScroll:!0})},aL=e=>{let[t,n]=(0,G.useState)(null),{props:r,paneRef:i}=e,a=new Set(r.block.files.map(e=>e.path));return iA(nL(t,e),()=>{t?.row===null?n(rL(e,t)):t!==null&&(iL(i,t.row),n(null))}),{canJump:e=>a.has(e),handleJump:(t,r)=>{e.onOpen(t),n({path:t,line:r,row:null,isWidened:!1})}}},oL=(e,t)=>{let n=qn(),r=(n,r)=>t.echoResolve(n.id,r,()=>e.actions.handleResolve(n,r));return{...e,actions:{...e.actions,handleResolve:async(e,t)=>{t&&n.add({title:`Settled`,actionProps:{children:`Undo`,onClick:()=>{r(e,!1)}}}),await r(e,t)},handleReply:(n,r)=>(t.echoReply(n.id,r,()=>e.sendReply(n,r)),Promise.resolve())}}},sL=(e,t)=>e.shown({threads:t,remarks:[],drafts:[]}).threads,cL=(e,t)=>{let{deck:n,view:r,block:i,state:a,setState:o,isZoomed:s,onToggleZoom:c}=e,l=eI({deck:n,point:r.id,live:e.live,block:i,refresh:e.refresh}),u=GI({...e,live:l.live}),d=UF({deck:n,point:r.id,branch:i.branch},e.refresh),f=$I({props:e,model:u,comments:l}),{file:p,selection:m,threadRows:h,settledRows:g,shownThreads:_}=f,v=aL({props:e,shown:p,whole:u.files.get(a.selected),paneRef:t,onOpen:u.handleOpen});ZI({threads:i.threads,shown:_,acts:d});let y=II({paneRef:t,isZoomed:s,rows:u.rows,order:u.order,hasLayers:u.hasLayers,rowsFor:u.rowsFor,layerOf:u.layerOf,state:a,setState:o,onToggleReviewed:e=>{u.toggleReviewed(a.selected,e)},onToggleZoom:c,onOpenPull:()=>{let t=e.extras.pull?.url;t!==void 0&&window.open(t,`_blank`,`noopener`)},onAskLayers:()=>{d.askLayers(i.layers)},onSettleRead:()=>{d.settleRead()},onSendDrafts:()=>{d.sendDrafts()},onTurn:()=>AF(a,{threads:sL(d,i.threads),rows:u.rows}),onToggleSince:()=>{let t=e.sinceView.modeOf(a.selected);t!==null&&e.sinceView.setMode(a.selected,t===`since`?`full`:`since`)},shown:{worktree:i.worktree,file:p},diff:{rows:p?.rows??[],threadRows:h,settledRows:g,selection:m}});return{comments:oL(l,d),model:u,acts:d,shown:d.shown({threads:i.threads,remarks:e.extras.remarks,drafts:e.extras.drafts}),handleOpen:u.handleOpen,threadJump:XI({props:e,rowOf:f.rowOf,paneRef:t}),press:y,jump:v,file:p,selection:m}},lL=k({id:b(),file:b(),start:i(),end:i(),at:b(),snippet:b(),isMovedPast:y(),isOutdated:y()});k({deck:b(),point:b(),branch:b(),threads:w(lL)});var uL=e=>({id:e.id,file:e.file,start:e.start,end:e.end,at:e.at,snippet:e.snippet,isMovedPast:e.isMovedPast,isOutdated:e.isOutdated}),dL={key:``,found:{}},fL=(e,{threads:t,isOn:n})=>{let[r,i]=(0,G.useState)(dL),a=new Map(e.block.files.map(e=>[e.path,e.fingerprint])),o=n&&t.length>0?[e.block.head.sha,...t.map(e=>`${e.id}@${a.get(e.file)??``}`)].join(`|`):``,s=xy(o);return iA(o,()=>{let{deck:n,view:r,block:a}=e,c=t.map(e=>uL(e));(async()=>{try{let e=await ZS({data:{deck:n,point:r.id,branch:a.branch,threads:c}});s.current===o&&i({key:o,found:e})}catch{}})()}),r.found},pL=e=>e.metaKey||e.ctrlKey||e.altKey,mL=(e,t)=>t.isOn&&EI.has(e.key)&&!t.isDialogOpen&&!pL(e)&&!bn(e.target)&&(t.isZoomed||t.paneRef.current?.contains(document.activeElement)===!0),hL=e=>{Ut(`keydown`,t=>{let n=e.keys.get(t.key);n!==void 0&&mL(t,e)&&(t.preventDefault(),n(t))})},gL=300,_L=({props:e,pane:t},n)=>{let{state:r}=e,i=r.pile??[],a=t.shown.threads,o=new Map(a.map(e=>[e.id,e]));return{isOn:r.lead===`threads`&&!n,pile:i,found:o,all:a,current:r.threadAt===null?void 0:o.get(r.threadAt),threads:i.flatMap(e=>{let t=o.get(e.id);return t===void 0?[]:[t]})}},vL=({props:e,pane:t},n)=>(r,i=null)=>{let{state:a,setState:o}=e,{threads:s}=t.shown,c=s.find(e=>e.id===r);r!==null&&r!==a.threadAt&&(i!==null&&n.mark(i),o(kF(a,r,{threads:s,rows:t.model.rows})),c!==void 0&&c.unread>0&&t.acts.read(c))},yL=({pane:e},t)=>(n=t.current)=>{if(n===void 0||n.isAboutBranch)return;let r={lead:`diff`,isBackToThreads:!0,threadAt:n.id};n.isMovedPast?e.threadJump.handleShowLayer(n,r):e.threadJump.handleJump(n,r)},bL=(e,{view:t,moved:n})=>{let{props:r,pane:i,paneRef:a}=e,{threads:o}=i.shown,s=r.state.threadAt,c=vL(e,n),l=e=>YM(e,{point:r.view.id,revision:i.comments.revision,comments:i.comments.live.comments});return{pick:c,placed:l,showInDiff:yL(e,t),step:(e,n)=>{c(Uj(t.pile,{threads:o,at:s,offset:e}),n)},section:(e,n)=>{c(Wj(t.pile,{threads:o,at:s,offset:e}),n)},settle:e=>{t.current===void 0||e-n.at<gL||(i.comments.actions.handleResolve(l(t.current).root,!0),c(Uj(t.pile,{threads:o,at:t.current.id,offset:1}),e))},reply:()=>{a.current?.querySelector(`[data-thread-current] [data-reply-open]`)?.click()},turn:()=>{r.setState(AF(r.state,{threads:o,rows:i.model.rows}))}}},xL=e=>new Map([[`j`,t=>{e.step(1,t.timeStamp)}],[`ArrowDown`,t=>{e.step(1,t.timeStamp)}],[`k`,t=>{e.step(-1,t.timeStamp)}],[`ArrowUp`,t=>{e.step(-1,t.timeStamp)}],[`]`,t=>{e.section(1,t.timeStamp)}],[`[`,t=>{e.section(-1,t.timeStamp)}],[`d`,t=>{e.settle(t.timeStamp)}],[`Enter`,()=>{e.showInDiff()}],[`R`,e.reply]]),SL=(e,{view:t,acts:n})=>{let r=Gj(e.state.pile);return t.isOn&&r!==void 0?{pile:r,at:t.current?.id??null,left:zj(t.pile,t.all),onPick:e=>{n.pick(e.id)}}:void 0},CL=e=>{let{props:t,paneRef:n}=e,[r,i]=(0,G.useState)(0),a=_L(e,Sb()),o=fL(t,{threads:a.threads,isOn:a.isOn}),s=bL(e,{view:a,moved:{at:r,mark:e=>{i(e)}}});return hL({isOn:a.isOn,isZoomed:t.isZoomed,isDialogOpen:t.state.dialog!==null,paneRef:n,keys:xL(s)}),{...a,...s,code:o,left:zj(a.pile,a.all),waiting:Lj(a.all).length,panel:SL(t,{view:a,acts:s})}},wL=`review-height rounded-md border border-border max-md:rounded-none max-md:border-0`,TL=e=>{let{block:t,state:n,setState:r,isZoomed:i,onToggleZoom:a}=e,o=(0,G.useRef)(null),s=cL(e,o),c=CL({props:e,pane:s,paneRef:o}),l=c.turn,{phone:u,view:d,swipe:f,backRef:p,handleBarScroll:m}=lP(e,s);return(0,K.jsxs)(`section`,{"aria-label":`Review of ${t.branch}`,className:`flex min-h-0 flex-col overflow-clip bg-wash outline-none ${i?`size-full`:wL}`,"data-owns-keys":!0,onScrollCapture:t=>{e.onScroll(t.currentTarget,s.selection===null?null:s.file??null),m(t.target)},ref:o,tabIndex:-1,children:[(0,K.jsx)(nO,{block:t,isZoomed:i,lead:(0,K.jsx)(fM,{isThreads:c.isOn,left:c.isOn?c.left:c.waiting,onTurn:l}),onBase:()=>{r({...n,dialog:`base`})},onKeys:()=>{r({...n,dialog:`keys`})},onToggleZoom:a,phone:u,pull:e.extras.pull,reviewedCount:s.model.marks.count,model:u.listener,total:s.model.reviewTotal}),(0,K.jsxs)(`div`,{className:`relative min-h-0 flex-1 ${n.isPanelOpen?`review-columns-panel`:`review-columns`}`,"data-phone-view":d,onTouchEnd:f.handleTouchEnd,onTouchStart:f.handleTouchStart,ref:p,children:[(0,K.jsx)(OF,{block:t,model:s.model,acts:s.acts,setState:r,state:n}),(0,K.jsx)(pM,{lead:c,onPress:u.handlePress,pane:s,props:e}),n.isPanelOpen?(0,K.jsx)(vN,{lead:c,pane:s,paneRef:o,props:e}):null]}),(0,K.jsx)(hP,{...u}),(0,K.jsx)($E,{onOpen:s.handleOpen,phone:u,props:e})]})},EL=(e,t)=>{let n=(0,G.useRef)({onMount:e,onUnmount:t});(0,G.useEffect)(()=>{n.current={onMount:e,onUnmount:t}}),(0,G.useLayoutEffect)(()=>(n.current.onMount(),()=>{n.current.onUnmount()}),[])},DL=e=>{let t=(0,G.useRef)(e);(0,G.useEffect)(()=>{t.current=e}),(0,G.useEffect)(()=>{let e=()=>{t.current()},n=()=>{document.visibilityState===`hidden`&&t.current()};return globalThis.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,n),()=>{globalThis.removeEventListener(`pagehide`,e),document.removeEventListener(`visibilitychange`,n)}},[])},OL=`review-deck-review`,kL=k({old:d(i()),new:d(i())}),AL=k({path:b(),fingerprint:b(),top:i(),line:d(kL)}),jL=k({version:O(1),head:b(),isZoomed:y(),selected:b(),cursor:b(),collapsed:w(b()),isHidingReviewed:y(),isLayered:y(),layerOpen:l(b(),y()),isPanelOpen:y(),focus:o([`tree`,`diff`]),row:i(),context:c([i(),O(`whole`)]),opened:f(l(b(),w(s([i(),i()]))),{}),isWrapped:y(),lead:f(o([`diff`,`threads`]),`diff`),pile:f(d(w(k({id:b(),section:o([`asked`,`answered`,`movedOn`])}))),null),threadAt:f(d(b()),null),scroll:d(AL),rail:i()}),ML=({deck:e,point:t,blockIndex:n,branch:r})=>[OL,e,t,String(n),r].join(`|`),NL=e=>{try{let t=r(jL,JSON.parse(sessionStorage.getItem(e)??`null`));return t.success?t.output:null}catch{return null}},PL=(e,t)=>{try{return sessionStorage.setItem(e,JSON.stringify(t)),!0}catch{return!1}},FL=(e,t)=>e.includes(t)?t:e.find(e=>e>t)??e.at(-1)??``,IL=(e,t)=>Math.max(0,e.layers.findIndex(e=>e.files.includes(t))),LL=(e,{selected:t,isLayered:n})=>n?`layer:${String(IL(e,t))}:${t}`:`file:${t}`,RL=(e,t)=>{let n=wD(t),r=FL(t.order,e.selected);if(r===``)return{state:n,isZoomed:e.isZoomed,scroll:null,rail:0};let i=r===e.selected&&e.head===t.head.sha,a=e.isLayered&&t.layers.length>0,o=new Set(CD(r));return{state:{...n,selected:r,cursor:i?e.cursor:LL(t,{selected:r,isLayered:a}),collapsed:new Set(e.collapsed.filter(e=>!o.has(e))),isHidingReviewed:e.isHidingReviewed,isLayered:a,layerOpen:i?e.layerOpen:{},isPanelOpen:e.isPanelOpen,focus:e.focus,row:i?e.row:0,context:e.context,opened:e.head===t.head.sha?e.opened:{},isWrapped:e.isWrapped,lead:e.lead,pile:e.pile,threadAt:e.threadAt},isZoomed:e.isZoomed,scroll:e.scroll?.path===r?e.scroll:null,rail:e.rail}},zL=(e,{head:t,isZoomed:n,scroll:r,rail:i})=>({version:1,head:t,isZoomed:n,selected:e.selected,cursor:e.cursor,collapsed:[...e.collapsed],isHidingReviewed:e.isHidingReviewed,isLayered:e.isLayered,layerOpen:{...e.layerOpen},isPanelOpen:e.isPanelOpen,focus:e.focus,row:e.row,context:e.context,opened:Object.fromEntries(Object.entries(e.opened).map(([e,t])=>[e,t.map(([e,t])=>[e,t])])),isWrapped:e.isWrapped,lead:e.lead,pile:e.pile===null?null:e.pile.map(e=>({...e})),threadAt:e.threadAt,scroll:r,rail:i}),BL=(e,t)=>{let{reviewRow:n=``}=RA(e)?.dataset??{},r=n===``?void 0:t.rows[Number(n)];return{path:t.path,fingerprint:t.fingerprint,top:e.scrollTop,line:r===void 0?null:{old:r.old,new:r.new}}},VL=(e,t)=>t.new!==null&&e.new!==null?Math.abs(e.new-t.new):t.old!==null&&e.old!==null?Math.abs(e.old-t.old):1/0,HL=(e,t)=>e.reduce((e,n,r)=>{let i=VL(n,t);return i<e.distance?{index:r,distance:i}:e},{index:-1,distance:1/0}).index,UL=(e,t,n)=>{let r=n===null?-1:HL(t.rows,n);r===-1?e.scrollTop=0:UA(e,t,r)},WL=(e,{scroll:t,file:n})=>{t.fingerprint===n.fingerprint?e.scrollTop=t.top:UL(e,n,t.line)},GL=3e3,KL=[`touchstart`,`wheel`,`keydown`,`pointerdown`],qL=(e,{scroll:t,file:n})=>{let r={isFirst:!0},i=new ResizeObserver(()=>{r.isFirst?r.isFirst=!1:t.line===null?e.scrollTop=t.top:UL(e,n,t.line)});return i.observe(e.querySelector(`[data-review-rows]`)??e),i},JL=(e,t)=>{for(let t of e.getAnimations())t.finish();WL(e,t);let n=qL(e,t),r=()=>{n.disconnect();for(let e of KL)globalThis.removeEventListener(e,r,!0)};for(let e of KL)globalThis.addEventListener(e,r,{capture:!0,passive:!0});globalThis.setTimeout(r,GL)},YL=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),XL=(e,t)=>{let n=vw(e.cursor);return n!==null&&e.cursor===hw(n,e.selected)?n:Math.max(0,t.findIndex(t=>t.files.includes(e.selected)))},ZL=(e,t,n)=>{if(t.selected===e.selected&&t.isLayered===e.isLayered)return t;if(!t.isLayered){let e=new Set(CD(t.selected));return{...t,collapsed:new Set([...t.collapsed].filter(t=>!e.has(t)))}}let r=XL(t,n),i=n[r]?.ticket??null,a=YL(t.layerOpen,pw(r));return{...t,cursor:hw(r,t.selected),layerOpen:i===null?a:YL(a,mw(i))}},QL=250,$L=`[data-review-diff]`,eR=`[data-review-rail]`,tR=(e,t)=>{let n=e.closest(`section`)?.querySelector(eR);n!=null&&(n.scrollTop=t)},nR=(e,t,n)=>{let r=(0,G.useRef)(null),i=()=>{let{state:r,...i}=n.current;PL(e,zL(r,{...i,head:t}))};return{save:i,flush:()=>{r.current!==null&&(clearTimeout(r.current.id),r.current.measure(),r.current=null),i()},later:e=>{r.current===null?r.current={measure:e,id:setTimeout(()=>{r.current?.measure(),r.current=null,i()},QL)}:r.current.measure=e}}},rR=(e,t)=>{bb()&&(e.current.state={...e.current.state,isWrapped:!0},t(e.current.state))},iR=(e,t)=>{let[n,r]=(0,G.useState)(()=>wD(t)),[i,a]=(0,G.useState)(!1),o=(0,G.useRef)({state:n,isZoomed:!1,scroll:null,rail:0}),s=(0,G.useRef)(null),c=nR(ML(e),t.head.sha,o);return EL(()=>{let n=NL(ML(e));if(n===null){rR(o,r),Mn();return}let i=RL(n,t);s.current={path:i.state.selected,scroll:i.scroll,rail:i.rail},o.current=i,r(i.state),a(i.isZoomed)},()=>{o.current.isZoomed=!1,c.flush()}),DL(c.flush),{state:n,isZoomed:i,setState:e=>{let n=ZL(o.current.state,e,t.layers);s.current=null,Mn(),o.current.state=n,r(n),c.save()},setIsZoomed:e=>{o.current.isZoomed=e,a(e),c.save()},handleScroll:(e,t)=>{c.later(()=>{let n=e.querySelector($L);o.current.rail=e.querySelector(eR)?.scrollTop??0,o.current.scroll=n===null||t===null?o.current.scroll:BL(n,t)})},handleDiffShown:(e,t)=>{let n=s.current;n?.path===t.path&&(s.current=null,n.scroll!==null&&JL(e,{scroll:n.scroll,file:t}),tR(e,n.rail),Mn())}}},aR=({branch:e,isFullPage:t})=>(0,K.jsxs)(`div`,{className:W(`grid place-items-center rounded-md border border-border text-sm text-subtle`,t?`size-full`:`review-height`),children:[`Reading `,e,`…`]}),oR=({outline:e,refresh:t,extras:n,stub:r,isFullPage:i=!1,...a})=>{let o=iR({deck:a.deck,point:a.view.id,blockIndex:a.blockIndex,branch:r.branch},e),{state:s,isZoomed:c,setState:l,setIsZoomed:u}=o,d=zC(e),f=XC({deck:a.deck,point:a.view.id,branch:r.branch},{outline:e,selected:s.selected,layer:s.isLayered?vw(s.cursor):null}),p={...e,kind:`review`,title:r.title,files:f.files,layers:d.layers,tickets:d.tickets,threads:d.threads},m={...a,block:p,state:s,setState:l,refresh:t,onLayers:d.handleLayers,extras:n.extras,isFileLoaded:f.isFileLoaded,sinceView:f.sinceView,onToggleZoom:()=>{u(!c)},onScroll:o.handleScroll,onDiffShown:o.handleDiffShown};return i?(0,K.jsx)(TL,{...m,isZoomed:!0,onToggleZoom:void 0}):(0,K.jsxs)(K.Fragment,{children:[c?(0,K.jsx)(`div`,{className:`grid review-height place-items-center rounded-md border border-dashed border-border text-sm text-subtle`,children:`Zoomed in · Esc to close`}):(0,K.jsx)(TL,{...m,isZoomed:!1}),(0,K.jsx)(j_,{onOpenChange:u,open:c,children:(0,K.jsxs)(I_,{"data-review-zoom":!0,initialFocus:!1,children:[(0,K.jsxs)(N_,{children:[`Review of `,r.branch]}),(0,K.jsx)(TL,{...m,isZoomed:!0})]})})]})},sR=e=>{let{stub:t}=e,n=sC({deck:e.deck,point:e.view.id,branch:t.branch}),{outline:r,refresh:i}=RC({deck:e.deck,point:e.view.id,branch:t.branch,kept:t.outline},e=>e.includes(`other`)?n.refresh():Promise.resolve());return(0,K.jsxs)(`div`,{className:W(`grid grid-cols-1 gap-3`,e.isFullPage===!0&&`h-full grid-rows-1`),children:[t.title===void 0?null:(0,K.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:t.title}),r===null?(0,K.jsx)(aR,{branch:t.branch,isFullPage:e.isFullPage===!0}):(0,K.jsx)(oR,{...e,extras:n,outline:r,refresh:i})]})};export{p_ as A,Rg as B,iy as C,H_ as D,Kv as E,Ng as F,jr as G,Ti as H,Mg as I,ar as J,Dr as K,Fg as L,Ag as M,jg as N,W_ as O,Og as P,Pg as R,ay as S,Jv as T,di as U,Xa as V,ti as W,Zn as Y,zy as _,ST as a,my as b,KS as c,aS as d,uS as f,Ry as g,My as h,bT as i,kg as j,G_ as k,WS as l,rS as m,_T as n,vT as o,lS as p,Cr as q,yT as r,gT as s,sR as t,US as u,Vy as v,$v as w,by as x,yy as y,Lg as z};
|