frizz-server 0.15.50 → 0.15.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev-child.js +645 -181
- package/package.json +1 -1
- package/runtime/cc-worker/lib/frizz-tools.mjs +3 -2
- package/web-dist/assets/{abnfDiagram-VCTEODGH-CSl-iUaD.js → abnfDiagram-VCTEODGH-DiSjUTD1.js} +1 -1
- package/web-dist/assets/architecture-7GRP2DOG-BYgmFD1v.js +1 -0
- package/web-dist/assets/{architectureDiagram-5GKGNRK7-Bo_gyMVC.js → architectureDiagram-5GKGNRK7-I0TjaMyJ.js} +1 -1
- package/web-dist/assets/{blockDiagram-I7D4REHJ-9EtOS1Y1.js → blockDiagram-I7D4REHJ-XB2-cEOS.js} +1 -1
- package/web-dist/assets/{c4Diagram-7LVT6UL2-CE1hW3oj.js → c4Diagram-7LVT6UL2-DtSoQNFw.js} +1 -1
- package/web-dist/assets/channel-DWuOn0MA.js +1 -0
- package/web-dist/assets/{chunk-2E4U76K2-QqOdoNOR.js → chunk-2E4U76K2-B-wkZcpD.js} +1 -1
- package/web-dist/assets/{chunk-4HAMMTFA-Df2uLm9r.js → chunk-4HAMMTFA-DWlXC__7.js} +1 -1
- package/web-dist/assets/{chunk-75Z2AOVW-DF1G6d8q.js → chunk-75Z2AOVW-B8ME16qz.js} +1 -1
- package/web-dist/assets/{chunk-CLGD4ZFX-CMAQm7EJ.js → chunk-CLGD4ZFX-DgSrSm54.js} +1 -1
- package/web-dist/assets/{chunk-DU6HZSFF-UWY5hXXp.js → chunk-DU6HZSFF-CKILAkFG.js} +1 -1
- package/web-dist/assets/{chunk-F27PBJKO-C59uYSbj.js → chunk-F27PBJKO-B_8M_0Rl.js} +1 -1
- package/web-dist/assets/{chunk-GMAD6QVW-BsJsQjY4.js → chunk-GMAD6QVW-UnCsWXAs.js} +1 -1
- package/web-dist/assets/{chunk-GVQU2GXP-BuITwr9r.js → chunk-GVQU2GXP-DC9Elw0X.js} +1 -1
- package/web-dist/assets/{chunk-IMKFNOWR-5Ui4f5l4.js → chunk-IMKFNOWR-wpPy-2NT.js} +1 -1
- package/web-dist/assets/{chunk-L3NEJ4N5-BISBblwX.js → chunk-L3NEJ4N5-BMMh5yw5.js} +1 -1
- package/web-dist/assets/{chunk-OSK3NFVY-CZl3XlkY.js → chunk-OSK3NFVY-CsTV5TtL.js} +1 -1
- package/web-dist/assets/{chunk-P2QGCYS3-DoytbW1J.js → chunk-P2QGCYS3-D3dlUq-V.js} +1 -1
- package/web-dist/assets/{chunk-POPQ4Y6H-D28hnSIy.js → chunk-POPQ4Y6H-BvI7-pFd.js} +1 -1
- package/web-dist/assets/{chunk-PWAF6VOD-CbZvnkji.js → chunk-PWAF6VOD-RqbILfUC.js} +1 -1
- package/web-dist/assets/{chunk-SHT3W25Y-DM4ozJwj.js → chunk-SHT3W25Y-OWaxTLwc.js} +1 -1
- package/web-dist/assets/{chunk-SVP7TREG-m6oapxSg.js → chunk-SVP7TREG-DGAeAXgv.js} +1 -1
- package/web-dist/assets/{chunk-TICWLB2K-Ochfyos9.js → chunk-TICWLB2K-CsSqwjw1.js} +1 -1
- package/web-dist/assets/{chunk-TLUHSLCS-iM7uiuAo.js → chunk-TLUHSLCS-C9oqWUOB.js} +2 -2
- package/web-dist/assets/classDiagram-ZZMXUADV-DSspmFZn.js +1 -0
- package/web-dist/assets/classDiagram-v2-VYDZK3BY-DSspmFZn.js +1 -0
- package/web-dist/assets/{cynefin-OW5HDTMX-XtTYGcIH.js → cynefin-OW5HDTMX-BG_ktheh.js} +1 -1
- package/web-dist/assets/{cynefinDiagram-5FMLGOSQ--ClxINOZ.js → cynefinDiagram-5FMLGOSQ-DNxe0xQs.js} +1 -1
- package/web-dist/assets/{dagre-GXQ25YYZ-CupZ_9Gq.js → dagre-GXQ25YYZ-5rLGzKH4.js} +1 -1
- package/web-dist/assets/{diagram-S7CK7UJ4-BlF7gkGi.js → diagram-S7CK7UJ4-ink8IARk.js} +1 -1
- package/web-dist/assets/{diagram-UQ7AKVKN-BMXRmU5D.js → diagram-UQ7AKVKN-CER8u9ua.js} +1 -1
- package/web-dist/assets/{diagram-VSXAHHWV-r5DJsSB3.js → diagram-VSXAHHWV-BWxvx-RY.js} +1 -1
- package/web-dist/assets/{diagram-VX7I27RA-DxGq7Ln7.js → diagram-VX7I27RA-CJ1Zu00i.js} +1 -1
- package/web-dist/assets/{diagram-Z3DM3KII-DqXtb_id.js → diagram-Z3DM3KII-Co7zWuGs.js} +1 -1
- package/web-dist/assets/{ebnfDiagram-PWID7BFC-BV_AT7TD.js → ebnfDiagram-PWID7BFC-nrejbQbC.js} +1 -1
- package/web-dist/assets/{erDiagram-RLTQ6QDP-BV70EqG9.js → erDiagram-RLTQ6QDP-C6CKKxxF.js} +1 -1
- package/web-dist/assets/eventmodeling-NTZA5JFV-BSYbQdT6.js +1 -0
- package/web-dist/assets/flowDiagram-HODETNUW-DlmV6Aj2.js +1 -0
- package/web-dist/assets/{ganttDiagram-EL5Y4UJY-Cvkf14ib.js → ganttDiagram-EL5Y4UJY-Dncm7cLz.js} +1 -1
- package/web-dist/assets/{gitGraph-4MIJSDKK-XBlZCz1U.js → gitGraph-4MIJSDKK-CvKEiD2o.js} +1 -1
- package/web-dist/assets/{gitGraphDiagram-WWUBYQGX-vDyL82tj.js → gitGraphDiagram-WWUBYQGX-CFYEFiNn.js} +1 -1
- package/web-dist/assets/index-BRMjhxrd.js +242 -0
- package/web-dist/assets/index-C2agpmfX.css +2 -0
- package/web-dist/assets/{info-A6RAGUB7-DfR7iRgc.js → info-A6RAGUB7-CC2XUtgl.js} +1 -1
- package/web-dist/assets/{infoDiagram-27XIBGKW-BT4k6N6o.js → infoDiagram-27XIBGKW-C1uS_G88.js} +1 -1
- package/web-dist/assets/{ishikawaDiagram-5VMMS53U-BJIdMG0T.js → ishikawaDiagram-5VMMS53U-BZb69j5E.js} +1 -1
- package/web-dist/assets/{journeyDiagram-3NMN7TZE-CUGzIF61.js → journeyDiagram-3NMN7TZE-CMylE70d.js} +1 -1
- package/web-dist/assets/{kanban-definition-UXKFOSKX-DIPC4kv7.js → kanban-definition-UXKFOSKX-CHEOsGED.js} +1 -1
- package/web-dist/assets/{line-CJKCWj73.js → line-BsjU0-dp.js} +1 -1
- package/web-dist/assets/{mermaid-parser.core-BH-fcjsB.js → mermaid-parser.core-BKAVaI1u.js} +3 -3
- package/web-dist/assets/{mermaid.core-BSdNmJCs.js → mermaid.core-B9-DVS7z.js} +3 -3
- package/web-dist/assets/{mindmap-definition-YA3MSWOX-CJC3zMDF.js → mindmap-definition-YA3MSWOX-DZRcUVDr.js} +1 -1
- package/web-dist/assets/{packet-AYTQ26CC-BET157L_.js → packet-AYTQ26CC-BLeUhLlU.js} +1 -1
- package/web-dist/assets/{pegDiagram-XKGWAZYB-Du8ALEoR.js → pegDiagram-XKGWAZYB-Xyqkee6_.js} +1 -1
- package/web-dist/assets/{pie-WAS4IAKB-CDs5cIGi.js → pie-WAS4IAKB-D4o5BTS4.js} +1 -1
- package/web-dist/assets/{pieDiagram-E7YTZNPT-BX88bIIM.js → pieDiagram-E7YTZNPT-DCvmLOew.js} +1 -1
- package/web-dist/assets/{quadrantDiagram-AXDQQJYC-BkGxldmI.js → quadrantDiagram-AXDQQJYC-DOJ_yQix.js} +1 -1
- package/web-dist/assets/{radar-RG4KPBEZ-FMcFyhAF.js → radar-RG4KPBEZ-K-A12o39.js} +1 -1
- package/web-dist/assets/{railroad-74A4TZTK-Du0SbLQI.js → railroad-74A4TZTK-BMkfFovv.js} +1 -1
- package/web-dist/assets/railroad-abnf-HS5TGJTU-CY-xG4Um.js +1 -0
- package/web-dist/assets/railroad-ebnf-LZEXJU2U-DOHo_q0W.js +1 -0
- package/web-dist/assets/railroad-peg-WCYAUIDC-LeJLBEXF.js +1 -0
- package/web-dist/assets/{railroadDiagram-O6MQD6OU-CYqN0dL6.js → railroadDiagram-O6MQD6OU-DT4trHKC.js} +1 -1
- package/web-dist/assets/{requirementDiagram-BXWQKSXE-ClpQ_sLR.js → requirementDiagram-BXWQKSXE-CGM4uxvA.js} +1 -1
- package/web-dist/assets/{sankeyDiagram-P5KCCOFB-CEJUF8o9.js → sankeyDiagram-P5KCCOFB-DS3oAp2M.js} +1 -1
- package/web-dist/assets/{sequenceDiagram-WJ2MYXX4-BpJYUJhB.js → sequenceDiagram-WJ2MYXX4-UD3omQ5N.js} +1 -1
- package/web-dist/assets/{stateDiagram-D77RDMKH-BmKLEj9Q.js → stateDiagram-D77RDMKH-DONM7MNf.js} +1 -1
- package/web-dist/assets/stateDiagram-v2-MP3YSRHH-DzVzPXHZ.js +1 -0
- package/web-dist/assets/{swimlanes-42K2YHIH-CyJxVets.js → swimlanes-42K2YHIH-D33RTQxF.js} +1 -1
- package/web-dist/assets/swimlanesDiagram-VR7AAH4N-BXcjoK_e.js +8 -0
- package/web-dist/assets/threadSurfaces-ClAzSMCV.js +143 -0
- package/web-dist/assets/{timeline-definition-24CTP7MA-ChEqw_62.js → timeline-definition-24CTP7MA-DPFThVi8.js} +1 -1
- package/web-dist/assets/{treeView-Q6P3EWNA-l1PaAwLT.js → treeView-Q6P3EWNA-BV49dnms.js} +1 -1
- package/web-dist/assets/{treemap-WGGIJYW6-CxvHcEiT.js → treemap-WGGIJYW6-BVrEvhvK.js} +1 -1
- package/web-dist/assets/{vennDiagram-4TSXK5OY-DF-yXPNP.js → vennDiagram-4TSXK5OY-W5Uk1TBS.js} +1 -1
- package/web-dist/assets/{wardley-WFR3VGLG-BqkX6NQy.js → wardley-WFR3VGLG-CblJtHHu.js} +1 -1
- package/web-dist/assets/{wardleyDiagram-VM6X3IG4-B9LU1bxh.js → wardleyDiagram-VM6X3IG4-CGarvkjP.js} +1 -1
- package/web-dist/assets/{xychartDiagram-S5SC5T6Z-Zt_ZqCWS.js → xychartDiagram-S5SC5T6Z-CK45_7ZH.js} +1 -1
- package/web-dist/index.html +2 -2
- package/web-dist/assets/architecture-7GRP2DOG-jYpGgJVJ.js +0 -1
- package/web-dist/assets/channel-CC-n29cI.js +0 -1
- package/web-dist/assets/classDiagram-ZZMXUADV-CXJ9OBBD.js +0 -1
- package/web-dist/assets/classDiagram-v2-VYDZK3BY-CXJ9OBBD.js +0 -1
- package/web-dist/assets/eventmodeling-NTZA5JFV-Cw8GwV1a.js +0 -1
- package/web-dist/assets/flowDiagram-HODETNUW-B0Q6ZSg0.js +0 -1
- package/web-dist/assets/index-D-pcMA7P.js +0 -242
- package/web-dist/assets/index-DqckQXcp.css +0 -2
- package/web-dist/assets/railroad-abnf-HS5TGJTU-DRi4RhLb.js +0 -1
- package/web-dist/assets/railroad-ebnf-LZEXJU2U-BmBkdsnK.js +0 -1
- package/web-dist/assets/railroad-peg-WCYAUIDC-CydTrmQm.js +0 -1
- package/web-dist/assets/stateDiagram-v2-MP3YSRHH-D_c6vvvW.js +0 -1
- package/web-dist/assets/swimlanesDiagram-VR7AAH4N-BcVx8rdP.js +0 -8
- package/web-dist/assets/threadSurfaces-CYpFDk_e.js +0 -143
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BSdNmJCs.js","assets/index-D-pcMA7P.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/index-DqckQXcp.css","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-C4XfhTaE.js","assets/chunk-DU6HZSFF-UWY5hXXp.js","assets/chunk-75Z2AOVW-DF1G6d8q.js","assets/dist-DoH_9pyS.js","assets/chunk-CLGD4ZFX-CMAQm7EJ.js","assets/chunk-PWAF6VOD-CbZvnkji.js","assets/chunk-GMAD6QVW-BsJsQjY4.js","assets/chunk-P2QGCYS3-DoytbW1J.js","assets/chunk-4HAMMTFA-Df2uLm9r.js","assets/rough.esm-CSKSodPl.js","assets/chunk-GVQU2GXP-BuITwr9r.js","assets/chunk-OSK3NFVY-CZl3XlkY.js","assets/line-CJKCWj73.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-L3NEJ4N5-BISBblwX.js","assets/chunk-TLUHSLCS-iM7uiuAo.js","assets/chunk-2E4U76K2-QqOdoNOR.js","assets/graphlib-B8gBHxth.js","assets/chunk-LNGE3PJU-DNNNwF8Y.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,t}from"./rolldown-runtime-Bh1tDfsg.js";import{$ as n,$a as r,$i as i,$n as a,$o as o,$r as s,$s as c,$t as l,A as u,Aa as d,Ai as f,An as p,Ao as m,Ar as h,As as g,At as _,B as v,Ba as y,Bc as b,Bi as x,Bn as S,Bo as C,Br as w,Bs as T,Bt as E,C as D,Ca as O,Cc as k,Ci as A,Cn as j,Co as M,Cr as N,Cs as P,Ct as F,D as I,Da as L,Dc as R,Di as z,Dn as B,Do as ee,Dr as te,Ds as ne,Dt as re,E as ie,Ea as ae,Ec as oe,Ei as se,En as ce,Eo as le,Er as ue,Es as de,Et as fe,F as V,Fa as pe,Fc as H,Fi as me,Fn as he,Fo as ge,Fr as _e,Fs as ve,Ft as ye,G as be,Ga as xe,Gi as Se,Gn as Ce,Go as we,Gr as Te,Gs as Ee,Gt as De,H as Oe,Ha as ke,Hi as Ae,Hn as je,Ho as Me,Hr as Ne,Hs as Pe,Ht as Fe,I as Ie,Ia as Le,Ic as Re,Ii as ze,In as Be,Io as U,Ir as Ve,Is as He,It as Ue,J as We,Ja as Ge,Ji as Ke,Jn as qe,Jo as Je,Jr as Ye,Js as Xe,Jt as Ze,K as Qe,Ka as $e,Ki as et,Kn as tt,Ko as nt,Kr as rt,Ks as it,Kt as at,L as ot,La as st,Lc as ct,Li as lt,Ln as ut,Lo as dt,Lr as ft,Ls as pt,Lt as mt,M as ht,Ma as gt,Mc as _t,Mi as vt,Mn as yt,Mo as bt,Mr as xt,Ms as St,Mt as Ct,N as wt,Na as Tt,Nc as Et,Ni as Dt,Nn as Ot,No as kt,Nr as At,Ns as jt,Nt as Mt,O as Nt,Oa as Pt,Oc as Ft,Oi as It,On as Lt,Oo as Rt,Or as zt,Os as Bt,Ot as Vt,P as Ht,Pa as Ut,Pc as Wt,Pi as Gt,Pn as Kt,Po as qt,Pr as Jt,Ps as Yt,Pt as Xt,Q as Zt,Qa as Qt,Qi as $t,Qn as en,Qo as tn,Qr as nn,Qs as rn,Qt as an,R as on,Ra as sn,Rc as cn,Ri as ln,Rn as un,Ro as dn,Rr as fn,Rs as pn,Rt as mn,S as hn,Sa as gn,Sc as _n,Si as vn,Sn as yn,So as W,Sr as bn,Ss as xn,St as Sn,T as Cn,Ta as wn,Tc as Tn,Ti as En,Tn as Dn,To as On,Tr as kn,Ts as An,Tt as jn,U as Mn,Ua as Nn,Ui as Pn,Un as Fn,Uo as In,Ur as Ln,Us as Rn,Ut as zn,V as Bn,Va as Vn,Vc as Hn,Vi as Un,Vn as Wn,Vo as Gn,Vr as Kn,Vs as qn,Vt as Jn,W as Yn,Wa as Xn,Wi as Zn,Wn as Qn,Wo as $n,Wr as er,Ws as tr,Wt as nr,X as rr,Xa as ir,Xi as ar,Xn as or,Xo as sr,Xr as cr,Xs as lr,Xt as ur,Y as dr,Ya as fr,Yi as pr,Yn as mr,Yo as hr,Yr as gr,Ys as _r,Yt as vr,Z as yr,Za as br,Zi as xr,Zn as Sr,Zo as Cr,Zr as wr,Zs as Tr,Zt as Er,_ as Dr,_a as Or,_c as kr,_i as Ar,_n as jr,_o as Mr,_r as Nr,_s as Pr,_t as Fr,a as Ir,aa as Lr,ac as Rr,ai as zr,an as Br,ao as Vr,ar as Hr,as as Ur,at as Wr,b as Gr,ba as Kr,bc as qr,bi as Jr,bn as Yr,bo as G,br as Xr,bt as Zr,c as Qr,ca as $r,cc as ei,ci as ti,cn as ni,co as ri,cr as ii,cs as ai,ct as oi,d as si,da as ci,dc as li,di as ui,dn as di,do as fi,dr as pi,ds as mi,dt as hi,ea as gi,ec as _i,ei as vi,en as yi,eo as bi,er as xi,es as Si,et as Ci,f as wi,fa as Ti,fc as Ei,fi as Di,fn as Oi,fo as ki,fr as Ai,fs as ji,ft as Mi,g as Ni,ga as Pi,gc as Fi,gi as Ii,gn as Li,go as Ri,gr as zi,gs as Bi,gt as Vi,h as Hi,ha as Ui,hc as Wi,hi as Gi,hn as Ki,ho as qi,hr as Ji,hs as Yi,ht as Xi,i as Zi,ia as Qi,ic as $i,ii as ea,in as ta,io as na,ir as ra,is as ia,it as aa,j as oa,ja as sa,jc as ca,ji as la,jn as ua,jo as da,jr as fa,js as pa,jt as ma,k as ha,ka as ga,kc as _a,ki as va,kn as ya,ko as ba,kr as xa,ks as Sa,kt as Ca,l as wa,la as Ta,lc as Ea,li as Da,ln as Oa,lo as ka,lr as Aa,ls as ja,lt as Ma,m as Na,ma as Pa,mc as Fa,mi as Ia,mn as La,mo as Ra,mr as za,ms as Ba,mt as Va,n as Ha,na as Ua,nc as Wa,ni as Ga,nn as Ka,no as qa,nr as Ja,ns as Ya,nt as Xa,o as Za,oa as Qa,oc as $a,oi as eo,on as to,oo as no,or as ro,os as io,ot as ao,p as oo,pa as so,pc as co,pi as lo,pn as uo,po as fo,pr as po,ps as mo,pt as ho,q as go,qa as _o,qi as vo,qn as yo,qo as bo,qr as xo,qs as So,qt as Co,r as wo,ra as To,rc as Eo,ri as Do,rn as Oo,ro as ko,rr as Ao,rs as jo,rt as Mo,s as No,sa as Po,sc as Fo,si as Io,sn as Lo,so as Ro,sr as zo,ss as Bo,st as Vo,t as Ho,ta as Uo,tc as Wo,ti as Go,tn as Ko,to as K,tr as qo,ts as Jo,tt as Yo,u as Xo,ua as Zo,uc as Qo,ui as $o,un as es,uo as ts,ur as ns,us as rs,ut as is,v as as,va as os,vc as ss,vi as cs,vn as ls,vo as us,vr as ds,vt as fs,w as ps,wa as ms,wc as hs,wi as gs,wn as _s,wo as vs,wr as ys,ws as bs,wt as xs,x as Ss,xa as Cs,xc as ws,xi as Ts,xn as Es,xo as Ds,xr as Os,xs as ks,xt as As,y as js,ya as Ms,yc as Ns,yi as Ps,yn as Fs,yo as Is,yr as Ls,ys as Rs,yt as zs,z as Bs,za as Vs,zc as Hs,zi as Us,zn as Ws,zo as Gs,zr as Ks,zs as qs,zt as Js}from"./index-D-pcMA7P.js";var Ys=K(`alarm-clock-off`,[[`path`,{d:`M6.87 6.87a8 8 0 1 0 11.26 11.26`,key:`3on8tj`}],[`path`,{d:`M19.9 14.25a8 8 0 0 0-9.15-9.15`,key:`15ghsc`}],[`path`,{d:`m22 6-3-3`,key:`1opdir`}],[`path`,{d:`M6.26 18.67 4 21`,key:`yzmioq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M4 4 2 6`,key:`1ycko6`}]]),Xs=K(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),Zs=K(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Qs=K(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),$s=K(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),ec=K(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),tc=K(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),nc=K(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),rc=K(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),ic=K(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),ac=K(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),oc=K(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),sc=K(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),cc=K(`file-diff`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),lc=K(`folder`,[[`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`}]]),uc=K(`git-branch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),dc=K(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),fc=K(`keyboard`,[[`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`}]]),pc=K(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),mc=K(`list-checks`,[[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),hc=K(`list-todo`,[[`rect`,{x:`3`,y:`5`,width:`6`,height:`6`,rx:`1`,key:`1defrl`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),gc=K(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),_c=K(`message-circle-off`,[[`path`,{d:`M20.5 14.9A9 9 0 0 0 9.1 3.5`,key:`1iebmn`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5.6 5.6C3 8.3 2.2 12.5 4 16l-2 6 6-2c3.4 1.8 7.6 1.1 10.3-1.7`,key:`1ov8ce`}]]),vc=K(`message-square-code`,[[`path`,{d:`M10 7.5 8 10l2 2.5`,key:`xb17xw`}],[`path`,{d:`m14 7.5 2 2.5-2 2.5`,key:`5rap1v`}],[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}]]),yc=K(`messages-square`,[[`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`,key:`p1xzt8`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`,key:`1cx29u`}]]),bc=K(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),xc=K(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),Sc=K(`package-check`,[[`path`,{d:`m16 16 2 2 4-4`,key:`gfu2re`}],[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}]]),Cc=K(`play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),wc=K(`repeat`,[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]),Tc=K(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),Ec=K(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Dc=K(`signpost`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M12 3v3`,key:`1n5kay`}],[`path`,{d:`M18 6a2 2 0 0 1 1.387.56l2.307 2.22a1 1 0 0 1 0 1.44l-2.307 2.22A2 2 0 0 1 18 13H6a2 2 0 0 1-1.387-.56l-2.306-2.22a1 1 0 0 1 0-1.44l2.306-2.22A2 2 0 0 1 6 6z`,key:`gqqp9m`}]]),Oc=K(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),kc=K(`square-dot`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),Ac=K(`square-terminal`,[[`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`}]]),jc=K(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Mc=K(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),Nc=K(`zoom-in`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),Pc=K(`zoom-out`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),q=e(Hn(),1),Fc=e(b(),1);function Ic(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Lc=Ic();function Rc(e){Lc=e}var zc={exec:()=>null};function J(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Bc.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Bc={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`)},Vc=/^(?:[ \t]*(?:\n|$))+/,Hc=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Uc=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Wc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Gc=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Kc=/(?:[*+-]|\d{1,9}[.)])/,qc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Jc=J(qc).replace(/bull/g,Kc).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Yc=J(qc).replace(/bull/g,Kc).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Xc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Zc=/^[^\n]+/,Qc=/(?!\s*\])(?:\\.|[^\[\]\\])+/,$c=J(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Qc).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),el=J(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Kc).getRegex(),tl=`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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,nl=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,rl=J(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,nl).replace(`tag`,tl).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),il=J(Xc).replace(`hr`,Wc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,tl).getRegex(),al={blockquote:J(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,il).getRegex(),code:Hc,def:$c,fences:Uc,heading:Gc,hr:Wc,html:rl,lheading:Jc,list:el,newline:Vc,paragraph:il,table:zc,text:Zc},ol=J(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Wc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,tl).getRegex(),sl={...al,lheading:Yc,table:ol,paragraph:J(Xc).replace(`hr`,Wc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,ol).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,tl).getRegex()},cl={...al,html:J(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,nl).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:zc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:J(Xc).replace(`hr`,Wc).replace(`heading`,` *#{1,6} *[^
|
|
3
|
-
]`).replace(`lheading`,Jc).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},ll=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ul=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,dl=/^( {2,}|\\)\n(?!\s*$)/,fl=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,pl=/[\p{P}\p{S}]/u,ml=/[\s\p{P}\p{S}]/u,hl=/[^\s\p{P}\p{S}]/u,gl=J(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,ml).getRegex(),_l=/(?!~)[\p{P}\p{S}]/u,vl=/(?!~)[\s\p{P}\p{S}]/u,yl=/(?:[^\s\p{P}\p{S}]|~)/u,bl=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,xl=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Sl=J(xl,`u`).replace(/punct/g,pl).getRegex(),Cl=J(xl,`u`).replace(/punct/g,_l).getRegex(),wl=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Tl=J(wl,`gu`).replace(/notPunctSpace/g,hl).replace(/punctSpace/g,ml).replace(/punct/g,pl).getRegex(),El=J(wl,`gu`).replace(/notPunctSpace/g,yl).replace(/punctSpace/g,vl).replace(/punct/g,_l).getRegex(),Dl=J(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,hl).replace(/punctSpace/g,ml).replace(/punct/g,pl).getRegex(),Ol=J(/\\(punct)/,`gu`).replace(/punct/g,pl).getRegex(),kl=J(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Al=J(nl).replace(`(?:-->|$)`,`-->`).getRegex(),jl=J(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Al).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ml=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Nl=J(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,Ml).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Pl=J(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Ml).replace(`ref`,Qc).getRegex(),Fl=J(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Qc).getRegex(),Il={_backpedal:zc,anyPunctuation:Ol,autolink:kl,blockSkip:bl,br:dl,code:ul,del:zc,emStrongLDelim:Sl,emStrongRDelimAst:Tl,emStrongRDelimUnd:Dl,escape:ll,link:Nl,nolink:Fl,punctuation:gl,reflink:Pl,reflinkSearch:J(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Pl).replace(`nolink`,Fl).getRegex(),tag:jl,text:fl,url:zc},Ll={...Il,link:J(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Ml).getRegex(),reflink:J(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Ml).getRegex()},Rl={...Il,emStrongRDelimAst:El,emStrongLDelim:Cl,url:J(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,`i`).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},zl={...Rl,br:J(dl).replace(`{2,}`,`*`).getRegex(),text:J(Rl.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Bl={normal:al,gfm:sl,pedantic:cl},Vl={normal:Il,gfm:Rl,breaks:zl,pedantic:Ll},Hl={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Ul=e=>Hl[e];function Wl(e,t){if(t){if(Bc.escapeTest.test(e))return e.replace(Bc.escapeReplace,Ul)}else if(Bc.escapeTestNoEncode.test(e))return e.replace(Bc.escapeReplaceNoEncode,Ul);return e}function Gl(e){try{e=encodeURI(e).replace(Bc.percentDecode,`%`)}catch{return null}return e}function Kl(e,t){let n=e.replace(Bc.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Bc.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(Bc.slashPipe,`|`);return n}function ql(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Jl(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Yl(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function Xl(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
4
|
-
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
5
|
-
`)}var Zl=class{options;rules;lexer;constructor(e){this.options=e||Lc}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:ql(e,`
|
|
6
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Xl(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=ql(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:ql(t[0],`
|
|
7
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=ql(t[0],`
|
|
8
|
-
`).split(`
|
|
9
|
-
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
10
|
-
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
11
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
12
|
-
${s}`:s,r=r?`${r}
|
|
13
|
-
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
|
|
14
|
-
`+e.join(`
|
|
15
|
-
`),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
|
|
16
|
-
`+e.join(`
|
|
17
|
-
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
18
|
-
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=t[2].split(`
|
|
19
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,e=>` `.repeat(3*e.length)),l=e.split(`
|
|
20
|
-
`,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=t[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
|
|
21
|
-
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d);for(;e;){let f=e.split(`
|
|
22
|
-
`,1)[0],p;if(l=f,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),p=l):p=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||t.test(l)||n.test(l))break;if(p.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
23
|
-
`+p.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
|
|
24
|
-
`+l}!u&&!l.trim()&&(u=!0),r+=f+`
|
|
25
|
-
`,e=e.substring(f.length+1),c=p.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0));let f=null,p;this.options.gfm&&(f=this.rules.other.listIsTask.exec(s),f&&(p=f[0]!==`[ ] `,s=s.replace(this.rules.other.listReplaceTask,``))),i.items.push({type:`list_item`,raw:r,task:!!f,checked:p,loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){let t=i.items[e].tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Kl(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
26
|
-
`):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Kl(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
27
|
-
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=ql(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Jl(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Yl(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Yl(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(r&&!(r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},Ql=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Lc,this.options.tokenizer=this.options.tokenizer||new Zl,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Bc,block:Bl.normal,inline:Vl.normal};this.options.pedantic?(t.block=Bl.pedantic,t.inline=Vl.pedantic):this.options.gfm&&(t.block=Bl.gfm,this.options.breaks?t.inline=Vl.breaks:t.inline=Vl.gfm),this.tokenizer.rules=t}static get rules(){return{block:Bl,inline:Vl}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(Bc.carriageReturn,`
|
|
28
|
-
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(Bc.tabCharGlobal,` `).replace(Bc.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
|
|
29
|
-
`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=`
|
|
30
|
-
`+r.raw,n.text+=`
|
|
31
|
-
`+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=`
|
|
32
|
-
`+r.raw,n.text+=`
|
|
33
|
-
`+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=t.at(-1);n&&a?.type===`paragraph`?(a.raw+=`
|
|
34
|
-
`+r.raw,a.text+=`
|
|
35
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=`
|
|
36
|
-
`+r.raw,n.text+=`
|
|
37
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let i=!1,a=``;for(;e;){i||(a=``),i=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,a)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let o=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(o=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(o)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(a=r.raw.slice(-1)),i=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},$l=class{options;parser;constructor(e){this.options=e||Lc}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(Bc.notSpaceStart)?.[0],i=e.replace(Bc.endingNewline,``)+`
|
|
38
|
-
`;return r?`<pre><code class="language-`+Wl(r)+`">`+(n?i:Wl(i,!0))+`</code></pre>
|
|
39
|
-
`:`<pre><code>`+(n?i:Wl(i,!0))+`</code></pre>
|
|
40
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
41
|
-
${this.parser.parse(e)}</blockquote>
|
|
42
|
-
`}html({text:e}){return e}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
43
|
-
`}hr(e){return`<hr>
|
|
44
|
-
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
|
|
45
|
-
`+r+`</`+i+`>
|
|
46
|
-
`}listitem(e){let t=``;if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type===`paragraph`?(e.tokens[0].text=n+` `+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type===`text`&&(e.tokens[0].tokens[0].text=n+` `+Wl(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:`text`,raw:n+` `,text:n+` `,escaped:!0}):t+=n+` `}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
|
|
47
|
-
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox">`}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
48
|
-
`}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
|
|
49
|
-
<thead>
|
|
50
|
-
`+t+`</thead>
|
|
51
|
-
`+r+`</table>
|
|
52
|
-
`}tablerow({text:e}){return`<tr>
|
|
53
|
-
${e}</tr>
|
|
54
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
55
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Wl(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Gl(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+Wl(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Gl(e);if(i===null)return Wl(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${Wl(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Wl(e.text)}},eu=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}},tu=class e{options;renderer;textRenderer;constructor(e){this.options=e||Lc,this.options.renderer=this.options.renderer||new $l,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new eu}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(t!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`paragraph`,`text`].includes(e.type)){n+=t||``;continue}}let a=i;switch(a.type){case`space`:n+=this.renderer.space(a);continue;case`hr`:n+=this.renderer.hr(a);continue;case`heading`:n+=this.renderer.heading(a);continue;case`code`:n+=this.renderer.code(a);continue;case`table`:n+=this.renderer.table(a);continue;case`blockquote`:n+=this.renderer.blockquote(a);continue;case`list`:n+=this.renderer.list(a);continue;case`html`:n+=this.renderer.html(a);continue;case`paragraph`:n+=this.renderer.paragraph(a);continue;case`text`:{let i=a,o=this.renderer.text(i);for(;r+1<e.length&&e[r+1].type===`text`;)i=e[++r],o+=`
|
|
56
|
-
`+this.renderer.text(i);t?n+=this.renderer.paragraph({type:`paragraph`,raw:o,text:o,tokens:[{type:`text`,raw:o,text:o,escaped:!0}]}):n+=o;continue}default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t=this.renderer){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},nu=class{options;block;constructor(e){this.options=e||Lc}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?Ql.lex:Ql.lexInline}provideParser(){return this.block?tu.parse:tu.parseInline}},ru=class{defaults=Ic();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=tu;Renderer=$l;TextRenderer=eu;Lexer=Ql;Tokenizer=Zl;Hooks=nu;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new $l(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Zl(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new nu;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];nu.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async)return Promise.resolve(i.call(t,e)).then(e=>a.call(t,e));let n=i.call(t,e);return a.call(t,n)}:t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ql.lex(e,t??this.defaults)}parser(e,t){return tu.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(t==null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));i.hooks&&(i.hooks.options=i,i.hooks.block=e);let o=i.hooks?i.hooks.provideLexer():e?Ql.lex:Ql.lexInline,s=i.hooks?i.hooks.provideParser():e?tu.parse:tu.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then(e=>o(e,i)).then(e=>i.hooks?i.hooks.processAllTokens(e):e).then(e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then(()=>e):e).then(e=>s(e,i)).then(e=>i.hooks?i.hooks.postprocess(e):e).catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let e=o(t,i);i.hooks&&(e=i.hooks.processAllTokens(e)),i.walkTokens&&this.walkTokens(e,i.walkTokens);let n=s(e,i);return i.hooks&&(n=i.hooks.postprocess(n)),n}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
57
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Wl(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},iu=new ru;function Y(e,t){return iu.parse(e,t)}Y.options=Y.setOptions=function(e){return iu.setOptions(e),Y.defaults=iu.defaults,Rc(Y.defaults),Y},Y.getDefaults=Ic,Y.defaults=Lc,Y.use=function(...e){return iu.use(...e),Y.defaults=iu.defaults,Rc(Y.defaults),Y},Y.walkTokens=function(e,t){return iu.walkTokens(e,t)},Y.parseInline=iu.parseInline,Y.Parser=tu,Y.parser=tu.parse,Y.Renderer=$l,Y.TextRenderer=eu,Y.Lexer=Ql,Y.lexer=Ql.lex,Y.Tokenizer=Zl,Y.Hooks=nu,Y.parse=Y,Y.options,Y.setOptions,Y.use,Y.walkTokens,Y.parseInline,tu.parse,Ql.lex;var au=e(t(((e,t)=>{function n(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw Error(`map is read-only`)}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw Error(`set is read-only`)}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{let r=e[t],i=typeof r;(i===`object`||i===`function`)&&!Object.isFrozen(r)&&n(r)}),e}var r=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function i(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function a(e,...t){let n=Object.create(null);for(let t in e)n[t]=e[t];return t.forEach(function(e){for(let t in e)n[t]=e[t]}),n}var o=`</span>`,s=e=>!!e.scope,c=(e,{prefix:t})=>{if(e.startsWith(`language:`))return e.replace(`language:`,`language-`);if(e.includes(`.`)){let n=e.split(`.`);return[`${t}${n.shift()}`,...n.map((e,t)=>`${e}${`_`.repeat(t+1)}`)].join(` `)}return`${t}${e}`},l=class{constructor(e,t){this.buffer=``,this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!s(e))return;let t=c(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){s(e)&&(this.buffer+=o)}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}},u=(e={})=>{let t={children:[]};return Object.assign(t,e),t},d=class e{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let t=u({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return typeof t==`string`?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(t=>this._walk(e,t)),e.closeNode(t)),e}static _collapse(t){typeof t!=`string`&&t.children&&(t.children.every(e=>typeof e==`string`)?t.children=[t.children.join(``)]:t.children.forEach(t=>{e._collapse(t)}))}},f=class extends d{constructor(e){super(),this.options=e}addText(e){e!==``&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){let n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function p(e){return e?typeof e==`string`?e:e.source:null}function m(e){return _(`(?=`,e,`)`)}function h(e){return _(`(?:`,e,`)*`)}function g(e){return _(`(?:`,e,`)?`)}function _(...e){return e.map(e=>p(e)).join(``)}function v(e){let t=e[e.length-1];return typeof t==`object`&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function y(...e){return`(`+(v(e).capture?``:`?:`)+e.map(e=>p(e)).join(`|`)+`)`}function b(e){return RegExp(e.toString()+`|`).exec(``).length-1}function x(e,t){let n=e&&e.exec(t);return n&&n.index===0}var S=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function C(e,{joinWith:t}){let n=0;return e.map(e=>{n+=1;let t=n,r=p(e),i=``;for(;r.length>0;){let e=S.exec(r);if(!e){i+=r;break}i+=r.substring(0,e.index),r=r.substring(e.index+e[0].length),e[0][0]===`\\`&&e[1]?i+=`\\`+String(Number(e[1])+t):(i+=e[0],e[0]===`(`&&n++)}return i}).map(e=>`(${e})`).join(t)}var w=/\b\B/,T=`[a-zA-Z]\\w*`,E=`[a-zA-Z_]\\w*`,D=`\\b\\d+(\\.\\d+)?`,O=`(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)`,k=`\\b(0b[01]+)`,A=`!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~`,j=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=_(t,/.*\b/,e.binary,/\b.*/)),a({scope:`meta`,begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{e.index!==0&&t.ignoreMatch()}},e)},M={begin:`\\\\[\\s\\S]`,relevance:0},N={scope:`string`,begin:`'`,end:`'`,illegal:`\\n`,contains:[M]},P={scope:`string`,begin:`"`,end:`"`,illegal:`\\n`,contains:[M]},F={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},I=function(e,t,n={}){let r=a({scope:`comment`,begin:e,end:t,contains:[]},n);r.contains.push({scope:`doctag`,begin:`[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)`,end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let i=y(`I`,`a`,`is`,`so`,`us`,`to`,`at`,`if`,`in`,`it`,`on`,/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:_(/[ ]+/,`(`,i,/[.]?[:]?([.][ ]|[ ])/,`){3}`)}),r},L=I(`//`,`$`),R=I(`/\\*`,`\\*/`),z=I(`#`,`$`),B=Object.freeze({__proto__:null,APOS_STRING_MODE:N,BACKSLASH_ESCAPE:M,BINARY_NUMBER_MODE:{scope:`number`,begin:k,relevance:0},BINARY_NUMBER_RE:k,COMMENT:I,C_BLOCK_COMMENT_MODE:R,C_LINE_COMMENT_MODE:L,C_NUMBER_MODE:{scope:`number`,begin:O,relevance:0},C_NUMBER_RE:O,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:z,IDENT_RE:T,MATCH_NOTHING_RE:w,METHOD_GUARD:{begin:`\\.\\s*[a-zA-Z_]\\w*`,relevance:0},NUMBER_MODE:{scope:`number`,begin:D,relevance:0},NUMBER_RE:D,PHRASAL_WORDS_MODE:F,QUOTE_STRING_MODE:P,REGEXP_MODE:{scope:`regexp`,begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[M,{begin:/\[/,end:/\]/,relevance:0,contains:[M]}]},RE_STARTERS_RE:A,SHEBANG:j,TITLE_MODE:{scope:`title`,begin:T,relevance:0},UNDERSCORE_IDENT_RE:E,UNDERSCORE_TITLE_MODE:{scope:`title`,begin:E,relevance:0}});function ee(e,t){e.input[e.index-1]===`.`&&t.ignoreMatch()}function te(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function ne(e,t){t&&e.beginKeywords&&(e.begin=`\\b(`+e.beginKeywords.split(` `).join(`|`)+`)(?!\\.)(?=\\b|\\s)`,e.__beforeBegin=ee,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function re(e,t){Array.isArray(e.illegal)&&(e.illegal=y(...e.illegal))}function ie(e,t){if(e.match){if(e.begin||e.end)throw Error(`begin & end are not supported with match`);e.begin=e.match,delete e.match}}function ae(e,t){e.relevance===void 0&&(e.relevance=1)}var oe=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error(`beforeMatch cannot be used with starts`);let n=Object.assign({},e);Object.keys(e).forEach(t=>{delete e[t]}),e.keywords=n.keywords,e.begin=_(n.beforeMatch,m(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},se=[`of`,`and`,`for`,`in`,`not`,`or`,`if`,`then`,`parent`,`list`,`value`],ce=`keyword`;function le(e,t,n=ce){let r=Object.create(null);return typeof e==`string`?i(n,e.split(` `)):Array.isArray(e)?i(n,e):Object.keys(e).forEach(function(n){Object.assign(r,le(e[n],t,n))}),r;function i(e,n){t&&(n=n.map(e=>e.toLowerCase())),n.forEach(function(t){let n=t.split(`|`);r[n[0]]=[e,ue(n[0],n[1])]})}}function ue(e,t){return t?Number(t):+!de(e)}function de(e){return se.includes(e.toLowerCase())}var fe={},V=e=>{console.error(e)},pe=(e,...t)=>{console.log(`WARN: ${e}`,...t)},H=(e,t)=>{fe[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),fe[`${e}/${t}`]=!0)},me=Error();function he(e,t,{key:n}){let r=0,i=e[n],a={},o={};for(let e=1;e<=t.length;e++)o[e+r]=i[e],a[e+r]=!0,r+=b(t[e-1]);e[n]=o,e[n]._emit=a,e[n]._multi=!0}function ge(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw V(`skip, excludeBegin, returnBegin not compatible with beginScope: {}`),me;if(typeof e.beginScope!=`object`||e.beginScope===null)throw V(`beginScope must be object`),me;he(e,e.begin,{key:`beginScope`}),e.begin=C(e.begin,{joinWith:``})}}function _e(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw V(`skip, excludeEnd, returnEnd not compatible with endScope: {}`),me;if(typeof e.endScope!=`object`||e.endScope===null)throw V(`endScope must be object`),me;he(e,e.end,{key:`endScope`}),e.end=C(e.end,{joinWith:``})}}function ve(e){e.scope&&typeof e.scope==`object`&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function ye(e){ve(e),typeof e.beginScope==`string`&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope==`string`&&(e.endScope={_wrap:e.endScope}),ge(e),_e(e)}function be(e){function t(t,n){return new RegExp(p(t),`m`+(e.case_insensitive?`i`:``)+(e.unicodeRegex?`u`:``)+(n?`g`:``))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=b(e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let e=this.regexes.map(e=>e[1]);this.matcherRe=t(C(e,{joinWith:`|`}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;let t=this.matcherRe.exec(e);if(!t)return null;let n=t.findIndex((e,t)=>t>0&&e!==void 0),r=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,r)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];let t=new n;return this.rules.slice(e).forEach(([e,n])=>t.addRule(e,n)),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),t.type===`begin`&&this.count++}exec(e){let t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition()&&!(n&&n.index===this.lastIndex)){let t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}function i(e){let t=new r;return e.contains.forEach(e=>t.addRule(e.begin,{rule:e,type:`begin`})),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:`end`}),e.illegal&&t.addRule(e.illegal,{type:`illegal`}),t}function o(n,r){let a=n;if(n.isCompiled)return a;[te,ie,ye,oe].forEach(e=>e(n,r)),e.compilerExtensions.forEach(e=>e(n,r)),n.__beforeBegin=null,[ne,re,ae].forEach(e=>e(n,r)),n.isCompiled=!0;let s=null;return typeof n.keywords==`object`&&n.keywords.$pattern&&(n.keywords=Object.assign({},n.keywords),s=n.keywords.$pattern,delete n.keywords.$pattern),s||=/\w+/,n.keywords&&=le(n.keywords,e.case_insensitive),a.keywordPatternRe=t(s,!0),r&&(n.begin||=/\B|\b/,a.beginRe=t(a.begin),!n.end&&!n.endsWithParent&&(n.end=/\B|\b/),n.end&&(a.endRe=t(a.end)),a.terminatorEnd=p(a.end)||``,n.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(n.end?`|`:``)+r.terminatorEnd)),n.illegal&&(a.illegalRe=t(n.illegal)),n.contains||=[],n.contains=[].concat(...n.contains.map(function(e){return Se(e===`self`?n:e)})),n.contains.forEach(function(e){o(e,a)}),n.starts&&o(n.starts,r),a.matcher=i(a),a}if(e.compilerExtensions||=[],e.contains&&e.contains.includes(`self`))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=a(e.classNameAliases||{}),o(e)}function xe(e){return e?e.endsWithParent||xe(e.starts):!1}function Se(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return a(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:xe(e)?a(e,{starts:e.starts?a(e.starts):null}):Object.isFrozen(e)?a(e):e}var Ce=`11.11.1`,we=class extends Error{constructor(e,t){super(e),this.name=`HTMLInjectionError`,this.html=t}},Te=i,Ee=a,De=Symbol(`nomatch`),Oe=7,ke=function(e){let t=Object.create(null),i=Object.create(null),a=[],o=!0,s=`Could not find the language '{}', did you forget to load/include a language module?`,c={disableAutodetect:!0,name:`Plain text`,contains:[]},l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:`hljs-`,cssSelector:`pre code`,languages:null,__emitter:f};function u(e){return l.noHighlightRe.test(e)}function d(e){let t=e.className+` `;t+=e.parentNode?e.parentNode.className:``;let n=l.languageDetectRe.exec(t);if(n){let t=N(n[1]);return t||(pe(s.replace(`{}`,n[1])),pe(`Falling back to no-highlight mode for this block.`,e)),t?n[1]:`no-highlight`}return t.split(/\s+/).find(e=>u(e)||N(e))}function p(e,t,n){let r=``,i=``;typeof t==`object`?(r=e,n=t.ignoreIllegals,i=t.language):(H(`10.7.0`,`highlight(lang, code, ...args) has been deprecated.`),H(`10.7.0`,`Please use highlight(code, options) instead.
|
|
58
|
-
https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(n=!0);let a={code:r,language:i};z(`before:highlight`,a);let o=a.result?a.result:v(a.language,a.code,n);return o.code=a.code,z(`after:highlight`,o),o}function v(e,n,i,a){let c=Object.create(null);function u(e,t){return e.keywords[t]}function d(){if(!A.keywords){M.addText(P);return}let e=0;A.keywordPatternRe.lastIndex=0;let t=A.keywordPatternRe.exec(P),n=``;for(;t;){n+=P.substring(e,t.index);let r=D.case_insensitive?t[0].toLowerCase():t[0],i=u(A,r);if(i){let[e,a]=i;if(M.addText(n),n=``,c[r]=(c[r]||0)+1,c[r]<=Oe&&(F+=a),e.startsWith(`_`))n+=t[0];else{let n=D.classNameAliases[e]||e;m(t[0],n)}}else n+=t[0];e=A.keywordPatternRe.lastIndex,t=A.keywordPatternRe.exec(P)}n+=P.substring(e),M.addText(n)}function f(){if(P===``)return;let e=null;if(typeof A.subLanguage==`string`){if(!t[A.subLanguage]){M.addText(P);return}e=v(A.subLanguage,P,!0,j[A.subLanguage]),j[A.subLanguage]=e._top}else e=S(P,A.subLanguage.length?A.subLanguage:null);A.relevance>0&&(F+=e.relevance),M.__addSublanguage(e._emitter,e.language)}function p(){A.subLanguage==null?d():f(),P=``}function m(e,t){e!==``&&(M.startScope(t),M.addText(e),M.endScope())}function h(e,t){let n=1,r=t.length-1;for(;n<=r;){if(!e._emit[n]){n++;continue}let r=D.classNameAliases[e[n]]||e[n],i=t[n];r?m(i,r):(P=i,d(),P=``),n++}}function g(e,t){return e.scope&&typeof e.scope==`string`&&M.openNode(D.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(m(P,D.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),P=``):e.beginScope._multi&&(h(e.beginScope,t),P=``)),A=Object.create(e,{parent:{value:A}}),A}function _(e,t,n){let i=x(e.endRe,n);if(i){if(e[`on:end`]){let n=new r(e);e[`on:end`](t,n),n.isMatchIgnored&&(i=!1)}if(i){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return _(e.parent,t,n)}function y(e){return A.matcher.regexIndex===0?(P+=e[0],1):(R=!0,0)}function b(e){let t=e[0],n=e.rule,i=new r(n),a=[n.__beforeBegin,n[`on:begin`]];for(let n of a)if(n&&(n(e,i),i.isMatchIgnored))return y(t);return n.skip?P+=t:(n.excludeBegin&&(P+=t),p(),!n.returnBegin&&!n.excludeBegin&&(P=t)),g(n,e),n.returnBegin?0:t.length}function C(e){let t=e[0],r=n.substring(e.index),i=_(A,e,r);if(!i)return De;let a=A;A.endScope&&A.endScope._wrap?(p(),m(t,A.endScope._wrap)):A.endScope&&A.endScope._multi?(p(),h(A.endScope,e)):a.skip?P+=t:(a.returnEnd||a.excludeEnd||(P+=t),p(),a.excludeEnd&&(P=t));do A.scope&&M.closeNode(),!A.skip&&!A.subLanguage&&(F+=A.relevance),A=A.parent;while(A!==i.parent);return i.starts&&g(i.starts,e),a.returnEnd?0:t.length}function w(){let e=[];for(let t=A;t!==D;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach(e=>M.openNode(e))}let T={};function E(t,r){let a=r&&r[0];if(P+=t,a==null)return p(),0;if(T.type===`begin`&&r.type===`end`&&T.index===r.index&&a===``){if(P+=n.slice(r.index,r.index+1),!o){let t=Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=T.rule,t}return 1}if(T=r,r.type===`begin`)return b(r);if(r.type===`illegal`&&!i){let e=Error(`Illegal lexeme "`+a+`" for mode "`+(A.scope||`<unnamed>`)+`"`);throw e.mode=A,e}else if(r.type===`end`){let e=C(r);if(e!==De)return e}if(r.type===`illegal`&&a===``)return P+=`
|
|
59
|
-
`,1;if(L>1e5&&L>r.index*3)throw Error(`potential infinite loop, way more iterations than matches`);return P+=a,a.length}let D=N(e);if(!D)throw V(s.replace(`{}`,e)),Error(`Unknown language: "`+e+`"`);let O=be(D),k=``,A=a||O,j={},M=new l.__emitter(l);w();let P=``,F=0,I=0,L=0,R=!1;try{if(D.__emitTokens)D.__emitTokens(n,M);else{for(A.matcher.considerAll();;){L++,R?R=!1:A.matcher.considerAll(),A.matcher.lastIndex=I;let e=A.matcher.exec(n);if(!e)break;let t=E(n.substring(I,e.index),e);I=e.index+t}E(n.substring(I))}return M.finalize(),k=M.toHTML(),{language:e,value:k,relevance:F,illegal:!1,_emitter:M,_top:A}}catch(t){if(t.message&&t.message.includes(`Illegal`))return{language:e,value:Te(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:I,context:n.slice(I-100,I+100),mode:t.mode,resultSoFar:k},_emitter:M};if(o)return{language:e,value:Te(n),illegal:!1,relevance:0,errorRaised:t,_emitter:M,_top:A};throw t}}function b(e){let t={value:Te(e),illegal:!1,relevance:0,_top:c,_emitter:new l.__emitter(l)};return t._emitter.addText(e),t}function S(e,n){n=n||l.languages||Object.keys(t);let r=b(e),i=n.filter(N).filter(F).map(t=>v(t,e,!1));i.unshift(r);let[a,o]=i.sort((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(N(e.language).supersetOf===t.language)return 1;if(N(t.language).supersetOf===e.language)return-1}return 0}),s=a;return s.secondBest=o,s}function C(e,t,n){let r=t&&i[t]||n;e.classList.add(`hljs`),e.classList.add(`language-${r}`)}function w(e){let t=null,n=d(e);if(u(n))return;if(z(`before:highlightElement`,{el:e,language:n}),e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);return}if(e.children.length>0&&(l.ignoreUnescapedHTML||(console.warn(`One of your code blocks includes unescaped HTML. This is a potentially serious security risk.`),console.warn(`https://github.com/highlightjs/highlight.js/wiki/security`),console.warn(`The element with unescaped HTML:`),console.warn(e)),l.throwUnescapedHTML))throw new we(`One of your code blocks includes unescaped HTML.`,e.innerHTML);t=e;let r=t.textContent,i=n?p(r,{language:n,ignoreIllegals:!0}):S(r);e.innerHTML=i.value,e.dataset.highlighted=`yes`,C(e,n,i.language),e.result={language:i.language,re:i.relevance,relevance:i.relevance},i.secondBest&&(e.secondBest={language:i.secondBest.language,relevance:i.secondBest.relevance}),z(`after:highlightElement`,{el:e,result:i,text:r})}function T(e){l=Ee(l,e)}let E=()=>{k(),H(`10.6.0`,`initHighlighting() deprecated. Use highlightAll() now.`)};function D(){k(),H(`10.6.0`,`initHighlightingOnLoad() deprecated. Use highlightAll() now.`)}let O=!1;function k(){function e(){k()}if(document.readyState===`loading`){O||window.addEventListener(`DOMContentLoaded`,e,!1),O=!0;return}document.querySelectorAll(l.cssSelector).forEach(w)}function A(n,r){let i=null;try{i=r(e)}catch(e){if(V(`Language definition for '{}' could not be registered.`.replace(`{}`,n)),o)V(e);else throw e;i=c}i.name||=n,t[n]=i,i.rawDefinition=r.bind(null,e),i.aliases&&P(i.aliases,{languageName:n})}function j(e){delete t[e];for(let t of Object.keys(i))i[t]===e&&delete i[t]}function M(){return Object.keys(t)}function N(e){return e=(e||``).toLowerCase(),t[e]||t[i[e]]}function P(e,{languageName:t}){typeof e==`string`&&(e=[e]),e.forEach(e=>{i[e.toLowerCase()]=t})}function F(e){let t=N(e);return t&&!t.disableAutodetect}function I(e){e[`before:highlightBlock`]&&!e[`before:highlightElement`]&&(e[`before:highlightElement`]=t=>{e[`before:highlightBlock`](Object.assign({block:t.el},t))}),e[`after:highlightBlock`]&&!e[`after:highlightElement`]&&(e[`after:highlightElement`]=t=>{e[`after:highlightBlock`](Object.assign({block:t.el},t))})}function L(e){I(e),a.push(e)}function R(e){let t=a.indexOf(e);t!==-1&&a.splice(t,1)}function z(e,t){let n=e;a.forEach(function(e){e[n]&&e[n](t)})}function ee(e){return H(`10.7.0`,`highlightBlock will be removed entirely in v12.0`),H(`10.7.0`,`Please use highlightElement now.`),w(e)}Object.assign(e,{highlight:p,highlightAuto:S,highlightAll:k,highlightElement:w,highlightBlock:ee,configure:T,initHighlighting:E,initHighlightingOnLoad:D,registerLanguage:A,unregisterLanguage:j,listLanguages:M,getLanguage:N,registerAliases:P,autoDetection:F,inherit:Ee,addPlugin:L,removePlugin:R}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=Ce,e.regex={concat:_,lookahead:m,either:y,optional:g,anyNumberOfTimes:h};for(let e in B)typeof B[e]==`object`&&n(B[e]);return Object.assign(e,B),e},Ae=ke({});Ae.newInstance=()=>ke({}),t.exports=Ae,Ae.HighlightJS=Ae,Ae.default=Ae}))()).default;function ou(e){let t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:[`self`,{begin:/:-/,contains:[n]}]};Object.assign(n,{className:`variable`,variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,`(?![\\w\\d])(?![$])`)},r]});let i={className:`subst`,begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},a=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:`comment`}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:`string`})]}},s={className:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,i]};i.contains.push(s);let c={match:/\\"/},l={className:`string`,begin:/'/,end:/'/},u={match:/\\'/},d={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:`number`},e.NUMBER_MODE,n]},f=e.SHEBANG({binary:`(${[`fish`,`bash`,`zsh`,`sh`,`csh`,`ksh`,`tcsh`,`dash`,`scsh`].join(`|`)})`,relevance:10}),p={className:`function`,begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},m=[`if`,`then`,`else`,`elif`,`fi`,`time`,`for`,`while`,`until`,`in`,`do`,`done`,`case`,`esac`,`coproc`,`function`,`select`],h=[`true`,`false`],g={match:/(\/[a-z._-]+)+/},_=[`break`,`cd`,`continue`,`eval`,`exec`,`exit`,`export`,`getopts`,`hash`,`pwd`,`readonly`,`return`,`shift`,`test`,`times`,`trap`,`umask`,`unset`],v=[`alias`,`bind`,`builtin`,`caller`,`command`,`declare`,`echo`,`enable`,`help`,`let`,`local`,`logout`,`mapfile`,`printf`,`read`,`readarray`,`source`,`sudo`,`type`,`typeset`,`ulimit`,`unalias`],y=`autoload.bg.bindkey.bye.cap.chdir.clone.comparguments.compcall.compctl.compdescribe.compfiles.compgroups.compquote.comptags.comptry.compvalues.dirs.disable.disown.echotc.echoti.emulate.fc.fg.float.functions.getcap.getln.history.integer.jobs.kill.limit.log.noglob.popd.print.pushd.pushln.rehash.sched.setcap.setopt.stat.suspend.ttyctl.unfunction.unhash.unlimit.unsetopt.vared.wait.whence.where.which.zcompile.zformat.zftp.zle.zmodload.zparseopts.zprof.zpty.zregexparse.zsocket.zstyle.ztcp`.split(`.`),b=`chcon.chgrp.chown.chmod.cp.dd.df.dir.dircolors.ln.ls.mkdir.mkfifo.mknod.mktemp.mv.realpath.rm.rmdir.shred.sync.touch.truncate.vdir.b2sum.base32.base64.cat.cksum.comm.csplit.cut.expand.fmt.fold.head.join.md5sum.nl.numfmt.od.paste.ptx.pr.sha1sum.sha224sum.sha256sum.sha384sum.sha512sum.shuf.sort.split.sum.tac.tail.tr.tsort.unexpand.uniq.wc.arch.basename.chroot.date.dirname.du.echo.env.expr.factor.groups.hostid.id.link.logname.nice.nohup.nproc.pathchk.pinky.printenv.printf.pwd.readlink.runcon.seq.sleep.stat.stdbuf.stty.tee.test.timeout.tty.uname.unlink.uptime.users.who.whoami.yes`.split(`.`);return{name:`Bash`,aliases:[`sh`,`zsh`],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:m,literal:h,built_in:[..._,...v,`set`,`shopt`,...y,...b]},contains:[f,e.SHEBANG(),p,d,a,o,g,s,c,l,u,n]}}var su=e=>({IMPORTANT:{scope:`meta`,begin:`!important`},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:`number`,begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:`built_in`,begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:`selector-attr`,begin:/\[/,end:/\]/,illegal:`$`,contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:`number`,begin:e.NUMBER_RE+`(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?`,relevance:0},CSS_VARIABLE:{className:`attr`,begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),cu=`a.abbr.address.article.aside.audio.b.blockquote.body.button.canvas.caption.cite.code.dd.del.details.dfn.div.dl.dt.em.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.html.i.iframe.img.input.ins.kbd.label.legend.li.main.mark.menu.nav.object.ol.optgroup.option.p.picture.q.quote.samp.section.select.source.span.strong.summary.sup.table.tbody.td.textarea.tfoot.th.thead.time.tr.ul.var.video`.split(`.`),lu=`defs.g.marker.mask.pattern.svg.switch.symbol.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feFlood.feGaussianBlur.feImage.feMerge.feMorphology.feOffset.feSpecularLighting.feTile.feTurbulence.linearGradient.radialGradient.stop.circle.ellipse.image.line.path.polygon.polyline.rect.text.use.textPath.tspan.foreignObject.clipPath`.split(`.`),uu=[...cu,...lu],du=`any-hover.any-pointer.aspect-ratio.color.color-gamut.color-index.device-aspect-ratio.device-height.device-width.display-mode.forced-colors.grid.height.hover.inverted-colors.monochrome.orientation.overflow-block.overflow-inline.pointer.prefers-color-scheme.prefers-contrast.prefers-reduced-motion.prefers-reduced-transparency.resolution.scan.scripting.update.width.min-width.max-width.min-height.max-height`.split(`.`).sort().reverse(),fu=`active.any-link.blank.checked.current.default.defined.dir.disabled.drop.empty.enabled.first.first-child.first-of-type.fullscreen.future.focus.focus-visible.focus-within.has.host.host-context.hover.indeterminate.in-range.invalid.is.lang.last-child.last-of-type.left.link.local-link.not.nth-child.nth-col.nth-last-child.nth-last-col.nth-last-of-type.nth-of-type.only-child.only-of-type.optional.out-of-range.past.placeholder-shown.read-only.read-write.required.right.root.scope.target.target-within.user-invalid.valid.visited.where`.split(`.`).sort().reverse(),pu=[`after`,`backdrop`,`before`,`cue`,`cue-region`,`first-letter`,`first-line`,`grammar-error`,`marker`,`part`,`placeholder`,`selection`,`slotted`,`spelling-error`].sort().reverse(),mu=`accent-color.align-content.align-items.align-self.alignment-baseline.all.anchor-name.animation.animation-composition.animation-delay.animation-direction.animation-duration.animation-fill-mode.animation-iteration-count.animation-name.animation-play-state.animation-range.animation-range-end.animation-range-start.animation-timeline.animation-timing-function.appearance.aspect-ratio.backdrop-filter.backface-visibility.background.background-attachment.background-blend-mode.background-clip.background-color.background-image.background-origin.background-position.background-position-x.background-position-y.background-repeat.background-size.baseline-shift.block-size.border.border-block.border-block-color.border-block-end.border-block-end-color.border-block-end-style.border-block-end-width.border-block-start.border-block-start-color.border-block-start-style.border-block-start-width.border-block-style.border-block-width.border-bottom.border-bottom-color.border-bottom-left-radius.border-bottom-right-radius.border-bottom-style.border-bottom-width.border-collapse.border-color.border-end-end-radius.border-end-start-radius.border-image.border-image-outset.border-image-repeat.border-image-slice.border-image-source.border-image-width.border-inline.border-inline-color.border-inline-end.border-inline-end-color.border-inline-end-style.border-inline-end-width.border-inline-start.border-inline-start-color.border-inline-start-style.border-inline-start-width.border-inline-style.border-inline-width.border-left.border-left-color.border-left-style.border-left-width.border-radius.border-right.border-right-color.border-right-style.border-right-width.border-spacing.border-start-end-radius.border-start-start-radius.border-style.border-top.border-top-color.border-top-left-radius.border-top-right-radius.border-top-style.border-top-width.border-width.bottom.box-align.box-decoration-break.box-direction.box-flex.box-flex-group.box-lines.box-ordinal-group.box-orient.box-pack.box-shadow.box-sizing.break-after.break-before.break-inside.caption-side.caret-color.clear.clip.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.color-scheme.column-count.column-fill.column-gap.column-rule.column-rule-color.column-rule-style.column-rule-width.column-span.column-width.columns.contain.contain-intrinsic-block-size.contain-intrinsic-height.contain-intrinsic-inline-size.contain-intrinsic-size.contain-intrinsic-width.container.container-name.container-type.content.content-visibility.counter-increment.counter-reset.counter-set.cue.cue-after.cue-before.cursor.cx.cy.direction.display.dominant-baseline.empty-cells.enable-background.field-sizing.fill.fill-opacity.fill-rule.filter.flex.flex-basis.flex-direction.flex-flow.flex-grow.flex-shrink.flex-wrap.float.flood-color.flood-opacity.flow.font.font-display.font-family.font-feature-settings.font-kerning.font-language-override.font-optical-sizing.font-palette.font-size.font-size-adjust.font-smooth.font-smoothing.font-stretch.font-style.font-synthesis.font-synthesis-position.font-synthesis-small-caps.font-synthesis-style.font-synthesis-weight.font-variant.font-variant-alternates.font-variant-caps.font-variant-east-asian.font-variant-emoji.font-variant-ligatures.font-variant-numeric.font-variant-position.font-variation-settings.font-weight.forced-color-adjust.gap.glyph-orientation-horizontal.glyph-orientation-vertical.grid.grid-area.grid-auto-columns.grid-auto-flow.grid-auto-rows.grid-column.grid-column-end.grid-column-start.grid-gap.grid-row.grid-row-end.grid-row-start.grid-template.grid-template-areas.grid-template-columns.grid-template-rows.hanging-punctuation.height.hyphenate-character.hyphenate-limit-chars.hyphens.icon.image-orientation.image-rendering.image-resolution.ime-mode.initial-letter.initial-letter-align.inline-size.inset.inset-area.inset-block.inset-block-end.inset-block-start.inset-inline.inset-inline-end.inset-inline-start.isolation.justify-content.justify-items.justify-self.kerning.left.letter-spacing.lighting-color.line-break.line-height.line-height-step.list-style.list-style-image.list-style-position.list-style-type.margin.margin-block.margin-block-end.margin-block-start.margin-bottom.margin-inline.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.margin-trim.marker.marker-end.marker-mid.marker-start.marks.mask.mask-border.mask-border-mode.mask-border-outset.mask-border-repeat.mask-border-slice.mask-border-source.mask-border-width.mask-clip.mask-composite.mask-image.mask-mode.mask-origin.mask-position.mask-repeat.mask-size.mask-type.masonry-auto-flow.math-depth.math-shift.math-style.max-block-size.max-height.max-inline-size.max-width.min-block-size.min-height.min-inline-size.min-width.mix-blend-mode.nav-down.nav-index.nav-left.nav-right.nav-up.none.normal.object-fit.object-position.offset.offset-anchor.offset-distance.offset-path.offset-position.offset-rotate.opacity.order.orphans.outline.outline-color.outline-offset.outline-style.outline-width.overflow.overflow-anchor.overflow-block.overflow-clip-margin.overflow-inline.overflow-wrap.overflow-x.overflow-y.overlay.overscroll-behavior.overscroll-behavior-block.overscroll-behavior-inline.overscroll-behavior-x.overscroll-behavior-y.padding.padding-block.padding-block-end.padding-block-start.padding-bottom.padding-inline.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.page.page-break-after.page-break-before.page-break-inside.paint-order.pause.pause-after.pause-before.perspective.perspective-origin.place-content.place-items.place-self.pointer-events.position.position-anchor.position-visibility.print-color-adjust.quotes.r.resize.rest.rest-after.rest-before.right.rotate.row-gap.ruby-align.ruby-position.scale.scroll-behavior.scroll-margin.scroll-margin-block.scroll-margin-block-end.scroll-margin-block-start.scroll-margin-bottom.scroll-margin-inline.scroll-margin-inline-end.scroll-margin-inline-start.scroll-margin-left.scroll-margin-right.scroll-margin-top.scroll-padding.scroll-padding-block.scroll-padding-block-end.scroll-padding-block-start.scroll-padding-bottom.scroll-padding-inline.scroll-padding-inline-end.scroll-padding-inline-start.scroll-padding-left.scroll-padding-right.scroll-padding-top.scroll-snap-align.scroll-snap-stop.scroll-snap-type.scroll-timeline.scroll-timeline-axis.scroll-timeline-name.scrollbar-color.scrollbar-gutter.scrollbar-width.shape-image-threshold.shape-margin.shape-outside.shape-rendering.speak.speak-as.src.stop-color.stop-opacity.stroke.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.tab-size.table-layout.text-align.text-align-all.text-align-last.text-anchor.text-combine-upright.text-decoration.text-decoration-color.text-decoration-line.text-decoration-skip.text-decoration-skip-ink.text-decoration-style.text-decoration-thickness.text-emphasis.text-emphasis-color.text-emphasis-position.text-emphasis-style.text-indent.text-justify.text-orientation.text-overflow.text-rendering.text-shadow.text-size-adjust.text-transform.text-underline-offset.text-underline-position.text-wrap.text-wrap-mode.text-wrap-style.timeline-scope.top.touch-action.transform.transform-box.transform-origin.transform-style.transition.transition-behavior.transition-delay.transition-duration.transition-property.transition-timing-function.translate.unicode-bidi.user-modify.user-select.vector-effect.vertical-align.view-timeline.view-timeline-axis.view-timeline-inset.view-timeline-name.view-transition-name.visibility.voice-balance.voice-duration.voice-family.voice-pitch.voice-range.voice-rate.voice-stress.voice-volume.white-space.white-space-collapse.widows.width.will-change.word-break.word-spacing.word-wrap.writing-mode.x.y.z-index.zoom`.split(`.`).sort().reverse();function hu(e){let t=e.regex,n=su(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i=/@-?\w[\w]*(-\w+)*/,a=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:`CSS`,case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:`from to`},classNameAliases:{keyframePosition:`selector-tag`},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:`selector-id`,begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:`selector-class`,begin:`\\.[a-zA-Z-][a-zA-Z0-9_-]*`,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:`selector-pseudo`,variants:[{begin:`:(`+fu.join(`|`)+`)`},{begin:`:(:)?(`+pu.join(`|`)+`)`}]},n.CSS_VARIABLE,{className:`attribute`,begin:`\\b(`+mu.join(`|`)+`)\\b`},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...a,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:`url data-uri`},contains:[...a,{className:`string`,begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:`[{;]`,relevance:0,illegal:/:/,contains:[{className:`keyword`,begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:`and or not only`,attribute:du.join(` `)},contains:[{begin:/[a-z-]+(?=:)/,className:`attribute`},...a,n.CSS_NUMBER_MODE]}]},{className:`selector-tag`,begin:`\\b(`+uu.join(`|`)+`)\\b`}]}}function gu(e){let t=e.regex;return{name:`Diff`,aliases:[`patch`],contains:[{className:`meta`,relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:`comment`,variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:`addition`,begin:/^\+/,end:/$/},{className:`deletion`,begin:/^-/,end:/$/},{className:`addition`,begin:/^!/,end:/$/}]}}var _u=`[A-Za-z$_][0-9A-Za-z$_]*`,vu=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),yu=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],bu=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),xu=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],Su=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],Cu=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],wu=[].concat(Su,bu,xu);function Tu(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=_u,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:_u,keyword:vu,literal:yu,built_in:wu,"variable.language":Cu},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:`[A-Za-z$_][0-9A-Za-z$_]*(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...bu,...xu]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...Su,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},j=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,M={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(j)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},M,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:j,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$[A-Za-z$_][0-9A-Za-z$_]*`,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function Eu(e){let t={className:`attr`,begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:`punctuation`,relevance:0},r=[`true`,`false`,`null`],i={scope:`literal`,beginKeywords:r.join(` `)};return{name:`JSON`,aliases:[`jsonc`],keywords:{literal:r},contains:[t,n,e.QUOTE_STRING_MODE,i,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:`\\S`}}function Du(e){let t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:`>`,subLanguage:`xml`,relevance:0},r={begin:`^[-\\*]{3,}`,end:`$`},i={className:`code`,variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:`(~{3,})[^~](.|\\n)*?\\1~*[ ]*`},{begin:"```",end:"```+[ ]*$"},{begin:`~~~`,end:`~~~+[ ]*$`},{begin:"`.+?`"},{begin:`(?=^( {4}|\\t))`,contains:[{begin:`^( {4}|\\t)`,end:`(\\n)$`}],relevance:0}]},a={className:`bullet`,begin:`^[ ]*([*+-]|(\\d+\\.))(?=\\s+)`,end:`\\s+`,excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:`symbol`,begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:`link`,begin:/:\s*/,end:/$/,excludeBegin:!0}]},s={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:`string`,relevance:0,begin:`\\[`,end:`\\]`,excludeBegin:!0,returnEnd:!0},{className:`link`,relevance:0,begin:`\\]\\(`,end:`\\)`,excludeBegin:!0,excludeEnd:!0},{className:`symbol`,relevance:0,begin:`\\]\\[`,end:`\\]`,excludeBegin:!0,excludeEnd:!0}]},c={className:`strong`,contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},l={className:`emphasis`,contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},u=e.inherit(c,{contains:[]}),d=e.inherit(l,{contains:[]});c.contains.push(d),l.contains.push(u);let f=[n,s];return[c,l,u,d].forEach(e=>{e.contains=e.contains.concat(f)}),f=f.concat(c,l),{name:`Markdown`,aliases:[`md`,`mkdown`,`mkd`],contains:[{className:`section`,variants:[{begin:`^#{1,6}`,end:`$`,contains:f},{begin:`(?=^.+?\\n[=-]{2,}$)`,contains:[{begin:`^[=-]*$`},{begin:`^`,end:`\\n`,contains:f}]}]},n,a,c,l,{className:`quote`,begin:`^>\\s+`,contains:f,end:`$`},i,r,s,o,{scope:`literal`,match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function Ou(e){let t=e.regex,n=/[\p{XID_Start}_]\p{XID_Continue}*/u,r=`and.as.assert.async.await.break.case.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.match.nonlocal|10.not.or.pass.raise.return.try.while.with.yield`.split(`.`),i={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:`__import__.abs.all.any.ascii.bin.bool.breakpoint.bytearray.bytes.callable.chr.classmethod.compile.complex.delattr.dict.dir.divmod.enumerate.eval.exec.filter.float.format.frozenset.getattr.globals.hasattr.hash.help.hex.id.input.int.isinstance.issubclass.iter.len.list.locals.map.max.memoryview.min.next.object.oct.open.ord.pow.print.property.range.repr.reversed.round.set.setattr.slice.sorted.staticmethod.str.sum.super.tuple.type.vars.zip`.split(`.`),literal:[`__debug__`,`Ellipsis`,`False`,`None`,`NotImplemented`,`True`],type:[`Any`,`Callable`,`Coroutine`,`Dict`,`List`,`Literal`,`Generic`,`Optional`,`Sequence`,`Set`,`Tuple`,`Type`,`Union`]},a={className:`meta`,begin:/^(>>>|\.\.\.) /},o={className:`subst`,begin:/\{/,end:/\}/,keywords:i,illegal:/#/},s={begin:/\{\{/,relevance:0},c={className:`string`,contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a,s,o]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a,s,o]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,s,o]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,s,o]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},l=`[0-9](_?[0-9])*`,u=`(\\b(${l}))?\\.(${l})|\\b(${l})\\.`,d=`\\b|${r.join(`|`)}`,f={className:`number`,relevance:0,variants:[{begin:`(\\b(${l})|(${u}))[eE][+-]?(${l})[jJ]?(?=${d})`},{begin:`(${u})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${d})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${d})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${d})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${d})`},{begin:`\\b(${l})[jJ](?=${d})`}]},p={className:`comment`,begin:t.lookahead(/# type:/),end:/$/,keywords:i,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},m={className:`params`,variants:[{className:``,begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:i,contains:[`self`,a,f,c,e.HASH_COMMENT_MODE]}]};return o.contains=[c,f,a],{name:`Python`,aliases:[`py`,`gyp`,`ipython`],unicodeRegex:!0,keywords:i,illegal:/(<\/|\?)|=>/,contains:[a,f,{scope:`variable.language`,match:/\bself\b/},{beginKeywords:`if`,relevance:0},{match:/\bor\b/,scope:`keyword`},c,p,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:`keyword`,3:`title.function`},contains:[m]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:`keyword`,3:`title.class`,6:`title.class.inherited`}},{className:`meta`,begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[f,m,c]}]}}function ku(e){let t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),a={className:`title.function.invoke`,relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,i,t.lookahead(/\s*\(/))},o=`abstract.as.async.await.become.box.break.const.continue.crate.do.dyn.else.enum.extern.false.final.fn.for.if.impl.in.let.loop.macro.match.mod.move.mut.override.priv.pub.ref.return.self.Self.static.struct.super.trait.true.try.type.typeof.union.unsafe.unsized.use.virtual.where.while.yield`.split(`.`),s=[`true`,`false`,`Some`,`None`,`Ok`,`Err`],c=`drop .Copy.Send.Sized.Sync.Drop.Fn.FnMut.FnOnce.ToOwned.Clone.Debug.PartialEq.PartialOrd.Eq.Ord.AsRef.AsMut.Into.From.Default.Iterator.Extend.IntoIterator.DoubleEndedIterator.ExactSizeIterator.SliceConcatExt.ToString.assert!.assert_eq!.bitflags!.bytes!.cfg!.col!.concat!.concat_idents!.debug_assert!.debug_assert_eq!.env!.eprintln!.panic!.file!.format!.format_args!.include_bytes!.include_str!.line!.local_data_key!.module_path!.option_env!.print!.println!.select!.stringify!.try!.unimplemented!.unreachable!.vec!.write!.writeln!.macro_rules!.assert_ne!.debug_assert_ne!`.split(`.`),l=[`i8`,`i16`,`i32`,`i64`,`i128`,`isize`,`u8`,`u16`,`u32`,`u64`,`u128`,`usize`,`f32`,`f64`,`str`,`char`,`bool`,`Box`,`Option`,`Result`,`String`,`Vec`];return{name:`Rust`,aliases:[`rs`],keywords:{$pattern:e.IDENT_RE+`!?`,type:l,keyword:o,literal:s,built_in:c},illegal:`</`,contains:[e.C_LINE_COMMENT_MODE,e.COMMENT(`/\\*`,`\\*/`,{contains:[`self`]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:`symbol`,begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:`string`,variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:`char.escape`,match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:`number`,variants:[{begin:`\\b0b([01_]+)([ui](8|16|32|64|128|size)|f(32|64))?`},{begin:`\\b0o([0-7_]+)([ui](8|16|32|64|128|size)|f(32|64))?`},{begin:`\\b0x([A-Fa-f0-9_]+)([ui](8|16|32|64|128|size)|f(32|64))?`},{begin:`\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)([ui](8|16|32|64|128|size)|f(32|64))?`}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:`keyword`,3:`title.function`}},{className:`meta`,begin:`#!?\\[`,end:`\\]`,contains:[{className:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:`keyword`,3:`keyword`,4:`variable`}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:`keyword`,3:`variable`,5:`keyword`}},{begin:[/type/,/\s+/,r],className:{1:`keyword`,3:`title.class`}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:`keyword`,3:`title.class`}},{begin:e.IDENT_RE+`::`,keywords:{keyword:`Self`,built_in:c,type:l}},{className:`punctuation`,begin:`->`},a]}}function Au(e){let t=e.regex,n=e.COMMENT(`--`,`$`),r={scope:`string`,variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},a=[`true`,`false`,`unknown`],o=[`double precision`,`large object`,`with timezone`,`without timezone`],s=`bigint.binary.blob.boolean.char.character.clob.date.dec.decfloat.decimal.float.int.integer.interval.nchar.nclob.national.numeric.real.row.smallint.time.timestamp.varchar.varying.varbinary`.split(`.`),c=[`add`,`asc`,`collation`,`desc`,`final`,`first`,`last`,`view`],l=`abs.acos.all.allocate.alter.and.any.are.array.array_agg.array_max_cardinality.as.asensitive.asin.asymmetric.at.atan.atomic.authorization.avg.begin.begin_frame.begin_partition.between.bigint.binary.blob.boolean.both.by.call.called.cardinality.cascaded.case.cast.ceil.ceiling.char.char_length.character.character_length.check.classifier.clob.close.coalesce.collate.collect.column.commit.condition.connect.constraint.contains.convert.copy.corr.corresponding.cos.cosh.count.covar_pop.covar_samp.create.cross.cube.cume_dist.current.current_catalog.current_date.current_default_transform_group.current_path.current_role.current_row.current_schema.current_time.current_timestamp.current_path.current_role.current_transform_group_for_type.current_user.cursor.cycle.date.day.deallocate.dec.decimal.decfloat.declare.default.define.delete.dense_rank.deref.describe.deterministic.disconnect.distinct.double.drop.dynamic.each.element.else.empty.end.end_frame.end_partition.end-exec.equals.escape.every.except.exec.execute.exists.exp.external.extract.false.fetch.filter.first_value.float.floor.for.foreign.frame_row.free.from.full.function.fusion.get.global.grant.group.grouping.groups.having.hold.hour.identity.in.indicator.initial.inner.inout.insensitive.insert.int.integer.intersect.intersection.interval.into.is.join.json_array.json_arrayagg.json_exists.json_object.json_objectagg.json_query.json_table.json_table_primitive.json_value.lag.language.large.last_value.lateral.lead.leading.left.like.like_regex.listagg.ln.local.localtime.localtimestamp.log.log10.lower.match.match_number.match_recognize.matches.max.member.merge.method.min.minute.mod.modifies.module.month.multiset.national.natural.nchar.nclob.new.no.none.normalize.not.nth_value.ntile.null.nullif.numeric.octet_length.occurrences_regex.of.offset.old.omit.on.one.only.open.or.order.out.outer.over.overlaps.overlay.parameter.partition.pattern.per.percent.percent_rank.percentile_cont.percentile_disc.period.portion.position.position_regex.power.precedes.precision.prepare.primary.procedure.ptf.range.rank.reads.real.recursive.ref.references.referencing.regr_avgx.regr_avgy.regr_count.regr_intercept.regr_r2.regr_slope.regr_sxx.regr_sxy.regr_syy.release.result.return.returns.revoke.right.rollback.rollup.row.row_number.rows.running.savepoint.scope.scroll.search.second.seek.select.sensitive.session_user.set.show.similar.sin.sinh.skip.smallint.some.specific.specifictype.sql.sqlexception.sqlstate.sqlwarning.sqrt.start.static.stddev_pop.stddev_samp.submultiset.subset.substring.substring_regex.succeeds.sum.symmetric.system.system_time.system_user.table.tablesample.tan.tanh.then.time.timestamp.timezone_hour.timezone_minute.to.trailing.translate.translate_regex.translation.treat.trigger.trim.trim_array.true.truncate.uescape.union.unique.unknown.unnest.update.upper.user.using.value.values.value_of.var_pop.var_samp.varbinary.varchar.varying.versioning.when.whenever.where.width_bucket.window.with.within.without.year`.split(`.`),u=`abs.acos.array_agg.asin.atan.avg.cast.ceil.ceiling.coalesce.corr.cos.cosh.count.covar_pop.covar_samp.cume_dist.dense_rank.deref.element.exp.extract.first_value.floor.json_array.json_arrayagg.json_exists.json_object.json_objectagg.json_query.json_table.json_table_primitive.json_value.lag.last_value.lead.listagg.ln.log.log10.lower.max.min.mod.nth_value.ntile.nullif.percent_rank.percentile_cont.percentile_disc.position.position_regex.power.rank.regr_avgx.regr_avgy.regr_count.regr_intercept.regr_r2.regr_slope.regr_sxx.regr_sxy.regr_syy.row_number.sin.sinh.sqrt.stddev_pop.stddev_samp.substring.substring_regex.sum.tan.tanh.translate.translate_regex.treat.trim.trim_array.unnest.upper.value_of.var_pop.var_samp.width_bucket`.split(`.`),d=[`current_catalog`,`current_date`,`current_default_transform_group`,`current_path`,`current_role`,`current_schema`,`current_transform_group_for_type`,`current_user`,`session_user`,`system_time`,`system_user`,`current_time`,`localtime`,`current_timestamp`,`localtimestamp`],f=[`create table`,`insert into`,`primary key`,`foreign key`,`not null`,`alter table`,`add constraint`,`grouping sets`,`on overflow`,`character set`,`respect nulls`,`ignore nulls`,`nulls first`,`nulls last`,`depth first`,`breadth first`],p=u,m=[...l,...c].filter(e=>!u.includes(e)),h={scope:`variable`,match:/@[a-z0-9][a-z0-9_]*/},g={scope:`operator`,match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},_={match:t.concat(/\b/,t.either(...p),/\s*\(/),relevance:0,keywords:{built_in:p}};function v(e){return t.concat(/\b/,t.either(...e.map(e=>e.replace(/\s+/,`\\s+`))),/\b/)}let y={scope:`keyword`,match:v(f),relevance:0};function b(e,{exceptions:t,when:n}={}){let r=n;return t||=[],e.map(e=>e.match(/\|\d+$/)||t.includes(e)?e:r(e)?`${e}|0`:e)}return{name:`SQL`,case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:b(m,{when:e=>e.length<3}),literal:a,type:s,built_in:d},contains:[{scope:`type`,match:v(o)},y,_,h,r,i,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,g]}}var ju=`[A-Za-z$_][0-9A-Za-z$_]*`,Mu=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),Nu=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],Pu=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),Fu=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],Iu=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],Lu=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],Ru=[].concat(Iu,Pu,Fu);function zu(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=ju,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:ju,keyword:Mu,literal:Nu,built_in:Ru,"variable.language":Lu},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:`[A-Za-z$_][0-9A-Za-z$_]*(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...Pu,...Fu]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...Iu,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},j=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,M={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(j)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},M,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:j,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$[A-Za-z$_][0-9A-Za-z$_]*`,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function Bu(e){let t=e.regex,n=zu(e),r=ju,i=[`any`,`void`,`number`,`boolean`,`string`,`object`,`never`,`symbol`,`bigint`,`unknown`],a={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:`keyword`,3:`title.class`}},o={beginKeywords:`interface`,end:/\{/,excludeEnd:!0,keywords:{keyword:`interface extends`,built_in:i},contains:[n.exports.CLASS_REFERENCE]},s={className:`meta`,relevance:10,begin:/^\s*['"]use strict['"]/},c={$pattern:ju,keyword:Mu.concat([`type`,`interface`,`public`,`private`,`protected`,`implements`,`declare`,`abstract`,`readonly`,`enum`,`override`,`satisfies`]),literal:Nu,built_in:Ru.concat(i),"variable.language":Lu},l={className:`meta`,begin:`@[A-Za-z$_][0-9A-Za-z$_]*`},u=(e,t,n)=>{let r=e.contains.findIndex(e=>e.label===t);if(r===-1)throw Error(`can not find mode to replace`);e.contains.splice(r,1,n)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(l);let d=n.contains.find(e=>e.scope===`attr`),f=Object.assign({},d,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,d,f]),n.contains=n.contains.concat([l,a,o,f]),u(n,`shebang`,e.SHEBANG()),u(n,`use_strict`,s);let p=n.contains.find(e=>e.label===`func.def`);return p.relevance=0,Object.assign(n,{name:`TypeScript`,aliases:[`ts`,`tsx`,`mts`,`cts`]}),n}function Vu(e){let t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,i={className:`symbol`,begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},a={begin:/\s/,contains:[{className:`keyword`,begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(a,{begin:/\(/,end:/\)/}),s=e.inherit(e.APOS_STRING_MODE,{className:`string`}),c=e.inherit(e.QUOTE_STRING_MODE,{className:`string`}),l={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:`attr`,begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:`string`,endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:`HTML, XML`,aliases:[`html`,`xhtml`,`rss`,`atom`,`xjb`,`xsd`,`xsl`,`plist`,`wsf`,`svg`],case_insensitive:!0,unicodeRegex:!0,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,relevance:10,contains:[a,c,s,o,{begin:/\[/,end:/\]/,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,contains:[a,o,c,s]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:`meta`,end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:`tag`,begin:/<style(?=\s|>)/,end:/>/,keywords:{name:`style`},contains:[l],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:[`css`,`xml`]}},{className:`tag`,begin:/<script(?=\s|>)/,end:/>/,keywords:{name:`script`},contains:[l],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:[`javascript`,`handlebars`,`xml`]}},{className:`tag`,begin:/<>|<\/>/},{className:`tag`,begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:`name`,begin:n,relevance:0,starts:l}]},{className:`tag`,begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:`name`,begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function Hu(e){let t=`true false yes no null`,n={className:`attr`,variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},r={className:`template-variable`,variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},i={className:`string`,relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:`char.escape`,relevance:0}]},a={className:`string`,relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,r]},o=e.inherit(a,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),s={className:`number`,begin:`\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b`},c={end:`,`,endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},l={begin:/\{/,end:/\}/,contains:[c],illegal:`\\n`,relevance:0},u={begin:`\\[`,end:`\\]`,contains:[c],illegal:`\\n`,relevance:0},d=[n,{className:`meta`,begin:`^---\\s*$`,relevance:10},{className:`string`,begin:`[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*`},{begin:`<%[%=-]?`,end:`[%-]?%>`,subLanguage:`ruby`,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:`type`,begin:`!\\w+![\\w#;/?:@&=+$,.~*'()[\\]]+`},{className:`type`,begin:`!<[\\w#;/?:@&=+$,.~*'()[\\]]+>`},{className:`type`,begin:`![\\w#;/?:@&=+$,.~*'()[\\]]+`},{className:`type`,begin:`!![\\w#;/?:@&=+$,.~*'()[\\]]+`},{className:`meta`,begin:`&`+e.UNDERSCORE_IDENT_RE+`$`},{className:`meta`,begin:`\\*`+e.UNDERSCORE_IDENT_RE+`$`},{className:`bullet`,begin:`-(?=[ ]|$)`,relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},s,{className:`number`,begin:e.C_NUMBER_RE+`\\b`,relevance:0},l,u,i,a],f=[...d];return f.pop(),f.push(o),c.contains=f,{name:`YAML`,case_insensitive:!0,aliases:[`yml`],contains:d}}var Uu=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`],Wu=Object.freeze({bold:!1,dim:!1,italic:!1,underline:!1,inverse:!1,hidden:!1,strike:!1}),Gu=`ansi-esc`,Ku=/^(?:color:#[0-9a-f]{6}(?:;background-color:#[0-9a-f]{6})?|background-color:#[0-9a-f]{6})$/,qu=String.raw`(?:\x1b|�|\\x1[bB]|\\u001[bB]|\\033|\\e|\^\[)`,Ju=new RegExp(qu,`g`),Yu=/\[([0-?]{0,64})[ -/]{0,8}([@-~])/y,Xu=new RegExp(String.raw`\][^\n]{0,2048}?(?:${qu}\\\\?|\x07|�|\\a|\\x07|\\007|\\u0007)`,`y`),Zu=/[()][0-9A-Za-z]/y;function Qu(e){let t=``,n={...Wu},r=``,i=0,a=n=>{if(n<=i)return;let a=ad(e.slice(i,n));t+=r?`${r}${a}</span>`:a};Ju.lastIndex=0;for(let o=Ju.exec(e);o;o=Ju.exec(e)){let s=o.index,c=s+o[0].length,l=-1,u;for(let t of[Yu,Xu,Zu]){t.lastIndex=c;let n=t.exec(e);if(n){l=c+n[0].length,t===Yu&&n[2]===`m`&&(u=n[1]);break}}l<0&&o[0]===`\x1B`&&(l=c),!(l<0)&&(a(s),t+=`<span class="${Gu}">${ad(e.slice(s,l))}</span>`,u!==void 0&&(n=$u(n,u),r=id(n)),i=l,Ju.lastIndex=l)}return a(e.length),t}function $u(e,t){if(!/^[0-9:;]*$/.test(t))return e;let n={...e},r=t===``?[`0`]:t.split(`;`);for(let e=0;e<r.length;e++){let[t,...i]=r[e].split(`:`),a=t===``?0:Number(t);if(a===38||a===48||a===58){let t;if(i.length>0)t=ed(i[0],i[0]===`2`&&i.length>4?i.slice(2,5):i.slice(1));else{let n=r[e+1],i=n===`5`?1:n===`2`?3:0;t=ed(n,r.slice(e+2,e+2+i)),e+=1+i}t&&a===38&&(n.fg=t),t&&a===48&&(n.bg=t);continue}a===0?Object.assign(n,Wu,{fg:void 0,bg:void 0}):a===1?n.bold=!0:a===2?n.dim=!0:a===3?n.italic=!0:a===4?n.underline=i[0]!==`0`:a===7?n.inverse=!0:a===8?n.hidden=!0:a===9?n.strike=!0:a===21?n.underline=!0:a===22?n.bold=n.dim=!1:a===23?n.italic=!1:a===24?n.underline=!1:a===27?n.inverse=!1:a===28?n.hidden=!1:a===29?n.strike=!1:a>=30&&a<=37?n.fg={index:a-30}:a===39?n.fg=void 0:a>=40&&a<=47?n.bg={index:a-40}:a===49?n.bg=void 0:a>=90&&a<=97?n.fg={index:a-90+8}:a>=100&&a<=107&&(n.bg={index:a-100+8})}return n}function ed(e,t){let n=t.map(e=>e===``?NaN:Number(e));if(n.every(e=>Number.isInteger(e)&&e>=0&&e<=255)){if(e===`5`&&n.length===1)return td(n[0]);if(e===`2`&&n.length===3)return{hex:nd(n[0],n[1],n[2])}}}function td(e){if(e<16)return{index:e};if(e>=232){let t=8+(e-232)*10;return{hex:nd(t,t,t)}}let t=e=>e===0?0:55+e*40,n=e-16;return{hex:nd(t(Math.floor(n/36)),t(Math.floor(n/6)%6),t(n%6))}}function nd(...e){return`#${e.map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function rd(e){return e<8?Uu[e]:`bright-${Uu[e-8]}`}function id(e){let t=e.inverse?e.bg:e.fg,n=e.inverse?e.fg:e.bg,r=[],i=[];return t&&`index`in t?r.push(`ansi-fg-${rd(t.index)}`):t?i.push(`color:${t.hex}`):e.inverse&&r.push(`ansi-fg-inverse`),n&&`index`in n?r.push(`ansi-bg-${rd(n.index)}`):n?i.push(`background-color:${n.hex}`):e.inverse&&r.push(`ansi-bg-inverse`),e.bold&&r.push(`ansi-bold`),e.dim&&r.push(`ansi-dim`),e.italic&&r.push(`ansi-italic`),e.underline&&r.push(`ansi-underline`),e.strike&&r.push(`ansi-strike`),e.hidden&&r.push(`ansi-hidden`),r.length===0&&i.length===0?``:`<span${r.length?` class="${r.join(` `)}"`:``}${i.length?` style="${i.join(`;`)}"`:``}>`}function ad(e){return e.replace(/[&<>"']/g,e=>e===`&`?`&`:e===`<`?`<`:e===`>`?`>`:e===`"`?`"`:`'`)}var od={bash:ou,css:hu,diff:gu,javascript:Tu,json:Eu,markdown:Du,python:Ou,rust:ku,sql:Au,typescript:Bu,xml:Vu,yaml:Hu};for(let[e,t]of Object.entries(od))au.registerLanguage(e,t);function sd(e,t){if(t===`plaintext`)return ps(e);if(t===`ansi`)return Qu(e);try{return au.highlight(e,{language:t,ignoreIllegals:!0}).value}catch{return ps(e)}}function cd(e,t,n=t){return`<code class="hljs language-${n}">${sd(`${e.replace(/\n$/,``)}\n`,t)}</code>`}var ld=`<button type="button" class="${hn}" title="${D}"></button>`;function ud(e,t){let n=Cn(t);return`<span class="${Ss}"><pre>${cd(e,n,/^\s*(lightbox|mermaid)\s*$/i.exec(t??``)?.[1].toLowerCase()??n)}</pre>${ld}</span>\n`}var dd=/<span\b[^>]*>|<\/span>|\n|[^<\n]+|</g;function fd(e){let t=[],n=[],r=``;for(let[i]of e.matchAll(dd))i===`
|
|
60
|
-
`?(t.push(r+`</span>`.repeat(n.length)),r=n.join(``)):i===`</span>`?(n.pop(),r+=i):(i.startsWith(`<span`)&&n.push(i),r+=i);return t.push(r+`</span>`.repeat(n.length)),t}var pd=/^(\s*\d+\t)([\s\S]*)$/,md=/^\s*\d+$/;function hd(e){let t=0,n=0,r=0;for(let i of e)i.trim()&&(t++,pd.test(i)?(n++,r++):md.test(i)&&n++);return t>0&&n===t&&r>0}function gd(e){return e.replace(/[&<>"']/g,e=>e===`&`?`&`:e===`<`?`<`:e===`>`?`>`:e===`"`?`"`:`'`)}var _d=`frizz-code-gutter`;function vd(e,t){let n=e.split(`
|
|
61
|
-
`);if(!hd(n))return sd(e,t);let r=[],i=[];for(let e of n){let t=pd.exec(e);t?(r.push(t[1]),i.push(t[2])):e.trim()&&md.test(e)?(r.push(e),i.push(``)):(r.push(``),i.push(e))}let a=fd(sd(i.join(`
|
|
62
|
-
`),t));return r.map((e,t)=>(e?`<span class="${_d}">${gd(e)}</span>`:``)+(a[t]??``)).join(`
|
|
63
|
-
`)}var yd=`md-diff-row`,bd=/(?:^|\s)lang(?:uage)?\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"']+))/i;function xd(e){let t=(e??``).trim(),n=t.split(/\s+/,1)[0].toLowerCase(),r=bd.exec(t.slice(n.length)),i=r&&(r[1]??r[2]??r[3]).trim().toLowerCase()||null;if(n===`diff`||n===`patch`)return{declared:i};let a=/^(.+)-diff$/.exec(n)??/^diff-(.+)$/.exec(n);return a?{declared:a[1]}:null}var Sd=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,Cd=/^(?:index [0-9a-f]+\.\.[0-9a-f]+|(?:new|deleted) file mode |(?:old|new) mode |(?:dis)?similarity index |(?:rename|copy) (?:from|to) |Binary files )/;function wd(e){let t=[],n=!1,r=0,i=0,a=null,o=null;for(let s=0;s<e.length;s++){let c=e[s];if(/^diff (?:--git|--cc|--combined|-\S+) /.test(c)||/^Index: /.test(c)){t.push({kind:`file`,raw:c}),n=!0,r=i=0,a=o=null;continue}if(c.startsWith(`@@`)){let e=Sd.exec(c);t.push({kind:`hunk`,raw:c}),n=!1,a=e?Number(e[1]):null,o=e?Number(e[3]):null,r=e?Number(e[2]??1):0,i=e?Number(e[4]??1):0;continue}if(n&&Cd.test(c)){t.push({kind:/^index /.test(c)?`file`:`meta`,raw:c});continue}if(r===0&&i===0&&c.startsWith(`--- `)&&e[s+1]?.startsWith(`+++ `)){t.push({kind:`file`,raw:c},{kind:`file`,raw:e[s+1]}),s++,n=!0,a=o=null;continue}n=!1,c.startsWith(`\\ `)?t.push({kind:`meta`,raw:c}):c.startsWith(`+`)?(t.push({kind:`add`,raw:c,line:o??void 0}),o!==null&&o++,i>0&&i--):c.startsWith(`-`)?(t.push({kind:`del`,raw:c,line:a??void 0}),a!==null&&a++,r>0&&r--):(t.push({kind:`ctx`,raw:c,line:o??void 0}),a!==null&&a++,o!==null&&o++,r>0&&r--,i>0&&i--)}return t}function Td(e){let t=e.slice(4).split(` `,1)[0].trim().replace(/^[ab]\//,``);return t&&t!==`/dev/null`?t:null}function Ed(e){let t=[];for(let n=0;n<e.length;n++){if(e[n].kind!==`file`||!e[n].raw.startsWith(`--- `))continue;let r=e[n+1],i=(r?.raw.startsWith(`+++ `)?Td(r.raw):null)??Td(e[n].raw);i&&t.push(i)}return t}var Dd=e=>e.map(ps);function Od(e,t){return e.length===0?[]:t===`plaintext`||t===`ansi`?Dd(e):fd(sd(e.join(`
|
|
64
|
-
`),t))}function kd(e,t={}){let n=e.replace(/\n$/,``).split(`
|
|
65
|
-
`),r=wd(n),i=Ed(r),a=ie(t.label),o=t.declared?Cn(t.declared):a===`plaintext`?ie(i[0]):a,s=r.some(e=>e.kind===`hunk`)||!r.some(e=>e.kind===`ctx`&&e.raw!==``&&!e.raw.startsWith(` `)),c=e=>e.kind===`ctx`&&!(s&&e.raw.startsWith(` `))?[``,e.raw]:[e.raw[0],e.raw.slice(1)],l=r.some(e=>e.line!==void 0),u=[],d=0,f=0,p=0;for(let e=0;e<r.length;){let t=r[e];if(t.kind===`hunk`||t.kind===`file`||t.kind===`meta`){u.push(`<span class="${yd} md-diff-${t.kind}">${ps(t.raw)}\n</span>`),e++;continue}let n=e;for(;n<r.length&&(r[n].kind===`add`||r[n].kind===`del`||r[n].kind===`ctx`);)n++;let i=r.slice(e,n).map(e=>({row:e,parts:c(e)})),a=Od(i.filter(({row:e})=>e.kind!==`add`).map(({parts:e})=>e[1]),o),s=Od(i.filter(({row:e})=>e.kind!==`del`).map(({parts:e})=>e[1]),o),m=0,h=0;for(let{row:e,parts:[t]}of i){let n=e.kind===`del`?a[m]:s[h];e.kind!==`add`&&m++,e.kind!==`del`&&h++,e.kind===`add`&&d++,e.kind===`del`&&f++,e.line!==void 0&&(p=Math.max(p,e.line));let r=l?`<span class="md-diff-num"${e.line===void 0?``:` data-line="${e.line}"`}></span>`:``;u.push(`<span class="${yd} md-diff-${e.kind}">${r}<span class="md-diff-sign">${ps(t)}</span><span class="md-diff-text">${n??``}\n</span></span>`)}e=n}return{html:u.join(``),additions:d,deletions:f,file:i.length===1?i[0]:null,digits:l?String(p).length:0,lines:n.length}}var Ad=`md-line`,jd=`is-marked`,Md=/\{\s*(\d[\d\s,–-]*)\}/;function Nd(e){let t=Md.exec(e??``);if(!t)return null;let n=[];for(let e of t[1].split(/[\s,]+/)){let t=/^(\d{1,7})(?:[–-](\d{1,7}))?$/.exec(e);if(!t)continue;let r=Number(t[1]),i=t[2]===void 0?r:Number(t[2]);r>=1&&i>=r&&n.push([r,i])}return n.length>0?n:null}function Pd(e,t){return e.some(([e,n])=>t>=e&&t<=n)}function Fd(e,t){let n=fd(e);return n.at(-1)?.replace(/<[^>]*>/g,``)===``&&n.pop(),n.map((e,n)=>`<span class="${Ad}${Pd(t,n+1)?` ${jd}`:``}">${e}\n</span>`).join(``)}var Id=`md-code-frame`,Ld=`md-code-lined`,Rd=`md-diff`,zd=/^(?:lightbox|mermaid)$/i,Bd=!0;function Vd(e){let t=Bd;Bd=!1;try{return e()}finally{Bd=t}}function Hd(e){if(e.label===void 0)return Cn(e.info);let t=Gr(e.info)?.language;return t?Cn(t):ie(e.label)}function Ud(e){let t=`${e.text.replace(/\n$/,``)}\n`,n=t.split(`
|
|
66
|
-
`).length-1,r=xd(e.info),i=r?null:Nd(e.info),a=[],o,s;if(r){let t=kd(e.text,{declared:r.declared,label:e.label});o=`<code class="hljs language-diff">${t.html}</code>`,a.push(Rd),t.digits>0&&a.push(`md-diff-n${Math.min(t.digits,6)}`),s={file:t.file,additions:t.additions,deletions:t.deletions}}else if(i){let n=Hd(e);o=`<code class="hljs language-${n}">${Fd(sd(t,n),i)}</code>`,a.push(Ld)}else o=cd(e.text,Hd(e));let c=!1;if(i)for(let e=25;e<=n&&!c;e++)c=Pd(i,e);let l=Bd&&e.closed&&n>40&&!c,u=l&&Ir(e.text);return l&&a.push(u?Zi:`${Zi} ${Ha}`),{code:o,classes:a,lines:n,long:l,open:u,diff:s}}var Wd=28,Gd=e=>e.length>=Wd?` title="${ps(e)}"`:``;function Kd({additions:e,deletions:t}){return e===0&&t===0?``:`<span class="md-diff-stat">`+(e>0?`<span class="md-diff-adds">+${e}</span>`:``)+(t>0?`<span class="md-diff-dels">−${t}</span>`:``)+`</span>`}var qd=e=>`<button type="button" class="${wo}" aria-expanded="${e.open}">${Za(e.lines,e.open)}</button>`;function Jd(e){let t=e.length===1;if(t&&zd.test(e[0].info.trim().split(/\s+/,1)[0]))return ud(e[0].text,e[0].closed?e[0].info:``);let n=e.map(Ud),r=t?e[0].label??n[0].diff?.file??void 0:void 0,i=!t||r!==void 0;if(!(i||n.some(e=>e.long))){let[{code:t,classes:r}]=n;return r.length===0?ud(e[0].text,e[0].info):`<span class="${Ss}"><pre class="${r.join(` `)}">${t}</pre>${ld}</span>\n`}let a=t?0:js(e.map(e=>e.label??``)),o=``;t&&r!==void 0?(e[0].label===void 0&&n[0].classes.push(`md-diff-titled`),o=`<span class="${wi}"><span class="${Ni}"${Gd(r)}>${ps(r)}</span>${n[0].diff?Kd(n[0].diff):``}</span>`):t||(o=`<span class="${wi}" role="tablist">`+e.map((e,t)=>{let n=t===a,r=e.label??``;return`<button type="button" class="${Hi}${n?` ${Na}`:``}" role="tab" aria-selected="${n}"${Gd(r)}>${ps(r)}</button>`}).join(``)+`</span>`);let s=n.map((e,n)=>{let r=[...i?[n===a?`${si} ${Na}`:si]:[],...e.classes];return`<pre${r.length>0?` class="${r.join(` `)}"`:``}${t?``:` role="tabpanel"`}>${e.code}</pre>`+(e.long?qd(e):``)}).join(``);return`<span class="${Ss} ${Id}${i?` ${oo}`:``}">${o}${s}${ld}</span>\n`}var Yd={name:`codeTabs`,level:`block`,tokenizer(){},renderer(e){return Jd(e.tabs)}},Xd=/^[a-zA-Z]:\\(?!\\)/,Zd=/(?<![A-Za-z0-9])[A-Za-z]:\\/,Qd=Ql.rules.inline.normal.link;function $d(e,t){let n=t.length;for(;n>0&&!/\s/.test(t[n-1]);)n--;n>0&&(e.inPath=!1,e.tail=``);let r=e.tail+t.slice(n);e.inPath||=Zd.test(r),e.tail=r.slice(-3)}function ef(e){if(!/^[a-zA-Z]:/.test(e.href))return;let t=Qd.exec(e.raw);if(!t)return;let n=t[2].trim();n.startsWith(`<`)&&n.endsWith(`>`)&&(n=n.slice(1,-1)),Xd.test(n)&&(e.href=n)}function tf(e){let t={inPath:!1,tail:``};for(let n=0;n<e.length;n++){let r=e[n];(r.type===`link`||r.type===`image`)&&ef(r);let i=dn(r);for(let e of i)tf(e);if(r.type===`text`&&i.length===0){$d(t,r.raw);continue}if(r.type===`escape`){$d(t,r.raw),r.raw!==`\\\\`&&t.inPath&&(e[n]={type:`text`,raw:r.raw,text:r.raw});continue}t.inPath=!1,t.tail=``}}var nf=`md-callout`,rf=`md-callout-title`,af={note:`Note`,tip:`Tip`,important:`Important`,warning:`Warning`,caution:`Caution`},of={info:`note`,hint:`tip`,attention:`warning`,danger:`caution`,error:`caution`};function sf(e){let t=e.toLowerCase();return Object.hasOwn(af,t)?t:Object.hasOwn(of,t)?of[t]:null}var cf=/^\[!([A-Za-z]+)\](?=[ \t]|\n|$)/;function lf(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.type===`list`){for(let e of n.items)lf(e.tokens);continue}if(n.type!==`blockquote`)continue;let r=n,i=uf(r);i&&(e[t]=i),lf(i?i.tokens:r.tokens)}}function uf(e){let t=e.tokens.findIndex(e=>e.type!==`space`),n=e.tokens[t];if(n?.type!==`paragraph`)return null;let r=n,i=r.tokens,a=i[0];if(a?.type!==`text`)return null;let o=cf.exec(a.text);if(!o||!a.raw.startsWith(o[0]))return null;let s=sf(o[1]);if(!s)return null;let c=[],l=i.slice();for(l[0]=df(a,o[0].length);l.length>0;){let e=l[0];if(e.type===`br`){l.shift();break}if(e.type===`text`){let t=e.text.indexOf(`
|
|
67
|
-
`);if(t<0){c.push(l.shift());continue}c.push(df(e,0,t)),l[0]=df(e,t+1);break}if(e.raw.includes(`
|
|
68
|
-
`))break;c.push(l.shift())}ff(c),ff(l);let u=e.tokens.slice(t+1);if(l.length>0){let e=l.map(e=>e.raw).join(``);u.unshift({...r,raw:e,text:e,tokens:l})}return{type:`callout`,raw:e.raw,kind:s,titleTokens:pf(c),tokens:u}}function df(e,t,n){return{...e,raw:e.raw.slice(t,n),text:e.text.slice(t,n)}}function ff(e){for(let[t,n]of[[0,`trimStart`],[-1,`trimEnd`]])for(let r=e.at(t);r?.type===`text`;r=e.at(t)){let i=r,a={...i,raw:i.raw[n](),text:i.text[n]()};if(e.splice(t,1,...a.raw?[a]:[]),a.raw)break}}function pf(e){return e.map(e=>{if(e.type===`html`)return{type:`text`,raw:e.raw,text:e.raw,escaped:!1};let t=e.tokens;return Array.isArray(t)?{...e,tokens:pf(t)}:e})}var mf={name:`callout`,level:`block`,childTokens:[`titleTokens`,`tokens`],tokenizer(){},renderer(e){let{kind:t,titleTokens:n,tokens:r}=e;return`<blockquote class="${nf} ${nf}-${t}"><p class="${rf}">${n.length>0?this.parser.parseInline(n):af[t]}</p>\n${this.parser.parse(r)}</blockquote>\n`}},X=cn();function hf({caption:e,children:t}){return(0,X.jsxs)(`figure`,{className:gf,children:[(0,X.jsx)(`div`,{className:_f,children:t}),e]})}var gf=`frizz-image-frame max-w-full`,_f=`flex justify-center bg-panel-2 p-1.5`,vf=`block max-h-[420px] max-w-full w-auto rounded-md object-contain`,yf=/^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,bf={del(e){let t=yf.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}},xf=/^:?-+:?$/,Sf=/^ {0,3}$/,Cf=/^[ \t]*$/;function wf(e){let t=[],n=``;for(let r=0;r<e.length;r++){let i=e[r];i===`\\`&&r+1<e.length?(n+=i+e[r+1],r++):i===`|`?(t.push(n),n=``):n+=i}return t.push(n),t.length<4||!Sf.test(t[0])||!Cf.test(t.at(-1))?null:t.slice(1,-1).map(e=>e.trim())}function Tf(e){let t=[],n=0;for(let r of e.split(`
|
|
69
|
-
`)){let e=wf(r);if(!e)break;if(e.every(e=>xf.test(e)))return null;t.push(e),n+=r.length+1}return t.length<2?null:{raw:e.slice(0,Math.min(n,e.length)),rows:t}}var Ef={name:`headerlessTable`,level:`block`,start(e){let t=0;for(let n of e.split(`
|
|
70
|
-
`)){if(n.includes(`|`)&&Tf(e.slice(t)))return t;t+=n.length+1}},tokenizer(e){let t=Tf(e);if(!t)return;let n=Math.max(...t.rows.map(e=>e.length)),r=t.rows.map(e=>Array.from({length:n},(t,n)=>({tokens:this.lexer.inline(e[n]??``)})));return{type:`headerlessTable`,raw:t.raw,rows:r}},renderer(e){return`<table>\n<tbody>${e.rows.map(e=>`<tr>${e.map(e=>`<td>${this.parser.parseInline(e.tokens)}</td>`).join(``)}</tr>`).join(`
|
|
71
|
-
`)}</tbody></table>\n`}},Df=/^\[([ xX/\-?])\](?:[ \t]+|[ \t]*$)/,Of={" ":{className:``,label:`To do`},x:{className:`md-task-checked`,label:`Done`},"/":{className:`md-task-in-progress`,label:`In progress`},"-":{className:`md-task-cancelled`,label:`Cancelled`},"?":{className:`md-task-blocked`,label:`Blocked`}},kf={name:`frizzTaskStatus`,level:`inline`,tokenizer(){},renderer(e){let{status:t}=e,n=Of[t];return`<span class="md-task${n.className?` ${n.className}`:``}" title="${n.label}"></span>`}},Af={name:`frizzTaskText`,level:`inline`,tokenizer(){},renderer(e){return`<span class="md-task-text">${this.parser.parseInline(e.tokens)}</span>`}};function jf(e){let t=e.tokens[0],n=t&&`tokens`in t?t.tokens:void 0;if(!Array.isArray(n)||n[0]?.type===`frizzTaskStatus`)return;let r,i;if(e.task)r=e.checked?`x`:` `,i=``,e.task=!1,e.checked=void 0;else{let t=Df.exec(e.text);if(!t)return;let a=t[0].length,o=[];for(let e=0;e<n.length&&a>0;e++){let t=n[e];if(t.type!==`text`)return;let r=Math.min(a,t.raw.length);o.push({token:t,count:r}),a-=r}if(a>0)return;for(let{token:e,count:t}of o)e.raw=e.raw.slice(t),e.text=e.text.slice(t);for(let e=n.length-1;e>=0;e--)n[e].type===`text`&&!n[e].raw&&n.splice(e,1);e.text=e.text.slice(t[0].length),r=t[1]===`X`?`x`:t[1],i=t[0]}let a=n.splice(0,n.length);n.push({type:`frizzTaskStatus`,raw:i,status:r}),a.length&&n.push({type:`frizzTaskText`,raw:``,tokens:a})}var Mf={breaks:!0,extensions:[Ef,kf,Af,Yd,mf],tokenizer:bf,hooks:{processAllTokens(e){return tf(e),Gn(e),Dr(e),lf(e),e}},walkTokens(e){e.type===`list_item`&&jf(e)},renderer:{code:e=>Jd([{info:e.lang??``,text:e.text,closed:as(e)}]),blockquote:wa}},Nf=new ru(Mf),Pf=new ru({...Mf,breaks:!1});function Ff(e,t){if(!e.trim())return``;let{result:n,quotes:r}=Xo(()=>$n(t?.githubRepo,()=>t?.document?Vd(()=>Pf.parse(e,{async:!1})):Nf.parse(e,{async:!1})));return Jf(n,{block:!0,baseDir:t?.baseDir,homeDir:t?.homeDir,project:t?.project,quotes:r})}function If(e,t){if(!e.trim())return``;let{baseDir:n,homeDir:r,project:i,githubRepo:a}=t??{};return Jf($n(a,()=>Nf.parseInline(e,{async:!1})),{baseDir:n,homeDir:r,project:i})}function Lf(e){let t=e.match(/^?---\r?\n[\s\S]*?\r?\n---\r?\n?/);return t?e.slice(t[0].length):e}var Rf=new Set(`h1.h2.h3.h4.h5.h6.p.br.hr.strong.em.del.code.pre.blockquote.ul.ol.li.a.img.button.table.thead.tbody.tr.th.td.span.details.summary.kbd.sub.sup.mark`.split(`.`)),zf=new Set([`href`,`src`,`alt`,`title`,`type`]),Bf=RegExp(`^(?:hljs(?:-[a-z0-9_-]+)?|ansi-[a-z-]+|language-[a-z0-9-]+|md-task(?:-(?:checked|in-progress|cancelled|blocked|text))?|md-diff-(?:row|add|del|ctx|hunk|file|meta|num|sign|text|stat|adds|dels)|${[Ss,Id,oo,wi,Ni,Ad,jd].join(`|`)})$`),Vf=(...e)=>RegExp(`^(?:${e.join(`|`)})$`),Hf={code:Bf,span:Bf,pre:Vf(si,Na,Ld,Rd,`md-diff-titled`,`md-diff-n[1-6]`,Zi,Ha),button:Vf(hn,wo,Hi,Na),blockquote:Vf(nf,`${nf}-[a-z]+`),p:Vf(rf)};function Uf(e,t,n){let r=Hf[e];return t.split(/\s+/).filter(t=>r?.test(t)||e===`blockquote`&&Qr(t,n)!==void 0).join(` `)}var Wf=new Set([`http:`,`https:`,`mailto:`]);function Gf(e){try{return Wf.has(new URL(e,`http://frizz.invalid/`).protocol)}catch{return!1}}var Kf={details:{open:/^[^]*$/},ol:{start:/^\d{1,9}$/},span:{style:Ku,role:/^tablist$/,"data-line":/^\d{1,9}$/},button:{role:/^tab$/,"aria-selected":/^(?:true|false)$/,"aria-expanded":/^(?:true|false)$/},pre:{role:/^tabpanel$/},th:{align:/^(?:left|center|right)$/},td:{align:/^(?:left|center|right)$/}},qf=new Set([`script`,`style`,`textarea`,`title`,`xmp`,`iframe`,`frame`,`frameset`,`object`,`embed`,`applet`,`noscript`,`template`,`svg`,`math`]);function Jf(e,{block:t=!1,baseDir:n,homeDir:r,project:i,quotes:a}={}){let o=document.createElement(`template`);return o.innerHTML=e,Yf(o.content,{block:t,baseDir:n,homeDir:r,project:i,quotes:a}),o.innerHTML}function Yf(e,t){let{block:n}=t;for(let r of Array.from(e.children)){let e=r.tagName.toLowerCase();if(!Rf.has(e)){qf.has(e)?r.remove():Qf(r,t);continue}(e===`a`||e===`img`)&&Xf(r,e===`a`?`href`:`src`,t);let i;if(e===`a`){let e=Ur(r.getAttribute(`href`),void 0,t.project);e&&r.setAttribute(`href`,e);let n=Ua(r.getAttribute(`href`));if(n){let e=Uo(n);if(e)r.setAttribute(`href`,e),r.setAttribute(`title`,n.display),i=n.filePath;else{let e=n.filePath&&xr(n.filePath),i=document.createElement(`button`);for(i.type=`button`,i.className=`local-file-action`,i.title=e?`Read ${n.display}`:n.display,n.filePath&&i.setAttribute(`data-local-path`,n.filePath);r.firstChild;)i.append(r.firstChild);r.replaceWith(i),Yf(i,t);continue}}}if(e===`img`){let e=Ua(r.getAttribute(`src`)),t=e&&Uo(e);if(!t){r.remove();continue}r.setAttribute(`src`,t),r.setAttribute(`title`,e.display),i=e.filePath,r.getAttribute(`alt`)||r.setAttribute(`alt`,e.display)}for(let n of Array.from(r.attributes)){let i=n.name.toLowerCase();if(i===`class`){let i=Uf(e,n.value,t.quotes);i?r.setAttribute(`class`,i):r.removeAttribute(n.name);continue}let a=Kf[e]?.[i];if(a){a.test(n.value)||r.removeAttribute(n.name);continue}if(!zf.has(i)){r.removeAttribute(n.name);continue}i===`href`&&!Gf(n.value)&&r.removeAttribute(n.name)}if(i!==void 0&&(r.setAttribute(`data-local-path`,i),r.setAttribute(`data-local-image`,`true`)),e===`img`&&n&&Zf(r),e===`a`){r.setAttribute(`target`,`_blank`),r.setAttribute(`rel`,`noopener noreferrer`),r.removeAttribute(`data-gh-ref`);let e=Gs(r.getAttribute(`href`));e&&r.setAttribute(`data-gh-ref`,e)}if(Yf(r,t),e===`details`&&Ho(r),e===`blockquote`){let e=Qr(r.getAttribute(`class`)??``,t.quotes);e!==void 0&&No(r,e)}}}function Xf(e,t,{baseDir:n,homeDir:r}){if(!n&&!r)return;let i=To(e.getAttribute(t),n??``,r);i&&e.setAttribute(t,i)}function Zf(e){let t=e.ownerDocument,n=t.createElement(`span`);n.className=`${gf} md-image-frame`;let r=t.createElement(`span`);r.className=_f,e.replaceWith(n),n.append(r),r.append(e),e.setAttribute(`class`,vf)}function Qf(e,t){let n=e.ownerDocument.createDocumentFragment();for(;e.firstChild;)n.append(e.firstChild);Yf(n,t),e.replaceWith(n)}function $f(){let e=Do(),t=(0,q.useCallback)(()=>C(e),[e]);return(0,q.useSyncExternalStore)(In,t,t)}function ep(){let e=Do(),t=(0,q.useCallback)(()=>bt(e),[e]);return(0,q.useSyncExternalStore)(kt,t,t)}function tp(e,t){let n=$f(),r=ep(),i=Do(),{baseDir:a,asDocument:o}=t??{},s=a??r.dir,c=(0,q.useMemo)(()=>Ff(e,{baseDir:s,homeDir:r.home,document:o,project:i,githubRepo:n}),[e,s,r.home,o,i,n]);return np(c),c}function np(e){let t=(0,q.useMemo)(()=>qt(e),[e]);(0,q.useEffect)(()=>{t.length>0&&ge(t)},[t])}function rp(e){let t=$f(),n=ep(),r=Do(),i=(0,q.useMemo)(()=>If(e,{baseDir:n.dir,homeDir:n.home,project:r,githubRepo:t}),[e,n.dir,n.home,r,t]);return np(i),i}var ip=e=>new Set(e.split(/\s+/).filter(Boolean)),ap=ip(`
|
|
72
|
-
break case catch class const continue debugger default delete do else enum export extends
|
|
73
|
-
false finally for function if import in instanceof new null return super switch this throw
|
|
74
|
-
true try typeof var void while with yield async await let static get set of as from
|
|
75
|
-
interface type namespace declare readonly public private protected implements abstract
|
|
76
|
-
package struct func go defer chan map fn impl trait mut pub use mod match loop where
|
|
77
|
-
int long short float double char boolean byte final synchronized volatile transient native
|
|
78
|
-
`),op=ip(`
|
|
79
|
-
string number boolean object symbol bigint unknown any never void undefined
|
|
80
|
-
String Number Boolean Object Array Promise Map Set Record Partial
|
|
81
|
-
i8 i16 i32 i64 u8 u16 u32 u64 usize isize f32 f64 str Vec Option Result Box
|
|
82
|
-
int8 int16 int32 int64 uint float32 float64 error rune
|
|
83
|
-
`),sp={typescript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:ap,types:op},javascript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:ap,types:op},go:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:ap,types:op},rust:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:ap,types:op},java:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:ap,types:op},c:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:ap,types:op},cpp:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:ap,types:op},css:{line:null,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:ip(`important media supports keyframes import from to`),types:new Set},json:{line:null,block:null,quotes:[`"`],keywords:ip(`true false null`),types:new Set},python:{line:`#`,block:null,quotes:[`"`,`'`],keywords:ip(`
|
|
84
|
-
def class return if elif else for while break continue pass import from as with try except
|
|
85
|
-
finally raise lambda yield global nonlocal del assert async await and or not in is None True
|
|
86
|
-
False self lambda`),types:ip(`int float str bool list dict set tuple bytes object`)},shell:{line:`#`,block:null,quotes:[`"`,`'`],keywords:ip(`if then else elif fi for while do done case esac in function return export local echo cd exit set unset source`),types:new Set},yaml:{line:`#`,block:null,quotes:[`"`,`'`],keywords:ip(`true false null yes no on off ~`),types:new Set,lineStart:[{re:/^([ \t]*)(- +)?("[^"\n]*"|'[^'\n]*'|[A-Za-z_][\w.\-/]*)([ \t]*)(:)/,kinds:[`plain`,`punct`,`key`,`plain`,`punct`]}]},toml:{line:`#`,block:null,quotes:[`"`,`'`],keywords:ip(`true false`),types:new Set,keyChars:`=`,lineStart:[{re:/^([ \t]*)(\[\[?[^\]\n]*\]\]?)/,kinds:[`plain`,`fn`]}]},html:{line:null,block:[`<!--`,`-->`],quotes:[`"`,`'`],keywords:new Set,types:new Set,keyChars:`=`,tagNames:!0}},cp=(e,t)=>{let n=e.indexOf(`
|
|
87
|
-
`,t);return n===-1?e.length:n},lp=(e,t)=>{let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;return e[n]??``},up=new Set(Object.keys(sp)),dp=e=>/[A-Za-z_$]/.test(e),fp=e=>/[A-Za-z0-9_$]/.test(e),pp=e=>e>=`0`&&e<=`9`,mp=new Set(`{}()[];,.`),hp=new Set(`+-*/%=<>!&|^~?:@`);function gp(e,t){let n=[],r=e.length,i=(e,t)=>e&&n.push({text:e,kind:t}),a=0;for(;a<r;){let n=e[a];if(t.lineStart&&(a===0||e[a-1]===`
|
|
88
|
-
`)){let n=!1;for(let r of t.lineStart){let t=r.re.exec(e.slice(a,cp(e,a)));if(t){for(let e=1;e<t.length;e++)i(t[e]??``,r.kinds[e-1]??`plain`);a+=t[0].length,n=!0;break}}if(n)continue}if(t.block&&e.startsWith(t.block[0],a)){let n=e.indexOf(t.block[1],a+t.block[0].length),o=n===-1?r:n+t.block[1].length;i(e.slice(a,o),`com`),a=o;continue}if(t.line&&e.startsWith(t.line,a)){let t=e.indexOf(`
|
|
89
|
-
`,a);t===-1&&(t=r),i(e.slice(a,t),`com`),a=t;continue}if(t.quotes.includes(n)){let t=n==="`",o=a+1;for(;o<r;){if(e[o]===`\\`){o+=2;continue}if(e[o]===n){o++;break}if(e[o]===`
|
|
90
|
-
`&&!t)break;o++}i(e.slice(a,o),`str`),a=o;continue}if(pp(n)){let t=a+1;for(;t<r&&/[0-9a-fA-FxXbBoO_.]/.test(e[t]);)t++;i(e.slice(a,t),`num`),a=t;continue}if(dp(n)){let n=a+1;for(;n<r&&fp(e[n]);)n++;let o=e.slice(a,n);i(o,t.keywords.has(o)?`kw`:t.types.has(o)?`type`:t.tagNames&&(e[a-1]===`<`||e[a-1]===`/`&&e[a-2]===`<`)?`kw`:t.keyChars&&t.keyChars.includes(lp(e,n))?`key`:e[n]===`(`?`fn`:`plain`),a=n;continue}if(mp.has(n)){i(n,`punct`),a++;continue}if(hp.has(n)){let t=a+1;for(;t<r&&hp.has(e[t]);)t++;i(e.slice(a,t),`op`),a=t;continue}let o=a+1;for(;o<r&&!dp(e[o])&&!pp(e[o])&&!t.quotes.includes(e[o])&&!mp.has(e[o])&&!hp.has(e[o])&&!(t.line&&e.startsWith(t.line,o));)o++;i(e.slice(a,o),`plain`),a=o}return n}function _p(e){let t=[[]];for(let n of e){let e=n.text.split(`
|
|
91
|
-
`);for(let r=0;r<e.length;r++)r>0&&t.push([]),e[r]&&t[t.length-1].push({text:e[r],kind:n.kind})}return t}function vp(e,t){if(e===``)return[];let n=sp[t];return n?_p(gp(e,n)):e.split(`
|
|
92
|
-
`).map(e=>e?[{text:e,kind:`plain`}]:[])}var yp={".ts":`typescript`,".tsx":`typescript`,".mts":`typescript`,".cts":`typescript`,".js":`javascript`,".jsx":`javascript`,".mjs":`javascript`,".cjs":`javascript`,".json":`json`,".jsonc":`json`,".css":`css`,".scss":`css`,".less":`css`,".py":`python`,".go":`go`,".rs":`rust`,".java":`java`,".c":`c`,".h":`c`,".cpp":`cpp`,".hpp":`cpp`,".cc":`cpp`,".sh":`shell`,".bash":`shell`,".zsh":`shell`,".yaml":`yaml`,".yml":`yaml`,".toml":`toml`,".html":`html`,".htm":`html`,".xml":`html`,".svg":`html`},bp={Dockerfile:`shell`,Makefile:`shell`,".gitignore":`shell`,".env":`shell`,".bashrc":`shell`,".zshrc":`shell`};function xp(e){let t=Rt(e),n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=bp[t]??yp[r]??`text`;return up.has(i)?i:`text`}function Sp(e,t,n){let r=e.length,i=t.length,a=Array.from({length:r+1},()=>new Uint32Array(i+1));for(let n=r-1;n>=0;n--)for(let r=i-1;r>=0;r--)a[n][r]=e[n]===t[r]?a[n+1][r+1]+1:Math.max(a[n+1][r],a[n][r+1]);let o=[],s=0,c=0;for(;s<r&&c<i;)e[s]===t[c]?(o.push({type:`eq`,a:n+s,b:n+c}),s++,c++):a[s+1][c]>=a[s][c+1]?(o.push({type:`del`,a:n+s,b:null}),s++):(o.push({type:`add`,a:null,b:n+c}),c++);for(;s<r;)o.push({type:`del`,a:n+s++,b:null});for(;c<i;)o.push({type:`add`,a:null,b:n+c++});return o}function Cp(e,t){let n=e.length,r=t.length,i=0;for(;i<n&&i<r&&e[i]===t[i];)i++;let a=0;for(;a<n-i&&a<r-i&&e[n-1-a]===t[r-1-a];)a++;let o=[];for(let e=0;e<i;e++)o.push({type:`eq`,a:e,b:e});o.push(...Sp(e.slice(i,n-a),t.slice(i,r-a),i));for(let e=0;e<a;e++)o.push({type:`eq`,a:n-a+e,b:r-a+e});return o}var wp=3,Tp=e=>e===``?[]:e.split(`
|
|
93
|
-
`);function Ep(e,t,n){return e.type===`del`?{type:`del`,oldLine:e.a+1,newLine:null,tokens:t[e.a]??[]}:e.type===`add`?{type:`add`,oldLine:null,newLine:e.b+1,tokens:n[e.b]??[]}:{type:`context`,oldLine:e.a+1,newLine:e.b+1,tokens:n[e.b]??[]}}function Dp(e){let t=[];for(let n=0;n<e.length;n++)e[n].type!==`context`&&t.push(n);if(t.length===0)return{hunks:[],collapsedAfter:e.length};let n=[],r=Math.max(0,t[0]-wp),i=-1;for(let a=0;a<t.length;a++){let o=t[a],s=t[a+1];i=Math.min(e.length-1,o+wp),!(s!==void 0&&s-o<=7)&&(n.push({collapsedBefore:r,lines:e.slice(r,i+1)}),s!==void 0&&(r=Math.max(i+1,s-wp)))}let a=n.length?n[n.length-1].collapsedBefore+n[n.length-1].lines.length:0;return{hunks:n,collapsedAfter:Math.max(0,e.length-a)}}function Op(e,t,n){let r=xp(n),i=vp(e,r),a=vp(t,r),o=Tp(e),s=Tp(t),c=e===``?`added`:t===``?`deleted`:`modified`;if(c===`added`){let e=s.map((e,t)=>({type:`add`,oldLine:null,newLine:t+1,tokens:a[t]??[]}));return{file:n,lang:r,status:c,hunks:[{collapsedBefore:0,lines:e}],collapsedAfter:0,additions:e.length,deletions:0}}if(c===`deleted`){let e=o.map((e,t)=>({type:`del`,oldLine:t+1,newLine:null,tokens:i[t]??[]}));return{file:n,lang:r,status:c,hunks:[{collapsedBefore:0,lines:e}],collapsedAfter:0,additions:0,deletions:e.length}}let l=Cp(o,s).map(e=>Ep(e,i,a)),u=l.filter(e=>e.type===`add`).length,d=l.filter(e=>e.type===`del`).length,{hunks:f,collapsedAfter:p}=Dp(l);return{file:n,lang:r,status:c,hunks:f,collapsedAfter:p,additions:u,deletions:d}}var kp=`flex min-w-0 items-baseline gap-2`,Ap=`flex shrink-0 items-baseline gap-2`;function jp(e){return e===`failed`||e===`cancelled`?e:void 0}function Mp(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`))+1;return{dir:e.slice(0,t),base:e.slice(t)}}var Np=`a, button, input, select, textarea, summary, label, [role="button"], [role="link"]`;function Pp(e){let t=e;return typeof t?.closest==`function`&&t.closest(Np)!=null}function Fp({children:e,className:t,controls:n,expanded:r,label:i,meta:a,onToggle:o}){function s(e){if(Pp(e.target))return;let t=typeof window>`u`?null:window.getSelection();t&&!t.isCollapsed&&t.toString().trim()!==``||o()}return(0,q.createElement)(`div`,{className:`${t} w-full cursor-pointer text-left`,"data-expanded":r,onClick:s},(0,q.createElement)(`span`,{className:kp},e),(0,q.createElement)(`span`,{className:Ap},a,(0,q.createElement)(`button`,{type:`button`,"data-tool-disclosure":!0,"aria-controls":n,"aria-expanded":r,"aria-label":i,title:i,onClick:o,className:`-my-1 -ml-1 inline-flex shrink-0 items-center justify-center rounded py-1 pl-1 text-muted outline-none transition-colors hover:text-fg/80 focus-visible:ring-1 focus-visible:ring-focus-ink-60`},(0,q.createElement)(br,{"aria-hidden":!0,size:12,className:`frizz-tool-chevron${r?` rotate-90`:``}`}))))}function Ip(e){let t=W.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function Lp({path:e}){let{dir:t,base:n}=Mp(e);return(0,X.jsxs)(`span`,{className:`frizz-tool-path`,children:[t&&(0,X.jsx)(`span`,{className:`frizz-tool-path-dir`,children:t}),(0,X.jsx)(`span`,{className:`frizz-tool-path-base`,children:n})]})}function Rp({open:e=!1,shown:t=!0}){return t?(0,X.jsx)(br,{"aria-hidden":`true`,size:12,className:`frizz-tool-chevron${e?` rotate-90`:``}`}):(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`w-3 shrink-0`})}function zp({path:e,className:t=``,children:n}){return(0,X.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),I(e)},title:e,className:`font-mono-keep block max-w-full cursor-pointer truncate text-left hover:underline hover:text-fg/80 ${t}`,children:n??e})}function Bp({edits:e,meta:t}){let n=(0,q.useId)(),r=e[0].file,i=(0,q.useMemo)(()=>e.map(e=>Op(e.old,e.new,e.file)),[e]),a=i.reduce((e,t)=>e+t.additions,0),o=i.reduce((e,t)=>e+t.deletions,0),[s,c]=(0,q.useState)(!1);return(0,X.jsxs)(`div`,{className:`frizz-diff`,"data-tool-node":`edit`,children:[(0,X.jsxs)(Fp,{className:`frizz-diff-header`,controls:n,expanded:s,label:`${s?`Collapse`:`Expand`} Edit diff: ${r}`,onToggle:()=>c(!s),meta:t,children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:`Edit`}),(0,X.jsx)(`span`,{className:`frizz-diff-file`,children:(0,X.jsx)(zp,{path:r,children:(0,X.jsx)(Lp,{path:Ip(r)})})}),(a>0||o>0)&&(0,X.jsxs)(`span`,{className:`frizz-diff-stat`,children:[a>0&&(0,X.jsxs)(`span`,{className:`frizz-diff-add`,children:[`+`,a]}),a>0&&o>0&&` `,o>0&&(0,X.jsxs)(`span`,{className:`frizz-diff-del`,children:[`−`,o]})]})]}),(0,X.jsx)(`div`,{id:n,className:`frizz-tool-body frizz-diff-body`,hidden:!s,children:s&&i.map((e,t)=>(0,X.jsx)(`div`,{className:t>0?`frizz-diff-editsep`:void 0,children:(0,X.jsx)(Vp,{hunks:e.hunks,collapsedAfter:e.collapsedAfter})},t))})]})}function Vp({hunks:e,collapsedAfter:t}){let n=0,r=[];return e.forEach((e,t)=>{let i=e.collapsedBefore-n;i>0&&r.push((0,X.jsx)(Hp,{n:i},`s${t}`));for(let n of e.lines){let e=n.type===`del`?n.oldLine:n.newLine,i=n.type===`add`?`+`:n.type===`del`?`-`:` `;r.push((0,X.jsxs)(`div`,{className:`frizz-diff-line`,"data-type":n.type,children:[(0,X.jsx)(`span`,{className:`frizz-diff-gutter`,children:e}),(0,X.jsx)(`span`,{className:`frizz-diff-sign`,children:i}),(0,X.jsx)(`span`,{className:`frizz-diff-code`,children:n.tokens.map((e,t)=>(0,X.jsx)(`span`,{className:`ftk-${e.kind}`,children:e.text},t))})]},`${t}:${n.oldLine}:${n.newLine}`))}n=e.collapsedBefore+e.lines.length}),t>0&&r.push((0,X.jsx)(Hp,{n:t},`safter`)),(0,X.jsx)(X.Fragment,{children:r})}function Hp({n:e}){return(0,X.jsxs)(`div`,{className:`frizz-diff-sep`,children:[e,` unchanged line`,e===1?``:`s`]})}function Up(e){return(0,q.useMemo)(()=>({__html:e}),[e])}var Wp=/^[\w.@+-]+\.[a-z][a-z0-9]{0,7}$/i,Gp=/^(?:[A-Za-z]:\\|\\\\)?[\w.@+~-]+(?:\\[\w.@+~-]+)*(?::\d+(?::\d+)?)?$/;function Kp(e){let t=e.trim();return!t||t.length>1024||/\s/.test(t)||/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?!1:t===`~`||t.startsWith(`~/`)||t.startsWith(`/`)||t.includes(`/`)||t.includes(`\\`)&&Gp.test(t)?!0:Wp.test(t)}var qp=/^(?:~(?:[\\/]|$)|\/|[A-Za-z]:[\\/]|\\\\)/;function Jp(e,t){return e?{key:`project:${e}`,apiFor:()=>dt(e)}:jo(t)?{key:`console`,apiFor:e=>qp.test(e)?Qi(e):null}:{key:`page:${ai(t)??``}`,apiFor:()=>U}}var Yp=new Map,Xp=(e,t)=>`${e.key}\n${t}`;function Zp(e,t){return Yp.get(Xp(e,t))}var Qp=new Set,$p=0,em=new Set,tm=e=>(em.add(e),()=>{em.delete(e)}),nm=()=>$p,rm=128;async function im(e,t){let n=[...new Set(t)].filter(t=>!Yp.has(Xp(e,t))&&!Qp.has(Xp(e,t)));if(!n.length)return;for(let t of n)Qp.add(Xp(e,t));let r=new Map;for(let t of n){let n=e.apiFor(t);r.set(n,[...r.get(n)??[],t])}let i=[];for(let[e,t]of r)for(let n=0;n<t.length;n+=rm)i.push({api:e,paths:t.slice(n,n+rm)});let a=await Promise.all(i.map(async({api:e,paths:t})=>{try{if(!e)throw Error(`no project to resolve against`);return(await e.resolveLocalPaths({paths:t})).resolved}catch{return t.map(e=>({input:e,path:null}))}})),o=!1;for(let t of a)for(let n of t){let t=Xp(e,n.input);Yp.has(t)||(Yp.set(t,n.path),o=!0)}for(let t of n)Qp.delete(Xp(e,t));if(o){$p+=1;for(let e of em)e()}}function am(e,t){e.setAttribute(`data-local-path`,t),e.setAttribute(`title`,`Open ${t}`),e.classList.add(`local-file-code`)}function om(e,t){let n=(0,q.useSyncExternalStore)(tm,nm,nm),r=Do();(0,q.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=Jp(r),i=[];for(let e of t.querySelectorAll(`code`)){if(e.closest(`pre`)||e.closest(`a, [data-local-path]`))continue;let t=(e.textContent??``).trim();if(!Kp(t))continue;let r=Zp(n,t);r===void 0?i.push(t):r&&am(e,r)}i.length&&im(n,i)},[e,t,n,r])}var sm=0;function cm(e,t,n,r,i){let[a,o]=(0,q.useState)([]),s=(0,q.useRef)(null);return(0,q.useLayoutEffect)(()=>{let c=e.current;if(s.current&&s.current.root===c&&s.current.html===t)return;s.current={root:c,html:t};let l=[...a],u=[];for(let e of c?.querySelectorAll(`pre > code.language-${n}`)??[]){let t=e.closest(`.md-code`)??e.parentElement,a=e.textContent??``,o=l.findIndex(e=>e.body===a),s;if(o>=0)s=l.splice(o,1)[0];else{let e=document.createElement(`div`);e.className=r,s={key:`${n}-${++sm}`,host:e,body:a,value:i(a)}}t.replaceWith(s.host),u.push(s)}o(e=>e.length===0&&u.length===0?e:u)}),a}var lm=`[overflow-wrap:anywhere]`,um=`rounded-xl`,dm=`rounded-t-xl`,fm=`rounded-b-[calc(var(--block-radius)_-_1px)]`,pm={neutral:{border:`border-border-strong`,head:`text-fg`},attention:{border:`border-accent/45`,head:`text-accent`},caution:{border:`border-border-strong`,head:`text-attention`},risk:{border:`border-border-strong`,head:`text-danger`},danger:{border:`border-danger-fill/45`,head:`text-danger`}},mm=`card-icon-offset`;function hm(e,t){let n=(0,q.useRef)(null);return(0,q.useLayoutEffect)(()=>{let e=n.current;if(!e||typeof e.getBBox!=`function`)return;let r=e.getBBox(),i=e.viewBox.baseVal;if(!i||i.width===0||r.width===0)return;let a=Number(e.getAttribute(`stroke-width`))||0;if(t!==void 0&&r.height>0){let n=e.width.baseVal.value,o=a*n/i.width,s=e=>r.height*e/i.height+o,c=n;for(;s(c+2)<=t;)c+=2;let l=c>n;e.style.width=e.style.height=l?`${c}px`:``,e.style.marginBlock=l?`${(n-c)/2}px`:``,l&&(a=o*i.width/c),e.style.strokeWidth=l?String(a):``}let o=e.getBoundingClientRect().width/i.width,s=a/2;e.style.marginLeft=`${-Math.max(0,r.x-s-i.x)*o}px`,e.style.marginRight=`${-Math.max(0,i.x+i.width-(r.x+r.width)-s)*o}px`},[e,t]),n}function gm({icon:e,className:t}){return(0,X.jsx)(e,{ref:hm(e),"aria-hidden":`true`,size:16,className:`shrink-0 ${mm} ${t}`})}function _m({icon:e,label:t,head:n=pm.neutral.head,aside:r}){return(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[e&&(0,X.jsx)(gm,{icon:e,className:n}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 text-[16px] font-semibold leading-6 tracking-tight ${n}`,children:t}),r&&(0,X.jsx)(`span`,{className:`shrink-0 leading-6`,children:r})]})}var vm=`flex min-w-0 items-center gap-[5px] text-[12px] font-medium leading-4`,ym=12,bm=ym*22/24;function xm({icon:e,children:t,className:n=`text-muted`,evenInk:r=!1}){let i=hm(e,r?bm:void 0);return(0,X.jsxs)(`span`,{"data-card-kind":!0,className:`${vm} ${n}`,children:[e&&(0,X.jsx)(e,{ref:i,"aria-hidden":`true`,size:ym,className:`shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0`,children:t})]})}function Sm({icon:e,kind:t,kindClass:n,label:r,head:i,aside:a,ruled:o,evenInk:s}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(xm,{icon:e,className:n,evenInk:s,children:t}),a&&(0,X.jsx)(`span`,{className:`ml-auto flex shrink-0 items-center [--card-icon-offset:0px]`,children:a})]}),r!=null&&r!==!1&&(0,X.jsx)(`div`,{"data-card-title":!0,className:`min-w-0 text-[16px] font-semibold leading-6 tracking-tight ${i}`,children:r})]}),o&&(0,X.jsx)(`div`,{"aria-hidden":!0,"data-card-rule":!0,className:`-mx-4 mt-3.5 border-t border-border`})]})}function Cm({children:e,gap:t=`plain`}){return(0,X.jsx)(`div`,{className:`card-md ${t===`ruled`?`mt-3`:t===`band`?`mt-3.5`:`mt-1`} min-w-0 text-fg/75`,children:e})}function wm({tone:e=`neutral`,icon:t,kind:n,label:r,ruled:i,aside:a,children:o,className:s=``,surface:c=`inset`,...l}){let{border:u,head:d}=pm[e],f=n!=null&&(i??o!=null);return(0,X.jsxs)(`div`,{...l,className:`min-w-0 ${um} border ${c===`question`?`border-question-border bg-question`:`${u} bg-panel-2`} p-4 ${s}`,children:[n==null?(0,X.jsx)(_m,{icon:t,label:r,head:d,aside:a}):(0,X.jsx)(Sm,{icon:t,kind:n,kindClass:e===`neutral`?`text-muted`:d,label:r,head:e===`neutral`?d:pm.neutral.head,aside:a,ruled:f,evenInk:c===`question`}),o!=null&&(0,X.jsx)(Cm,{gap:n==null?`plain`:f?`ruled`:`band`,children:o})]})}var Tm=`block min-w-0 text-[13px] leading-5 text-fg/75`;function Em({children:e,className:t=``,...n}){return(0,X.jsx)(`div`,{...n,"data-card-actions":!0,className:`-mx-4 -mb-4 mt-3 flex flex-wrap items-center justify-start gap-x-2.5 gap-y-2 border-t border-border bg-fg/[0.03] px-4 py-2.5 ${fm} ${t}`,children:e})}var Dm=`min-w-0 flex-1 text-[11px] leading-snug text-muted-70`,Om=`text-accent underline underline-offset-2 decoration-accent/40 hover:decoration-accent`,km=`bg-fg px-2.5 py-1 text-bg hover:opacity-90`,Am=`rounded-md`,jm=`flex shrink-0 items-center gap-1 ${Am} text-[11px] font-medium outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${km}`;function Mm(e,t){let n=Promise.resolve();function r(r){let i={...r,palette:{...r.palette}},a=n.then(async()=>{try{return await e(i)}finally{t(i.id)}});return n=a.then(()=>void 0,()=>void 0),a}return{enqueue:r}}var Nm=e=>new Promise(t=>setTimeout(t,e));function Pm(e,{retryAfterMs:t=800,wait:n=Nm}={}){let r;return()=>(r??=e().catch(()=>n(t).then(e)).catch(e=>{throw r=void 0,e}),r)}function Fm(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function Im(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function Lm(e,t){let n=Fm(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function Rm({directive:e,icon:t,title:n,meta:r,children:i}){return(0,X.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${um} border border-border bg-panel-2/75 p-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center text-muted`,"aria-hidden":!0,children:t}),(0,X.jsx)(`div`,{className:`max-w-[calc(100%-1.5rem)] shrink-0 break-words text-[12px] font-medium leading-4 text-fg`,children:n}),r&&(0,X.jsx)(`div`,{className:`min-w-0 truncate text-[11px] font-normal leading-4 text-muted`,children:r})]}),i]})}function zm({children:e,mono:t=!1}){return(0,X.jsx)(`div`,{className:`ml-6 mt-1 break-words text-[11px] leading-4 text-muted${t?` font-mono-keep`:``}`,children:e})}function Bm({directive:e}){let t=e.attrs,n=Fm(t,`display_name`)??Fm(t,`skill_name`)??`Artifact template`,r=Fm(t,`artifact_kind`),i=Fm(t,`skill_name`),a=Fm(t,`skill_directory`),[o,s]=(0,q.useState)(!!a);return(0,X.jsxs)(Rm,{directive:e,icon:(0,X.jsx)(pc,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,X.jsx)(zm,{mono:!0,children:i.startsWith(`$`)?i:`$${i}`}),o&&a&&(0,X.jsx)(`img`,{src:gi(`${a}/assets/preview.png`),alt:`${n} template preview`,loading:`lazy`,onError:()=>s(!1),className:`ml-6 mt-2 max-h-44 max-w-[calc(100%-1.5rem)] rounded-md border border-border object-contain`})]})}function Vm({directive:e}){let t=e.attrs,n=Fm(t,`file`),r=Im(t,`start`),i=Im(t,`end`)??r,a=Im(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,X.jsxs)(Rm,{directive:e,icon:(0,X.jsx)(vc,{size:15}),title:Fm(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[Fm(t,`body`)&&(0,X.jsx)(zm,{children:Fm(t,`body`)}),n?(0,X.jsx)(`button`,{type:`button`,className:`local-file-action ml-6 mt-1 max-w-[calc(100%-1.5rem)] break-all text-left font-mono-keep text-[11px] leading-4 text-accent underline decoration-dotted underline-offset-2`,"data-local-path":n,title:o,children:o}):(0,X.jsx)(zm,{mono:!0,children:o})]})}var Hm={"git-stage":[Sc,`Changes staged`],"git-commit":[Vn,`Commit created`],"git-create-branch":[uc,`Branch created`],"git-push":[Mc,`Branch pushed`],"git-create-pr":[sn,`Pull request created`]};function Um({directive:e}){let[t,n]=Hm[e.name],r=Fm(e.attrs,`branch`),i=Lm(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,X.jsx)(Rm,{directive:e,icon:(0,X.jsx)(t,{size:15}),title:i?(0,X.jsx)(`a`,{className:`text-accent underline underline-offset-2`,href:i,target:`_blank`,rel:`noopener noreferrer`,children:a}):a,meta:r&&(0,X.jsx)(`span`,{className:`font-mono-keep`,children:r})})}function Wm({directive:e}){let t=Fm(e.attrs,`threadId`),n=Fm(e.attrs,`pendingWorktreeId`);return(0,X.jsx)(Rm,{directive:e,icon:(0,X.jsx)(xc,{size:15}),title:n?`Thread setup queued`:`Thread created`,meta:(t||n)&&(0,X.jsx)(`span`,{className:`font-mono-keep`,children:t??n})})}function Gm({directive:e}){let t=Fm(e.attrs,`reason`);return(0,X.jsx)(Rm,{directive:e,icon:(0,X.jsx)(Xs,{size:15}),title:`Archive suggested`,meta:t})}function Km(e){if(typeof e!=`string`||!e)return;let t=e.match(/(?:^|;)INTERVAL=(\d+)(?:;|$)/)?.[1];return/(?:^|;)FREQ=HOURLY(?:;|$)/.test(e)?`Every ${t??`1`} hour${t===`1`||t===void 0?``:`s`}`:/(?:^|;)FREQ=WEEKLY(?:;|$)/.test(e)?`Weekly schedule`:`Custom schedule`}function qm({directive:e}){let t=e.attrs,n=Fm(t,`mode`),r=Fm(t,`name`)??`Automation`,i=Km(t.rrule),a=[r,n,Fm(t,`status`),i].filter(Boolean).join(` · `);return(0,X.jsx)(Rm,{directive:e,icon:(0,X.jsx)(ec,{size:15}),title:`Automation suggested`,meta:a,children:Fm(t,`prompt`)&&(0,X.jsx)(zm,{children:Fm(t,`prompt`)})})}function Jm({directive:e}){return e.name===`artifact-template`?(0,X.jsx)(Bm,{directive:e}):e.name===`code-comment`?(0,X.jsx)(Vm,{directive:e}):e.name.startsWith(`git-`)?(0,X.jsx)(Um,{directive:e}):e.name===`created-thread`?(0,X.jsx)(Wm,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,X.jsx)(Gm,{directive:e}):(0,X.jsx)(qm,{directive:e})}var Ym=0,Xm=Pm(()=>gn(async()=>{let{default:e}=await import(`./mermaid.core-BSdNmJCs.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24])).then(({default:e})=>e));function Zm(){let e=getComputedStyle(document.documentElement),t=t=>e.getPropertyValue(t).trim();return{background:t(`--color-panel-2`),primaryColor:t(`--color-panel-2`),primaryTextColor:t(`--color-fg`),primaryBorderColor:t(`--color-control-strong`),lineColor:t(`--color-muted`),secondaryColor:t(`--color-border`),tertiaryColor:t(`--color-bg`),fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`}}var Qm=Mm(async e=>{let t=await Xm();return t.initialize({startOnLoad:!1,securityLevel:`strict`,theme:e.resolved===`dark`?`dark`:`base`,themeVariables:e.palette}),t.render(e.id,e.source)},e=>document.getElementById(`d${e}`)?.remove());function $m({source:e}){let t=(0,q.useId)(),{resolved:n}=(0,q.useSyncExternalStore)(Ht,wt,wt),[r,i]=(0,q.useState)({}),a=(0,q.useRef)(0),o=Up(r.html??``);return(0,q.useEffect)(()=>{let r=!0,o=++a.current;if(i(e=>e.error?{html:e.html}:e),e.length>5e4)return i({error:`Diagram source exceeds the 50 KB rendering limit`}),()=>{r=!1};let s=`frizz-mermaid-${t.replace(/[^a-zA-Z0-9]/g,``)}-${++Ym}`;return Qm.enqueue({id:s,source:e,resolved:n,palette:Zm()}).then(({svg:e})=>{r&&a.current===o&&i({html:e})}).catch(e=>{if(!r||a.current!==o)return;let t=e instanceof Error?e.message.split(/\n| for text:/,1)[0]:`Unknown diagram error`;i({error:t.slice(0,240)})}),()=>{r=!1}},[t,n,e]),r.error?(0,X.jsxs)(`section`,{"data-mermaid-state":`error`,className:`${um} border border-border bg-panel-2/75 p-4`,children:[(0,X.jsx)(`div`,{className:`text-[12px] font-medium text-fg`,children:`Diagram unavailable`}),(0,X.jsx)(`div`,{className:`mt-1 text-[11px] text-muted`,children:r.error}),(0,X.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap rounded-md bg-bg p-2 font-mono-keep text-[11px] text-muted`,children:e})]}):r.html?(0,X.jsx)(`div`,{"data-mermaid-state":`ready`,className:`overflow-x-auto ${um} border border-border bg-panel-2/75 p-4 [&_svg]:mx-auto [&_svg]:h-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:o}):(0,X.jsx)(`div`,{"data-mermaid-state":`loading`,role:`status`,"aria-label":`Rendering diagram`,className:`h-24 animate-pulse ${um} bg-panel-2`})}var eh=e=>e.replace(/\n$/,``);function th(e,t){return cm(e,t,`mermaid`,`md-mermaid`,eh).map(({key:e,host:t,value:n})=>(0,Fc.createPortal)((0,X.jsx)($m,{source:n}),t,e))}function nh(e,t,n){let r=e.length;if(r===0||!(t>0))return[];let{gap:i,target:a,maxHeight:o,maxPerRow:s}=n,c=(t,n)=>{let r=0;for(let i=t;i<n;i++)r+=e[i];return r},l=(e,n)=>Math.max(0,t-i*(n-e-1))/c(e,n),u=Array(r+1).fill(1/0),d=Array(r+1).fill(0);u[0]=0;for(let e=1;e<=r;e++)for(let t=1;t<=Math.min(s,e);t++){let n=e-t,r=u[n]+(l(n,e)-a)**2;r<u[e]&&(u[e]=r,d[e]=n)}let f=[];for(let e=r;e>0;e=d[e]){let n=d[e],r=l(n,e),a=Math.min(r,o);f.unshift({start:n,end:e,height:a,width:a<r?a*c(n,e)+i*(e-n-1):t})}return f}var rh={scale:1,x:0,y:0},ih=(e,t,n)=>Math.min(Math.max(e,t),n);function ah(e,t,n,r,i){let a=t*n/2;return 2*a<=i-r?ih(0,r+a,i-a):ih(e,i-a,r+a)}function oh(e,t){let n=ih(e.scale,1,t.max);return n===1?rh:{scale:n,x:ah(e.x,t.width,n,t.left,t.right),y:ah(e.y,t.height,n,t.top,t.bottom)}}function sh(e,t,n,r){let i=ih(e.scale*t,1,r.max),a=i/e.scale;return oh({scale:i,x:n.x-(n.x-e.x)*a,y:n.y-(n.y-e.y)*a},r)}function ch(e,t,n,r){return oh({scale:e.scale,x:e.x+t,y:e.y+n},r)}function lh(e,t,n,r,i,a){let o=ih(e.scale*(i/Math.max(n,1)),1,a.max),s=o/e.scale;return oh({scale:o,x:r.x-(t.x-e.x)*s,y:r.y-(t.y-e.y)*s},a)}function uh(e,t){return ih(t/Math.max(e,1),2,4)}function dh(e,t){return ih(2*t/Math.max(e,1),4,12)}var fh=6,ph=420,mh=16/10,hh=.4,gh=3,_h=(e,t,n)=>Math.min(Math.max(e,t),n),vh=e=>_h(e/4,112,180);function yh({entries:e,baseDir:t,framed:n=!0}){let r=ep(),i=(0,q.useMemo)(()=>t?{...r,dir:t}:r,[r,t]),a=(0,q.useMemo)(()=>e.map(e=>{let t=N(e.target,i);return{entry:e,path:t,label:Os(e,t)}}),[e,i]),[o,s]=(0,q.useState)({}),[c,l]=(0,q.useState)({}),[u,d]=(0,q.useState)(null),f=wh(u),p=a.filter(e=>e.path!==null&&!c[e.path]),m=a.filter(e=>!p.includes(e)),h=e=>_h(o[e.path]||mh,hh,gh),g=nh(p.map(h),f,{gap:fh,target:vh(f),maxHeight:ph,maxPerRow:8}),_=a.some(e=>e.entry.caption),v=p.map(e=>Xr(e.entry,e.path));if(p.length===0)return(0,X.jsx)(`div`,{"data-lightbox-gallery":!0,className:`flex flex-col gap-1`,children:m.map((e,t)=>(0,X.jsx)(Ch,{tile:e},t))});let y=(0,X.jsxs)(`div`,{ref:d,"data-lightbox-gallery":!0,className:`flex w-full min-w-0 flex-col gap-1.5`,children:[g.map(e=>(0,X.jsx)(`div`,{"data-lightbox-row":!0,className:`mx-auto flex max-w-full gap-1.5`,style:{width:e.width},children:p.slice(e.start,e.end).map((t,n)=>(0,X.jsx)(xh,{tile:t,ratio:h(t),labelled:_,onOpen:()=>fi(v,e.start+n),onShape:e=>s(n=>n[t.path]===e?n:{...n,[t.path]:e}),onBroken:()=>l(e=>({...e,[t.path]:!0}))},e.start+n))},e.start)),m.map((e,t)=>(0,X.jsx)(Ch,{tile:e},t))]});return n?(0,X.jsx)(hf,{children:y}):(0,X.jsx)(`div`,{className:_f,children:y})}function bh(e){return{flex:`${e} 1 0%`}}function xh({tile:e,ratio:t,labelled:n,onOpen:r,onShape:i,onBroken:a}){let o=ds(e.path),s=(e,t)=>{e>0&&t>0&&i(e/t)};return(0,X.jsxs)(`button`,{type:`button`,"data-lightbox-tile":!0,"data-lightbox-video":o||void 0,onClick:r,"aria-label":`${o?`Play`:`View`} ${e.label}`,className:`group flex min-w-0 flex-col gap-1 rounded-md text-left outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60 focus-visible:ring-offset-2 focus-visible:ring-offset-panel-2 ${o?`cursor-pointer`:`cursor-zoom-in`}`,style:bh(t),children:[(0,X.jsx)(`span`,{className:`relative block w-full overflow-hidden rounded-md`,style:{aspectRatio:t},children:o?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`video`,{src:`${gi(e.path)}#t=0.001`,preload:`metadata`,muted:!0,playsInline:!0,disablePictureInPicture:!0,tabIndex:-1,"aria-hidden":!0,onLoadedMetadata:e=>s(e.currentTarget.videoWidth,e.currentTarget.videoHeight),onError:a,className:`pointer-events-none block h-full w-full object-contain transition-[filter] group-hover:brightness-110`}),(0,X.jsx)(Sh,{})]}):(0,X.jsx)(`img`,{src:gi(e.path),alt:n?``:e.label,draggable:!1,onLoad:e=>s(e.currentTarget.naturalWidth,e.currentTarget.naturalHeight),onError:a,className:`block h-full w-full object-contain transition-[filter] group-hover:brightness-110`})}),n&&(0,X.jsx)(`span`,{title:e.label,className:`block truncate font-sans text-[11px] leading-4 text-muted`,children:e.label})]})}function Sh(){return(0,X.jsx)(`span`,{"data-lightbox-play":!0,"aria-hidden":!0,className:`pointer-events-none absolute left-1/2 top-1/2 flex h-8 w-8 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-black/55 text-white/90 ring-1 ring-white/15 backdrop-blur-sm transition-colors group-hover:bg-black/70 group-hover:text-white`,children:(0,X.jsx)(Cc,{size:14,strokeWidth:Zh,absoluteStrokeWidth:!0,fill:`currentColor`})})}function Ch({tile:e}){return(0,X.jsx)(`div`,{"data-lightbox-missing":!0,className:`break-all font-mono-keep text-[12px] text-muted-70`,children:e.path??e.entry.target})}function wh(e){let[t,n]=(0,q.useState)(0);return(0,q.useLayoutEffect)(()=>{if(!e)return;n(e.clientWidth);let t=new ResizeObserver(([e])=>n(e.contentRect.width));return t.observe(e),()=>t.disconnect()},[e]),t}function Th(e){let[t,n]=(0,q.useState)(0);return(0,q.useLayoutEffect)(()=>{if(!e){n(0);return}let t=()=>n(e.getBoundingClientRect().height);t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[e]),t}function Eh(e,t,n){return cm(e,t,`lightbox`,`md-lightbox`,bn).map(({key:e,host:t,value:r})=>(0,Fc.createPortal)((0,X.jsx)(yh,{entries:r,baseDir:n}),t,e))}function Dh(){let{lightbox:e}=_t(W);return e?(0,X.jsx)(yt,{children:(0,X.jsx)(Bh,{images:e.images,index:e.index})}):null}var Oh={x:0,y:0},kh=e=>({path:e,zoom:rh,pull:Oh,animate:!1,max:1/0,panning:!1}),Ah={mouse:4,touch:10},jh=48,Mh=96,Nh=300,Ph=40,Fh=1.5,Ih=1.1,Lh=`transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1)`,Rh=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),zh=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function Bh({images:e,index:t}){Vr(Cr(),!1,ts);let n=(0,q.useRef)(document.activeElement instanceof HTMLElement?document.activeElement:null),r=(0,q.useRef)(null),i=(0,q.useRef)(null),[a,o]=(0,q.useState)(null),c=(0,q.useCallback)(e=>{i.current=e,o(e)},[]),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=e[t],f=d?.path??``,p=ds(f),m=(0,q.useId)(),[h,g]=(0,q.useState)(null),_=Th(h),v=d?.caption?_:0,y=(0,q.useRef)(kh(f)),[b,x]=(0,q.useState)(y.current),S=()=>y.current.path===f?y.current:kh(f),C=e=>{let t={...S(),...e};y.current=t,x(t)},w=b.path===f?b:kh(f),T=(0,q.useRef)(new Map),E=(0,q.useRef)(`mouse`),D=(0,q.useRef)(null),O=(0,q.useRef)(!1),k=(0,q.useRef)(null),A=()=>{let e=l.current,t=i.current;if(!e||!t||!e.naturalWidth)return null;let n=e.getBoundingClientRect(),r=new DOMMatrixReadOnly(getComputedStyle(e).transform),a=n.width/r.a,o=n.height/r.d;if(!a||!o)return null;let s={x:n.left+n.width/2-r.e,y:n.top+n.height/2-r.f},c=t.getBoundingClientRect();return{centre:s,bounds:{width:a,height:o,left:c.left-s.x,right:c.right-s.x,top:c.top-s.y,bottom:c.bottom-s.y,max:dh(a,e.naturalWidth)},detail:uh(a,e.naturalWidth)}},j=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),M=(e,t)=>{let n=A();n&&C({zoom:e(S().zoom,n),animate:t,max:n.bounds.max})},N=e=>M((t,n)=>t.scale>1?rh:sh(rh,n.detail,j(e,n.centre),n.bounds),!0),P=e=>M((t,n)=>sh(t,e,{x:(n.bounds.left+n.bounds.right)/2,y:(n.bounds.top+n.bounds.bottom)/2},n.bounds),!0);if((0,q.useEffect)(()=>{if(!a)return;let e=e=>{let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?a.clientHeight:1;if(e.ctrlKey||e.metaKey){e.preventDefault();let n=Math.exp(_h(-e.deltaY*t*.01,-.5,.5));M((t,r)=>sh(t,n,j({x:e.clientX,y:e.clientY},r.centre),r.bounds),!1)}else S().zoom.scale>1&&(e.preventDefault(),M((n,r)=>ch(n,-e.deltaX*t,-e.deltaY*t,r.bounds),!1))},t=null,n=e=>{e.preventDefault();let n=e;if(e.type===`gesturestart`)t=S().zoom;else if(e.type===`gesturechange`&&t&&T.current.size===0){let e=t;M((t,r)=>sh(e,n.scale,j({x:n.clientX,y:n.clientY},r.centre),r.bounds),!1)}},r=new ResizeObserver(()=>{S().zoom.scale>1&&M((e,t)=>oh(e,t.bounds),!1)});a.addEventListener(`wheel`,e,{passive:!1});for(let e of[`gesturestart`,`gesturechange`,`gestureend`])a.addEventListener(e,n);return r.observe(a),()=>{a.removeEventListener(`wheel`,e);for(let e of[`gesturestart`,`gesturechange`,`gestureend`])a.removeEventListener(e,n);r.disconnect()}},[a,f]),!d)return null;let F=e.length>1,R=w.zoom.scale>1,z=t=>{let n=!t.ctrlKey&&!t.metaKey&&!t.altKey;if(t.key===`ArrowLeft`)Ds(-1);else if(t.key===`ArrowRight`)Ds(1);else if(t.key===`Home`)Ds(-e.length);else if(t.key===`End`)Ds(e.length);else if(n&&(t.key===`+`||t.key===`=`))P(Fh);else if(n&&(t.key===`-`||t.key===`_`))P(1/Fh);else if(n&&t.key===`0`)C({zoom:rh,animate:!0});else if(n&&t.key===` `&&p&&t.target!==u.current){let e=u.current;e?.paused?e.play().catch(()=>void 0):e?.pause()}else if(t.key===`Escape`)ts();else return;t.preventDefault(),t.stopPropagation()},B=e=>{e.target===e.currentTarget&&ts()},ee=e=>{if(!(e.pointerType===`mouse`&&e.button!==0)&&!e.target.closest(`button, video`)){if(T.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),T.current.size===1)E.current=e.pointerType,O.current=!1,D.current={kind:`press`,id:e.pointerId,x:e.clientX,y:e.clientY};else if(T.current.size===2){let e=A(),[t,n]=[...T.current.values()];O.current=!0,k.current=null,D.current=e?{kind:`pinch`,start:S().zoom,mid:j(Rh(t,n),e.centre),distance:zh(t,n)}:null,S().pull!==Oh&&C({pull:Oh,animate:!0})}}},te=n=>{if(!T.current.has(n.pointerId))return;T.current.set(n.pointerId,{x:n.clientX,y:n.clientY});let r=D.current;if(r?.kind===`pinch`){let e=r,[t,n]=[...T.current.values()];M((r,i)=>lh(e.start,e.mid,e.distance,j(Rh(t,n),i.centre),zh(t,n),i.bounds),!1);return}if(!(!r||r.id!==n.pointerId)){if(r.kind===`press`){if(Math.hypot(n.clientX-r.x,n.clientY-r.y)<(n.pointerType===`mouse`?Ah.mouse:Ah.touch))return;if(O.current=!0,k.current=null,S().zoom.scale>1)r={kind:`pan`,id:r.id,x:r.x,y:r.y};else if(n.pointerType!==`mouse`){let e=n.clientX-r.x,t=n.clientY-r.y;r={kind:`swipe`,id:r.id,x:r.x,y:r.y,axis:Math.abs(e)>Math.abs(t)?`x`:`y`}}else r=null;if(D.current=r,!r)return;i.current?.setPointerCapture(n.pointerId),r.kind===`pan`&&C({panning:!0})}if(r.kind===`pan`){let e=n.clientX-r.x,t=n.clientY-r.y;r.x=n.clientX,r.y=n.clientY,M((n,r)=>ch(n,e,t,r.bounds),!1)}else if(r.kind===`swipe`){let i=n.clientX-r.x,a=n.clientY-r.y,o=i>0&&t===0||i<0&&t===e.length-1;C({pull:r.axis===`x`?{x:o?i/4:i,y:0}:{x:0,y:a},animate:!1})}}},ne=e=>{if(!T.current.delete(e.pointerId))return;let t=D.current;if(t?.kind===`pinch`){let[e]=[...T.current.entries()];S().zoom.scale<Ih&&C({zoom:rh,animate:!0}),D.current=e&&S().zoom.scale>1?{kind:`pan`,id:e[0],x:e[1].x,y:e[1].y}:null;return}if(!t||t.id!==e.pointerId)return;D.current=null;let n=e.type===`pointercancel`;if(t.kind===`pan`&&C({panning:!1}),t.kind===`swipe`){let r=e.clientX-t.x,i=e.clientY-t.y;if(C({pull:Oh,animate:!0}),n)return;t.axis===`x`&&Math.abs(r)>jh?Ds(r<0?1:-1):t.axis===`y`&&Math.abs(i)>Mh&&ts();return}if(t.kind===`press`&&!n&&e.pointerType!==`mouse`){let t=k.current;t&&e.timeStamp-t.t<Nh&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<Ph?(k.current=null,O.current=!0,N({x:e.clientX,y:e.clientY})):k.current={t:e.timeStamp,x:e.clientX,y:e.clientY}}},re=e=>{if(O.current){O.current=!1;return}if(e.target.closest(`button, video, [data-lightbox-caption]`))return;let t=E.current===`mouse`;e.target===l.current?t&&N({x:e.clientX,y:e.clientY}):S().zoom.scale>1?t&&C({zoom:rh,animate:!0}):ts()},ie=1-Math.min(Math.abs(w.pull.y)/(Mh*3),.6);return(0,X.jsx)(cr,{open:!0,onOpenChange:e=>{e||ts()},children:(0,X.jsxs)(s,{children:[(0,X.jsx)(nn,{className:`overlay-in fixed inset-0 ${ko} bg-black/95 backdrop-blur-md`,style:{opacity:ie}}),(0,X.jsxs)(wr,{ref:r,"data-lightbox":!0,"aria-modal":`true`,"aria-describedby":d.caption?m:void 0,onEscapeKeyDown:Ot,onOpenAutoFocus:e=>{e.preventDefault(),r.current?.focus({preventScroll:!0})},onCloseAutoFocus:e=>{e.preventDefault(),n.current?.isConnected&&n.current.focus({preventScroll:!0})},onKeyDown:z,className:`overlay-in fixed inset-0 ${ko} flex flex-col text-white outline-none`,children:[(0,X.jsxs)(`header`,{onClick:B,className:`flex shrink-0 items-center gap-3 pb-2 pl-[max(env(safe-area-inset-left),16px)] pr-[max(env(safe-area-inset-right),16px)] pt-[max(env(safe-area-inset-top),12px)]`,style:{opacity:ie},children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(vi,{className:`truncate text-[13px] font-medium leading-5 text-white/90 ${d.titled?``:`font-mono-keep`}`,children:d.label}),(0,X.jsx)(`div`,{className:`truncate font-mono-keep text-[11px] leading-4 text-white/45`,children:d.path})]}),(0,X.jsxs)(`div`,{"data-lightbox-actions":!0,className:`-mr-1 flex shrink-0 items-center gap-0.5 pointer-coarse:-mr-3`,children:[F&&(0,X.jsxs)(`span`,{"data-lightbox-counter":!0,className:`mr-2.5 text-[12px] tabular-nums text-[#787a7d]`,children:[t+1,` / `,e.length]}),!p&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Xh,{label:`Zoom out`,onClick:()=>P(1/Fh),disabled:!R,className:`pointer-coarse:hidden`,children:(0,X.jsx)(Pc,{size:14,strokeWidth:2})}),(0,X.jsx)(Xh,{label:`Zoom in`,onClick:()=>P(Fh),disabled:w.zoom.scale>=w.max-1e-6,className:`pointer-coarse:hidden`,children:(0,X.jsx)(Nc,{size:14,strokeWidth:2})})]}),(0,X.jsx)(Xh,{label:`Download`,onClick:()=>Vh(d),children:(0,X.jsx)(oc,{size:14,strokeWidth:2,className:Yh})}),(0,X.jsx)(Xh,{label:p?`Open in default player`:`Open in default viewer`,onClick:()=>I(d.path,!0),children:(0,X.jsx)(sc,{size:14,strokeWidth:2,className:Yh})}),(0,X.jsx)(Xh,{label:`Close`,onClick:ts,children:(0,X.jsx)(L,{size:15,strokeWidth:2,className:Yh})})]})]}),(0,X.jsxs)(`div`,{ref:c,"data-lightbox-stage":!0,onClick:re,onPointerDown:ee,onPointerMove:te,onPointerUp:ne,onPointerCancel:ne,className:`relative flex min-h-0 flex-1 flex-col items-center justify-center overflow-hidden px-3 pb-[max(env(safe-area-inset-bottom),16px)] sm:px-16 ${R?w.panning?`cursor-grabbing`:`cursor-grab`:``}`,style:{touchAction:`none`},children:[p?(0,X.jsx)(Gh,{image:d,view:w,reserve:v,videoRef:u},d.path):(0,X.jsx)(Wh,{image:d,view:w,reserve:v,pictureRef:l},d.path),d.caption&&(0,X.jsx)(`p`,{ref:g,id:m,"data-lightbox-caption":!0,className:`max-w-2xl shrink-0 text-balance pt-3 text-center text-[13px] leading-5 text-white/75 ${R?`pointer-events-none`:``}`,style:{transform:`translate(${w.pull.x}px, ${w.pull.y}px)`,transition:`${w.animate?Lh:`transform 0s`}, opacity 150ms ease-out`,opacity:R?0:ie},children:d.caption}),F&&t>0&&(0,X.jsx)(Qh,{side:`left`,onClick:()=>Ds(-1)}),F&&t<e.length-1&&(0,X.jsx)(Qh,{side:`right`,onClick:()=>Ds(1)})]})]})]})})}function Vh(e){let t=document.createElement(`a`);t.href=gi(e.path),t.download=Ls(e),document.body.append(t),t.click(),t.remove()}function Hh({what:e,path:t}){return(0,X.jsxs)(`div`,{className:`pointer-events-none max-w-md text-center`,children:[(0,X.jsxs)(`div`,{className:`text-[13px] text-white/70`,children:[e,` unavailable`]}),(0,X.jsx)(`div`,{className:`mt-1 break-all font-mono-keep text-[11px] text-white/45`,children:t})]})}var Uh=e=>e?`calc(100% - ${e}px)`:void 0;function Wh({image:e,view:t,reserve:n,pictureRef:r}){let[i,a]=(0,q.useState)(!1);if(i)return(0,X.jsx)(Hh,{what:`Image`,path:e.path});let{scale:o,x:s,y:c}=t.zoom;return(0,X.jsx)(`img`,{ref:r,src:gi(e.path),alt:e.label,draggable:!1,onError:()=>a(!0),className:`block max-h-full max-w-full select-none object-contain ${o>1?``:`cursor-zoom-in`}`,style:{maxHeight:Uh(n),transform:`translate(${s+t.pull.x}px, ${c+t.pull.y}px) scale(${o})`,transition:t.animate?Lh:`none`,borderRadius:6/o,boxShadow:`0 0 0 ${1/o}px rgb(255 255 255 / 0.1)`}})}function Gh({image:e,view:t,reserve:n,videoRef:r}){let[i,a]=(0,q.useState)(!1);return i?(0,X.jsx)(Hh,{what:`Video`,path:e.path}):(0,X.jsx)(`video`,{ref:r,src:gi(e.path),"aria-label":e.label,controls:!0,autoPlay:!0,playsInline:!0,preload:`auto`,onError:()=>a(!0),className:`block max-h-full max-w-full rounded-md bg-black`,style:{maxHeight:Uh(n),transform:`translate(${t.pull.x}px, ${t.pull.y}px)`,transition:t.animate?Lh:`none`,boxShadow:`0 0 0 1px rgb(255 255 255 / 0.1)`}})}var Kh=`icon-focus-outline text-[#787a7d] transition-colors hover:bg-white/[0.04] hover:text-[#e6e7e9]`,qh=`cursor-default text-[#303132]`,Jh=`pointer-coarse:size-11 pointer-coarse:rounded-full pointer-coarse:text-[#cfd0d2]`,Yh=`pointer-coarse:size-[21px] pointer-coarse:[stroke-width:2.1]`;function Xh({label:e,onClick:t,disabled:n,className:r=``,children:i}){return(0,X.jsx)(ua,{label:e,side:`bottom`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":e,"aria-disabled":n||void 0,onClick:()=>{n||t()},className:`${Ca} focus-visible:ring-1 focus-visible:ring-white/60 ${n?qh:Kh} ${Jh} ${r}`,children:i})})}var Zh=1.5;function Qh({side:e,onClick:t}){return(0,X.jsx)(`button`,{type:`button`,"data-lightbox-page":e,"aria-label":e===`left`?`Previous image`:`Next image`,onClick:t,className:`absolute top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/55 text-white/85 outline-none ring-1 ring-white/15 backdrop-blur-sm transition-colors hover:bg-black/75 hover:text-white focus-visible:ring-white/60 pointer-coarse:hidden ${e===`left`?`left-3`:`right-3`}`,children:(0,X.jsx)(e===`left`?tc:br,{size:20,strokeWidth:Zh,absoluteStrokeWidth:!0})})}function $h({as:e=`div`,className:t,html:n}){let r=Up(n),i=(0,q.useRef)(null);om(i,n);let a=Eh(i,n),o=th(i,n);return(0,X.jsxs)(X.Fragment,{children:[(0,q.createElement)(e,{ref:i,className:t,dangerouslySetInnerHTML:r}),a,o]})}function eg({text:e,language:t,className:n=``,...r}){let i=Up((0,q.useMemo)(()=>vd(e,t),[e,t]));return(0,X.jsx)(`pre`,{...r,className:`hljs ${n}`,dangerouslySetInnerHTML:i})}var tg=`Todos`,ng={pending:{Icon:jc,className:`text-muted-50`},in_progress:{Icon:kc,className:`text-accent`},completed:{Icon:Oc,className:`text-muted-75`}},rg={pending:`text-fg/75`,in_progress:`text-fg`,completed:`text-muted-70`};function ig({status:e}){let{Icon:t,className:n}=ng[e];return(0,X.jsx)(t,{"aria-hidden":`true`,size:`1em`,strokeWidth:2,className:`frizz-todo-mark shrink-0 ${n}`})}var ag={pending:`to do`,in_progress:`in progress`,completed:`done`};function og({todos:e,note:t,meta:n,node:r}){let[i,a]=(0,q.useState)(!1),o=(0,q.useId)(),s=e.filter(e=>e.status===`completed`).length,c=e.find(e=>e.status===`in_progress`),l=e.length>0||!!t,u=e.length>0?`${s}/${e.length}`:void 0,d=c?c.text:e.length===0?`empty`:void 0;return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-todo-card":!0,"data-tool-node":r,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>l&&a(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":l?o:void 0,"aria-expanded":l?i:void 0,"aria-label":`${l?`${i?`Collapse`:`Expand`} `:``}${tg}${d?`: ${d}`:``}${u?` — ${s} of ${e.length} done`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-60`,children:[(0,X.jsxs)(`span`,{className:kp,children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:tg}),d&&(0,X.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,title:d,"data-todo-headline":!0,children:[c&&(0,X.jsx)(ig,{status:`in_progress`}),(0,X.jsx)(`span`,{className:`frizz-tool-detail`,children:d})]})]}),(0,X.jsxs)(`span`,{className:Ap,children:[u&&(0,X.jsx)(`span`,{className:`tabular-nums text-[11.5px] leading-none text-faint`,title:`${s} of ${e.length} done`,children:u}),n,(0,X.jsx)(Rp,{shown:l,open:i})]})]}),l&&(0,X.jsxs)(`div`,{id:o,className:`frizz-tool-body`,hidden:!i,children:[i&&e.length>0&&(0,X.jsx)(`ul`,{className:`frizz-todo-list`,children:e.map((e,t)=>(0,X.jsxs)(`li`,{className:`frizz-todo-row`,"data-current":e.status===`in_progress`?`true`:void 0,children:[(0,X.jsx)(ig,{status:e.status}),(0,X.jsx)(`span`,{className:`min-w-0 ${rg[e.status]}`,children:e.text}),(0,X.jsx)(`span`,{className:`sr-only`,children:` — ${ag[e.status]}`})]},t))}),i&&t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`frizz-bash-output-label`,children:`Note`}),(0,X.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body`,children:t})]})]})]})}var sg=/^```question(?:[ \t]+([A-Za-z][^\r\n]*?))?[ \t]*\r?\n(?:([\s\S]*?)\r?\n)??```[ \t]*$/gm,cg=/^qst_[a-z0-9]+$/;function lg(e){let t=(e??``).toLowerCase().split(/\s+/).filter(Boolean),n=e=>t.includes(e),r=t.find(e=>cg.test(e));return{kind:n(`multi`)?`multi`:`question`,danger:n(`danger`),...r?{registeredId:r}:{}}}function ug(e){let t=[],n=R(e),r=0;sg.lastIndex=0;for(let i=sg.exec(e);i!==null;i=sg.exec(e)){if(n(i.index)){sg.lastIndex=i.index+1;continue}let{kind:a,danger:o,registeredId:s}=lg(i[1]);if(i[2]===void 0&&!s){sg.lastIndex=i.index+1;continue}let c=e.slice(r,i.index);c.trim()&&t.push({kind:`prose`,text:c}),t.push({kind:`question`,text:i[2]??``,questionKind:a,danger:o,...s?{registeredId:s}:{}}),r=i.index+i[0].length}let i=e.slice(r);return i.trim()&&t.push({kind:`prose`,text:i}),_g(t)}function dg(e,t,n){if(!t||!Ft(e))return ug(e);let r=hs(e).filter(e=>e.read.form!==`invalid`||mg(e.body));if(r.length===0)return ug(e);let i=[],a=0;for(let t of r){if(i.push(...ug(e.slice(a,t.start))),a=t.end,t.read.form===`ref`&&fg(t.read,n)){i.push({kind:`refusedRef`,id:t.read.id});continue}if(t.read.form===`ask`&&fg(t.read,n)){i.push({kind:`refusedAsk`,id:t.read.id,spec:t.read.spec});continue}if(t.read.form===`invalid`){let n=Tn(t.body);i.push({kind:`invalidFence`,text:e.slice(t.start,t.end),faults:t.read.faults,...n?{draft:n}:{}});continue}let r=t.read;i.push({kind:`question`,text:t.body,questionKind:r.form===`ask`&&r.spec.kind===`multi`?`multi`:`question`,danger:r.form===`ask`&&r.spec.danger===!0,fence:r})}return i.push(...ug(e.slice(a))),i}function fg(e,t){return t!==void 0&&t.size>0&&t.has(e.id.toLowerCase())}var pg=RegExp(`^[ \\t]*(?:${k.join(`|`)}):(?:[ \\t]|$)`);function mg(e){let t=e.split(/\r?\n/).find(e=>e.trim()!==``);return t!==void 0&&pg.test(t)}function hg(e,t){if(!Ft(e))return[];let n=[];for(let r of hs(e)){let e=r.read;e.form===`invalid`||fg(e,t)||(e.form===`ref`||e.form===`ask`&&!e.when)&&n.push(e.id.toLowerCase())}for(let r of gg(e,t))n.includes(r)||n.push(r);return n}function gg(e,t){if(!Ft(e)||!e.includes(`when:`))return[];let n=hs(e).map(e=>e.read),r=new Set(n.flatMap(e=>e.form===`invalid`?[]:[e.id.toLowerCase()])),i=[];for(let e of n){if(e.form!==`ask`||!e.when||fg(e,t))continue;let n=e.when.parent.toLowerCase();!r.has(n)&&!i.includes(n)&&i.push(n)}return i}function _g(e){for(let t=0;t<e.length-1;t++){let n=e[t],r=e[t+1];if(n.kind!==`question`||r.kind!==`prose`||n.registeredId&&n.text.trim()===``)continue;let i=kg(n.text,n.questionKind,n.danger),a=null;if(i.options.length>0){if(i.trailingMd!==void 0||i.recommendation!==void 0)continue;let e=Pg(i.options[i.options.length-1]);if(!/^([A-Z]|\d+)$/.test(e))continue;a=e}let o=vg(r.text,a);o!==null&&(e[t]={...n,text:n.text.replace(/\s+$/,``)+`
|
|
94
|
-
|
|
95
|
-
`+o.run},o.rest.trim()?e[t+1]={kind:`prose`,text:o.rest}:e.splice(t+1,1))}return e}function vg(e,t){let n=e.split(`
|
|
96
|
-
`).map(e=>e.replace(/\r$/,``)),r=0;for(;r<n.length&&n[r].trim()===``;)r++;if(r>=n.length||!bg.test(n[r]))return null;let i=Cg(n[r]);if(t===null?!Tg(i):!wg(t,i))return null;let a=r,o=i;for(let e=r+1;e<n.length;e++){let t=n[e];if(bg.test(t)){if(!wg(o,Cg(t)))break;o=Cg(t),a=e;continue}if(t.trim()===``)continue;if(xg.test(t)){a=e;break}let r=n.findIndex((t,n)=>n>e&&bg.test(t));if(r===-1||!wg(o,Cg(n[r])))break}let s=n.slice(r,a+1);return s.filter(e=>bg.test(e)).length<(t===null?2:1)?null:{run:s.join(`
|
|
97
|
-
`),rest:n.slice(a+1).join(`
|
|
98
|
-
`)}}function yg(e,t){return Ft(e)?t!==void 0&&t.size>0?dg(e,!0,t).some(e=>e.kind===`question`):ug(e).some(e=>e.kind===`question`)||hg(e).length>0:!1}var bg=/^\s*(?:[-*+]\s+)?([A-Z]|\d+)[.)]\s+\S/,xg=/^\s*recommendation\b/i;function Sg(e){return e.trim().replace(/^[-*+]\s+/,``)}function Cg(e){return Sg(e).match(/^([A-Za-z]|\d+)[.)]/)?.[1].toUpperCase()??``}function wg(e,t){return/^\d+$/.test(e)?/^\d+$/.test(t)&&Number(t)===Number(e)+1:/^[A-Z]$/.test(e)&&/^[A-Z]$/.test(t)&&t.charCodeAt(0)===e.charCodeAt(0)+1}var Tg=e=>e===`A`||e===`1`,Eg=/(^|[^a-z])recommended([^a-z]|$)/i;function Dg(e){return e.replace(/\s{2,}/g,` `).trim()}function Og(e){if(!Eg.test(e))return{label:e,recommended:!1};let t=e.match(/\s*[—–-]?\s*[([]\s*[*_`~]*recommended\b(?:\s*[::,;—–-]\s*([^)\]]*?))?\s*[*_`~]*\s*[)\]]/i);if(t){let n=t[1]?.trim()||void 0;return{label:Dg(e.slice(0,t.index)+e.slice(t.index+t[0].length)),recommended:!0,note:n}}let n=e.match(/\s*[—–:-]?\s*[*_`~]+recommended\b[*_`~]+\s*[—–:-]?\s*/i);if(n)return{label:Dg(e.slice(0,n.index)+` `+e.slice(n.index+n[0].length)),recommended:!0};let r=e.match(/\s*[—–:-]?\s*recommended\b\s*$/i);if(r&&r.index>0)return{label:Dg(e.slice(0,r.index)),recommended:!0};let i=e.match(/^(\s*(?:[A-Za-z]|\d+)[.)]\s*)?[*_`~]*recommended\b[*_`~]*\s*[::—–-]\s*/i);if(i){let t=Dg((i[1]??``)+e.slice(i[0].length));if(t)return{label:t,recommended:!0}}return{label:e,recommended:!1}}function kg(e,t,n=!1){let r=e.split(`
|
|
99
|
-
`).map(e=>e.replace(/\r$/,``)),i=e=>r.findIndex((t,n)=>n>e&&bg.test(t)),a=e=>{let t=[];for(let n=e;n<r.length;n++){if(bg.test(r[n])){t.push(n);continue}if(t.length===0||r[n].trim()===``)continue;if(xg.test(r[n]))break;let e=i(n);if(e===-1||!wg(Cg(r[t[t.length-1]]),Cg(r[e])))break}return t},o=e=>{for(let t=e.length-1;t>0;t--)if(!wg(Cg(r[e[t-1]]),Cg(r[e[t]])))return Tg(Cg(r[e[t]]))?t:0;return+(e.length===1&&!/^\s*[-*+]\s/.test(r[e[0]])&&!r.slice(0,e[0]).some(e=>e.trim()))},s=[];for(let e=0;e<r.length;){let t=a(e);if(t.length===0)break;let n=o(t);if(n<t.length){s=t.slice(n);break}e=t[0]+1}if(s.length===0)return{kind:t,danger:n,contextMd:e,options:[],recommendedIdxs:[]};let c=s[0],l=s[s.length-1],u=[],d=[],f,p=[];for(let[e,n]of s.entries()){let{label:i,recommended:a,note:o}=Og(Sg(r[n]));a&&(t===`multi`||d.length===0)&&(d.length===0&&(f=o),d.push(u.length)),u.push(i);let c=e===0?[]:r.slice(s[e-1]+1,n).filter(e=>e.trim());p.push(c.length?c.join(`
|
|
100
|
-
`):void 0)}let m=e=>{let t=0,n=e.length-1;for(;t<=n&&e[t].trim()===``;)t++;for(;n>=t&&e[n].trim()===``;)n--;return e.slice(t,n+1)},h=m(r.slice(0,c)).join(`
|
|
101
|
-
`),g,_=[];for(let e of r.slice(l+1))g===void 0&&xg.test(e)?g=e.trim():_.push(e);let v=m(_).join(`
|
|
102
|
-
`)||void 0;if(d.length===0&&g){let e=jg(g,u);e!==null&&(d=[e],f=g)}return{kind:t,danger:n,contextMd:h,options:u,recommendedIdxs:d,recommendedNote:f,recommendation:g,trailingMd:v,...p.some(Boolean)?{optionHeadings:p}:{}}}var Ag=/^[*_`~\s]+/;function jg(e,t){if(!e)return null;let n=e.replace(/^\s*recommendation\s*:?\s*/i,``).replace(Ag,``).match(/^([A-Za-z]|\d+)(?![A-Za-z0-9])/);if(!n)return null;let r=n[1].toUpperCase(),i=t.findIndex(e=>{let t=e.replace(Ag,``).match(/^([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase()===r:!1});return i===-1?null:i}function Mg(e){let t=e,n=``;do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return`${n}.`}function Ng(e){let t=e.match(/^\s*([A-Za-z]{1,2}|\d+)[.)]\s+/);return t?{id:t[1].toUpperCase(),rest:e.slice(t[0].length)}:{rest:e}}function Pg(e){let t=e.match(/^\s*([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase():e.trim()}function Fg(e,t){let n=t.text.trim();if(e.kind===`multi`){let r=(t.chosenSet??[]).slice().sort((e,t)=>e-t).map(t=>Pg(e.options[t]??``)).filter(Boolean).join(`, `);return r&&n?`${r} — ${n}`:r||n}return t.chosen==null?n:e.options[t.chosen]??``}var Ig=/^(`{3,})(done|awaiting)[ \t]*\r?\n([\s\S]*?)\r?\n\1`*[ \t]*$/gm;function Lg(e,t){return t===`done`?Wi(e):Fa(e)}function Rg(e){let t=[],n=R(e),r=0;Ig.lastIndex=0;for(let i=Ig.exec(e);i!==null;i=Ig.exec(e)){if(n(i.index)){Ig.lastIndex=i.index+1;continue}let a=e.slice(r,i.index);a.trim()&&t.push({kind:`prose`,text:a});let o=i[2],{body:s,hints:c}=Lg(i[3],o);t.push({kind:`fence`,fenceKind:o,body:s,hints:c}),r=i.index+i[0].length}let i=e.slice(r);return i.trim()&&t.push({kind:`prose`,text:i}),t}function zg(e,t){for(let n=Math.min(t,e.length)-1;n>=0;n--){let t=e[n];if(!(t.role!==`assistant`||t.kind===`event`)&&Rg(t.text).some(e=>e.kind===`fence`&&e.fenceKind===`awaiting`&&Yt(e.hints)))return n}return-1}function Bg(e,t){let n=e?.lastFence;return!(!n||n.kind!==`done`||n.registered!==!0||t&&Rg(t).some(e=>e.kind===`fence`&&e.fenceKind===`done`))}var Vg=(e,t)=>[`registeredDone`,e,t.bodyElided??-1,t.body];function Hg(e){return e?.kind===`done`&&e.registered===!0&&e.bodyElided!==void 0}function Ug(e,t){return e!==void 0&&e.length===t.bodyElided&&_n(e)===t.body}function Wg(e){let t=e?.lastFence,n=e?.id??``,r=(0,q.useRef)(void 0);t?.kind===`done`&&t.bodyElided===void 0&&(r.current={slug:n,body:t.body});let i=Hg(t)?t:void 0,a=i&&r.current?.slug===n&&Ug(r.current.body,i)?r.current.body:void 0,o=ct(),s=Re({queryKey:i?Vg(n,i):[`registeredDone`,`none`],queryFn:async()=>(await U.threadRegisteredDone({slug:n})).body,enabled:i!==void 0&&a===void 0&&n!==``,staleTime:1/0,refetchOnWindowFocus:!1});if((0,q.useEffect)(()=>{i&&a!==void 0&&o.getQueryData(Vg(n,i))===void 0&&o.setQueryData(Vg(n,i),a)},[i,a,o,n]),t)return i?a===void 0?s.data===null||s.isError?t.body:s.data:a:t.body}function Gg(e,t,n){if(!e||e.kind!==`session`||e.foreign||e.runtime!==`turn-idle`&&e.runtime!==`exited`||e.needsYou!==!0||e.providerError)return!1;if(e.crashed===!0)return!0;if(e.lastFence||e.pendingQuestion||pt(e)||e.answersInFlight||e.operatorStopped||e.pendingAsk||e.pendingInteraction||e.awaitingBackground||e.limitPause||e.providerFault||!e.lastAssistantAt||t===void 0||Rg(t).some(e=>e.kind===`fence`))return!1;if(!Qo(e.spawnedAt)){let r=new Set((e.questions??[]).flatMap(e=>oe(e.spec).map(e=>e.toLowerCase()))),i=(e.closedQuestions??[]).filter(e=>!r.has(e.handle.toLowerCase()));return!dg(t,!0,i.length===0?n:new Set([...n??[],...i.map(e=>e.handle.toLowerCase())])).some(e=>e.kind===`question`)}return!yg(t)}function Kg({thread:e}){return e.crashed===!0?(0,X.jsx)(wm,{"data-rested-card":`stalled`,icon:Pt,label:`Stalled`,children:(0,X.jsx)(`p`,{className:Tm,children:`The agent's process exited mid-turn. Retry, in the header, re-sends the last message.`})}):(0,X.jsx)(wm,{"data-rested-card":`bare`,icon:fr,label:`Rested without a sign-off`,children:(0,X.jsx)(`p`,{className:Tm,children:`The worker stopped without a done card, a question or a registered wait. Frizz nudges it for one; a reply here also wakes it.`})})}function qg(e,t){return t!==void 0&&e.some(e=>e.providerError?.at===t.at&&e.providerError?.message===t.message&&e.providerError?.code===t.code)}function Jg({error:e,provider:t}){return(0,X.jsxs)(wm,{"data-codex-error":e.code??`unknown`,tone:e.retrying?`caution`:`danger`,icon:Pt,label:e.retrying?`${t} retrying`:`${t} request failed`,children:[e.code&&(0,X.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75 font-mono [overflow-wrap:anywhere]`,children:e.code}),(0,X.jsx)(`p`,{className:`${Tm} whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.message}),e.details&&(0,X.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details})]})}var Yg=e=>co(e.replace(/\r\n?/g,`
|
|
103
|
-
`)).answers;function Xg(e){return!e||i_(e)===null?``:co(e.replace(/\r\n?/g,`
|
|
104
|
-
`)).note}var Zg=/^(\d+)\.\s+(.*)$/;function Qg(e,t){let n=t.startsWith(` `)?t.slice(2):t;e.answer=e.answer?`${e.answer}\n${n}`:n}function $g(e){if(!e)return null;let t=Yg(e).split(`
|
|
105
|
-
`),n=0;for(;n<t.length&&!t[n].trim();)n++;if(n>=t.length||t[n].trim()!==`Answers:`)return null;n++;let r=[];for(;n<t.length;n++){let e=t[n],i=e.match(Zg);if(i)r.push({n:Number(i[1]),answer:i[2]});else if(r.length>0)Qg(r[r.length-1],e);else if(e.trim())return null}if(r.length===0)return null;for(let e of r)e.answer=e.answer.replace(/\s+$/,``);return r}var e_=Ba,t_=RegExp(`^(\\d+)\\.\\s+(⤷\\s+)?(?:\`(${mo})\`\\s+)?[“"]`),n_=/[”"]\s+→\s+/;function r_(e){if(!e)return null;let t=Yg(e).split(`
|
|
106
|
-
`),n=0;for(;n<t.length&&!t[n].trim();)n++;if(n>=t.length||t[n].trim()!==e_)return null;n++;let r=[],i=null,a=(e,t,n)=>{let i={n:e.n,answer:n},a=t.trim();a&&(i.question=a),e.followUp&&(i.followUp=!0),e.handle&&(i.handle=e.handle),r.push(i)};for(;n<t.length;n++){let e=t[n];if(i){if(t_.test(e))return null;let t=e.match(n_);t?(a(i,[...i.lines,e.slice(0,t.index)].join(`
|
|
107
|
-
`),e.slice(t.index+t[0].length)),i=null):i.lines.push(e);continue}let o=e.match(t_);if(o){let t=e.slice(o[0].length),n={n:Number(o[1]),followUp:!!o[2],handle:o[3],lines:[]},r=t.match(n_);r?a(n,t.slice(0,r.index),t.slice(r.index+r[0].length)):i={...n,lines:[t]}}else if(r.length>0)Qg(r[r.length-1],e);else if(e.trim())return null}if(i||r.length===0)return null;for(let e of r)e.answer=e.answer.replace(/\s+$/,``);return r}function i_(e){return r_(e)??$g(e)}function a_(e){return e.filter(e=>e.answer!==Bi).map(e=>Rn(e.answer)?{...e,answer:Rs}:e)}function o_(e){let t=e.split(`
|
|
108
|
-
`),n=[];for(;n.length<t.length&&t[n.length].startsWith(`- [x] `);)n.push(t[n.length].slice(ji.length));return n.length===0?{picks:n,note:e}:{picks:n,note:t.slice(n.length).join(`
|
|
109
|
-
`).trim()}}var s_=e=>e.displayText??e.text;function c_(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`?!1:i_(s_(e))!==null}var l_=e=>`${e.handle??``}${e.question??``}${e.answer}`;function u_(e,t){let n=t?i_(t):null;if(!n?.length)return null;let r=new Set;for(let t of e)if(!(t.role!==`user`||t.kind===`event`||t.kind===`reasoning`))for(let e of i_(s_(t))??[])r.add(l_(e));let i=n.filter(e=>!r.has(l_(e)));return a_(i).length>0?i:null}function d_(e,t){for(let n=t-1;n>=0;n--){let t=e[n];if(t.kind===`event`||t.kind===`reasoning`||!t.text.trim())continue;if(t.role===`user`)return null;if(!t.text.includes("```question"))continue;let r=ug(t.text).filter(e=>e.kind===`question`);if(r.length>0)return r}return null}var f_=e=>e.kind===`question`?kg(e.text,e.questionKind,e.danger).contextMd.trim():``;function p_(e,t){if(t.length!==1)return null;let n=e.trim();if(!n)return null;let r=t[0];if(r.kind!==`question`)return null;let i=kg(r.text,r.questionKind,r.danger);if(!i.options.some(e=>e.trim()===n))return null;let a=i.contextMd.trim();return[a?{n:1,answer:n,question:a}:{n:1,answer:n}]}function m_(e,t){let n=e[t];if(!n||n.role!==`user`||n.kind===`event`)return null;let r=s_(n),i=r_(r);if(i)return i;let a=$g(r),o=d_(e,t);return a?!o||!a.every((e,t)=>Number.isInteger(e.n)&&e.n>=1&&e.n<=o.length&&(t===0||e.n>a[t-1].n))?a:a.map(e=>{let t=f_(o[e.n-1]);return t?{...e,question:t}:{...e}}):o?p_(r,o):null}function h_(e){return e.map((t,n)=>m_(e,n))}function g_(e){return e.displayText??e.text}function __(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role===`user`&&!n.queued&&!n.peerFrom&&!n.agentInstruction&&!n.sessionPeer)return t}return-1}function v_(e){for(let t=e.length-1;t>=0;t--)if(y_(e[t]))return t;return 0}function y_(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`||e.queued||e.peerFrom||e.agentInstruction||e.sessionPeer?!1:!e.wake||e.text!==void 0&&c_({...e,text:e.text})}function b_(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function x_(e,t){for(let n=t+1;n<e.length;n++)if(b_(e[n]))return n-1;return e.length-1}function S_(e,t){let n=Date.parse(t),r=e.length-1;if(!Number.isFinite(n))return r;for(let t=0;t<e.length;t++){let r=e[t];if(!b_(r))continue;let i=r.at?Date.parse(r.at):NaN;if(!(!Number.isFinite(i)||i<=n))return t-1}let i=r;for(;i>=0&&b_(e[i])&&!(e[i].at&&Number.isFinite(Date.parse(e[i].at)));)i--;return i<0?r:i}function C_(e){let t=new Map,n=-1;return e.forEach((e,r)=>{if(y_(e)&&(n=r),e.role!==`assistant`||!e.text)return;let i=i=>{let a=e.questionOwners?.get(i),o=a===void 0?i:w_(i,a),s=t.get(o);(s===void 0||s<n)&&t.set(o,r)};if(e.text.includes("```awaiting")){for(let t of Rg(e.text))if(!(t.kind!==`fence`||t.fenceKind!==`awaiting`))for(let e of ne(t.hints))i(e.toLowerCase())}for(let t of hg(e.text,e.refusedFences))i(t)}),t}var w_=(e,t)=>`${e}\u0000${t}`;function T_(e,t){let n,r=r=>{for(let i of t.id?[r.toLowerCase(),w_(r.toLowerCase(),t.id)]:[r.toLowerCase()]){let t=e.get(i);t!==void 0&&(n===void 0||t>n)&&(n=t)}};if(t.id&&r(t.id),t.spec)for(let e of oe(t.spec))r(e);return n}function E_(e,t,n={}){let r=new Map,i=n.claims===!1||t.length===0?void 0:C_(e);for(let a of t){let t=S_(e,a.askedAt),o=i?T_(i,a):void 0;if(o!==void 0&&o>t&&(t=x_(e,o)),n.from!==void 0&&a.standing===!1&&t<n.from)continue;let s=r.get(t);s?s.push(a):r.set(t,[a])}return r}function D_(e,t){for(let n=t;n>=0;n--)if(O_(e[n]))return n+1;return 0}function O_(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function k_(e,t){let n=new Map;for(let[r,i]of E_(e,t,{claims:!1}))for(let t=D_(e,r);t<e.length;t++){if(O_(e[t]))continue;let r=n.get(t);r?r.push(...i):n.set(t,[...i])}return n}var A_=12;function j_(e){return e.replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[*_~`]/g,``).replace(/\s+/g,` `).trim().toLowerCase()}function M_(e){let t=e.indexOf(`?`);return t===-1?void 0:e.slice(0,t+1)}function N_(e,t){if(t.length===0)return!1;let n=j_(kg(e,`question`).contextMd);if(n.length<A_)return!1;let r=M_(n);return t.some(({spec:e})=>{let t=j_(e.question);if(t.length<A_)return!1;if(n.includes(t)||t.startsWith(n))return!0;let i=M_(t);return i!==void 0&&i.length>=A_&&n.includes(i)?!0:r!==void 0&&r.length>=A_&&t.includes(r)})}function P_(e,t){if(t.length===0||!e.includes("```question"))return!1;let n=ug(e).filter(e=>e.kind===`question`);return n.length>0&&n.every(e=>e.kind===`question`&&F_(e,t)!==void 0)}function F_(e,t){return e.registeredId?t.find(t=>t.id.toLowerCase()===e.registeredId):t.find(t=>N_(e.text,[t]))}function I_(e){let t=[e.id.toLowerCase()];if(e.spec)for(let n of oe(e.spec))t.push(n.toLowerCase());else e.handle&&t.push(e.handle.toLowerCase());return t}function L_(e,t,n){let r=e.toLowerCase(),i=n?.get(r);if(i!==void 0){let e=t.find(e=>e.id===i);if(e)return e}return t.find(e=>I_(e).includes(r))}function R_(e,t,n){let r=e.questionOwners?.get(t);return r===void 0||r===n}function z_(e,t){return Ft(e)?[...B_(e),...hg(e,t)]:[]}function B_(e){return e.includes("```question")?ug(e).flatMap(e=>e.kind===`question`&&e.registeredId&&e.text.trim()===``?[e.registeredId]:[]):[]}function V_(e,t){let n=new Map,r=new Set;if(t.length===0)return{placed:n,placedIds:r};let i=new Map,a=t=>{let n=i.get(t);if(n===void 0){let r=e[t];n=r.role===`assistant`&&r.text?z_(r.text,r.refusedFences):[],i.set(t,n)}return n};for(let[i,o]of E_(e,t))for(let t of o){let o=I_(t),s=[],c=!1;for(let n=D_(e,i);n<e.length;n++)y_(e[n])&&(c=!0),!O_(e[n])&&a(n).some(r=>o.includes(r)&&R_(e[n],r,t.id))&&(c&&(s=[]),s.push(n),c=!1);if(s.length!==0){for(let e of s){let r=n.get(e);r?r.push(t):n.set(e,[t])}r.add(t.id)}}return{placed:n,placedIds:r}}function H_(e,t,n){let r=new Map;for(let[e,t]of n.placed)for(let n of t)r.set(n.id,Math.max(e,r.get(n.id)??e));let i=t.filter(e=>!n.placedIds.has(e.id));for(let[t,n]of E_(e,i))for(let e of n)r.set(e.id,t);return r}function U_(e,t){if(t<=0)return e;let n=new Map,r=new Set;for(let[i,a]of e.placed)if(!(i<t)){n.set(i,a);for(let e of a)r.add(e.id)}return{placed:n,placedIds:r}}function W_(e,t){let n=new Set;for(let r of t.placed.keys())n.add(x_(e,r));return n}function G_(e,t){if(t.length===0||e?.runtime!==`turn-idle`||e.lastFence?.kind!==`awaiting`)return!1;let n=Sa(e.lastFence.hints);return n.length===t.length&&n.every((e,n)=>e===t[n])}var K_=Et({}),q_=new Map,J_=5e3,Y_=(e,t)=>`${e}\u0000${t}`;function X_(e){clearTimeout(q_.get(e)),q_.set(e,setTimeout(()=>Z_(e),J_))}function Z_(e){clearTimeout(q_.get(e)),q_.delete(e),delete K_[e]}function Q_(e,t,n){let r=Y_(e,t);clearTimeout(q_.get(r)),q_.delete(r),K_[r]={done:n},U.setHumanTodo({slug:e,id:t,done:n}).then(()=>X_(r),e=>{Z_(r),G(`Couldn’t save that tick — ${e.message.slice(0,120)}`)})}function $_(e){let t=_t(K_),n=e?.id,r=e?.humanTodos;return(0,q.useEffect)(()=>{if(n)for(let e of r??[]){let t=Y_(n,e.id),r=K_[t];r&&r.done===e.done&&(r.staged===void 0||r.staged===e.staged)&&Z_(t)}},[n,r]),e?(e.humanTodos??[]).map(n=>{let r=t[Y_(e.id,n.id)];return r?{...n,done:r.done,staged:r.staged??(r.done===n.done?n.staged:!n.staged)}:n}):[]}function ev(e){return e.filter(e=>e.staged||!e.done)}function tv(e,t){let n=e.filter(e=>e.done).length,r=n===e.length?xn:`${xn} ${n} of ${e.length}:\n${e.map(e=>`- [${e.done?`x`:` `}] ${e.text}`).join(`
|
|
110
|
-
`)}`,i=t.trim();return i?`${r}\n\n${i}`:r}var nv=RegExp(`^${xn} \\d+ of \\d+:$`),rv=/^- \[( |x)\] (.*)$/;function iv(e){if(li(e))return`all`;let[t,...n]=Ns(e).split(`
|
|
111
|
-
`);if(!nv.test(t))return null;let r=new Set;for(let e of n){let t=rv.exec(e);if(!t)break;t[1]===`x`&&r.add(t[2])}return r}function av(e){let t=new Map;for(let n=0;n<e.length;n++){let r=e[n];if(!(r.role!==`assistant`||r.kind===`event`||!r.text.includes("```awaiting")))for(let r=n+1;r<e.length;r++){let i=e[r];if(i.role===`assistant`&&i.kind!==`event`)break;let a=i.role===`user`?iv(i.text):null;if(a){t.set(n,a);break}}}return t}function ov(e){let t=$_(e),n=t.some(e=>e.staged);return{staged:n,take:()=>{if(!e||!n)return null;let r=ev(t),i=r.map(t=>Y_(e.id,t.id));return{todos:r.map(({id:e,done:t})=>({id:e,done:t})),compose:e=>tv(r,e),onOptimistic:()=>r.forEach((e,t)=>{K_[i[t]]={done:e.done,staged:!1},X_(i[t])}),onRollback:()=>i.forEach(Z_)}}}}function sv(e){let t=e.kind===`session`&&e.foreign!==!0,n=t&&(e.state===`archived`||e.archived===!0),r=t,i=t&&!n;return{lifecycle:r,done:n,snooze:i,archive:i}}function cv(e){if(e.runtime===`exited`&&e.crashed)return!1;if(e.runtime===`perm-prompt`||e.pendingAsk)return!0;if(e.runtime===`running`||e.runtime===`spawning`)return!1;let t=e=>e.state===`running`||e.state===`stale`;return!(e.subAgents?.some(e=>qs(e)&&t(e))||e.bgShells?.some(t))}function lv(e){let t={lead:`This thread is still running.`,groups:[],trailer:`Marking it done will stop its agent session, then move it to Done.`};if(!e)return t;if(e.cutOff)return{lead:`This session was cut off mid-turn — its worker ended before the turn finished, so the thread isn’t done.`,groups:[],trailer:`Marking it done files it under Done as it is. Retry resumes it where it left off.`};let n=[uv(`agent`,`sub-agent`,e.subAgents,e.subAgentCount),uv(`shell`,`background shell`,e.bgShells,e.bgShellCount)].filter(e=>e!==null);return e.unobservable?{lead:`This session is live, but its transcript can’t be read right now — it may still be working.`,groups:n,trailer:`Marking it done will stop the session anyway, then move it to Done.`}:!e.turnInFlight&&n.length===0?t:{lead:e.turnInFlight?n.length>0?`The agent is mid-turn, and it still owns background work:`:`The agent is mid-turn — it’s executing right now.`:`The agent is resting, but the background work it launched is still running:`,groups:n,trailer:n.length>0?`Marking it done will stop the session and everything running under it, then move it to Done.`:`Marking it done will stop its agent session mid-turn, then move it to Done.`}}function uv(e,t,n,r){let i=Math.max(r,n.length);return i===0?null:{kind:e,heading:`${i} ${t}${i===1?``:`s`}`,items:n.map(e=>({label:e.label,stale:e.state===`stale`})),overflow:Math.max(0,i-n.length)}}function dv(e,t=[],n=[]){let r=fv(e),i=r.filter(e=>e.kind===`github`),a=e.links??[];return{todos:e.humanTodos??[],agents:Oo(e.subAgents??[],`card`),children:n,shells:Ko(e.bgShells??[],t),prs:i.filter(e=>e.subject!==`issue`),issues:i.filter(e=>e.subject===`issue`),commands:r.filter(e=>e.kind===`command`),timers:r.filter(e=>e.kind===`timer`),files:a.filter(e=>e.kind===`file`),links:a.filter(e=>e.kind===`link`)}}function fv(e){return!e||e.state===`archived`?[]:(e.watches??[]).filter(e=>e.state===`armed`)}function pv(e){let t=new Set(fv(e).filter(e=>e.kind===`shell`).map(e=>e.target));return e=>t.has(e.taskId??``)||t.has(e.id??``)||t.has(e.label)}var mv=`Watched — this thread wakes when it finishes`,hv=`icon-label-nudge`,gv=class{send=null;listeners=new Set;set(e){if(this.send===e)return;let t=this.send!==null;if(this.send=e,t!==(e!==null))for(let e of this.listeners)e()}run(){return this.send?(this.send(),!0):!1}present=()=>this.send!==null;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e))},_v=(0,q.createContext)(null),vv=(0,q.createContext)(null);function yv(){return(0,q.useState)(()=>new gv)[0]}function bv(e,t){let{stagedCount:n,takeAnswers:r}=t;return(0,q.useMemo)(()=>({composer:e,fencedCount:n,takeFenced:r}),[e,n,r])}function xv(e){return(0,q.useSyncExternalStore)(e.subscribe,e.present,Cv)}var Sv=()=>()=>{},Cv=()=>!1;function wv(){let e=(0,q.useContext)(vv);return(0,q.useSyncExternalStore)(e?.subscribe??Sv,e?.present??Cv,Cv)}var Tv=`md-body ${lm} mt-[var(--md-step)] first:mt-0`;function Ev({steps:e,done:t}){return(0,X.jsx)(`div`,{"data-awaiting-steps":!0,className:Tv,children:(0,X.jsx)(`ul`,{className:`frizz-todos`,children:e.map((e,n)=>(0,X.jsx)(Ov,{step:e,done:t===`all`||t?.has(e.text)===!0},n))})})}function Dv({md:e}){return(0,X.jsx)($h,{className:`md-body frizz-todo-body`,html:tp(e)})}function Ov({step:e,done:t}){let n=tp(e.text),r=(0,q.useId)();return(0,X.jsxs)(`li`,{"data-human-todo":!0,"data-done":t,className:`frizz-todo`,children:[(0,X.jsx)(`span`,{role:`checkbox`,"aria-checked":t,"aria-disabled":`true`,"aria-labelledby":r,className:Iv(t,!1),children:t&&(0,X.jsx)(Lv,{})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{id:r,children:(0,X.jsx)($h,{className:`md-body frizz-todo-text`,html:n})}),e.body&&!t&&(0,X.jsx)(Dv,{md:e.body})]})]})}function kv({slug:e,todo:t,onTicked:n}){let r=tp(t.text),i=(0,q.useId)();return(0,X.jsxs)(`li`,{"data-human-todo":!0,"data-done":t.done,"data-staged":t.staged,className:`frizz-todo`,children:[(0,X.jsxs)(`span`,{className:Iv(t.done,t.staged),children:[t.done&&(0,X.jsx)(Lv,{}),(0,X.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t.done,"aria-labelledby":i,onClick:r=>{Q_(e,t.id,!t.done),n?.(r)},onMouseDown:e=>e.preventDefault(),className:`absolute -inset-[5px] rounded-md outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60`})]}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{id:i,children:(0,X.jsx)($h,{className:`md-body frizz-todo-text`,html:r})}),t.body&&(!t.done||t.staged)&&(0,X.jsx)(Dv,{md:t.body})]})]})}function Av({thread:e,sends:t}){let n=$_(e);return(0,X.jsxs)(`div`,{"data-human-todo-list":!0,className:Tv,children:[(0,X.jsx)(`ul`,{className:`frizz-todos`,children:n.map(t=>(0,X.jsx)(kv,{slug:e.id,todo:t},t.id))}),t&&(0,X.jsx)(Mv,{thread:e})]})}function jv({thread:e,onReplied:t,onReplyFailed:n}){let r=$_(e),{staged:i}=ov(e),a=(0,q.useContext)(_v),o=wv(),s=Pv(e,t,n),c=(0,q.useRef)(null),[l,u]=(0,q.useState)(!1),d=r.filter(e=>e.done&&!e.staged),f=r.filter(e=>!e.done||e.staged),p=e=>{if(!i||!Hr({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode}))return;let t=e.target;t.closest(`a`)||t.closest(`button[aria-expanded]`)||t.closest(`button[role=checkbox]`)?.getAttribute(`aria-checked`)!==`false`&&(e.preventDefault(),e.stopPropagation(),a?.composer.run()||s())},m=e=>{let t=document.activeElement;t!==e.currentTarget&&!Fv(t)&&c.current?.focus()};return r.length===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{ref:c,"data-awaiting-steps":!0,tabIndex:-1,onKeyDown:p,className:`${Tv} outline-none`,children:[d.length>0&&(0,X.jsx)(`button`,{type:`button`,"data-todos-earlier":!0,"aria-expanded":l,onClick:()=>u(e=>!e),onMouseDown:e=>e.preventDefault(),className:`mb-2 block rounded text-[12px] leading-[18px] text-muted-70 outline-none hover:text-fg/85 focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:l?`Hide completed`:`Show ${d.length} completed`}),(0,X.jsxs)(`ul`,{className:`frizz-todos`,children:[l&&d.map(t=>(0,X.jsx)(kv,{slug:e.id,todo:t,onTicked:m},t.id)),f.map(t=>(0,X.jsx)(kv,{slug:e.id,todo:t,onTicked:m},t.id))]})]}),!o&&(0,X.jsx)(Nv,{staged:i,send:s})]})}function Mv({thread:e}){let{staged:t}=ov(e),n=Pv(e);return(0,X.jsx)(`button`,{type:`button`,"data-steps-send":!0,disabled:!t,onClick:n,className:`mt-3.5 flex h-[46px] w-full items-center justify-center rounded-xl bg-fg text-[15.5px] font-semibold text-bg outline-none disabled:opacity-45`,children:`Send`})}function Nv({staged:e,send:t}){return(0,X.jsx)(Em,{"data-awaiting-steps-reply":!0,children:(0,X.jsx)(`button`,{type:`button`,"data-steps-send":!0,disabled:!e,onClick:t,onMouseDown:e=>e.preventDefault(),className:`${jm} disabled:opacity-40`,children:`Send`})})}function Pv(e,t,n){let{take:r}=ov(e),i=Fr(e.id);return()=>{let e=r();e&&i.submit(e.compose(``),{todos:e.todos,onOptimistic:()=>{e.onOptimistic(),t?.()},onRollback:()=>{e.onRollback(),n?.()}})}}function Fv(e){return e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement||e instanceof HTMLElement&&e.isContentEditable}function Iv(e,t){return`frizz-todo-box border transition-colors ${e?t?`border-accent bg-accent-fill text-on-accent`:`border-control-strong text-fg`:`border-control-strong bg-panel`}`}function Lv(){return(0,X.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(Qt,{size:12,strokeWidth:3})})}function Rv(e){return(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).length}function zv(e,t={}){let n=(e.subAgents??[]).filter(e=>qs(e)&&e.state===`running`).length,r=(e.bgShells??[]).filter(e=>e.state===`running`).length,i=t.watchers===!1?0:Rv(e),a=[n>0?`${n} sub-agent${n===1?``:`s`}`:null,r>0?`${r} background shell${r===1?``:`s`}`:null,i>0?`${i} PR watcher${i===1?``:`s`}`:null].filter(e=>e!==null);return a.length===0?`0 background shells`:a.length===1?a[0]:`${a.slice(0,-1).join(`, `)} and ${a[a.length-1]}`}function Bv(e){return(e.subAgents??[]).some(e=>qs(e)&&e.state===`running`)}function Vv(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length}function Hv(e){return Bv(e)||Vv(e)>0}function Uv(e,t){return Sa(t).length>0?is:Wv(e)?Ma:Vo}function Wv(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length>0&&!Bv(e)&&Rv(e)===0&&Gv(e).length===0&&Kv(e).length===0}function Gv(e){return(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`)}function Kv(e){return(e.watches??[]).filter(e=>e.kind===`command`&&e.state===`armed`)}var qv={id:``,subAgents:[],bgShells:[],watches:[]},Jv=[];function Yv(e,t){let n=new Set((e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).map(e=>e.target));return ho(t).filter(e=>!n.has(e.ref))}function Xv({watch:e}){return(0,q.useEffect)(()=>{e.url&&ge([e.ref])},[e.url,e.ref]),e.url?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-gh-ref":e.ref,className:`${Om} text-[12px]`,children:e.ref}):(0,X.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.ref})}var Zv={mergeable:`no conflicts`,blocked:`merge blocked`,conflicting:`has conflicts`,unknown:null};function Qv(e){return e.state!==`open`||e.merge===`blocked`&&e.checks!==`passing`&&e.checks!==`none`?null:Zv[e.merge]}var Z=`shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`;function $v({tone:e}){return(0,X.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-3 rounded-full border ${e} border-t-transparent motion-safe:animate-spin ${Z}`})}function ey(){return(0,X.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 16 16`,width:12,height:12,fill:`none`,stroke:`currentColor`,overflow:`visible`,className:Z,style:{color:Fn.fgAttention},children:[(0,X.jsx)(`circle`,{cx:`8`,cy:`8`,r:`4`,fill:`currentColor`,stroke:`none`}),(0,X.jsxs)(`g`,{strokeWidth:`2`,className:`origin-center motion-safe:animate-spin`,children:[(0,X.jsx)(`circle`,{cx:`8`,cy:`8`,r:`7`,opacity:`0.25`}),(0,X.jsx)(`path`,{d:`M15 8A7 7 0 0 1 8 15`})]})]})}function ty({status:e,now:t}){return e?e.state===`merged`?(0,X.jsx)(y,{size:12,className:Z,style:{color:Fn.fgDone}}):e.state===`closed`?(0,X.jsx)(Vs,{size:12,className:Z,style:{color:Fn.fgDanger}}):He(e,t)||e.newHeadSince?(0,X.jsx)(fr,{size:12,className:`${Z} text-muted-60`}):e.checks===`failing`?(0,X.jsx)(ac,{size:12,className:Z,style:{color:Fn.fgDanger}}):e.checks===`passing`?(0,X.jsx)(ir,{size:12,className:Z,style:{color:Fn.fgSuccess}}):e.gated>0&&e.running===0?(0,X.jsx)(ic,{size:12,className:Z,style:{color:Fn.fgAttention}}):e.checks===`running`?(0,X.jsx)(ey,{}):(0,X.jsx)(fr,{size:12,className:`${Z} text-muted-60`}):(0,X.jsx)(fr,{size:12,className:`${Z} text-muted-60`})}function ny(e){return[e.failed>0?`${e.failed} failing`:null,e.gated>0?`${e.gated} awaiting approval`:null,e.running>0?`${e.running} in progress`:null,e.passed>0?`${e.passed} successful`:null,e.skipped>0?`${e.skipped} skipped`:null].filter(e=>e!==null).join(`, `)}function ry(e,t=Date.now()){if(!e)return`Checking…`;if(e.state===`merged`)return`Merged`;if(e.state===`closed`)return`Closed`;let n=e.head?Ei(e.head):void 0,r=ny(e),i=Qv(e),a=[e.newHeadSince?`Waiting for CI${n?` on ${n}`:``}`:r||`No checks`,i].filter(e=>e!==null).join(` · `),o=n&&!e.newHeadSince?` · on ${n}`:``;return He(e,t)?`Last read ${xo(e.polledAt,t)}: ${a}${o}`:`${a}${o}`}function iy(e,t=Date.now()){if(!e)return`Checking…`;if(e.state===`open`&&e.failed===0&&!He(e,t)){if(e.merge===`conflicting`)return`conflicts`;if(e.merge===`blocked`&&e.checks===`passing`)return`blocked`}return an(e,t)}var ay=`group relative flex items-baseline rounded-sm px-2 text-[12px] leading-5`,oy=`ml-1.5 font-medium text-fg/90`,sy=`${oy} line-clamp-2 break-words`,cy=`${oy} min-w-0 flex-1 truncate`,ly=`ml-3 min-w-0 truncate text-right text-muted-70`,uy=`min-w-1/2 flex-1`,dy=`outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-1 focus-visible:after:ring-fg/60`;function fy(){return(0,X.jsx)(br,{size:13,"aria-hidden":!0,className:`${Z} ml-[3px] -mr-[4px] text-muted-35 transition-colors group-hover:text-muted-70`})}function py({mark:e,name:t,status:n,onOpen:r,onPrewarm:i,href:a,ghRef:o,title:s,testKind:c,testId:l,indent:u,dismiss:d,oneLine:f}){let p=u!==void 0,m=f?`${oy} truncate`:sy,h=p?cy:d?`${m} min-w-0`:`${m} ${uy}`,g=a?(0,X.jsx)(`a`,{href:a,target:`_blank`,rel:`noreferrer noopener`,title:s,"data-gh-ref":o,onMouseDown:e=>e.stopPropagation(),className:`${h} ${dy} group-hover:underline group-hover:decoration-fg/40 group-hover:underline-offset-2`,children:t}):r?(0,X.jsx)(`button`,{type:`button`,onClick:r,onMouseDown:e=>e.stopPropagation(),title:s,className:`${h} ${dy} text-left group-hover:underline group-hover:decoration-fg/40 group-hover:underline-offset-2`,children:t}):(0,X.jsx)(`span`,{className:h,title:s,children:t}),_=!!(a||r),v=d&&(0,X.jsx)(`button`,{type:`button`,onClick:d.onDismiss,onMouseDown:e=>e.stopPropagation(),title:d.title,"aria-label":d.label,className:`relative ml-0.5 shrink-0 self-start mt-[2.5px] rounded-sm p-0.5 text-muted-45 outline-none transition-colors hover:text-fg focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:(0,X.jsx)(L,{size:11})});return(0,X.jsxs)(`div`,{"data-wait-row":l,"data-wait-kind":c,onMouseEnter:i,onFocus:i,style:p?{paddingLeft:8+u}:void 0,className:`${ay} ${_?`cursor-pointer transition-colors hover:bg-fg/[0.045]`:``}`,children:[(0,X.jsx)(`span`,{className:`flex shrink-0`,children:e}),v?(0,X.jsxs)(`span`,{className:`flex items-baseline ${uy}`,children:[g,v]}):g,(0,X.jsx)(`span`,{"data-wait-status":!0,className:ly,children:n}),_?(0,X.jsx)(fy,{}):(0,X.jsx)(`span`,{"aria-hidden":!0,className:`w-3 shrink-0`})]})}function my({status:e}){return e?e.state===`closed`?e.stateReason===`not_planned`||e.stateReason===`duplicate`?(0,X.jsx)($e,{size:12,className:`${Z} text-muted`}):(0,X.jsx)(ir,{size:12,className:Z,style:{color:Fn.fgDone}}):(0,X.jsx)(Ge,{size:12,className:Z,style:{color:Fn.fgSuccess}}):(0,X.jsx)(fr,{size:12,className:`${Z} text-muted-60`})}function hy(e){if(!e)return`Checking…`;if(e.state===`closed`){let t=e.stateReason===`not_planned`?`not planned`:e.stateReason===`duplicate`?`duplicate`:null;return t?`Closed as ${t}`:`Closed`}return`Open · ${e.comments} comment${e.comments===1?``:`s`}`}function gy({watch:e}){if(e.subject===`issue`)return(0,X.jsx)(_y,{watch:e});let t=e.github,n=Va(e.target),r=di();return(0,q.useEffect)(()=>{n&&ge([e.target])},[n,e.target]),(0,X.jsx)(py,{testKind:`github`,testId:e.target,mark:(0,X.jsx)(ty,{status:t,now:r}),name:e.target,href:n??void 0,ghRef:n?e.target:void 0,title:n?`Open ${e.target} on GitHub — ${ry(t,r)}`:e.target,status:t&&t.state===`open`&&t.failed>0&&n&&!He(t,r)?(0,X.jsx)(`a`,{href:`${n}/checks`,target:`_blank`,rel:`noreferrer noopener`,title:`View the failing checks on ${e.target}`,onMouseDown:e=>e.stopPropagation(),className:`relative underline underline-offset-2 ${Qn}`,children:iy(t,r)}):iy(t,r)})}function _y({watch:e}){let t=e.issue,n=Va(e.target,`issue`);return(0,q.useEffect)(()=>{n&&ge([e.target])},[n,e.target]),(0,X.jsx)(py,{testKind:`github`,testId:`issue:${e.target}`,mark:(0,X.jsx)(my,{status:t}),name:t?.title?`${e.target} ${t.title}`:e.target,href:n??void 0,ghRef:n?e.target:void 0,title:n?`Open ${e.target} on GitHub — ${hy(t)}`:e.target,status:t?yi(t):`Checking…`})}function vy(e,t){return(e.bgShells??[]).find(e=>e.id===t||e.taskId===t||e.label===t)}function yy(e){return(e.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`)}function by({watch:e,thread:t,slug:n,now:r}){let i=vy(t,e.target);if(i)return(0,X.jsx)(Sy,{shell:i,slug:n,now:r,testId:e.target});let a=Ks(e.createdAt,r);return(0,X.jsx)(py,{testKind:`shell`,testId:e.target,mark:(0,X.jsx)(Ac,{size:12,className:`${Z} text-shell`}),name:e.target,title:e.target,status:a})}function xy(e,t,n,r,i){if(!e||t&&n)return;let a=t?`running`:`settled`;return{onDismiss:e,title:Ue[a],label:`${mt[a]} ${ye[r]}: ${i}`}}function Sy({shell:e,slug:t,now:n,testId:r,onDismiss:i,watched:a}){let o=Ks(e.startedAt,n),s=e.state===`running`,c=e.id&&!e.outputUnavailable,l=s?`running for ${o}`:nr;return(0,X.jsx)(py,{testKind:`shell`,testId:r??e.id??e.label,mark:(0,X.jsx)(Ac,{size:12,className:`${Z} ${s?`text-shell`:`text-muted-60`}`}),name:e.label,onOpen:c?()=>Ra(t,e.id,{label:e.label,startedAt:e.startedAt}):void 0,title:[c?`Read this shell's output — ${l}`:s?e.label:`${e.label} — ${l}`,a?mv:null].filter(Boolean).join(`
|
|
112
|
-
`),status:o,dismiss:xy(i,s,!!c,`SHELL`,e.label)})}function Cy({watch:e,now:t}){let n=e.timer?.prompt;return(0,X.jsx)(py,{testKind:`timer`,testId:e.target,mark:(0,X.jsx)(xe,{size:12,className:`${Z} text-muted-60`}),name:n||e.target,oneLine:!0,title:wy(e),status:Ty(e,t)})}function wy(e){return[e.timer?.prompt,e.timer?.fireAt?`One-off timer, set for ${e.timer.fireAt}`:e.target].filter(Boolean).join(`
|
|
113
|
-
|
|
114
|
-
`)}function Ty(e,t){let n=Date.parse(e.timer?.fireAt??``);return Number.isFinite(n)?n>t?`in ${Ne(n-t)}`:`firing…`:`armed`}function Ey(e){return e.trim().replace(/\s+/g,` `).replace(/(^|[\s'"=])\/(?:[^\s'"/]*\/){2,}(?=[^\s'"/])/g,`$1`)}function Dy(e){return e.command?.monitor?.description||Ey(e.command?.command??e.target)}function Oy({watch:e,slug:t,now:n}){let r=e.command?.monitor,i=r?gt:sa,a=Dy(e);return(0,X.jsx)(py,{testKind:`command`,testId:e.target,mark:(0,X.jsx)(i,{size:12,className:`${Z} text-muted-60`}),name:a,oneLine:!0,title:ky(e,n),status:Ay(e),onOpen:r?()=>Ri(t,e.target,{label:a}):void 0})}function ky(e,t){let n=e.command,r=n?.monitor;if(n&&r){let e=r.lastEvent;return[n.command,`Kept running by Frizz; every line it prints wakes the thread.`,e?`${r.events} event${r.events===1?``:`s`} so far. The last, ${Ks(e.at,t)} ago:`:`No events yet.`,e?.text.trim()||null].filter(Boolean).join(`
|
|
115
|
-
|
|
116
|
-
`)}let i=n?.lastRun,a=n&&i?`${n.runs} check${n.runs===1?``:`s`} so far. The last, ${Ks(i.at,t)} ago, ${St(i)}.`:null;return[n?.command??e.target,n?`Re-run every ${n.every} until it exits 0.`:null,a,i?.output.trim()||null].filter(Boolean).join(`
|
|
117
|
-
|
|
118
|
-
`)}function Ay(e){let t=e.command?.monitor;return t?t.events===0?`running`:`${t.events} event${t.events===1?``:`s`}`:e.command?`every ${e.command.every}`:`armed`}function jy(e){return(e.subAgents??[]).filter(e=>qs(e)&&e.state===`running`)}function My({agent:e,slug:t,now:n,onDismiss:r}){let i=Ks(e.startedAt,n),a=Oi(e.subagentType),o=e.state===`stale`;return(0,X.jsx)(py,{testKind:`agent`,testId:e.id??e.label,mark:o?(0,X.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-3 p-[3px] ${Z}`,children:(0,X.jsx)(`span`,{className:zn})}):(0,X.jsx)($v,{tone:`border-accent`}),name:e.label,onOpen:e.id?()=>Mr(t,e.id,{label:e.label,subagentType:e.subagentType,startedAt:e.startedAt}):void 0,title:e.id?`Open this sub-agent${a?` (${a})`:``} — ${o?De:`working for ${i}`}`:e.label,status:i,dismiss:xy(r,e.state===`running`,!!e.id,`AGENT`,e.label)})}function Ny({child:e,now:t}){let n=jt(e),r=Cs(e),i=Ks(Kr(e),t),a=r===`running`?(0,X.jsx)($v,{tone:`border-accent`}):(0,X.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-3 p-[3px] ${Z}`,children:(0,X.jsx)(`span`,{className:r===`stale`?zn:Jn})}),o=r===`rested`&&!e.needsYou&&e.waitStatus!==void 0,s=e.needsYou?at:r===`running`?i:r===`stale`?`stale`:o?vr:`rested`;return(0,X.jsx)(py,{testKind:`thread`,testId:e.id,mark:a,name:n,onOpen:()=>ki(e.id),title:`Open child thread — ${r===`running`?`working for ${i}`:r===`stale`?Ze:e.needsYou?at:o?ur:Co}`,status:s})}function Py(e,t,n){let r=new Set(n.map(e=>e.target)),i=[];for(let n of t){if(n.kind!==`shell`)continue;let t=n.value.trim();if(!t||r.has(t))continue;let a=vy(e,t);!a||a.state!==`running`||(r.add(t),i.push({id:`shell:${e.id}:${t}`,kind:`shell`,target:t,state:`armed`,createdAt:a.startedAt}))}return i}function Fy(e,t={}){let n=(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`),r=n.filter(e=>e.subject!==`issue`),i=n.filter(e=>e.subject===`issue`),a=yy(e),o=[...a,...Py(e,t.hints??[],a)],s=jy(e),c=new Set((t.hints??[]).filter(e=>e.kind===`thread`).map(e=>e.value));return{prs:r,issues:i,shells:o,agents:s,children:(t.childThreads??[]).filter(e=>Cs(e)===`running`||c.has(e.id)),timers:Gv(e),commands:Kv(e)}}function Iy(e,t,n={}){let{prs:r,issues:i,shells:a,agents:o,children:s,timers:c,commands:l}=Fy(e,n);return[{head:`Sub-agents`,rows:o.map(n=>(0,X.jsx)(My,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Child threads`,rows:s.map(e=>(0,X.jsx)(Ny,{child:e,now:t},e.id))},{head:`Background shells`,rows:a.map(n=>(0,X.jsx)(by,{watch:n,thread:e,slug:e.id,now:t},n.id))},{head:`Pull requests`,rows:r.map(e=>(0,X.jsx)(gy,{watch:e},e.id))},{head:`Issues`,rows:i.map(e=>(0,X.jsx)(gy,{watch:e},e.id))},{head:`Monitors`,rows:l.map(n=>(0,X.jsx)(Oy,{watch:n,slug:e.id,now:t},n.id))},{head:`Timers`,rows:c.map(e=>(0,X.jsx)(Cy,{watch:e,now:t},e.id))}].filter(e=>e.rows.length>0)}function Ly({group:e,first:t}){let n=`px-2 text-[10.5px] uppercase tracking-wide text-muted-45 ${t?``:`mt-4`}`;return e.onToggle?(0,X.jsxs)(`button`,{type:`button`,onClick:e.onToggle,"aria-expanded":!e.collapsed,onMouseDown:e=>e.stopPropagation(),className:`${n} flex items-baseline rounded-sm text-left transition-colors hover:text-muted-80`,children:[(0,X.jsx)(`span`,{children:e.head}),e.count!==void 0&&(0,X.jsx)(`span`,{className:`ml-1.5 tabular-nums`,children:e.count}),(0,X.jsx)(br,{size:10,"aria-hidden":!0,className:`${Z} ml-[5px] transition-transform ${e.collapsed?``:`rotate-90`}`})]}):(0,X.jsx)(`div`,{className:n,children:e.head})}function Ry({groups:e,divider:t}){return e.length===0?null:(0,X.jsxs)(X.Fragment,{children:[t&&(0,X.jsx)(`div`,{"aria-hidden":!0,className:`-mx-4 mt-3 border-t border-border`}),(0,X.jsx)(`div`,{className:`-mx-2 mt-3 flex flex-col gap-y-px`,children:e.map((e,t)=>(0,X.jsxs)(q.Fragment,{children:[(0,X.jsx)(Ly,{group:e,first:t===0}),!e.collapsed&&e.rows]},e.head))})]})}function zy(e){return e?.lastFence?.kind===`awaiting`&&hi(e.lastFence.hints)?!1:e?.awaitingBackground===!0&&e.runtime===`turn-idle`&&e.bgSnoozed!==!0}var By=`Hides card until new activity is detected`;function Vy({thread:e,onSnooze:t,onSnoozeFailed:n}){let[r,i]=(0,q.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{i(!0),t?.(),U.snoozeAwaitingBackground({slug:e.id,sessionId:e.sessionId??``}).then(()=>G(`Snoozed until the background work returns`)).catch(e=>{n?.(),G(`Couldn’t snooze: ${e.message.slice(0,80)}`),i(!1)})},disabled:r,onMouseDown:e=>e.preventDefault(),title:By,className:`disabled:opacity-45 ${jm}`,children:[(0,X.jsx)(Le,{size:12,className:hv}),`Snooze`]}),(0,X.jsx)(`span`,{className:Dm,children:By})]})}function Hy({thread:e,fence:t,onSnooze:n,onSnoozeFailed:r,onReplied:i,onReplyFailed:a,stepsDone:o}){let s=e??qv,c=t??(e?.lastFence?.kind===`awaiting`?e.lastFence:void 0),l=c?.hints??Jv,u=Sa(l),d=de(l),f=e!==void 0&&G_(e,u),p=Bv(s),m=Mi(c?.body),h=tp(m??``),g=di(),_=u.length===0,v=lt(s.id),y=_?Iy(s,g,{hints:l,childThreads:v}):[],b=_?Yv(s,l):[],x=e!==void 0&&t===void 0&&u.length===0&&e.waitStatus!==`watching`&&zy(e)&&sv(e).snooze;return(0,X.jsxs)(wm,{"data-awaiting-background":!0,icon:u.length>0?hc:Wv(s)?Ac:Le,kind:Uv(s,l),label:d?(0,X.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:d}):null,children:[m?(0,X.jsx)($h,{className:`md-body ${lm}`,html:h}):y.length===0&&!Hv(s)&&u.length===0?(0,X.jsx)(`p`,{className:Tm,children:oi}):null,u.length>0&&(f?(0,X.jsx)(jv,{thread:e,onReplied:i,onReplyFailed:a}):(0,X.jsx)(Ev,{steps:Bt(l),done:o})),b.length>0&&(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:b.map(e=>(0,X.jsx)(Xv,{watch:e},e.ref))}),_&&y.length===0&&Hv(s)&&(0,X.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75`,children:p?(0,X.jsxs)(X.Fragment,{children:[`It’s awaiting the results from `,zv(s,{watchers:!1}),` it dispatched. It returns to the queue on its own when the work comes back.`]}):(0,X.jsxs)(X.Fragment,{children:[zv(s,{watchers:!1}),` `,Vv(s)===1?`is`:`are`,` still running. It resumes on its own when`,` `,Vv(s)===1?`it finishes`:`one of them finishes`,`.`]})}),(0,X.jsx)(Ry,{groups:y,divider:!!m}),x?(0,X.jsx)(Em,{"data-awaiting-snooze":!0,children:(0,X.jsx)(Vy,{thread:e,onSnooze:n,onSnoozeFailed:r})}):null]})}function Uy(e){let t=e?Date.parse(e):NaN;return Number.isFinite(t)?t:null}function Wy(e,t){let n=Uy(e),r=Uy(t);return n===null||r===null?null:new Date(n).toDateString()!==new Date(r).toDateString()||r-n>=12e5?t:null}function Gy(e,t){let n=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();return Math.round((n(t)-n(e))/864e5)}function Ky(e,t=new Date,n){let r=new Date(Date.parse(e)),i=r.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`}),a=Gy(r,t);return{day:a===0?`Today`:a===1?`Yesterday`:a>1&&a<7?r.toLocaleDateString(n,{weekday:`long`}):r.toLocaleDateString(n,r.getFullYear()===t.getFullYear()?{month:`short`,day:`numeric`}:{month:`short`,day:`numeric`,year:`numeric`}),time:i}}function qy(e,t=new Date,n){let r=Uy(e);if(r===null)return null;let i=new Date(r),a=i.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`}),o=Gy(i,t);return`${o===0?`Today`:o===1?`Yesterday`:i.toLocaleDateString(n,i.getFullYear()===t.getFullYear()?{weekday:`long`,month:`long`,day:`numeric`}:{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})} at ${a}`}function Q({icon:e,children:t,sourceId:n,ariaLabel:r,marker:i,at:a,trailing:o,onClick:s,ariaExpanded:c,ariaControls:l}){let u=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:Yy}),(0,X.jsx)(Jy,{icon:e,at:a,trailing:o,children:t}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:Yy})]});return s?(0,X.jsx)(`button`,{type:`button`,"data-wake-divider":i,onClick:s,onMouseDown:e=>e.preventDefault(),"aria-label":r,"aria-expanded":c,"aria-controls":l,className:`group/wake @container/wake my-1 flex w-full items-center gap-3 rounded-sm text-left outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:u}):(0,X.jsx)(`div`,{"data-frizz-msg":n,"data-wake-divider":i,className:`@container/wake my-1 flex items-center gap-3`,role:r?`separator`:void 0,"aria-label":r,children:u})}function Jy({icon:e,children:t,at:n,trailing:r}){return(0,X.jsxs)(`span`,{className:`petite-caps flex min-w-0 items-center gap-1 overflow-x-clip break-words text-center text-[12px] text-muted-70 transition-colors group-hover/wake:text-fg${r?` pr-px`:``}`,children:[e&&(0,X.jsx)(e,{"aria-hidden":`true`,size:12,className:`shrink-0 translate-y-[0.04em]`}),t,(0,X.jsx)(tb,{at:n}),r]})}var Yy=`h-px min-w-[50px] flex-1 bg-border/70 transition-colors group-hover/wake:bg-border`,Xy=`@max-[34rem]/wake:hidden`,Zy=`@min-[34rem]/wake:hidden`,Qy=`@max-[19.5rem]/wake:hidden`;function $y({open:e}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50 ${Qy}`,children:`·`}),(0,X.jsxs)(`span`,{className:`shrink-0 ${Qy}`,children:[(0,X.jsx)(`span`,{className:Xy,children:`Click to `}),e?`collapse`:`expand`]})]})}function eb({lead:e,title:t,tail:n,note:r}){return(0,X.jsxs)(X.Fragment,{children:[e&&(0,X.jsxs)(`span`,{className:`shrink-0 @max-[34rem]/wake:hidden`,children:[e,` `]}),(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center`,title:t,children:[(0,X.jsx)(`span`,{className:`shrink-0`,children:`«`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`»`})]}),n&&(0,X.jsxs)(`span`,{className:`shrink-0`,children:[` `,n]}),r&&(0,X.jsxs)(`span`,{className:`shrink-0 @max-[34rem]/wake:hidden`,children:[` `,r]})]})}function tb({at:e}){let t=xo(e,di());return t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,X.jsx)(`span`,{title:qy(e)??void 0,className:`shrink-0 tabular-nums`,children:t})]}):null}var nb=`shrink-0 translate-y-[0.04em]`;function rb({bump:e,sourceId:t,at:n}){let r=e.kind===`schedule`;if(e.kind===`signoff`){let e=`Frizz asked for a sign-off`;return(0,X.jsx)(Q,{icon:Dc,sourceId:t,marker:`rest`,ariaLabel:e,at:n,children:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,X.jsx)(`span`,{className:Xy,children:e}),(0,X.jsx)(`span`,{className:Zy,children:`Sign-off requested`})]})})}let i=r?`Goal${e.every?` · every ${e.every}`:``}`:`Goal · at rest`;return(0,X.jsx)(Q,{icon:r?ga:wc,sourceId:t,marker:r?`schedule`:`rest`,ariaLabel:i,at:n,children:(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:i})})}function ib({h:e=14}){return(0,X.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0`,style:{height:e}})}function ab(e,t,n){return e===1?n?`New ${t} from @${n}`:`New ${t}`:`${e} new items`}var ob=`rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`;function sb({steer:e,text:t,sourceId:n,at:r,wrap:i}){let a=Tr(t);if(a)return(0,X.jsx)(cb,{parts:a,sourceId:n,at:r,wrap:i});let o=$a(t);if(o)return(0,X.jsx)(rb,{bump:o,sourceId:n,at:r});let s=Fo(t);if(s)return(0,X.jsx)(Cb,{wake:s,sourceId:n,at:r});let l=ei(t);if(l)return(0,X.jsx)(ub,{wake:l,sourceId:n});let u=lr(t);if(u)return(0,X.jsx)(xb,{window:u.window,sourceId:n,at:r});let d=_r(t);if(d)return(0,X.jsx)(Sb,{capped:d.capped,to:d.to,sourceId:n,at:r});let f=_i(t);if(f)return(0,X.jsx)(fb,{wake:f,sourceId:n,at:r});let p=Wo(t);if(p)return(0,X.jsx)(pb,{watchRef:p.ref,sourceId:n,at:r});let m=Wa(t);if(m)return(0,X.jsx)(pb,{watchRef:m.ref,sentence:`Not found — watcher ended`,sourceId:n,at:r});let h=c(t);if(h)return(0,X.jsx)(_b,{kind:h.kind,sourceId:n,at:r});let g=it(t);if(g)return(0,X.jsx)(vb,{wake:g,sourceId:n,at:r});let _=rn(t);if(_)return(0,X.jsx)(yb,{wake:_,sourceId:n,at:r});let v=Xe(t);if(v)return(0,X.jsx)(bb,{agents:v.agents,sourceId:n,at:r});let y=Rr(t);if(y)return(0,X.jsx)(db,{count:y.count,sourceId:n,at:r});let b=$i(t),x=Eo(t),S=e??So(b||x?t.split(`
|
|
119
|
-
`).filter(e=>!$i(e)&&!Eo(e)).join(`
|
|
120
|
-
`):t);return!S&&!b&&!x?(0,X.jsx)(`div`,{"data-frizz-msg":n,"data-frizz-wake":!0,className:`min-w-0 max-w-[85%]`,children:(0,X.jsx)(wm,{icon:Qs,label:`Frizz`,children:(0,X.jsx)(lb,{text:Fi(t),wrap:i})})}):b||x?(0,X.jsxs)(`div`,{"data-frizz-wake":!0,className:`flex flex-col`,children:[b&&(0,X.jsx)(wb,{wake:b,sourceId:n,at:r}),x&&(0,X.jsxs)(X.Fragment,{children:[b&&(0,X.jsx)(ib,{}),(0,X.jsx)(Tb,{wake:x,sourceId:b?void 0:n,at:r})]}),S&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ib,{}),(0,X.jsx)(Eb,{steer:S,text:t,at:r})]})]}):(0,X.jsx)(Eb,{steer:S,text:t,sourceId:n,at:r})}function cb({parts:e,sourceId:t,at:n,wrap:r}){let i=e.map(e=>Fi(e.body)).filter(e=>!Pe(e)&&!qn(e));return i.length?(0,X.jsx)(`div`,{"data-frizz-wake":`merged`,className:`flex flex-col`,children:i.map((e,i)=>(0,X.jsxs)(q.Fragment,{children:[i>0&&(0,X.jsx)(ib,{}),(0,X.jsx)(sb,{text:e,sourceId:i===0?t:void 0,at:n,wrap:r})]},i))}):null}function lb({text:e,wrap:t}){let n=tp(e),r=Up(n),i=(0,q.useRef)(null),a=th(i,n);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{ref:i,className:`md-body [overflow-wrap:anywhere]${t?` ${lm}`:``}`,dangerouslySetInnerHTML:r}),a]})}function ub({wake:e,sourceId:t}){let[n,r]=(0,q.useState)(!1),i=(0,q.useId)();return(0,X.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,X.jsxs)(Q,{icon:bi,marker:`timer`,at:e.at,onClick:()=>r(e=>!e),ariaExpanded:n,ariaControls:i,ariaLabel:`${n?`Collapse`:`Expand`} the text this timer handed back`,children:[(0,X.jsx)(`span`,{className:`shrink-0`,children:`Timer`}),(0,X.jsx)($y,{open:n})]}),n&&(0,X.jsx)(`div`,{id:i,className:`mt-1.5 whitespace-pre-wrap border-l border-border/70 pl-3 text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.prompt})]})}function db({count:e,sourceId:t,at:n}){let r=`${e} question${e===1?``:`s`} cancelled`,i=` — the worker decides ${e===1?`it`:`them`} itself`;return(0,X.jsx)(Q,{icon:_c,sourceId:t,marker:`event`,ariaLabel:`${r}${i}`,at:n,children:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[r,(0,X.jsx)(`span`,{className:Xy,children:i})]})})}function fb({wake:e,sourceId:t,at:n}){let[r,i]=(0,q.useState)(!1),a=(0,q.useId)(),o=e.kind===`expired`?`Wait expired`:`Wait over`,s=e.kind===`expired`?` — nothing resolved`:` — its work finished`,c=(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[o,(0,X.jsx)(`span`,{className:Xy,children:s})]});return e.items.length?(0,X.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,X.jsxs)(Q,{icon:Le,marker:`event`,at:n,onClick:()=>i(e=>!e),ariaExpanded:r,ariaControls:a,ariaLabel:`${r?`Collapse`:`Expand`} what this wait named`,children:[c,(0,X.jsx)($y,{open:r})]}),r&&(0,X.jsx)(`div`,{id:a,className:`mt-1.5 whitespace-pre-wrap border-l border-border/70 pl-3 text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.items.join(`
|
|
121
|
-
`)})]}):(0,X.jsx)(Q,{icon:Le,sourceId:t,marker:`event`,ariaLabel:`${o}${s}`,at:n,children:c})}function pb({watchRef:e,sentence:t=`Watcher expired`,sourceId:n,at:r}){let i=Va(e);return(0,X.jsx)(Q,{icon:st,sourceId:n,marker:`event`,ariaLabel:`${t} on ${e}`,at:r,children:(0,X.jsx)(mb,{sentence:t,children:i?(0,X.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:ob,children:(0,X.jsx)(gb,{value:e})}):(0,X.jsx)(gb,{value:e})})})}function mb({sentence:e,children:t}){return(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),(0,X.jsxs)(`span`,{className:`shrink-0 whitespace-pre`,children:[(0,X.jsx)(hb,{}),` `,t]})]})}function hb(){return(0,X.jsx)(`span`,{className:Xy,children:` on`})}function gb({value:e}){let t=e.lastIndexOf(`#`);return t<=0?(0,X.jsx)(X.Fragment,{children:e}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:Xy,children:e.slice(0,t)}),e.slice(t)]})}function _b({kind:e,sourceId:t,at:n}){let r=` on a ${e===`agent`?`sub-agent`:`background shell`}`;return(0,X.jsx)(Q,{icon:e===`agent`?$s:Ac,sourceId:t,marker:`event`,ariaLabel:`Watch expired${r}`,at:n,children:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Watch expired`,(0,X.jsx)(`span`,{className:Xy,children:r})]})})}function vb({wake:e,sourceId:t,at:n}){let[r,i]=(0,q.useState)(!1),a=(0,q.useId)(),o=e.kind===`cancelled`?`stopped`:e.kind;return(0,X.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,X.jsxs)(Q,{icon:sa,marker:`event`,at:n,onClick:()=>i(e=>!e),ariaExpanded:r,ariaControls:a,ariaLabel:`${r?`Collapse`:`Expand`} how this monitor ended`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate ${Zy}`,children:`${o.charAt(0).toUpperCase()}${o.slice(1)}`}),(0,X.jsx)(`span`,{className:`flex min-w-0 items-center gap-1 ${Xy}`,children:(0,X.jsx)(eb,{lead:`Monitor`,title:Ey(e.command),tail:e.kind===`cancelled`?`stopped by Frizz`:o})}),(0,X.jsx)($y,{open:r})]}),r&&(0,X.jsxs)(`div`,{id:a,className:`mt-1.5 flex flex-col gap-1.5 border-l border-border/70 pl-3 text-[13px] text-muted [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`div`,{className:`whitespace-pre-wrap font-mono text-[12px]`,children:e.command}),(0,X.jsx)(`div`,{children:e.summary}),e.output!==void 0&&(0,X.jsx)(`div`,{className:`whitespace-pre-wrap font-mono text-[12px]`,children:e.output})]})]})}function yb({wake:e,sourceId:t,at:n}){let[r,i]=(0,q.useState)(!1),a=(0,q.useId)(),o=`${e.count} line${e.count===1?``:`s`}`,s=e.kind===`event`?o:e.kind===`exited`?`Ended`:e.kind===`expired`?`Expired`:`Stopped`,c=e.kind===`event`?o:e.kind===`exited`?`ended`:e.kind===`expired`?`expired`:e.by===`human`?`stopped by you`:`stopped by Frizz`;return(0,X.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,X.jsxs)(Q,{icon:gt,marker:`event`,at:n,onClick:()=>i(e=>!e),ariaExpanded:r,ariaControls:a,ariaLabel:`${r?`Collapse`:`Expand`} ${e.kind===`event`?`what this monitor printed`:`how this monitor ended`}`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate ${Zy}`,children:s}),(0,X.jsx)(`span`,{className:`flex min-w-0 items-center gap-1 ${Xy}`,children:(0,X.jsx)(eb,{lead:`Monitor`,title:e.label??Ey(e.command??e.id),tail:c})}),(0,X.jsx)($y,{open:r})]}),r&&(0,X.jsxs)(`div`,{id:a,className:`mt-1.5 flex flex-col gap-1.5 border-l border-border/70 pl-3 text-[13px] text-muted [overflow-wrap:anywhere]`,children:[e.command!==void 0&&(0,X.jsx)(`div`,{className:`whitespace-pre-wrap font-mono text-[12px]`,children:e.command}),(0,X.jsx)(`div`,{children:e.summary}),e.output!==void 0&&(0,X.jsx)(`div`,{className:`whitespace-pre-wrap font-mono text-[12px]`,children:e.output})]})]})}function bb({agents:e,sourceId:t,at:n}){return(0,X.jsx)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:e.map((e,t)=>(0,X.jsxs)(q.Fragment,{children:[t>0&&(0,X.jsx)(ib,{}),(0,X.jsx)(Q,{icon:$s,marker:`event`,ariaLabel:`Sub-agent ${e.label} stopped by the interrupt`,at:n,children:(0,X.jsx)(eb,{lead:`Sub-agent`,title:e.label,tail:`stopped`,note:`by the interrupt`})})]},t))})}function xb({window:e,sourceId:t,at:n}){let r=e===`weekly`?`Weekly usage limit`:e===`session`?`Session usage limit`:`Usage limit`,i=`${r} reset — resuming`,a=e===`weekly`?`Weekly`:e===`session`?`Session`:null;return(0,X.jsx)(Q,{icon:Le,sourceId:t,marker:`limit-resume`,ariaLabel:i,at:n,children:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[a?(0,X.jsxs)(X.Fragment,{children:[a,(0,X.jsx)(`span`,{className:Xy,children:` usage`}),` limit`]}):r,` reset`,(0,X.jsx)(`span`,{className:Xy,children:` — resuming`})]})})}function Sb({capped:e,to:t,sourceId:n,at:r}){return(0,X.jsx)(Q,{icon:Le,sourceId:n,marker:`limit-model-switch`,ariaLabel:`${e} limit — switched to ${t}`,at:r,children:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e,(0,X.jsx)(`span`,{className:Xy,children:` limit — switched to `}),(0,X.jsx)(`span`,{className:Zy,children:` → `}),t]})})}function Cb({wake:e,sourceId:t,at:n}){let r=e.label.length>64?`${e.label.slice(0,63)}…`:e.label;return(0,X.jsx)(Q,{icon:Ac,sourceId:t,marker:`event`,ariaLabel:`Background task «${r}» ${e.outcome}`,at:n,children:(0,X.jsx)(eb,{lead:`Background task`,title:r,tail:e.outcome})})}function wb({wake:e,sourceId:t,at:n}){let r=Va(e.ref),i=r?(0,X.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:ob,children:(0,X.jsx)(gb,{value:e.ref})}):(0,X.jsx)(`span`,{children:(0,X.jsx)(gb,{value:e.ref})}),a=e.kind===`ci`?e.verdict===`passing`?`passed`:e.verdict===`failing`?`failed`:`awaiting approval`:``,o=e.kind===`ci`?`CI ${a}`:`PR ${e.kind}`,s=e.kind===`ci`?e.verdict===`failing`&&e.failing.length?`: ${e.failing.join(`, `)}`:e.verdict===`gated`&&e.gating.length?`: ${e.gating.join(`, `)}`:``:``,c=e.kind===`ci`&&e.verdict!==`gated`&&e.commit?` at ${e.commit}`:``,l=e.kind===`ci`?e.verdict===`passing`&&e.passed!==void 0?`${e.passed} ${e.passed===1?`check`:`checks`} green${e.skipped?`, ${e.skipped} skipped`:``}`:e.verdict===`gated`?`${e.gated} ${e.gated===1?`workflow`:`workflows`} held`:null:null;return(0,X.jsxs)(Q,{icon:st,sourceId:t,marker:`github`,at:n,ariaLabel:r?void 0:`${o} on ${e.ref}${c}${s}${l?` · ${l}`:``}`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[o,(0,X.jsx)(hb,{}),` `,i,c,s]}),l&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50 @max-[34rem]/wake:hidden`,children:`·`}),(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums @max-[34rem]/wake:hidden`,children:l})]})]})}function Tb({wake:e,sourceId:t,at:n}){let r=Va(e.ref),i=r?(0,X.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:ob,children:(0,X.jsx)(gb,{value:e.ref})}):(0,X.jsx)(`span`,{children:(0,X.jsx)(gb,{value:e.ref})});return(0,X.jsx)(Q,{icon:st,sourceId:t,marker:`github`,at:n,ariaLabel:r?void 0:`PR updated on ${e.ref}: ${e.detail}`,children:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`PR updated`,(0,X.jsx)(hb,{}),` `,i,`: ${e.detail}`]})})}function Eb({steer:e,text:t,sourceId:n,at:r}){let i=Va(e.ref),a=e.items.length+e.omitted,o=T(t),s=!o&&e.items.length===1&&e.omitted===0?e.items[0]:null,c=s?.url??i,l=o?`${a} ${a===1?`item`:`items`} already`:ab(a,e.items[0]?.label??`item`,s?.actor),u=!o&&s?.actor&&l.endsWith(` from @${s.actor}`)?` from @${s.actor}`:``,d=!o&&l.startsWith(`New `)?`New `:``,f=c?(0,X.jsx)(`a`,{href:c,target:`_blank`,rel:`noreferrer noopener`,className:ob,children:(0,X.jsx)(gb,{value:e.ref})}):(0,X.jsx)(`span`,{children:(0,X.jsx)(gb,{value:e.ref})});return(0,X.jsx)(Q,{icon:st,sourceId:n,marker:`github`,at:s?.at??r,ariaLabel:c?void 0:`${l} on ${e.ref}`,children:(0,X.jsx)(mb,{sentence:(0,X.jsxs)(X.Fragment,{children:[d&&(0,X.jsx)(`span`,{className:`@max-[34rem]/wake:hidden`,children:d}),l.slice(d.length,l.length-u.length),u&&(0,X.jsx)(`span`,{className:`@max-[34rem]/wake:hidden`,children:u})]}),children:f})})}var Db=/(^|[^\w/.@-])(https?:\/\/[^\s<>`]+|www\.[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:[^\s<>`]*)?)/gi,Ob=new Set([`.`,`,`,`:`,`;`,`!`,`?`,`*`,`_`,`~`,`'`,`"`]),kb={")":`(`,"]":`[`,"}":`{`};function Ab(e){let t=e;for(;;){let e=t[t.length-1];if(e!==void 0&&Ob.has(e)){t=t.slice(0,-1);continue}let n=e===void 0?void 0:kb[e];if(n){let r=0;for(let i of t)i===n?r++:i===e&&r--;if(r<0){t=t.slice(0,-1);continue}}break}return t}function jb(e,t,n){if(t===``)return;let r=0;for(let i of Me(t,n))i.start>r&&e.push({kind:`text`,text:t.slice(r,i.start)}),e.push({kind:`link`,text:i.text,href:i.href,title:i.title,ghRef:Gs(i.href)}),r=i.start+i.text.length;r<t.length&&e.push({kind:`text`,text:t.slice(r)})}function Mb(e,t){let n=[],r=0;Db.lastIndex=0;for(let i=Db.exec(e);i;i=Db.exec(e)){let[,a,o]=i,s=Ab(o);if(/^https?:\/\/$/i.test(s)||s===``)continue;let c=i.index+a.length;Db.lastIndex=c+s.length;let l=/^www\./i.test(s)?`http://${s}`:s;c>r&&jb(n,e.slice(r,c),t),n.push({kind:`link`,text:s,href:l,ghRef:Gs(l)}),r=c+s.length}return r<e.length&&jb(n,e.slice(r),t),n}function Nb({text:e}){let t=$f(),n=(0,q.useMemo)(()=>Mb(e,t),[e,t]),r=(0,q.useMemo)(()=>n.flatMap(e=>e.kind===`link`&&e.ghRef?[e.ghRef]:[]),[n]);return(0,q.useEffect)(()=>{r.length>0&&ge(r)},[r]),(0,X.jsx)(X.Fragment,{children:n.map((e,t)=>e.kind===`text`?e.text:(0,X.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,title:e.title,"data-gh-ref":e.ghRef??void 0,className:`underline underline-offset-2`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:e.text},t))})}function Pb({answers:e,queued:t,sourceId:n}){return(0,X.jsx)(`div`,{"data-frizz-msg":n,"data-answers-card":!0,className:`self-end flex w-full max-w-[85%] flex-col items-end ${t?`opacity-50`:``}`,children:(0,X.jsxs)(`div`,{className:`w-full min-w-0 ${um} rounded-br-sm border border-border-strong bg-elevated p-4`,children:[(0,X.jsx)(_m,{icon:mc,label:`Answers`}),(0,X.jsx)(Cm,{children:(0,X.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:a_(e).map((e,t)=>(0,X.jsxs)(`div`,{"data-answer-id":e.handle,className:e.followUp?`ml-3 flex flex-col gap-1 border-l border-border pl-3`:`flex flex-col gap-1`,children:[e.question&&(0,X.jsx)(`div`,{title:e.question,className:`line-clamp-2 min-w-0 [overflow-wrap:anywhere] text-[11px] leading-snug text-muted`,children:e.question}),(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[!e.question&&(0,X.jsx)(`span`,{className:`mt-1.5 shrink-0 text-[10px] uppercase tabular-nums tracking-wide text-muted-70`,children:e.n}),(0,X.jsx)(Ib,{answer:e.answer})]})]},t))})})]})})}var Fb=`min-w-0 [overflow-wrap:anywhere] rounded-md border border-border-strong border-l-2 border-l-accent/40 bg-bg/50 px-2.5 py-1.5 text-[12px] leading-snug text-fg`;function Ib({answer:e}){let{picks:t,note:n}=o_(e);return t.length===0?(0,X.jsx)(`span`,{className:`${Fb} flex-1 whitespace-pre-wrap`,children:(0,X.jsx)(Nb,{text:e})}):(0,X.jsxs)(`div`,{className:`${Fb} flex flex-1 flex-col`,children:[(0,X.jsx)(`ul`,{className:`flex flex-col gap-1`,children:t.map((e,t)=>(0,X.jsxs)(`li`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`mt-px flex h-3.5 w-3.5 shrink-0 self-start items-center justify-center rounded-[3px] border border-control-strong text-fg`,children:(0,X.jsx)(Qt,{size:10,strokeWidth:3})}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Nb,{text:e})})]},t))}),n&&(0,X.jsx)(`div`,{className:`mt-1.5 whitespace-pre-wrap border-t border-border pt-1.5`,children:(0,X.jsx)(Nb,{text:n})})]})}var Lb=(0,q.createContext)(null),Rb=(0,q.createContext)(null),zb=(0,q.createContext)(null);function Bb(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`&&e[t].kind!==`event`)return t;return-1}function Vb(e){return e.sourceId??`legacy-${Zb(e.text)}`}function Hb(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.kind===`event`||n.kind===`reasoning`)&&n.role===`assistant`&&n.text.trim())return t}return-1}var Ub=e=>ug(e).filter(e=>e.kind===`question`).map(e=>e.kind===`question`?kg(e.text,e.questionKind,e.danger):kg(``,`question`));function Wb(){let e=new Set;return(t,n)=>{let r=Vb(t);return e.has(r)&&(r=`${r}#${n}`),e.add(r),r}}function Gb(e){let t=Hb(e),n=Wb(),r=[];for(let i=0;i<e.length;i++){let a=e[i];if(a.kind===`event`||a.kind===`reasoning`||a.role!==`assistant`||!a.text.trim()||!a.text.includes("```question"))continue;let o=Ub(a.text);o.length>0&&r.push({idx:i,identity:n(a,i),blocks:o,isLive:i===t})}return r}function Kb(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.kind===`event`||n.kind===`reasoning`)){if(n.role===`user`&&n.text.trim())break;if(!(n.role!==`assistant`||!n.text.trim())&&Ub(n.text).length>0)return t}}return-1}function qb(e){let{answered:t,live:n}=e;return t.length>0&&t.every(e=>e.isLive)&&n?`Answers:\n${n.numbered.map(({n:e,a:t})=>`${e}. ${pn(t)}`).join(`
|
|
122
|
-
`)}`:`${Ba}\n${t.map((e,t)=>`${t+1}. “${e.question}” → ${pn(e.answer)}`).join(`
|
|
123
|
-
`)}`}function Jb(e,t,n,r={}){let i=Fr(e),[a,o]=(0,q.useState)({}),s=(0,q.useMemo)(()=>Gb(t),[t]),c=(0,q.useMemo)(()=>{for(let e=t.length-1;e>=0;e--)if(!(t[e].kind===`event`||t[e].kind===`reasoning`)&&t[e].role===`assistant`&&t[e].text.trim())return t[e]},[t]),l=(0,q.useMemo)(()=>Kb(t)!==-1,[t]),u=yn(),d=j(e),f=(0,q.useCallback)((t,n)=>jr.answer(u,e,d,t,n),[u,e,d]),p=(0,q.useMemo)(()=>s.flatMap(e=>e.blocks.map((t,n)=>f(e.identity,n))),[s,f]),m=Es(p),h=(0,q.useRef)(n);h.current=n;let g=(0,q.useRef)(r.onSendFailed);g.current=r.onSendFailed;let _=(0,q.useCallback)((e,t)=>({...a[`${e}::${t}`]??{chosen:null,text:``},text:m.get(f(e,t))??``}),[a,m,f]),v=(0,q.useMemo)(()=>{let e=new Map;for(let t of s)e.set(t.identity,t);return e},[s]),y=(0,q.useCallback)((e,t,n)=>{let r=v.get(e)?.blocks[t],i=`${e}::${t}`;o(e=>{let t=e[i]??{chosen:null,text:``};if(r?.kind===`multi`){let r=new Set(t.chosenSet??[]);return r.has(n)?r.delete(n):r.add(n),{...e,[i]:{chosen:null,text:t.text,chosenSet:[...r].sort((e,t)=>e-t)}}}return{...e,[i]:{chosen:t.chosen===n?null:n,text:t.text}}})},[v]),b=(0,q.useCallback)((e,t,n)=>{let r=v.get(e)?.blocks[t];ls.set(f(e,t),n),o(i=>{let a=`${e}::${t}`,o=i[a]??{chosen:null,text:``};return r?.kind===`multi`?{...i,[a]:{chosen:null,text:n,chosenSet:o.chosenSet??[]}}:{...i,[a]:{chosen:null,text:n}}})},[v,f]),x=s.reduce((e,t)=>e+t.blocks.filter((e,n)=>Fg(e,_(t.identity,n))!==``).length,0),S=x>0,C=(0,q.useCallback)((e,t={})=>{i.submit(e,{...t,onRollback:e=>{t.onRollback?.(e),g.current?.()}})&&h.current?.()},[i]),w=(0,q.useCallback)(e=>{let t=e?s.filter(t=>t.identity===e):s,n=e?t.flatMap(e=>e.blocks.map((t,n)=>f(e.identity,n))):p,r=t.flatMap(e=>e.blocks.map((t,n)=>`${e.identity}::${n}`)),i=(e,t)=>Fg(e.blocks[t],_(e.identity,t)),c=t.flatMap(e=>e.blocks.map((t,n)=>({ask:e,bi:n,question:Xb(t),answer:i(e,n)})).filter(e=>e.answer!==``));if(c.length===0)return null;let l=t.find(e=>e.isLive),u=qb({answered:c.map(e=>({isLive:e.ask.isLive,question:e.question,answer:e.answer})),live:l&&{numbered:l.blocks.map((e,t)=>({n:t+1,a:i(l,t)})).filter(({a:e})=>e!==``)}}),d=a,m=n.map(e=>[e,ls.get(e)]);return{wire:u,onOptimistic:()=>{n.forEach(e=>ls.clear(e)),o(e=>{let t={...e};for(let e of r)delete t[e];return t})},onRollback:()=>{o(e=>{let t={...e};for(let e of r)d[e]?t[e]=d[e]:delete t[e];return t}),m.forEach(([e,t])=>{t&&!ls.get(e)&&ls.set(e,t)})}}},[a,s,_,p,f]),T=(0,q.useCallback)(()=>w(),[w]),E=r.composer,D=(0,q.useCallback)(e=>{if(E?.run())return;let t=w(typeof e==`string`?e:void 0);t&&C(t.wire,{onOptimistic:t.onOptimistic,onRollback:t.onRollback})},[E,w,C]),O=(0,q.useCallback)(e=>{let t=v.get(Vb(e));if(t)return{answerFor:e=>_(t.identity,e),onChip:(e,n)=>y(t.identity,e,n),onText:(e,n)=>b(t.identity,e,n),onSubmit:()=>D(t.identity),anyAnswered:t.blocks.some((e,n)=>Fg(e,_(t.identity,n))!==``),sending:i.pending}},[v,_,y,b,D,i.pending]);return{liveMsg:c,answering:(0,q.useMemo)(()=>c?O(c):void 0,[c,O]),answeringForMessage:O,answerable:l,anyAnswered:S,sending:i.pending,sendAnswers:D,sendMessage:C,stagedCount:x,takeAnswers:T}}function Yb(e){let t=e.split(`
|
|
124
|
-
`).map(e=>e.trim()).find(e=>e.length>0)??``;return t.length>120?`${t.slice(0,117)}…`:t}function Xb(e){return Yb(e.contextMd)||Yb(e.options.join(` / `))||`earlier question`}function Zb(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0).toString(36)}function Qb(e){let t=new Set,n=new Set;for(let r of e)for(let e of r.tools)e.agentId&&(t.add(e.agentId),e.agentStatus&&n.add(e.agentId));return{launched:t,finished:n}}function $b(e,t,n){if(n.length===0)return{agents:e,key:void 0};let{launched:r,finished:i}=Qb(n),a=new Set(t.flatMap(e=>e.id?[e.id]:[])),o=new Set(e.flatMap(e=>e.id?[e.id]:[])),s=e.filter(e=>e.id&&!a.has(e.id)&&!r.has(e.id)),c=t.filter(e=>e.id&&!o.has(e.id)&&r.has(e.id)&&!i.has(e.id));if(s.length===0&&c.length===0)return{agents:e,key:void 0};let l=[...s.map(e=>`+${e.id}`),...c.map(e=>`-${e.id}`)].join(` `);return{agents:[...e.filter(e=>!s.includes(e)),...c],key:l}}function ex(e,t){let n=(0,q.useRef)(void 0),[r,i]=(0,q.useState)(void 0),a=e?.subAgents??[],o=n.current===void 0?{agents:a,key:void 0}:$b(a,n.current,t),s=o.key;(0,q.useEffect)(()=>{if(s===void 0)return;let e=setTimeout(()=>i(s),ti);return()=>clearTimeout(e)},[s]);let c=s!==void 0&&r!==s?o.agents:a;return(0,q.useEffect)(()=>{n.current=c},[c]),!e||c===a?e:{...e,subAgents:[...c]}}function tx(e,t,n){return e===t||n(e,t)?e:t}function nx(e,t){let n=(0,q.useRef)(e);return n.current=t(n.current,e),n.current}function rx(e,t){return nx(e,(e,n)=>tx(e,n,t))}function ix(e,t,n){if(e===t)return e;let r=e.size!==t.size,i=new Map;for(let[a,o]of t){let t=e.get(a),s=e.has(a)&&n(t,o);s||(r=!0),i.set(a,s?t:o)}return r?i:e}function ax(e,t){return ix(e,t,sx)}function ox(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(t.get(n),r))return!1;return!0}function sx(e,t){return!e||!t?e===t:e.length===t.length&&e.every((e,n)=>Object.is(e,t[n]))}function cx(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!Mo(n))return n.kind===`event`&&n.boundary===`rest`?n.sourceId??`rest@${n.at??t}`:void 0}}function lx(e,t,n){if(!e||e.runtime!==`running`&&e.runtime!==`spawning`)return;let r=cx(t);return r!==void 0&&r!==n?r:void 0}function ux(e,t){let n=(0,q.useRef)(null),[r,i]=(0,q.useState)(void 0),a=n.current&&n.current.messages.length>0?lx(e,t,n.current.restKey):void 0;(0,q.useEffect)(()=>{if(a===void 0)return;let e=setTimeout(()=>i(a),400);return()=>clearTimeout(e)},[a]);let o=a!==void 0&&r!==a?n.current.messages:t;return(0,q.useEffect)(()=>{n.current?.messages!==o&&(n.current={messages:o,restKey:cx(o)})},[o]),o}function dx(e,t,n=!0){return e.held>0&&n?`release`:e.steered>0&&t?`interrupt`:null}function fx(e){if(!e)return!1;let t=vs(W.board,e);return g(t?.backend).interrupt&&t?.runtime===`running`}function px(e){return g(e?vs(W.board,e)?.backend:void 0).steer}function mx(e){return(0,q.useSyncExternalStore)(e=>Wt(W,e),()=>px(e),()=>!0)}function hx(e){return(0,q.useSyncExternalStore)(e=>Wt(W,e),()=>fx(e),()=>!1)}var gx=new Set,_x=new Set;function vx(e,t){if(t!==gx.has(e)){t?gx.add(e):gx.delete(e);for(let e of _x)e()}}function yx(e){return(0,q.useSyncExternalStore)((0,q.useCallback)(e=>(_x.add(e),()=>_x.delete(e)),[]),()=>e?gx.has(e):!1,()=>!1)}function bx(e,t){let n=dx(t,fx(e),px(e));if(!n)return!1;if(gx.has(e))return!0;let r=vs(W.board,e)?.sessionId;if(!r)return G(`This thread has no live session to send to`),!0;vx(e,!0);let i=n===`release`;return U.deliverQueuedNow({slug:e,sessionId:r,...i?{releaseOnly:!0}:{}}).then(t=>{vx(e,!1),i?t.released||G(t.reason??`That message could not be sent now`):!t.interrupted&&!t.released&&G(t.reason??`That message could not be pushed through`)},t=>{vx(e,!1);let n=(t instanceof Error?t.message:String(t)).slice(0,160);G(i?`Couldn't send it now — ${n}`:`Couldn't push it through — ${n}`)}),!0}var xx=`input, textarea, select, [contenteditable]:not([contenteditable='false'])`;function Sx(e,t){if(e.defaultPrevented||e.repeat||!ra(e))return!1;let n=e.target;if(!(n instanceof Element)||!t.contains(n))return!1;let r=n.closest(xx);return r?r instanceof HTMLTextAreaElement&&r.closest(`[data-thread-composer-box]`)!==null&&r.value.trim()===``:!0}var Cx=new Set;function wx(e){if(e.defaultPrevented||e.repeat||!ra(e))return;let t=document.activeElement;if(t&&t!==document.body&&t!==document.documentElement)return;let n=[...Cx],r=On();(r?n.find(e=>e.slug===r):new Set(n.map(e=>e.slug)).size===1?n[0]:void 0)?.press()&&e.preventDefault()}function Tx(e,t){let n=(0,q.useRef)(t);return n.current=t,(0,q.useEffect)(()=>{let t={slug:e,press:()=>bx(e,n.current)};return Cx.size===0&&window.addEventListener(`keydown`,wx),Cx.add(t),()=>{Cx.delete(t),Cx.size===0&&window.removeEventListener(`keydown`,wx)}},[e]),(0,q.useCallback)(t=>{Sx(t.nativeEvent,t.currentTarget)&&bx(e,n.current)&&t.preventDefault()},[e])}function Ex(e,t){for(let n=0;n<e.length;n++){let r=e[n].at?Date.parse(e[n].at):NaN;if(Number.isFinite(r)&&r>t)return n}return e.length}function Dx(e,t){let n=t;for(;n>0&&e[n].kind===`event`;)n--;return n}function Ox(e){let t=e.findIndex(e=>e.queued===!0);return t<0?e.length:t}function kx(e,t){let n=new Map,r=new Map;if(t.length===0||e.length===0)return{placed:n,anchored:r};let i=new Map;for(let e of t){let t=e.pending?`pending`:e.settledAt,n=i.get(t);n?n.push(e):i.set(t,[e])}let a=(e,t,n)=>{let r=e.get(t);r?r.push(...n):e.set(t,[...n])};for(let[t,o]of i){let i=t===`pending`?1/0:Date.parse(t),s=Number.isFinite(i)?Ex(e,i):Ox(e);if(s===0)continue;let c=e.slice(0,s),l=V_(c,o);for(let[e,t]of l.placed)a(n,e,t);let u=o.filter(e=>!l.placedIds.has(e.id));for(let[e,t]of E_(c,u))e<0||a(r,Dx(c,e),t)}let o=(e,t)=>Date.parse(e.askedAt)-Date.parse(t.askedAt);for(let e of n.values())e.sort(o);for(let e of r.values())e.sort(o);return{placed:n,anchored:r}}var Ax=e=>e.role===`user`&&!e.queued,jx=e=>e.wake===!0&&e.text.trimStart().startsWith(`**This message is from frizz, not from the human.**`);function Mx(e,t){let n=e.length-1;for(;n>t&&e[n].signOff!==!0;)n--;if(n<=t)return[];let r=[n];for(;;){let i=n-1;for(;i>t&&!Ax(e[i]);)i--;if(i<=t||!jx(e[i]))break;let a=i-1;for(;a>t&&e[a].signOff!==!0&&!Ax(e[a]);)a--;if(a<=t||e[a].signOff!==!0)break;r.push(a),n=a}return r.reverse()}function Nx(e){return e.status===`pending`&&e.backgroundState===`background`}function Px(e){let t=[];for(let n of e)for(let e of n.tools)Nx(e)&&n.at&&t.push({label:e.desc??e.detail??e.command??`Background command`,startedAt:n.at,state:`running`,...e.shellId?{launchId:e.shellId}:{},...e.command?{command:e.command}:{}});return t}function Fx(e){return e.map(e=>{if(!e.tools.some(Nx))return e;let t=e.tools.filter(e=>!Nx(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!Nx(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}var Ix=2e3;function Lx(e,t){if(!e.spec.handle)return!1;let n=Date.parse(e.askedAt);if(!Number.isFinite(n))return!1;let r;for(let i=t.length-1;i>=0;i--){let a=t[i],o=a.at?Date.parse(a.at):NaN;if(Number.isFinite(o)&&o>=n)return!1;if(a.role===`assistant`&&a.text&&Ft(a.text)){r??=I_(e);for(let e of hs(a.text))if(e.read.form!==`invalid`&&r.includes(e.read.id.toLowerCase()))return!1}if(Number.isFinite(o))break}return!0}function Rx(e,t,n,r){let i,a=new Set;for(let o of e){if(!Lx(o,t)){n.delete(o.id);continue}let e=n.get(o.id)??r;n.set(o.id,e);let s=e+Ix;r>=s||(a.add(o.id),i=i===void 0?s:Math.min(i,s))}if(n.size>a.size){let t=new Set(e.map(e=>e.id));for(let e of n.keys())t.has(e)||n.delete(e)}return a.size===0?{shown:e}:{shown:e.filter(e=>!a.has(e.id)),wakeAt:i}}function zx(e,t){let n=-1;if(!Number.isFinite(t))return n;for(let r=0;r<e.length;r++){let i=e[r];if(i.kind===`event`||i.kind===`reasoning`)continue;let a=i.at?Date.parse(i.at):NaN;Number.isFinite(a)&&a<=t&&(n=r)}return n}function Bx(e,t,n=[]){let r=new Map;if(!t?.length||e.length===0)return r;let i=new Map,a=t=>{let n=i.get(t);if(!n){n=new Set;let r=e[t].text;if(e[t].role===`assistant`&&r&&Ft(r))for(let e of hs(r))e.read.form!==`invalid`&&n.add(e.read.id.toLowerCase());i.set(t,n)}return n};for(let i of t){if(!i.id)continue;let t=i.id.toLowerCase(),o=zx(e,Date.parse(i.at));if(o<0||!a(o).has(t)||n.some(n=>I_(n).includes(t)&&zx(e,Date.parse(n.askedAt))===o))continue;let s=r.get(o);s||r.set(o,s=new Map),s.set(t,[...s.get(t)??[],...i.faults])}return r}var Vx=new WeakMap;function Hx(e,t,n=[]){let r=Bx(e,t,n);return r.size===0?e:e.map((e,t)=>{let n=r.get(t);if(!n)return e;let i=[...n].map(([e,t])=>`${e}\u0000${t.join(`\0`)}`).sort().join(`
|
|
125
|
-
`),a=Vx.get(e);if(a?.key===i)return a.message;let o={...e,refusedFences:new Set(n.keys()),refusedReasons:n};return Vx.set(e,{key:i,message:o}),o})}function Ux(e){return e?.length?e.map(e=>`${e.at}|${e.id??``}|${e.faults.join(`\0`)}`).join(`
|
|
126
|
-
`):``}function Wx(e){let t=e?.find(e=>e.trim());if(!t)return;let n=t.indexOf(` — `);return n!==-1&&/^`[^`]*`$/.test(t.slice(0,n).trim())&&(n=t.indexOf(` — `,n+3)),(n===-1?t:t.slice(0,n)).trim().replace(/[.;:]+$/,``)}function Gx(e,t){let n=new Map;if(t.length<2||e.length===0)return n;let r=new Map,i=new Set;for(let e of t)if(!i.has(e.id)){i.add(e.id);for(let t of I_(e)){let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[...r].filter(([,e])=>e.length>1);if(a.length===0)return n;let o=a.map(([t,n])=>({name:t,rows:n.map(t=>({id:t.id,askedMs:Date.parse(t.askedAt),at:zx(e,Date.parse(t.askedAt))})).sort((e,t)=>e.askedMs-t.askedMs)}));return e.forEach((e,t)=>{if(e.role!==`assistant`||!e.text||!(Ft(e.text)||e.text.includes("```awaiting")))return;let r=e.text.toLowerCase();for(let{name:e,rows:i}of o){if(!r.includes(e))continue;let a;for(let e of i)e.at<=t&&(a=e.id);if(a===void 0)continue;let o=n.get(t);o||n.set(t,o=new Map),o.set(e,a)}}),n}var Kx=new WeakMap;function qx(e,t){let n=Gx(e,t);return n.size===0?e:e.map((e,t)=>{let r=n.get(t);if(!r)return e;let i=[...r].map(([e,t])=>`${e}\u0000${t}`).sort().join(`
|
|
127
|
-
`),a=Kx.get(e);if(a?.key===i)return a.message;let o={...e,questionOwners:r};return Kx.set(e,{key:i,message:o}),o})}function Jx(e,t){let n=t.description?.trim(),r=n&&!n.includes(`
|
|
128
|
-
`)?n:void 0,i=[r?void 0:n,t.preview?.trim()].filter(Boolean).join(`
|
|
129
|
-
|
|
130
|
-
`)||void 0;return{line:`${Mg(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var Yx=`root`;function Xx(e,t,n){return`${e}/${t}.${n}`}function Zx(e){let t=e.options??[],n=t.map((e,t)=>Jx(t,e));return{question:{kind:e.kind,danger:e.danger===!0,...e.secret?{secret:!0}:{},contextMd:e.question,...e.context?.trim()?{detailMd:e.context.trim()}:{},options:n.map(e=>e.line),recommendedIdxs:t.flatMap((e,t)=>e.recommended?[t]:[]),...n.some(e=>e.body)?{optionBodies:n.map(e=>e.body)}:{}},optionLabels:t.map(e=>e.label)}}function Qx(e){return e.secret||e.danger||!e.options?.length?!0:e.options.some(e=>e.followUps?.some(Qx))}function $x(e,t){return!t||e.kind===`multi`?null:t.chosen}function eS(e,t){let n=[],r=(e,i,a)=>{let{question:o,optionLabels:s}=Zx(e);n.push({path:i,spec:e,question:o,optionLabels:s,depth:a});let c=$x(e,t.get(i));c!==null&&(e.options?.[c]?.followUps??[]).forEach((e,t)=>r(e,Xx(i,c,t),a+1))};return r(e,Yx,1),n}function tS(e,t){return t?t.text.trim()?!0:e.kind===`multi`?(t.chosenSet??[]).length>0:t.chosen!==null:!1}function nS(e,t){if(!tS(e.spec,t.get(`root`)))return;let n=(r,i)=>{let a=t.get(i),o=(r.options??[]).map(e=>e.label),s=$x(r,a),c=r.kind===`multi`?(a?.chosenSet??[]).slice().sort((e,t)=>e-t).flatMap(e=>o[e]===void 0?[]:[o[e]]):s===null?[]:[o[s]].filter(e=>e!==void 0),l=r.kind===`multi`||s===null?a?.text.trim():void 0,u=s===null?[]:(r.options?.[s]?.followUps??[]).map((e,t)=>n(e,Xx(i,s,t)));return{questionId:e.id,question:r.question,chosen:c,...l?{text:l}:{},...u.length>0?{followUps:u}:{}}};return n(e.spec,Yx)}function rS(e,t){let n=[],r=(e,t,i,a)=>{let o=e.options??[],{question:s}=Zx(e),c=[],l=[];for(let e of t.chosen){let t=o.findIndex(t=>t.label===e);t===-1?l.push(e):c.includes(t)||c.push(t)}c.sort((e,t)=>e-t);let u=[l.join(`, `),t.text?.trim()].filter(Boolean).join(` — `)||void 0;if(n.push({path:i,question:{...s,options:c.map(e=>s.options[e]),recommendedIdxs:c.flatMap((e,t)=>s.recommendedIdxs.includes(e)?[t]:[]),...s.optionBodies?{optionBodies:c.map(e=>s.optionBodies[e])}:{}},settled:{chosenIdxs:c.map((e,t)=>t),...u?{text:u}:{}},depth:a}),e.kind===`multi`||c.length!==1)return;let d=c[0];(o[d]?.followUps??[]).forEach((e,n)=>{let o=t.followUps?.[n];o&&r(e,o,Xx(i,d,n),a+1)})};return r(e,t,Yx,1),n}function iS(e,t){let n=e.options??[];if(t.chosen===null&&t.chosenSet.length===0)return``;let r=e=>n[e]?{index:e,label:n[e].label}:null;return JSON.stringify({chosen:t.chosen===null?null:r(t.chosen),chosenSet:t.chosenSet.flatMap(e=>{let t=r(e);return t?[t]:[]})})}function aS(e,t){let n={chosen:null,chosenSet:[]};if(!t)return n;try{let r=JSON.parse(t);if(!r||typeof r!=`object`)return n;let{chosen:i,chosenSet:a}=r;if(!Array.isArray(a))return n;let o=e.options??[],s=e=>{if(!e||typeof e!=`object`)return null;let{index:t,label:n}=e;return typeof t==`number`&&Number.isInteger(t)&&t>=0&&typeof n==`string`&&o[t]?.label===n?t:null},c=new Set(a.map(s).filter(e=>e!==null));return e.kind===`multi`?{chosen:null,chosenSet:o.flatMap((e,t)=>c.has(t)?[t]:[])}:{chosen:s(i),chosenSet:[]}}catch{return n}}function oS(e,t){let[n,...r]=t.split(`/`);if(n!==`root`)return;let i=e;for(let e of r){if(!/^\d+\.\d+$/.test(e))return;let[t,n]=e.split(`.`).map(Number);i=i?.options?.[t]?.followUps?.[n]}return i}function sS({className:e}){return(0,X.jsxs)(`div`,{className:`flex items-baseline gap-[0.3em] ${e}`,children:[(0,X.jsx)(gc,{"aria-hidden":!0,strokeWidth:2.25,className:`size-[0.9em] shrink-0 self-baseline translate-y-[calc(0.45em_-_0.5cap)]`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 text-pretty`,children:`Value stored only in memory. It will not show up in transcripts.`})]})}function cS({raw:e,question:t,questionKind:n,danger:r,interactive:i,wrap:a,aside:o,label:s,settled:c,pending:l}){let u=(0,q.useMemo)(()=>t??kg(e??``,n??`question`,r),[t,e,n,r]),d=tp(u.contextMd),f=tp(u.detailMd??``),p=tp(u.trailingMd??``),m=u.recommendedIdxs,h=rp(u.recommendation??``),g=u.kind===`multi`,_=u.danger,v=i?.answer.chosen??null,y=i?.answer.chosenSet??[],b=i?.answer.text??``,x=(0,q.useRef)(null),S=(0,q.useRef)(null),C=(0,q.useId)();(0,q.useLayoutEffect)(()=>{let e=x.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`)},[b]);let w=_?Pt:u.secret?dc:g?mc:_o,T=s??(u.secret?`Secret`:g?`Select multiple`:`Question`);return(0,X.jsxs)(wm,{tone:_?`risk`:`neutral`,surface:`question`,icon:w,kind:T,label:null,aside:o,children:[d&&(0,X.jsx)(`div`,{id:C,className:`text-fg`,children:(0,X.jsx)($h,{className:`md-body${a?` [overflow-wrap:anywhere]`:``}`,html:d})}),u.detailMd&&(0,X.jsx)(`div`,{"data-question-context":!0,className:d?`mt-[13px]`:void 0,children:(0,X.jsx)($h,{className:`md-body${a?` [overflow-wrap:anywhere]`:``}`,html:f})}),(u.options.length>0||i||l)&&(0,X.jsxs)(`div`,{ref:S,tabIndex:-1,onKeyDown:e=>{!i||e.target!==e.currentTarget||Hr({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),e.stopPropagation(),i.onSubmit())},"data-question-grid":!0,role:`group`,"aria-labelledby":d?C:void 0,"aria-label":d?void 0:T,className:`mt-2 grid grid-cols-1 gap-1.5 outline-none`,children:[u.options.map((e,t)=>(0,X.jsxs)(q.Fragment,{children:[u.optionHeadings?.[t]&&(0,X.jsx)(lS,{md:u.optionHeadings[t],wrap:a}),(0,X.jsx)(uS,{label:e,index:t,bodyMd:u.optionBodies?.[t],wrap:a,multi:g,recommended:m.includes(t),recTitle:m[0]===t?u.recommendedNote:void 0,selected:g?y.includes(t):v===t,settledPick:c?.chosenIdxs.includes(t)??!1,disabled:!i,onClick:()=>{i?.onChip(t,e),!(g&&x.current&&document.activeElement===x.current)&&S.current?.focus()}})]},t)),i&&!i.optionsOnly&&(0,X.jsxs)(`div`,{className:`relative col-span-full${u.options.length>0?` flex items-baseline`:``}`,children:[u.options.length>0&&(0,X.jsx)(`span`,{className:`pointer-events-none relative ml-[13px] -mr-[29px] flex`,children:(0,X.jsx)(fS,{id:Mg(u.options.length).slice(0,-1),live:!0})}),u.secret?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{type:`password`,"data-secret-answer":!0,"data-surface":`questionAnswer`,"data-claims-escape":!0,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,"aria-label":`Secret value`,value:b,onChange:e=>i.onText(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){e.preventDefault(),S.current?.focus();return}e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),i.onSubmit())},placeholder:`Paste the value…`,className:`block w-full rounded-md border py-1.5 pl-3 pr-3 text-[12px] leading-snug text-fg/90 outline-none placeholder:text-muted-80 transition-colors ${b.trim()?`border-selection-border bg-selection`:`border-border bg-transparent hover:bg-panel-2 focus:border-accent`}`}),(0,X.jsx)(sS,{className:`mt-2 text-[11px] leading-snug text-muted`})]}):(0,X.jsx)(`textarea`,{ref:x,"data-1p-ignore":!0,rows:1,"data-surface":`questionAnswer`,"data-claims-escape":!0,value:b,onChange:e=>i.onText(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){e.preventDefault(),S.current?.focus();return}Hr({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),i.onSubmit())},onFocus:()=>{!g&&v!==null&&i.onText(b)},placeholder:g?`Add a note…`:u.options.length?`Something else…`:`Type your answer…`,className:`block w-full min-w-0 flex-1 resize-none overflow-hidden rounded-md border py-1.5 pr-3 ${u.options.length>0?dS:`pl-3`} text-[12px] leading-snug text-fg/90 outline-none placeholder:text-muted-80 transition-colors ${b.trim()&&(g||v===null)?`border-selection-border bg-selection`:`border-border bg-transparent hover:bg-panel-2 focus:border-accent`}`})]}),!i&&l&&(0,X.jsx)(`div`,{"data-question-pending-text":!0,className:`relative col-span-full`,children:u.secret?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{type:`password`,disabled:!0,tabIndex:-1,"aria-hidden":!0,placeholder:`Paste the value…`,className:`block w-full rounded-md border border-border bg-transparent py-1.5 pl-3 pr-3 text-[12px] leading-snug text-fg/90 outline-none placeholder:text-muted-80`}),(0,X.jsx)(sS,{className:`mt-2 text-[11px] leading-snug text-muted`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{ref:x,"data-1p-ignore":!0,rows:1,disabled:!0,tabIndex:-1,"aria-hidden":!0,placeholder:u.options.length>0?void 0:`Type your answer…`,className:`block w-full min-w-0 resize-none overflow-hidden rounded-md border border-border bg-transparent px-3 py-1.5 text-[12px] leading-snug outline-none placeholder:text-muted-80`}),u.options.length>0&&(0,X.jsxs)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 flex items-baseline border border-transparent py-1.5 pr-3 text-[12px] leading-snug text-muted-80`,children:[(0,X.jsx)(`span`,{className:`ml-3 mr-2 flex`,children:(0,X.jsx)(fS,{id:Mg(u.options.length).slice(0,-1)})}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:g?`Add a note…`:`Something else…`})]})]})})]}),c?.text&&(0,X.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap [overflow-wrap:anywhere] rounded-md border border-border-strong border-l-2 border-l-accent/40 bg-bg/50 py-1.5 pl-[11px] pr-3 text-[12px] leading-snug text-fg`,children:u.secret?`••••••••••••`:c.text}),c&&c.chosenIdxs.length===0&&!c.text&&(0,X.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-70`,children:`Not answered`}),u.trailingMd&&(0,X.jsx)(`div`,{"data-question-note":!0,className:`mt-2 text-muted-70`,children:(0,X.jsx)($h,{className:`md-body${a?` [overflow-wrap:anywhere]`:``}`,html:p})}),u.recommendation&&m.length===0&&(0,X.jsx)($h,{className:`md-inline mt-1.5 text-[11px] text-muted-70`,html:h})]})}function lS({md:e,wrap:t}){let n=rp(e.split(`
|
|
131
|
-
`).join(` `));return(0,X.jsx)(`div`,{className:`mt-1 text-fg`,children:(0,X.jsx)($h,{className:`md-body${t?` ${lm}`:``}`,html:n})})}function uS({label:e,index:t,bodyMd:n,wrap:r,selected:i,settledPick:a,disabled:o,multi:s,recommended:c,recTitle:l,onClick:u}){let d=Ng(e),f=d.id??Mg(t).slice(0,-1),p=rp(d.rest),m=tp(n??``),h=(0,q.useId)();return(0,X.jsxs)(`div`,{"data-question-option":!0,title:l,onClick:e=>{o||e.target.closest(`a, button, summary, img[data-local-path], .local-file-action, .local-file-code`)||window.getSelection()?.toString()||u()},className:`relative flex items-baseline gap-2 rounded-md border px-3 py-1.5 text-[12px] leading-snug transition-colors ${i?`border-selection-border bg-selection text-fg`:a?`border-border-strong border-l-2 border-l-accent/40 bg-bg/50 pl-[11px] text-fg`:o?`border-border text-muted-80`:`border-border text-fg/90 hover:bg-elevated`}`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:o,"aria-labelledby":h,"aria-pressed":i||a,onClick:u,onMouseDown:e=>e.preventDefault(),className:`absolute inset-0 rounded-md outline-none`}),(0,X.jsx)(fS,{id:f,live:!o,selected:i}),s&&(0,X.jsx)(`span`,{"aria-hidden":!0,className:`mt-px flex h-3.5 w-3.5 shrink-0 self-start items-center justify-center rounded-[3px] border ${i?`border-accent bg-accent-fill text-on-accent`:a?`border-control-strong text-fg`:`border-control-strong`}`,children:(i||a)&&(0,X.jsx)(Qt,{size:10,strokeWidth:3})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{id:h,children:[c&&(0,X.jsx)(`span`,{className:`pointer-events-none float-right ml-2 mt-px rounded-full border border-border-strong px-1.5 py-px text-[9.5px] leading-none uppercase tracking-wide text-muted`,children:`Recommended`}),(0,X.jsx)($h,{as:`span`,className:`md-inline`,html:p})]}),n!==void 0&&(0,X.jsx)($h,{className:`md-body mt-1.5 opacity-90 ${r?`[overflow-wrap:anywhere]`:``}`,html:m})]})]})}var dS=`pl-9`;function fS({id:e,live:t=!1,selected:n=!1}){return(0,X.jsxs)(`span`,{"aria-hidden":!0,className:`flex w-4 shrink-0 justify-end whitespace-nowrap text-[11px] transition-colors ${n&&t?`text-fg`:`text-muted`}`,children:[e,`.`]})}var pS=(0,q.createContext)(null);function mS(){return(0,q.useContext)(pS)}function hS({questions:e}){let t=mS();return e.length===0?null:(0,X.jsx)(`div`,{"data-compact-questions":!0,className:`min-w-0 overflow-hidden rounded-[12px] border border-border-strong bg-panel pb-2.5 text-[14px] leading-5`,children:e.map((e,n)=>(0,X.jsx)(`div`,{"data-question-id":e.id,className:n>0?`mt-2.5 border-t border-border`:void 0,children:(0,X.jsx)(gS,{q:e,n:t?.numberOf(e.id)??n+1})},e.id))})}function gS({q:e,n:t}){let n=tp(e.spec.question),r=e.spec.options??[],i=ue();return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex gap-2 px-3.5 pb-1 pt-[11px] font-semibold`,children:[(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums text-accent`,children:t}),(0,X.jsx)($h,{className:`min-w-0 flex-1 ${_S}`,html:n})]}),r.map((e,t)=>(0,X.jsxs)(`div`,{"data-compact-option":!0,className:`flex gap-2 py-0.5 pl-[30px] pr-3.5 text-muted`,children:[(0,X.jsx)(`span`,{className:`w-3 shrink-0 font-bold`,children:Mg(t).slice(0,-1)}),(0,X.jsxs)(`span`,{className:`min-w-0`,children:[(0,X.jsx)(yS,{md:e.label}),e.recommended&&(0,X.jsx)(`span`,{className:`ml-1 text-[11px] font-semibold leading-none text-accent`,children:`RECOMMENDED`})]})]},t)),i&&Qx(e.spec)&&(0,X.jsxs)(ys,{className:`px-3.5 pt-1 text-[13px] text-muted`,children:[`This question has to be answered on `,i,`.`]})]})}var _S=`md-inline break-words [&_p+*]:mt-2 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li+li]:mt-1 [&_pre]:[white-space:var(--code-wrap,pre-wrap)] [&_pre]:overflow-x-auto [&_pre]:text-[0.85em] [&_code]:text-[0.9em] [&_a]:underline`;function vS({count:e,onAnswer:t,onReply:n}){return(0,X.jsxs)(X.Fragment,{children:[n&&(0,X.jsx)(`button`,{type:`button`,"data-phone-answer-reply":!0,onClick:n,"aria-label":`Write a reply instead`,title:`Write a reply instead`,className:`flex size-[42px] shrink-0 items-center justify-center rounded-full border border-border-strong bg-panel text-fg active:bg-hover`,children:(0,X.jsx)(fc,{"aria-hidden":!0,size:19,strokeWidth:1.8})}),(0,X.jsx)(`button`,{type:`button`,"data-phone-answer-open":!0,onClick:t,className:`flex h-[42px] min-w-0 flex-1 items-center justify-center rounded-full bg-fg px-4 text-[15px] font-semibold text-bg active:opacity-90`,children:e>1?`Answer ${e} questions`:`Answer`})]})}function yS({md:e}){return(0,X.jsx)($h,{as:`span`,className:`md-inline`,html:rp(e)})}function bS(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var xS=(0,q.createContext)(null);function SS(e){let t=e?.id,n=e?.questions??[],r=yn(),i=ue(),[a,o]=(0,q.useState)(()=>new Map),[s,c]=(0,q.useState)(),l=(0,q.useContext)(Rb),u=(0,q.useContext)(_v),d=Es((0,q.useMemo)(()=>t?n.flatMap(e=>e.spec.secret?[]:ZS(e).flatMap(n=>[jr.question(r,t,e.id,n),jr.questionPick(r,t,e.id,n)])):[],[r,t,n])),f=(e,n)=>{if(e.spec.secret)return{chosen:null,chosenSet:[],text:a.get(e.id)??``};let i=oS(e.spec,n),o=i?aS(i,t?d.get(jr.questionPick(r,t,e.id,n))??``:``):void 0;return{chosen:o?.chosen??null,chosenSet:o?.chosenSet??[],text:(t?d.get(jr.question(r,t,e.id,n)):void 0)??``}},p=e=>new Map(ZS(e).map(t=>[t,f(e,t)])),m=n.flatMap(e=>{let t=nS(e,p(e));return t?[{q:e,answer:t}]:[]}),h=m.map(e=>e.answer),g=ct(),_=H({mutationFn:async e=>U.answerQuestions({slug:t,answers:e.answers}),onSuccess:(e,t)=>{for(let n of e.answered){o(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t});for(let e of t.drafts.find(e=>e.id===n)?.keys??[])ls.clear(e)}},onError:e=>{l?.cancel(),t&&Da(t),c(bS(e))},onSettled:()=>{t&&g.invalidateQueries({queryKey:wS(t)})}}),v=H({mutationFn:async e=>U.dismissQuestions({slug:t,ids:[e]}),onError:e=>c(bS(e))}),y=e=>e.map(({q:e,answer:t})=>e.spec.secret?{...t,text:`(secret sent)`}:t),b=(e,t)=>{let n=wS(e);g.cancelQueries({queryKey:n});let r=new Date().toISOString(),i=new Set(t.map(e=>e.q.id));ui(e,[...i]);let a=y(t);g.setQueryData(n,e=>({closed:e?.closed??[],questions:[...(e?.questions??[]).filter(e=>!i.has(e.id)),...t.map(({q:e},t)=>({id:e.id,spec:e.spec,askedAt:e.askedAt,settledAt:r,pending:!0,answer:a[t]}))]}))},x=(e,t)=>t.map(({q:t})=>({id:t.id,keys:t.spec.secret?[]:ZS(t).flatMap(n=>[jr.question(r,e,t.id,n),jr.questionPick(r,e,t.id,n)])})),S=()=>{!t||h.length===0||_.isPending||(c(void 0),(l?.sent??l?.dismiss)?.(),Di(t),b(t,m),_.mutate({answers:h,drafts:x(t,m)}))},C=()=>{if(!t||h.length===0)return null;let e=m,n=x(t,e),r=()=>void g.invalidateQueries({queryKey:wS(t)}),i=()=>{o(t=>{if(!e.some(({q:e})=>t.has(e.id)))return t;let n=new Map(t);for(let{q:t}of e)n.delete(t.id);return n});for(let e of n)for(let t of e.keys)ls.clear(t)};return{answers:h,display:y(e).map((t,n)=>tr(t,e[n].q.spec,e[n].q.handle)),onOptimistic:()=>{c(void 0),b(t,e)},onSuccess:()=>{i(),r()},onRollback:e=>{e&&i(),r()}}},w=()=>{u?.composer.run()||S()};return{slug:t,answerFor:f,answersOf:p,onChip:(e,n,i,a)=>{let o=oS(e.spec,n);if(!t||!o||e.spec.secret||!o.options?.[a])return;let s=jr.questionPick(r,t,e.id,n),c=aS(o,ls.get(s)),l=i?{...c,chosenSet:c.chosenSet.includes(a)?c.chosenSet.filter(e=>e!==a):[...c.chosenSet,a]}:{...c,chosen:c.chosen===a?null:a};ls.set(s,iS(o,l))},onText:(e,n,a,s)=>{if(!(!t||i)){if(e.spec.secret){o(t=>t.get(e.id)===s?t:new Map(t).set(e.id,s));return}ls.set(jr.question(r,t,e.id,n),s),a||ls.clear(jr.questionPick(r,t,e.id,n))}},dismiss:e=>v.mutate(e),dismissing:v.isPending,submit:()=>w(),take:C,staged:h.length,sending:_.isPending,error:s,readAndAnswerHost:i}}var CS=[],wS=e=>[`settledQuestions`,e],TS=[],ES=e=>e.questions,DS=e=>e.closed;function OS(e,t){return Re({queryKey:wS(e??``),queryFn:async()=>{let t=await U.threadSettledQuestions({slug:e});return{questions:t.questions,closed:t.closed??[]}},enabled:!!e,refetchOnWindowFocus:!1,select:t})}function kS(e){let t=e?.id,n=ct(),r=OS(t,ES),i=(e?.questions??[]).map(e=>e.id).join(` `),a=(0,q.useRef)(i);return(0,q.useEffect)(()=>{let e=a.current;if(a.current=i,!t||e===i)return;let r=new Set(i.split(` `));e.split(` `).some(e=>e&&!r.has(e))&&n.invalidateQueries({queryKey:wS(t)})},[i,n,t]),r.data??CS}function AS(e){return OS(e?.id,DS).data??TS}var jS=[];function MS(e,t){let n=e?.questions??jS;if(t.length===0||n.length===0)return n;let r=new Set(t.map(e=>e.id));return n.some(e=>r.has(e.id))?n.filter(e=>!r.has(e.id)):n}function NS({s:e,wrap:t,copy:n}){let r=(0,q.useMemo)(()=>rS(e.spec,e.answer),[e.spec,e.answer]),i=e=>(0,X.jsx)(cS,{question:e.question,label:e.depth>1?`Follow-up`:void 0,settled:e.settled,wrap:t},e.path),a=r.slice(1);return(0,X.jsxs)(`article`,{...n?{"data-question-copy":e.id}:{"data-question-id":e.id},"data-settled-question":!0,"aria-label":`Answered question`,className:`flex min-w-0 flex-col gap-2 opacity-60`,children:[i(r[0]),a.length>0&&(0,X.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:a.map(e=>(0,X.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:i(e)},e.path))})]})}function PS({questions:e,wrap:t,className:n=``}){return e.length===0?null:(0,X.jsx)(`section`,{"data-settled-questions":!0,"aria-label":`${e.length} answered question${e.length===1?``:`s`}`,className:`flex min-w-0 flex-col gap-3 ${n}`,children:e.map(e=>(0,X.jsx)(NS,{s:e,wrap:t},e.id))})}function FS(e){return`settledAt`in e?e:void 0}function IS(e,t,n,r,i=TS){let a=r?.closedQuestions,o=(0,q.useMemo)(()=>{let e=new Map(i.map(e=>[e.id,e.spec]));return(a??[]).map(t=>({id:t.id,handle:t.handle,closed:t.state,asked:e.get(t.id)}))},[a?.length?a.map(e=>`${e.id}:${e.state}`).join(` `):``,i]);return(0,q.useMemo)(()=>e?void 0:[...t,...n,...o],[e,t,n,o])}function LS(e,t){let n=(0,q.useRef)(new Map),[,r]=(0,q.useState)(0),{shown:i,wakeAt:a}=Rx(e,t,n.current,Date.now());return(0,q.useEffect)(()=>{if(a===void 0)return;let e=setTimeout(()=>r(e=>e+1),Math.max(0,a-Date.now()));return()=>clearTimeout(e)},[a]),(0,q.useMemo)(()=>i,[e,i===e?``:e.filter(e=>!i.includes(e)).map(e=>e.id).join(` `)])}function RS(e,t,n,r){let i=t?.questionFaults,a=(0,q.useMemo)(()=>i,[Ux(i)]),o=t?.closedQuestions,s=(0,q.useMemo)(()=>a?.length?[...n,...r,...o??[]]:[],[a,n,r,o]);return(0,q.useMemo)(()=>a?.length?Hx(e,a,s):e,[e,a,s])}function zS(e,t,n,r){let i=t?.closedQuestions,a=(0,q.useMemo)(()=>[...n,...r,...i??[]],[n,r,i?.length?i.map(e=>e.id).join(` `):``]);return(0,q.useMemo)(()=>qx(e,a),[e,a])}function BS({spec:e,wrap:t}){let n=(0,q.useMemo)(()=>Zx(e).question,[e]);return(0,X.jsx)(`article`,{"data-question-fence":e.handle,"data-question-unregistered":!0,className:`flex min-w-0 flex-col gap-2`,children:(0,X.jsx)(cS,{question:n,wrap:t,pending:!0})})}function VS({spec:e,state:t,wrap:n,copyOf:r}){let i=(0,q.useMemo)(()=>Zx(e).question,[e]);return(0,X.jsx)(`article`,{...r?{"data-question-copy":r}:{"data-question-fence":e.handle},"data-question-closed":t,"aria-label":t===`dismissed`?`Dismissed question`:`Withdrawn question`,className:`flex min-w-0 flex-col gap-2 opacity-60`,children:(0,X.jsx)(cS,{question:i,label:t===`dismissed`?`Question dismissed`:`Question withdrawn`,settled:HS,wrap:n})})}var HS={chosenIdxs:[]};function US({q:e,above:t,wrap:n}){let r=(0,q.useMemo)(()=>Zx(e.spec).question,[e.spec]);return(0,X.jsx)(`article`,{"data-question-copy":e.id,"data-question-open":t?`above`:`below`,"aria-label":t?`Open question, answered further up`:`Open question, answered further down`,className:`flex min-w-0 flex-col gap-2 opacity-60`,children:(0,X.jsx)(cS,{question:r,label:t?`Still open, answer it above`:`Still open, answer it below`,wrap:n})})}function WS({spec:e,reasons:t,unread:n,wrap:r}){let i=(0,q.useMemo)(()=>Zx(e).question,[e]);return(0,X.jsx)(KS,{reasons:t,...n?{"data-question-invalid":e.handle}:{"data-question-refused-ask":e.handle},children:(0,X.jsx)(`div`,{className:`opacity-60`,children:(0,X.jsx)(cS,{question:i,wrap:r})})})}function GS({faults:e,children:t}){return(0,X.jsx)(KS,{reasons:e,"data-question-invalid":``,children:t})}function KS({reasons:e,children:t,...n}){let r=Wx(e),i=rp(r?`Question not asked: ${r}.`:`Question not asked.`);return(0,X.jsxs)(`div`,{...n,className:`flex min-w-0 flex-col gap-1.5`,children:[(0,X.jsx)(`p`,{"data-question-not-asked":!0,className:`text-[13px] leading-snug text-muted`,children:(0,X.jsx)($h,{as:`span`,className:`md-inline`,html:i})}),t]})}function qS({id:e,closed:t}){return(0,X.jsxs)(`p`,{"data-question-refused":e,className:`md-inline text-[13px] leading-snug text-muted`,children:[`Refers to `,(0,X.jsx)(`code`,{children:e}),`, `,t===`withdrawn`?`a question the worker withdrew`:t===`dismissed`?`a question that was dismissed`:`a question this thread never asked`,`.`]})}function JS({thread:e,children:t}){let n=SS(e);return(0,X.jsx)(xS.Provider,{value:n,children:t})}function YS({q:e,answering:t}){let n=(0,q.useContext)(xS),r=mS(),i=t??n;if(!i||!i.slug)return null;if(r)return(0,X.jsx)(hS,{questions:[e]});if(i.readAndAnswerHost&&Qx(e.spec))return(0,X.jsxs)(`article`,{"data-question-id":e.id,className:`flex min-w-0 flex-col gap-2`,children:[(0,X.jsx)(cS,{question:Zx(e.spec).question}),(0,X.jsxs)(ys,{className:`text-[12px] text-muted`,children:[`This question has to be answered on `,i.readAndAnswerHost,`.`]})]});let a=eS(e.spec,i.answersOf(e)),o=t=>(0,X.jsx)(cS,{question:t.question,label:t.depth>1?`Follow-up`:void 0,aside:t.depth===1&&!e.spec.danger&&!i.readAndAnswerHost?(0,X.jsx)(`button`,{type:`button`,"data-dismiss-question":!0,"aria-label":`Dismiss this question`,title:`Dismiss — the worker decides it itself`,disabled:i.dismissing,onClick:()=>i.dismiss(e.id),className:`icon-focus-outline card-icon-offset -mx-2 -my-1 flex rounded-md p-1 text-muted-70 outline-none transition-colors hover:bg-hover-strong hover:text-fg disabled:opacity-40`,children:(0,X.jsx)(L,{size:16})}):void 0,interactive:{answer:i.answerFor(e,t.path),onChip:n=>i.onChip(e,t.path,t.spec.kind===`multi`,n),onText:n=>i.onText(e,t.path,t.spec.kind===`multi`,n),onSubmit:i.submit,...i.readAndAnswerHost?{optionsOnly:!0}:{}}},t.path),s=a.slice(1);return(0,X.jsxs)(`article`,{"data-question-id":e.id,className:`flex min-w-0 flex-col gap-2`,children:[o(a[0]),s.length>0&&(0,X.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:s.map(e=>(0,X.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:o(e)},e.path))})]})}function XS({thread:e,questions:t,inFlight:n=null,showSend:r=!1,className:i=``}){let a=e?.id,o=t??e?.questions??[],s=(0,q.useContext)(xS),c=SS(s?void 0:e),l=s??c,u=mS(),d=wv(),f=r&&!d;return!a||o.length===0&&(!f||u)?!a||!n?.length?null:(0,X.jsx)(`section`,{"data-answers-in-flight":!0,"aria-label":`Your answer, on its way to the worker`,className:`flex min-w-0 flex-col items-end ${i}`,children:(0,X.jsx)(Pb,{answers:n,queued:!0})}):u?(0,X.jsxs)(`section`,{"data-registered-questions":!0,"aria-label":`${o.length} question${o.length===1?``:`s`} waiting for an answer`,className:`flex min-w-0 flex-col gap-3 ${i}`,children:[(0,X.jsx)(hS,{questions:o}),l.error&&(0,X.jsx)(`div`,{role:`alert`,className:`break-words text-[13px] leading-snug text-danger-soft`,children:l.error}),l.sending&&(0,X.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[13px] leading-snug text-muted`,children:`Sending…`})]}):(0,X.jsxs)(`section`,{"data-registered-questions":!0,"aria-label":o.length>0?`${o.length} question${o.length===1?``:`s`} waiting for an answer`:`Send the answers above`,className:`flex min-w-0 flex-col gap-3 ${i}`,children:[o.map(e=>(0,X.jsx)(YS,{q:e,answering:l},e.id)),l.error&&(0,X.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-danger-soft`,children:l.error}),l.sending&&(0,X.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[11px] leading-snug text-muted`,children:`Sending…`}),!d&&(0,X.jsx)(`div`,{className:`flex justify-start`,children:(0,X.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:l.staged===0||l.sending,onClick:l.submit,onMouseDown:e=>e.preventDefault(),className:`button-outline rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:`Send answers`})})]})}function ZS(e){let t=[],n=(e,r)=>{t.push(r),e.options?.forEach((e,t)=>{e.followUps?.forEach((e,i)=>n(e,`${r}/${t}.${i}`))})};return n(e.spec,Yx),t}function QS(e,t){let n=kS(e);Wg(e);let r=(0,q.useMemo)(()=>MS(e,n),[e,n]),i=ux(e,t),a=(0,q.useMemo)(()=>Px(i),[i]),o=(0,q.useMemo)(()=>Fx(i),[i]),s=LS(r,i);return{messages:$S(zS(RS(o,e,s,n),e,s,n),e),openQuestions:s,settledQuestions:n,transcriptShells:a}}function $S(e,t){let n=t?.runtime===`running`||t?.runtime===`spawning`;return(0,q.useMemo)(()=>{if(n)return e;let t=Mx(e,v_(e));if(t.length===0)return e;let r=[...e];for(let e of t)r[e]={...r[e],latestSignOff:!0};return r},[e,n])}var eC=(0,q.createContext)(null),tC=(0,q.createContext)(null);function nC(){let e=(0,q.useContext)(eC);if(!e)throw Error(`A thread's prompt box must be rendered inside a <ThreadSurface>`);return e}function rC(){let e=(0,q.useContext)(tC);if(!e)throw Error(`A thread's transcript must be rendered inside a <ThreadSurface>`);return e}function iC(e){let t=(0,q.useContext)(tC)?.opsThread;return t&&t.id===e.id?t:e}var aC=(e,t)=>e===t||e!==`all`&&t!==`all`&&e.size===t.size&&[...e].every(e=>t.has(e)),oC=(e,t)=>ix(e,t,aC);function sC(e,t={}){let{slug:n,thread:r,messages:i}=e,a=nx(e.openQuestions,Hs),o=nx(e.settledQuestions,Hs),{exit:s,onFilesDropped:c}=t,l=yv(),u=xv(l),d=Jb(n,i,s?()=>{if(s.sent){s.sent();return}document.activeElement?.blur(),s.dismiss()}:void 0,{onSendFailed:s?.cancel,composer:l}),{stagedCount:f,takeAnswers:p,answeringForMessage:m}=d,h=bv(l,{stagedCount:f,takeAnswers:p}),g=r?.runtime===`running`||r?.runtime===`spawning`,_=(0,q.useMemo)(()=>Bb(i),[i]),v=g?i.length:_,y=(0,q.useMemo)(()=>r?.heldHandoff?zg(i,v):-1,[r?.heldHandoff,i,v]),b=zy(r),x=Qo(r?.spawnedAt),S=rx(IS(x,a,o,r,AS(r)),sx),C=nx((0,q.useMemo)(()=>k_(i,a),[i,a]),ax),w=(0,q.useMemo)(()=>V_(i,a),[i,a]),T=nx(w.placed,ax),E=(0,q.useMemo)(()=>({...w,placed:T}),[w,T]),D=rx((0,q.useMemo)(()=>H_(i,a,E),[i,a,E]),ox),O=(0,q.useMemo)(()=>kx(i,o),[i,o]),k=nx(O.placed,ax),A=(0,q.useMemo)(()=>({...O,placed:k}),[O,k]),j=nx((0,q.useMemo)(()=>h_(i),[i]),Hs),M=nx((0,q.useMemo)(()=>av(i),[i]),oC),N=(0,q.useMemo)(()=>u_(i,r?.answersInFlight),[i,r?.answersInFlight]),P=ex(r,i),F=(0,q.useMemo)(()=>aa(i),[i]),I=(0,q.useMemo)(()=>({held:F.held,steered:F.steered}),[F.held,F.steered]),L=(0,q.useMemo)(()=>({thread:r,messages:i,running:g,lastAgentIdx:_,awaitingCut:v,heldIdx:y,restingShown:b,hidesAwaiting:e=>[v>=0&&e<v&&e!==y,e===_&&b],stepsDone:M,openQuestions:a,fencesLive:x,fenceQuestions:S,shadowedByMessage:C,placement:E,questionHomes:D,settledPlacement:A,paired:j,inFlightAnswers:N,answeringForMessage:m,opsThread:P}),[r,i,g,_,v,y,b,M,a,x,S,C,E,D,A,j,N,m,P]),R=Sr(),z=or(e=>{R.give(e),c?.()}),B=(0,q.useMemo)(()=>({fileDrop:{over:z.over,intake:R}}),[z.over,R]),ee=s?.dismiss,te=s?.cancel,ne=s?.sent,re=(0,q.useMemo)(()=>ee&&te?{dismiss:ee,cancel:te,sent:ne}:null,[ee,te,ne]);return{slug:n,answering:d,transcript:L,promptBoxSends:u,fileOver:z.over,queuedRun:I,exit:re,sendScope:h,zone:z.handlers,box:B}}function cC({surface:e,children:t,...n}){let r=on(),i=Tx(e.slug,e.queuedRun),a=e.zone;return(0,q.useEffect)(()=>{if(r)return r.current=a,()=>{r.current===a&&(r.current=null)}}),(0,X.jsx)(Lb.Provider,{value:e.slug,children:(0,X.jsx)(Rb.Provider,{value:e.exit,children:(0,X.jsx)(_v.Provider,{value:e.sendScope,children:(0,X.jsx)(vv.Provider,{value:e.sendScope.composer,children:(0,X.jsx)(JS,{thread:e.transcript.thread,children:(0,X.jsx)(tC.Provider,{value:e.transcript,children:(0,X.jsx)(zb.Provider,{value:e.queuedRun,children:(0,X.jsx)(eC.Provider,{value:e.box,children:(0,X.jsx)(`div`,{...n,...r?null:a,"data-thread-surface":e.slug,onKeyDown:e=>{n.onKeyDown?.(e),i(e)},children:t})})})})})})})})})}function lC({blocks:e,answering:t,onClose:n}){let[r,i]=(0,q.useState)(0),[a,o]=(0,q.useState)(!1);(0,q.useEffect)(()=>{let e=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(e)},[]),(0,q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),n())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n]);let s=e[Math.min(r,e.length-1)];if(!s)return null;let c=r>=e.length-1;return(0,X.jsxs)(oa,{"data-mobile-answer-sheet":!0,label:`Answer questions`,className:`fixed inset-0 ${na} flex flex-col justify-end`,children:[(0,X.jsx)(`button`,{"aria-label":`Close`,onClick:n,className:`absolute inset-0 bg-scrim-50 transition-opacity duration-200 ${a?`opacity-100`:`opacity-0`}`}),(0,X.jsxs)(`div`,{className:`relative flex max-h-[86%] flex-col overflow-hidden rounded-t-[14px] border-t border-border-strong bg-panel pb-[env(safe-area-inset-bottom)] shadow-[0_-20px_60px_-10px_var(--sheet-shadow)] transition-transform duration-200 ease-out motion-reduce:transition-none ${a?`translate-y-0`:`translate-y-full`}`,children:[(0,X.jsx)(`div`,{className:`mx-auto mt-[6px] h-[5px] w-[36px] shrink-0 rounded-full bg-muted/35`}),(0,X.jsxs)(`div`,{className:`flex h-[48px] shrink-0 items-center gap-2 border-b border-border/70 px-3`,children:[(0,X.jsx)(`button`,{onClick:n,className:`flex h-[44px] items-center px-2 text-[16px] text-fg/85`,children:`Cancel`}),(0,X.jsx)(`span`,{className:`flex-1 text-center text-[15px] font-semibold tracking-[-0.01em] text-fg`,children:e.length>1?`Question ${r+1} of ${e.length}`:`Question`}),(0,X.jsx)(`span`,{className:`flex h-[44px] w-[44px] items-center justify-center`,children:(0,X.jsx)(L,{size:19,className:`opacity-0`,"aria-hidden":!0})})]}),(0,X.jsx)(`div`,{"data-mobile-answer-body":!0,className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:(0,X.jsx)(cS,{raw:s.raw,questionKind:s.kind,danger:s.danger,interactive:{answer:t.answerFor(s.bi),onChip:(e,n)=>t.onChip(s.bi,e,n),onText:e=>t.onText(s.bi,e),onSubmit:()=>c?l():i(e=>e+1)}},s.bi)}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-3 border-t border-border/70 px-4 pb-[30px] pt-3`,children:[e.length>1?(0,X.jsx)(`div`,{className:`flex items-center gap-1.5`,children:e.map((e,t)=>(0,X.jsx)(`span`,{className:`size-[6px] rounded-full ${t===r?`bg-accent`:`bg-muted/35`}`},e.bi))}):null,(0,X.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[r>0?(0,X.jsx)(`button`,{onClick:()=>i(e=>e-1),className:`flex h-[50px] shrink-0 items-center justify-center rounded-[14px] border border-border-strong bg-elevated px-5 text-[17px] text-fg active:bg-panel-2`,children:`Back`}):null,(0,X.jsx)(`button`,{onClick:()=>c?l():i(e=>e+1),disabled:c?!t.anyAnswered||t.sending:!1,className:`button-outline flex h-[50px] flex-1 items-center justify-center rounded-[14px] bg-accent-fill px-5 text-[17px] font-semibold text-on-accent transition-[filter,opacity] active:brightness-90 disabled:opacity-40`,children:c?t.sending?`Sending…`:`Send answers`:`Continue`})]})]})]})]});function l(){t.onSubmit(),n()}}var uC=(e,t)=>`${e}|${t}`;function dC(e,t){return e.flatMap(e=>eS(e.spec,t(e)).map(t=>({key:uC(e.id,t.path),q:e,path:t.path,spec:t.spec,depth:t.depth})))}function fC(e,t,n,r){return pC(dC(e,e=>{let i=t(e);if(e.id!==n.q.id)return i;let a=i.get(n.path)??{chosen:null,chosenSet:[],text:``};return new Map(i).set(n.path,{...a,chosen:r})}),n.key)}function pC(e,t){let n=e.findIndex(e=>e.key===t);return n===-1?null:e[n+1]?.key??null}function mC(e,t){return e.find(e=>!tS(e.spec,t(e.q).get(e.path)))?.key??null}var hC=`••••••••`;function gC(e,t){if(!t||!tS(e,t))return null;if(e.secret)return hC;let n=(e.options??[]).map(e=>_C(e.label)),r=t.text.trim();return e.kind===`multi`?[(t.chosenSet??[]).slice().sort((e,t)=>e-t).flatMap(e=>n[e]===void 0?[]:[n[e]]).join(`, `),r].filter(Boolean).join(` — `):t.chosen!==null&&n[t.chosen]!==void 0?n[t.chosen]:r||null}function _C(e){return e.replace(/[`*_~]/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\s+/g,` `).trim()}function vC(e){let t=e?.trim();return t&&!t.includes(`
|
|
132
|
-
`)?t:void 0}function yC({title:e,onRequestClose:t,children:n,footer:r,className:i=``,dataAttr:a}){let[o,c]=(0,q.useState)(!1),l=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=requestAnimationFrame(()=>c(!0));return()=>cancelAnimationFrame(e)},[]);let u=a?{[a]:``}:{};return(0,X.jsx)(cr,{open:!0,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(s,{children:[(0,X.jsx)(nn,{className:`fixed inset-0 ${na} bg-scrim-50 transition-opacity duration-200 motion-reduce:transition-none ${o?`opacity-100`:`opacity-0`}`}),(0,X.jsxs)(wr,{ref:l,...u,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault(),l.current?.focus({preventScroll:!0})},onEscapeKeyDown:Ot,className:`fixed inset-x-0 bottom-0 ${na} flex max-h-[86%] flex-col overflow-hidden rounded-t-[14px] border-t border-border-strong bg-panel pb-[calc(14px+env(safe-area-inset-bottom))] shadow-[0_-20px_60px_-10px_var(--sheet-shadow)] outline-none transition-transform duration-200 ease-out motion-reduce:transition-none ${o?`translate-y-0`:`translate-y-full`} ${i}`,children:[(0,X.jsx)(vi,{className:`sr-only`,children:e}),(0,X.jsx)(`div`,{"aria-hidden":!0,className:`mx-auto mt-[6px] mb-[6px] h-[5px] w-[36px] shrink-0 rounded-full bg-muted/35`}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:n}),r]})]})})}function bC({questions:e,onClose:t}){let n=(0,q.useContext)(xS),r=no(t),i=n?dC(e,n.answersOf):[],[a,o]=(0,q.useState)(()=>n?mC(i,n.answersOf):null),[s,c]=(0,q.useState)(!1),l=e.length===0;if((0,q.useEffect)(()=>{l&&r()},[l,r]),!n||!n.slug||l)return null;let u=a===null?-1:i.findIndex(e=>e.key===a),d=u===-1?void 0:i[u],f=e=>{c(!1),o(e)},p=d?u:i.length,m=(0,X.jsx)(`span`,{"aria-hidden":!0,className:`flex gap-[5px]`,children:Array.from({length:i.length+1},(e,t)=>(0,X.jsx)(`i`,{className:`size-[6px] rounded-full ${t<=p?`bg-fg`:`bg-border-strong`}`},t))});return(0,X.jsxs)(yC,{title:d?`Question ${u+1} of ${i.length}`:`Review your answers`,onRequestClose:()=>r(),dataAttr:`data-answer-sheet`,footer:d?(0,X.jsx)(OC,{a:n,step:d,first:u===0,writing:s,onBack:()=>f(i[u-1]?.key??d.key),onNext:()=>f(pC(i,d.key))}):(0,X.jsx)(AC,{a:n,onSent:()=>r()}),children:[(0,X.jsxs)(`div`,{"data-answer-step":d?d.key:`review`,className:`flex items-center gap-2 px-[18px] pb-1 text-[12.5px] text-muted`,children:[m,(0,X.jsxs)(`span`,{children:[d?`Question ${u+1} of ${i.length}`:`Review`,d&&d.depth>1&&` · follow-up`,d?.spec.danger&&(0,X.jsx)(`span`,{className:`text-danger-soft`,children:` · destructive`})]})]}),d?(0,X.jsx)(xC,{a:n,step:d,writing:s,onWrite:()=>c(!0),onPick:t=>{let r=fC(e,n.answersOf,d,t);n.answerFor(d.q,d.path).chosen!==t&&n.onChip(d.q,d.path,!1,t),f(r)}},d.key):(0,X.jsx)(kC,{a:n,steps:i,onChange:e=>f(e)})]})}function xC({a:e,step:t,writing:n,onWrite:r,onPick:i}){let a=tp(t.spec.question),o=tp(t.spec.context?.trim()??``),s=e.answerFor(t.q,t.path),c=t.spec.options??[],l=t.spec.kind===`multi`,u=!e.readAndAnswerHost&&(c.length===0||n||!l&&s.chosen===null&&s.text.trim()!==``);return(0,X.jsxs)(`div`,{"data-answer-question":!0,children:[(0,X.jsx)($h,{className:`px-[18px] pb-3 pt-1 text-[17px] font-semibold leading-[23px] text-fg ${_S}`,html:a}),o&&(0,X.jsx)(`div`,{"data-question-context":!0,className:`card-md min-w-0 overflow-x-auto px-[18px] pb-3 text-fg/75`,children:(0,X.jsx)($h,{className:`md-body`,html:o})}),c.length>0&&(0,X.jsxs)(`div`,{role:l?`group`:`radiogroup`,className:`border-b border-border`,children:[c.map((n,r)=>(0,X.jsx)(CC,{option:n,multi:l,on:l?(s.chosenSet??[]).includes(r):s.chosen===r,onClick:()=>l?e.onChip(t.q,t.path,!0,r):i(r)},r)),!u&&!e.readAndAnswerHost&&(0,X.jsxs)(`button`,{type:`button`,"data-answer-write":!0,onClick:r,className:`${SC} text-left`,children:[(0,X.jsx)(TC,{multi:l,on:!1,dashed:!0}),(0,X.jsx)(`span`,{className:`text-[15.5px] font-medium leading-[21px] text-muted`,children:l?`Add a note…`:`Write a different answer…`})]})]}),u&&t.spec.secret&&(0,X.jsx)(DC,{a:e,step:t,text:s.text}),u&&!t.spec.secret&&(0,X.jsx)(EC,{a:e,step:t,autoFocus:n,placeholder:c.length===0?`Type your answer…`:l?`Add a note…`:`Write a different answer…`})]})}var SC=`flex w-full items-start gap-3 border-t border-border px-[18px] py-3 outline-none active:bg-hover focus-visible:bg-hover`;function CC({option:e,multi:t,on:n,onClick:r}){let i=vC(e.description),a=[i?void 0:e.description?.trim(),e.preview?.trim()].filter(Boolean).join(`
|
|
133
|
-
|
|
134
|
-
`);return(0,X.jsxs)(`button`,{type:`button`,role:t?`checkbox`:`radio`,"aria-checked":n,"data-answer-option":!0,"data-on":n||void 0,onClick:e=>{e.target.closest(`[data-lightbox-tile], img[data-local-path]`)||r()},className:`${SC} text-left`,children:[(0,X.jsx)(TC,{multi:t,on:n}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`block text-[15.5px] font-medium leading-[21px] text-fg`,children:[(0,X.jsx)(yS,{md:e.label}),e.recommended&&(0,X.jsx)(`span`,{className:`ml-1.5 text-[11px] font-bold leading-none tracking-[0.02em] text-accent`,children:`RECOMMENDED`})]}),i&&(0,X.jsx)(`span`,{className:`mt-px block text-[13px] leading-[18px] text-muted`,children:i}),a&&(0,X.jsx)(wC,{md:a})]})]})}function wC({md:e}){return(0,X.jsx)(`div`,{className:`card-md mt-1 text-muted`,children:(0,X.jsx)($h,{className:`md-body`,html:tp(e)})})}function TC({multi:e,on:t,dashed:n=!1}){return(0,X.jsx)(`span`,{"aria-hidden":!0,className:`mt-[0.5px] flex size-5 shrink-0 items-center justify-center border-[1.5px] ${e?`rounded-[5px]`:`rounded-full`} ${n?`border-dashed`:``} ${t?e?`border-fg bg-fg text-bg`:`border-fg`:`border-border-strong`}`,children:t&&(e?(0,X.jsx)(Qt,{size:14,strokeWidth:3}):(0,X.jsx)(`span`,{className:`size-2.5 rounded-full bg-fg`}))})}function EC({a:e,step:t,autoFocus:n,placeholder:r}){let i=(0,q.useRef)(null),a=e.answerFor(t.q,t.path).text,o=t.spec.kind===`multi`;return(0,q.useLayoutEffect)(()=>{let e=i.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`)},[a]),(0,q.useEffect)(()=>{n&&i.current?.focus()},[n]),(0,X.jsx)(`div`,{className:`px-[18px] ${(t.spec.options??[]).length===0?``:`pt-3`}`,children:(0,X.jsx)(`textarea`,{ref:i,"data-answer-text":!0,"data-1p-ignore":!0,"data-claims-escape":!0,rows:(t.spec.options??[]).length===0?3:1,value:a,placeholder:r,onChange:n=>e.onText(t.q,t.path,o,n.target.value),onFocus:()=>{o||e.onText(t.q,t.path,!1,a)},className:`block max-h-[40vh] w-full resize-none overflow-y-auto rounded-[12px] border border-border-strong bg-bg px-3 py-[11px] text-[16px] leading-[22px] text-fg outline-none placeholder:text-faint focus:border-fg/40`})})}function DC({a:e,step:t,text:n}){return(0,X.jsxs)(`div`,{className:`px-[18px]`,children:[(0,X.jsx)(`input`,{type:`password`,"data-answer-text":!0,"data-secret-answer":!0,"data-claims-escape":!0,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,"aria-label":`Secret value`,value:n,placeholder:`Paste the value…`,onChange:n=>e.onText(t.q,t.path,!1,n.target.value),className:`block w-full rounded-[12px] border border-border-strong bg-bg px-3 py-[11px] text-[16px] leading-[22px] text-fg outline-none placeholder:text-faint focus:border-fg/40`}),(0,X.jsx)(sS,{className:`mt-2 text-[13px] leading-[18px] text-muted`})]})}function OC({a:e,step:t,first:n,writing:r,onBack:i,onNext:a}){let o=e.answerFor(t.q,t.path),s=tS(t.spec,o),c=t.spec.options??[],l=t.spec.kind!==`multi`&&o.chosen===null&&o.text.trim()!==``,u=t.spec.kind===`multi`||c.length===0||r||l;return(0,X.jsxs)(PC,{children:[(0,X.jsx)(`button`,{type:`button`,"data-answer-back":!0,disabled:n,onClick:i,className:`${jC} ${MC} disabled:opacity-35`,children:`Back`}),(0,X.jsx)(`span`,{className:`flex-1`}),!(u&&s)&&(0,X.jsx)(`button`,{type:`button`,"data-answer-skip":!0,onClick:a,className:`${jC} ${MC}`,children:s?`Next`:`Skip`}),u&&(0,X.jsx)(`button`,{type:`button`,"data-answer-continue":!0,disabled:!s,onClick:a,className:`${jC} ${NC} px-6 disabled:opacity-35`,children:`Continue`})]})}function kC({a:e,steps:t,onChange:n}){let r=t.map(t=>({s:t,said:gC(t.spec,e.answerFor(t.q,t.path))})),i=r.filter(e=>e.said!==null).length;return(0,X.jsxs)(`div`,{"data-answer-review":!0,children:[(0,X.jsx)(`div`,{className:`px-[18px] pb-3 pt-1 text-[17px] font-semibold leading-[23px] text-fg`,children:i===0?`No answers yet`:`${i} answer${i===1?``:`s`}`}),(0,X.jsx)(`div`,{className:`border-b border-border`,children:r.map(({s:e,said:t})=>(0,X.jsxs)(`button`,{type:`button`,"data-answer-change":e.key,onClick:()=>n(e.key),className:`block w-full border-t border-border px-[18px] py-2.5 text-left outline-none active:bg-hover focus-visible:bg-hover`,children:[(0,X.jsx)(`span`,{className:`line-clamp-2 block text-[13px] leading-[18px] text-muted`,children:FC(e.spec.question)}),(0,X.jsxs)(`span`,{className:`mt-0.5 flex items-baseline justify-between gap-2.5`,children:[(0,X.jsx)(`span`,{className:`min-w-0 break-words text-[15.5px] leading-[21px] ${t===null?`text-muted`:`font-medium text-fg`}`,children:t??`Skipped`}),(0,X.jsx)(`span`,{className:`shrink-0 text-[13.5px] text-muted`,children:`Change`})]})]},e.key))})]})}function AC({a:e,onSent:t}){return(0,X.jsx)(PC,{children:(0,X.jsx)(`button`,{type:`button`,"data-answer-send":!0,disabled:e.staged===0||e.sending,onClick:()=>{e.submit(),t()},className:`${jC} ${NC} flex-1 disabled:opacity-35`,children:e.sending?`Sending…`:`Send answers`})})}var jC=`flex h-[46px] shrink-0 items-center justify-center rounded-[12px] text-[15.5px] font-semibold outline-none`,MC=`px-[18px] text-muted active:bg-hover focus-visible:bg-hover`,NC=`bg-fg text-bg active:opacity-90`;function PC({children:e}){let t=(0,q.useRef)(null),[n,r]=(0,q.useState)(!1);(0,q.useEffect)(()=>{let e=0,n=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e=document.activeElement;r((e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement)&&t.current?.parentElement?.contains(e)===!0)})};return n(),document.addEventListener(`focusin`,n),document.addEventListener(`focusout`,n),()=>{cancelAnimationFrame(e),document.removeEventListener(`focusin`,n),document.removeEventListener(`focusout`,n)}},[]);let i=en(t,n);return(0,X.jsxs)(`div`,{ref:t,"data-answer-footer":!0,className:`shrink-0`,children:[(0,X.jsx)(`div`,{className:`flex items-center gap-2.5 px-[18px] pt-3.5`,children:e}),i>0&&(0,X.jsx)(`div`,{"aria-hidden":!0,style:{height:i}})]})}function FC(e){return _C(e.trim().split(/\n\s*\n/)[0]??``)}function IC(e){return(0,q.useSyncExternalStore)(e=>Wt(W,e),()=>e?LC(e)!==`codex`:!1,()=>!1)}function LC(e){return vs(W.board,e)?.backend}function RC(e,t,n,r){let i=jr.followUp(e,t,n);return Fs(i,r),i}function zC(e){if(!(typeof document>`u`)){for(let t=e;t;t=t.parentElement){let e=t.querySelector(`[data-thread-composer-box] textarea`);if(e){e.focus(),e.setSelectionRange(e.value.length,e.value.length);return}}document.getElementById(`followup-input`)?.focus()}}function BC(e){let t=ct(),n=yn(),[r,i]=(0,q.useState)(!1);return{unqueue:(0,q.useCallback)(a=>{if(!e||r)return;let o=vs(W.board,e)?.sessionId;if(!o){G(`This thread has no live session to unqueue from`);return}i(!0),U.unqueueFollowUp({slug:e,sessionId:o,deliveryId:a.deliveryId}).then(r=>{if(i(!1),!r.unqueued){G(r.reason??`That message could not be taken back`);return}vt(t,e,a.rawText,a.deliveryId),RC(n,e,o,a.text),zC(a.from)},e=>{i(!1),G(`Couldn't unqueue — ${(e instanceof Error?e.message:String(e)).slice(0,160)}`)})},[r,n,t,e]),pending:r}}function VC(e){let t=ct(),n=yn(),[r,i]=(0,q.useState)(!1),a=(0,q.useCallback)(n=>{!e||r||Vi(t,e,n.text,{supersedes:n.deliveryId,failureToast:e=>`Retry failed — ${e.slice(0,160)}`})},[r,t,e]),o=(0,q.useCallback)(async t=>{if(!e)return!1;i(!0);try{return await U.dismissFailedFollowUp({slug:e,deliveryId:t}),!0}catch(e){return G(`Couldn't dismiss — ${(e instanceof Error?e.message:String(e)).slice(0,160)}`),!1}finally{i(!1)}},[e]);return{retry:a,edit:(0,q.useCallback)(t=>{!e||r||(RC(n,e,vs(W.board,e)?.sessionId,t.text),zC(t.from),o(t.deliveryId))},[o,r,n,e]),dismiss:(0,q.useCallback)(t=>{!e||r||o(t.deliveryId)},[o,r,e]),pending:r}}var HC=new Map;function UC(e,t){let n=(HC.get(e)??[]).filter(e=>e.deliveryId!==t.deliveryId);n.push(t),HC.set(e,n.slice(-8))}var WC=e=>e.replace(/\s+/g,` `).trim();function GC(e,t){let n=HC.get(e);if(!n?.length)return;let r=WC(t);for(let t=n.length-1;t>=0;t--){let i=WC(n[t].text);if(!i||!r.includes(i))continue;let[a]=n.splice(t,1);return n.length||HC.delete(e),a.deliveryId}}function KC(e){return e.project?`${Bo(e.project)}/thread/${e.slug}`:ia(`/thread/${e.slug}`)}function qC({peer:e,text:t,queued:n,sourceId:r,at:i,wrap:a}){let[o,s]=(0,q.useState)(!1),c=(0,q.useId)(),l=e.thread,u=Se(l&&!l.project?l.slug:void 0),d=u?jt(u):l?.title,f=tp(t),p=Up(f),m=(0,q.useRef)(null),h=th(m,f),g=(0,q.useRef)(null),_=(0,q.useRef)(!1),v=()=>{_.current=document.activeElement===g.current,s(e=>!e)};(0,q.useLayoutEffect)(()=>{_.current&&(_.current=!1,g.current?.focus())},[o]);let y=e=>{e.target.closest(`a, button`)||v()},b=e=>e.preventDefault(),x=l?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`shrink-0 ${Xy}`,children:`Message from `}),(0,X.jsx)(`a`,{href:KC(l),"data-session-peer-link":!0,title:`Open the thread that sent this`,onMouseDown:b,className:`min-w-0 truncate [font-variant-caps:normal] ${ob}`,children:d})]}):(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name?`Message from session ${e.name}`:`Message from another session`}),S=(0,X.jsx)(`button`,{ref:g,type:`button`,"data-session-message-toggle":!0,onClick:v,onMouseDown:b,"aria-expanded":o,"aria-controls":c,"aria-label":o?`Collapse the message`:`Expand the message`,className:`shrink-0 rounded-sm outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:(0,X.jsx)(br,{"aria-hidden":`true`,size:12,className:`${nb} ${o?`-mx-[0.15em] rotate-90`:`-mx-[0.275em]`}`})});return(0,X.jsx)(`div`,{"data-frizz-msg":r,"data-session-message":!0,className:`flex flex-col ${n?`opacity-50`:``}`,children:o?(0,X.jsxs)(`fieldset`,{className:`@container/wake my-1 min-w-0 rounded-xl border border-border/70 px-4 pb-3.5 pt-1 transition-colors has-[>legend:hover]:border-border`,children:[(0,X.jsx)(`legend`,{onClick:y,onMouseDown:b,className:`group/wake mx-auto max-w-[calc(100%-66px)] cursor-pointer px-3`,children:(0,X.jsx)(Jy,{icon:yc,at:i,trailing:S,children:x})}),(0,X.jsxs)(`div`,{id:c,className:`card-md text-fg/85`,children:[(0,X.jsx)(`div`,{ref:m,className:`md-body [overflow-wrap:anywhere]${a?` ${lm}`:``}`,dangerouslySetInnerHTML:p}),h]})]}):(0,X.jsx)(`div`,{onClick:y,onMouseDown:b,className:`group/wake cursor-pointer`,children:(0,X.jsx)(Q,{icon:yc,marker:`session-message`,at:i,trailing:S,children:x})})})}function JC(e,t,n){return{type:`frizz-inline-vis-theme`,requestId:e,colorScheme:t,vars:n}}function YC(e,t){return typeof e==`object`&&!!e&&e.type===`frizz-inline-vis-applied`&&e.requestId===t}var XC=new Set([`planning`,`planned`,`active`,`needs-human`,`blocked`]);function ZC(e){return!!(e&&e.kind===`legacy`&&!e.foreign&&e.runtime===`none`&&!e.sessionId&&!e.threadName&&!e.owner&&e.agents.length===0&&e.errors.length===0&&XC.has(e.status))}function QC(e,t){return e.pending?`loading`:e.failed?`failed`:t.running?`starting`:t.adoptable?`adopt`:`empty`}var $C=`sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3 ${ae} max-[640px]:h-auto max-[640px]:min-h-12 max-[640px]:flex-wrap max-[640px]:items-start max-[640px]:gap-y-2 max-[640px]:px-4 max-[640px]:py-2.5`,ew=`flex min-w-0 flex-1 items-center gap-2.5 pl-1 max-[640px]:basis-full`,tw=`flex shrink-0 items-center max-[640px]:w-full`;function nw(e){return e?.trim()?{kind:`profile-error`,message:`Profile controls unavailable: ${e.trim().slice(0,160)}`}:null}function rw(e){if(e.foreign)return`Read-only external thread`;if(e.permissionChangePending||e.permissionPending)return`A permission change is already in progress`;if(e.profileChangePending)return`A model and effort change is already in progress`;if(e.runtimeControlPending)return`Another runtime control is already in progress`;if(e.pendingAsk||e.runtime===`perm-prompt`)return`Resolve the open approval or question first`;if(e.backend===`codex`||e.backend===`acp`||e.backend===`opencode`)return null;let t=[...e.subAgents??[],...e.bgShells??[]].filter(e=>e.state===`running`||e.state===`stale`).length;return t>0?`Wait for ${t} unresolved background operation${t===1?``:`s`}`:e.runtime===`running`||e.runtime===`spawning`?`Wait for the current turn to finish`:null}function iw(e){return e.permissionChangePending===!0||e.permissionPending!==void 0||e.profileChangePending===!0||e.runtimeControlPending===!0}function aw(e,t){let n=t===`codex`?`Sandbox`:`Permissions`;return e===`applied`?`${n} applied to the live session`:e===`next-turn`?t===`codex`?`${n} applied — takes effect on the next turn`:`${n} saved — the worker restarts on the next turn`:`${n} saved for the next resume`}function ow(e,t,n,r){let i=e.find(e=>e.model===t),a=!!i,o=!!(i&&n&&i.efforts.includes(n)),s=a&&o;return{selectedProfile:i,modelKnown:a,effortKnown:o,profileKnown:s,modelSelectable:r||a,effortSelectable:!!i&&(r||s)}}function sw(e){let t=Se(e),n=Re({queryKey:[`threadProfileOptions`,e],queryFn:()=>U.threadProfileOptions({slug:e}),enabled:!!(t&&!t.foreign&&t.kind===`session`),staleTime:5e3}),r=H({mutationFn:t=>U.setThreadProfile({slug:e,model:t.model,...t.effort?{effort:t.effort}:{}})}),i=H({mutationFn:t=>U.setThreadPermission({slug:e,permissionMode:t})}),a=H({mutationFn:t=>U.upgradeThreadModel({slug:e,sessionId:t})}),o=Cr(),s=H({mutationFn:t=>U.stopThreadTurn({slug:e,sessionId:t})}),c=r.isPending||i.isPending||a.isPending,l=t?.backend===`codex`?`codex`:t?.backend===`acp`?`acp`:t?.backend===`opencode`?`opencode`:`claude`,u=t?Si(t.id):void 0,d=Re({queryKey:Ga([`acpAgents`],u),queryFn:()=>dt(u).acpAgents(),enabled:!!t&&l===`acp`}),f=qe(u,!!t&&l===`opencode`);if(!t||t.foreign||t.kind!==`session`)return{busy:c,footer:null,phoneTools:null,status:null};let m=c||iw(t),h=t.model?.trim(),g=t.effort?.trim(),_=l===`acp`?P(h):void 0,v=l===`acp`?bs(h):void 0,y=r.isPending?r.variables:void 0,b=t.profilePendingModel??y?.model,x=t.profilePendingEffort??y?.effort,S=l===`acp`&&y?bs(y.model):void 0,C=n.data?.options??[],{modelSelectable:w}=ow(C,h,g,t.runtime===`exited`),T=n.data!==void 0,E=d.data?.find(e=>e.id===_)?.label??_,D=[{id:l,label:l===`codex`?`Codex`:`Claude Code`,options:C}],O=nw(n.isError?n.error.message:void 0),k=t.permissionMode?fn(t.permissionMode):`auto`,A=Ve.some(e=>e.value===k)?k:`auto`,j=i.isPending?i.variables:A,M=rw(t);function N(e){e!==A&&i.mutate(e,{onSuccess:e=>G(aw(e.effect,`claude`)),onError:e=>G(`Permission change failed: ${e.message.slice(0,120)}`)})}let F=l===`claude`?rw(t):null;function I(){t?.sessionId&&a.mutate(t.sessionId,{onSuccess:e=>G(`${e.label} from the next turn — the worker restarts then`),onError:e=>G(`Upgrade failed: ${e.message.slice(0,120)}`)})}function L(e){r.mutate(e,{onSuccess:e=>G(l===`acp`?e.effect===`next-resume`?`Model saved for the next resume`:`Model applied`:e.effect===`next-resume`?`Model and effort saved for the next resume`:`Model and effort applied`),onError:e=>G(`Profile change failed: ${e.message.slice(0,120)}`)})}let R=(0,X.jsxs)(X.Fragment,{children:[(l===`claude`||l===`codex`)&&(0,X.jsx)(Lt,{groups:D,value:{provider:l,model:h,effort:g},pending:b||x?{provider:l,model:b,effort:x}:void 0,onValueChange:({model:e,effort:t})=>L({model:e,effort:t}),placeholder:n.isPending?`Profile loading…`:`Profile unknown`,ariaLabel:`Thread model and effort`,menuAriaLabel:`Choose ${l===`codex`?`Codex`:`Claude Code`} model and effort`,title:w?t.runtime===`exited`?`Saved per thread and applied when this conversation resumes`:`Change this idle conversation's model and reasoning effort`:`The current live backend profile is unavailable; controls fail closed`,disabled:m||!T||!w||n.isError,compact:!0,side:`top`,className:`max-w-[20rem]`,runningModelLabel:t.runningModelLabel,upgrade:t.modelUpgrade&&t.runningModelLabel?{latest:t.modelUpgrade.label,staged:t.modelUpgrade.staged,blockedReason:F,pending:a.isPending,onUpgrade:I}:void 0}),l===`acp`&&_&&(0,X.jsx)(B,{agentId:_,agentLabel:E??_,modelId:S??v,onValueChange:e=>L({model:An(_,e),effort:``}),disabled:m,side:`top`,className:`max-w-[20rem]`}),l===`opencode`&&(0,X.jsx)(Lt,{groups:[Ce({models:f.models,loading:f.loading,saved:h,onRequestOptions:f.request})],value:tt(h),pending:y?tt(y.model):void 0,onValueChange:e=>L({model:yo(e),effort:``}),ariaLabel:`Thread model and effort`,menuAriaLabel:`Choose OpenCode model and effort`,title:`This thread's OpenCode model and reasoning level`,disabled:m,compact:!0,side:`top`,className:`max-w-[20rem]`})]});return{busy:m,footer:(0,X.jsxs)(`div`,{"data-thread-composer-controls":!0,className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-1.5 gap-y-0.5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-x-1.5`,children:[(0,X.jsxs)(p,{children:[R,l===`claude`&&(0,X.jsx)(ya,{variant:`readout`,side:`top`,value:j,onValueChange:e=>N(e),options:Ve,ariaLabel:`Thread permission mode`,title:M?`${M} — changing permissions restarts this thread's worker process`:j===`bypassPermissions`?`Bypass: the worker never asks for approval. Changing this restarts the worker process; the conversation resumes from disk on the next turn.`:`Auto: risky actions raise an approval card here. Changing this restarts the worker process; the conversation resumes from disk on the next turn.`,disabled:m||M!==null,className:`shrink-0`}),l===`opencode`&&(0,X.jsx)(ya,{variant:`readout`,side:`top`,value:i.isPending?i.variables:t.permissionMode??`auto`,onValueChange:e=>{i.mutate(e,{onSuccess:()=>G(`Permissions applied to the session`),onError:e=>G(`Permission change failed: ${e.message.slice(0,120)}`)})},options:ft,ariaLabel:`Thread permission mode`,title:`Applied to the session at once, and to its sub-agents.`,disabled:m,className:`shrink-0`})]}),l===`opencode`&&t.runtime===`running`&&t.sessionId&&(0,X.jsxs)(`button`,{type:`button`,"data-stop-turn":!0,onClick:()=>s.mutate(t.sessionId,{onError:e=>G(`Stop failed: ${e.message.slice(0,120)}`)}),disabled:s.isPending,"aria-label":`Stop this turn`,title:`Stop this turn. The thread stays open for your next message.`,className:`-ml-px -mr-[6.5px] flex h-[22px] shrink-0 items-center gap-1 rounded-md px-1.5 text-[11px] text-muted hover:bg-fill-hover hover:text-fg disabled:opacity-50`,children:[(0,X.jsx)(jc,{size:8,fill:`currentColor`,strokeWidth:0,"aria-hidden":!0}),!o&&`Stop`]}),(0,X.jsx)(Be,{gauge:l===`acp`||l===`opencode`?void 0:{backend:l,model:h},mcp:{slug:e},side:`top`})]}),b&&x&&(0,X.jsxs)(`span`,{className:`min-w-0 truncate text-[9px] text-muted-50`,children:[`→ `,b,` · `,x,` pending`]})]}),phoneTools:R,status:O?(0,X.jsx)(`div`,{"data-thread-control-error":``,className:`px-1 pt-1 text-[9.5px] leading-tight text-muted-65`,children:O.message}):null}}function cw(e,t=cs.queueOrder){let n=sr(e,t),r=n.active.filter(Ee),i=n.active.filter(e=>!Ee(e));return[...n.pinned,...r,...i]}function lw(e,t,n=cs.queueOrder,r=ea()){return cw(e.map(e=>Io(e,r[e.id])),n).find(e=>e.id!==t&&pa(e))}function uw(e){let t=lw(W.board?.threads??[],e);if(Or()){t&&window.addEventListener(`popstate`,()=>setTimeout(()=>ki(t.id),0),{once:!0}),history.back();return}if(t){ki(t.id);return}let n=W.drawers.filter(e=>!e.closing).map(e=>e.id);n.length&&ri(n)}var dw=new Map;async function fw(e,t={}){let n=e.id,r=t.terminateLive===!0,i=r||cv(e),a=jt(e),o=()=>{eo(n),uw(n),G(`“${a}” marked done`,{action:{label:`Undo`,run:()=>void pw(n)}})};i&&o();let s=U.completeThread({slug:n,sessionId:e.sessionId??``,terminateLive:r});dw.set(n,s);try{let e=await s;return e.needsConfirmation?(zr(n),i?(G(e.hold?.cutOff?`Cut off mid-turn — open the thread to retry it, or to mark it done anyway`:`Still running — open the thread to finish it`,{link:{label:`Open`,slug:n}}),{kind:`declined`}):{kind:`needs-confirmation`,hold:e.hold}):(i||o(),{kind:`done`})}catch(e){return zr(n),G(`Couldn’t finish: ${e.message.slice(0,80)}`,i?{link:{label:`Open`,slug:n}}:void 0),{kind:`failed`}}finally{dw.get(n)===s&&dw.delete(n)}}async function pw(e){await dw.get(e)?.catch(()=>void 0);try{await U.setThreadState({slug:e,state:`open`}),zr(e),ki(e)}catch(e){G(`Couldn’t undo: ${e.message.slice(0,80)}`)}}function mw({thread:e,compact:t}){let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(null);async function o(t){r(!0),t&&a(null);let n=await fw(e,{terminateLive:t});n.kind===`needs-confirmation`&&a({hold:n.hold}),n.kind!==`done`&&r(!1)}let s=lv(i?.hold);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,"data-phone-done":!0,onMouseDown:e=>e.preventDefault(),onClick:()=>void o(!1),disabled:n,"aria-label":`Mark as done`,className:`flex shrink-0 items-center justify-center gap-1 rounded-full bg-fg font-semibold text-bg disabled:opacity-45 ${t?`relative h-[36px] pl-[11px] pr-[14px] text-[14px] after:absolute after:inset-x-0 after:-inset-y-[4px] after:content-['']`:`h-[42px] pl-[13px] pr-[16px] text-[15px]`}`,children:[n&&!i?(0,X.jsx)(Ut,{"aria-hidden":!0,size:t?15:17,className:`animate-spin`}):(0,X.jsx)(Qt,{"aria-hidden":!0,size:t?15:17,strokeWidth:2.6,className:`translate-y-[0.1em]`}),`Done`]}),(0,X.jsx)(ht,{open:i!==null,onOpenChange:e=>{!e&&!n&&a(null)},title:i?.hold?.cutOff?`Mark an unfinished thread done?`:`End this session?`,className:`w-[390px] max-w-[92vw]`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>a(null),className:`button-outline h-[40px] rounded-md px-4 text-[14px] text-muted outline-none disabled:opacity-45`,children:`Cancel`}),(0,X.jsxs)(`button`,{type:`button`,"data-phone-done-confirm":!0,disabled:n,onClick:()=>void o(!0),className:`button-outline flex h-[40px] items-center gap-1.5 rounded-md bg-fg px-4 text-[14px] font-medium text-bg outline-none disabled:opacity-45`,children:[n&&(0,X.jsx)(Ut,{size:14,className:`animate-spin`}),i?.hold?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,X.jsxs)(`div`,{"data-completion-hold":!0,className:`flex flex-col gap-2 p-4 text-[14px] leading-relaxed text-muted`,children:[(0,X.jsx)(`p`,{children:s.lead}),s.groups.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`div`,{className:`text-[12px] font-medium text-fg/70`,children:e.heading}),(0,X.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[e.items.map((e,t)=>(0,X.jsxs)(`li`,{className:`min-w-0 truncate text-fg/80`,children:[e.label,e.stale&&(0,X.jsx)(`span`,{className:`text-muted-60`,children:` · no recent output`})]},`${e.label}-${t}`)),e.overflow>0&&(0,X.jsxs)(`li`,{className:`text-muted-60`,children:[`+`,e.overflow,` more`]})]})]},e.kind)),(0,X.jsx)(`p`,{children:s.trailer})]})})]})}var hw={sm:{track:`h-[16px] w-[28px]`,thumb:`size-[12px]`,travel:`translate-x-[12px]`,onCap:`translate-y-[calc(6px_-_0.5cap)]`},md:{track:`h-[20px] w-[34px]`,thumb:`size-[16px]`,travel:`translate-x-[14px]`,onCap:`translate-y-[calc(8px_-_0.5cap)]`}};function gw({checked:e,onChange:t,disabled:n,label:r,size:i=`sm`,testId:a}){let o=hw[i];return(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r,disabled:n,"data-switch":a,"data-state":e?`checked`:`unchecked`,onMouseDown:e=>e.preventDefault(),onClick:()=>t(!e),className:`inline-flex shrink-0 cursor-pointer items-center self-baseline rounded-full p-[2px] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:cursor-default disabled:opacity-45 ${o.track} ${o.onCap} ${e?`bg-fg`:`bg-border hover:bg-border-strong`}`,children:(0,X.jsx)(`span`,{className:`pointer-events-none block rounded-full transition-transform duration-150 ease-out ${o.thumb} ${e?`bg-bg ${o.travel}`:`translate-x-0 bg-muted/70`}`})})}function _w({size:e=12,viewBox:t=`0 0 24 24`,strokeWidth:n=2,className:r=``}){return(0,X.jsxs)(`svg`,{width:e,height:e,viewBox:t,fill:`none`,stroke:`currentColor`,strokeWidth:n,strokeLinecap:`round`,strokeLinejoin:`round`,className:r,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,X.jsx)(`path`,{d:`M12 7a5 5 0 1 0 5 5`}),(0,X.jsx)(`path`,{d:`M13 3.055a9 9 0 1 0 7.941 7.945`}),(0,X.jsx)(`path`,{d:`M15 6v3h3l3 -3h-3v-3l-3 3`}),(0,X.jsx)(`path`,{d:`M15 9l-3 3`})]})}function vw({thread:e}){let[t,n]=(0,q.useState)(`closed`),r=(0,q.useRef)(null),i=(0,q.useRef)(void 0);(0,q.useEffect)(()=>()=>clearTimeout(i.current),[]);let a=t!==`closed`,[o,s]=(0,q.useState)(null);(0,q.useLayoutEffect)(()=>{if(!a)return;let e=r.current?.closest(`[data-queue-card-root], [role="dialog"], main`);if(!e){s(null);return}let t=e.getBoundingClientRect().left+e.clientLeft,n=r.current?.closest(`[data-composer-box]`)?.getBoundingClientRect(),i=r.current?.getBoundingClientRect();s({surface:e,left:Math.max(12,n?n.left-t:0),right:Math.max(12,n?t+e.clientWidth-n.right:0),width:xi(n?.width??e.clientWidth,yw),toBoxEnd:n&&i?n.right-i.right:0})},[a]);let c=o?{collisionBoundary:o.surface,collisionPadding:{top:12,bottom:12,left:o.left,right:o.right}}:{},l=e.recurringPrompt,u=l?.stopHook===!0||l?.heartbeat===!0||l?.postCompaction===!0;function d(){clearTimeout(i.current),i.current=setTimeout(()=>n(e=>e===`closed`?`preview`:e),bw)}function f(){clearTimeout(i.current),n(e=>e===`preview`?`closed`:e)}let p=e=>{r.current?.contains(e.detail.originalEvent.target)&&e.preventDefault()};return(0,X.jsxs)(S,{open:t!==`closed`,onOpenChange:e=>{e||(clearTimeout(i.current),n(`closed`))},children:[(0,X.jsx)(Wn,{asChild:!0,children:(0,X.jsx)(`button`,{ref:r,type:`button`,"data-recurring-prompt":!0,"data-recurring-prompt-on":u?`true`:`false`,"aria-label":u?`Goal (on)`:`Goal`,"aria-haspopup":`dialog`,"aria-expanded":t===`full`,onClick:()=>{clearTimeout(i.current),n(e=>e===`full`?`closed`:`full`)},onPointerEnter:e=>{e.pointerType===`mouse`&&d()},onPointerLeave:e=>{e.pointerType===`mouse`&&f()},onFocus:()=>n(e=>e===`closed`?`preview`:e),onBlur:f,className:`group/goal icon-focus-outline flex ${Ja} items-center justify-center outline-none transition-[color,background-color] hover:bg-hover-strong`,children:(0,X.jsx)(_w,{...qo,className:u?`text-attention-90`:`text-muted group-hover/goal:text-fg group-focus-visible/goal:text-fg`})})}),t===`preview`?(0,X.jsx)(je,{side:`top`,align:`end`,...c,"data-recurring-preview":!0,onPointerDownOutside:p,className:`pointer-events-none max-w-[min(22rem,calc(100vw-1.5rem))] p-2.5 text-[11px] leading-snug text-fg`,onOpenAutoFocus:e=>e.preventDefault(),children:(0,X.jsx)(xw,{armed:l})}):(0,X.jsx)(je,{side:`top`,align:`end`,...c,className:`w-[min(46rem,calc(100vw-1.5rem))] p-3 text-[11px] leading-relaxed text-fg`,style:o?{width:o.width}:void 0,alignOffset:o?-o.toBoxEnd:0,onPointerDownOutside:p,onOpenAutoFocus:e=>e.preventDefault(),onDragOver:e=>e.stopPropagation(),onDragLeave:e=>e.stopPropagation(),onDrop:e=>{e.stopPropagation(),e.dataTransfer.files.length>0&&e.preventDefault()},children:(0,X.jsx)(jw,{thread:e,armed:l,close:()=>n(`closed`)})})]})}var yw=736,bw=260;function xw({armed:e}){let t=e?.prompt?.trim(),n=e?Aw({stopHook:e.stopHook===!0,heartbeat:e.heartbeat===!0,postCompaction:e.postCompaction===!0,seconds:e.intervalSeconds??ww}):[];return(0,X.jsxs)(`div`,{"data-recurring-preview-body":!0,children:[(0,X.jsxs)(`div`,{className:`mb-1 flex items-baseline gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Goal`}),(0,X.jsx)(`span`,{className:`text-muted-70`,children:n.length>0?`sent ${n.join(`, `)}`:t?`no trigger is on`:`not set`})]}),(0,X.jsx)(`p`,{className:`line-clamp-4 whitespace-pre-wrap ${t?`text-fg/90`:`text-muted`}`,children:t||`Click to write what this thread is trying to achieve.`})]})}var Sw=1,Cw=1440,ww=600;function Tw(e,t){if(e===String(Math.round(t/60)))return t;let n=Math.round(Number(e));return Number.isFinite(n)&&n>0?Math.min(Cw,Math.max(Sw,n))*60:t}var Ew=null;function Dw(e){return{prompt:e.text.trim(),stopHook:e.stopHook,heartbeat:e.heartbeat,postCompaction:e.postCompaction,seconds:e.seconds}}function Ow(e,t){return(e.text.trim()||null)===(t.prompt||null)&&e.stopHook===t.stopHook&&e.heartbeat===t.heartbeat&&e.postCompaction===t.postCompaction&&e.seconds===t.seconds}function kw(e,t){return!e.archived&&!t}function Aw(e){return[e.stopHook?`at every rest`:null,e.heartbeat?`every ${Math.round(e.seconds/60)}m`:null,e.postCompaction?`after every compaction`:null].filter(e=>e!==null)}function jw({thread:e,armed:t,close:n,heading:r=!0}){let i=kw(e,t)?Yi:``,a=Ew?.slug===e.id?Ew.draft:null,[o,s]=(0,q.useState)(a?.text??t?.prompt??i),[c,l]=(0,q.useState)(a?.stopHook??t?.stopHook??!1),[u,d]=(0,q.useState)(a?.heartbeat??t?.heartbeat??!1),[f,p]=(0,q.useState)(a?.postCompaction??t?.postCompaction??!1),[m,h]=(0,q.useState)(a?.seconds??t?.intervalSeconds??ww),g=c||u||f,[_,v]=(0,q.useState)(String(Math.round((a?.seconds??t?.intervalSeconds??ww)/60))),y=(0,q.useRef)(null),b=(0,q.useRef)({prompt:t?.prompt??i,stopHook:t?.stopHook??!1,heartbeat:t?.heartbeat??!1,postCompaction:t?.postCompaction??!1,seconds:t?.intervalSeconds??ww}),x=e=>({text:o,stopHook:c,heartbeat:u,postCompaction:f,seconds:Tw(_,m),...e}),S=(0,q.useRef)(x());S.current=x(),(0,q.useEffect)(()=>()=>{let n=S.current;if(Ow(n,b.current)){Ew?.slug===e.id&&(Ew=null);return}if(n.text.trim()===``&&!t){Ew={slug:e.id,draft:n};return}w(n)},[]);let C=(0,q.useRef)(Promise.resolve(!0));function w(t){let n=C.current.catch(()=>!1).then(async()=>{let n=await T(t);return n?Ew?.slug===e.id&&(Ew=null):Ew={slug:e.id,draft:t},n});return C.current=n,n}async function T(t){let n=t.text.trim()||null;if(Ow(t,b.current))return!0;try{await U.setThreadRecurringPrompt({slug:e.id,sessionId:e.sessionId??``,prompt:n,stopHook:t.stopHook,heartbeat:t.heartbeat,postCompaction:t.postCompaction,...n===null?{}:{intervalSeconds:t.seconds}}),b.current={...Dw(t),prompt:n??``};let r=Aw(t);G(n===null?`Goal cleared`:r.length===0?`Goal saved — no trigger is on, so nothing is sent`:`Goal: sent ${r.join(`, `)}`)}catch(e){return G((e instanceof Error?e.message:`Could not save the recurring prompt`).slice(0,100)),!1}return!0}function E(){if(Ow(x(),b.current)||o.trim()===``&&!t){n();return}w(x()).then(e=>{e&&n()})}function D(){let e=Tw(_,m);v(String(Math.round(e/60))),h(e)}let O=[{at:t?.lastRestFiredAt,how:`at rest`},{at:t?.lastScheduleFiredAt,how:`on schedule`},{at:t?.lastCompactFiredAt,how:`after a compaction`}].filter(e=>e.at!==void 0),k=O.reduce((e,t)=>e&&Date.parse(e.at)>=Date.parse(t.at)?e:t,void 0),A=k===void 0?null:O.length>1?`Last sent ${Kn(k.at)}`:`Last sent ${k.how} ${Kn(k.at)}`;return(0,X.jsxs)(`section`,{"data-recurring-panel":!0,children:[r?(0,X.jsxs)(`div`,{className:`mb-2 flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Goal`}),A&&(0,X.jsx)(`span`,{className:`ml-auto truncate text-muted-55`,children:A})]}):A?(0,X.jsx)(`div`,{className:`mb-2 truncate text-muted-55`,children:A}):null,(0,X.jsx)(`textarea`,{ref:y,"data-recurring-text":!0,"data-1p-ignore":!0,value:o,maxLength:Pr,onChange:e=>s(e.target.value),onKeyDown:e=>{Hr({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),E())},placeholder:`What is this thread trying to achieve?`,className:`field-sizing-content max-h-[28vh] min-h-[4rem] w-full resize-none overflow-y-auto rounded-md border border-border bg-bg px-2 py-1.5 text-[12px] leading-snug outline-none placeholder:text-muted-50 focus:border-border-strong ${g?`text-fg`:`text-muted`}`}),(0,X.jsxs)(`div`,{className:`mt-3 grid grid-cols-[auto_auto_1fr] items-baseline gap-x-2.5 gap-y-2`,children:[(0,X.jsx)(gw,{testId:`stop-hook`,label:`Stop hook`,checked:c,onChange:e=>{l(e),e&&!o.trim()&&requestAnimationFrame(()=>y.current?.focus())}}),(0,X.jsx)(`span`,{className:`font-medium ${c?`text-fg`:`text-muted`}`,children:`Stop hook`}),(0,X.jsx)(`span`,{className:`text-muted`,children:`every rest — unless it signed off or parked on a wait`}),(0,X.jsx)(gw,{testId:`heartbeat`,label:`Heartbeat`,checked:u,onChange:e=>{d(e),e&&!o.trim()&&requestAnimationFrame(()=>y.current?.focus())}}),(0,X.jsx)(`span`,{className:`font-medium ${u?`text-fg`:`text-muted`}`,children:`Heartbeat`}),u?(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted`,children:[`every`,(0,X.jsx)(`input`,{type:`number`,"data-recurring-minutes":!0,inputMode:`numeric`,min:Sw,max:Cw,value:_,onChange:e=>v(e.target.value),onBlur:D,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),D())},"aria-label":`Heartbeat interval in minutes`,className:`w-[4.5ch] rounded-md border border-border bg-bg px-1 py-[3px] text-center text-[11px] leading-none tabular-nums text-fg outline-none focus:border-border-strong disabled:opacity-45 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`}),`min, even mid-turn`]}):(0,X.jsx)(`span`,{className:`text-muted`,children:`on a clock, even mid-turn`}),(0,X.jsx)(gw,{testId:`post-compaction`,label:`Compaction`,checked:f,onChange:e=>{p(e),e&&!o.trim()&&requestAnimationFrame(()=>y.current?.focus())}}),(0,X.jsx)(`span`,{className:`font-medium ${f?`text-fg`:`text-muted`}`,children:`Compaction`}),(0,X.jsx)(`span`,{className:`text-muted`,children:`when the context is summarized away — link the doc to re-read`})]})]})}var Mw=`frizz:send-mode`;function Nw(){try{return localStorage.getItem(Mw)===`queue`?`queue`:`steer`}catch{return`steer`}}var Pw=Et({mode:typeof window>`u`?`steer`:Nw()});typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`storage`,e=>{(e.key===Mw||e.key===null)&&(Pw.mode=Nw())});function Fw(e){Pw.mode!==e&&(Pw.mode=e);try{e===`steer`?localStorage.removeItem(Mw):localStorage.setItem(Mw,e)}catch{}}function Iw(){return _t(Pw).mode}function Lw(e){return e.staged>0?e.staged===1?`Add a note to send with your answer…`:`Add a note to send with your ${e.staged} answers…`:e.openQuestions?`Or skip the questions and reply…`:e.running&&e.steerable===!1?`Queue a message for when this turn ends…`:e.running&&e.mode===`queue`?`Queue a message for when the agent rests…`:`Reply to the agent…`}var Rw=new Map;function zw(e){let t=Rw.get(e);if(t)return t;let n=U.threadSkills({slug:e}).then(e=>e.skills,()=>(Rw.delete(e),[]));return Rw.set(e,n),n}function Bw({surface:e,className:t,above:n,phoneBarOverride:r,phoneChrome:i,readAndAnswerHost:a}){let o=(0,q.useContext)(xS),s=Cr(),c=(i??s)&&e===`chatComposer`;return(0,X.jsxs)(`div`,{"data-thread-composer-box":e,"data-remote-composer":!0,...e===`chatComposer`?{"data-thread-action-bar":``}:{},className:c?`flex flex-col gap-2 px-3 py-2.5`:t,children:[n,c&&r&&(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:r({editReply:()=>{}})}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 ${c?``:`px-3 py-2`}`,children:[(0,X.jsx)(kn,{host:a}),!c&&(o?.staged??0)>0&&(0,X.jsx)(`button`,{type:`button`,"data-remote-send-answers":!0,disabled:o.sending,onClick:o.submit,className:`shrink-0 rounded-md bg-fg px-3 py-1.5 text-[13px] font-medium text-bg outline-none disabled:opacity-40`,children:o.sending?`Sending…`:`Send answers`})]})]})}function Vw(e){let t=ue();return t?(0,X.jsx)(Bw,{...e,readAndAnswerHost:t}):(0,X.jsx)(Hw,{...e})}function Hw({slug:e,surface:t,className:n,id:r,above:i,submitOverride:a,phoneBarOverride:o,phoneChrome:s}){let{fileDrop:c}=nC(),l=_t(W),u=Se(e),d=(0,q.useContext)(xS),f=(0,q.useContext)(_v),p=(0,q.useContext)(Rb),m=ov(u),h=(d?.staged??0)+(f?.fencedCount??0)+ +!!m.staged,_=u?.runtime===`running`,v=(0,q.useContext)(zb)?.held??0,y=_||v>0,{steer:b}=g(u?.backend),x=Iw(),S=b?x:`queue`,C=u?.foreign?`Send a message to take over this session…`:Lw({staged:h,openQuestions:!!u?.pendingQuestion||(u?pt(u):!1),running:y,mode:S,steerable:b}),w=yn(),T=jr.followUp(w,e,u?.sessionId),[E,D,O]=Yr(T),k=sw(e),A=Fr(e),[j,N]=(0,q.useState)(null),P=(0,q.useMemo)(()=>()=>zw(e),[e]),[F,I]=(0,q.useState)(null),L=l.composerContext[e],R=(0,q.useMemo)(()=>L?.map(e=>e.token)??[],[L]);(0,q.useEffect)(()=>{let t=W.composerContext[e];if(!t?.length)return;let{prose:n}=zi(E),r=t.filter(e=>ii(n,e.token));r.length!==t.length&&(W.composerContext[e]=r)},[e,E,L]);let z=Ao(u,a!==void 0),B=Cr(),ee=(s??B)&&t===`chatComposer`,te=u?.runtime===`running`||u?.runtime===`spawning`,ne=u?.lastFence?.kind===`awaiting`&&Sa(u.lastFence.hints).length>0,re=u?sv(u).archive&&!te&&!ne:!1,ie=u&&u.kind===`session`&&u.foreign!==!0?(0,X.jsx)(vw,{thread:u}):void 0;function ae(t=!1){let n=E.trim(),r=ee?null:d?.take()??null,i=ee?null:f?.takeFenced()??null,o=ee?null:m.take();if(!n&&!r&&!i&&!o)return;let s=un(n);if(s){if(O(),u?.backend===`acp`){G(`An ACP agent signs in through its own CLI — Frizz holds no account for it`);return}if(u?.backend===`opencode`){G("OpenCode signs in through its own CLI: run `opencode auth login`");return}let e=u?.backend===`codex`?`codex`:`claude`;s===`login`?N(e):I(e);return}let c=M(e),l=n?ro(n,c,w):``,h=o?o.compose(l):l,g=i?ss(i.wire,h):h,_=r?ss(Ea(r.display),g):g,v={onOptimistic:()=>{O(),r?.onOptimistic(),i?.onOptimistic(),o?.onOptimistic()},onSuccess:()=>r?.onSuccess(),...r?{answers:r.answers,displayText:_}:{},...o?{todos:o.todos}:{},...S===`queue`&&!t&&(y||u?.deliveryInFlight===!0)?{hold:!0}:{},...b?{}:{failureToast:e=>`Send failed — ${e.slice(0,160)}`},supersedes:GC(T,g),onRollback:t=>{Fs(T,E),Is(e,c),UC(T,{...t,text:E}),r?.onRollback(t.kept),i?.onRollback(),o?.onRollback()}};a?a(g,v):(A.submit(g,{...v,interrupt:t}),p?.sent?.())}let oe=(0,q.useRef)(ae);oe.current=ae;let se=ee?void 0:f?.composer;return(0,q.useEffect)(()=>se?(se.set(()=>oe.current()),()=>se.set(null)):void 0,[se]),ee?(0,X.jsxs)(`div`,{"data-thread-composer-box":t,"data-thread-action-bar":``,"data-phone-thread-bar":``,children:[(0,X.jsx)(mr,{contextTokens:R,id:r,surface:t,value:E,onChange:D,onSubmit:()=>ae(),onInterruptSubmit:z?()=>ae(!0):void 0,slashSuggest:P,placeholder:u?.foreign?C:te?b?`Steer…`:`Queue…`:`Reply…`,busy:k.busy,fileDrop:c,phone:{layout:`bar`,tools:k.phoneTools,idlePrimary:re&&u?e=>(0,X.jsx)(mw,{thread:u,compact:e}):void 0,override:o,onLongPressSend:z?()=>ae(!0):void 0}}),k.status,j&&(0,X.jsx)(Dn,{backend:j,onClose:()=>N(null),onAuthed:()=>N(null)}),F&&(0,X.jsx)(_s,{backend:F,onClose:()=>I(null)})]}):(0,X.jsxs)(`div`,{"data-thread-composer-box":t,...t===`chatComposer`?{"data-thread-action-bar":``}:{},className:n,children:[i,(0,X.jsx)(mr,{contextTokens:R,id:r,surface:t,value:E,onChange:D,onSubmit:()=>ae(),onInterruptSubmit:z?()=>ae(!0):void 0,slashSuggest:P,placeholder:C,busy:k.busy,footer:k.footer,railLead:ie,fileDrop:c,send:u?.foreign?void 0:{mode:S,onMode:Fw,running:y,staged:h,steerable:b}}),k.status,j&&(0,X.jsx)(Dn,{backend:j,onClose:()=>N(null),onAuthed:()=>N(null)}),F&&(0,X.jsx)(_s,{backend:F,onClose:()=>I(null)})]})}function Uw({slug:e,above:t,phoneBarOverride:n,phoneChrome:r}){return Se(e)?(0,X.jsx)(Vw,{slug:e,surface:`chatComposer`,id:`followup-input`,className:`shrink-0 px-3 py-3`,above:t,phoneBarOverride:n,phoneChrome:r}):null}var Ww=24,Gw=2;function Kw(e,t,n,r,i,a){return(n-e)*(a-t)-(r-t)*(i-e)}function qw(e,t){return e.y>=t.bottom?[t.left,t.bottom,t.right,t.bottom]:e.y<=t.top?[t.left,t.top,t.right,t.top]:e.x<=t.left?[t.left,t.top,t.left,t.bottom]:e.x>=t.right?[t.right,t.top,t.right,t.bottom]:null}function Jw(e,t,n){if(Math.hypot(t.x-e.x,t.y-e.y)<Gw)return!1;if(t.x>=n.left&&t.x<=n.right&&t.y>=n.top&&t.y<=n.bottom)return!0;let r=qw(e,n);if(!r)return!1;let[i,a,o,s]=r,c=Kw(e.x,e.y,i,a,t.x,t.y),l=Kw(i,a,o,s,t.x,t.y),u=Kw(o,s,e.x,e.y,t.x,t.y);return!((c<0||l<0||u<0)&&(c>0||l>0||u>0))}function Yw(e,t){let n=e.filter(e=>t.at-e.at<=150),r=e[e.length-1];return n.length>0?[...n,t]:r?[r,t]:[t]}function Xw(e,t,n){let r=e[e.length-1];if(!r||e.length<2||t-r.at>250)return!1;let i=e[0];for(let t=e.length-2;t>=0;t--){let n=e[t];if(Math.hypot(r.x-n.x,r.y-n.y)>=Ww){i=n;break}}return Jw(i,r,n)}function Zw(e,t=[],n=[]){let{todos:r,agents:i,children:a,shells:o,prs:s,issues:c,commands:l,timers:u,files:d,links:f}=dv(e,t,n),p=r.filter(e=>!e.done).length;return[{key:`todo`,n:e.runtime===`turn-idle`&&e.lastFence?.kind===`awaiting`&&Sa(e.lastFence.hints).length>0?0:p||r.length,one:p?`to-do`:`to-do done`,many:p?`to-dos`:`to-dos done`,states:[]},{key:`agent`,n:i.length,one:`agent`,many:`agents`,states:i.map(e=>e.state)},{key:`child`,n:a.length,one:`child thread`,many:`child threads`,states:a.map(Cs)},{key:`shell`,n:o.length,one:`shell`,many:`shells`,states:o.map(e=>e.state)},{key:`pr`,n:s.length,one:`PR`,many:`PRs`,states:[`running`]},{key:`issue`,n:c.length,one:`issue`,many:`issues`,states:[`running`]},{key:`command`,n:l.length,one:`monitor`,many:`monitors`,states:[`running`]},{key:`timer`,n:u.length,one:`timer`,many:`timers`,states:[`running`]},{key:`file`,n:d.length,one:`file`,many:`files`,states:[]},{key:`link`,n:f.length,one:`link`,many:`links`,states:[]}].filter(e=>e.n>0)}function Qw({slug:e,subAgents:t,className:n=`px-1 pt-1.5`,density:r=`card`}){let i=Oo(t,`card`);return i.length===0?null:(0,X.jsx)(`div`,{"data-queue-subagents":!0,className:`flex min-w-0 flex-col ${r===`panel`?``:`gap-0.5`} ${n}`,children:i.map((t,n)=>(0,X.jsx)(Mt,{kind:`AGENT`,label:t.label,state:t.state,density:r,depth:t.depth,startedAt:t.startedAt,parentSlug:e,onOpen:t.id?()=>Mr(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:fe(e,t)},t.id??`${t.startedAt}-${n}`))})}var $w=300,eT=50,tT=480,nT=12,rT=6,iT={todo:`What this thread needs a person to do`,agent:`Sub-agents running for this thread`,child:`Child threads this thread started`,shell:`Background shells running for this thread`,pr:`Pull requests this thread is watching`,issue:`Issues this thread is watching`,command:`Monitors this thread is waiting on`,timer:`Timers this thread has set`,file:`Files saved for this thread`,link:`Links saved for this thread`};function aT({thread:e,transcriptShells:t=[]}){let n=iC(e),r=lt(n.id),[i,a]=(0,q.useState)(null),o=(0,q.useRef)(void 0),s=(0,q.useRef)(void 0);(0,q.useEffect)(()=>()=>{clearTimeout(o.current),clearTimeout(s.current)},[]);let c=Zw(n,t,r),l=(0,q.useRef)(null),u=(0,q.useRef)([]),d=i!==null,f=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!d){f.current=null;return}let e=e=>{u.current=Yw(u.current,{x:e.clientX,y:e.clientY,at:performance.now()})};return document.addEventListener(`pointermove`,e,{capture:!0,passive:!0}),()=>{document.removeEventListener(`pointermove`,e,{capture:!0}),u.current=[]}},[d]);let p=(0,q.useRef)(null),m=(0,q.useCallback)(e=>{e&&(p.current=e)},[]),h=()=>{let e=p.current?.isConnected?p.current.getBoundingClientRect():void 0;return!!e&&Xw(u.current,performance.now(),e)},g=i!==null&&!c.some(e=>e.key===i);if((0,q.useEffect)(()=>{g&&(clearTimeout(o.current),clearTimeout(s.current),a(null))},[g]),c.length===0)return null;let _=e=>{clearTimeout(o.current),clearTimeout(s.current),a(e)},v=e=>{if(clearTimeout(o.current),clearTimeout(s.current),i===null||i===e||!h()){a(e);return}s.current=setTimeout(()=>v(e),eT)},y=()=>{clearTimeout(o.current),clearTimeout(s.current)},b=()=>{clearTimeout(o.current),clearTimeout(s.current);let e=()=>{h()?o.current=setTimeout(e,eT):a(null)};o.current=setTimeout(e,$w)};return(0,X.jsxs)(`div`,{"data-queue-ops-summary":!0,ref:l,className:`-mt-3 flex h-8 min-w-0 items-baseline justify-end text-[11.5px]`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-[calc(16px_+_0.5cap)] w-0 shrink-0`}),c.map(e=>(0,X.jsx)(oT,{group:e,line:l,open:i===e.key,onOpen:()=>_(e.key),onHover:t=>{u.current=Yw(u.current,{x:t.clientX,y:t.clientY,at:performance.now()}),v(e.key)},onHoverPanel:y,onCloseSoon:b,registerPanel:m,caretAt:f,onOpenChange:t=>t?_(e.key):a(t=>t===e.key?null:t),children:e.key===`todo`?(0,X.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,X.jsx)(Av,{thread:n})}):e.key===`agent`?(0,X.jsx)(Qw,{slug:n.id,subAgents:n.subAgents??[],className:``,density:`panel`}):e.key===`child`?(0,X.jsx)(`div`,{"data-queue-child-threads":!0,className:`flex min-w-0 flex-col`,children:(0,X.jsx)(Ct,{parent:n.id,childThreads:r,density:`panel`})}):e.key===`command`||e.key===`timer`?(0,X.jsx)(uT,{thread:n,kind:e.key}):(0,X.jsx)(Sk,{slug:n.id,includeAgents:!1,only:e.key,transcriptShells:t,className:``,density:`panel`})},e.key))]})}function oT({group:e,line:t,open:n,onOpen:r,onHover:i,onHoverPanel:a,onCloseSoon:o,registerPanel:s,caretAt:c,onOpenChange:l,children:u}){let d=(0,q.useRef)(null),f=(0,q.useRef)(null),[p]=(0,q.useState)(()=>({current:{getBoundingClientRect:()=>t.current?.getBoundingClientRect()??new DOMRect,get contextElement(){return t.current??void 0}}})),m=e.n===1?e.one:e.many,h=()=>{r(),requestAnimationFrame(()=>f.current?.querySelector(`button, a[href], [tabindex]:not([tabindex='-1'])`)?.focus())};return(0,X.jsxs)(S,{open:n,onOpenChange:l,children:[(0,X.jsx)(Wn,{virtualRef:p}),(0,X.jsxs)(`button`,{type:`button`,"data-ops-count":e.key,"aria-label":`${e.n} ${m} — show ${e.n===1?`it`:`them`}`,"aria-haspopup":`dialog`,"aria-expanded":n,onMouseEnter:i,onMouseLeave:o,onFocus:r,ref:d,onClick:e=>{e.stopPropagation(),e.detail===0?h():r()},onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),h())},onMouseDown:e=>e.preventDefault(),className:`flex shrink-0 items-baseline gap-1.5 whitespace-nowrap rounded-md px-1.5 py-0.5 outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${n?`bg-panel-2 text-fg/85`:`text-muted-70 hover:bg-panel-2 hover:text-fg/85`}`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`relative block h-[1em] w-[1em] shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`,children:(0,X.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(cT,{kind:e.key,states:e.states})})}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`tabular-nums text-fg/85`,children:e.n}),` `,m]})]}),(0,X.jsxs)(je,{side:`top`,align:`end`,sideOffset:0,"data-queue-ops-panel":e.key,"aria-label":iT[e.key],onMouseEnter:a,onMouseLeave:o,onOpenAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{t.current?.contains(e.target)&&e.preventDefault()},onEscapeKeyDown:e=>{e.stopPropagation(),f.current?.contains(document.activeElement)&&d.current?.focus()},ref:e=>{f.current=e,s(e)},onClick:e=>e.stopPropagation(),className:`group/panel relative flex max-w-[calc(100vw-1.5rem)] flex-col p-1 before:absolute before:inset-x-0 before:top-full before:h-1.5 before:content-[''] data-[side=bottom]:before:top-auto data-[side=bottom]:before:bottom-full`,style:n?{width:xi(t.current?.getBoundingClientRect().width??tT,tT)}:void 0,children:[(0,X.jsx)(`div`,{className:`max-h-[min(20rem,50vh)] overflow-y-auto scrollbar-none`,children:u}),(0,X.jsx)(sT,{count:d,line:t,caretAt:c})]})]})}function sT({count:e,line:t,caretAt:n}){let r=()=>{let n=t.current?.getBoundingClientRect(),r=e.current?.getBoundingClientRect();return n&&r?n.right-(r.left+r.width/2)-nT/2-1:0},[i,a]=(0,q.useState)(()=>n.current??r());return(0,q.useEffect)(()=>{let e=r();n.current=e;let t=requestAnimationFrame(()=>a(e));return()=>cancelAnimationFrame(t)}),(0,X.jsxs)(`svg`,{"aria-hidden":!0,"data-queue-ops-caret":!0,width:nT,height:rT,viewBox:`0 0 ${nT} ${rT}`,style:{right:i},className:`pointer-events-none absolute top-full transition-[right] duration-100 ease-out motion-reduce:transition-none group-data-[side=bottom]/panel:top-auto group-data-[side=bottom]/panel:bottom-full group-data-[side=bottom]/panel:rotate-180`,children:[(0,X.jsx)(`path`,{d:`M1 0 L6 5 L11 0 Z`,className:`fill-elevated`}),(0,X.jsx)(`path`,{d:`M.5 .75 L5.5 5.1 Q6 5.5 6.5 5.1 L11.5 .75`,fill:`none`,strokeLinejoin:`round`,className:`stroke-border`})]})}function cT({kind:e,states:t}){switch(e){case`todo`:return(0,X.jsx)(hc,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`});case`agent`:case`child`:return(0,X.jsx)(lT,{hue:`agent`,states:t});case`shell`:return(0,X.jsx)(lT,{hue:`shell`,states:t});case`pr`:case`issue`:return(0,X.jsx)(lT,{hue:`github`,states:t});case`command`:case`timer`:return(0,X.jsx)(lT,{hue:`github`,states:t});case`file`:return(0,X.jsx)(ke,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`});case`link`:return(0,X.jsx)(sc,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`})}}function lT({hue:e,states:t}){return t.some(ni)?(0,X.jsx)(es,{hue:e}):(0,X.jsx)(`span`,{className:t.includes(`rested`)?Jn:zn})}function uT({thread:e,kind:t}){let n=di(),{commands:r,timers:i}=dv(e);return(0,X.jsx)(`div`,{className:`flex flex-col`,children:t===`timer`?i.map(e=>(0,X.jsx)(Mt,{kind:`TIMER`,label:e.timer?.prompt?.split(`
|
|
135
|
-
`)[0]||e.target,state:`running`,density:`panel`,counter:Ty(e,n),title:wy(e)},e.id)):r.map(t=>(0,X.jsx)(Mt,{kind:`COMMAND`,label:Dy(t),state:`running`,density:`panel`,startedAt:t.createdAt,counter:Ay(t),title:ky(t,n),onOpen:t.command?.monitor?()=>Ri(e.id,t.target,{label:Dy(t)}):void 0},t.id))})}function dT(e,t){let n=e.trim();if(!(!n||n===t.trim()))return n}function fT(e,t){let n=e.trim();return!n||n===t||n===`Untitled thread`||n===`Spinning up a thread…`?``:n}function pT(e){return e.kind!==`session`||e.foreign||e.backend===`codex`||e.backend===`acp`||e.backend===`opencode`||e.claudeRuntime!==void 0&&e.claudeRuntime!==`broker`?{show:!1,enabled:!1,label:``}:e.runtime===`exited`||e.runtime===`none`?{show:!0,enabled:!1,label:`Resume this Claude thread to rename it with Claude`}:e.runtime===`spawning`?{show:!0,enabled:!1,label:`Rename with Claude once this thread has started`}:{show:!0,enabled:!0,label:`Rename with Claude — a fresh title from the opening request`}}function mT(e,t){return new Promise(n=>{Vi(e,t,`Your worker process was restarted so it picks up frizz's current tooling (hooks and worker contract). Re-read whatever you left in your scratch directory, then continue exactly where you left off.`,{freshProcess:!0,onSuccess:()=>{G(`Restarting worker…`),n()},onRollback:()=>n(),failureToast:e=>`Restart failed: ${e.slice(0,80)}`})||n()})}function hT(){return gr(te().data??null)}function gT(e,t){return!t||e.kind!==`session`||e.foreign||e.backend===`codex`||e.backend===`acp`||e.backend===`opencode`?!1:e.runtime!==`exited`}function _T({thread:e,onSnoozed:t}){let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(``),g=(0,q.useId)(),_=(0,q.useId)(),v=(0,q.useId)(),y=ve(e),b=e.snoozePrompt?.trim(),x=(0,q.useMemo)(()=>A(new Date(Date.now()+6e4)),[c]),S=(0,q.useMemo)(()=>Ps.map(e=>{let t=vn(En(e.value));return e.value===`tomorrow`?{value:e.value,label:`Tomorrow`,wake:t.replace(/^Tomorrow at /,``)}:{value:e.value,label:e.label,wake:t}}),[n]),C=(0,q.useMemo)(()=>Jr(e),[n,e.runtime,e.wakesOnItsOwn]),w=!y&&Ts(e),T=!!y||w,E=y?b?`Bumps ${vn(y)}`:`Snoozed until ${vn(y)}`:w?`Snoozed until activity`:null,D=E?b?`${E}\n${b}`:E:`Snooze`;async function O(){s(!0);try{await U.snoozeAwaitingBackground({slug:e.id,sessionId:e.sessionId??``}),G(`Snoozed until activity`),t?.()}catch(e){G((e instanceof Error?e.message:`Snooze failed`).slice(0,100))}finally{s(!1)}}async function k(n,r=null){s(!0);try{await U.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:n,prompt:n?r:null}),n?(G(`${r?`Bump scheduled`:`Snoozed`} · ${vn(n)}`),t?.()):G(`Snooze cleared`),l(!1),h(``)}catch(e){let t=e instanceof Error?e.message:`Snooze failed`;G(t.slice(0,100)),h(t)}finally{s(!1)}}function j(){d(A(new Date(y??En(`1d`)))),p(e.snoozePrompt??``),h(``),l(!0)}function M(){let e=gs(u);if(!e.ok){h(e.message);return}let t=f.trim();if(t.length>4e3){h(`Prompt is too long (${t.length}/${ks})`);return}k(e.until,t||null)}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(As,{open:n,onOpenChange:e=>{r(e),e||a(!0)},children:[(0,X.jsx)(ua,{label:D,multiline:!!b,disabled:n||i,children:(0,X.jsx)(jn,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,disabled:o,"data-snooze-menu":!0,"data-snoozed":T?`true`:`false`,"aria-label":E??`Snooze`,"aria-description":y&&b?b:void 0,onMouseDown:e=>e.preventDefault(),onBlur:()=>a(!1),onPointerLeave:()=>a(!1),className:`${T?Vt.replace(/(^| )text-muted( |$)/,`$1text-attention-90$2`):Vt} ${n?`bg-panel-2`:``}`,children:o?(0,X.jsx)(Ut,{size:14,strokeWidth:2,className:`animate-spin`}):(0,X.jsx)(bi,{size:14,strokeWidth:2})})})}),(0,X.jsxs)(Sn,{align:`end`,children:[(0,X.jsx)(`div`,{className:`px-2.5 pb-1 pt-1.5 text-[11px] text-muted-60`,children:E??`Snooze`}),T&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(F,{onSelect:()=>void k(null),icon:(0,X.jsx)(Ys,{size:12}),children:`Wake now`}),(0,X.jsx)(xs,{})]}),S.map(e=>(0,X.jsx)(F,{onSelect:()=>void k(En(e.value)),icon:(0,X.jsx)(bi,{size:12}),children:(0,X.jsxs)(`span`,{"data-snooze-preset":e.value,className:`flex min-w-0 flex-1 items-center justify-between gap-6`,children:[(0,X.jsx)(`span`,{children:e.label}),(0,X.jsx)(`span`,{className:`text-[10.5px] text-muted-55`,children:e.wake})]})},e.value)),(0,X.jsx)(F,{onSelect:()=>void O(),disabled:!C.enabled,children:(0,X.jsx)(ua,{label:C.enabled?``:C.reason,side:`left`,disabled:C.enabled,children:(0,X.jsxs)(`span`,{"data-snooze-activity":!0,className:`-mx-2.5 -my-1.5 flex min-w-0 flex-1 items-center gap-2 px-2.5 py-1.5`,children:[(0,X.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:(0,X.jsx)(bi,{size:12})}),(0,X.jsx)(`span`,{children:`Until activity`})]})})}),(0,X.jsx)(xs,{}),(0,X.jsx)(F,{onSelect:j,children:`Custom time & prompt…`})]})]}),(0,X.jsx)(ht,{open:c,onOpenChange:e=>{o||l(e)},title:`Snooze thread`,className:`w-[360px] max-w-[92vw]`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>l(!1),className:`button-outline rounded-md px-3 py-1.5 text-[12px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:opacity-45`,children:`Cancel`}),(0,X.jsxs)(`button`,{type:`submit`,form:v,disabled:o,className:`button-outline flex items-center gap-1.5 rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-opacity hover:opacity-90 disabled:opacity-45`,children:[o&&(0,X.jsx)(Ut,{size:12,className:`animate-spin`}),f.trim()?`Snooze & bump`:`Snooze`]})]}),children:(0,X.jsxs)(`form`,{id:v,className:`flex flex-col gap-2.5 p-4`,onSubmit:e=>{e.preventDefault(),M()},children:[(0,X.jsx)(`label`,{htmlFor:g,className:`text-[11px] font-medium text-muted`,children:`Wake at this local time`}),(0,X.jsx)(`input`,{id:g,type:`datetime-local`,required:!0,min:x,value:u,onChange:e=>{d(e.target.value),h(``)},className:`w-full rounded-md border border-border bg-bg px-2.5 py-2 text-[13px] text-fg outline-none focus:border-accent`}),(0,X.jsx)(`p`,{className:`text-[10.5px] text-muted-65`,children:`Stored as an exact instant; shown here in your browser’s local time zone.`}),(0,X.jsxs)(`label`,{htmlFor:_,className:`mt-1 text-[11px] font-medium text-muted`,children:[`Then send this prompt `,(0,X.jsx)(`span`,{className:`font-normal text-muted-55`,children:`(optional)`})]}),(0,X.jsx)(`textarea`,{id:_,"data-1p-ignore":!0,autoFocus:!0,rows:3,maxLength:ks,placeholder:`e.g. Check whether CI went green and land it if so.`,value:f,onChange:e=>{p(e.target.value),h(``)},onKeyDown:e=>{Hr({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),M())},className:`w-full resize-y rounded-md border border-border bg-bg px-2.5 py-2 text-[13px] leading-5 text-fg outline-none placeholder:text-muted-40 focus:border-accent`}),(0,X.jsx)(`p`,{className:`min-h-4 text-[10.5px] text-muted-65`,children:f.trim()?`frizz will resume this thread with the prompt at the wake time.`:`Leave empty to just bring the card back to your queue.`}),m&&(0,X.jsx)(`p`,{role:`alert`,className:`text-[11px] text-danger`,children:m})]})})]})}function vT({thread:e,onArchived:t,onDismissCancel:n,onSnoozed:r}){let i=sv(e);return i.lifecycle?(0,X.jsxs)(`span`,{"data-thread-lifecycle":!0,role:`group`,"aria-label":`Thread lifecycle actions`,className:`flex shrink-0 items-center gap-0.5`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,"data-lifecycle-rule":!0,className:`mx-2.5 h-4 w-px shrink-0 bg-border`}),i.done?(0,X.jsx)(yT,{}):(0,X.jsxs)(X.Fragment,{children:[i.snooze&&(0,X.jsx)(_T,{thread:e,onSnoozed:r}),(0,X.jsx)(xT,{thread:e,onArchived:t,onDismissCancel:n,iconOnly:!0})]})]}):null}function yT(){return(0,X.jsx)(bT,{"data-thread-done":``,check:!0,tooltip:`Marked done — send a message to reopen it`,children:`Done`})}function bT({check:e=!1,tooltip:t,children:n,...r}){return(0,X.jsx)(ua,{label:t,children:(0,X.jsxs)(`span`,{...r,"aria-label":t,className:`flex h-7 items-center gap-1 rounded-md px-2 text-[12px] font-medium text-muted`,children:[e&&(0,X.jsx)(Qt,{size:12}),n]})})}function xT({thread:e,onArchived:t,onDismissCancel:n,className:r=`rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] text-fg/80 hover:bg-panel-2 hover:text-fg`,iconClassName:i=``,iconSize:a=12,iconOnly:o=!1}){let[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(void 0),p=(r,i)=>{c(!0),i&&t?.(),(r||cv(e))&&eo(e.id),U.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:r}).then(r=>{if(r.needsConfirmation){zr(e.id),i&&n?.(),f(r.hold),u(!0),c(!1);return}u(!1),v(`Done`,e),i||t?.()}).catch(t=>{zr(e.id),i&&n?.(),G(`Couldn’t finish: ${t.message.slice(0,80)}`),c(!1)})},m=!!t&&!!n&&cv(e);return(0,X.jsxs)(X.Fragment,{children:[o?(0,X.jsx)(ua,{label:`Mark as done`,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>p(!1,m),disabled:s,"aria-label":`Mark as done`,onMouseDown:e=>e.preventDefault(),className:Vt,children:(0,X.jsx)(Qt,{size:15,strokeWidth:2})})}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>p(!1,m),disabled:s,"aria-label":`Mark as done`,title:`Mark as done`,onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-1 font-medium outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:opacity-45 ${r}`,children:[(0,X.jsx)(Qt,{size:a,className:i}),`Mark as done`]}),(0,X.jsx)(ht,{open:l,onOpenChange:e=>{s||u(e)},title:d?.cutOff?`Mark an unfinished thread done?`:`End this session?`,className:`w-[390px] max-w-[92vw]`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>u(!1),className:`button-outline rounded-md px-3 py-1.5 text-[12px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:opacity-45`,children:`Cancel`}),(0,X.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>p(!0,!1),className:`button-outline flex items-center gap-1.5 rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-opacity hover:opacity-90 disabled:opacity-45`,children:[s&&(0,X.jsx)(Ut,{size:12,className:`animate-spin`}),d?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,X.jsx)(ST,{hold:d})})]})}function ST({hold:e}){let t=lv(e);return(0,X.jsxs)(`div`,{"data-completion-hold":!0,className:`flex flex-col gap-2 p-4 text-[12px] leading-relaxed text-muted`,children:[(0,X.jsx)(`p`,{children:t.lead}),t.groups.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-fg/70`,children:e.heading}),(0,X.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[e.items.map((e,t)=>(0,X.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:Xt,children:`⤷`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate text-fg/80`,children:e.label}),e.stale&&(0,X.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-60`,children:`no recent output`})]},`${e.label}-${t}`)),e.overflow>0&&(0,X.jsxs)(`li`,{className:`pl-[15px] text-muted-60`,children:[`+`,e.overflow,` more`]})]})]},e.kind)),(0,X.jsx)(`p`,{children:t.trailer})]})}function CT({slug:e,onClose:t,onArchived:n,initialView:r=`actions`}){let i=_t(W),a=vs(i.board,e),[o,s]=(0,q.useState)(r),c=no(t);if((0,q.useEffect)(()=>{i.board&&!a&&c()},[i.board,a,c]),!a)return null;let l=jt(a);return(0,X.jsx)(yC,{title:`Thread actions: ${l}`,onRequestClose:()=>c(),dataAttr:`data-thread-actions-sheet`,children:o===`actions`?(0,X.jsx)(wT,{thread:a,title:l,setView:s,dismiss:c,onArchived:n}):o===`snooze`?(0,X.jsx)(ET,{thread:a,back:()=>s(`actions`),custom:()=>s(`snooze-custom`),dismiss:c}):o===`snooze-custom`?(0,X.jsx)(DT,{thread:a,back:()=>s(`snooze`),dismiss:c}):o===`goal`?(0,X.jsx)(OT,{thread:a,back:()=>s(`actions`)}):o===`todos`?(0,X.jsx)(kT,{thread:a,back:()=>s(`actions`)}):o===`files`?(0,X.jsx)(AT,{thread:a,back:r===`files`?void 0:()=>s(`actions`),dismiss:c}):(0,X.jsx)(NT,{thread:a,back:()=>s(`actions`),dismiss:c})})}function wT({thread:e,title:t,setView:n,dismiss:r,onArchived:i}){let a=ct(),s=hT(),c=_t(cs).snoozePreset,l=sv(e),u=e.kind===`session`&&e.foreign!==!0,f=ve(e),p=e.recurringPrompt?.stopHook===!0||e.recurringPrompt?.heartbeat===!0||e.recurringPrompt?.postCompaction===!0,m=e.links??[],h=e.humanTodos??[],g=e.runtime===`running`||e.runtime===`spawning`,_=u&&Je(e),v=gT(e,s),y=PT(e),b=[xa(e.context),y].filter(Boolean).join(` · `);return(0,X.jsxs)(`div`,{"data-thread-actions-list":!0,children:[(0,X.jsx)(LT,{children:t}),l.snooze&&(0,X.jsx)(IT,{data:`snooze`,icon:(0,X.jsx)(bi,{size:19}),label:`Snooze`,value:f?vn(f):se(c),chevron:!0,onClick:()=>n(`snooze`)}),u&&(0,X.jsx)(IT,{data:`goal`,icon:(0,X.jsx)(_w,{size:19,className:p?`text-attention-90`:void 0}),label:`Goal`,value:p?`on`:`off`,chevron:!0,onClick:()=>n(`goal`)}),h.length>0&&(0,X.jsx)(IT,{data:`todos`,icon:(0,X.jsx)(hc,{size:19}),label:`To-do`,value:String(h.filter(e=>!e.done).length),chevron:!0,onClick:()=>n(`todos`)}),m.length>0&&(0,X.jsx)(IT,{data:`files`,icon:(0,X.jsx)(ke,{size:19}),label:`Files and links`,value:String(m.length),chevron:!0,onClick:()=>n(`files`)}),g&&l.archive&&(0,X.jsx)(xT,{thread:e,iconSize:19,iconClassName:`shrink-0 text-muted`,onArchived:()=>r(i),className:`${FT} !gap-[14px] !font-normal`}),(0,X.jsx)(`div`,{className:`my-1 h-px bg-border`}),u&&(0,X.jsx)(IT,{data:`rename`,icon:(0,X.jsx)(Tt,{size:19}),label:`Rename`,onClick:()=>n(`rename`)}),(0,X.jsx)(IT,{data:`copy-link`,icon:(0,X.jsx)(Xn,{size:19}),label:`Copy link`,onClick:()=>{let t=new URL(o(e.id),location.origin).href;r(()=>{ce(t).then(()=>G(`Link copied`)).catch(e=>G(`Couldn’t copy: ${e.message.slice(0,80)}`))})}}),_&&(0,X.jsx)(IT,{data:`retry`,icon:(0,X.jsx)(d,{size:19}),label:`Retry`,onClick:()=>r(()=>void Xi(a,e.id))}),v&&(0,X.jsx)(IT,{data:`restart-worker`,icon:(0,X.jsx)(sa,{size:19}),label:`Restart worker`,onClick:()=>r(()=>void mT(a,e.id))}),b&&(0,X.jsx)(`div`,{"data-thread-actions-foot":!0,className:`px-[18px] pt-2.5 text-[12.5px] leading-[17px] text-muted`,children:b})]})}function TT(e,t){let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(``);async function o(n,i=null){r(!0),a(``);try{await U.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:n,prompt:n?i:null}),t(()=>G(n?`${i?`Bump scheduled`:`Snoozed`} · ${vn(n)}`:`Snooze cleared`))}catch(e){let t=e instanceof Error?e.message:`Snooze failed`;G(t.slice(0,100)),a(t)}finally{r(!1)}}return{busy:n,error:i,setError:a,apply:o}}function ET({thread:e,back:t,custom:n,dismiss:r}){let i=_t(cs).snoozePreset,a=ve(e),{busy:o,apply:s}=TT(e,r),c=e=>{cs.snoozePreset=e,s(En(e))};return(0,X.jsxs)(`div`,{"data-thread-actions-snooze":!0,children:[(0,X.jsx)(RT,{back:t,children:`Snooze`}),a&&(0,X.jsxs)(`p`,{className:`px-[18px] pb-2 text-[13px] text-muted`,children:[`Snoozed until `,vn(a).replace(/^(Today|Tomorrow)/,e=>e.toLowerCase())]}),Ps.map(e=>(0,X.jsx)(IT,{data:`snooze-${e.value}`,disabled:o,icon:(0,X.jsx)(bi,{size:19}),label:e.label,value:e.detail,trailing:e.value===i?(0,X.jsx)(Qt,{size:16,className:`text-fg/80`}):(0,X.jsx)(`span`,{className:`w-4`}),onClick:()=>c(e.value)},e.value)),(0,X.jsx)(`div`,{className:`my-1 h-px bg-border`}),(0,X.jsx)(IT,{data:`snooze-custom`,disabled:o,icon:(0,X.jsx)(Tt,{size:19}),label:`Custom time & prompt…`,chevron:!0,onClick:n}),a&&(0,X.jsx)(IT,{data:`snooze-wake`,disabled:o,icon:(0,X.jsx)(d,{size:19}),label:`Wake now`,onClick:()=>void s(null)})]})}function DT({thread:e,back:t,dismiss:n}){let r=_t(cs).snoozePreset,i=ve(e),{busy:a,error:o,setError:s,apply:c}=TT(e,n),[l,u]=(0,q.useState)(()=>A(new Date(i??En(r)))),[d,f]=(0,q.useState)(e.snoozePrompt??``),p=(0,q.useMemo)(()=>A(new Date(Date.now()+6e4)),[]),m=(0,q.useId)(),h=(0,q.useId)(),g=()=>{let e=gs(l);if(!e.ok)return s(e.message);let t=d.trim();if(t.length>4e3)return s(`Prompt is too long (${t.length}/${ks})`);c(e.until,t||null)};return(0,X.jsxs)(`form`,{"data-thread-actions-snooze-custom":!0,className:`flex flex-col`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,X.jsx)(RT,{back:t,children:`Custom snooze`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 px-[18px]`,children:[(0,X.jsx)(`label`,{htmlFor:m,className:`text-[13px] font-medium text-muted`,children:`Wake at this local time`}),(0,X.jsx)(`input`,{id:m,type:`datetime-local`,required:!0,min:p,value:l,onChange:e=>{u(e.target.value),s(``)},className:`h-11 w-full rounded-lg border border-border bg-bg px-3 text-[16px] text-fg outline-none focus:border-border-strong`}),(0,X.jsxs)(`label`,{htmlFor:h,className:`mt-2 text-[13px] font-medium text-muted`,children:[`Then send this prompt `,(0,X.jsx)(`span`,{className:`font-normal text-muted-70`,children:`(optional)`})]}),(0,X.jsx)(`textarea`,{id:h,"data-1p-ignore":!0,rows:3,maxLength:ks,placeholder:`e.g. Check whether CI went green and land it if so.`,value:d,onChange:e=>{f(e.target.value),s(``)},className:`w-full resize-none rounded-lg border border-border bg-bg px-3 py-2 text-[16px] leading-[22px] text-fg outline-none placeholder:text-muted-50 focus:border-border-strong`}),(0,X.jsx)(`p`,{className:`text-[12.5px] text-muted`,children:d.trim()?`Frizz will resume this thread with the prompt at the wake time.`:`Leave it empty to just bring the thread back to your queue.`}),o&&(0,X.jsx)(`p`,{role:`alert`,className:`text-[13px] text-danger`,children:o}),(0,X.jsxs)(`button`,{type:`submit`,disabled:a,className:`mt-1 flex h-[46px] items-center justify-center gap-2 rounded-xl bg-fg text-[15.5px] font-semibold text-bg outline-none disabled:opacity-45`,children:[a&&(0,X.jsx)(Ut,{size:16,className:`animate-spin`}),d.trim()?`Snooze and bump`:`Snooze`]})]})]})}function OT({thread:e,back:t}){return(0,X.jsxs)(`div`,{"data-thread-actions-goal":!0,children:[(0,X.jsx)(RT,{back:t,children:`Goal`}),(0,X.jsx)(`div`,{className:`px-[18px] text-[13.5px] leading-relaxed text-fg [&_input]:!text-[16px] [&_textarea]:!min-h-[6rem] [&_textarea]:!text-[16px] [&_textarea]:!leading-[22px]`,children:(0,X.jsx)(jw,{thread:e,armed:e.recurringPrompt,close:t,heading:!1})})]})}function kT({thread:e,back:t}){return(0,X.jsxs)(`div`,{"data-thread-actions-todos":!0,children:[(0,X.jsx)(RT,{back:t,count:(e.humanTodos??[]).filter(e=>!e.done).length,children:`To-do`}),(0,X.jsx)(`div`,{className:`px-[18px] pb-3 text-[14px] leading-[21px]`,children:(0,X.jsx)(Av,{thread:e,sends:!0})})]})}function AT({thread:e,back:t,dismiss:n}){let r=[...e.links??[]].reverse();return(0,X.jsxs)(`div`,{"data-thread-actions-files":!0,children:[t?(0,X.jsx)(RT,{back:t,count:r.length,children:`Files and links`}):(0,X.jsx)(LT,{count:r.length,children:`Files and links`}),r.length===0&&(0,X.jsx)(`p`,{className:`px-[18px] pb-2 text-[14px] text-muted`,children:`Nothing registered yet.`}),r.map(e=>(0,X.jsx)(jT,{link:e,dismiss:n},e.id))]})}function jT({link:e,dismiss:t}){let n=e.kind===`link`,r=n&&xt(e.target),i=_t(W).board?.projectDir,a=n?r?`${h(e.target)} — not reachable from this phone`:h(e.target):MT(e.target,i),o=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex h-[21px] w-[19px] shrink-0 items-center justify-center text-muted`,children:n?(0,X.jsx)(sc,{size:19}):(0,X.jsx)(ke,{size:19})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{"data-link-label":!0,className:`block truncate text-[15.5px] leading-[21px] text-fg`,children:e.label}),(0,X.jsx)(`span`,{"data-link-destination":!0,className:`block truncate text-[12.5px] leading-[17px] text-muted`,children:a})]}),!r&&(0,X.jsx)(br,{size:15,className:`shrink-0 self-center text-muted-70`})]}),s=`flex min-h-[56px] w-full items-start gap-[14px] px-[18px] py-[9px] text-left outline-none focus-visible:bg-hover`;return r?(0,X.jsx)(`div`,{"data-thread-link":e.id,"data-link-unreachable":!0,title:e.target,className:s,children:o}):n?(0,X.jsx)(`a`,{"data-thread-link":e.id,title:e.target,href:e.target,target:`_blank`,rel:`noopener noreferrer`,className:`${s} active:bg-hover`,onClick:()=>t(),children:o}):(0,X.jsx)(`button`,{type:`button`,"data-thread-link":e.id,title:e.target,className:`${s} active:bg-hover`,onClick:()=>t(()=>I(e.target)),children:o})}function MT(e,t){if(t&&e.startsWith(`${t.replace(/\/+$/,``)}/`))return e.slice(t.replace(/\/+$/,``).length+1);let n=e.split(`/`).filter(Boolean);return n.length>2?`…/${n.slice(-2).join(`/`)}`:e}function NT({thread:e,back:t,dismiss:n}){let r=jt(e),[i,a]=(0,q.useState)(()=>fT(r,e.id)),o=(0,q.useRef)(null),s=H({mutationFn:t=>U.renameThread({slug:e.id,title:t})}),c=H({mutationFn:()=>U.aiRenameThread({slug:e.id})}),l=pT(e);(0,q.useEffect)(()=>{let e=requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>cancelAnimationFrame(e)},[]);let u=()=>{let e=dT(i,r);if(!e)return t();s.mutate(e,{onSuccess:()=>n(()=>G(`Thread renamed`)),onError:e=>G(e instanceof Error?e.message:`Could not rename thread`)})};return(0,X.jsxs)(`form`,{"data-thread-actions-rename":!0,onSubmit:e=>{e.preventDefault(),u()},children:[(0,X.jsx)(RT,{back:t,children:`Rename`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 px-[18px]`,children:[(0,X.jsx)(`input`,{ref:o,"aria-label":`Thread title`,value:i,maxLength:200,onChange:e=>a(e.target.value),"data-claims-escape":!0,className:`h-11 w-full rounded-lg border border-border bg-bg px-3 text-[16px] text-fg outline-none focus:border-border-strong`}),(0,X.jsxs)(`button`,{type:`submit`,disabled:s.isPending,className:`flex h-[46px] items-center justify-center gap-2 rounded-xl bg-fg text-[15.5px] font-semibold text-bg outline-none disabled:opacity-45`,children:[s.isPending&&(0,X.jsx)(Ut,{size:16,className:`animate-spin`}),`Save`]})]}),l.show&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`mt-3 mb-1 h-px bg-border`}),(0,X.jsx)(IT,{data:`ai-rename`,disabled:c.isPending,icon:c.isPending?(0,X.jsx)(Ut,{size:19,className:`animate-spin`}):(0,X.jsx)(Tc,{size:19}),label:c.isPending?`Claude is naming it…`:`Rename with Claude`,onClick:()=>{if(!l.enabled)return G(l.label);c.mutate(void 0,{onSuccess:({title:e})=>n(()=>G(`Renamed to “${e}”`)),onError:e=>G(e instanceof Error?e.message:`Could not rename with Claude`,{duration:7e3})})}})]})]})}function PT(e){let t=!!(e&&!e.foreign&&e.kind===`session`),n=ue(),r=Re({queryKey:[`threadProfileOptions`,e?.id??``],queryFn:()=>U.threadProfileOptions({slug:e.id}),enabled:t&&!n,staleTime:5e3});if(!e)return null;let i=e.model?.trim(),a=e.effort?.trim();if(!i&&!a&&!e.runningModelLabel)return null;let o=Kt([{id:e.backend??`claude`,label:``,options:r.data?.options??[]}],{model:i,effort:a},``,e.runningModelLabel);return[[o.name,o.edition].filter(Boolean).join(` `)||null,fa(o.effort)].filter(Boolean).join(` · `)||null}var FT=`flex min-h-[50px] w-full items-center gap-[14px] px-[18px] text-left text-[15.5px] leading-[21px] text-fg outline-none transition-colors active:bg-hover focus-visible:bg-hover disabled:opacity-45`;function IT({icon:e,label:t,value:n,chevron:r,trailing:i,onClick:a,disabled:o,data:s}){return(0,X.jsxs)(`button`,{type:`button`,"data-thread-action":s,disabled:o,onClick:a,className:FT,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`flex w-[19px] shrink-0 items-center justify-center text-muted`,children:e}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),(n||r||i)&&(0,X.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 text-[14px] text-muted`,children:[n,r&&(0,X.jsx)(br,{size:15,className:`text-muted-70`}),i]})]})}function LT({children:e,count:t}){return(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2 px-[18px] pb-2.5 pt-1`,children:[(0,X.jsx)(`span`,{"data-thread-actions-title":!0,className:`min-w-0 flex-1 truncate text-[16px] font-semibold leading-[22px]`,children:e}),t!==void 0&&(0,X.jsx)(`span`,{className:`shrink-0 text-[12.5px] text-muted`,children:t})]})}function RT({children:e,back:t,count:n}){return(0,X.jsxs)(`div`,{className:`flex items-center gap-0.5 pb-1 pl-[6px] pr-[18px]`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Back`,onClick:t,className:`flex size-11 shrink-0 items-center justify-center rounded-full text-fg/85 outline-none active:bg-hover focus-visible:bg-hover`,children:(0,X.jsx)(tc,{size:21})}),(0,X.jsx)(`span`,{"data-thread-actions-title":!0,className:`min-w-0 flex-1 truncate text-[16px] font-semibold leading-[22px]`,children:e}),n!==void 0&&(0,X.jsx)(`span`,{className:`shrink-0 text-[12.5px] text-muted`,children:n})]})}function zT({slug:e,onClose:t}){let n=Se(e),[i,a]=(0,q.useState)(!1),o=di(),s=et(e,{poll:n?.runtime===`running`||n?.runtime===`spawning`}),c=(0,q.useMemo)(()=>_e(s.data?.messages??[]),[s.data]),l=PT(n);if(!n)return null;let u=Jt(n),d=At(n,u,c,o),f=u===`needs-you`?`font-semibold text-accent`:u===`working`?`font-semibold text-live`:``,p=jt(n);return(0,X.jsxs)(`header`,{"data-thread-header":!0,"data-mobile-thread-header":!0,className:`flex min-h-14 shrink-0 items-center gap-0.5 border-b border-border bg-panel py-1 pl-1 pr-[5px]`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Back`,"data-mobile-thread-back":!0,onClick:()=>{Or()?history.back():t()},className:`flex size-11 shrink-0 items-center justify-center rounded-full text-fg/90 outline-none active:bg-hover focus-visible:bg-hover`,children:(0,X.jsx)(r,{size:21,strokeWidth:2.1})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 pl-0.5 leading-[1.25]`,children:[(0,X.jsx)(`div`,{"data-mobile-thread-title":!0,className:`truncate text-[16.5px] font-semibold tracking-[-0.01em]`,title:p,children:p}),(0,X.jsxs)(`div`,{"data-mobile-thread-subtitle":!0,"data-state":u,className:`truncate text-[13px] text-muted`,children:[(0,X.jsx)(`span`,{className:f,children:zt[u]}),d&&(0,X.jsxs)(X.Fragment,{children:[` · `,d]}),l&&(0,X.jsxs)(X.Fragment,{children:[` · `,l]})]})]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Thread actions`,"aria-haspopup":`dialog`,"aria-expanded":i,"data-mobile-thread-more":!0,onClick:()=>a(!0),className:`flex size-11 shrink-0 items-center justify-center rounded-full text-fg/90 outline-none active:bg-hover focus-visible:bg-hover`,children:(0,X.jsx)(Nn,{size:21,strokeWidth:2.1})}),i&&(0,X.jsx)(CT,{slug:e,onClose:()=>a(!1),onArchived:()=>uw(e)})]})}function BT({thread:e}){let t=ct(),[n,r]=(0,q.useState)(!1);return gT(e,hT())?(0,X.jsx)(ua,{label:`Restart worker — same conversation, fresh process on current tooling`,side:`top`,children:(0,X.jsx)(`button`,{type:`button`,disabled:n,"aria-label":`Restart worker`,onMouseDown:e=>e.preventDefault(),onClick:()=>{r(!0),mT(t,e.id).finally(()=>r(!1))},className:`${Vt} mr-[2px]`,children:n?(0,X.jsx)(Ut,{size:14,strokeWidth:2,className:`animate-spin`}):(0,X.jsx)(sa,{size:14,strokeWidth:2})})}):null}function VT(e){return _(e)??os(`/`)}function HT(e){Ms(VT(e),{viewTransition:!ee()})}function UT({slug:e,label:t=`Exit fullscreen`}){let n=VT(e);function r(t){if(tn(t)){if(t.preventDefault(),fo()){a(!1);return}HT(e)}}return(0,X.jsx)(ua,{label:t,children:(0,X.jsx)(`a`,{href:n,"aria-label":t,"data-standalone-return":!0,onMouseDown:e=>e.preventDefault(),onClick:r,className:Vt,children:(0,X.jsx)(bc,{size:14})})})}function WT({thread:e,expand:t,collapse:n,onDoc:r,onDone:i,onCollapse:a,collapsed:o,doneBusy:s,onStatusMutate:c,onStatusApplied:l,onStatusFailed:u}){let d=e.kind===`session`;return(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[a&&(0,X.jsx)(KT,{label:o?`Expand`:`Collapse`,icon:o?rc:nc,size:13,onClick:a}),(0,X.jsx)(BT,{thread:e}),r&&(0,X.jsx)(KT,{label:`Frizz document`,icon:ke,size:14,onClick:r}),t&&(0,X.jsx)(re,{slug:e.id}),n&&(0,X.jsx)(UT,{slug:e.id}),d?Je(e)?(0,X.jsx)(GT,{slug:e.id}):null:(0,X.jsx)(`div`,{className:`ml-1`,children:(0,X.jsx)(Zr,{slug:e.id,onDone:i,doneBusy:s,onMutateStart:c,onApplied:l,onFailed:u})})]})}function GT({slug:e}){let t=ct(),[n,r]=(0,q.useState)(!1);return(0,X.jsx)(ua,{label:`Retry — resume this session where it left off`,children:(0,X.jsxs)(`button`,{onClick:()=>{r(!0),Xi(t,e).finally(()=>r(!1))},disabled:n,"aria-label":`Retry exited session`,"data-header-pill":!0,onMouseDown:e=>e.preventDefault(),className:`ml-1 flex items-center gap-1.5 rounded-md border border-accent/45 bg-accent/10 px-2.5 py-1 text-[12px] font-medium text-accent outline-none transition-colors hover:bg-accent/15 disabled:opacity-50`,children:[n?(0,X.jsx)(Ut,{size:12,className:`animate-spin`}):(0,X.jsx)(d,{size:12}),`Retry`]})})}function KT({label:e,icon:t,size:n,busy:r,...i}){return(0,X.jsx)(ua,{label:e,children:(0,X.jsx)(`button`,{...i,"aria-label":e,onMouseDown:e=>e.preventDefault(),className:Vt,children:r?(0,X.jsx)(Ut,{size:n,strokeWidth:2,className:`animate-spin`}):(0,X.jsx)(t,{size:n,strokeWidth:2})})})}var qT=1.25,JT=7.5-qT/2,YT=2*Math.PI*JT;function XT(e,t){return Math.max(0,Math.min(100,Math.floor(e/t*100)))}var ZT=150;function QT(e){return!!e.context&&e.context.window>0}function $T({thread:e}){let t=e.context;if(!t||!QT(e))return null;let n=iE(e,t.tokens);return(0,X.jsx)(eE,{context:t,action:kr(e)?t=>(0,X.jsx)(aE,{thread:e,compacting:n,onRequested:t}):void 0})}function eE({context:e,action:t}){let[n,r]=(0,q.useState)(!1),i=(0,q.useRef)(void 0),a=(0,q.useRef)(null),o=(0,q.useRef)(null);if((0,q.useEffect)(()=>()=>clearTimeout(i.current),[]),!(e.window>0))return null;let s=()=>{clearTimeout(i.current),r(!0)},c=()=>{clearTimeout(i.current),i.current=setTimeout(()=>r(!1),ZT)},l=e=>{a.current?.contains(e.target)&&e.preventDefault()},u=XT(e.tokens,e.window),d=Math.max(0,Math.min(1,e.tokens/e.window)),f=`Context ${u}% full`,p=`${e.tokens.toLocaleString()} of ${e.window.toLocaleString()} tokens`;return(0,X.jsxs)(S,{open:n,onOpenChange:r,children:[(0,X.jsx)(Wn,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-context-meter":!0,"data-context-percent":u,"aria-label":`${f}\n${p}`,"aria-haspopup":`dialog`,"aria-expanded":n,onMouseEnter:s,onMouseLeave:c,onFocus:s,ref:a,onClick:e=>{e.stopPropagation(),s(),e.detail===0&&requestAnimationFrame(()=>o.current?.querySelector(`button:not(:disabled)`)?.focus())},className:`flex shrink-0 items-baseline gap-1 rounded-sm outline-none transition-colors hover:text-fg/85 focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${n?`text-fg/85`:``}`,children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,className:`-mt-[1em] h-[1.05em] w-[1.05em] shrink-0 self-baseline translate-y-[calc(0.525em_-_0.5cap)]`,"aria-hidden":!0,children:[(0,X.jsx)(`circle`,{cx:`8`,cy:`8`,r:JT,fill:`none`,stroke:`currentColor`,strokeOpacity:.3,strokeWidth:qT}),(0,X.jsx)(`circle`,{cx:`8`,cy:`8`,r:JT,fill:`none`,stroke:`currentColor`,strokeWidth:qT,strokeDasharray:`${YT*d} ${YT}`,transform:`rotate(-90 8 8)`})]}),(0,X.jsxs)(`span`,{children:[u,`% context`]})]})}),(0,X.jsxs)(je,{side:`bottom`,align:`start`,sideOffset:5,ref:o,"data-context-panel":!0,"aria-label":f,onInteractOutside:e=>l({target:e.detail.originalEvent.target,preventDefault:()=>e.preventDefault()}),onMouseEnter:s,onMouseLeave:c,onOpenAutoFocus:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),className:`flex w-max max-w-[min(22rem,calc(100vw-1.5rem))] flex-col gap-2 px-3 py-2 text-[11px] leading-relaxed text-fg`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{children:f}),(0,X.jsx)(`span`,{className:`text-muted`,children:p})]}),t?.(()=>r(!1))]})]})}function tE(e){return e.runtime===`running`||e.runtime===`spawning`||e.runtime===`perm-prompt`}var nE=new Map,rE=2*6e4;function iE(e,t){let n=e.sessionId;if(!n)return!1;let r=nE.get(n);return r?!tE(e)&&(r.tokens!==t||e.lastActivityAt!==r.activity)||Date.now()-r.at>rE?(nE.delete(n),!1):!0:!1}function aE({thread:e,compacting:t,onRequested:n}){let[r,i]=(0,q.useState)(!1),a=e.context?.tokens??0,o=tE(e)&&!t;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsxs)(`button`,{type:`button`,"data-compact-now":!0,disabled:o||r||t||!e.sessionId,onClick:()=>{let t=e.sessionId;t&&(i(!0),U.compactThread({slug:e.id,sessionId:t}).then(()=>{nE.set(t,{tokens:a,activity:e.lastActivityAt,at:Date.now()}),G(`Compacting context`),n()}).catch(e=>G(`Couldn’t compact: ${e.message.slice(0,80)}`)).finally(()=>i(!1)))},onMouseDown:e=>e.preventDefault(),className:`flex items-center justify-center gap-1 rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] font-medium text-fg/80 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:opacity-45 disabled:hover:bg-panel-2/60 disabled:hover:text-fg/80`,children:[(r||t)&&(0,X.jsx)(Ut,{size:12,className:`animate-spin`}),t?`Compacting…`:`Compact now`]}),o&&(0,X.jsx)(`span`,{className:`text-muted`,children:`Available once the current turn ends`})]})}function oE({thread:e}){let t=Si(e.id);return(0,X.jsx)(sE,{"data-thread-header-facts":``,lead:t?(0,X.jsx)(cE,{slug:t}):null,lastActiveAt:bo(e),fallbackAt:e.spawnedAt,reading:QT(e)?(0,X.jsx)($T,{thread:e}):null})}function sE({lead:e,lastActiveAt:t,fallbackAt:n,reading:r,...i}){return(0,X.jsxs)(`div`,{...i,className:`mt-0.5 flex min-w-0 items-center gap-1.5 text-[11px] leading-tight text-muted-75 empty:hidden`,children:[e?(0,X.jsxs)(X.Fragment,{children:[e,(0,X.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-muted-45`,children:`·`})]}):null,(0,X.jsx)(Ie,{at:t,fallbackAt:n,className:`min-w-0 truncate`}),r?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`hidden shrink-0 text-muted-45 [time+&]:inline`,children:`·`}),r]}):null]})}function cE({slug:e}){let t=Re({queryKey:[`projectsList`],queryFn:()=>U.projectsList()}).data?.find(t=>t.slug===e),n=t?.name??e,r=Bo(e);function i(e){e.stopPropagation(),tn(e)&&(e.preventDefault(),Ms(r))}return(0,X.jsxs)(`a`,{href:r,"data-thread-project":e,title:`Open ${n}`,onClick:i,className:`flex min-w-0 shrink-0 items-center gap-1.5 rounded-sm font-medium text-fg/80 no-underline outline-none transition-colors hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:[t?(0,X.jsx)(zs,{project:t,size:14}):null,(0,X.jsx)(`span`,{className:`truncate`,children:n})]})}function lE({thread:e,hidden:t=!1}){let n=H({mutationFn:()=>U.aiRenameThread({slug:e.id}),onSuccess:({title:e})=>G(`Renamed to “${e}”`),onError:e=>G(e instanceof Error?e.message:`Could not rename with Claude`,{duration:7e3})}),r=pT(e);if(!r.show||t)return null;let i=n.isPending?`Claude is generating a title…`:n.error instanceof Error?n.error.message:r.label,a=n.isPending||!!n.error;return(0,X.jsx)(ua,{label:i,children:(0,X.jsx)(`button`,{type:`button`,"data-ai-rename":!0,"aria-label":n.isPending?`Renaming with Claude`:r.label,"aria-busy":n.isPending,"aria-disabled":!r.enabled,onMouseDown:e=>e.preventDefault(),onClick:()=>{if(!n.isPending){if(!r.enabled){G(r.label);return}n.reset(),n.mutate()}},className:`title-refresh-offset -mx-[7px] -my-3 flex h-6 w-6 shrink-0 items-center justify-center rounded-md outline-none transition-[color,background-color,opacity] focus-visible:opacity-100 group-hover/thread-title:opacity-100 ${a?`opacity-100`:`opacity-0`} ${n.error?`text-danger hover:bg-danger-fill/10`:r.enabled?`text-muted hover:bg-hover-strong hover:text-fg`:`cursor-not-allowed text-muted-50 hover:bg-hover-strong`}`,children:n.isPending?(0,X.jsx)(Ut,{size:12,className:`animate-spin`}):(0,X.jsx)(Tc,{size:12})})})}function uE({thread:e,className:t=``}){let n=e.id,r=H({mutationFn:e=>U.renameThread({slug:n,title:e})}),[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(``),c=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!i)return;let e=requestAnimationFrame(()=>{c.current?.focus(),c.current?.select()});return()=>cancelAnimationFrame(e)},[i]),(0,q.useEffect)(()=>{a(!1),s(``)},[n]);let l=e.kind===`session`&&e.foreign!==!0,u=jt(e);function d(){a(!1),s(``)}function f(){let e=dT(o,u);if(a(!1),!e){s(``);return}r.mutate(e,{onSuccess:()=>{s(``),G(`Thread renamed`)},onError:t=>{s(e),a(!0),G(t instanceof Error?t.message:`Could not rename thread`)}})}return(0,X.jsxs)(`div`,{className:`group/thread-title flex min-w-0 items-center gap-2`,children:[i?(0,X.jsx)(`input`,{ref:c,"aria-label":`Thread title`,value:o,maxLength:200,onChange:e=>s(e.target.value),onBlur:f,"data-claims-escape":!0,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),f()):e.key===`Escape`&&(e.preventDefault(),d())},className:`min-w-0 flex-1 -mx-1.5 -my-px rounded-md border border-border bg-elevated px-1.5 py-0 font-semibold text-[15px] text-fg outline-none focus:border-accent ${t}`}):l?(0,X.jsx)(`button`,{type:`button`,title:`Edit title`,"aria-label":`Edit thread title: ${u}`,disabled:r.isPending,onClick:()=>{s(fT(u,n)),a(!0)},className:`min-w-0 max-w-full shrink truncate rounded px-0.5 -mx-0.5 font-semibold text-[15px] text-left outline-none transition-colors hover:bg-panel-2 focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:cursor-not-allowed disabled:opacity-40 ${t}`,children:u}):(0,X.jsx)(`div`,{className:`min-w-0 max-w-full shrink truncate px-0.5 -mx-0.5 font-semibold text-[15px] ${t}`,title:u,children:u}),(0,X.jsx)(lE,{thread:e,hidden:i})]})}function dE(e){if(e.kind!==void 0||e.role!==`assistant`||e.text.trim())return;let t=e.parts??[],n=t.length>0?t.length===1&&t[0].kind===`tools`?t[0].tools:[]:e.tools??[],r=n.length===1?n[0]:void 0;return r?.agentCompletion?r:void 0}var fE={completed:`finished`,killed:`stopped`,failed:`failed`};function pE(e){let t=fE[e.agentStatus??`completed`],n=e.agentElapsedMs===void 0?void 0:er(e.agentElapsedMs);return{outcome:t,tail:`${t}${n?` · ${n}`:``}`}}var mE=e=>e===void 0?void 0:rt(e),hE=e=>{if(e!==void 0)return er(e)||void 0};function gE(e){let{agentStatus:t,agentElapsedMs:n,liveState:r,liveElapsedMs:i,status:a,durationMs:o}=e;if(t){let e=t===`killed`,r=t===`failed`,i=mE(n);return{label:t===`completed`?void 0:fE[t],duration:hE(n),tone:r?`failed`:`muted`,title:`${e?`Stopped`:r?`Failed`:`Ran for`}${e||r?` after`:``} ${i??`an unknown time`}`}}if(r){let e=mE(i);return{label:void 0,duration:hE(i),tone:`muted`,title:r===`running`?`Working for ${e??`an unknown time`}`:`Dispatched ${e??`an unknown time`} ago`}}if(a===`pending`||a!==`failed`&&a!==`cancelled`)return null;let s=a===`failed`,c=a===`cancelled`,l=mE(o);return{label:c?fE.killed:s?fE.failed:void 0,duration:hE(o),tone:s?`failed`:`muted`,title:`${c?`Stopped after`:s?`Failed after`:`Ran for`} ${l??`an unknown time`}`}}var _E=`group flex min-w-0 items-baseline gap-1.5 rounded-sm text-left text-[11.5px] outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60`,vE=`${Js} -mt-[1em] self-baseline`,yE=`h-[1em] w-[1em] shrink-0 translate-y-[calc(0.5em_-_0.5cap)] text-muted-45`,bE=`group flex min-w-0 items-baseline gap-2 rounded-md px-2.5 py-1.5 text-left text-[12px] outline-none transition-colors hover:bg-hover-strong focus-visible:bg-hover-strong`;function xE({links:e}){return(0,X.jsx)(`div`,{"data-thread-links":!0,"aria-label":`Registered links`,className:`flex min-w-0 flex-col`,children:e.map(e=>{let t=e.kind===`link`,n=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:Er,children:(0,X.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(t?sc:ke,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-60`})})}),(0,X.jsx)(`span`,{"data-link-label":!0,className:`min-w-0 shrink truncate text-fg/85 group-hover:text-fg`,children:e.label}),(0,X.jsx)(`span`,{"data-link-destination":!0,className:`font-mono-keep min-w-0 flex-1 truncate text-right text-[10.5px] text-muted-50`,children:t?e.target:e.target.split(`/`).pop()})]});return t?(0,X.jsx)(`a`,{"data-thread-link":e.id,href:e.target,target:`_blank`,rel:`noopener noreferrer`,title:e.target,className:bE,onClick:e=>e.stopPropagation(),children:n},e.id):(0,X.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${bE} cursor-pointer`,onClick:t=>{t.stopPropagation(),I(e.target)},children:n},e.id)})})}function SE({links:e,panel:t=!1}){return e.length?t?(0,X.jsx)(xE,{links:e}):(0,X.jsx)(`div`,{"data-thread-links":!0,"aria-label":`Registered links`,className:`mt-2 flex min-w-0 flex-col gap-0.5 border-t border-border pt-1.5`,children:e.map(e=>{let t=e.kind===`link`,n=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:Xt,children:`⤷`}),(0,X.jsx)(`span`,{className:vE,children:(0,X.jsx)(t?sc:ke,{"aria-hidden":!0,className:yE})}),(0,X.jsx)(`span`,{"data-link-kind":!0,className:mn,children:t?`Link`:`File`}),(0,X.jsx)(`span`,{"data-link-label":!0,className:`min-w-0 flex-1 truncate text-muted-70 group-hover:text-fg/80 group-hover:underline`,children:e.label}),t&&(0,X.jsx)(`span`,{"data-link-destination":!0,className:`font-mono-keep ml-auto -mb-[0.5em] max-w-[45%] min-w-0 truncate text-right text-[10px] text-muted-45`,children:e.target})]});return t?(0,X.jsx)(`a`,{"data-thread-link":e.id,href:e.target,target:`_blank`,rel:`noopener noreferrer`,title:e.target,className:_E,onClick:e=>e.stopPropagation(),children:n},e.id):(0,X.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${_E} cursor-pointer`,onClick:t=>{t.stopPropagation(),I(e.target)},children:n},e.id)})}):null}var CE=`text-[14px] leading-5 text-muted`,wE=`size-[1em] shrink-0 self-baseline -mt-[calc(1em_-_1cap)] translate-y-[calc(0.5em_-_0.5cap)] text-muted-70 transition-transform group-hover:text-fg`;function TE(e){return`${wE} ${e?`-mx-[0.208em] rotate-90`:`-mx-[0.333em]`}`}var $=q.createElement;function EE({payload:e}){return e.kind===`command-approval`?$(q.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},`Command`),$(`div`,{className:`mt-0.5 break-words text-[13px] font-medium text-fg`},e.command.summary),e.command.workingDirectoryLabel?$(`div`,{className:`mt-1 break-all text-[10.5px] text-muted-70`},`Working directory: `,e.command.workingDirectoryLabel):null,$(DE,{label:`Redacted command preview`,text:e.command.preview}),e.command.actions?$(OE,{actions:e.command.actions}):null,e.capabilities?$(AE,{capabilities:e.capabilities}):null):e.kind===`file-approval`?$(q.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},PE(e.operation)),$(`div`,{className:`mt-0.5 break-all font-mono-keep text-[12px] text-fg`},e.pathLabel),e.destinationLabel?$(`div`,{className:`mt-1 break-all font-mono-keep text-[11px] text-muted`},`→ `,e.destinationLabel):null,e.grantRootLabel?$(`section`,{"aria-label":`Requested session write root`,className:`mt-2.5 min-w-0 rounded-md border border-attention/35 bg-attention-fill/[0.06] px-2.5 py-2`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-attention-soft-80`},`Requested session write root`),$(`div`,{className:`mt-1 min-w-0 break-all font-mono-keep text-[10.5px] text-fg/85`},e.grantRootLabel),e.scopeLabel?$(`div`,{className:`mt-1.5 whitespace-pre-wrap break-words text-[10.5px] leading-snug text-attention-soft-75`},e.scopeLabel):null):null,e.diffPreview?$(DE,{label:`Plain-text diff preview`,text:e.diffPreview}):null,e.changes?$(kE,{changes:e.changes}):null):$(q.Fragment,null,e.preview?$(`pre`,{className:`max-h-64 max-w-full min-w-0 overflow-auto rounded-md border border-border/70 bg-bg/40 px-2.5 py-2 whitespace-pre-wrap break-words font-mono-keep text-[11.5px] leading-relaxed text-fg/90`},e.promptLabel?$(`span`,{className:`text-shell/90`},e.promptLabel):null,e.promptLabel?$(`span`,{className:`text-accent`},` ❯ `):null,e.preview):null,e.resourceLabel?$(`div`,{className:`mt-1 break-all text-[11px] text-muted`},`Resource: `,e.resourceLabel):null,e.workingDirectoryLabel?$(`div`,{className:`mt-1.5 break-all text-[10.5px] text-muted-70`},`Working directory: `,e.workingDirectoryLabel):null,e.scopeLabel?$(`div`,{className:`mt-2 whitespace-pre-wrap break-words text-[11px] leading-snug text-muted`},e.scopeLabel):null,e.capabilities?$(AE,{capabilities:e.capabilities}):null)}function DE({label:e,text:t}){return $(`details`,{className:`mt-2.5 min-w-0 rounded-md border border-border/70 bg-bg/35`,open:t.length<1200},$(`summary`,{className:`cursor-pointer px-2.5 py-2 text-[10.5px] text-muted outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-50`},e),$(`pre`,{className:`max-h-64 max-w-full min-w-0 overflow-auto border-t border-border/60 px-2.5 py-2 whitespace-pre-wrap break-words font-mono-keep text-[11px] leading-relaxed text-fg/80`},t))}function OE({actions:e}){return $(`section`,{"aria-label":`Parsed command actions`,className:`mt-3 min-w-0`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-muted-75`},`Parsed actions`),$(`ul`,{className:`mt-1.5 flex min-w-0 flex-col gap-2`},e.map((e,t)=>$(`li`,{key:t,className:`min-w-0 rounded-md border border-border/65 bg-bg/25 px-2.5 py-2`},$(`div`,{className:`text-[11px] font-medium text-fg/90`},NE(e.kind)),e.resourceLabel?$(`div`,{className:`mt-0.5 break-all font-mono-keep text-[10.5px] text-muted`},e.resourceLabel):null,e.queryLabel?$(`div`,{className:`mt-0.5 break-all text-[10.5px] text-muted`},`Query: `,e.queryLabel):null,$(DE,{label:`${NE(e.kind)} command detail`,text:e.commandPreview})))))}function kE({changes:e}){return $(`section`,{"aria-label":`Affected file changes`,className:`mt-3 min-w-0`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-muted-75`},`Affected changes`),$(`ol`,{className:`mt-1.5 flex min-w-0 flex-col gap-2`},e.map((e,t)=>$(`li`,{key:t,className:`min-w-0 rounded-md border border-border/65 bg-bg/25 px-2.5 py-2`},$(`div`,{className:`text-[11px] font-medium text-fg/90`},PE(e.operation)),$(`div`,{className:`mt-0.5 break-all font-mono-keep text-[10.5px] text-fg/80`},e.pathLabel),e.destinationLabel?$(`div`,{className:`mt-0.5 min-w-0 break-all font-mono-keep text-[10.5px] text-muted`},`→ `,e.destinationLabel):null,e.diffPreview?$(DE,{label:`${PE(e.operation)} plain-text diff`,text:e.diffPreview}):null))))}function AE({capabilities:e}){return $(`section`,{"aria-label":`Requested capabilities`,className:`mt-3 min-w-0`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-muted-75`},`Requested capabilities`),$(`ul`,{className:`mt-1.5 flex min-w-0 flex-col gap-2`},e.map((e,t)=>$(`li`,{key:t,className:`min-w-0 rounded-md border border-border/65 bg-bg/25 px-2.5 py-2`},$(jE,{capability:e})))))}function jE({capability:e}){if(e.kind===`network`){let t=e.enabled===!0?`Enable network access`:e.enabled===!1?`Disable network access`:`Network access request`;return $(q.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},t),e.hosts.length>0?$(ME,{label:`Hosts and protocols`,values:e.hosts}):null)}if(e.kind===`filesystem`){let t=e.access===`read`?`Read filesystem paths`:e.access===`write`?`Write filesystem paths`:`Deny filesystem paths`;return $(q.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},t),$(ME,{label:`Paths`,values:e.resources}))}return e.kind===`glob-scan`?$(q.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},`Filesystem glob scanning`),$(`div`,{className:`mt-0.5 text-[10.5px] text-muted`},`Maximum depth: `,String(e.depth))):e.kind===`exec-policy`?$(q.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},`Future command policy amendment`),$(ME,{label:`Command prefix tokens`,values:e.prefixes})):$(q.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},e.access===`allow`?`Allow future network hosts`:`Deny future network hosts`),$(ME,{label:`Hosts`,values:e.hosts}))}function ME({label:e,values:t}){return $(`div`,{className:`mt-1 min-w-0`},$(`div`,{className:`sr-only`},e),$(`ul`,{"aria-label":e,className:`flex min-w-0 flex-col gap-0.5`},t.map((e,t)=>$(`li`,{key:t,className:`min-w-0 break-all font-mono-keep text-[10.5px] text-muted`},e))))}function NE(e){switch(e){case`read`:return`Read a file`;case`list-files`:return`List files`;case`search`:return`Search files`;case`unknown`:return`Unclassified command`}}function PE(e){switch(e){case`read`:return`Read file`;case`create`:return`Create file`;case`write`:return`Modify file`;case`move`:return`Move file`;case`delete`:return`Delete file`;case`execute`:return`Execute file`;case`other`:return`File operation`}}function FE(e){return e===`sending`?{actionsEnabled:!1,status:`Sending to runtime…`}:e===`reconnect-required`?{actionsEnabled:!1,status:`Runtime reconnect required before this request can be answered.`}:{actionsEnabled:!0}}var IE={semantic:`approve`,label:`Approve once`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`},LE={semantic:`approve`,label:`Approve for session`,order:20,tone:`primary`,durable:!0,scope:`Persists for later matching requests in this thread session.`},RE={semantic:`approve`,label:`Grant for turn`,order:10,tone:`primary`,durable:!1,scope:`Applies to this turn only.`},zE={semantic:`approve`,label:`Grant for session`,order:20,tone:`primary`,durable:!0,scope:`Persists until this thread session ends.`},BE={semantic:`deny`,label:`Deny`,order:70,tone:`danger`,durable:!1,scope:`Rejects this request.`},VE={semantic:`decline`,label:`Decline`,order:70,tone:`danger`,durable:!1,scope:`Declines this request.`},HE={semantic:`cancel`,label:`Cancel request`,order:80,tone:`neutral`,durable:!1,scope:`Cancels this pending request.`};function UE(e,t){let{id:n,semantic:r}=t;if(e.kind===`command-approval`||e.kind===`file-approval`)return(n===`accept`||n===`approve-once`)&&r===`approve`?IE:n===`acceptForSession`&&r===`approve`?LE:(n===`decline`||n===`deny`)&&r===`deny`?BE:n===`cancel`&&r===`cancel`?HE:void 0;if(e.kind===`permission-approval`)return n===`grant-turn`&&r===`approve`?RE:n===`grant-session`&&r===`approve`?zE:(n===`deny`||n===`decline`)&&r===`deny`?BE:n===`cancel`&&r===`cancel`?HE:void 0;if(e.kind===`mcp-elicitation-form`||e.kind===`mcp-elicitation-url`)return n===`accept`&&r===`accept`?{semantic:`accept`,label:e.kind===`mcp-elicitation-form`?`Submit`:`Continue`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`}:n===`decline`&&r===`decline`?VE:n===`cancel`&&r===`cancel`?HE:void 0;if(n===`answer`&&r===`answer`)return{semantic:`answer`,label:`Send answer`,order:10,tone:`primary`,durable:!1,scope:`Sends these answers to this request only.`};if(n===`decline`&&r===`decline`)return VE;if(n===`cancel`&&r===`cancel`)return HE}function WE(e){let t=t=>e.payload.kind===`mcp-elicitation-form`&&t===`accept`||e.payload.kind===`agent-question`&&t===`answer`;return e.allowedDecisions.flatMap(n=>{let r=UE(e.payload,n);return r?[{...r,id:n.id,semantic:n.semantic,requiresValues:t(n.semantic)}]:[]}).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id))}function GE(e){switch(e){case`claude`:return`Claude`;case`codex`:return`Codex`;case`acp`:return`ACP agent`;case`opencode`:return`OpenCode`;case`frizz`:return`Frizz`}}function KE(e){switch(e){case`runtime`:return`Runtime`;case`agent`:return`Agent`;case`tool`:return`Tool`;case`mcp-server`:return`MCP server`;case`frizz`:return`Frizz`}}function qE(e,t){let n=e.options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t));return n<0?``:String(n)}function JE(e){let t=Object.create(null);for(let n of e)if(n.input===`text`||n.input===`multiline`)t[n.id]=n.default??``;else if(n.input===`number`||n.input===`integer`)t[n.id]=n.default===void 0?``:String(n.default);else if(n.input===`boolean`)t[n.id]=n.default??!1;else if(n.input===`select`)t[n.id]=n.default===void 0?``:qE(n,n.default);else if(n.input===`multi-select`){let e=new Set(n.default??[]);t[n.id]=n.options.flatMap((t,n)=>e.has(t.value)?[String(n)]:[])}return t}function YE(e,t,n){let r=Object.create(null);for(let t of Object.keys(e))r[t]=e[t];return r[t]=n,r}function XE(e,t){if(e.some(e=>e.secret))return{errors:{},formError:`Secret responses cannot be sent through this Frizz connection.`};let n=Object.create(null),r={};for(let i of e){let e=t[i.id],a;if(i.input===`text`||i.input===`multiline`){let t=typeof e==`string`?e:``;if(!i.required&&t===``)continue;i.required&&t===``?r[i.id]=`This field is required.`:a=t}else if(i.input===`number`||i.input===`integer`){let t=typeof e==`string`?e.trim():``;if(!i.required&&t===``)continue;if(t===``)r[i.id]=`This field is required.`;else{let e=Number(t);Number.isFinite(e)?a=e:r[i.id]=`Enter a valid number.`}}else if(i.input===`boolean`)a=e===!0;else if(i.input===`select`){let t=typeof e==`string`&&/^\d+$/.test(e)?Number(e):-1;if(t<0||t>=i.options.length)if(i.required)r[i.id]=`Choose an option.`;else continue;else a=i.options[t].value}else if(i.input===`multi-select`){let t=(Array.isArray(e)?e:[]).flatMap(e=>/^\d+$/.test(e)?[Number(e)]:[]);if(t.some(e=>e<0||e>=i.options.length))r[i.id]=`Choose only advertised options.`;else if(i.required&&t.length===0)r[i.id]=`Choose at least one option.`;else if(t.length>0)a=t.map(e=>i.options[e].value);else continue}if(a!==void 0&&!r[i.id]){let e=ca(i,a);e?r[i.id]=`Value ${e}.`:n[i.id]=a}}if(Object.keys(r).length>0)return{errors:r};let i=_a.safeParse(n);return i.success?{errors:r,values:i.data}:{errors:r,formError:`The response is too large or contains invalid values.`}}function ZE(e,t){return JSON.stringify([e,t??null])}function QE(e,t){let n=e??t;if(!n)return null;let r=e&&(e.input===`select`||e.input===`multi-select`)?e.options:[];return{question:{kind:e?.input===`multi-select`?`multi`:`question`,danger:!1,contextMd:n.description??n.label,options:r.map((e,t)=>`${Mg(t)} ${e.label}`),recommendedIdxs:[]},...e?{optionFieldId:e.id}:{},optionValues:r.map(e=>e.value),...t?{notesFieldId:t.id}:{}}}function $E(e){if(e.payload.kind!==`agent-question`)return null;let t=e.payload.fields,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.secret)return null;if(r.id.endsWith(`_notes`))continue;let i=t[e+1],a=i&&i.id===`${r.id}_notes`?i:void 0;if(r.input===`select`||r.input===`multi-select`){let e=QE(r,a);if(!e)return null;n.push(e)}else if(r.input===`text`||r.input===`multiline`){let e=QE(void 0,r);if(!e)return null;n.push(e)}else return null}return n.length>0?n:null}function eD(e,t){let n=[],r;if(t){let i=e.multiSelect?t.split(`, `):[t];e.options.forEach((e,t)=>{i.includes(e.label)&&n.push(t)}),n.length===0&&(r=t)}return{question:{kind:e.multiSelect?`multi`:`question`,danger:!1,contextMd:e.question,options:e.options.map((e,t)=>`${Mg(t)} ${e.label}${e.description?` — ${e.description}`:``}`),recommendedIdxs:[]},chosenIdxs:n,text:r}}function tD(e,t){let n={};return e.forEach((e,r)=>{let i=t[r];if(!i)return;let a=i.text.trim();if(e.question.kind===`multi`){let t=(i.chosenSet??[]).slice().sort((e,t)=>e-t).flatMap(t=>{let n=e.optionValues[t];return n===void 0?[]:[n]});e.optionFieldId&&t.length>0&&(n[e.optionFieldId]=t),e.notesFieldId&&a&&(n[e.notesFieldId]=a);return}let o=i.chosen;if(e.optionFieldId&&o!==null&&e.optionValues[o]!==void 0){n[e.optionFieldId]=e.optionValues[o];return}a&&e.notesFieldId&&(n[e.notesFieldId]=a)}),Object.keys(n).length>0?n:void 0}function nD(e){let t=e instanceof Error?e.message:`The request could not be updated.`;return t.length>240?`${t.slice(0,239)}…`:t}function rD(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`frizz-response-${Date.now()}-${Math.random().toString(36).slice(2)}`}function iD({thread:e,className:t=``,autoFocusFirst:n=!1}){let r=la(e),i=Un(e),a=(0,q.useMemo)(()=>[...i.data?.interactions??[]].sort((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)),[i.data?.interactions]);return r?i.isError&&a.length===0?(0,X.jsxs)(`div`,{"data-interactions-error":!0,role:`alert`,className:`${um} border border-attention-fill/35 bg-attention-fill/[0.07] p-4 text-[12px] text-attention-soft ${t}`,children:[(0,X.jsx)(`div`,{className:`font-medium`,children:`Pending requests could not be loaded.`}),(0,X.jsx)(`div`,{className:`mt-1 break-words text-attention-soft-75`,children:nD(i.error)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void i.refetch(),className:`mt-2 rounded-md border border-attention/40 px-2 py-1 text-[11px] hover:bg-attention-fill/10`,children:`Try again`})]}):a.length===0?null:(0,X.jsx)(`section`,{"data-typed-interactions":!0,"aria-label":`${a.length} pending request${a.length===1?``:`s`}`,className:`flex min-w-0 flex-col gap-3 ${t}`,children:a.map((e,t)=>(0,X.jsx)(oD,{record:e,autoFocus:n&&t===0,siblings:a},e.id))}):null}function aD({record:e,questions:t,autoFocus:n,siblings:r}){let i=ct(),a=ue(),o=uD(e,r),s=(0,q.useRef)(null),c=(0,q.useRef)(new Map),l=yn(),u=FE(e.delivery?.effect),d=(0,q.useMemo)(()=>WE(e).find(e=>e.semantic===`answer`),[e]),f=Es(t.flatMap(t=>t.notesFieldId?[jr.interaction(l,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId)]:[])),[p,m]=(0,q.useState)(()=>t.map(()=>({chosen:null,chosenSet:[]}))),h=t.map((t,n)=>({chosen:p[n]?.chosen??null,chosenSet:p[n]?.chosenSet??[],text:t.notesFieldId?f.get(jr.interaction(l,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId))??``:``})),g=tD(t,h),[_,v]=(0,q.useState)(),[y,b]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!n)return;let e=document.activeElement;e&&e!==document.body||requestAnimationFrame(()=>s.current?.focus())},[n,e.id]);let x=H({mutationFn:async t=>U.interactionResolve({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision,responseId:t.responseId,decisionId:t.decisionId,values:t.values}),onSuccess:t=>{b(!0),Pi(i,t.interaction),i.invalidateQueries({queryKey:Ui(e.owner.threadSlug,e.owner.sessionId)}),i.invalidateQueries({queryKey:Pa(e.owner.threadSlug,e.owner.sessionId,e.id)})},onError:t=>{so(i,e),o.rollback(),v(nD(t)),U.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{Pi(i,t),i.setQueryData(Pa(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t}),i.invalidateQueries({queryKey:Ui(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}}),S=()=>{if(!d||!g||x.isPending||y||!u.actionsEnabled)return;v(void 0);let e=ZE(d.id,g),t=c.current.get(e)??rD();c.current.set(e,t),o.release(!0),x.mutate({decisionId:d.id,values:g,responseId:t})},C=(t,n)=>{t.notesFieldId&&ls.set(jr.interaction(l,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId),n)};return(0,X.jsxs)(`article`,{ref:s,tabIndex:-1,"data-interaction-id":e.id,"data-interaction-kind":e.payload.kind,"data-interaction-question":`native`,"data-delivery-effect":e.delivery?.effect,className:`flex min-w-0 flex-col gap-2 outline-none`,children:[t.map((e,t)=>(0,X.jsx)(cS,{question:e.question,interactive:u.actionsEnabled&&!y?{answer:h[t],onChip:n=>{m(r=>r.map((r,i)=>{if(i!==t)return r;if(e.question.kind===`multi`){let e=r.chosenSet.includes(n)?r.chosenSet.filter(e=>e!==n):[...r.chosenSet,n];return{...r,chosenSet:e}}return{...r,chosen:r.chosen===n?null:n}}))},onText:n=>{C(e,n),e.question.kind!==`multi`&&m(e=>e[t]?.chosen===null||e[t]===void 0?e:e.map((e,n)=>n===t?{...e,chosen:null}:e))},onSubmit:S}:void 0},e.optionFieldId??e.notesFieldId??t)),_&&(0,X.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-danger-soft`,children:_}),(u.status||x.isPending||y)&&(0,X.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[11px] leading-snug text-muted`,children:u.status??(y?`Answer sent.`:`Sending…`)}),a&&(0,X.jsxs)(ys,{className:`text-[12px] text-muted`,children:[`This has to be answered on `,a,`.`]}),u.actionsEnabled&&!y&&!a&&(0,X.jsx)(`div`,{className:`flex justify-start`,children:(0,X.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:!g||x.isPending,onClick:S,onMouseDown:e=>e.preventDefault(),className:`button-outline rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:`Send answers`})})]})}function oD({record:e,autoFocus:t=!1,siblings:n}){let r=(0,q.useMemo)(()=>$E(e),[e]),i=n??[e];return r?(0,X.jsx)(aD,{record:e,questions:r,autoFocus:t,siblings:i}):(0,X.jsx)(dD,{record:e,autoFocus:t,siblings:i})}function sD(e){return e.semantic!==`cancel`}var cD=new Set,lD=new Set;function uD(e,t){let n=(0,q.useContext)(Rb),r=e.owner.threadSlug;return{release:i=>{cD.add(e.id),i&&t.every(t=>t.id===e.id||cD.has(t.id)||t.delivery?.effect===`sending`)&&(lD.add(r),Di(r),(n?.sent??n?.dismiss)?.())},rollback:()=>{cD.delete(e.id),lD.delete(r)&&(Da(r),n?.cancel())}}}function dD({record:e,autoFocus:t=!1,siblings:n}){let r=ct(),i=ue(),a=uD(e,n),o=(0,q.useId)(),s=(0,q.useRef)(null),c=(0,q.useRef)(new Map),l=e.payload.kind===`mcp-elicitation-form`||e.payload.kind===`agent-question`?e.payload.fields:[],u=l.some(e=>e.secret),d=yn(),f=l.filter(e=>!e.secret&&(e.input===`text`||e.input===`multiline`)).map(t=>jr.interaction(d,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.id)),p=Es(f),[m,h]=(0,q.useState)(()=>JE(l)),g=(0,q.useMemo)(()=>{let t={...m};return l.forEach(n=>{if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=jr.interaction(d,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id);t[n.id]=p.get(r)??``}}),t},[l,m,p,d,e.id,e.owner]),[_,v]=(0,q.useState)({}),[y,b]=(0,q.useState)(),[x,S]=(0,q.useState)(),[C,w]=(0,q.useState)(!1),[T,E]=(0,q.useState)(),[D,O]=(0,q.useState)(!1),k=FE(e.delivery?.effect),A=(0,q.useMemo)(()=>WE(e),[e]).filter(e=>!(u&&e.requiresValues)),j=e.allowedDecisions.length-A.length,M=(0,q.useCallback)(t=>{for(let n of l)if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=t[n.id];typeof r==`string`&&ls.set(jr.interaction(d,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id),r)}h(t)},[l,d,e.id,e.owner]);(0,q.useEffect)(()=>{if(!t)return;let e=document.activeElement;e&&e!==document.body||requestAnimationFrame(()=>s.current?.focus())},[t,e.id]),(0,q.useEffect)(()=>{k.actionsEnabled||(E(void 0),O(!1))},[k.actionsEnabled]);let N=H({mutationFn:async({decision:t,values:n,responseId:r})=>{if(t.semantic===`cancel`&&e.provider.kind===`frizz`){let t=await U.interactionCancel({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision});return{effect:t.effect,interaction:t.interaction,waitingForProvider:!1}}let i=await U.interactionResolve({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision,responseId:r,decisionId:t.id,...n===void 0?{}:{values:n}});return{effect:i.effect,interaction:i.interaction,waitingForProvider:i.interaction.delivery?.effect===`sending`||i.effect===`queued`||i.effect===`already-queued`}},onSuccess:(t,n)=>{t.waitingForProvider||c.current.delete(ZE(n.decision.id,n.values)),b(void 0),E(void 0),O(!1),w(!0),f.forEach(e=>ls.clear(e)),S(t.waitingForProvider?`Response sent. Waiting for the provider to acknowledge it…`:`Request completed.`),Pi(r,t.interaction),r.setQueryData(Pa(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t.interaction}),r.invalidateQueries({queryKey:Ui(e.owner.threadSlug,e.owner.sessionId),exact:!0}),t.waitingForProvider&&window.setTimeout(()=>{r.invalidateQueries({queryKey:Ui(e.owner.threadSlug,e.owner.sessionId),exact:!0})},1e3)},onError:t=>{S(void 0),a.rollback(),b(nD(t)),so(r,e),U.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{Pi(r,t),r.setQueryData(Pa(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t}),t.delivery?.effect===`sending`?(b(void 0),S(void 0),w(!0)):t.delivery?.effect===`reconnect-required`?(b(void 0),S(void 0)):(t.lifecycle!==`pending`||t.recordRevision!==e.recordRevision)&&(b(void 0),S(t.lifecycle===`expired`?`This request expired.`:`This request changed in another client.`),r.invalidateQueries({queryKey:Ui(e.owner.threadSlug,e.owner.sessionId),exact:!0})),r.invalidateQueries({queryKey:Ui(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}});function P(e){if(!e.requiresValues){v({});return}let t=XE(l,g);return v(t.errors),t.formError?(b(t.formError),null):t.values?t.values:null}function F(e,t=!1){if(!k.actionsEnabled||N.isPending||C)return;b(void 0);let n=P(e);if(n===null)return;if(e.durable&&!t){E(e),O(!1);return}let r=ZE(e.id,n),i=c.current.get(r)??rD();c.current.set(r,i),a.release(sD(e)),N.mutate({decision:e,values:n,responseId:i})}let I=A.find(e=>e.requiresValues&&e.tone===`primary`);function L(e){e.preventDefault(),k.actionsEnabled&&I&&F(I)}return(0,X.jsxs)(`article`,{ref:s,tabIndex:-1,"aria-labelledby":o,"data-interaction-id":e.id,"data-interaction-kind":e.payload.kind,"data-delivery-effect":e.delivery?.effect,className:`min-w-0 ${um} border border-question-border bg-question outline-none focus-visible:ring-2 focus-visible:ring-focus-accent-60`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 border-b border-question-border px-4 py-3`,children:[(0,X.jsx)(Ec,{"aria-hidden":`true`,size:16,className:`shrink-0 text-accent`}),(0,X.jsx)(`h3`,{id:o,className:`min-w-0 flex-1 break-words text-[14px] font-semibold leading-snug text-fg`,children:e.payload.title})]}),(0,X.jsx)(`form`,{onSubmit:L,onKeyDown:e=>{e.target instanceof HTMLButtonElement||Hr({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),k.actionsEnabled&&I&&F(I))},className:`min-w-0 px-4 py-3.5`,noValidate:!0,children:(0,X.jsxs)(`fieldset`,{disabled:!k.actionsEnabled,className:`min-w-0 border-0 p-0`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`Interaction request`}),(0,X.jsx)(pD,{record:e,instanceId:o,draft:g,setDraft:M,errors:_,autoFocus:t}),u&&(0,X.jsxs)(`div`,{"data-secret-fallback":!0,className:`mt-3 rounded-md border border-attention-fill/35 bg-attention-fill/[0.07] p-3 text-[12px] leading-snug text-attention-soft-90`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(dc,{"aria-hidden":`true`,size:14,className:`mt-0.5 shrink-0`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-medium`,children:`Secret input is unavailable in this page.`}),(0,X.jsx)(`div`,{className:`mt-1 text-attention-soft-70`,children:`Frizz will not persist or send secret values through the current RPC.`})]})]}),(0,X.jsx)(`div`,{className:`mt-2 font-medium`,children:`Use the provider's trusted secret-input flow. The thread terminal cannot answer this typed request.`})]}),j>0&&(0,X.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-md border border-attention-fill/25 bg-attention-fill/[0.05] px-3 py-2 text-[11px] leading-snug text-attention-soft-75`,children:[(0,X.jsx)(Pt,{"aria-hidden":`true`,size:13,className:`mt-0.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[j===1?`One advertised choice`:`${j} advertised choices`,` cannot be safely labeled or delivered in Frizz and is not shown.`]})]}),T&&(0,X.jsxs)(`div`,{"data-durable-confirmation":!0,role:`group`,"aria-label":`Confirm ${T.label}`,className:`mt-3 rounded-md border border-attention/45 bg-attention-fill/[0.08] p-3`,children:[(0,X.jsx)(`div`,{className:`text-[12px] font-semibold text-attention-soft`,children:`This approval persists beyond the current request.`}),(0,X.jsx)(`div`,{className:`mt-1 text-[11px] leading-snug text-attention-soft-75`,children:T.scope}),(0,X.jsxs)(`label`,{className:`mt-2.5 flex cursor-pointer items-start gap-2 text-[11px] leading-snug text-fg/85`,children:[(0,X.jsx)(`input`,{type:`checkbox`,autoFocus:!0,checked:D,onChange:e=>O(e.target.checked),className:`mt-0.5 accent-[var(--color-accent)]`}),(0,X.jsx)(`span`,{children:`I understand this may authorize later matching actions in this session.`})]}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-start gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>{E(void 0),O(!1)},className:`rounded-md border border-border px-2.5 py-1.5 text-[11px] text-muted hover:bg-panel-2 hover:text-fg`,children:`Back`}),(0,X.jsxs)(`button`,{type:`button`,disabled:!D||N.isPending,onClick:()=>F(T,!0),className:`rounded-md border border-attention/50 bg-attention-fill/15 px-2.5 py-1.5 text-[11px] font-semibold text-attention-faint hover:bg-attention-fill/25 disabled:opacity-35`,children:[`Confirm `,T.label.toLowerCase()]})]})]}),y&&(0,X.jsx)(`div`,{role:`alert`,className:`mt-3 break-words text-[11px] leading-snug text-danger-soft`,children:y}),(k.status??x)&&(0,X.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`mt-3 text-[11px] leading-snug text-muted`,children:k.status??x}),i&&(0,X.jsxs)(ys,{className:`mt-3 text-[12px] text-muted`,children:[`This has to be answered on `,i,`.`]}),k.actionsEnabled&&!T&&!C&&A.length>0&&!i&&(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap justify-start gap-2`,children:[A.map(e=>(0,X.jsxs)(`button`,{type:e===I?`submit`:`button`,"data-interaction-decision":e.id,disabled:N.isPending,"aria-describedby":e.durable?`${o}-scope-${e.id}`:void 0,onClick:e===I?void 0:()=>F(e),className:fD(e),children:[N.isPending?`Sending…`:e.label,e.durable&&(0,X.jsx)(`span`,{className:`sr-only`,children:`; persistent approval`})]},e.id)),A.filter(e=>e.durable).map(e=>(0,X.jsx)(`span`,{id:`${o}-scope-${e.id}`,className:`sr-only`,children:e.scope},`scope-${e.id}`))]}),!mD.has(e.payload.kind)&&(0,X.jsx)(_D,{record:e})]})})]})}function fD(e){let t=`rounded-md border px-2.5 py-1.5 text-[11px] font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-focus-ink-50 disabled:opacity-40`;return e.tone===`primary`?`${t} border-border-strong bg-panel-2 text-fg hover:bg-inset`:e.tone===`danger`?`${t} border-danger/35 bg-danger-fill/[0.07] text-danger-faint hover:bg-danger-fill/15`:`${t} border-border bg-panel text-muted hover:bg-panel-2 hover:text-fg`}function pD({record:e,instanceId:t,draft:n,setDraft:r,errors:i,autoFocus:a}){let o=e.payload,s=(e,t)=>r(YE(n,e,t)),c;return c=o.kind===`command-approval`||o.kind===`file-approval`||o.kind===`permission-approval`?(0,X.jsx)(EE,{payload:o}):o.kind===`mcp-elicitation-url`?(0,X.jsx)(gD,{url:o.url}):(0,X.jsx)(vD,{instanceId:t,fields:o.fields,draft:n,setValue:s,errors:i,autoFocus:a}),(0,X.jsxs)(X.Fragment,{children:[`message`in o&&o.message&&(0,X.jsx)(hD,{text:o.message}),(0,X.jsx)(`div`,{className:`message`in o&&o.message?`mt-3`:``,children:c})]})}var mD=new Set([`command-approval`,`file-approval`,`permission-approval`]);function hD({text:e}){return e.length>600||e.split(`
|
|
136
|
-
`).length>6?(0,X.jsxs)(`details`,{className:`rounded-md border border-border/70 bg-panel/60`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer px-2.5 py-2 text-[11px] text-muted outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-50`,children:`Request message`}),(0,X.jsx)(`div`,{className:`max-h-52 overflow-auto border-t border-border/60 px-2.5 py-2 whitespace-pre-wrap break-words text-[12px] leading-relaxed text-fg/80`,children:e})]}):(0,X.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-[12px] leading-relaxed text-fg/80`,children:e})}function gD({url:e}){let t=ha(e,location.href);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-[11px] font-medium text-fg`,children:`Open this page to continue`}),(0,X.jsx)(`code`,{className:`mt-1.5 block max-h-24 overflow-auto break-all rounded-md border border-border bg-bg/40 px-2.5 py-2 font-mono-keep text-[10.5px] text-fg/80`,children:e}),t?(0,X.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-border bg-panel px-2.5 py-1.5 text-[11px] font-medium text-fg hover:bg-panel-2`,children:[(0,X.jsx)(sc,{"aria-hidden":`true`,size:12}),`Open page`]}):(0,X.jsx)(`div`,{role:`alert`,className:`mt-1.5 break-words text-[11px] text-danger-soft`,children:`This request did not provide a safe http(s) URL.`})]})}function _D({record:e}){return(0,X.jsxs)(`details`,{className:`mt-3 border-t border-border/50 pt-2 text-[10.5px] text-muted-70`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer w-fit outline-none hover:text-muted focus-visible:ring-1 focus-visible:ring-focus-ink-50`,children:`Request details`}),(0,X.jsxs)(`dl`,{className:`mt-2 grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1`,children:[(0,X.jsx)(`dt`,{children:`Provider`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:GE(e.provider.kind)}),e.provider.name&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{children:`Reported name`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.provider.name})]}),e.provider.version&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{children:`Reported version`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.provider.version})]}),(0,X.jsx)(`dt`,{children:`Source`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:KE(e.source.kind)}),e.source.label&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{children:`Reported source`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.source.label})]}),(0,X.jsx)(`dt`,{children:`Scope`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:`This thread · this request`}),e.expiresAt&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{children:`Expires`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.expiresAt})]})]})]})}function vD({instanceId:e,fields:t,draft:n,setValue:r,errors:i,autoFocus:a}){let o=t.findIndex(e=>!e.secret);return(0,X.jsxs)(`fieldset`,{className:`min-w-0`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`Requested information`}),(0,X.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:t.map((t,s)=>(0,X.jsx)(yD,{instanceId:e,field:t,value:n[t.id],setValue:e=>r(t.id,e),error:i[t.id],autoFocus:a&&s===o},t.id))})]})}function yD({instanceId:e,field:t,value:n,setValue:r,error:i,autoFocus:a}){let o=`${e}-${t.id}`,s=t.description?`${o}-description`:void 0,c=i?`${o}-error`:void 0,l=[s,c].filter(Boolean).join(` `)||void 0,u=(0,X.jsxs)(X.Fragment,{children:[t.label,t.required&&(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`ml-0.5 text-accent`,children:`*`})]}),d=`mt-1 w-full min-w-0 rounded-md border border-border bg-bg/45 px-2.5 py-2 text-[12px] text-fg outline-none focus:border-accent focus:ring-1 focus:ring-focus-accent-40`,f;if(t.secret)f=(0,X.jsx)(`div`,{className:`mt-1 text-[11px] text-attention-soft-70`,children:`Use the secure fallback below.`});else if(t.input===`multiline`)f=(0,X.jsx)(`textarea`,{id:o,name:t.id,"data-1p-ignore":!0,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,minLength:t.minLength,maxLength:t.maxLength,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,rows:4,className:`${d} resize-y`});else if(t.input===`text`){let e=t.format===`email`?`email`:t.format===`uri`?`url`:t.format===`date`?`date`:`text`;f=(0,X.jsx)(`input`,{id:o,name:t.id,type:e,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,minLength:t.minLength,maxLength:t.maxLength,placeholder:t.format===`date-time`?`2026-07-13T12:00:00Z`:void 0,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,className:d})}else if(t.input===`number`||t.input===`integer`)f=(0,X.jsx)(`input`,{id:o,name:t.id,type:`number`,step:t.input===`integer`?1:`any`,min:t.minimum,max:t.maximum,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,className:d});else if(t.input===`boolean`)f=(0,X.jsxs)(`label`,{htmlFor:o,className:`mt-1 flex cursor-pointer items-center gap-2 rounded-md border border-border bg-bg/30 px-2.5 py-2 text-[12px] text-fg/85`,children:[(0,X.jsx)(`input`,{id:o,name:t.id,type:`checkbox`,checked:n===!0,onChange:e=>r(e.target.checked),"aria-describedby":l,autoFocus:a,className:`accent-[var(--color-accent)]`}),(0,X.jsx)(`span`,{children:u})]});else if(t.input===`select`)f=(0,X.jsxs)(`select`,{id:o,name:t.id,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,className:d,children:[(0,X.jsx)(`option`,{value:``,children:`Choose an option…`}),t.options.map((e,t)=>(0,X.jsx)(`option`,{value:String(t),children:e.label},t))]});else if(t.input===`multi-select`){let e=Array.isArray(n)?n:[];f=(0,X.jsxs)(`fieldset`,{id:o,"aria-describedby":l,className:`mt-1 rounded-md border border-border bg-bg/30 px-2.5 py-2`,children:[(0,X.jsx)(`legend`,{className:`px-1 text-[11px] font-medium text-fg/85`,children:u}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t.options.map((n,i)=>{let o=String(i);return(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-[12px] text-fg/85`,children:[(0,X.jsx)(`input`,{type:`checkbox`,name:t.id,value:o,checked:e.includes(o),onChange:t=>r(t.target.checked?[...e,o]:e.filter(e=>e!==o)),autoFocus:a&&i===0,className:`mt-0.5 accent-[var(--color-accent)]`}),(0,X.jsx)(`span`,{children:n.label})]},o)})})]})}return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[t.secret?(0,X.jsx)(`div`,{className:`text-[11px] font-medium text-fg/85`,children:u}):t.input!==`boolean`&&t.input!==`multi-select`?(0,X.jsx)(`label`,{htmlFor:o,className:`block text-[11px] font-medium text-fg/85`,children:u}):null,t.description&&(0,X.jsx)(`div`,{id:s,className:`mt-0.5 whitespace-pre-wrap break-words text-[10.5px] leading-snug text-muted`,children:t.description}),f,i&&(0,X.jsx)(`div`,{id:c,role:`alert`,className:`mt-1 text-[10.5px] text-danger-soft`,children:i})]})}function bD(e,t=Date.now()){return e!==void 0&&ve(e,t)!==void 0}function xD(){let[e,t]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function SD({thread:e}){let t=xD(),[n,r]=(0,q.useState)(!1),i=ve(e,t);if(!i)return null;let a=Date.parse(i),o=vn(i,t).replace(/^(Today|Tomorrow)/,e=>e.toLowerCase()),s=e.snoozePrompt?.trim();async function c(){r(!0);try{await U.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:null,prompt:null}),G(`Snooze cleared`)}catch(e){G((e instanceof Error?e.message:`Wake failed`).slice(0,100))}finally{r(!1)}}return(0,X.jsxs)(wm,{"data-snooze-card":!0,icon:bi,label:`Snoozed`,children:[(0,X.jsx)(`div`,{"data-snooze-countdown":!0,title:new Date(a).toLocaleString(),className:`text-[22px] font-semibold leading-8 tracking-tight text-fg tabular-nums`,children:Ln(a-t)}),(0,X.jsx)(`p`,{className:Tm,children:s?(0,X.jsxs)(X.Fragment,{children:[`Resumes `,o,` and sends: “`,z(s),`”`]}):(0,X.jsxs)(X.Fragment,{children:[`Returns to the queue `,o,`.`]})}),e.foreign!==!0&&(0,X.jsx)(Em,{children:(0,X.jsx)(`button`,{type:`button`,"data-snooze-wake-now":!0,disabled:n,onClick:()=>void c(),className:`${jm} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}function CD(e){return e?.foreign&&e.pendingInteraction!==!0?e.pendingAsk:void 0}function wD(e,t){return e?.actionableInteraction===!0?!1:t||e?.runtime===`perm-prompt`}async function TD({slug:e,cursor:t,expectedKey:n,queryClient:r,refetch:i,beforePrepend:a}){let o=await U.threadTranscriptEarlier({slug:e,cursor:t}),s=r.getQueryData([`transcript`,e]);return!s?.transcriptKey||s.transcriptKey!==n||o.transcriptKey!==n?(await i(),G(`Transcript changed while loading history; refreshed the current session`),null):(a?.(o),r.setQueryData([`transcript`,e],$r(s,o)),o)}function ED(e){let t=Math.max(e.scrollHeight-e.clientHeight,0),n=t-e.scrollTop,r=e.scrollHeight!==e.previousScrollHeight||e.previousClientHeight!==void 0&&e.previousClientHeight>=0&&e.clientHeight!==e.previousClientHeight,i=r&&!e.readerMoved?e.following||n<=1:n<=4;return!i||!r||t<=0||n<=1?{following:i,scrollTop:null}:{following:i,scrollTop:t}}function DD(e){let t=e.scrollTop>640?!0:e.armed,n=t&&e.readerMoved&&e.scrollTop<=480&&e.hasEarlier&&!e.loading;return{armed:n?!1:t,shouldLoad:n}}function OD(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function kD(e,t,n){let r=[],i=new Map,a=null;return e.forEach((e,o)=>{if(Mo(e)||t(e))return;let s=e.sourceId??OD(e),c=i.get(s)??0;i.set(s,c+1),r.push({key:c===0?s:`${s}:${c}`,message:e,messageIndex:o,gap:a===null?0:n(a,e)}),a=e}),r}function AD(e,t,n){let r=e[t];if(!r||r.kind!==`event`||r.boundary!==`rest`)return!1;for(let r=t+1;r<e.length;r++){let t=e[r];if(!(Mo(t)||n(t)))return!!t.boundary||t.wake===!0||dE(t)!==void 0}return!0}function jD(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!AD(n,r,t))}var MD=(0,q.createContext)(null);function ND(){let e=(0,q.useContext)(Lb),t=(0,q.useContext)(MD);return e??t}function PD({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1,pane:i}){Se(e);let a=Cr()&&n!==void 0,{splitFileViewer:o}=_t(W);return(0,X.jsx)(FD,{slug:e,phone:a,railBeside:(i?i.railBeside===!0:r)&&o,pane:i,header:a?(0,X.jsx)(zT,{slug:e,onClose:n}):(0,X.jsx)(QD,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r,pane:i})})}function FD({slug:e,phone:t=!1,railBeside:n=!1,header:r,pane:i}){let a=Se(e),o=et(e,{poll:a?.runtime===`running`||a?.runtime===`spawning`}),s=ct(),c=(0,q.useRef)(!1),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(null),{messages:p,openQuestions:m,settledQuestions:h,transcriptShells:g}=QS(a,(0,q.useMemo)(()=>o.data?.messages??[],[o.data])),_=(0,q.useMemo)(()=>t?{numberOf:e=>m.findIndex(t=>t.id===e)+1}:null,[t,m]),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(void 0);if(i?.queueWindow&&b===void 0&&p.length>0){let e=v_(p);x(e>0?p[e]?.sourceId??null:null)}let S=b?Math.max(0,p.findIndex(e=>e.sourceId===b)):0,C=ue(),w=(0,q.useMemo)(()=>C?m.filter(e=>!Qx(e.spec)):m,[C,m]),T=Ii()[e],E=(0,q.useMemo)(()=>Wr(p,T===void 0?void 0:new Date(T).toISOString()),[p,T]),D=(0,q.useMemo)(()=>Bb(E),[E]),O=(0,q.useMemo)(()=>lo(a,E,D,T),[a,E,D,T]),k=Ar(O,E),A=k?.runtime===`running`||k?.runtime===`spawning`,j=O===a?void 0:O?.lastUserAt,M=sC({slug:e,thread:k,messages:p,openQuestions:m,settledQuestions:h},i?{exit:i.exit}:void 0),{inFlightAnswers:N}=M.transcript,P=(0,q.useRef)(null),[F,I]=(0,q.useState)(null),L=o.data?.messages.length??0,R=QC({pending:o.isPending,failed:o.isError},{running:A,adoptable:ZC(k)}),z=(0,q.useCallback)(async()=>{if(c.current)return;let t=s.getQueryData([`transcript`,e]),n=t?.beforeCursor,r=t?.transcriptKey;if(!(!t?.hasEarlier||!n||!r)){c.current=!0,u(!0),f(null);try{await TD({slug:e,cursor:n,expectedKey:r,queryClient:s,refetch:()=>o.refetch()})}catch(e){let t=e instanceof Error?e.message:`Could not load earlier transcript history`;f(t)}finally{c.current=!1,u(!1)}}},[o,s,e]),B=(0,q.useCallback)(()=>{if(S===0)return void z();let e=Ta(p,S);x(e!==null&&e>0?p[e]?.sourceId??null:null)},[z,p,S]);return(0,X.jsxs)(cC,{surface:M,className:`flex-1 min-h-0 flex flex-col`,children:[r,(0,X.jsx)(pS.Provider,{value:_,children:(0,X.jsxs)(`div`,{"data-drawer-scroll-ready":o.isPending?`false`:`true`,className:`flex-1 min-h-0 flex flex-col overflow-hidden outline-none`,children:[(0,X.jsxs)(`div`,{className:`relative min-h-0 flex-1 flex flex-col`,children:[(0,X.jsx)(`div`,{ref:P,"data-drawer-transcript-scroll":!0,"data-virtualized-transcript-scroll":!0,tabIndex:0,role:`region`,"aria-label":`Thread conversation`,"aria-busy":l?!0:void 0,className:`relative min-h-0 flex-1 overflow-y-auto pb-3 outline-none [overflow-anchor:none] focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-60`,children:L>0?(0,X.jsx)(XD,{slug:e,transcriptRef:P,transcriptKey:o.data?.transcriptKey,messages:E,steerSince:j,transportFallback:o.transportFallback,isFetching:o.isFetching,refresh:()=>void o.refetch(),retryLiveUpdates:o.retryLiveUpdates,hasEarlier:o.data?.hasEarlier===!0,beforeCursor:o.data?.beforeCursor,loadingEarlier:l,earlierError:d,loadEarlier:B,jumpOverlay:F,openAtLastMessage:(t||i!==void 0)&&!A,windowStart:S,openAtTop:i?.queueWindow===!0,sentAt:i?T:void 0}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(iD,{thread:k,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,X.jsx)(XS,{thread:k,inFlight:N,className:`px-6 pt-5`}),o.transportFallback&&(0,X.jsx)(HD,{fallback:o.transportFallback,isFetching:o.isFetching,onRefresh:()=>void o.refetch(),onRetryLive:o.retryLiveUpdates,className:`mx-6 mt-3`}),(0,X.jsx)(`div`,{className:`flex min-h-full flex-col px-6 py-5`,children:(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted`,children:R===`loading`?(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(kk,{}),` Loading…`]}):R===`failed`?(0,X.jsx)(UD,{error:o.error,retry:()=>o.refetch()}):R===`starting`?(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(kk,{}),` Session starting…`]}):R===`adopt`?(0,X.jsxs)(`div`,{className:`text-center`,children:[(0,X.jsx)(`p`,{className:`mb-3`,children:`No session is attached to this thread yet.`}),(0,X.jsx)(`button`,{className:`btn-ghost border border-border text-[12px]`,onClick:()=>U.adoptThread({slug:e}).catch(()=>{}),children:`Start a session on this thread`})]}):`No conversation yet.`})})]})}),(0,X.jsx)(`div`,{ref:I,"data-transcript-overlay":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-end p-4 [&>*]:pointer-events-auto`})]}),(0,X.jsx)(`div`,{"data-thread-chat-footer":!0,className:`z-10 shrink-0 border-t border-border/60 bg-panel ${t?``:`pb-[env(safe-area-inset-bottom)]`}`,children:(0,X.jsx)(Uw,{slug:e,above:t||n||!k?void 0:(0,X.jsx)(aT,{thread:k,transcriptShells:g}),phoneBarOverride:t&&w.length>0?e=>(0,X.jsx)(vS,{count:w.length,onAnswer:()=>y(!0),onReply:C?void 0:e.editReply}):void 0,phoneChrome:t})}),t&&v&&(0,X.jsx)(bC,{questions:w,onClose:()=>y(!1)})]})})]})}var ID=700,LD=`button, a[href], input, textarea, select, summary, label, [role='button'], [role='checkbox'], [role='radio'], [contenteditable='true']`;function RD(e){return e.target instanceof Element&&e.target.closest(LD)!==null}var zD=250,BD=900,VD=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function HD({fallback:e,isFetching:t,onRefresh:n,onRetryLive:r,className:i=``}){return(0,X.jsxs)(`div`,{"data-transcript-sync-fallback":!0,className:`flex flex-wrap items-center gap-2.5 ${um} border border-border-strong bg-panel-2 px-4 py-2.5 text-[12px] ${i}`,title:e.kind===`payload-too-large`?`Live payload ${e.actualBytes} bytes; socket limit ${e.maxBytes} bytes`:`Transcript read budget reached (${e.scope}); retry after about ${e.retryAfterMs}ms`,children:[(0,X.jsx)(Pt,{size:13,className:`shrink-0 text-muted`}),(0,X.jsxs)(`div`,{className:`min-w-[180px] flex-1 leading-snug text-fg/85`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Live transcript updates paused.`}),` `,e.kind===`payload-too-large`?`The transcript is too large for push; it refreshes over HTTP each time the thread moves.`:`The live read budget was reached; the last complete copy remains visible. Retry in a moment.`]}),(0,X.jsx)(`button`,{type:`button`,disabled:t,onClick:n,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel disabled:opacity-40`,children:t?`Refreshing…`:`Refresh once`}),(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel`,children:`Retry live`})]})}function UD({error:e,retry:t}){let[n,r]=(0,q.useState)(!1),i=(e instanceof Error?e.message:String(e??``)).slice(0,200);return(0,X.jsxs)(`div`,{"data-transcript-read-failed":!0,role:`status`,className:`text-center`,children:[(0,X.jsx)(`p`,{children:`Could not load this conversation.`}),i&&(0,X.jsx)(`p`,{className:`font-mono-keep mt-1.5 break-words text-[11.5px]`,children:i}),(0,X.jsx)(`button`,{type:`button`,disabled:n,className:`btn-ghost mt-3 border border-border text-[12px] disabled:opacity-40`,onClick:()=>{r(!0),t().finally(()=>r(!1))},children:n?`Retrying…`:`Retry`})]})}function WD({thread:e,showWorking:t,registeredDone:n,restedCard:r,errorVisible:i}){return e?.providerError?.retrying?`provider-error`:e?.providerFault&&!e.foreign?`provider-fault`:e?.limitPause&&!e.foreign?`limit-pause`:CD(e)?`pending-ask`:wD(e,t)?`working`:e?.providerError?i?null:`provider-error`:bD(e)?`snooze`:zy(e)?`resting`:n?`registered-done`:r?`rested`:null}function GD(e,t){return WD(e)===`working`?xO(t):14}function KD({state:e,slug:t,retryText:n,liveRuntimeStart:r,liveActivityLabel:i,liveToolRun:a,onRestingExit:o,onRestingExitFailed:s,onRestingReplied:c,wrap:l}){let u=e.thread;switch(WD(e)){case`provider-fault`:return(0,X.jsx)(yk,{slug:t,sessionId:u.sessionId,fault:u.providerFault,retryText:n});case`provider-error`:return(0,X.jsx)(lk,{error:u.providerError});case`limit-pause`:return(0,X.jsx)(bk,{slug:t,sessionId:u.sessionId,pause:u.limitPause});case`pending-ask`:return(0,X.jsx)(Ck,{ask:CD(u)});case`working`:return(0,X.jsx)(Ak,{since:u?.lastUserAt,startedAt:r,activityLabel:i,run:a});case`snooze`:return(0,X.jsx)(SD,{thread:u});case`resting`:return(0,X.jsx)(Hy,{thread:u,onSnooze:o,onSnoozeFailed:s,onReplied:c??o,onReplyFailed:s});case`registered-done`:return(0,X.jsx)(qD,{thread:u,wrap:l});case`rested`:return(0,X.jsx)(Kg,{thread:u});default:return null}}function qD({thread:e,wrap:t}){let n=Wg(e);return n===void 0?null:(0,X.jsx)(vk,{fenceKind:`done`,body:n,hints:e.lastFence.hints,wrap:t})}function JD(e,t,n,r){let{thread:i,messages:a,running:o,lastAgentIdx:s}=e,c=Ae(),l=(0,q.useMemo)(()=>__(a),[a]);return(0,q.useMemo)(()=>{let e=s>=0?a[s]:void 0,u={thread:i,showWorking:o,registeredDone:Bg(i,e?.text),restedCard:Gg(i,e?.text,e?.refusedFences),errorVisible:qg(t.map(e=>e.message),i?.providerError)},d=WD(u),f=o?Zt(t):void 0;return{state:u,rung:d,shown:d!==null||!!i?.permPolicy,gap:GD(u,n.map(e=>e.message)),retryText:l>=0?a[l]?.text:void 0,liveRuntimeStart:o?hO(rr(t),r):void 0,liveActivityLabel:f?Xa(f,c):void 0,liveToolRun:o?yr(t):void 0}},[i,a,o,s,l,t,n,r,c])}function YD({tail:e,wrap:t}){let n=(0,q.useContext)(Lb),r=(0,q.useContext)(Rb),i=e.state.thread;return!e.shown||!n?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ib,{h:e.gap}),(0,X.jsx)(KD,{state:e.state,slug:n,retryText:e.retryText,liveRuntimeStart:e.liveRuntimeStart,liveActivityLabel:e.liveActivityLabel,liveToolRun:e.liveToolRun,onRestingExit:r?.dismiss,onRestingExitFailed:r?.cancel,onRestingReplied:r?.sent,wrap:t}),i?.permPolicy?(0,X.jsx)(`div`,{className:e.rung===null?``:`mt-3`,children:(0,X.jsx)(xk,{policy:i.permPolicy,denies:i.permDenies})}):null]})}function XD({slug:e,transcriptRef:t,transcriptKey:n,messages:r,steerSince:i,transportFallback:a,isFetching:o,refresh:s,retryLiveUpdates:c,hasEarlier:l,beforeCursor:u,loadingEarlier:d,earlierError:f,loadEarlier:p,jumpOverlay:m,openAtLastMessage:h=!1,windowStart:g=0,openAtTop:_=!1,sentAt:v}){let y=rC(),{thread:b,running:x,lastAgentIdx:S,awaitingCut:C,restingShown:w,heldIdx:T,paired:E,inFlightAnswers:D,settledPlacement:O,openQuestions:k}=y,A=(0,q.useMemo)(()=>U_(y.placement,g),[y.placement,g]),j=(0,q.useMemo)(()=>{let e=Yn(r);return g>0?e.filter(e=>e.messageIndex>=g):e},[r,g]),M=(0,q.useMemo)(()=>{let e=x?Qe(j):j;return jD(e,gO(e,C,w,T))},[j,x,C,w,T]),N=(0,q.useMemo)(()=>{let e=kD(M.map(e=>e.message),gO(M,C,w,T),fO);return e.map((t,n)=>({...t,messageIndex:M[t.messageIndex].messageIndex,restGap:uO(t.message,e[n+1]?.message)}))},[M,C,w,T]),P=JD(y,j,M,i),F=P.shown,I=(0,q.useMemo)(()=>{let e=[],t=new Map,n=r.length-1,i=e=>{let t=-1;for(let n=0;n<N.length&&!(N[n].messageIndex>e);n++)t=n;return t},a=k.filter(e=>!A.placedIds.has(e.id));for(let[o,s]of E_(r,a,{from:g})){if(o>=n){e.push(...s);continue}let r=i(o),a=t.get(r);a?a.push(...s):t.set(r,[...s])}let o=!1,s=new Set;for(let e of W_(r,A)){if(e>=n){o=!0;continue}let r=i(e);s.add(r),t.has(r)||t.set(r,[])}return{byRow:t,tail:e,tailSend:o,sendRows:s}},[N,r,k,A,g]),L=(0,q.useMemo)(()=>{let e=new Map;for(let[t,n]of O.anchored){let r=-1;for(let e=0;e<N.length&&!(N[e].messageIndex>t);e++)r=e;if(r<0)continue;let i=e.get(r);i?i.push(...n):e.set(r,[...n])}return e},[N,O.anchored]),R=(0,q.useMemo)(()=>{let e=[{key:`head-anchor`,kind:`head-anchor`}];a&&e.push({key:`transport-fallback`,kind:`transport-fallback`}),(l||d||f||g>0)&&e.push({key:`earlier-history:${u??`complete`}`,kind:`earlier-history`});let t=I.byRow.get(-1);t&&e.push({key:`questions:head`,kind:`questions`,questions:t,send:I.sendRows.has(-1)}),N.forEach((t,n)=>{e.push({...t,kind:`message`});let r=L.get(n);r&&e.push({key:`settled-questions:${t.key}`,kind:`settled-questions`,questions:r});let i=I.byRow.get(n);i&&e.push({key:`questions:${t.key}`,kind:`questions`,questions:i,send:I.sendRows.has(n)})}),e.push({key:`interactions`,kind:`interactions`}),F&&e.push({key:`runtime-status`,kind:`runtime-status`});let n=null;return r.forEach((t,r)=>{if(!Mo(t))return;let i=`queued:${t.deliveryId??t.sourceId??r}`,a=n?fO(n,t):F||N.length>0?14:0;e.push({key:i,kind:`queued`,message:t,messageIndex:r,gap:a}),n=t}),n&&e.push({key:`queued-send-now`,kind:`queued-send-now`}),e},[u,f,l,F,d,N,r,I,L,a,g]),z=(0,q.useRef)(null),B=Ki({count:R.length,getScrollElement:()=>t.current,getItemKey:e=>R[e]?.key??e,estimateSize:e=>{let t=R[e];return t?t.kind===`head-anchor`||t.kind===`interactions`?1:t.kind===`queued-send-now`?22:t.kind===`earlier-history`?42:t.kind===`transport-fallback`?76:t.kind===`runtime-status`?54:t.kind===`questions`?220:t.kind===`settled-questions`?140:t.kind===`message`?108+t.gap:82+t.gap:80},overscan:8,rangeExtractor:e=>{let t=Li(e),n=z.current?.rowKey,r=n?R.findIndex(e=>e.key===n):-1;if(r<0)return t;let i=[];for(let e=Math.max(0,r-2);e<=Math.min(R.length-1,r+24);e++)i.push(e);return[...new Set([...t,...i])].sort((e,t)=>e-t)},paddingStart:20,paddingEnd:20,anchorTo:`end`,scrollEndThreshold:4,scrollToFn:(e,{adjustments:t,behavior:n},r)=>{let i=r.scrollElement;i&&i.scrollTo({top:t===void 0?e:i.scrollTop+t,behavior:n})}}),[ee,te]=(0,q.useState)(!0),ne=(0,q.useRef)(!0),re=(0,q.useRef)(-1),ie=(0,q.useRef)(-1),ae=(0,q.useRef)(0),oe=(0,q.useRef)(null),se=(0,q.useRef)(!1),ce=(0,q.useRef)(!1),le=(0,q.useRef)(!0),ue=(0,q.useRef)(void 0),de=(0,q.useRef)(null),fe=(0,q.useRef)(void 0),V=(0,q.useRef)(0),pe=(0,q.useRef)(0),H=(0,q.useCallback)(()=>{let e=t.current;if(e){let t=e.getBoundingClientRect().top,n=Array.from(e.querySelectorAll(`[data-transcript-source-id]`)).find(e=>e.getBoundingClientRect().bottom>t+1),r=n?.dataset.transcriptRowKey;n&&r&&(z.current={rowKey:r,viewportTop:n.getBoundingClientRect().top-t})}p()},[p,t]),me=(0,q.useCallback)((e,n)=>{let r=t.current;if(!r)return;let i=Array.from(r.querySelectorAll(`[data-transcript-source-id]`)).find(t=>t.dataset.transcriptSourceId===e);i&&(r.scrollTop+=i.getBoundingClientRect().top-n)},[t]);(0,q.useLayoutEffect)(()=>{if(!n||R.length===0||ue.current===n)return;ue.current=n,se.current=!1,ce.current=!1,le.current=!0;let r=ma(e)?.candidates.map(e=>({candidate:e,index:R.findIndex(t=>t.kind===`message`&&t.message.sourceId===e.sourceId)})).find(e=>e.index>=0),i=!r&&h&&S>=0?R.reduce((e,t,n)=>t.kind===`message`&&t.messageIndex<=S&&t.message.role===`assistant`&&t.message.kind!==`event`?n:e,-1):-1,a=requestAnimationFrame(()=>{if(!r&&(_||i>=0)){let e=_?null:R[i].key;_?t.current?.scrollTo({top:0}):B.scrollToIndex(i,{align:`start`,behavior:`instant`}),ne.current=!1,te(!1),se.current=!0;let n=performance.now()+BD;V.current=n;let r=()=>{let i=t.current;if(!i||performance.now()>=n||performance.now()<ae.current){V.current=0,pe.current=0,i&&i.scrollHeight-i.clientHeight-i.scrollTop<=4&&(ne.current=!0,re.current=i.scrollHeight,te(!0));return}if(e===null)i.scrollTop=0;else{let t=i.querySelector(`[data-transcript-row-key="${CSS.escape(e)}"]`);t&&(i.scrollTop+=t.getBoundingClientRect().top-i.getBoundingClientRect().top)}pe.current=requestAnimationFrame(r)};r();return}if(!r){B.scrollToEnd({behavior:`instant`}),te(!0),se.current=!0;return}B.scrollToIndex(r.index,{align:`start`,behavior:`instant`}),ne.current=!1,te(!1),se.current=!0;let e=performance.now()+zD;V.current=e;let n=()=>{performance.now()>=e||performance.now()<ae.current||(me(r.candidate.sourceId,r.candidate.screenTop),a=requestAnimationFrame(n))};n()});return()=>cancelAnimationFrame(a)},[me,R.length,e,n,B]),(0,q.useEffect)(()=>()=>cancelAnimationFrame(pe.current),[]);let he=(0,q.useRef)(v);(0,q.useEffect)(()=>{let e=v!==he.current;he.current=v;let n=t.current;!e||v===void 0||!n||(V.current=0,ne.current=!0,te(!0),n.scrollTop=n.scrollHeight)},[v,t]);let ge=(0,q.useCallback)(()=>{let e=t.current;if(!e)return null;let n=e.getBoundingClientRect().top,r=Array.from(e.querySelectorAll(`[data-transcript-row-key]`)).find(e=>e.getBoundingClientRect().bottom>n+1),i=r?.dataset.transcriptRowKey;return!r||!i?null:{rowKey:i,viewportTop:r.getBoundingClientRect().top-n}},[t]),_e=(0,q.useCallback)(e=>{let n=t.current;if(!n)return;let r=Array.from(n.querySelectorAll(`[data-transcript-row-key]`)).find(t=>t.dataset.transcriptRowKey===e.rowKey);if(!r)return;let i=r.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTop+=i-e.viewportTop},[t]),ve=N[0]?.key;(0,q.useLayoutEffect)(()=>{let e=fe.current;if(fe.current=ve,e===void 0||e===ve||!se.current||ne.current||z.current)return;let t=de.current;if(!t)return;_e(t);let n=()=>{if(performance.now()<ae.current)return;let e=de.current;e&&_e(e)},r=0,i=requestAnimationFrame(()=>{n(),r=requestAnimationFrame(n)});return()=>{cancelAnimationFrame(i),cancelAnimationFrame(r)}},[_e,ve]);let ye=(0,q.useCallback)(()=>{let e=t.current;if(!e||z.current||performance.now()<V.current)return;let n=ED({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,previousScrollHeight:re.current,previousClientHeight:ie.current,following:ne.current,readerMoved:performance.now()<ae.current});if(ne.current=n.following,n.scrollTop!==null&&(e.scrollTop=n.scrollTop),re.current=e.scrollHeight,ie.current=e.clientHeight,te(e=>e===n.following?e:n.following),VD&&!n.following&&performance.now()>=ae.current){let t=de.current,n=t&&Array.from(e.querySelectorAll(`[data-transcript-row-key]`)).find(e=>e.dataset.transcriptRowKey===t.rowKey);if(t&&n){let r=Math.round(n.getBoundingClientRect().top-e.getBoundingClientRect().top-t.viewportTop);Math.abs(r)>2&&console.warn(`[frizz] transcript moved ${r}px under a still reader — row=${t.rowKey}`)}}de.current=ge()??de.current},[ge,t]);(0,q.useLayoutEffect)(()=>{let e=oe.current;if(!e)return;let t=new Map(B.getVirtualItems().map(e=>[e.index,e.size])),n=[],r=0;for(let i of e.querySelectorAll(`:scope > [data-index]`)){let e=B.indexFromElement(i),a=Math.round(i.getBoundingClientRect().height),o=t.get(e);e<0||o===void 0||o===a||(n.push({index:e,size:a}),r+=a-o)}if(n.length!==0){e.style.height=`${B.getTotalSize()+r}px`;for(let{index:e,size:t}of n)B.resizeItem(e,t)}});let be=(0,q.useRef)(null);(0,q.useLayoutEffect)(()=>{let e=z.current,n=t.current;if(!e||!n||d)return;let r=()=>{let t=Array.from(n.querySelectorAll(`[data-transcript-row-key]`)).find(t=>t.dataset.transcriptRowKey===e.rowKey);if(!t){let t=R.findIndex(t=>t.key===e.rowKey),r=t>=0?B.getOffsetForIndex(t,`start`)?.[0]:void 0;return r!==void 0&&(n.scrollTop=r-e.viewportTop),!1}let r=t.getBoundingClientRect().top-n.getBoundingClientRect().top-e.viewportTop;return Math.abs(r)<.5?!0:(n.scrollTop+=r,!1)};if(r(),be.current?.anchor===e)return;let i=0,a=0,o=()=>{if(i=r()?i+1:0,a++,i>=2||a>=10){z.current===e&&(z.current=null),be.current=null;return}be.current&&(be.current.frame=requestAnimationFrame(o))};be.current={anchor:e,frame:requestAnimationFrame(o)}}),(0,q.useEffect)(()=>()=>{be.current&&cancelAnimationFrame(be.current.frame)},[]),(0,q.useLayoutEffect)(ye),(0,q.useEffect)(()=>{let e=oe.current;if(!e)return;let n=new ResizeObserver(ye);n.observe(e);let r=t.current;return r&&n.observe(r),()=>n.disconnect()},[ye,t]),(0,q.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{ye();let t=DD({armed:le.current,scrollTop:e.scrollTop,readerMoved:se.current&&ce.current,hasEarlier:l&&g===0,loading:d});le.current=t.armed,t.shouldLoad&&H()},r=()=>{ce.current=!0,ae.current=performance.now()+ID,requestAnimationFrame(n)},i=t=>{![`ArrowUp`,`PageUp`,`Home`,` `].includes(t.key)||RD(t)||(e.scrollTop<=480&&(le.current=!0),r())},a=t=>{t.deltaY<0&&e.scrollTop<=480&&(le.current=!0),r()},o=t=>{t.type===`touchstart`&&RD(t)||(e.scrollTop<=480&&(le.current=!0),r())},s=e=>{RD(e)||r()};e.addEventListener(`scroll`,n,{passive:!0}),e.addEventListener(`wheel`,a,{passive:!0}),e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`pointerdown`,s,{passive:!0}),e.addEventListener(`keydown`,i);let c=requestAnimationFrame(n);return()=>{cancelAnimationFrame(c),e.removeEventListener(`scroll`,n),e.removeEventListener(`wheel`,a),e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,o),e.removeEventListener(`pointerdown`,s),e.removeEventListener(`keydown`,i)}},[l,d,H,ye,t,g]);let xe=B.getVirtualItems(),Se=B.getTotalSize();return(0,X.jsxs)(`div`,{ref:oe,"data-virtualized-transcript":!0,"data-virtual-row-count":xe.length,className:`relative w-full`,style:{height:Se},children:[xe.map(e=>{let t=R[e.index];return t?(0,X.jsx)(`div`,{ref:B.measureElement,"data-index":e.index,"data-transcript-row-key":t.key,"data-transcript-source-id":t.kind===`message`?t.message.sourceId:void 0,className:`absolute left-0 top-0 w-full`,style:{transform:`translateY(${e.start}px)`},children:t.kind===`head-anchor`?null:t.kind===`interactions`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(iD,{thread:b,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,X.jsx)(XS,{thread:b,questions:I.tail,inFlight:D,showSend:I.tailSend,className:`px-6 pt-5`})]}):t.kind===`questions`?(0,X.jsx)(XS,{thread:b,questions:t.questions,showSend:t.send,className:`px-6 pt-5`}):t.kind===`settled-questions`?(0,X.jsx)(PS,{questions:t.questions,className:`px-6 pt-5`}):t.kind===`transport-fallback`?a?(0,X.jsx)(`div`,{className:`px-6 pt-3`,children:(0,X.jsx)(HD,{fallback:a,isFetching:o,onRefresh:s,onRetryLive:c})}):null:t.kind===`earlier-history`?(0,X.jsx)(`div`,{className:`flex min-h-10 items-center justify-center px-6 text-[11px] text-muted`,role:`status`,children:f?(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-2 text-center`,children:[(0,X.jsx)(`span`,{children:f}),(0,X.jsx)(`button`,{type:`button`,onClick:H,className:`rounded-md border border-border px-2 py-1 text-fg/90 hover:bg-panel-2`,children:`Retry`})]}):d?(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Ut,{size:12,className:`animate-spin`}),` Loading earlier messages…`]}):(0,X.jsx)(`button`,{type:`button`,onClick:H,className:`button-outline rounded-md px-2 py-1 outline-none hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:`Load earlier messages`})}):t.kind===`message`?(0,X.jsx)(`div`,{className:`relative flex flex-col px-6`,style:{paddingTop:t.gap},children:t.restGap?(0,X.jsx)(dO,{rest:t.message,at:t.restGap}):(0,X.jsx)(sk,{m:t.message,index:t.messageIndex,showSendButton:!0})}):t.kind===`runtime-status`?(0,X.jsx)(`div`,{className:`px-6`,children:(0,X.jsx)(YD,{tail:P})}):t.kind===`queued-send-now`?(0,X.jsx)(`div`,{className:`flex flex-col px-6`,children:(0,X.jsx)(ik,{})}):(0,X.jsx)(`div`,{className:`relative flex flex-col px-6`,style:{paddingTop:t.gap},children:(0,X.jsx)(ck,{m:t.message,paired:E[t.messageIndex]})})},t.key):null}),(0,X.jsx)(ZD,{overlay:m,hidden:ee,onJump:()=>B.scrollToEnd({behavior:`smooth`})})]})}function ZD({overlay:e,hidden:t,onJump:n}){return!e||t?null:(0,Fc.createPortal)((0,X.jsxs)(`button`,{type:`button`,"data-jump-to-latest":!0,onClick:n,className:`flex items-center gap-1.5 rounded-full border border-border-strong bg-elevated px-3 py-1.5 text-[11px] font-medium text-fg shadow-lg shadow-shadow-ink/30 hover:bg-panel-2`,children:[(0,X.jsx)(Zs,{size:12}),`Jump to latest`]}),e)}function QD({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1,pane:i}){let a=Se(e),o=H({mutationFn:()=>U.markComplete({slug:e})}),s=Lf(Re({queryKey:[`threadBody`,e],queryFn:()=>U.threadBody({slug:e})}).data?.markdown??``).trim().length>0;return a?(0,X.jsxs)(`header`,{"data-thread-header":!0,className:$C,children:[(0,X.jsxs)(`div`,{className:ew,children:[n&&(0,X.jsx)(ms,{onClose:n}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 leading-tight`,children:[(0,X.jsx)(uE,{thread:a}),(0,X.jsx)(oE,{thread:a})]})]}),(0,X.jsx)(`div`,{className:tw,children:(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,X.jsx)(WT,{thread:a,collapse:r,expand:!!n||i?.expand===!0,onDoc:s?()=>qi(`doc`,a.id):void 0,onDone:()=>o.mutate(void 0,{onSuccess:t??i?.exit.dismiss}),doneBusy:o.isPending,onStatusApplied:t}),(0,X.jsx)(vT,{thread:a,onArchived:t??i?.exit.dismiss,onDismissCancel:i?.exit.cancel,onSnoozed:t??i?.exit.dismiss})]})})]}):null}function $D(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||dE(e))return null;if(e.parts&&e.parts.length>0){for(let t=e.parts.length-1;t>=0;t--){let n=e.parts[t];if(n.kind===`tools`?n.tools.length>0:n.text.trim())return n.kind===`tools`?n.tools:null}return null}return(e.tools?.length??0)>0&&!e.text.trim()?e.tools:null}function eO(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||dE(e))return null;if(e.parts&&e.parts.length>0){for(let t of e.parts)if(t.kind===`tools`?t.tools.length>0:t.text.trim())return t.kind===`tools`?t.tools:null;return null}return(e.tools?.length??0)>0?e.tools:null}function tO(e){return $D(e)!==null}function nO(e){return eO(e)!==null}function rO(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function iO(e){return rO(e)||tO(e)}function aO(e){return rO(e)||nO(e)}function oO(e){if(rO(e))return!0;let t=$D(e);return t!==null&&!dr(t[t.length-1])}function sO(e){if(rO(e))return!0;let t=eO(e);return t!==null&&!dr(t[0])}function cO(e){let t=$D(e);return t!==null&&go(t[t.length-1])}function lO(e){let t=eO(e);return t!==null&&go(t[0])}function uO(e,t){return e.kind!==`event`||e.boundary!==`rest`||!t||!pO(t)?null:Wy(e.at,t.at)}function dO({rest:e,at:t}){let{day:n,time:r}=Ky(t),i=qy(e.at)?.replace(/^(Today|Yesterday)/,e=>e.toLowerCase());return(0,X.jsx)(`div`,{title:i?`Agent rested ${i}`:void 0,className:`contents`,children:(0,X.jsx)(Q,{sourceId:e.sourceId,marker:`rest-gap`,ariaLabel:`${n}, ${r}`,children:(0,X.jsxs)(`time`,{dateTime:t,className:`flex shrink-0 items-center gap-1 tabular-nums`,children:[(0,X.jsx)(`span`,{children:n}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`opacity-50`,children:`·`}),(0,X.jsx)(`span`,{children:r})]})})})}function fO(e,t){if(pO(e)&&pO(t))return 6;let n=cO(e)||lO(t),r=!n&&iO(e)&&aO(t)&&!(oO(e)&&sO(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function pO(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`||e.providerError||e.sessionPeer||e.peerFrom||e.agentInstruction?!1:!e.wake||c_(e)}function mO(e,t,n){return e.kind===`event`||e.kind===`reasoning`||e.role===`user`?!1:e.parts&&e.parts.length>0?e.parts.every(r=>r.kind===`tools`?r.tools.length===0:_O(e,r.text,t,n)):(e.tools?.length??0)===0&&_O(e,e.text,t,n)}function hO(e,t){let n=Date.parse(e??``),r=Date.parse(t??``);return Number.isFinite(r)?Number.isFinite(n)&&n>=r?e:t:e}function gO(e,t,n=!1,r=-1){let i=new WeakSet,a=new WeakSet;if(t>=0)for(let n of e)n.messageIndex<t&&n.messageIndex!==r&&i.add(n.message);if(t>=0&&n)for(let n of e)n.messageIndex===t&&a.add(n.message);return e=>mO(e,i.has(e),a.has(e))}function _O(e,t,n,r){return!e.fenceRefused&&!n&&!r?t.includes("```awaiting")?Rg(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`&&hi(e.hints)&&!Mi(e.body)):!t.trim():Rg(t).every(t=>t.kind===`fence`&&t.fenceKind===`awaiting`&&(e.fenceRefused||r||!(vO(t.hints)||yO(e,t))))}function vO(e){return Sa(e).length>0}function yO(e,t){return e.latestSignOff?!hi(t.hints)||Mi(t.body)!==null:!1}function bO(e,t,n){return e.kind===`event`||e.kind===`reasoning`||e.role===`user`?!1:e.parts&&e.parts.length>0?e.parts.some(r=>r.kind===`text`&&!_O(e,r.text,t,n)):typeof e.text==`string`&&!_O(e,e.text,t,n)}function xO(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(Mo(n)||mO(n)))return cO(n)?22:iO(n)&&!oO(n)?6:14+(n.role===`user`?3:0)}return 0}function SO(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||mO(e)||(i!==null&&r.push((0,X.jsx)(ib,{h:fO(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function CO(e){let t=[];for(let n of e){if(n.kind===`text`){if(!n.text.trim())continue;t.push(n);continue}if(n.tools.length===0)continue;let e=t[t.length-1];e&&e.kind===`tools`?t[t.length-1]={kind:`tools`,tools:[...e.tools,...n.tools]}:t.push(n)}return t}function wO(e,t=14){let n=e.filter(e=>e!=null&&e!==!1),r=[];return n.forEach((e,n)=>{let i=n===0?0:typeof t==`number`?t:t(n);i>0&&r.push((0,X.jsx)(ib,{h:i},`vs${n}`)),r.push(e)}),r}var TO={head:!1,tail:!1};function EO(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function DO(e){return{head:go(e[0]),tail:go(e[e.length-1])}}function OO(e){let t=[];for(let n of e){let e=t[t.length-1];if(n.edit){let r=!!(n.input||n.output||n.status||n.exitCode!==void 0);e&&e.edits&&!r&&!e.input&&!e.output&&!e.status&&e.edits[0].file===n.edit.file?e.edits.push(n.edit):t.push({name:n.name,detail:n.detail,edits:[n.edit],input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1})}else n.command?t.push({name:n.name,detail:n.detail,command:n.command,desc:n.desc,input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1}):n.outputImage?t.push({name:n.name,detail:n.detail,outputImage:n.outputImage,output:n.output??n.read,status:n.status,durationMs:n.durationMs,count:1}):n.read?t.push({name:n.name,detail:n.detail,read:n.read,status:n.status,durationMs:n.durationMs,count:1}):n.prompt||n.agentId?t.push({name:n.name,detail:n.detail,prompt:n.prompt,input:n.input,subagentType:n.subagentType,agentId:n.agentId,agentStatus:n.agentStatus,agentElapsedMs:n.agentElapsedMs,output:n.output,status:n.status,durationMs:n.durationMs,count:1}):n.sendTo!==void 0||n.sendBody!==void 0?t.push({name:n.name,detail:n.detail,sendTo:n.sendTo,sendSummary:n.sendSummary,sendBody:n.sendBody,sendType:n.sendType,sendDispatchId:n.sendDispatchId,sendTargetLabel:n.sendTargetLabel,status:n.status,durationMs:n.durationMs,count:1}):n.todos?t.push({name:n.name,detail:n.detail,todos:n.todos,input:n.input,status:n.status,durationMs:n.durationMs,count:1}):We(n)?t.push({name:n.name,detail:n.detail,ask:n.ask,askAnswers:n.askAnswers,status:n.status,durationMs:n.durationMs,count:1}):n.sentImages||n.sentFiles?t.push({name:n.name,detail:n.detail,sentImages:n.sentImages,sentFiles:n.sentFiles,caption:n.caption,status:n.status,durationMs:n.durationMs,count:1}):n.input||n.output?t.push({name:n.name,detail:n.detail,input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1}):e&&!e.edits&&!e.command&&!e.input&&!e.output&&!e.read&&!e.prompt&&!e.outputImage&&!e.sentImages&&!e.sentFiles&&e.sendTo===void 0&&e.sendBody===void 0&&e.name===n.name&&e.detail===n.detail&&e.status===n.status&&e.backgroundState===n.backgroundState&&e.exitCode===n.exitCode&&e.cwd===n.cwd&&e.sessionId===n.sessionId&&e.durationMs===n.durationMs?e.count++:t.push({name:n.name,detail:n.detail,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1})}return t}function kO(e){return e.split(`__`).pop()||e}function AO({tools:e,at:t}){let[n,r]=(0,q.useState)(!1),i=(0,q.useId)(),a=e.reduce((e,t)=>e+t.count,0),o=Ci(a,be(e));return(0,X.jsxs)(`div`,{"data-tool-activity":!0,"data-tool-activity-state":`settled`,className:`flex min-w-0 flex-col`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":i,"aria-expanded":n,"aria-label":`${n?`Collapse`:`Expand`} ${a} tool ${a===1?`call`:`calls`}: ${o}`,className:`group flex w-full min-w-0 items-baseline gap-1.5 rounded -my-0.5 py-0.5 text-left outline-none transition-colors hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${CE}`,children:[(0,X.jsx)(`span`,{"data-tool-activity-label":!0,title:o,className:`min-w-0 truncate text-muted`,children:o}),(0,X.jsx)(br,{"data-tool-activity-chevron":!0,"aria-hidden":`true`,size:13,className:TE(n)})]}),n&&(0,X.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:(0,X.jsx)(jO,{tools:e,at:t})}),!n&&(0,X.jsx)(`div`,{id:i,hidden:!0})]})}function jO({tools:e,at:t}){let n=(0,q.useContext)(Lb)!==null,r=e=>!We(e)&&!(n&&(e.sendTo!==void 0||e.sendBody!==void 0));return(0,X.jsx)(X.Fragment,{children:wO(e.map((e,n)=>(0,X.jsx)(NO,{t:e,startedAt:t},n)),t=>go(e[t-1])||go(e[t])?22:r(e[t-1])&&r(e[t])?0:6)})}function MO({tools:e,at:t}){let n=[];for(let t of e){let e=dr(t),r=n[n.length-1];r?.exceptional===e?r.tools.push(t):n.push({exceptional:e,tools:[t]})}return(0,X.jsx)(`div`,{className:`flex flex-col`,children:wO(n.map((e,n)=>e.exceptional?(0,X.jsx)(`div`,{className:`flex flex-col`,children:(0,X.jsx)(jO,{tools:e.tools,at:t})},`exceptions-${n}`):(0,X.jsx)(AO,{tools:e.tools,at:t},`activity-${n}`)),EO(n.map(e=>DO(e.tools)),6))})}function NO({t:e,startedAt:t}){let n=Oa(e,Se((0,q.useContext)(Lb))?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,X.jsx)(Bp,{edits:e.edits,meta:(0,X.jsx)(RO,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:n,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,X.jsx)(qO,{command:e.command,desc:e.desc??e.detail,literalDesc:e.desc===void 0,output:e.output,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:n,exitCode:e.exitCode,sessionId:e.sessionId,durationMs:e.durationMs,startedAt:t}):e.outputImage?(0,X.jsx)(WO,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,X.jsx)(YO,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,X.jsx)(ZO,{detail:e.detail,prompt:e.prompt,subagentType:e.subagentType,agentId:e.agentId,agentStatus:e.agentStatus,agentElapsedMs:e.agentElapsedMs,status:e.status,durationMs:e.durationMs}):e.sendTo!==void 0||e.sendBody!==void 0?(0,X.jsx)($O,{to:e.sendTo,summary:e.sendSummary,body:e.sendBody??``,type:e.sendType,dispatchId:e.sendDispatchId,targetLabel:e.sendTargetLabel,status:e.status,durationMs:e.durationMs,at:t}):e.sentImages||e.sentFiles?(0,X.jsx)(GO,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,X.jsx)(og,{todos:e.todos,note:e.input,node:jp(e.status),meta:(0,X.jsx)(RO,{status:e.status,durationMs:e.durationMs})}):We(e)?(0,X.jsx)(PO,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,X.jsx)(qO,{name:e.name,command:e.input??``,desc:e.detail,literalDesc:!0,output:e.output,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:n,exitCode:e.exitCode,sessionId:e.sessionId,durationMs:e.durationMs,inputLabel:`Input`,startedAt:t}):(0,X.jsx)(UO,{name:e.name,detail:e.detail,count:e.count,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:n,exitCode:e.exitCode,cwd:e.cwd,sessionId:e.sessionId,durationMs:e.durationMs,startedAt:t})}function PO({ask:e,askAnswers:t}){return(0,X.jsx)(`div`,{"data-settled-ask":!0,className:`flex flex-col gap-1.5`,children:e.map((e,n)=>{let r=eD(e,t?.[n]);return(0,X.jsx)(cS,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function FO({tone:e,indicator:t,label:n,duration:r,title:i}){return(0,X.jsxs)(`span`,{className:`flex shrink-0 items-baseline gap-1 whitespace-nowrap text-[11.5px] leading-none tabular-nums ${e}`,title:i,"aria-label":i,children:[t,(0,X.jsx)(`span`,{children:[n,r].filter(Boolean).join(` · `)})]})}function IO(e,t,n){let[r,i]=(0,q.useState)(()=>Date.now()),a=Lo(e,t),o=Br(e,t,n,r);return(0,q.useEffect)(()=>{if(!a||o)return;let e=n?Date.parse(n):NaN;if(!Number.isFinite(e))return;let t=setTimeout(()=>i(Date.now()),Math.max(ta-(Date.now()-e),0));return()=>clearTimeout(t)},[a,o,n]),o}function LO({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=IO(e,t,r),a=n===`running`?(0,X.jsx)(es,{"aria-hidden":!0,hue:`shell`,"data-running-indicator":`tool-disclosure`}):n===`stale`?(0,X.jsx)(`span`,{className:zn,title:nr}):to(e,t)||i?(0,X.jsx)(es,{"aria-hidden":!0,hue:`shell`,"data-running-indicator":`tool-disclosure`}):null;return a?(0,X.jsx)(`span`,{className:`frizz-tool-mark`,children:a}):null}function RO({status:e,backgroundState:t,liveBackgroundState:n,exitCode:r,durationMs:i}){if(!e&&i===void 0)return null;let[a,o]=n===`running`?[`running`,`background running`]:n===`stale`?[`stale`,`background stale`]:e===`pending`?t===`unknown`?[`unknown`,`background / unknown`]:[`running`,t===`background`?`background running`:`running`]:e===`failed`?r===void 0?[`failed`,`failed`]:[`exit ${r}`,`exit ${r}`]:e===`cancelled`?[`cancelled`,`cancelled`]:e===`completed`?[void 0,`done`]:[void 0,void 0],s=i===void 0?void 0:rt(i);if(!a&&!s)return null;let c=[o,s].filter(Boolean).join(` · `);return(0,X.jsx)(FO,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-attention`:`text-faint`,title:c,label:a,duration:s})}function zO(e,t,n){let r=t?Date.parse(t):NaN,i=e===`pending`&&Number.isFinite(r),[a,o]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{if(!i)return;let e=()=>o(Date.now()),t,n=setTimeout(()=>{e(),t=setInterval(e,1e3)},1e3-Date.now()%1e3);return()=>{clearTimeout(n),t&&clearInterval(t)}},[i,t]),i?Math.max(a-r,0):n}function BO(e,t,n){let r=t&&t!==W.board?.projectDir?`in ${Ip(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function VO(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function HO({detail:e,shown:t=e}){return t?e&&VO(e)?(0,X.jsx)(`span`,{className:`min-w-0`,children:(0,X.jsx)(zp,{path:e,children:(0,X.jsx)(Lp,{path:Ip(e)})})}):(0,X.jsx)(`span`,{className:`frizz-tool-detail frizz-tool-detail--mono`,title:t,children:Ip(t)}):null}function UO({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=BO(t,s,c);return(0,X.jsx)(`div`,{className:`frizz-bash`,title:d,"data-tool-node":jp(r),children:(0,X.jsxs)(`div`,{className:`frizz-bash-header`,children:[(0,X.jsxs)(`span`,{className:kp,children:[(0,X.jsx)(LO,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:kO(e)}),(0,X.jsx)(HO,{detail:t,shown:d})]}),(0,X.jsxs)(`span`,{className:Ap,children:[(0,X.jsx)(RO,{status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,durationMs:l}),n>1&&(0,X.jsxs)(`span`,{className:`tabular-nums text-[11.5px] leading-none text-faint`,children:[`×`,n]}),(0,X.jsx)(Rp,{shown:!1})]})]})})}function WO({name:e,detail:t,outputImage:n,output:r,status:i,durationMs:a}){let[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(!1),u=(0,q.useId)(),d=kO(e),f=t?Ip(t):void 0;return(0,X.jsxs)(`div`,{"data-tool-image":!0,className:`frizz-bash`,"data-tool-node":jp(i),children:[(0,X.jsxs)(Fp,{className:`frizz-bash-header`,controls:u,expanded:o,label:`${o?`Collapse`:`Expand`} ${d}${t?`: ${t}`:``}`,onToggle:()=>s(e=>!e),meta:(0,X.jsx)(RO,{status:i,durationMs:a}),children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:d}),(0,X.jsx)(HO,{detail:t})]}),(0,X.jsx)(`div`,{id:u,className:`frizz-tool-body`,hidden:!o,children:o&&(0,X.jsxs)(X.Fragment,{children:[c?(0,X.jsx)(`div`,{className:`frizz-bash-body break-all text-muted-70`,children:n}):(0,X.jsx)(`div`,{className:`flex justify-center bg-panel-2 p-1.5`,children:(0,X.jsx)(`img`,{src:gi(n),alt:f?`${d}: ${f}`:d,"data-local-path":n,"data-local-image":`true`,onError:()=>l(!0),className:`cursor-zoom-in block max-h-[420px] max-w-full w-auto rounded-md object-contain`})}),r&&(0,X.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body`,children:r})]})})]})}function GO({images:e,files:t,caption:n,status:r,durationMs:i}){let[a,o]=(0,q.useState)(!0),s=(0,q.useId)(),c=(0,q.useMemo)(()=>e.map(e=>({target:e,title:n??`Delivered image`})),[e,n]),l=[e.length?`${e.length} image${e.length===1?``:`s`}`:``,t.length?`${t.length} file${t.length===1?``:`s`}`:``].filter(Boolean).join(` · `);return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":jp(r),children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":s,"aria-expanded":a,"aria-label":`${a?`Collapse`:`Expand`} files sent to you${l?`: ${l}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-60`,children:[(0,X.jsxs)(`span`,{className:kp,children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:`Sent to you`}),l&&(0,X.jsx)(`span`,{className:`frizz-tool-detail`,children:l})]}),(0,X.jsxs)(`span`,{className:Ap,children:[(0,X.jsx)(RO,{status:r,durationMs:i}),(0,X.jsx)(Rp,{open:a})]})]}),(0,X.jsx)(`div`,{id:s,className:`frizz-tool-body`,hidden:!a,children:a&&(0,X.jsxs)(X.Fragment,{children:[e.length>0&&(0,X.jsx)(yh,{entries:c,framed:!1}),(t.length>0||n)&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-2.5 pb-2.5 pt-1.5`,children:[t.length>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map((e,t)=>(0,X.jsx)(pk,{path:e},`f${t}`))}),n&&(0,X.jsx)(`div`,{className:`max-w-[65%] font-sans text-[12px] leading-snug text-muted`,children:n})]})]})})]})}var KO=16;function qO({command:e,desc:t,literalDesc:n,output:r,name:i=`Bash`,status:a,backgroundState:o,liveBackgroundState:s,exitCode:c,sessionId:l,durationMs:u,inputLabel:d,startedAt:f}){let[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(!1),y=(0,q.useId)(),b=zO(a,f,u),x=(0,q.useMemo)(()=>e.split(`
|
|
137
|
-
`).length,[e]),S=x>KO,C=(0,q.useMemo)(()=>r?r.split(`
|
|
138
|
-
`).length:0,[r]),w=C>KO,T=BO(t,void 0,l),E=!!(e||r);return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":jp(a),children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>E&&m(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":E?y:void 0,"aria-expanded":E?p:void 0,"aria-label":`${E?`${p?`Collapse`:`Expand`} `:``}${kO(i)}${T?`: ${T}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-60`,children:[(0,X.jsxs)(`span`,{className:kp,children:[(0,X.jsx)(LO,{status:a,backgroundState:o,liveBackgroundState:s,startedAt:f}),(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:kO(i)}),(0,X.jsx)(`span`,{className:`frizz-tool-detail${n?` frizz-tool-detail--mono`:``}`,title:T,children:T??``})]}),(0,X.jsxs)(`span`,{className:Ap,children:[(0,X.jsx)(RO,{status:a,backgroundState:o,liveBackgroundState:s,exitCode:c,durationMs:b}),(0,X.jsx)(Rp,{shown:E,open:p})]})]}),E&&(0,X.jsxs)(`div`,{id:y,className:`frizz-tool-body`,hidden:!p,children:[p&&e&&(0,X.jsxs)(X.Fragment,{children:[d&&(0,X.jsx)(`div`,{className:`frizz-bash-output-label`,children:d}),(0,X.jsx)(eg,{text:e,language:d?`plaintext`:`bash`,className:`frizz-bash-body${d?``:` frizz-bash-command`}${S&&!h?` frizz-bash-clamp`:``}`}),S&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>g(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand px-2.5 pb-1.5`,children:h?`Collapse`:`Show all ${x} lines`})]}),p&&r&&(0,X.jsxs)(X.Fragment,{children:[d&&(0,X.jsx)(`div`,{className:`frizz-bash-output-label`,children:`Output`}),(0,X.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body${w&&!_?` frizz-bash-clamp`:``}`,children:r}),w&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>v(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand px-2.5 pb-1.5`,children:_?`Collapse`:`Show all ${C} lines`})]})]})]})}var JO=16;function YO({detail:e,read:t,status:n,durationMs:r}){let[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1),c=(0,q.useId)(),l=(0,q.useMemo)(()=>t.split(`
|
|
139
|
-
`).length,[t]),u=l>JO;return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":jp(n),children:[(0,X.jsxs)(Fp,{className:`frizz-bash-header`,controls:c,expanded:i,label:`${i?`Collapse`:`Expand`} Read${e?`: ${e}`:``}`,onToggle:()=>a(e=>!e),meta:(0,X.jsx)(RO,{status:n,durationMs:r}),children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:`Read`}),(0,X.jsx)(HO,{detail:e})]}),(0,X.jsx)(`div`,{id:c,className:`frizz-tool-body`,hidden:!i,children:i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(eg,{text:t,language:ie(e),className:`frizz-bash-body${u&&!o?` frizz-bash-clamp`:``}`}),u&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand px-2.5 pb-1.5`,children:o?`Collapse`:`Show all ${l} lines`})]})})]})}var XO=16;function ZO({detail:e,prompt:t,subagentType:n,agentId:r,agentStatus:i,agentElapsedMs:a,status:o,durationMs:s}){let[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),f=(0,q.useId)(),p=t||`Initial prompt unavailable.`,m=(0,q.useMemo)(()=>p?p.split(`
|
|
140
|
-
`).length:0,[p]),h=m>XO,g=ND(),_=Se(g),v=!i&&r?(_?.subAgents??[]).find(e=>e.id===r):void 0,y=v?.state===`running`,b=!!(g&&r),x=e??`sub-agent`,S=Oi(n),C=di(),w=gE({agentStatus:i,agentElapsedMs:a,liveState:v?.state,liveElapsedMs:v?.startedAt?Math.max(C-Date.parse(v.startedAt),0):void 0,status:o,durationMs:s}),T=y?(0,X.jsx)(es,{"aria-hidden":!0,hue:`agent`,"data-running-indicator":`subagent-disclosure`}):v?.state===`stale`?(0,X.jsx)(`span`,{className:zn,title:De}):v?.state===`rested`?(0,X.jsx)(`span`,{className:Jn,title:Fe}):null;function E(){!g||!r||Mr(g,r,{label:x,subagentType:n,startedAt:v?.startedAt})}return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":w?.tone===`failed`?`failed`:void 0,children:[(0,X.jsxs)(Fp,{className:`frizz-bash-header`,controls:f,expanded:c,label:`${c?`Collapse`:`Expand`} Agent dispatch: ${x}`,onToggle:()=>l(e=>!e),meta:(S||w)&&(0,X.jsxs)(`span`,{className:`flex shrink-0 items-baseline gap-2.5`,children:[S&&(0,X.jsx)(`span`,{"data-subagent-profile":!0,className:`shrink-0 whitespace-nowrap text-[11.5px] leading-none text-faint`,title:`Sub-agent profile: ${S}`,children:S}),w&&(0,X.jsx)(FO,{tone:w.tone===`failed`?`frizz-tool-failed`:`text-faint`,title:w.title,label:w.label,duration:w.duration})]}),children:[T&&(0,X.jsx)(`span`,{className:`frizz-tool-mark`,children:T}),(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:`Agent`}),b?(0,X.jsx)(`button`,{type:`button`,"aria-label":`Open sub-agent transcript: ${x}`,title:`Open sub-agent transcript`,onClick:E,className:`frizz-tool-detail frizz-tool-drill min-w-[4rem] flex-1 text-left outline-none`,children:x}):(0,X.jsx)(`span`,{className:`frizz-tool-detail min-w-[4rem] flex-1`,title:x,children:x})]}),(0,X.jsx)(`div`,{id:f,className:`frizz-tool-body`,hidden:!c,children:c&&(0,X.jsxs)(X.Fragment,{children:[p&&(0,X.jsx)(`pre`,{className:`frizz-bash-body frizz-tool-prose${h&&!u?` frizz-bash-clamp`:``}`,children:p}),h&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand px-2.5 pb-1.5`,children:u?`Collapse`:`Show all ${m} lines`})]})})]})}function QO(e,t){return t===`shutdown_request`?`Shutdown`:t===`codex_followup`?`Followed up`:e===`main`?`Reported`:`Steered`}function $O({to:e,summary:t,body:n,type:r,dispatchId:i,targetLabel:a,status:o,durationMs:s,at:c}){return(0,q.useContext)(Lb)===null?(0,X.jsx)(tk,{to:e,summary:t,body:n,type:r,status:o,durationMs:s}):(0,X.jsx)(Ek,{to:e,type:r,dispatchId:i,targetLabel:a,at:c})}var ek=16;function tk({to:e,summary:t,body:n,type:r,status:i,durationMs:a}){let[o,s]=(0,q.useState)(!t),[c,l]=(0,q.useState)(!1),u=(0,q.useId)(),d=tp(n),f=(0,q.useMemo)(()=>n.split(`
|
|
141
|
-
`).length,[n]),p=f>ek,m=!!n.trim(),h=QO(e,r);return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":jp(i),children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":m?u:void 0,"aria-expanded":m?o:void 0,"aria-label":`${m?`${o?`Collapse`:`Expand`} `:``}${h}${e?` to ${e}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-60`,disabled:!m,children:[(0,X.jsxs)(`span`,{className:kp,children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:h}),t&&(0,X.jsx)(`span`,{className:`frizz-tool-detail`,children:t})]}),(0,X.jsxs)(`span`,{className:Ap,children:[(0,X.jsx)(RO,{status:i,durationMs:a}),(0,X.jsx)(Rp,{shown:m,open:o})]})]}),m&&(0,X.jsx)(`div`,{id:u,className:`frizz-tool-body`,hidden:!o,children:o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`px-2.5 py-2${p&&!c?` frizz-bash-clamp`:``}`,children:(0,X.jsx)($h,{className:`md-body`,html:d})}),p&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand px-2.5 pb-1.5`,children:c?`Collapse`:`Show all ${f} lines`})]})})]})}function nk({body:e,items:t}){let[n,r]=(0,q.useState)(null),i=(0,q.useMemo)(()=>new Map(t.map(e=>[e.token,e])),[t]),a=n===null?void 0:i.get(n);return(0,X.jsxs)(X.Fragment,{children:[(0,q.useMemo)(()=>Ai(e,[...i.keys()]),[e,i]).map((e,t)=>{let a=e.token?i.get(e.token):void 0;if(!a)return(0,X.jsx)(Nb,{text:e.text},t);let o=n===a.token;return(0,X.jsx)(`button`,{type:`button`,title:a.display,"aria-expanded":o,onClick:e=>{e.stopPropagation(),r(o?null:a.token)},onKeyDown:e=>e.stopPropagation(),className:`inline-flex max-w-56 items-baseline rounded border px-1 align-baseline font-mono-keep text-[11px] leading-snug transition-colors ${o?`border-bg/40 bg-bg/15`:`border-bg/25 bg-bg/[0.08] hover:bg-bg/15`}`,children:(0,X.jsx)(`span`,{className:`truncate`,children:po(a.token)})},t)}),a&&(0,X.jsxs)(`span`,{className:`mt-2 block cursor-auto rounded-md border border-bg/20 bg-bg/[0.06] px-2 py-1.5`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`span`,{className:`block truncate font-mono-keep text-[11px] text-user-bubble-fg/60`,children:[a.display,a.startLine===void 0?``:` · ${a.startLine===a.endLine?`line ${a.startLine}`:`lines ${a.startLine}-${a.endLine}`}`]}),(0,X.jsx)(`span`,{className:`mt-1 block max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono-keep text-[11.5px] leading-4 text-user-bubble-fg/80`,children:a.text})]})]})}function rk({deliveryId:e,text:t,rawText:n,error:r}){let i=(0,q.useContext)(Lb),{retry:a,edit:o,dismiss:s,pending:c}=VC(i),l=`rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] font-medium text-fg/80 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:opacity-45 disabled:hover:bg-panel-2/60 disabled:hover:text-fg/80`;return(0,X.jsxs)(`div`,{"data-failed-send":e,className:`mt-1 flex flex-col items-end gap-1.5`,children:[(0,X.jsxs)(`div`,{role:`alert`,className:`text-left text-[12px] leading-snug text-danger-soft [overflow-wrap:anywhere]`,children:[`Not delivered`,r?` — ${r.split(`
|
|
142
|
-
`,1)[0]}`:``]}),i&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`button`,{type:`button`,className:l,disabled:c,title:`Send this message again`,onClick:()=>a({deliveryId:e,text:n}),children:`Retry`}),(0,X.jsx)(`button`,{type:`button`,className:l,disabled:c,title:`Put this message back in the prompt box`,onClick:n=>o({deliveryId:e,text:t,from:n.currentTarget}),children:`Edit`}),(0,X.jsx)(`button`,{type:`button`,className:l,disabled:c,title:`Discard this message`,onClick:()=>s({deliveryId:e}),children:`Dismiss`})]})]})}function ik(){let e=(0,q.useContext)(Lb),t=(0,q.useContext)(zb),n=hx(e),r=mx(e),i=yx(e);if(!e||!t)return null;let a=dx(t,n,r);if(!a)return r||t.held+t.steered===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ib,{h:6}),(0,X.jsx)(`div`,{"data-queued-waits-for-turn":!0,className:`flex items-baseline justify-end text-[11.5px] leading-[16px] text-muted`,children:`Waits for this turn to end`})]});let o=t.held>1?`Send the next one now — the agent reads it at its next step`:`Send it now — the agent reads it at its next step`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ib,{h:6}),(0,X.jsx)(`div`,{"data-queued-send-now":a,className:`flex items-baseline justify-end text-[11.5px] leading-[16px] text-muted`,children:(0,X.jsxs)(`button`,{type:`button`,"data-send-now":!0,onMouseDown:e=>e.preventDefault(),onClick:()=>bx(e,t),disabled:i,"aria-keyshortcuts":`Meta+Enter Control+Enter`,title:`${a===`release`?o:`Send now — the worker reads the queue immediately, and a command it is running carries on in the background`} (⌘⏎)`,className:`relative flex cursor-pointer items-baseline outline-none transition-colors duration-50 before:absolute before:-inset-x-2 before:-inset-y-1 before:content-[''] hover:text-fg focus-visible:text-fg disabled:cursor-default disabled:opacity-50`,children:[i?(0,X.jsx)(Ut,{"aria-hidden":!0,className:`mr-1 size-[1em] shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)] animate-spin`,strokeWidth:2.4}):(0,X.jsx)(`span`,{"aria-hidden":!0,className:`mr-[0.44em] shrink-0`,children:(0,X.jsx)(`kbd`,{className:`send-now-key`,children:`⌘⏎`})}),(0,X.jsx)(`span`,{className:`underline decoration-border underline-offset-2`,children:`Send now`})]})})]})}function ak({m:e,answers:t,note:n}){let r=(t,n)=>{if(!t)return null;let i=n<2?i_(t):null;return i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Pb,{answers:i,queued:e.queued}),r(Xg(t),n+1)]}):(0,X.jsx)(ok,{text:t,rawText:e.text,queued:e.queued})};return(0,X.jsxs)(`div`,{"data-frizz-msg":e.sourceId,"data-answers-with-note":!0,className:`flex w-full flex-col gap-2 self-end`,children:[(0,X.jsx)(Pb,{answers:t,queued:e.queued}),r(n,0)]})}function ok({text:e,rawText:t,queued:n,held:r,deliveryUnconfirmed:i,deliveryFailed:a,deliveryError:o,deliveryId:s,sourceId:c}){let l=(0,q.useContext)(Lb),u=IC(l),{unqueue:d,pending:f}=BC(l),p=!!(n&&s&&l&&(u||r)),{prose:m,attachments:h}=(0,q.useMemo)(()=>zi(e),[e]),g=(0,q.useMemo)(()=>pi(m),[m]);return(0,X.jsxs)(`div`,{"data-frizz-msg":c,className:`self-end flex flex-col items-end gap-0.5 max-w-[85%]`,children:[m.trim()!==``&&(0,X.jsx)(`div`,{...p?{role:`button`,tabIndex:0,"data-unqueue":s,"aria-label":`Unqueue this message and put it back in the prompt box`,title:f?`Taking it back…`:void 0,onClick:n=>d({deliveryId:s,text:e,rawText:t??e,from:n.currentTarget}),onKeyDown:n=>{n.key!==`Enter`&&n.key!==` `||(n.preventDefault(),d({deliveryId:s,text:e,rawText:t??e,from:n.currentTarget}))}}:{},className:`relative rounded-xl rounded-br-sm bg-user-bubble px-3.5 py-3 text-[14px] whitespace-pre-wrap [overflow-wrap:anywhere] text-user-bubble-fg ${n||a?`opacity-50`:``} ${p?`cursor-pointer transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-bg`:``} ${f?`!opacity-30`:``}`,children:g?(0,X.jsx)(nk,{body:g.body,items:g.items}):(0,X.jsx)(Nb,{text:m})}),h.length>0&&(0,X.jsxs)(`div`,{className:`mt-1 flex flex-col items-end gap-1.5`,children:[h.filter(e=>e.kind===`image`).map((e,t)=>(0,X.jsx)(fk,{path:e.path,hideCaption:!0},`i${t}-${e.path}`)),h.some(e=>e.kind===`file`)&&(0,X.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:h.filter(e=>e.kind===`file`).map((e,t)=>(0,X.jsx)(pk,{path:e.path},`f${t}-${e.path}`))})]}),i&&(0,X.jsx)(`div`,{className:`text-[11px] text-attention-80`,children:`Delivery unconfirmed — no receipt from the worker`}),a&&s&&(0,X.jsx)(rk,{deliveryId:s,text:e,rawText:t??e,error:o}),p&&f&&(0,X.jsx)(`div`,{"aria-hidden":!0,className:`h-0 overflow-visible text-[11px] text-muted`,children:`Taking it back…`})]})}function sk({m:e,index:t,dense:n,textOnly:r,showSendButton:i}){let a=rC(),[o,s]=a.hidesAwaiting(t);return(0,X.jsx)(ck,{m:e,dense:n,textOnly:r,showSendButton:i,answering:a.fencesLive?a.answeringForMessage(e):void 0,paired:a.paired[t],staleAwaiting:o,restingCardShown:s,stepsDone:a.stepsDone.get(t),shadowedBy:a.shadowedByMessage.get(t),placed:a.placement.placed.get(t),settledPlaced:a.settledPlacement.placed.get(t),fenceQuestions:a.fenceQuestions,index:t,questionHomes:a.questionHomes})}var ck=(0,q.memo)(function(e){return(0,X.jsx)(`div`,{title:(e.m.queued?null:qy(e.m.at))??void 0,className:`contents`,children:(0,X.jsx)(uk,{...e})})});function lk({error:e}){let t=(0,q.useContext)(Lb);return(0,X.jsx)(Jg,{error:e,provider:(0,q.useSyncExternalStore)(e=>Wt(W,e),()=>{let e=t?vs(W.board,t):void 0;return Ws(e?.backend,e?.model)},()=>`Agent`)})}function uk({m:e,answering:t,dense:n,paired:r,textOnly:i,showSendButton:a,staleAwaiting:o,shadowedBy:s,placed:c,settledPlaced:l,fenceQuestions:u,index:d,questionHomes:f,restingCardShown:p,stepsDone:m}){let h=Cr(),[g,_]=(0,q.useState)(!1),v=wv();if(e.providerError)return(0,X.jsx)(lk,{error:e.providerError});if(e.kind===`event`)return(0,X.jsx)(Dk,{text:e.text,boundary:e.boundary,sourceId:e.sourceId,at:e.at});if(e.kind===`reasoning`)return(0,X.jsx)(Ok,{text:e.text,sourceId:e.sourceId});let y=dE(e);if(y)return(0,X.jsx)(wk,{call:y,sourceId:e.sourceId,at:e.at});if(e.role===`user`){let t=g_(e).replace(/\r\n?/g,`
|
|
143
|
-
`),i=r===void 0?i_(t):r;if(i&&e.deliveryState!==`failed`){let n=Xg(t);return!n&&e.deliveryState!==`held`?(0,X.jsx)(Pb,{answers:i,queued:e.queued,sourceId:e.sourceId}):(0,X.jsx)(ak,{m:e,answers:i,note:n})}return e.wake?(0,X.jsx)(sb,{steer:e.wakeSteer,text:t,sourceId:e.sourceId,at:e.at,wrap:n}):e.sessionPeer?(0,X.jsx)(qC,{peer:e.sessionPeer,text:t,queued:e.queued,sourceId:e.sourceId,at:e.at,wrap:n}):e.peerFrom?(0,X.jsx)(Tk,{from:e.peerFrom,unnamed:e.peerUnnamed,dispatchId:e.peerDispatchId,sourceId:e.sourceId,at:e.at}):(0,X.jsx)(ok,{text:t,rawText:e.text,queued:e.queued,held:e.deliveryState===`held`,deliveryUnconfirmed:e.deliveryState===`unconfirmed`,deliveryFailed:e.deliveryState===`failed`,deliveryError:e.deliveryError,deliveryId:e.deliveryId,sourceId:e.sourceId})}let b=[],x=[],S=(e,t=TO)=>{b.push(e),x.push(t)},C={n:-1},w=[],T=new Set,E,D=()=>E??=new Set(gg(e.text,e.refusedFences)),O=(r,i)=>{for(let[a,g]of Rg(r).entries()){if(g.kind===`fence`){if(g.fenceKind===`awaiting`&&o&&!e.fenceRefused&&!p&&vO(g.hints)){S((0,X.jsx)(Hy,{fence:{body:g.body,hints:g.hints},stepsDone:m},`${i}-f${a}`));continue}if(g.fenceKind===`awaiting`&&o&&!e.fenceRefused&&!p&&e.latestSignOff){if(hi(g.hints)){let e=Mi(g.body);e&&S((0,X.jsx)(dk,{md:e,wrap:n},`${i}-f${a}`))}else S((0,X.jsx)(Hy,{fence:{body:g.body,hints:g.hints}},`${i}-f${a}`));continue}if(g.fenceKind===`awaiting`&&(e.fenceRefused||o||p))continue;if(g.fenceKind===`awaiting`&&hi(g.hints)){let e=Mi(g.body);e&&S((0,X.jsx)(dk,{md:e,wrap:n},`${i}-f${a}`));continue}S((0,X.jsx)(vk,{fenceKind:g.fenceKind,body:g.body,hints:g.hints,wrap:n,pastRest:o},`${i}-f${a}`));continue}for(let[r,o]of dg(g.text,u!==void 0,e.refusedFences).entries()){if(o.kind===`prose`){for(let[e,t]of Nr(o.text).entries()){let o=`${i}-${a}-p${r}-${e}`;S(t.kind===`image`?(0,X.jsx)(fk,{path:t.path},o):t.kind===`file`?(0,X.jsx)(pk,{path:t.path},o):t.kind===`visualization`?(0,X.jsx)(gk,{file:t.file},o):t.kind===`directive`?(0,X.jsx)(Jm,{directive:t.directive},o):t.kind===`mermaid`?(0,X.jsx)($m,{source:t.source},o):t.kind===`lightbox`?(0,X.jsx)(yh,{entries:t.entries},o):(0,X.jsx)(dk,{md:t.text,wrap:n},o))}continue}if(o.kind===`refusedRef`){let t=L_(o.id,u??[],e.questionOwners)?.closed;S((0,X.jsx)(qS,{id:o.id,closed:t},`${i}-${a}-r${r}`));continue}if(o.kind===`refusedAsk`){S((0,X.jsx)(WS,{spec:o.spec,reasons:e.refusedReasons?.get(o.id.toLowerCase()),wrap:n},`${i}-${a}-x${r}`));continue}if(o.kind===`invalidFence`){S(o.draft?(0,X.jsx)(WS,{spec:o.draft,reasons:o.faults,unread:!0,wrap:n},`${i}-${a}-i${r}`):(0,X.jsx)(GS,{faults:o.faults,children:(0,X.jsx)(dk,{md:`<details>\n<summary>What the worker wrote</summary>\n\n${o.text}\n\n</details>`,wrap:n})},`${i}-${a}-i${r}`));continue}C.n+=1;let p=C.n;if(o.fence){let t=o.fence.form===`ask`?o.fence.when:void 0;if(t&&!D().has(t.parent.toLowerCase()))continue;let s=L_(t?t.parent:o.fence.id,u??[],e.questionOwners);if(s&&T.has(s.id))continue;if(s?.closed){let e=o.fence.form===`ask`&&!t?o.fence.spec:void 0,c=e??s.asked;c&&(T.add(s.id),S((0,X.jsx)(VS,{spec:c,state:s.closed,copyOf:e?void 0:s.id,wrap:n},`${i}-${a}-q${r}`)));continue}if(s){T.add(s.id);let e=c?.find(e=>e.id===s.id);if(e){S((0,X.jsx)(YS,{q:e},`${i}-${a}-q${r}`));continue}let t=l?.find(e=>e.id===s.id);if(t){S((0,X.jsx)(NS,{s:t,wrap:n},`${i}-${a}-q${r}`));continue}let o=FS(s),u=f?.get(s.id);S(o?(0,X.jsx)(NS,{s:o,copy:!0,wrap:n},`${i}-${a}-q${r}`):(0,X.jsx)(US,{q:s,above:u!==void 0&&d!==void 0&&u<d,wrap:n},`${i}-${a}-q${r}`));continue}o.fence.form===`ask`&&!t&&!T.has(`fence:${o.fence.id}`)&&(T.add(`fence:${o.fence.id}`),S((0,X.jsx)(BS,{spec:o.fence.spec,wrap:n},`${i}-${a}-q${r}`)));continue}let m=c&&o.registeredId?c.find(e=>e.id.toLowerCase()===o.registeredId):void 0;if(m&&!T.has(m.id)){T.add(m.id),S((0,X.jsx)(YS,{q:m},`${i}-${a}-q${r}`));continue}if(s&&F_(o,s)!==void 0)continue;let g=l&&o.registeredId?l.find(e=>e.id.toLowerCase()===o.registeredId):void 0;if(g&&!T.has(g.id)){T.add(g.id),S((0,X.jsx)(NS,{s:g,wrap:n},`${i}-${a}-q${r}`));continue}if(o.registeredId&&o.text.trim()===``)continue;t&&w.push({raw:o.text,kind:o.questionKind,danger:o.danger,bi:p});let _=t&&!h?{answer:t.answerFor(p),onChip:(e,n)=>t.onChip(p,e,n),onText:e=>t.onText(p,e),onSubmit:t.onSubmit}:void 0;S((0,X.jsx)(cS,{raw:o.text,questionKind:o.questionKind,danger:o.danger,interactive:_,wrap:n},`${i}-${a}-q${r}`))}}};if(e.parts&&e.parts.length>0)CO(e.parts).forEach((t,r)=>{if(t.kind===`tools`){if(i)return;let a=OO(t.tools);a.length&&S((0,X.jsx)(MO,{tools:a,dense:n,at:e.at},`t${r}`),DO(a))}else O(t.text,`x${r}`)});else{if(!i){let t=OO(e.tools);t.length>0&&S((0,X.jsx)(MO,{tools:t,dense:n,at:e.at},`tools`),DO(t))}O(e.text,`leg`)}return b.length===0?null:(a&&t&&h&&w.length>0?S((0,X.jsx)(`div`,{className:`flex justify-start`,children:(0,X.jsx)(`button`,{type:`button`,"data-mobile-answer-open":!0,onClick:()=>_(!0),className:`button-outline flex h-[40px] items-center justify-center rounded-[12px] bg-accent-fill px-4 text-[15px] font-semibold text-on-accent active:brightness-90`,children:w.length>1?`Answer ${w.length} questions`:`Answer`})},`answer-open`)):a&&t&&w.length>0&&!v&&S((0,X.jsx)(`div`,{className:`flex justify-start`,children:(0,X.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:!t.anyAnswered||t.sending,onClick:t.onSubmit,onMouseDown:e=>e.preventDefault(),className:`button-outline rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:`Send answers`})},`send-answers`)),(0,X.jsxs)(`div`,{"data-frizz-msg":e.sourceId,className:`flex flex-col text-[13px] min-w-0`,children:[wO(b,EO(x,14)),g&&t&&w.length>0?(0,X.jsx)(lC,{blocks:w,answering:t,onClose:()=>_(!1)}):null]}))}function dk({md:e,wrap:t}){let n=tp(e);return n?(0,X.jsx)($h,{className:`md-body${t?` ${lm}`:``}`,html:n}):null}function fk({path:e,hideCaption:t,altText:n}){let[r,i]=(0,q.useState)(!1);if(r)return(0,X.jsx)(`div`,{className:`font-mono-keep text-[12px] text-muted-70 break-all`,children:e});let a=Rt(e);return(0,X.jsx)(hf,{caption:t?void 0:(0,X.jsx)(`figcaption`,{className:`bg-panel-2 px-2 pb-1.5 font-mono-keep text-[11px] text-muted-60 break-all`,children:a}),children:(0,X.jsx)(`img`,{src:gi(e),alt:n??a,"data-local-path":e,"data-local-image":`true`,onError:()=>i(!0),className:`cursor-zoom-in ${vf}`})})}function pk({path:e}){let t=Rt(e);return(0,X.jsxs)(`button`,{type:`button`,className:`local-file-action inline-flex max-w-full items-center gap-1.5 ${um} border border-border bg-panel-2 px-3 py-1.5 text-left align-top no-underline hover:border-accent`,"data-local-path":e,title:e,children:[(0,X.jsx)(ke,{size:14,strokeWidth:2,className:`shrink-0 text-muted`}),(0,X.jsx)(`span`,{className:`font-mono-keep truncate text-[12px] text-fg`,children:t})]})}var mk={"--background":`--color-bg`,"--foreground":`--color-fg`,"--card":`--color-panel-2`,"--card-foreground":`--color-fg`,"--popover":`--color-elevated`,"--popover-foreground":`--color-fg`,"--primary":`--color-fg`,"--primary-foreground":`--color-bg`,"--secondary":`--color-panel-2`,"--secondary-foreground":`--color-fg`,"--muted":`--color-panel-2`,"--muted-foreground":`--color-muted`,"--accent":`--color-border-strong`,"--accent-foreground":`--color-fg`,"--border":`--color-border-strong`,"--input":`--color-control-strong`,"--ring":`--color-accent`,"--destructive":`--viz-destructive`,"--viz-series-1":`--viz-series-1`,"--viz-series-2":`--viz-series-2`,"--viz-series-3":`--viz-series-3`,"--viz-series-4":`--viz-series-4`,"--viz-series-5":`--viz-series-5`,"--viz-series-6":`--viz-series-6`};function hk(e){let t=getComputedStyle(document.documentElement),n=Object.fromEntries(Object.entries(mk).map(([e,n])=>[e,t.getPropertyValue(n).trim()]));return n[`--font-size-base`]=getComputedStyle(document.body).fontSize,JC(e,t.colorScheme===`light`?`light`:`dark`,n)}function gk({file:e}){let t=(0,q.useContext)(Lb),n=(0,q.useRef)(null),[r,i]=(0,q.useState)(360),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(null),l=(0,q.useRef)(void 0),u=(0,q.useRef)(0),d=(0,q.useRef)(null),{resolved:f}=(0,q.useSyncExternalStore)(Ht,wt,wt),p=t?Jo(t):null,m=t?`${p?io(p.project):Ya()}/local-visualization?slug=${encodeURIComponent(p?.slug??t)}&file=${encodeURIComponent(e)}`:null;(0,q.useEffect)(()=>{if(!m){o(!1);return}let e=new AbortController;return o(null),c(null),d.current=null,window.clearTimeout(l.current),fetch(m,{method:`HEAD`,signal:e.signal}).then(t=>{e.signal.aborted||o(t.ok)}).catch(()=>{e.signal.aborted||o(!1)}),()=>e.abort()},[m]);let h=(0,q.useCallback)(()=>{if(!m||d.current!==m)return;let e=++u.current;n.current?.contentWindow?.postMessage(hk(e),`*`)},[m]);return(0,q.useEffect)(()=>{let e=e=>{if(e.source!==n.current?.contentWindow)return;if(e.data?.type===`frizz-inline-vis-ready`){h();return}if(YC(e.data,u.current)&&m&&d.current===m){window.clearTimeout(l.current),c(m);return}if(e.data?.type!==`frizz-inline-vis-height`)return;let t=Number(e.data.height);Number.isFinite(t)&&i(Math.max(80,Math.min(2400,Math.ceil(t))))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[h,m]),(0,q.useEffect)(()=>{h()},[f,h]),(0,q.useEffect)(()=>()=>window.clearTimeout(l.current),[]),a===!1||!m?(0,X.jsxs)(`div`,{role:`status`,className:`${um} border border-border bg-panel-2 px-4 py-2.5 text-[12px] text-muted`,children:[`Visualization unavailable: `,(0,X.jsx)(`span`,{className:`font-mono-keep break-all`,children:e})]}):a===null?(0,X.jsx)(`div`,{role:`status`,className:`h-20 animate-pulse ${um} bg-panel-2`,"aria-label":`Loading ${e}`}):(0,X.jsx)(`iframe`,{ref:n,src:m,title:e.replace(/\.html$/,``).replaceAll(`-`,` `),sandbox:`allow-scripts`,onLoad:()=>{m&&(c(null),d.current=m,h(),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o(!1),5e3))},className:`block w-full border-0 bg-transparent`,style:{height:r,visibility:s===m?`visible`:`hidden`}})}function _k(e,t,n){return e?.kind===`awaiting`&&e.body===t&&JSON.stringify(e.hints)===JSON.stringify(n)}function vk({fenceKind:e,body:t,hints:n,wrap:r,pastRest:i}){let a=tp(t),o=(0,q.useContext)(Lb),s=(0,q.useContext)(Rb),c=Se(o),l=c?sv(c):void 0,u=!!(c&&l?.archive),d=(0,q.useRef)(null);u&&c&&(d.current=c);let f=u&&c?c:d.current,p=Cr();if(e===`done`){let e=de(n),t=f&&!p&&!i?(0,X.jsx)(Em,{children:(0,X.jsx)(xT,{thread:f,className:`${Am} text-[11px] ${km}`,iconClassName:hv,onArchived:s?.dismiss,onDismissCancel:s?.cancel})}):null;return(0,X.jsx)(wm,{icon:Qt,kind:`Done`,label:e?(0,X.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:e}):null,ruled:!!a,children:a||t?(0,X.jsxs)(X.Fragment,{children:[a&&(0,X.jsx)($h,{className:`md-body${r?` [overflow-wrap:anywhere]`:``}`,html:a}),t]}):null})}return c&&zy(c)&&_k(c.lastFence,t,n)?null:(0,X.jsx)(Hy,{thread:c,fence:{body:t,hints:n}})}function yk({slug:e,sessionId:t,fault:n,retryText:r}){let[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1),c=ct(),l=ut[n.backend],u=t=>{s(!0),Vi(c,e,t,{onSuccess:()=>{s(!1),G(`Retrying with the previous message…`)},onRollback:()=>s(!1),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||s(!1)};return(0,X.jsxs)(wm,{"data-provider-fault":!0,tone:`danger`,icon:dc,label:`${l} sign-in required`,children:[(0,X.jsx)(`span`,{className:Tm,children:`The provider rejected this session's credential. Sign in, then retry.`}),(0,X.jsxs)(Em,{children:[r?.trim()&&(0,X.jsx)(`button`,{onClick:()=>u(r),disabled:o,onMouseDown:e=>e.preventDefault(),className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel disabled:opacity-60`,children:`Retry`}),(0,X.jsx)(`button`,{onClick:()=>a(!0),onMouseDown:e=>e.preventDefault(),className:jm,children:`Sign in`})]}),i&&(0,X.jsx)(Dn,{backend:n.backend,onClose:()=>a(!1),onAuthed:()=>a(!1)})]})}function bk({slug:e,sessionId:t,pause:n}){let r=n.backend===`acp`?`The agent`:n.backend===`opencode`?`OpenCode`:ut[n.backend],i=n.window===`weekly`?`weekly limit`:n.window===`session`?`5-hour limit`:`usage limit`,[a,o]=(0,q.useState)(!1),s=ct();return(0,X.jsxs)(wm,{"data-limit-pause":!0,tone:`caution`,icon:Le,label:`Paused by the ${r} ${i}`,children:[(0,X.jsx)(`span`,{className:Tm,children:n.autoResume?n.resumesAt?`Continuing automatically at ${Ye(n.resumesAt)}.`:`Continuing automatically once the window resets.`:`Continue it whenever you have capacity again.`}),(0,X.jsx)(Em,{children:(0,X.jsx)(`button`,{onClick:()=>{o(!0),Vi(s,e,`Continue exactly where you left off.`,{onSuccess:()=>{o(!1),G(`Continuing…`)},onRollback:()=>o(!1),failureToast:e=>`Continue failed: ${e.slice(0,80)}`})||o(!1)},disabled:a,onMouseDown:e=>e.preventDefault(),className:`disabled:opacity-45 ${jm}`,children:`Continue now`})})]})}function xk({policy:e,denies:t}){let n=[e.tool,e.command].filter(Boolean).join(`: `);return(0,X.jsxs)(wm,{tone:`caution`,icon:Pt,label:`Blocked by frizz's permission policy`,children:[n?(0,X.jsx)(`code`,{className:`mb-1.5 block min-w-0 break-all rounded bg-panel px-1.5 py-1 text-[11px] text-fg/85`,children:n}):null,(0,X.jsx)(`span`,{className:Tm,children:e.reason}),(0,X.jsxs)(`span`,{className:`mt-1.5 block text-[11px] text-muted`,children:[`Rule `,(0,X.jsx)(`code`,{className:`rounded bg-panel px-1 py-0.5`,children:e.rule}),t&&t>1?` · ${t} denials this session`:``]})]})}function Sk({slug:e,className:t=`px-4 pb-2 pt-1`,includeAgents:n=!0,only:r,transcriptShells:i=[],parentAgentId:a,density:o=`sheet`}){let s=Se(e),c=s?.subAgents??[],u=n?a?l(c,a):c:[],d=s&&!a?dv(s,i):void 0,f=r&&r!==`shell`?[]:a?[...i]:d?.shells??[],p=!d||r&&r!==`pr`&&r!==`issue`?[]:r===`pr`?d.prs:r===`issue`?d.issues:[...d.prs,...d.issues],m=d?r===`file`?d.files:r===`link`?d.links:r?[]:s?.links??[]:[],h=u.length+f.length+p.length,g=pv(s),[,_]=(0,q.useState)(0);(0,q.useEffect)(()=>{if(h===0)return;let e=setInterval(()=>_(e=>e+1),3e4);return()=>clearInterval(e)},[h]);let v=Dt(e,f.flatMap(e=>e.id&&!e.outputUnavailable?[e.id]:[]));return h===0&&m.length===0?null:(0,X.jsxs)(`div`,{className:`flex flex-col ${o===`panel`?``:`gap-0.5`} ${t}`,"data-background-ops":!0,children:[Oo(u,`sheet`).map((t,n)=>(0,X.jsx)(Mt,{kind:`AGENT`,label:t.label,state:t.state,density:o,depth:t.displayDepth??t.depth,startedAt:t.startedAt,onOpen:t.id?()=>Mr(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:fe(e,t)},`a${n}`)),Oo(f,`sheet`).map((t,n)=>(0,X.jsx)(Mt,{kind:`SHELL`,label:t.label,state:t.state,density:o,startedAt:t.startedAt,counter:t.id?Ka(v.get(t.id)):void 0,counterTitle:`Lines of output so far — open the row to read them`,onOpen:t.id&&!t.outputUnavailable?()=>Ra(e,t.id,{label:t.label,startedAt:t.startedAt}):void 0,onDismiss:fe(e,t,`SHELL`),title:g(t)?`${t.label}\n${mv}`:void 0},`s${n}`)),p.map(e=>(0,X.jsx)(Mt,{kind:`GITHUB`,label:e.target,state:`running`,density:o,startedAt:e.createdAt,counter:e.subject===`issue`?yi(e.issue):an(e.github),counterTone:e.github?.checks===`failing`&&!He(e.github,Date.now())?`danger`:void 0,counterTitle:e.subject===`issue`?e.issue?`${e.target} — ${hy(e.issue)}`:void 0:e.github?`${e.target} — ${ry(e.github)}`:void 0,onOpen:()=>window.open(Va(e.target,e.subject===`issue`?`issue`:`pull`)??`https://github.com/${e.target.replace(`#`,e.subject===`issue`?`/issues/`:`/pull/`)}`,`_blank`,`noreferrer,noopener`)},e.id)),(0,X.jsx)(SE,{links:m,panel:o===`panel`})]})}function Ck({ask:e}){return(0,X.jsx)(wm,{tone:`attention`,icon:_o,label:`Waiting on your answer — in your external terminal`,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.header&&(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-55`,children:e.header}),(0,X.jsx)(`div`,{className:`min-w-0 text-[12px] font-medium leading-5 text-fg`,children:e.question}),e.options.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.options.map((e,t)=>(0,X.jsxs)(`div`,{className:`rounded-md border border-border bg-elevated px-3 py-1.5 text-[12px] text-fg/80`,children:[(0,X.jsx)(`span`,{className:`font-medium text-fg/90`,children:e.label}),e.description&&(0,X.jsxs)(`span`,{className:`text-muted-70`,children:[` — `,e.description]})]},t)),e.multiSelect&&(0,X.jsx)(`div`,{className:`text-[10px] text-muted-50`,children:`select one or more`})]})]},t))})})}function wk({call:e,sourceId:t,at:n}){let r=ND(),i=e.detail??`sub-agent`,{outcome:a,tail:o}=pE(e),s=o.slice(a.length).trim(),c=!!(r&&e.agentId);return(0,X.jsxs)(Q,{icon:$s,sourceId:t,marker:`agent`,ariaLabel:c?void 0:`Sub-agent ${i} ${o}`,at:n,children:[(0,X.jsx)(`span`,{className:`shrink-0 ${Xy}`,children:`Sub-agent`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,X.jsx)(`span`,{className:`shrink-0`,children:`«`}),c?(0,X.jsx)(`button`,{type:`button`,"data-subagent-completion-open":!0,title:E.AGENT,"aria-label":`${E.AGENT}: ${i}`,onClick:()=>Mr(r,e.agentId,{label:i,subagentType:e.subagentType}),onMouseDown:e=>e.preventDefault(),className:`min-w-0 truncate rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:i}):(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:i}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`»`})]}),(0,X.jsx)(`span`,{className:`shrink-0`,children:a}),s&&(0,X.jsx)(`span`,{className:`shrink-0 @max-[34rem]/wake:hidden`,children:s})]})}function Tk({from:e,unnamed:t,dispatchId:n,sourceId:r,at:i}){let a=ND(),o=!!(a&&n),s=t?void 0:e,c=t&&e?`${E.AGENT} — ${e}`:E.AGENT;return s===void 0?(0,X.jsx)(Q,{icon:$s,sourceId:r,marker:`agent-report`,ariaLabel:o?void 0:`Sub-agent reported`,at:i,children:o?(0,X.jsx)(`button`,{type:`button`,"data-subagent-report-open":!0,title:c,"aria-label":`${E.AGENT}${e?`: ${e}`:``}`,onClick:()=>Mr(a,n,{label:`Sub-agent`,subagentType:e}),onMouseDown:e=>e.preventDefault(),className:`shrink-0 rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:`Sub-agent reported`}):(0,X.jsx)(`span`,{className:`shrink-0`,title:e||void 0,children:`Sub-agent reported`})}):(0,X.jsxs)(Q,{icon:$s,sourceId:r,marker:`agent-report`,ariaLabel:o?void 0:`Sub-agent ${s} reported`,at:i,children:[(0,X.jsx)(`span`,{className:`shrink-0 ${Xy}`,children:`Sub-agent`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,X.jsx)(`span`,{className:`shrink-0`,children:`«`}),o?(0,X.jsx)(`button`,{type:`button`,"data-subagent-report-open":!0,title:E.AGENT,"aria-label":`${E.AGENT}: ${s}`,onClick:()=>Mr(a,n,{label:s,subagentType:e}),onMouseDown:e=>e.preventDefault(),className:`min-w-0 truncate rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:s}):(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:s}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`»`})]}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`reported`})]})}function Ek({to:e,type:t,dispatchId:n,targetLabel:r,sourceId:i,at:a}){let o=ND(),s=QO(e,t),c=e===`main`?void 0:r??e,l=!!(o&&n);return(0,X.jsxs)(Q,{icon:$s,sourceId:i,marker:`agent-steer`,ariaLabel:l?void 0:`${s}${c?` ${c}`:``}`,at:a,children:[(0,X.jsx)(`span`,{className:`shrink-0`,children:s}),c&&(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,X.jsx)(`span`,{className:`shrink-0`,children:`«`}),l?(0,X.jsx)(`button`,{type:`button`,"data-subagent-steer-open":!0,title:E.AGENT,"aria-label":`${E.AGENT}: ${c}`,onClick:()=>Mr(o,n,{label:c}),onMouseDown:e=>e.preventDefault(),className:`min-w-0 truncate rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:c}):(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:c}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`»`})]})]})}function Dk({text:e,boundary:t,sourceId:n,at:r}){if(t){let i=t===`wake`?/^([^«]+?) «(.+)» ([^»(]+?)(?: (\([^»]*\)))?$/.exec(e):null;return(0,X.jsx)(Q,{icon:t===`wake`?Ac:void 0,sourceId:n,marker:t===`rest`?`rest`:`event`,ariaLabel:e,at:r,children:i?(0,X.jsx)(eb,{lead:i[1],title:i[2],tail:i[3],note:i[4]}):(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e})})}return(0,X.jsx)(`div`,{"data-frizz-msg":n,className:CE,children:e})}function Ok({text:e,sourceId:t}){let[n,r]=(0,q.useState)(!1),i=(0,q.useId)();return(0,X.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":i,"aria-expanded":n,"aria-label":`${n?`Collapse`:`Expand`} model reasoning`,className:`${CE} flex items-baseline gap-1.5 self-start rounded outline-none transition-colors hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:[(0,X.jsx)(`span`,{children:`Reasoning`}),(0,X.jsx)(br,{"aria-hidden":`true`,size:13,className:TE(n)})]}),n&&(0,X.jsx)(`div`,{id:i,className:`frizz-reasoning mt-1.5 ml-[5px] border-l border-border/70 pl-3`,children:(0,X.jsx)(dk,{md:e,wrap:!0})})]})}function kk(){return(0,X.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-full border border-muted/70 border-t-transparent animate-spin`})}function Ak({since:e,startedAt:t,activityLabel:n,run:r}){let[i]=(0,q.useState)(()=>Date.now()),a=(0,q.useMemo)(()=>{for(let n of[t,e]){let e=Date.parse(n??``);if(Number.isFinite(e)&&e<=Date.now())return e}return i},[t,e,i]),[o,s]=(0,q.useState)(()=>Date.now()),[c,l]=(0,q.useState)(!1),u=(0,q.useId)();(0,q.useEffect)(()=>{let e=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(e)},[]);let d=Te(Math.max(0,o-a)),f=(0,q.useMemo)(()=>OO([...r?.tools??[]]),[r]),p=f.reduce((e,t)=>e+t.count,0),m=p>0,h=`group flex min-w-0 items-baseline justify-between gap-3 rounded text-left outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${CE}`,g=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate shimmer-text`,children:n??Yo(p)}),m&&(0,X.jsx)(br,{"data-working-chevron":!0,"aria-hidden":`true`,size:13,className:TE(c)})]}),(0,X.jsx)(`span`,{className:`shrink-0 whitespace-nowrap tabular-nums text-[12px] leading-none text-muted-60`,children:d})]});return(0,X.jsxs)(`div`,{"data-working-indicator":!0,"data-working-activity":n?`tool`:`generic`,className:`flex min-w-0 flex-col`,children:[m?(0,X.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":u,"aria-expanded":c,"aria-label":`${c?`Collapse`:`Expand`} ${p} tool ${p===1?`call`:`calls`}${n?`: ${n}`:``}`,className:`${h} w-full`,children:g}):(0,X.jsx)(`div`,{className:h,children:g}),m&&c&&(0,X.jsx)(`div`,{id:u,className:`mt-1.5 flex flex-col`,children:(0,X.jsx)(jO,{tools:f,at:r?.at})}),m&&!c&&(0,X.jsx)(`div`,{id:u,hidden:!0})]})}function jk(e){let t=ug(e).filter(e=>e.kind===`question`);if(t.length!==0)return JSON.stringify(t.map(e=>e.kind===`question`?[e.questionKind,e.danger===!0,e.text.trim()]:null))}function Mk(e){let t=new Map,n=[];for(let r=0;r<e.length;r++){let i=jk(e[r].text);n.push(i),i!==void 0&&t.set(i,r)}let r=new Set;for(let e=0;e<n.length;e++){let i=n[e];i!==void 0&&t.get(i)!==e&&r.add(e)}return r}function Nk(e,t,n){return yg(e.text,e.refusedFences)?!n.has(t):qr(e)||e.providerError?!0:e.wake===!0}function Pk(e){return e.wake===!0}function Fk(e,t){let n=[],r,i=!1,a=()=>{r&&r.start<=r.end&&n.push(r),r=void 0};for(let n=Math.max(0,t);n<e.length;n++){let t=e[n];if(t.closes===!0){a(),i=!0;continue}if(t.skip===!0)continue;if(t.opens===!0){a(),i=!0,r={start:n+1,end:n,open:-1,close:-1,steps:0,tools:0,resumed:!0,waker:-1,hiddenBeforeOpen:!1};continue}let o=r===void 0;r||={start:n,end:n,open:-1,close:-1,steps:0,tools:0,resumed:i,waker:-1,hiddenBeforeOpen:!1},o&&t.completion===!0&&r.resumed&&(r.waker=n),r.end=n,r.tools+=t.tools??0,t.text===!0&&(r.open<0&&(r.open=n),r.close=n)}a();for(let t of n)for(let n=t.start;n<=t.end;n++){let r=e[n];r.skip===!0||r.survives===!0||n===t.open||n===t.close||n===t.waker||r.countable===!0&&(t.steps++,n<t.open&&(t.hiddenBeforeOpen=!0))}return n}function Ik(e){return e.open<0||e.tools<1&&e.steps<1?!1:e.resumed||e.open!==e.close}function Lk(e,t=[]){if(e.length<3)return{kept:[...e],middles:[]};let n=new Set;for(let r of t){let t=-1;for(let n=0;n<e.length&&e[n].start<=r;n++)t=n;t>0&&t<e.length-1&&n.add(t)}let r=[e[0]],i=[],a=[],o=()=>{a.length!==0&&(i.push({start:Math.max(r[r.length-1].end+1,a[0].start-1),end:a[a.length-1].end,runs:a.length,tools:a.reduce((e,t)=>e+t.tools,0)}),a=[])};for(let t=1;t<e.length-1;t++){if(!n.has(t)){a.push(e[t]);continue}o(),r.push(e[t])}return o(),r.push(e[e.length-1]),{kept:r,middles:i}}function Rk(e,t){if(!(!t||!Gi(e,t)))for(let e=t.length-1;e>=0;e--){let n=t[e];if(!n.queued)return n.sourceId??`at:${n.at??e}`}}function zk(e,t){let n=(0,q.useRef)(!1),[r,i]=(0,q.useState)(void 0),a=Rk(e,t),o=n.current?a:void 0;(0,q.useEffect)(()=>{if(o===void 0)return;let e=setTimeout(()=>i(o),ti);return()=>clearTimeout(e)},[o]);let s=o!==void 0&&r!==o,c=t!==void 0&&t.length>0;return(0,q.useEffect)(()=>{n.current=c&&(s||a===void 0)},[c,s,a]),s}function Bk(e,t){if(e.runtime!==`turn-idle`&&e.runtime!==`exited`)return!1;let n=Date.parse(e.lastUserAt??``),r=Date.parse(e.lastAssistantAt??``);if(!Number.isFinite(n)||!Number.isFinite(r)||r<n)return!1;for(let e=t.length-1;e>=0;e--){let r=t[e];if(r.queued)continue;if(r.kind!==`event`||r.boundary!==`rest`)return!1;let i=Date.parse(r.at??``);return Number.isFinite(i)&&i<n}return!1}function Vk(e,t,n){return n!==void 0&&t!==void 0&&t===n.messages&&(e.lastAssistantAt??``)!==(n.said??``)}function Hk(e,t,n,r,i,a=new Map){let o=new Map;for(let s of n){let n=e.get(s.id)??(t!==null&&!t.has(s.id)?i:void 0);if(n===void 0||i-n>=1500)continue;let c=r(s.id)??[];!Ia(s,c)&&!Bk(s,c)&&!Vk(s,r(s.id),a.get(s.id))||o.set(s.id,n)}return o}var Uk=200,Wk=320,Gk=()=>ee()?0:Uk;function Kk(e){if(typeof document>`u`)return;let t=document.querySelector(`[data-queue-card="${CSS.escape(e)}"]`);if(!(!t||typeof t.getAnimations!=`function`))return t.getAnimations().find(e=>typeof CSSTransition<`u`&&e instanceof CSSTransition&&e.transitionProperty===`opacity`)}function qk(e){let t=[...document.querySelectorAll(`[data-queue-card]`)],n=t.findIndex(t=>t.dataset.queueCard===e);if(n<0)return null;let r=window.innerHeight,i=e=>{if(!e||e.dataset.queueLeaving===`true`||!e.dataset.queueCard)return!1;let t=e.getBoundingClientRect();return t.bottom>0&&t.top<r},a=i(t[n-1])?t[n-1]:i(t[n+1])?t[n+1]:null;return a?{slug:a.dataset.queueCard,top:a.getBoundingClientRect().top}:null}function Jk(e){let t=[...document.querySelectorAll(`[data-queue-card]`)],n=t.findIndex(t=>t.dataset.queueCard===e);if(n<0)return null;let r=e=>e.dataset.queueLeaving!==`true`&&!!e.dataset.queueCard;for(let e=n+1;e<t.length;e++)if(r(t[e]))return t[e].dataset.queueCard;for(let e=n-1;e>=0;e--)if(r(t[e]))return t[e].dataset.queueCard;return null}var Yk=0,Xk=``;function Zk(){Yk++===0&&(Xk=document.documentElement.style.overflowAnchor,document.documentElement.style.overflowAnchor=`none`)}function Qk(){Yk>0&&--Yk===0&&(document.documentElement.style.overflowAnchor=Xk)}function $k(e){return{...e,tools:[],parts:e.parts?.filter(e=>e.kind!==`tools`)}}function eA(){let e=me(),t=jo(),n=nt(),r=Qa(t),i=Pn(),a=ze(),o=_t(cs).queueOrder,s=(0,q.useMemo)(()=>hr(i,o),[i,o]),c=t?we(s,n,r.projects.map(e=>e.slug)):s,l=c.map(e=>e.id).join(`,`),u=ct(),d=(0,q.useRef)(null),p=(0,q.useRef)(new Map),m=(0,q.useRef)(new Map),h=(0,q.useRef)([]),[g,_]=(0,q.useState)(0),v=(0,q.useCallback)(()=>_(e=>e+1),[]),y=p.current;if(e){let t=e.projectDir,n=d.current&&d.current.project===t?d.current.ids:null,r=e=>u.getQueryData([`transcript`,e])?.messages,i=new Set(c.map(e=>e.id)),a=m.current;if(n)for(let e of h.current)i.has(e.id)||a.set(e.id,{messages:r(e.id),said:e.lastAssistantAt});p.current=Hk(p.current,n,c,r,Date.now(),a);for(let e of[...a.keys()])i.has(e)&&!p.current.has(e)&&a.delete(e);d.current={project:t,ids:i},h.current=c}let b=p.current,x=[...b.keys()].join(`,`),[S,C]=(0,q.useState)(()=>new Set),w=(0,q.useRef)(c);w.current=c;let T=(0,q.useRef)(S);T.current=S;let E=new Set(c.map(e=>e.id)),D=(0,q.useRef)([]),O=(0,q.useRef)([]),k=(0,q.useRef)(new Map),A=(0,q.useRef)(new Set),j=(0,q.useRef)(new Set),M=(0,q.useRef)(new Map),N=(0,q.useRef)(new Set),P=(0,q.useRef)(new Map),F=(0,q.useRef)(new Set),I=(0,q.useRef)(new Map),L=(0,q.useRef)(new Map),R=(0,q.useRef)(null),[z,B]=(0,q.useState)(0);{let e=new Set(D.current.map(e=>e.id));for(let t of c)if(!e.has(t.id)&&S.has(t.id)&&!j.current.has(t.id)&&k.current.has(t.id)&&F.current.add(t.id),e.has(t.id)&&S.has(t.id)&&!j.current.has(t.id)&&!F.current.has(t.id)&&I.current.has(t.id)&&I.current.get(t.id)!==t.lastAssistantAt){let e=D.current.find(e=>e.id===t.id),n=O.current.indexOf(t.id);k.current.has(t.id)||k.current.set(t.id,{view:e,index:n>=0?n:O.current.length}),A.current.add(t.id),F.current.add(t.id)}D.current.forEach(e=>{if(!(!E.has(e.id)&&F.current.delete(e.id))&&!E.has(e.id)&&!j.current.has(e.id)&&!y.has(e.id)){let t=O.current.indexOf(e.id);k.current.delete(e.id),k.current.set(e.id,{view:e,index:t>=0?t:O.current.length}),S.has(e.id)&&A.current.add(e.id)}}),D.current=c;for(let e of[...j.current])E.has(e)?S.has(e)||(j.current.delete(e),A.current.delete(e)):S.has(e)||(j.current.delete(e),k.current.delete(e),A.current.delete(e));for(;k.current.size>32;){let e=k.current.keys().next().value;if(e===void 0)break;k.current.delete(e),A.current.delete(e);let t=M.current.get(e);t&&(clearTimeout(t),M.current.delete(e),N.current.delete(e))}}let ee=e=>E.has(e)?S.has(e):A.current.has(e),te=Ii(),ne=e=>ee(e.id)||$o(e,te[e.id]),re=(0,q.useMemo)(()=>{let e=c.filter(e=>!j.current.has(e.id)&&!b.has(e.id)&&!F.current.has(e.id)),t=[...k.current.entries()].filter(([e])=>(!E.has(e)||F.current.has(e))&&!j.current.has(e)).map(([,e])=>e).sort((e,t)=>e.index-t.index);for(let{view:n,index:r}of t)e.splice(Math.min(r,e.length),0,n);return e},[c,S,z,x,g]);O.current=re.map(e=>e.id);let ie=O.current.join(`,`),ae=(0,q.useRef)([]),oe=(0,q.useRef)(null);va(ae.current,O.current)&&(oe.current=It()),(0,q.useEffect)(()=>{let e=[...k.current.keys()].filter(e=>!E.has(e)&&!j.current.has(e)),t=e.filter(e=>!A.current.has(e)),n;t.length&&(n=requestAnimationFrame(()=>{t.forEach(e=>{k.current.has(e)&&A.current.add(e)}),B(e=>e+1)}));let r=e=>{if(M.current.delete(e),N.current.delete(e),T.current.has(e)){let t=Jk(e);R.current=t?{kind:`top`,slug:t}:null}else{let t=qk(e);R.current=t?{kind:`hold`,...t}:null}if(F.current.delete(e)){k.current.delete(e),A.current.delete(e),I.current.delete(e),L.current.set(e,(L.current.get(e)??0)+1),d.current?.ids.delete(e);let t=P.current.get(e);t&&(clearTimeout(t),P.current.delete(e)),C(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),B(e=>e+1);return}j.current.add(e),A.current.delete(e),B(e=>e+1)},i=new Set;for(let e of S)j.current.has(e)||i.add(e);for(let t of e)A.current.has(t)&&i.add(t);for(let e of i){let t=M.current.get(e);if(t!==void 0){if(!N.current.has(e))continue;clearTimeout(t),N.current.delete(e)}let n=Kk(e),i=setTimeout(()=>r(e),n?Wk:Gk());M.current.set(e,i),n?.finished.then(()=>{M.current.get(e)===i&&(clearTimeout(i),r(e))},()=>{})}for(let t of e)i.has(t)||M.current.has(t)||(N.current.add(t),M.current.set(t,setTimeout(()=>r(t),Wk)));return()=>{n!==void 0&&cancelAnimationFrame(n)}},[l,S,z]),(0,q.useEffect)(()=>{let e=[...S].filter(e=>j.current.has(e)&&!E.has(e));if(e.length!==0){for(let t of e)j.current.delete(t),k.current.delete(t),A.current.delete(t);C(t=>{let n=new Set(t);for(let t of e)n.delete(t);return n})}},[l,z]),(0,q.useEffect)(()=>()=>{for(let e of M.current.values())clearTimeout(e);for(let e of P.current.values())clearTimeout(e)},[]),(0,q.useLayoutEffect)(()=>{let e=oe.current;oe.current=null,ae.current=ie?ie.split(`,`):[],!(!e||R.current||Yk>0||rs())&&f(e)},[ie]),(0,q.useLayoutEffect)(()=>{let e=R.current;if(!e)return;R.current=null;let t=document.querySelector(`[data-queue-card="${CSS.escape(e.slug)}"]`);if(!t)return;if(e.kind===`hold`){let n=t.getBoundingClientRect().top-e.top;Math.abs(n)>.5&&window.scrollBy({top:n,left:0,behavior:`auto`});return}Zk();let n=()=>{let t=us(e.slug);t!==null&&Math.abs(mi()-t)>.5&&window.scrollTo({top:t,left:0,behavior:`auto`})};n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n(),Qk()})})},[z]);let se=(0,q.useCallback)(e=>{C(t=>new Set(t).add(e));let t=w.current.find(t=>t.id===e);t&&I.current.set(e,t.lastAssistantAt);let n=P.current.get(e);n&&clearTimeout(n);let r=setTimeout(()=>{P.current.delete(e),w.current.some(t=>t.id===e)&&(j.current.delete(e),A.current.delete(e),C(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),B(e=>e+1))},8e3);P.current.set(e,r)},[]),ce=(0,q.useCallback)(e=>{let t=P.current.get(e);t&&(clearTimeout(t),P.current.delete(e));let n=M.current.get(e);n&&(clearTimeout(n),M.current.delete(e),N.current.delete(e)),j.current.delete(e),A.current.delete(e),I.current.delete(e),C(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),B(e=>e+1)},[]),le=!t&&a;return(0,X.jsxs)(`div`,{className:`${re.length===0&&!t?`my-auto`:`mb-auto`} w-full min-w-0 flex flex-col py-8`,children:[(0,X.jsx)(nA,{}),[...b].map(([e,t])=>(0,X.jsx)(Go,{project:Si(e),children:(0,X.jsx)(tA,{slug:e,since:t,onSettle:v})},e)),re.length>0&&(0,X.jsx)(`div`,{className:`flex flex-col`,children:re.map((e,t)=>(0,X.jsxs)(q.Fragment,{children:[(0,X.jsx)(iA,{slug:e.id,leaving:ee(e.id),children:(0,X.jsx)(Go,{project:Si(e.id),children:(0,X.jsx)(sA,{thread:e,leaving:ee(e.id),frozen:ne(e),onResolve:se,onUnresolve:ce})})}),t<re.length-1&&(0,X.jsx)(`hr`,{className:`my-10 border-0 border-t border-border/60`})]},`${e.id}:${L.current.get(e.id)??0}`))}),le?(0,X.jsxs)(`div`,{className:`w-full flex flex-col gap-3`,children:[(0,X.jsx)(`h2`,{className:`text-[15px] font-medium text-center`,children:`What should the agent do?`}),(0,X.jsx)(fs,{}),(0,X.jsx)(ao,{autoFocus:!0,pendingCard:`float`})]}):re.length===0?(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-2 pt-2`,children:[(0,X.jsx)(pe,{size:40,strokeWidth:1.25,className:`text-muted-30`}),(0,X.jsx)(`div`,{className:`text-[13px] text-muted-80`,children:`No threads awaiting human input`})]}):null]})}function tA({slug:e,since:t,onSettle:n}){let r=et(e,{poll:!1});return(0,q.useLayoutEffect)(()=>{r.data&&n()},[r.data,n]),(0,q.useEffect)(()=>{let e=setTimeout(n,Math.max(0,t+ti-Date.now()));return()=>clearTimeout(e)},[t,n]),null}function nA(){let e=me(),t=e?.errorItems??[],n=e?.errors??[];return t.length===0&&n.length===0?null:(0,X.jsxs)(`div`,{className:`mb-6 ${um} border border-attention-fill/25 bg-attention-fill/[0.06] px-4 py-2.5 text-[12px] text-attention-detail-90`,children:[(0,X.jsx)(`div`,{className:`font-medium mb-0.5`,children:`Board errors`}),t.length>0?t.slice(0,6).map((e,t)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:`${e.file?`${e.file}: `:``}${e.message}`,children:[e.file?`${e.file}: `:``,e.message]}),e.kind===`no-frontmatter`&&(0,X.jsx)(rA,{file:e.file})]},t)):n.slice(0,3).map((e,t)=>(0,X.jsx)(`div`,{className:`truncate`,title:e,children:e},t))]})}function rA({file:e}){let t=H({mutationFn:()=>U.repairThread({file:e}),onSuccess:({slug:e})=>G(`Repaired ${e} — verify its status`),onError:e=>G(e instanceof Error?e.message:`Repair failed`)});return(0,X.jsx)(`button`,{onClick:()=>t.mutate(),disabled:t.isPending,className:`shrink-0 rounded border border-attention/50 bg-attention-fill/10 px-2 py-0.5 text-[11px] font-medium text-attention-soft transition-colors hover:bg-attention-fill/25 disabled:opacity-50`,title:`Prepend minimal frontmatter (title + status: active) so this thread becomes visible again`,children:t.isPending?`Repairing…`:`Repair`})}function iA({leaving:e,slug:t,children:n}){return(0,X.jsx)(`div`,{"data-queue-card":t,"data-queue-leaving":e,className:`frizz-card-slot min-w-0`,children:(0,X.jsx)(`div`,{className:`frizz-card-clip min-h-0 min-w-0`,children:(0,X.jsx)(`div`,{className:`frizz-card-body min-w-0`,children:n})})})}function aA({runs:e,toolCount:t,onExpand:n}){let r=t>0?`${t} tool call${t===1?``:`s`}`:``,i=`${e} more round${e===1?``:`s`}`;return(0,X.jsxs)(Q,{icon:rc,marker:`middle-runs-summary`,onClick:n,ariaLabel:`Expand ${i}${r?` and ${r}`:``} of intermediate agent activity`,children:[(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:i}),r&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50 @max-[34rem]/wake:hidden`,children:`·`}),(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums @max-[34rem]/wake:hidden`,children:r})]}),(0,X.jsx)($y,{})]})}function oA({toolCount:e,onExpand:t}){let n=e>0?`${e} tool call${e===1?``:`s`}`:``;return(0,X.jsx)(Q,{icon:rc,marker:`intermediate-summary`,onClick:t,ariaLabel:`Expand ${n?`${n} of `:``}intermediate agent activity`,children:n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:n}),(0,X.jsx)($y,{})]}):(0,X.jsx)(`span`,{className:`shrink-0`,children:`Click to expand`})})}var sA=(0,q.memo)(function({thread:e,leaving:t,frozen:n,onResolve:r,onUnresolve:i}){let a=_t(W),o=jo(),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(0),y=(0,q.useRef)(null),b=(0,q.useRef)(null),x=(0,q.useRef)(!1),S=(0,q.useRef)(!1),C=(0,q.useRef)(null),w=ct(),T=et(e.id,{poll:!1}),E=zk(e,T.data?.messages),D=n||E,O=(0,q.useRef)(T.data);D||(O.current=T.data);let k=D?O.current:T.data,A=(0,q.useRef)(null),j=(0,q.useRef)(0),M=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=M.current,t=A.current;if(!e||!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>t.style.setProperty(`--queue-card-header-h`,`${e.getBoundingClientRect().height}px`));return n.observe(e),()=>n.disconnect()},[]),(0,q.useEffect)(()=>{let t=s?null:A.current?.querySelector(`:scope > [data-thread-composer-box]`);if(!(!t||typeof ResizeObserver>`u`))return Bn(e.id,t)},[s,e.id]),(0,q.useEffect)(()=>{let e=A.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(t=>{if(e.style.height)return;let n=t[0]?.borderBoxSize?.[0];n&&(j.current=n.blockSize)});return t.observe(e),()=>t.disconnect()},[]),(0,q.useLayoutEffect)(()=>{let e=A.current;if(e){if(!t){e.style.height=``,e.style.overflow=``;return}j.current>0&&(e.style.height=`${j.current}px`,e.style.overflow=`clip`)}});let{messages:N,openQuestions:P,settledQuestions:F,transcriptShells:I}=QS(e,(0,q.useMemo)(()=>k?.messages??[],[k])),L=e.runtime===`running`||e.runtime===`spawning`,R=(0,q.useCallback)(()=>r(e.id),[r,e.id]),z=(0,q.useCallback)(()=>i(e.id),[i,e.id]),B=sC({slug:e.id,thread:e,messages:N,openQuestions:P,settledQuestions:F},{exit:{dismiss:R,cancel:z},onFilesDropped:()=>c(!1)}),{lastAgentIdx:ee,hidesAwaiting:te,paired:ne,fencesLive:re,shadowedByMessage:ie,settledPlacement:ae,inFlightAnswers:oe}=B.transcript,se=(0,q.useMemo)(()=>v_(N),[N]),ce=(0,q.useMemo)(()=>{for(let e=N.length-1;e>=0;e--)if(N[e].boundary===`rest`)for(let t=e+1;t<N.length;t++){let n=N[t];if(!(n.queued||n.boundary===`rest`||mO(n,...te(t))))return e+1}return 0},[N]),le=(0,q.useMemo)(()=>{for(let e=N.length-1;e>=0;e--)if(N[e].role===`user`&&!N[e].queued)return e;return-1},[N]),ue=(0,q.useMemo)(()=>Mk(N),[N]),de=(0,q.useMemo)(()=>N.map((e,t)=>{if(!e||e.queued||mO(e,...te(t))||e.pinnedFromSourceId)return{skip:!0};if(e.boundary===`rest`)return{skip:!0,closes:!0};let n=dE(e),r=n?0:e.tools.length;return{text:bO(e,...te(t)),tools:r,countable:bO(e,...te(t))||r>0||n!==void 0||e.kind!==void 0,survives:Nk(e,t,ue),opens:Pk(e),completion:e.boundary===`wake`||n!==void 0}}),[N,ue]),fe=(0,q.useMemo)(()=>Fk(de,se+1),[de,se]),V=Zo(N,p,se),pe=(0,q.useMemo)(()=>N.slice(V),[N,V]),me=(0,q.useMemo)(()=>Yn(pe).map(e=>({...e,messageIndex:e.messageIndex+V})),[pe,V]),he=(0,q.useMemo)(()=>L?Qe(me):me,[me,L]),ge=(0,q.useMemo)(()=>{let e=new Map;return he.forEach(({message:t},n)=>{if(t.boundary!==`rest`)return;let r;for(let e=n+1;e<he.length&&!r;e++){let t=he[e];!t.message.queued&&!mO(t.message,...te(t.messageIndex))&&(r=t.message)}let i=uO(t,r);i&&e.set(n,i)}),e},[he,te]),_e=JD(B.transcript,me,he),ve=(0,q.useMemo)(()=>U_(B.transcript.placement,V),[B.transcript.placement,V]),ye=(0,q.useMemo)(()=>{let e=[],t=new Map,n=N.length-1,r=P.filter(e=>!ve.placedIds.has(e.id));for(let[i,a]of E_(N,r,{from:V})){if(i>=n){e.push(...a);continue}let r=t.get(i);r?r.push(...a):t.set(i,[...a])}let i=!1,a=new Set;for(let e of W_(N,ve)){if(e>=n){i=!0;continue}a.add(e),t.has(e)||t.set(e,[])}return{byAnchor:t,tail:e,tailSend:i,sendAnchors:a}},[N,P,ve,V]),be=V>0||k?.hasEarlier===!0,xe=(0,q.useMemo)(()=>[...ve.placed.keys(),...ye.byAnchor.keys(),...Mx(N,se)],[ve,ye,N,se]),{kept:Se,middles:Ce}=(0,q.useMemo)(()=>Lk(fe,xe),[fe,xe]),we=(0,q.useMemo)(()=>Se.filter(Ik),[Se]),Te=(0,q.useMemo)(()=>{let e=new Map;return we.forEach((t,n)=>{for(let r=t.start;r<=t.end;r++)e.set(r,n)}),e},[we]),Ee=!l&&(le>=0||ce>0)&&(we.length>0||Ce.length>0);(0,q.useLayoutEffect)(()=>{let e=b.current,t=y.current;if(!e||!t||![...t.querySelectorAll(`[data-transcript-source-id]`)].some(t=>t.dataset.transcriptSourceId===e.targetStartId))return;let n=()=>{ci(t,e.anchor,e=>{e!==0&&window.scrollBy({top:e,left:0,behavior:`auto`})});let n=0;return ci(t,e.anchor,e=>{n=e}),n},r=n();if(Ti({remaining:r,scrollY:window.scrollY,maxScrollY:Math.max(0,document.documentElement.scrollHeight-window.innerHeight),alreadyReserved:e.reserved===!0})===`reserve`){e.reserved=!0,v(e=>e+Math.ceil(r));return}S.current||(S.current=!0,requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n(),b.current=null,S.current=!1,x.current&&(x.current=!1,Qk())})}))},[_,N,p]),(0,q.useEffect)(()=>{let e=k?.transcriptKey;if(!e)return;let t=C.current;C.current=e,!(!t||t===e)&&(m(null),v(0),u(!1),b.current=null,S.current=!1,x.current&&(x.current=!1,Qk()))},[k?.transcriptKey]),(0,q.useEffect)(()=>()=>{x.current&&(x.current=!1,Qk())},[]);let De=e=>{let t=Po(y.current);!e||!t||(x.current||(x.current=!0,Zk()),b.current={anchor:t,targetStartId:e})},Oe=async()=>{if(h||!be)return;let t=Ta(N,V),n=t!==null&&N[t]?.role===`user`?t:null;if(n!==null){let e=N[n].sourceId;De(e),m(e??null);return}let r=k?.beforeCursor;if(!r){if(V>0){let e=N[0]?.sourceId;De(e),m(e??null)}return}let i=k?.transcriptKey;if(i){g(!0);try{let t,n=await TD({slug:e.id,cursor:r,expectedKey:i,queryClient:w,refetch:()=>T.refetch(),beforePrepend:e=>{t=e.messages[0]?.sourceId??N[0]?.sourceId,De(t)}});m(n?t??null:null)}catch(e){await T.refetch(),m(null),G(e instanceof Error?e.message:`Could not load earlier transcript history`)}finally{g(!1)}}},ke=H({mutationFn:()=>U.markComplete({slug:e.id})}),{answerable:Ae,anyAnswered:je,sendAnswers:Me,sendMessage:Ne}=B.answering,Pe=B.promptBoxSends,Fe=(0,q.useMemo)(()=>{let e=Kb(N);return e!==-1&&P_(N[e].text,ie.get(e)??[])},[N,ie]),Ie=!Pe&&re&&(Ae&&!Fe||je);return(0,X.jsxs)(cC,{surface:B,ref:A,"data-queue-card-root":e.id,"data-queue-leaving":t,style:{..._?{marginBottom:_}:null,...a.vtReturnTarget===e.id?{viewTransitionName:`thread-chat`}:null},onKeyDown:e=>{if(!je)return;let t=e.target;t instanceof HTMLButtonElement||t instanceof HTMLAnchorElement||t instanceof HTMLTextAreaElement&&t.value.trim()||Hr({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),Me())},"data-vt-chat":!0,className:`flex flex-col min-w-0 max-w-full ${um} border ${B.fileOver?`border-accent`:`border-border-strong`} bg-panel shadow-lg shadow-shadow-ink/25 transition-opacity ${d?`opacity-40`:``}`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col min-w-0 ${s?``:`mb-[calc(-1*var(--queue-card-header-h,0px))]`}`,children:[!s&&o&&(0,X.jsx)(`div`,{"aria-hidden":!0,"data-queue-card-cap":!0,className:`sticky top-0 z-10 h-[var(--queue-card-cap-h)] mb-[calc(-1*var(--queue-card-cap-h))] shrink-0 bg-panel rounded-t-xl`,style:{"--queue-card-cap-h":`min(var(--frizz-sticky-cap, 0px), var(--queue-card-header-h, 0px))`}}),(0,X.jsxs)(`div`,{ref:M,className:`sticky top-[var(--frizz-sticky-top,0px)] z-10 flex items-center gap-2 bg-panel px-5 py-3.5 max-[800px]:top-[var(--frizz-sticky-top-narrow,2.5rem)] ${s?um:`${dm} border-b border-border/60`}`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(uE,{thread:e,className:`leading-snug`}),(0,X.jsx)(oE,{thread:e})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,X.jsx)(WT,{thread:e,collapsed:s,onCollapse:()=>c(e=>!e),expand:!0,onDone:()=>ke.mutate(void 0,{onSuccess:()=>r(e.id),onError:()=>f(!1)}),doneBusy:ke.isPending,onStatusMutate:()=>f(!0),onStatusApplied:()=>r(e.id),onStatusFailed:()=>f(!1)}),(0,X.jsx)(vT,{thread:e,onArchived:()=>r(e.id),onDismissCancel:()=>i(e.id),onSnoozed:()=>r(e.id)})]})]}),s?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`px-5 pt-5 ${Ie?`pb-2`:`pb-5`}`,children:[T.transportFallback&&(0,X.jsx)(HD,{fallback:T.transportFallback,isFetching:T.isFetching,onRefresh:()=>void T.refetch(),onRetryLive:T.retryLiveUpdates,className:`mb-3.5`}),N.length===0?(0,X.jsx)(`p`,{className:`text-[13px] text-muted`,children:T.isLoading?`Loading…`:e.statusText||`No message yet.`}):(0,X.jsxs)(`div`,{ref:y,className:`flex flex-col`,children:[be&&(0,X.jsx)(`button`,{className:`mb-3.5 self-center rounded-md border border-border px-2 py-0.5 text-[11px] text-muted transition-colors hover:text-fg hover:bg-panel-2 outline-none`,onClick:()=>void Oe(),onMouseDown:e=>e.preventDefault(),disabled:h,children:h?`Loading earlier messages…`:k?.reachedTurnBoundary===!1?`Continue loading this turn`:`Load earlier messages`}),(()=>{let t=V,n=[],r,i=e=>r?fO(r,e):lO(e)?22:14,a=(e,t)=>{r!==void 0&&n.push((0,X.jsx)(ib,{h:i(t)},`s${e}`))},o=[...ye.byAnchor.entries()].sort((e,t)=>e[0]-t[0]),s=[...ae.anchored.entries()].filter(([e])=>e>=t).sort((e,t)=>e[0]-t[0]),c=e=>{for(;s.length>0&&s[0][0]<=e;){let[e,t]=s.shift();r!==void 0&&n.push((0,X.jsx)(ib,{h:14},`sq-space-${e}`)),n.push((0,X.jsx)(PS,{questions:t,wrap:!0},`sq-${e}`)),r=null}},l=t=>{for(c(t);o.length>0&&o[0][0]<=t;){let[t,i]=o.shift();r!==void 0&&n.push((0,X.jsx)(ib,{h:14},`qa-space-${t}`)),n.push((0,X.jsx)(XS,{thread:e,questions:i,showSend:ye.sendAnchors.has(t)},`qa-${t}`)),r=null}};l(t-1);let d=new Set,f=new Set;return he.forEach(({message:e,messageIndex:t},i)=>{if(e.queued||mO(e,...te(t)))return;if(e.boundary===`rest`){let o=ge.get(i);if(!o)return;l(t-1),a(i,e),n.push((0,X.jsx)(dO,{rest:e,at:o},e.sourceId??`rest-gap-${t}`)),r=e,l(t);return}let o=Ee?Ce.findIndex(e=>t>=e.start&&t<=e.end):-1;if(o>=0){let e=Ce[o];f.has(o)||(f.add(o),l(t-1),r!==void 0&&n.push((0,X.jsx)(ib,{h:14},`middle-runs-space-${o}`)),n.push((0,X.jsx)(aA,{runs:e.runs,toolCount:e.tools,onExpand:()=>u(!0)},`middle-runs-summary-${o}`)),r=null);return}let s=Ee?Te.get(t):void 0,c=s===void 0?void 0:we[s],p=c!==void 0,m=c!==void 0&&t===c.open,h=c!==void 0&&t===c.close,g=p&&!m&&!h&&!yg(e.text,e.refusedFences)&&!qr(e)&&Nk(e,t,ue);if(c!==void 0&&t===c.waker){l(t-1),a(i,e);let o=e.sourceId??`legacy-${t}`;n.push((0,X.jsx)(`div`,{"data-transcript-source-id":o,className:`flex flex-col`,children:(0,X.jsx)(ck,{m:e,dense:!0})},o)),r=e;return}if(p&&!g){if(!m&&!h&&!Nk(e,t,ue))return;let o=m&&h,f=()=>{s===void 0||d.has(s)||(r!==void 0&&n.push((0,X.jsx)(ib,{h:14},`im-space-${s}`)),n.push((0,X.jsx)(oA,{toolCount:c.tools,onExpand:()=>u(!0)},`intermediate-summary-${s}`)),r=null,d.add(s))};if((!m||o&&c.hiddenBeforeOpen)&&f(),!bO(e,...te(t)))return;l(t-1);let p=$k(e);a(i,p);let g=e.sourceId??`legacy-${t}`;n.push((0,X.jsx)(`div`,{"data-transcript-source-id":g,className:`flex flex-col`,children:(0,X.jsx)(sk,{m:e,index:t,dense:!0,textOnly:!0})},g)),r=p,o&&f(),l(t);return}l(t-1),a(i,e);let _=e.sourceId??`legacy-${t}`;n.push((0,X.jsx)(`div`,{"data-transcript-source-id":_,className:`flex flex-col`,children:(0,X.jsx)(sk,{m:e,index:t,dense:!0})},_)),r=e,l(t)}),l(1/0),n})()]}),!T.isLoading&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(iD,{thread:e,className:`mt-4`}),(0,X.jsx)(YD,{tail:_e,wrap:!0}),(()=>{let e=null;return pe.map((t,n)=>{if(!t.queued)return null;let r=e?fO(e,t):14;return e=t,(0,X.jsxs)(q.Fragment,{children:[(0,X.jsx)(ib,{h:r}),(0,X.jsx)(`div`,{className:`flex flex-col`,children:(0,X.jsx)(ck,{m:t,dense:!0,paired:ne[V+n]})})]},`q${V+n}`)})})(),(0,X.jsx)(ik,{})]})]}),(0,X.jsx)(XS,{thread:e,questions:ye.tail,inFlight:oe,showSend:ye.tailSend,className:`shrink-0 px-5 pb-4 pt-0`}),Ie&&(0,X.jsx)(`div`,{className:`shrink-0 px-5 pt-0`,children:(0,X.jsx)(`div`,{className:`mb-4 flex items-center justify-start gap-2`,children:(0,X.jsx)(`button`,{disabled:!je,onClick:()=>Me(),onMouseDown:e=>e.preventDefault(),className:`button-outline rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:`Send answers`})})})]})]}),s?null:(0,X.jsx)(Vw,{slug:e.id,surface:`queueComposer`,className:`sticky bottom-0 z-10 mt-[var(--queue-card-header-h,0px)] shrink-0 ${fm} border-t border-border/60 bg-panel px-5 pb-3 pt-3 shadow-[0_-12px_18px_-14px_var(--dock-shadow)]`,submitOverride:Ne,above:(0,X.jsx)(aT,{thread:e,transcriptShells:I})})]})},cA);function cA(e,t){return e.leaving===t.leaving&&e.frozen===t.frozen&&e.onResolve===t.onResolve&&e.onUnresolve===t.onUnresolve&&(e.thread===t.thread||JSON.stringify(e.thread)===JSON.stringify(t.thread))}function lA({label:e,stopping:t,onStop:n,...r}){return(0,X.jsx)(ua,{label:e,children:(0,X.jsx)(`button`,{type:`button`,...r,"aria-label":e,disabled:t,onClick:n,onMouseDown:e=>e.preventDefault(),className:Vt,children:t?(0,X.jsx)(Ut,{size:14,className:`animate-spin`}):(0,X.jsx)(Qt,{size:15,strokeWidth:2})})})}function uA({id:e,slug:t,subId:n,label:r,subagentType:i,startedAt:a,depth:o,widthDepth:s}){let[c,l]=(0,q.useState)(!1),u=(0,q.useRef)(null),[d,f]=(0,q.useState)(!1),p=ct(),m=Zn(t,n),h=Ae(),g=(0,q.useMemo)(()=>m.data?.messages??[],[m.data]),_=m.data?.state,v=_===`running`,y=(0,q.useMemo)(()=>Px(g),[g]),b=(0,q.useMemo)(()=>Fx(g),[g]),x=(0,q.useMemo)(()=>Yn(b),[b]),S=v?yr(x):void 0,C=v?Zt(x):void 0,w=C?Xa(C,h):void 0,T=v?rr(x):void 0,E=(0,q.useMemo)(()=>v?Qe(x):x,[x,v]),D=v,O=m.isError||_===`gone`||g.length===0&&(_===`done`||_===`stale`);(0,q.useEffect)(()=>{let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>l(!0))});return()=>{cancelAnimationFrame(t),e&&cancelAnimationFrame(e)}},[]);let[k,A]=(0,q.useState)(null),j=(0,q.useRef)(!0);(0,q.useLayoutEffect)(()=>{let e=u.current;e&&k&&j.current&&e.scrollHeight-e.scrollTop-e.clientHeight>.5&&(e.scrollTop=e.scrollHeight)}),(0,q.useLayoutEffect)(()=>{let e=u.current;if(!e||!k)return;j.current=!0;let t=()=>{j.current&&(e.scrollTop=e.scrollHeight)},n=()=>{j.current=e.scrollHeight-e.scrollTop-e.clientHeight<160};e.addEventListener(`scroll`,n,{passive:!0});let r=new ResizeObserver(t);return r.observe(k),r.observe(e),t(),()=>{e.removeEventListener(`scroll`,n),r.disconnect()}},[k]);function M(){d||(f(!0),U.subAgentStop({slug:t,id:n}).then(({descendantsStopped:e,note:r})=>{r?G(`Sub-agent stopped. ${r}`,{duration:7e3}):G(e>0?`Sub-agent and ${e} descendant${e===1?``:`s`} stopped`:`Sub-agent stopped`),p.invalidateQueries({queryKey:[`subAgentTranscript`,t,n]})}).catch(e=>{G(e instanceof Error?e.message:`Could not stop this sub-agent`)}).finally(()=>f(!1)))}let N=m.data?.stoppable?(0,X.jsx)(lA,{"data-stop-subagent":``,label:`Stop sub-agent`,stopping:d,onStop:M}):m.data?.outcome?(0,X.jsx)(pA,{outcome:m.data.outcome,startedAt:m.data.startedAt??a,finishedAt:m.data.finishedAt}):null;return(0,X.jsx)(qa,{id:e,depth:o,widthDepth:s,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`header`,{"data-subagent-header":!0,className:`flex ${ae} min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2.5 pl-1`,children:[(0,X.jsx)(ms,{onClose:e}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 leading-tight`,children:[(0,X.jsx)(`div`,{className:`flex min-w-0 items-center`,children:(0,X.jsx)(`div`,{className:`min-w-0 max-w-full shrink truncate px-0.5 -mx-0.5 font-semibold text-[15px]`,title:r,children:r})}),(0,X.jsx)(sE,{"data-subagent-header-facts":``,lastActiveAt:m.data?.lastActivityAt,fallbackAt:m.data?.startedAt??a,reading:m.data?.context?(0,X.jsx)(eE,{context:m.data.context}):null})]})]}),N&&(0,X.jsx)(`div`,{className:`flex shrink-0 items-center`,children:N})]}),(0,X.jsx)(`div`,{ref:u,className:`flex-1 min-h-0 overflow-y-auto`,children:O?(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center px-8 text-center text-[13px] text-muted`,children:`Transcript unavailable (agent completed or cleaned up).`}):!c||m.isLoading||g.length===0?(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,X.jsx)(`span`,{className:`block h-5 w-5 rounded-full border-2 border-muted/50 border-t-transparent animate-spin`})}):(0,X.jsx)(MD.Provider,{value:t,children:(0,X.jsxs)(`div`,{ref:A,"data-transcript-column":!0,className:`flex flex-col px-6 py-5`,children:[SO(E.map(e=>e.message),(e,t)=>(0,X.jsx)(ck,{m:e},t)),D&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ib,{h:xO(E.map(e=>e.message))}),(0,X.jsx)(Ak,{since:a,startedAt:T,activityLabel:w,run:S})]})]})})}),(0,X.jsx)(dA,{slug:t,subId:n,subagentType:i,observedModel:m.data?.model,steerable:m.data?.steerable===!0,note:m.data?.steerNote??null,stoppable:m.data?.stoppable===!0,stopNote:m.data?.stopNote??null,stopping:d,ops:e=>(0,X.jsx)(Sk,{slug:t,parentAgentId:n,transcriptShells:y,className:e})})]})})}function dA({slug:e,subId:t,subagentType:n,observedModel:r,steerable:i,note:a,stoppable:o,stopNote:s,stopping:c,ops:l}){let[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(!1),m=ct();function h(){let n=u.trim();!n||f||(p(!0),d(``),U.subAgentSteer({slug:e,id:t,message:n,deliveryId:crypto.randomUUID()}).then(()=>{m.invalidateQueries({queryKey:[`subAgentTranscript`,e,t]}),G(`Steer sent`)}).catch(e=>{d(n),G(e instanceof Error?e.message:`Could not steer this sub-agent`)}).finally(()=>p(!1)))}if(!i){let e=a??(o?null:s);return e?(0,X.jsxs)(`div`,{"data-subagent-steer-note":!0,className:`w-full shrink-0 border-t border-border bg-panel px-3 py-3`,children:[(0,X.jsx)(`div`,{className:`px-1 pb-2 text-[11.5px] text-muted-70`,children:e}),(0,X.jsx)(`div`,{className:`pl-1.5`,children:(0,X.jsx)(fA,{subagentType:n,observedModel:r})}),l?.(`px-1 pt-1.5 ops-column-optical-inset`)]}):(0,X.jsx)(X.Fragment,{children:l?.(`w-full shrink-0 border-t border-border bg-panel px-4 pb-2 pt-3`)})}return(0,X.jsxs)(`div`,{"data-subagent-steer":!0,className:`w-full shrink-0 border-t border-border bg-panel px-3 py-3`,children:[(0,X.jsx)(mr,{value:u,onChange:d,onSubmit:h,surface:`subAgentComposer`,placeholder:`Steer this sub-agent…`,busy:f||c,footer:(0,X.jsx)(fA,{subagentType:n,observedModel:r})}),!o&&s&&(0,X.jsx)(`div`,{className:`mt-2 px-1 text-[11.5px] text-muted-70`,children:s}),l?.(`px-1 pt-1.5 ops-column-optical-inset`)]})}function fA({subagentType:e,observedModel:t}){let n=uo(e,t),r=n?La(n):`Profile unknown`;return(0,X.jsx)(`span`,{"data-subagent-profile":!0,"aria-label":`Sub-agent profile: ${r}`,title:n?r:`The provider did not report this sub-agent's model and effort`,className:`inline-flex h-6 min-w-0 max-w-[min(72%,20rem)] items-center rounded-md border border-border/50 bg-transparent px-1.5 text-muted ${he}`,children:(0,X.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 truncate`,children:n&&n.verbatim===void 0?(0,X.jsxs)(X.Fragment,{children:[n.role&&`${n.role} · `,n.model,n.edition&&(0,X.jsxs)(X.Fragment,{children:[` `,(0,X.jsx)(`span`,{className:`profile-grid-edition text-edition`,children:n.edition})]}),n.effort&&`${n.model?` › `:``}${n.effort}`]}):r})})}function pA({outcome:e,startedAt:t,finishedAt:n}){let r=fE[e],i=`${r[0].toUpperCase()}${r.slice(1)}`,a=t&&n?Date.parse(n)-Date.parse(t):NaN,o=Number.isFinite(a)&&a>=0?`${i} after ${er(a)}`:i;return(0,X.jsx)(bT,{"data-subagent-outcome":e,check:e===`completed`,tooltip:o,children:i})}function mA({id:e,slug:t,title:n,depth:r,widthDepth:i}){let a=Re({queryKey:[`threadBody`,t],queryFn:()=>U.threadBody({slug:t})}),o=_t(W);(0,q.useEffect)(()=>{a.refetch()},[o.board]);let s=ZC(vs(o.board,t)),c=yn(),l=jr.adopt(c,t),[u,d,f]=Yr(l),p=H({mutationFn:async e=>{await U.adoptThread({slug:t,message:e.trim()||void 0})},onSuccess:()=>{W.drawers.find(t=>t.id===e)?.closing||(W.drawers=W.drawers.map(t=>t.id===e?{...t,kind:`thread`}:t))},onError:(e,t)=>{ls.get(l)||d(t),G(`Start failed: ${e.message.slice(0,80)}`)}}),m=tp(Lf(a.data?.markdown??``)),h=Up(m),g=(0,q.useRef)(null),_=th(g,m);return(0,X.jsx)(qa,{id:e,depth:r,widthDepth:i,widthOffset:1,subagentParent:t,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(wn,{title:n,subtitle:`${t}.md`,onClose:e}),(0,X.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:a.isLoading?(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):m?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{ref:g,className:`md-body`,dangerouslySetInnerHTML:h}),_]}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`No thread file found.`})}),s&&(0,X.jsxs)(`div`,{className:`shrink-0 border-t border-border/60 px-5 pb-4 pt-3`,children:[(0,X.jsx)(`p`,{className:`mb-2.5 text-[11.5px] text-muted-80`,children:`No session is attached to this thread yet. Send a message below to start one on this plan.`}),(0,X.jsx)(mr,{surface:`adoptComposer`,value:u,onChange:d,onSubmit:()=>{if(!u.trim()||p.isPending)return;let e=u;f(),G(`Starting thread…`,{spinner:!0,sticky:!0}),p.mutate(e)},placeholder:`Kick off work on this thread…`,minHeight:44,busy:p.isPending})]})]})})}var hA=`font-mono-keep overflow-x-auto whitespace-pre-wrap break-words ${um} border border-border bg-bg/75 px-4 py-2.5 text-[12px] leading-relaxed text-fg/85`;function gA({id:e,slug:t,shellId:n,label:r,startedAt:i,depth:a,widthDepth:o}){let s=Gt(t,n),c=s.data?.state,[l,u]=(0,q.useState)(!1),d=ct(),f=w(i),p=c===`running`?`running${f?` ${f}`:``}`:c===`done`?`finished`:c===`gone`?`unavailable`:``,m=s.isError||c===`gone`;function h(){l||(u(!0),U.subAgentStop({slug:t,id:n}).then(({note:e})=>{e?G(`Background shell stopped. ${e}`,{duration:7e3}):G(`Background shell stopped — the worker was told`),d.invalidateQueries({queryKey:[`backgroundShellOutput`,t,n]})}).catch(e=>{G(e instanceof Error?e.message:`Could not stop this background shell`)}).finally(()=>u(!1)))}return(0,X.jsx)(vA,{id:e,depth:a,widthDepth:o,kind:`background-shell`,title:r,icon:(0,X.jsx)(Ac,{"aria-hidden":!0,size:14,className:`shrink-0 text-muted-60`}),stateLabel:p,command:s.data?.command,output:s.data?.output??``,truncated:s.data?.truncated===!0,running:c===`running`,loading:s.isLoading,unavailable:m,unavailableText:`Background shell output is no longer available.`,noCommandText:`Command unavailable for this background operation.`,emptyText:c===`done`?`No output was captured.`:`No output yet.`,stop:!m&&s.data?.stoppable?{label:`Stop shell`,stopping:l,onStop:h}:void 0,footer:!m&&!s.data?.stoppable&&c===`running`?s.data?.stopNote??void 0:void 0})}function _A({id:e,slug:t,monitorId:n,label:r,depth:i,widthDepth:a}){let o=x(t,n),s=o.data,[c,l]=(0,q.useState)(!1),u=ct(),d=s?`${s.events} event${s.events===1?``:`s`}`:``,f=w(s?.startedAt??void 0),p=s?.state===`running`?[`running${f?` ${f}`:``}`,d].join(` · `):s?.state===`ended`?[s.ended??`ended`,d].join(` · `):s?.state===`gone`?`unavailable`:``,m=o.isError||s?.state===`gone`;function h(){c||(l(!0),U.stopMonitor({slug:t,id:n}).then(({stopped:e})=>{G(e?`Monitor stopped — the worker was told`:`This monitor had already ended`),u.invalidateQueries({queryKey:[`monitorOutput`,t,n]})}).catch(e=>{G(e instanceof Error?e.message:`Could not stop this monitor`)}).finally(()=>l(!1)))}return(0,X.jsx)(vA,{id:e,depth:i,widthDepth:a,kind:`monitor`,title:s?.description||r,icon:(0,X.jsx)(gt,{"aria-hidden":!0,size:14,className:`shrink-0 text-muted-60`}),stateLabel:p,command:s?.command,output:s?.output??``,truncated:s?.truncated===!0,running:s?.state===`running`,loading:o.isLoading,unavailable:m,unavailableText:`This monitor is no longer available.`,noCommandText:`Script unavailable for this monitor.`,emptyText:s?.state===`ended`?`It printed nothing.`:`Nothing printed yet.`,stop:!m&&s?.stoppable?{label:`Stop monitor`,stopping:c,onStop:h}:void 0})}function vA({id:e,depth:t,widthDepth:n,kind:r,title:i,icon:a,stateLabel:o,command:s,output:c,truncated:l,running:u,loading:d,unavailable:f,unavailableText:p,noCommandText:m,emptyText:h,stop:g,footer:_}){let v=(0,q.useRef)(null),y=e=>({[`data-${r}-${e}`]:``});(0,q.useEffect)(()=>{let e=v.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<160&&(e.scrollTop=e.scrollHeight)},[c]);async function b(){if(s)try{await ce(s),G(`Command copied`)}catch{G(`Could not copy command`)}}return(0,X.jsx)(qa,{id:e,depth:t,widthDepth:n,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(wn,{title:i,icon:a,meta:o?(0,X.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-[11.5px] text-muted-60`,children:o}):void 0,actions:g?(0,X.jsx)(`span`,{className:`-mr-1 flex shrink-0`,children:(0,X.jsx)(lA,{...y(`stop`),...r===`background-shell`?{"data-stop-background-shell":``}:{},label:g.label,stopping:g.stopping,onStop:g.onStop})}):void 0,onClose:e}),(0,X.jsx)(`div`,{ref:v,className:`min-h-0 flex-1 overflow-y-auto px-5 py-5`,children:f?(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center px-8 text-center text-[13px] text-muted`,children:p}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h2`,{className:`petite-caps text-[10px] text-muted-65`,children:`Command`}),s&&(0,X.jsxs)(`button`,{type:`button`,onClick:b,className:`button-outline flex items-center gap-1 rounded px-1.5 py-1 text-[10.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:[(0,X.jsx)(Xn,{"aria-hidden":!0,size:11}),` Copy`]})]}),s?(0,X.jsx)(eg,{...y(`command`),text:s,language:`bash`,className:hA}):(0,X.jsx)(`pre`,{...y(`command`),className:hA,children:d?`Loading…`:m})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`petite-caps text-[10px] text-muted-65`,children:`Output`}),u&&(0,X.jsx)(es,{"aria-hidden":!0,hue:`shell`,"data-running-indicator":r===`monitor`?`monitor-drawer`:`shell-drawer`}),l&&(0,X.jsx)(`span`,{className:`text-[10.5px] text-muted-50`,children:`Showing latest 512 KB`})]}),c?(0,X.jsx)(`pre`,{...y(`output`),className:`font-mono-keep min-h-40 whitespace-pre-wrap break-words ${um} border border-border bg-inset px-4 py-3 text-[12px] leading-relaxed text-fg/85`,children:c}):(0,X.jsx)(`div`,{...y(`output`),className:`flex min-h-40 items-center justify-center ${um} border border-border bg-inset px-4 text-center text-[12px] text-muted-60`,children:h})]})]})}),_&&(0,X.jsx)(`footer`,{...y(`stop-note`),className:`w-full shrink-0 border-t border-border/70 bg-panel/95 px-4 pt-2 pb-[max(0.5rem,env(safe-area-inset-bottom))] text-[11.5px] text-muted-70`,children:_})]})})}var yA=64,bA=12,xA=yA-bA-4,SA=16,CA=`#4a9eff`,wA,TA,EA=!1;function DA(){return wA??=[...document.querySelectorAll(`link[rel~="icon"]`)].map(e=>({link:e,href:e.getAttribute(`href`)??``,type:e.getAttribute(`type`),sizes:e.getAttribute(`sizes`)})),wA}function OA(e){let t=document.createElement(`canvas`);t.width=t.height=yA;let n=t.getContext(`2d`);return n.drawImage(e,0,0,yA,yA),n.globalCompositeOperation=`destination-out`,n.beginPath(),n.arc(xA,SA,16,0,Math.PI*2),n.fill(),n.globalCompositeOperation=`source-over`,n.fillStyle=CA,n.beginPath(),n.arc(xA,SA,bA,0,Math.PI*2),n.fill(),t.toDataURL(`image/png`)}function kA(e){return TA??=new Promise((t,n)=>{let r=e.find(e=>e.type===`image/svg+xml`)??e[0];if(!r)return n(Error(`no favicon link`));let i=new Image;i.onload=()=>t(OA(i)),i.onerror=()=>n(Error(`favicon did not load`)),i.src=r.href}),TA}function AA(e){EA=e;let t=DA();if(!e){for(let{link:e,href:n,type:r,sizes:i}of t)e.href=n,r===null?e.removeAttribute(`type`):e.type=r,i===null?e.removeAttribute(`sizes`):e.setAttribute(`sizes`,i);return}kA(t).then(e=>{if(EA)for(let{link:n}of t)n.type=`image/png`,n.removeAttribute(`sizes`),n.href=e}).catch(()=>{TA=void 0})}var jA=new Map,MA=12;function NA(e,t){let n=jA.get(e);if(n&&n.raw===t)return n.html;let r=vd(t,ie(e));if(jA.set(e,{raw:t,html:r}),jA.size>MA){let e=jA.keys().next();e.done||jA.delete(e.value)}return r}function PA(e){let t=globalThis.requestIdleCallback;t?t(e,{timeout:500}):setTimeout(e,0)}function FA(e,t){ar(t)||e.prefetchQuery(Ke(t)).then(()=>{let n=e.getQueryData(Ke(t).queryKey);!n?.markdown||n.binary||xr(t)||PA(()=>NA(n.path,n.markdown))}).catch(()=>{})}function IA(e){let t=/^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(e);return t?{front:t[1],body:e.slice(t[0].length)}:{front:null,body:e}}var LA={paddingBottom:`max(0.75rem, env(safe-area-inset-bottom))`};function RA({path:e}){return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void zA(e),onMouseDown:e=>e.preventDefault(),className:`-mr-2.5 flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[12px] font-medium text-fg/80 outline-none transition-colors hover:bg-hover-strong hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,title:`Open ${e} outside Frizz`,"aria-label":`Open`,children:[(0,X.jsx)(sc,{size:12,"aria-hidden":`true`}),` Open`]})}function zA(e){return Qi(e).openLocalFile({path:e}).then(Nt).catch(e=>G(`Could not open local file: ${e.message.slice(0,100)}`))}function BA({path:e,revision:t,title:n}){return(0,X.jsx)(`iframe`,{"data-pdf-view":!0,src:`${Lr(e)}${t===void 0?``:`&v=${t}`}`,title:n,className:`block min-h-0 w-full flex-1 border-0`})}function VA({phone:e=!1}){return(0,X.jsxs)(`div`,{className:`text-[13px] text-muted`,children:[`This file isn’t text, so Frizz can’t show it.`,e?``:` Open sends it to its default app.`]})}function HA({source:e}){return(0,X.jsx)(eg,{text:e,language:`yaml`,className:`mb-4 whitespace-pre-wrap break-words rounded-md border border-border/60 bg-panel-2/40 px-3 py-2 font-mono-keep text-[12px] leading-5 text-muted`})}function UA({id:e,path:t,title:n,depth:r,widthDepth:a}){let o=Us(t),s=Re({...Ke(t),refetchInterval:o?!1:vo}),c=s.data?.path??t,l=xr(t),u=$t(t)&&pr(),{front:d,body:f}=IA(l?s.data?.markdown??``:``),p=i(c),m=tp(f,{baseDir:p,asDocument:!0}),h=Up(m),g=(0,q.useRef)(null);om(g,m);let _=Eh(g,m,p),v=th(g,m),y=Cr(),b=s.data?.markdown??``,x=Up((0,q.useMemo)(()=>l?``:NA(c,b),[l,b,c]));return(0,X.jsx)(qa,{id:e,depth:r,widthDepth:a,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(wn,{title:n,subtitle:c,onClose:e}),(0,X.jsxs)(`div`,{className:`flex-1 min-h-0 ${u&&s.data?`flex flex-col`:`overflow-y-auto px-5 py-4`}`,children:[u&&s.data?(0,X.jsx)(BA,{path:c,revision:s.data.modifiedAt,title:n}):s.isLoading?(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):s.error?(0,X.jsxs)(`div`,{className:`text-[13px] text-danger-90`,children:[`Couldn’t read this file: `,s.error.message]}):s.data?.binary?(0,X.jsx)(VA,{phone:y}):l?m?(0,X.jsxs)(X.Fragment,{children:[d&&(0,X.jsx)(HA,{source:d}),(0,X.jsx)(`div`,{ref:g,className:`md-body`,dangerouslySetInnerHTML:h}),_,v,s.data?.truncated&&(0,X.jsxs)(`p`,{className:`mt-4 border-t border-border/60 pt-3 text-[12px] text-muted`,children:[`This file is too long to render in full — everything above the cut is shown.`,y?``:` Open it to read the rest.`]})]}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):b?(0,X.jsx)(`pre`,{"data-file-source":!0,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:x}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!l&&!s.isLoading&&!s.error&&s.data?.truncated&&(0,X.jsx)(`p`,{className:`mt-4 border-t border-border/60 pt-3 text-[12px] text-muted`,children:`This file is too long to show in full — everything above the cut is shown.`})]}),y?(0,X.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0`,style:{height:`env(safe-area-inset-bottom)`}}):(0,X.jsx)(`div`,{className:`shrink-0 flex items-center justify-end gap-1.5 border-t border-border/60 bg-panel px-5 pt-3`,style:LA,children:(0,X.jsx)(RA,{path:c})})]})})}function WA(e,t,n){let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=0;for(let e=r.nextNode();e;e=r.nextNode()){if(e===t)return i+n;i+=e.textContent?.length??0}if(t instanceof Element&&e.contains(t)){let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=0;for(let e=n.nextNode();e;e=n.nextNode())(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING||t.contains(e))&&(r+=e.textContent?.length??0);return r}return null}function GA(e,t){let n=1,r=Math.min(t,e.length);for(let t=0;t<r;t++)e.charCodeAt(t)===10&&n++;return n}function KA({slug:e,path:t,active:n}){let r=xr(t),a=$t(t)&&pr(),o=Us(t),s=Re({...Ke(t),refetchInterval:o?!1:vo}),c=s.data?.path??t,l=s.data?.markdown??``,{front:u,body:d}=IA(r?l:``),[f,p]=(0,q.useState)(r?`rendered`:`source`),m=i(c),h=tp(d,{baseDir:m,asDocument:!0}),g=Up(h),_=Up((0,q.useMemo)(()=>f===`source`?NA(c,l):``,[l,c,f])),v=(0,q.useRef)(null),y=(0,q.useRef)(null),b=(0,q.useRef)(null);om(v,h);let x=Eh(v,h,m),S=th(v,h),C=Rt(c),w=ln(),T=yn(),E=j(e);return(0,q.useEffect)(()=>{if(!n)return;let t=()=>document.querySelector(`main[data-standalone-thread] textarea`);function r(e,t){return e?document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0?t.length:Math.min(e.selectionStart??t.length,t.length):t.length}function i(n){if(!(n.metaKey||n.ctrlKey)||n.altKey||n.shiftKey||n.key.toLowerCase()!==`i`)return;let i=b.current,a=window.getSelection(),o=a&&!a.isCollapsed&&a.rangeCount>0?a.getRangeAt(0):null,s=!!(i&&o&&i.contains(o.commonAncestorContainer)),u=s?a.toString():``;if(!s||!u.trim()){n.preventDefault(),n.stopPropagation();let e=t();if(!e)return;document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0&&e.setSelectionRange(e.value.length,e.value.length),e.focus();return}n.preventDefault(),n.stopPropagation();let d=null,f=y.current;if(f&&f.contains(o.commonAncestorContainer)){let e=WA(f,o.startContainer,o.startOffset),t=WA(f,o.endContainer,o.endOffset);e!==null&&t!==null&&(d={startLine:GA(l,Math.min(e,t)),endLine:GA(l,Math.max(0,Math.max(e,t)-1))})}else d=ns(l,u);let p=t(),m=jr.followUp(T,e,E),{prose:h,attachments:g}=zi(ls.get(m)),_=za(zo({path:c,...d??{}}),W.composerContext[e]??[],h),v=Aa(h,r(p,h),_);ls.set(m,Ji(v.prose,g.map(e=>e.path))),Ro(e,{token:_,path:c,text:u,...d??{}}),a.removeAllRanges(),requestAnimationFrame(()=>{let e=t();e&&(e.setSelectionRange(v.caret,v.caret),e.focus())})}return window.addEventListener(`keydown`,i,!0),()=>window.removeEventListener(`keydown`,i,!0)},[n,e,c,l,T,E]),(0,X.jsxs)(`div`,{ref:b,"data-file-viewer-panel":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,X.jsx)(wn,{title:C,subtitle:da(c,w),onClose:ka,actions:r?(0,X.jsx)(`div`,{className:`-mr-0.5 flex shrink-0 items-center gap-0.5 text-[11px] font-medium`,role:`group`,"aria-label":`File view`,children:[`rendered`,`source`].map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>p(e),"aria-pressed":f===e,className:`rounded px-2 py-0.5 transition-colors ${f===e?`bg-hover-strong text-fg`:`text-muted hover:text-fg`}`,children:e===`rendered`?`Rendered`:`Source`},e))}):null}),(0,X.jsxs)(`div`,{className:`flex-1 min-h-0 ${a&&s.data?`flex flex-col`:`overflow-y-auto px-5 py-4`}`,children:[a&&s.data?(0,X.jsx)(BA,{path:c,revision:s.data.modifiedAt,title:C}):s.isLoading?(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):s.error?(0,X.jsxs)(`div`,{className:`text-[13px] text-danger-90`,children:[`Couldn’t read this file: `,s.error.message]}):s.data?.binary?(0,X.jsx)(VA,{}):f===`source`?l?(0,X.jsx)(`pre`,{ref:y,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:_}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):h?(0,X.jsxs)(X.Fragment,{children:[u&&(0,X.jsx)(HA,{source:u}),(0,X.jsx)(`div`,{ref:v,className:`md-body`,dangerouslySetInnerHTML:g}),x,S]}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!s.isLoading&&!s.error&&s.data?.truncated&&(0,X.jsx)(`p`,{className:`mt-4 border-t border-border/60 pt-3 text-[12px] text-muted`,children:`This file is too long to render in full — everything above the cut is shown. Open it to read the rest.`})]}),(0,X.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between gap-3 border-t border-border/60 bg-panel px-5 pt-3`,style:LA,children:[a||s.data?.binary?(0,X.jsx)(`span`,{}):(0,X.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-muted-70`,children:`Select text and press ⌘I to add it to the chat`}),(0,X.jsx)(RA,{path:c})]})]})}function qA(){return{dirs:new Map,files:new Map}}function JA(e,t,n){let r=e.replace(/[\\/]+$/,``);if(t){let e=ba(t,r);if(e!==null)return m(e)}if(n){let e=ba(n,r);if(e!==null)return[`~`,...m(e)]}let i=m(r);return/^[\\/]/.test(r)?[`/`,...i]:i}var YA=(e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`,numeric:!0});function XA(e,t,n=``){let r=[];for(let i of[...e.dirs.keys()].sort(YA)){let a=e.dirs.get(i),o=i;for(;a.files.size===0&&a.dirs.size===1;){let[e,t]=[...a.dirs.entries()][0];o=o===`/`?`/${e}`:`${o}/${e}`,a=t}let s=n===``||n===`/`?`${n}${o}`:`${n}/${o}`;r.push({kind:`dir`,name:o,path:s,depth:t,children:XA(a,t+1,s)})}for(let n of[...e.files.keys()].sort(YA))r.push({kind:`file`,name:n,depth:t,file:e.files.get(n)});return r}function ZA(e,t,n){let r=qA();for(let i of e){let e=JA(i.path,t,n);if(e.length===0)continue;let a=r;for(let t of e.slice(0,-1)){let e=a.dirs.get(t);e||(e=qA(),a.dirs.set(t,e)),a=e}a.files.set(e[e.length-1],i)}return XA(r,0)}function QA(e){let t=[],n=e=>{for(let r of e)t.push(r),r.kind===`dir`&&n(r.children)};return n(e),t}var $A=/(?:^|[\s;&|(])(?:rm|mv|unlink|git\s+(?:rm|mv|clean|checkout|restore|reset|stash|apply))\b/;function ej(e){if(e.edit||e.edits?.length)return!0;let t=n(e.name);return Mn.has(t)?!0:t!==`bash`||!e.command?!1:$A.test(e.command)||ws(e.command).length>0}function tj(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=n.tools??[];for(let e=r.length-1;e>=0;e--)if(ej(r[e]))return`${n.sourceId??n.at??`#${t}`}:${e}:${r[e].status??``}`}}var nj=10;function rj({name:e,depth:t}){return(0,X.jsxs)(`div`,{"data-file-dir":e,className:`flex items-baseline pr-2 text-[12px] leading-5 text-muted-70`,style:{paddingLeft:8+t*nj},children:[(0,X.jsx)(`span`,{className:`flex shrink-0`,children:(0,X.jsx)(lc,{size:12,className:`${Z} text-muted-45`})}),(0,X.jsx)(`span`,{className:`ml-[5px] min-w-0 truncate`,title:e,children:e})]})}function ij({files:e}){let t=Ae(),n=ln();return(0,X.jsx)(`div`,{"data-edited-file-tree":!0,className:`flex flex-col gap-y-px`,children:QA(ZA(e,t,n)).map(e=>e.kind===`dir`?(0,X.jsx)(rj,{name:e.name,depth:e.depth},`d:${e.path}`):(0,X.jsx)(aj,{file:e.file,name:e.name,depth:e.depth,homeDir:n},e.file.path))})}function aj({file:e,name:t,depth:n,homeDir:r}){let i=ct();return(0,X.jsx)(py,{testKind:`file`,testId:e.path,mark:(0,X.jsx)(cc,{size:12,className:`${Z} -mr-[2px] text-muted-60`}),name:t,indent:n*nj,onOpen:()=>I(e.path),onPrewarm:()=>FA(i,e.path),title:da(e.path,r),status:(0,X.jsxs)(X.Fragment,{children:[(e.added??0)>0&&(0,X.jsxs)(`span`,{style:{color:Fn.fgSuccess},children:[`+`,e.added]}),(e.added??0)>0&&(e.removed??0)>0&&` `,(e.removed??0)>0&&(0,X.jsxs)(`span`,{style:{color:Fn.fgDanger},children:[`−`,e.removed]})]})})}function oj({link:e}){let t=ct(),n=ln();return e.kind===`link`?(0,X.jsx)(py,{testKind:`link`,testId:e.id,mark:(0,X.jsx)(sc,{size:12,className:`${Z} text-muted-60`}),name:e.label,href:e.target,title:e.target,status:sj(e.target)}):(0,X.jsx)(py,{testKind:`link`,testId:e.id,mark:(0,X.jsx)(ke,{size:12,className:`${Z} text-muted-60`}),name:e.label,onOpen:()=>I(e.target),onPrewarm:()=>FA(t,e.target),title:da(e.target,n),status:null})}function sj(e){try{return new URL(e).host||e}catch{return e}}var cj=1500;function lj(e,t,n,r){let i=ct(),a=(0,q.useRef)({slug:e,loaded:t,changeKey:n,turnLive:r}),o=(0,q.useRef)(void 0);(0,q.useEffect)(()=>()=>clearTimeout(o.current),[e]),(0,q.useEffect)(()=>{let s=a.current;if(a.current={slug:e,loaded:t,changeKey:n,turnLive:r},s.slug!==e||!s.loaded)return;let c=n!==void 0&&n!==s.changeKey,l=s.turnLive&&!r;!c&&!l||(clearTimeout(o.current),o.current=setTimeout(()=>{i.refetchQueries({queryKey:[`transcript`,e],exact:!0,type:`active`})},cj))},[i,e,t,n,r])}function uj({thread:e,centred:t=!1}){let n=di(),r=et(e.id,{poll:!1}),i=r.data?.editedFiles??[],a=(0,q.useMemo)(()=>tj(r.data?.messages??[]),[r.data?.messages]);lj(e.id,r.data!==void 0,a,e.runtime===`running`||e.runtime===`spawning`);let{agents:o,children:s,shells:c,prs:l,issues:u,commands:d,timers:f}=dv(e,(0,q.useMemo)(()=>Px(r.data?.messages??[]),[r.data?.messages]),lt(e.id)),p=pv(e),m=o.filter(qs),{railFilesCollapsed:h}=_t(cs),g=[{head:`To-do`,rows:e.humanTodos?.length?[(0,X.jsx)(`div`,{className:`px-2 text-[12px] leading-[18px]`,children:(0,X.jsx)(Av,{thread:e})},`todos`)]:[]},{head:`Sub-agents`,rows:m.map(t=>(0,X.jsx)(My,{agent:t,slug:e.id,now:n,onDismiss:fe(e.id,t)},t.id??t.label))},{head:`Child threads`,rows:s.map(e=>(0,X.jsx)(Ny,{child:e,now:n},e.id))},{head:`Background shells`,rows:c.map(t=>(0,X.jsx)(Sy,{shell:t,slug:e.id,now:n,onDismiss:fe(e.id,t,`SHELL`),watched:p(t)},t.id??t.label))},{head:`Pull requests`,rows:l.map(e=>(0,X.jsx)(gy,{watch:e},e.id))},{head:`Issues`,rows:u.map(e=>(0,X.jsx)(gy,{watch:e},e.id))},{head:`Monitors`,rows:d.map(t=>(0,X.jsx)(Oy,{watch:t,slug:e.id,now:n},t.id))},{head:`Timers`,rows:f.map(e=>(0,X.jsx)(Cy,{watch:e,now:n},e.id))},{head:`Files and links`,rows:(e.links??[]).map(e=>(0,X.jsx)(oj,{link:e},e.id))},{head:`Edited files`,rows:i.length>0?[(0,X.jsx)(ij,{files:i},`tree`)]:[],count:i.length,collapsed:h,onToggle:()=>cs.railFilesCollapsed=!cs.railFilesCollapsed}].filter(e=>e.rows.length>0);return(0,X.jsx)(`aside`,{"data-focus-rail":!0,"aria-label":`Thread activity`,className:`flex h-full shrink-0 flex-col overflow-y-auto px-4 [view-transition-name:thread-rail]`,style:{width:340},children:(0,X.jsx)(`div`,{className:g.length===0||t?`my-auto py-6`:`pb-6 pt-14`,children:g.length===0?(0,X.jsx)(`div`,{className:`text-[11.5px] text-muted-50`,children:`Nothing running, watched or edited yet.`}):(0,X.jsx)(Ry,{groups:g,divider:!1})})})}function dj(e,t){return`${Bo(e)}${o(t,`/`)}`}function fj({slug:e}){let t=_t(W),n=t.filePanels.some(e=>!e.closing),r=me(),i=Se(e),a=ja(r,e,()=>i),o=a.kind===`found`?a.thread:void 0;r?.projectDir,(0,q.useEffect)(()=>{let e=window.matchMedia?.(`(min-width: ${le}px)`);if(!e)return;let t=()=>{W.splitFileViewer=e.matches};return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),W.splitFileViewer=!1,W.filePanels=[]}},[]);let s=(0,q.useRef)(null),c=!t.splitFileViewer,l=a.kind===`found`;(0,q.useEffect)(()=>{if(!c||!l)return;let t=s.current?.querySelector(`[data-thread-chat-footer]`);if(t)return Bn(`thread-page:${e}`,t)},[c,l,e]);let d=o?.runtime===`turn-idle`||o?.runtime===`exited`||o?.runtime===`none`;(0,q.useEffect)(()=>{!o||!d||U.threadSeen({slug:e}).catch(()=>{})},[d,e,o?.lastActivityAt]),(0,q.useEffect)(()=>{let t=r?.projectLabel??r?.projectName,n=o?jt(o):e;document.title=t?`${n} · ${t} — Frizz`:`${n} · Frizz`},[r?.projectLabel,r?.projectName,e,o]);let f=o!==void 0&&pa(o);return(0,q.useEffect)(()=>(AA(f),()=>AA(!1)),[f]),(0,X.jsx)(yt,{children:(0,X.jsxs)(u,{className:`h-dvh min-h-0 bg-bg text-sm text-fg`,children:[(0,X.jsx)(ot,{className:`h-full w-full overflow-hidden`,children:(0,X.jsxs)(`div`,{className:`flex h-full w-full justify-center transition-transform duration-200 ease-out motion-reduce:transition-none split:justify-start`,style:{...V,transform:n?`translateX(calc(-1 * var(--full-gutter)))`:void 0},children:[(0,X.jsx)(`div`,{className:`hidden w-[var(--full-gutter)] shrink-0 split:block`,"aria-hidden":`true`}),(0,X.jsx)(`main`,{ref:s,"data-standalone-thread":!0,className:`flex h-full w-[var(--full-thread-narrow)] min-w-0 shrink-0 flex-col overflow-hidden border-border bg-panel sm:border-x split:w-[var(--full-thread)] [view-transition-name:thread-chat]`,children:a.kind===`loading`?(0,X.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,role:`status`,"aria-label":`Loading thread`,children:(0,X.jsx)(`span`,{className:`block h-5 w-5 animate-spin rounded-full border-2 border-muted/50 border-t-transparent`})}):a.kind===`missing`?(0,X.jsx)(hj,{slug:e}):(0,X.jsx)(O,{label:`this thread`,resetKeys:[e],children:(0,X.jsx)(Oe,{slug:e,showReturnToQueue:!0})})}),o?(0,X.jsx)(O,{label:`this thread's side pane`,resetKeys:[e],children:(0,X.jsx)(pj,{slug:e,thread:o})}):(0,X.jsx)(`div`,{className:`hidden w-[var(--full-pane)] shrink-0 split:block`,"aria-hidden":`true`})]})}),(0,X.jsx)(Bs,{onEscapeAtRest:()=>HT(e)})]})})}function pj({slug:e,thread:t,rail:n=!0,centredRail:r=!1}){let i=_t(W);return(0,X.jsxs)(`div`,{"data-side-pane":!0,className:`relative hidden h-full w-[var(--full-pane)] min-h-0 min-w-0 shrink-0 grow-0 overflow-hidden split:block`,children:[n&&(0,X.jsx)(`div`,{inert:i.filePanels.length>0?!0:void 0,className:`h-full min-h-0`,children:(0,X.jsx)(uj,{thread:t,centred:r})}),i.filePanels.map((t,n)=>(0,X.jsx)(mj,{slug:e,path:t.path,closing:!!t.closing,active:n===i.filePanels.length-1&&!t.closing&&i.splitFileViewer},t.id))]})}function mj({slug:e,path:t,closing:n,active:r}){let[i,a]=(0,q.useState)(!1),o=(0,q.useRef)(null);return(0,q.useLayoutEffect)(()=>{o.current?.getBoundingClientRect();let e=()=>a(!0),t=requestAnimationFrame(e),n=window.setTimeout(e,120);return()=>{cancelAnimationFrame(t),window.clearTimeout(n)}},[]),(0,q.useEffect)(()=>{r&&o.current?.focus({preventScroll:!0})},[r]),(0,X.jsx)(`aside`,{ref:o,tabIndex:-1,"data-file-viewer-slot":!0,"aria-hidden":!r,inert:!r,className:`absolute inset-0 outline-none transition-[translate,opacity] duration-200 ease-out motion-reduce:transition-none ${i&&!n?`translate-x-0 opacity-100`:`translate-x-full opacity-0`}`,children:(0,X.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-panel`,children:(0,X.jsx)(KA,{slug:e,path:t,active:r})})})}function hj({slug:e}){let{data:t,isPending:n}=Re({queryKey:[`threadLocate`,e],queryFn:()=>U.threadLocate({slug:e})});return(0,q.useEffect)(()=>{t?.length===1&&location.replace(dj(t[0].projectSlug,e))},[t,e]),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 px-6 text-center`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h1`,{className:`font-medium text-fg`,children:`Thread unavailable`}),n?(0,X.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Looking for “`,e,`” in your other projects…`]}):t&&t.length>0?(0,X.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`“`,e,`” lives in `,t.length===1?`another project`:`these projects`,` — opening it there.`]}):(0,X.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Thread “`,e,`” was not found in any project on this machine.`]})]}),t&&t.length>1?(0,X.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:t.map(t=>(0,X.jsx)(`a`,{href:dj(t.projectSlug,e),className:`rounded-md border border-border px-3 py-1.5 text-[12px] text-fg/90 hover:bg-panel-2`,children:t.projectName},t.projectSlug))}):(0,X.jsx)(`a`,{href:`/`,className:`rounded-md border border-border px-3 py-1.5 text-[12px] text-fg/90 hover:bg-panel-2`,children:`All projects`})]})}export{gA as BackgroundShellSheet,Dh as LightboxHost,UA as MarkdownDrawer,_A as MonitorSheet,pj as SidePane,fj as StandaloneThreadPage,uA as SubAgentSheet,CT as ThreadActionsSheet,mA as ThreadDrawer,PD as ThreadView,eA as TodosView};
|