frizz-server 0.15.52 → 0.15.53

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.
Files changed (92) hide show
  1. package/dist/claude-agent-broker.js +21289 -19953
  2. package/dist/dev-child.js +20826 -19671
  3. package/package.json +1 -1
  4. package/web-dist/assets/{abnfDiagram-VCTEODGH-DiSjUTD1.js → abnfDiagram-VCTEODGH-C5-n-yX3.js} +1 -1
  5. package/web-dist/assets/architecture-7GRP2DOG-BXfsnnri.js +1 -0
  6. package/web-dist/assets/{architectureDiagram-5GKGNRK7-I0TjaMyJ.js → architectureDiagram-5GKGNRK7-v9eLyom7.js} +1 -1
  7. package/web-dist/assets/{blockDiagram-I7D4REHJ-XB2-cEOS.js → blockDiagram-I7D4REHJ-De0HKZV7.js} +1 -1
  8. package/web-dist/assets/{c4Diagram-7LVT6UL2-DtSoQNFw.js → c4Diagram-7LVT6UL2-DQFZ6NeQ.js} +1 -1
  9. package/web-dist/assets/channel-CbqV-FJf.js +1 -0
  10. package/web-dist/assets/{chunk-2E4U76K2-B-wkZcpD.js → chunk-2E4U76K2-Cec1rhm9.js} +1 -1
  11. package/web-dist/assets/{chunk-4HAMMTFA-DWlXC__7.js → chunk-4HAMMTFA-DYmlzCrb.js} +1 -1
  12. package/web-dist/assets/{chunk-75Z2AOVW-B8ME16qz.js → chunk-75Z2AOVW-D4PgvSWX.js} +1 -1
  13. package/web-dist/assets/{chunk-CLGD4ZFX-DgSrSm54.js → chunk-CLGD4ZFX-BCRaJRgH.js} +1 -1
  14. package/web-dist/assets/{chunk-DU6HZSFF-CKILAkFG.js → chunk-DU6HZSFF-CXuOpgv7.js} +1 -1
  15. package/web-dist/assets/{chunk-F27PBJKO-B_8M_0Rl.js → chunk-F27PBJKO-Cij7-KWq.js} +1 -1
  16. package/web-dist/assets/{chunk-GMAD6QVW-UnCsWXAs.js → chunk-GMAD6QVW-Vfi9Qodg.js} +1 -1
  17. package/web-dist/assets/{chunk-GVQU2GXP-DC9Elw0X.js → chunk-GVQU2GXP-eAwOwPRP.js} +1 -1
  18. package/web-dist/assets/{chunk-IMKFNOWR-wpPy-2NT.js → chunk-IMKFNOWR-jBkoemYF.js} +1 -1
  19. package/web-dist/assets/{chunk-L3NEJ4N5-BMMh5yw5.js → chunk-L3NEJ4N5-Xttgzyc5.js} +1 -1
  20. package/web-dist/assets/{chunk-OSK3NFVY-CsTV5TtL.js → chunk-OSK3NFVY-DR9jXn3P.js} +1 -1
  21. package/web-dist/assets/{chunk-P2QGCYS3-D3dlUq-V.js → chunk-P2QGCYS3-Cpc3emFn.js} +1 -1
  22. package/web-dist/assets/{chunk-POPQ4Y6H-BvI7-pFd.js → chunk-POPQ4Y6H-CuScFkWc.js} +1 -1
  23. package/web-dist/assets/{chunk-PWAF6VOD-RqbILfUC.js → chunk-PWAF6VOD-CIdwTlgR.js} +1 -1
  24. package/web-dist/assets/{chunk-SHT3W25Y-OWaxTLwc.js → chunk-SHT3W25Y-Yb5paoPg.js} +1 -1
  25. package/web-dist/assets/{chunk-SVP7TREG-DGAeAXgv.js → chunk-SVP7TREG-x8diHpMs.js} +1 -1
  26. package/web-dist/assets/{chunk-TICWLB2K-CsSqwjw1.js → chunk-TICWLB2K-DHsuW_jr.js} +1 -1
  27. package/web-dist/assets/{chunk-TLUHSLCS-C9oqWUOB.js → chunk-TLUHSLCS-BwiXM_E2.js} +2 -2
  28. package/web-dist/assets/classDiagram-ZZMXUADV-ChpFNZ6-.js +1 -0
  29. package/web-dist/assets/classDiagram-v2-VYDZK3BY-ChpFNZ6-.js +1 -0
  30. package/web-dist/assets/{cynefin-OW5HDTMX-BG_ktheh.js → cynefin-OW5HDTMX-Cs2PLbXO.js} +1 -1
  31. package/web-dist/assets/{cynefinDiagram-5FMLGOSQ-DNxe0xQs.js → cynefinDiagram-5FMLGOSQ-DThGVJ4q.js} +1 -1
  32. package/web-dist/assets/{dagre-GXQ25YYZ-5rLGzKH4.js → dagre-GXQ25YYZ-D4QLKHYZ.js} +1 -1
  33. package/web-dist/assets/{diagram-S7CK7UJ4-ink8IARk.js → diagram-S7CK7UJ4-C-oieh0l.js} +1 -1
  34. package/web-dist/assets/{diagram-UQ7AKVKN-CER8u9ua.js → diagram-UQ7AKVKN-BRTaSxi8.js} +1 -1
  35. package/web-dist/assets/{diagram-VSXAHHWV-BWxvx-RY.js → diagram-VSXAHHWV-B01NfoBK.js} +1 -1
  36. package/web-dist/assets/{diagram-VX7I27RA-CJ1Zu00i.js → diagram-VX7I27RA-CIi0wWLy.js} +1 -1
  37. package/web-dist/assets/{diagram-Z3DM3KII-Co7zWuGs.js → diagram-Z3DM3KII-Bj0bns7N.js} +1 -1
  38. package/web-dist/assets/{ebnfDiagram-PWID7BFC-nrejbQbC.js → ebnfDiagram-PWID7BFC-DJWjvFhA.js} +1 -1
  39. package/web-dist/assets/{erDiagram-RLTQ6QDP-C6CKKxxF.js → erDiagram-RLTQ6QDP-OArCjKyL.js} +1 -1
  40. package/web-dist/assets/eventmodeling-NTZA5JFV-DnLS-G1o.js +1 -0
  41. package/web-dist/assets/flowDiagram-HODETNUW-DxBcq7hK.js +1 -0
  42. package/web-dist/assets/{ganttDiagram-EL5Y4UJY-Dncm7cLz.js → ganttDiagram-EL5Y4UJY-Sh-yF7Pk.js} +1 -1
  43. package/web-dist/assets/{gitGraph-4MIJSDKK-CvKEiD2o.js → gitGraph-4MIJSDKK-diOiZ9jR.js} +1 -1
  44. package/web-dist/assets/{gitGraphDiagram-WWUBYQGX-CFYEFiNn.js → gitGraphDiagram-WWUBYQGX-CUUUaPk1.js} +1 -1
  45. package/web-dist/assets/{index-BRMjhxrd.js → index-C7R3M7gN.js} +2 -2
  46. package/web-dist/assets/{info-A6RAGUB7-CC2XUtgl.js → info-A6RAGUB7-RybBrr2w.js} +1 -1
  47. package/web-dist/assets/{infoDiagram-27XIBGKW-C1uS_G88.js → infoDiagram-27XIBGKW-Cph6Zwcq.js} +1 -1
  48. package/web-dist/assets/{ishikawaDiagram-5VMMS53U-BZb69j5E.js → ishikawaDiagram-5VMMS53U-BANgLDpg.js} +1 -1
  49. package/web-dist/assets/{journeyDiagram-3NMN7TZE-CMylE70d.js → journeyDiagram-3NMN7TZE-DI-v8VTL.js} +1 -1
  50. package/web-dist/assets/{kanban-definition-UXKFOSKX-CHEOsGED.js → kanban-definition-UXKFOSKX-Bzf950KK.js} +1 -1
  51. package/web-dist/assets/{line-BsjU0-dp.js → line--92Un6e-.js} +1 -1
  52. package/web-dist/assets/{mermaid-parser.core-BKAVaI1u.js → mermaid-parser.core-tLBuwbpU.js} +3 -3
  53. package/web-dist/assets/{mermaid.core-B9-DVS7z.js → mermaid.core-eLZc0PEp.js} +3 -3
  54. package/web-dist/assets/{mindmap-definition-YA3MSWOX-DZRcUVDr.js → mindmap-definition-YA3MSWOX-4_2Ouyga.js} +1 -1
  55. package/web-dist/assets/{packet-AYTQ26CC-BLeUhLlU.js → packet-AYTQ26CC-DpTDZ1kf.js} +1 -1
  56. package/web-dist/assets/{pegDiagram-XKGWAZYB-Xyqkee6_.js → pegDiagram-XKGWAZYB-CHCMV4dR.js} +1 -1
  57. package/web-dist/assets/{pie-WAS4IAKB-D4o5BTS4.js → pie-WAS4IAKB-DCAUr7Sl.js} +1 -1
  58. package/web-dist/assets/{pieDiagram-E7YTZNPT-DCvmLOew.js → pieDiagram-E7YTZNPT-ClmhRIOi.js} +1 -1
  59. package/web-dist/assets/{quadrantDiagram-AXDQQJYC-DOJ_yQix.js → quadrantDiagram-AXDQQJYC-C5-AhbaK.js} +1 -1
  60. package/web-dist/assets/{radar-RG4KPBEZ-K-A12o39.js → radar-RG4KPBEZ-BcqJ67Ci.js} +1 -1
  61. package/web-dist/assets/{railroad-74A4TZTK-BMkfFovv.js → railroad-74A4TZTK-BfVmIesg.js} +1 -1
  62. package/web-dist/assets/railroad-abnf-HS5TGJTU-DmdHOz1X.js +1 -0
  63. package/web-dist/assets/railroad-ebnf-LZEXJU2U-pF0K7xke.js +1 -0
  64. package/web-dist/assets/railroad-peg-WCYAUIDC-D-df90Rl.js +1 -0
  65. package/web-dist/assets/{railroadDiagram-O6MQD6OU-DT4trHKC.js → railroadDiagram-O6MQD6OU-BV06urHq.js} +1 -1
  66. package/web-dist/assets/{requirementDiagram-BXWQKSXE-CGM4uxvA.js → requirementDiagram-BXWQKSXE-B0kxzubq.js} +1 -1
  67. package/web-dist/assets/{sankeyDiagram-P5KCCOFB-DS3oAp2M.js → sankeyDiagram-P5KCCOFB-DjBlKiUQ.js} +1 -1
  68. package/web-dist/assets/{sequenceDiagram-WJ2MYXX4-UD3omQ5N.js → sequenceDiagram-WJ2MYXX4-BHxYt7aE.js} +1 -1
  69. package/web-dist/assets/{stateDiagram-D77RDMKH-DONM7MNf.js → stateDiagram-D77RDMKH-DUMg8VxQ.js} +1 -1
  70. package/web-dist/assets/stateDiagram-v2-MP3YSRHH-W4P30iTw.js +1 -0
  71. package/web-dist/assets/{swimlanes-42K2YHIH-D33RTQxF.js → swimlanes-42K2YHIH-yb-iMsnc.js} +1 -1
  72. package/web-dist/assets/swimlanesDiagram-VR7AAH4N-CY1l7luM.js +8 -0
  73. package/web-dist/assets/{threadSurfaces-ClAzSMCV.js → threadSurfaces-i506BiUf.js} +26 -26
  74. package/web-dist/assets/{timeline-definition-24CTP7MA-DPFThVi8.js → timeline-definition-24CTP7MA-DNW8iOn2.js} +1 -1
  75. package/web-dist/assets/{treeView-Q6P3EWNA-BV49dnms.js → treeView-Q6P3EWNA-CuVRJqXc.js} +1 -1
  76. package/web-dist/assets/{treemap-WGGIJYW6-BVrEvhvK.js → treemap-WGGIJYW6-CqAS1nJa.js} +1 -1
  77. package/web-dist/assets/{vennDiagram-4TSXK5OY-W5Uk1TBS.js → vennDiagram-4TSXK5OY-CayuoPm-.js} +1 -1
  78. package/web-dist/assets/{wardley-WFR3VGLG-CblJtHHu.js → wardley-WFR3VGLG-DLBjtOPH.js} +1 -1
  79. package/web-dist/assets/{wardleyDiagram-VM6X3IG4-CGarvkjP.js → wardleyDiagram-VM6X3IG4-VjTKjARS.js} +1 -1
  80. package/web-dist/assets/{xychartDiagram-S5SC5T6Z-CK45_7ZH.js → xychartDiagram-S5SC5T6Z-VztC2hoJ.js} +1 -1
  81. package/web-dist/index.html +1 -1
  82. package/web-dist/assets/architecture-7GRP2DOG-BYgmFD1v.js +0 -1
  83. package/web-dist/assets/channel-DWuOn0MA.js +0 -1
  84. package/web-dist/assets/classDiagram-ZZMXUADV-DSspmFZn.js +0 -1
  85. package/web-dist/assets/classDiagram-v2-VYDZK3BY-DSspmFZn.js +0 -1
  86. package/web-dist/assets/eventmodeling-NTZA5JFV-BSYbQdT6.js +0 -1
  87. package/web-dist/assets/flowDiagram-HODETNUW-DlmV6Aj2.js +0 -1
  88. package/web-dist/assets/railroad-abnf-HS5TGJTU-CY-xG4Um.js +0 -1
  89. package/web-dist/assets/railroad-ebnf-LZEXJU2U-DOHo_q0W.js +0 -1
  90. package/web-dist/assets/railroad-peg-WCYAUIDC-LeJLBEXF.js +0 -1
  91. package/web-dist/assets/stateDiagram-v2-MP3YSRHH-DzVzPXHZ.js +0 -1
  92. package/web-dist/assets/swimlanesDiagram-VR7AAH4N-BXcjoK_e.js +0 -8
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-B9-DVS7z.js","assets/index-BRMjhxrd.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/index-C2agpmfX.css","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-C4XfhTaE.js","assets/chunk-DU6HZSFF-CKILAkFG.js","assets/chunk-75Z2AOVW-B8ME16qz.js","assets/dist-DoH_9pyS.js","assets/chunk-CLGD4ZFX-DgSrSm54.js","assets/chunk-PWAF6VOD-RqbILfUC.js","assets/chunk-GMAD6QVW-UnCsWXAs.js","assets/chunk-P2QGCYS3-D3dlUq-V.js","assets/chunk-4HAMMTFA-DWlXC__7.js","assets/rough.esm-CSKSodPl.js","assets/chunk-GVQU2GXP-DC9Elw0X.js","assets/chunk-OSK3NFVY-CsTV5TtL.js","assets/line-BsjU0-dp.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-L3NEJ4N5-BMMh5yw5.js","assets/chunk-TLUHSLCS-C9oqWUOB.js","assets/chunk-2E4U76K2-B-wkZcpD.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,Ac as f,Ai as p,An as m,Ao as h,Ar as g,As as _,At as v,B as y,Ba 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 V,Ds as te,Dt as ne,E as re,Ea as ie,Ec as H,Ei as ae,En as oe,Eo as se,Er as ce,Es as le,Et as ue,F as de,Fa as fe,Fi as pe,Fn as me,Fo as he,Fr as ge,Fs as _e,Ft as ve,G as ye,Ga as be,Gi as xe,Gn as Se,Go as Ce,Gr as we,Gs as Te,Gt as Ee,H as De,Ha as Oe,Hi as ke,Hn as Ae,Ho as je,Hr as Me,Hs as Ne,Ht as Pe,I as Fe,Ia as Ie,Ii as Le,In as Re,Io as U,Ir as ze,Is as Be,It as Ve,J as He,Ja as Ue,Ji as We,Jn as Ge,Jo as Ke,Jr as qe,Js as Je,Jt as Ye,K as Xe,Ka as Ze,Ki as Qe,Kn as $e,Ko as et,Kr as tt,Ks as nt,Kt as rt,L as it,La as at,Li as ot,Ln as st,Lo as ct,Lr as lt,Ls as ut,Lt as dt,M as ft,Ma as pt,Mi as mt,Mn as ht,Mo as gt,Mr as _t,Ms as vt,Mt as yt,N as bt,Na as xt,Ni as St,Nn as Ct,No as wt,Nr as Tt,Ns as Et,Nt as Dt,O as Ot,Oa as kt,Oc as At,Oi as jt,On as Mt,Oo as Nt,Or as Pt,Os as Ft,Ot as It,P as Lt,Pa as Rt,Pi as zt,Pn as Bt,Po as Vt,Pr as Ht,Ps as Ut,Pt as Wt,Q as Gt,Qa as Kt,Qi as qt,Qn as Jt,Qo as Yt,Qr as Xt,Qs as Zt,Qt,R as $t,Ra as en,Ri as tn,Rn as nn,Ro as rn,Rr as an,Rs as on,Rt as sn,S as cn,Sa as ln,Sc as un,Si as dn,Sn as fn,So as W,Sr as pn,Ss as mn,St as hn,T as gn,Ta as _n,Tc as vn,Ti as yn,Tn as bn,To as xn,Tr as Sn,Ts as Cn,Tt as wn,U as Tn,Ua as En,Ui as Dn,Un as On,Uo as kn,Ur as An,Us as jn,Ut as Mn,V as Nn,Va as Pn,Vi as Fn,Vn as In,Vo as Ln,Vr as Rn,Vs as zn,Vt as Bn,W as Vn,Wa as Hn,Wi as Un,Wn,Wo as Gn,Wr as Kn,Ws as qn,Wt as Jn,X as Yn,Xa as Xn,Xi as Zn,Xn as Qn,Xo as $n,Xr as er,Xs as tr,Xt as nr,Y as rr,Ya as ir,Yi as ar,Yn as or,Yo as sr,Yr as cr,Ys as lr,Yt as ur,Z as dr,Za as fr,Zi as pr,Zn as mr,Zo as hr,Zr as gr,Zs as _r,Zt as vr,_ as yr,_a as br,_c as xr,_i as Sr,_n as Cr,_o as wr,_r as Tr,_s as Er,_t as Dr,a as Or,aa as kr,ac as Ar,ai as jr,an as Mr,ao as Nr,ar as Pr,as as Fr,at as Ir,b as Lr,ba as Rr,bi as zr,bn as Br,bo as G,br as Vr,bs as Hr,bt as Ur,c as Wr,ca as Gr,cc as Kr,ci as qr,cn as Jr,co as Yr,cr as Xr,cs as Zr,ct as Qr,d as $r,da as ei,dc as ti,di as ni,dn as ri,do as ii,dr as ai,ds as oi,dt as si,ea as ci,ec as li,ei as ui,en as di,eo as fi,er as pi,es as mi,et as hi,f as gi,fa as _i,fc as vi,fi as yi,fn as bi,fo as xi,fr as Si,ft as Ci,g as wi,ga as Ti,gc as Ei,gi as Di,gn as Oi,go as ki,gr as Ai,gs as ji,gt as Mi,h as Ni,ha as Pi,hc as Fi,hi as Ii,hn as Li,ho as Ri,hr as zi,hs as Bi,ht as Vi,i as Hi,ia as Ui,ic as Wi,ii as Gi,in as Ki,io as qi,ir as Ji,is as Yi,it as Xi,j as Zi,ja as Qi,jc as $i,ji as ea,jn as ta,jo as na,jr as ra,js as ia,jt as aa,k as oa,ka as sa,kc as ca,ki as la,kn as ua,ko as da,kr as fa,ks as pa,kt as ma,l as ha,la as ga,lc as _a,li as va,ln as ya,lo as ba,lr as xa,ls as Sa,lt as Ca,m as wa,ma as Ta,mc as Ea,mi as Da,mn as Oa,mo as ka,mr as Aa,ms as ja,mt as Ma,n as Na,na as Pa,nc as Fa,ni as Ia,nn as La,no as Ra,nr as za,ns as Ba,nt as Va,o as Ha,oa as Ua,oc as Wa,oi as Ga,on as Ka,oo as qa,or as Ja,os as Ya,ot as Xa,p as Za,pa as Qa,pc as $a,pi as eo,pn as to,po as no,pr as ro,ps as io,pt as ao,q as oo,qa as so,qi as co,qn as lo,qo as uo,qr as fo,qs as po,qt as mo,r as ho,ra as go,rc as _o,ri as vo,rn as yo,ro as K,rr as bo,rs as xo,rt as So,s as Co,sa as wo,sc as To,si as Eo,sn as Do,so as Oo,sr as ko,ss as Ao,st as jo,t as Mo,ta as No,tc as Po,ti as Fo,tn as Io,to as Lo,tr as Ro,ts as zo,tt as Bo,u as Vo,ua as Ho,uc as Uo,ui as Wo,un as Go,uo as Ko,ur as qo,ut as Jo,v as Yo,va as Xo,vc as Zo,vi as Qo,vn as $o,vo as es,vr as ts,vs as ns,vt as rs,w as is,wa as as,wc as os,wi as ss,wn as cs,wo as ls,wr as us,ws as ds,wt as fs,x as ps,xa as ms,xc as hs,xi as gs,xn as _s,xo as vs,xr as ys,xs as bs,xt as xs,y as Ss,ya as Cs,yc as ws,yi as Ts,yn as Es,yo as Ds,yr as Os,ys as ks,yt as As,z as js,za as Ms,zi as Ns,zn as Ps,zo as Fs,zr as Is,zs as Ls,zt as Rs}from"./index-BRMjhxrd.js";var zs=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`}]]),Bs=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`}]]),Vs=K(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Hs=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`}]]),Us=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`}]]),Ws=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`}]]),Gs=K(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Ks=K(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),qs=K(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Js=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`}]]),Ys=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`}]]),Xs=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`}]]),Zs=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`}]]),Qs=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`}]]),$s=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`}]]),ec=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`}]]),tc=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`}]]),nc=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`}]]),rc=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`}]]),ic=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`}]]),ac=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`}]]),oc=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`}]]),sc=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`}]]),cc=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`}]]),lc=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`}]]),uc=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`}]]),dc=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`}]]),fc=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`}]]),pc=K(`play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),mc=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`}]]),hc=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`}]]),gc=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`}]]),_c=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`}]]),vc=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`}]]),yc=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`}]]),bc=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`}]]),xc=K(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Sc=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`}]]),Cc=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`}]]),wc=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($i(),1),Tc=e(f(),1);function Ec(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Dc=Ec();function Oc(e){Dc=e}var kc={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(Ac.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Ac={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`)},jc=/^(?:[ \t]*(?:\n|$))+/,Mc=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Nc=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Pc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Fc=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ic=/(?:[*+-]|\d{1,9}[.)])/,Lc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Rc=J(Lc).replace(/bull/g,Ic).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(),zc=J(Lc).replace(/bull/g,Ic).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(),Bc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Vc=/^[^\n]+/,Hc=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Uc=J(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Hc).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Wc=J(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ic).getRegex(),Gc=`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`,Kc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,qc=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`,Kc).replace(`tag`,Gc).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Jc=J(Bc).replace(`hr`,Pc).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`,Gc).getRegex(),Yc={blockquote:J(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Jc).getRegex(),code:Mc,def:Uc,fences:Nc,heading:Fc,hr:Pc,html:qc,lheading:Rc,list:Wc,newline:jc,paragraph:Jc,table:kc,text:Vc},Xc=J(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Pc).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`,Gc).getRegex(),Zc={...Yc,lheading:zc,table:Xc,paragraph:J(Bc).replace(`hr`,Pc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Xc).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`,Gc).getRegex()},Qc={...Yc,html:J(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Kc).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:kc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:J(Bc).replace(`hr`,Pc).replace(`heading`,` *#{1,6} *[^
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-eLZc0PEp.js","assets/index-C7R3M7gN.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/index-C2agpmfX.css","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-C4XfhTaE.js","assets/chunk-DU6HZSFF-CXuOpgv7.js","assets/chunk-75Z2AOVW-D4PgvSWX.js","assets/dist-DoH_9pyS.js","assets/chunk-CLGD4ZFX-BCRaJRgH.js","assets/chunk-PWAF6VOD-CIdwTlgR.js","assets/chunk-GMAD6QVW-Vfi9Qodg.js","assets/chunk-P2QGCYS3-Cpc3emFn.js","assets/chunk-4HAMMTFA-DYmlzCrb.js","assets/rough.esm-CSKSodPl.js","assets/chunk-GVQU2GXP-eAwOwPRP.js","assets/chunk-OSK3NFVY-DR9jXn3P.js","assets/line--92Un6e-.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-L3NEJ4N5-Xttgzyc5.js","assets/chunk-TLUHSLCS-BwiXM_E2.js","assets/chunk-2E4U76K2-Cec1rhm9.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,Ac as f,Ai as p,An as m,Ao as h,Ar as g,As as _,At as v,B as y,Ba 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 ee,Dn as z,Do as te,Dr as ne,Ds as B,Dt as re,E as V,Ea as ie,Ec as H,Ei as ae,En as oe,Eo as se,Er as ce,Es as le,Et as ue,F as de,Fa as fe,Fi as pe,Fn as me,Fo as he,Fr as ge,Fs as _e,Ft as ve,G as ye,Ga as be,Gi as xe,Gn as Se,Go as Ce,Gr as we,Gs as Te,Gt as Ee,H as De,Ha as Oe,Hi as ke,Hn as Ae,Ho as je,Hr as Me,Hs as Ne,Ht as Pe,I as Fe,Ia as Ie,Ii as Le,In as Re,Io as U,Ir as ze,Is as Be,It as Ve,J as He,Ja as Ue,Ji as We,Jn as Ge,Jo as Ke,Jr as qe,Js as Je,Jt as Ye,K as Xe,Ka as Ze,Ki as Qe,Kn as $e,Ko as et,Kr as tt,Ks as nt,Kt as rt,L as it,La as at,Li as ot,Ln as st,Lo as ct,Lr as lt,Ls as ut,Lt as dt,M as ft,Ma as pt,Mi as mt,Mn as ht,Mo as gt,Mr as _t,Ms as vt,Mt as yt,N as bt,Na as xt,Ni as St,Nn as Ct,No as wt,Nr as Tt,Ns as Et,Nt as Dt,O as Ot,Oa as kt,Oc as At,Oi as jt,On as Mt,Oo as Nt,Or as Pt,Os as Ft,Ot as It,P as Lt,Pa as Rt,Pi as zt,Pn as Bt,Po as Vt,Pr as Ht,Ps as Ut,Pt as Wt,Q as Gt,Qa as Kt,Qi as qt,Qn as Jt,Qo as Yt,Qr as Xt,Qs as Zt,Qt,R as $t,Ra as en,Ri as tn,Rn as nn,Ro as rn,Rr as an,Rs as on,Rt as sn,S as cn,Sa as ln,Sc as un,Si as dn,Sn as fn,So as W,Sr as pn,Ss as mn,St as hn,T as gn,Ta as _n,Tc as vn,Ti as yn,Tn as bn,To as xn,Tr as Sn,Ts as Cn,Tt as wn,U as Tn,Ua as En,Ui as Dn,Un as On,Uo as kn,Ur as An,Us as jn,Ut as Mn,V as Nn,Va as Pn,Vi as Fn,Vn as In,Vo as Ln,Vr as Rn,Vs as zn,Vt as Bn,W as Vn,Wa as Hn,Wi as Un,Wn,Wo as Gn,Wr as Kn,Ws as qn,Wt as Jn,X as Yn,Xa as Xn,Xi as Zn,Xn as Qn,Xo as $n,Xr as er,Xs as tr,Xt as nr,Y as rr,Ya as ir,Yi as ar,Yn as or,Yo as sr,Yr as cr,Ys as lr,Yt as ur,Z as dr,Za as fr,Zi as pr,Zn as mr,Zo as hr,Zr as gr,Zs as _r,Zt as vr,_ as yr,_a as br,_c as xr,_i as Sr,_n as Cr,_o as wr,_r as Tr,_s as Er,_t as Dr,a as Or,aa as kr,ac as Ar,ai as jr,an as Mr,ao as Nr,ar as Pr,as as Fr,at as Ir,b as Lr,ba as Rr,bi as zr,bn as Br,bo as G,br as Vr,bs as Hr,bt as Ur,c as Wr,ca as Gr,cc as Kr,ci as qr,cn as Jr,co as Yr,cr as Xr,cs as Zr,ct as Qr,d as $r,da as ei,dc as ti,di as ni,dn as ri,do as ii,dr as ai,ds as oi,dt as si,ea as ci,ec as li,ei as ui,en as di,eo as fi,er as pi,es as mi,et as hi,f as gi,fa as _i,fc as vi,fi as yi,fn as bi,fo as xi,fr as Si,ft as Ci,g as wi,ga as Ti,gc as Ei,gi as Di,gn as Oi,go as ki,gr as Ai,gs as ji,gt as Mi,h as Ni,ha as Pi,hc as Fi,hi as Ii,hn as Li,ho as Ri,hr as zi,hs as Bi,ht as Vi,i as Hi,ia as Ui,ic as Wi,ii as Gi,in as Ki,io as qi,ir as Ji,is as Yi,it as Xi,j as Zi,ja as Qi,jc as $i,ji as ea,jn as ta,jo as na,jr as ra,js as ia,jt as aa,k as oa,ka as sa,kc as ca,ki as la,kn as ua,ko as da,kr as fa,ks as pa,kt as ma,l as ha,la as ga,lc as _a,li as va,ln as ya,lo as ba,lr as xa,ls as Sa,lt as Ca,m as wa,ma as Ta,mc as Ea,mi as Da,mn as Oa,mo as ka,mr as Aa,ms as ja,mt as Ma,n as Na,na as Pa,nc as Fa,ni as Ia,nn as La,no as Ra,nr as za,ns as Ba,nt as Va,o as Ha,oa as Ua,oc as Wa,oi as Ga,on as Ka,oo as qa,or as Ja,os as Ya,ot as Xa,p as Za,pa as Qa,pc as $a,pi as eo,pn as to,po as no,pr as ro,ps as io,pt as ao,q as oo,qa as so,qi as co,qn as lo,qo as uo,qr as fo,qs as po,qt as mo,r as ho,ra as go,rc as _o,ri as vo,rn as yo,ro as K,rr as bo,rs as xo,rt as So,s as Co,sa as wo,sc as To,si as Eo,sn as Do,so as Oo,sr as ko,ss as Ao,st as jo,t as Mo,ta as No,tc as Po,ti as Fo,tn as Io,to as Lo,tr as Ro,ts as zo,tt as Bo,u as Vo,ua as Ho,uc as Uo,ui as Wo,un as Go,uo as Ko,ur as qo,ut as Jo,v as Yo,va as Xo,vc as Zo,vi as Qo,vn as $o,vo as es,vr as ts,vs as ns,vt as rs,w as is,wa as as,wc as os,wi as ss,wn as cs,wo as ls,wr as us,ws as ds,wt as fs,x as ps,xa as ms,xc as hs,xi as gs,xn as _s,xo as vs,xr as ys,xs as bs,xt as xs,y as Ss,ya as Cs,yc as ws,yi as Ts,yn as Es,yo as Ds,yr as Os,ys as ks,yt as As,z as js,za as Ms,zi as Ns,zn as Ps,zo as Fs,zr as Is,zs as Ls,zt as Rs}from"./index-C7R3M7gN.js";var zs=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`}]]),Bs=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`}]]),Vs=K(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Hs=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`}]]),Us=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`}]]),Ws=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`}]]),Gs=K(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Ks=K(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),qs=K(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Js=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`}]]),Ys=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`}]]),Xs=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`}]]),Zs=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`}]]),Qs=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`}]]),$s=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`}]]),ec=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`}]]),tc=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`}]]),nc=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`}]]),rc=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`}]]),ic=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`}]]),ac=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`}]]),oc=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`}]]),sc=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`}]]),cc=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`}]]),lc=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`}]]),uc=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`}]]),dc=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`}]]),fc=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`}]]),pc=K(`play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),mc=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`}]]),hc=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`}]]),gc=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`}]]),_c=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`}]]),vc=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`}]]),yc=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`}]]),bc=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`}]]),xc=K(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Sc=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`}]]),Cc=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`}]]),wc=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($i(),1),Tc=e(f(),1);function Ec(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Dc=Ec();function Oc(e){Dc=e}var kc={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(Ac.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Ac={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`)},jc=/^(?:[ \t]*(?:\n|$))+/,Mc=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Nc=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Pc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Fc=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ic=/(?:[*+-]|\d{1,9}[.)])/,Lc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Rc=J(Lc).replace(/bull/g,Ic).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(),zc=J(Lc).replace(/bull/g,Ic).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(),Bc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Vc=/^[^\n]+/,Hc=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Uc=J(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Hc).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Wc=J(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ic).getRegex(),Gc=`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`,Kc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,qc=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`,Kc).replace(`tag`,Gc).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Jc=J(Bc).replace(`hr`,Pc).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`,Gc).getRegex(),Yc={blockquote:J(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Jc).getRegex(),code:Mc,def:Uc,fences:Nc,heading:Fc,hr:Pc,html:qc,lheading:Rc,list:Wc,newline:jc,paragraph:Jc,table:kc,text:Vc},Xc=J(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Pc).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`,Gc).getRegex(),Zc={...Yc,lheading:zc,table:Xc,paragraph:J(Bc).replace(`hr`,Pc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Xc).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`,Gc).getRegex()},Qc={...Yc,html:J(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Kc).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:kc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:J(Bc).replace(`hr`,Pc).replace(`heading`,` *#{1,6} *[^
3
3
  ]`).replace(`lheading`,Rc).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},$c=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,el=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,tl=/^( {2,}|\\)\n(?!\s*$)/,nl=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,rl=/[\p{P}\p{S}]/u,il=/[\s\p{P}\p{S}]/u,al=/[^\s\p{P}\p{S}]/u,ol=J(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,il).getRegex(),sl=/(?!~)[\p{P}\p{S}]/u,cl=/(?!~)[\s\p{P}\p{S}]/u,ll=/(?:[^\s\p{P}\p{S}]|~)/u,ul=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,dl=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,fl=J(dl,`u`).replace(/punct/g,rl).getRegex(),pl=J(dl,`u`).replace(/punct/g,sl).getRegex(),ml=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,hl=J(ml,`gu`).replace(/notPunctSpace/g,al).replace(/punctSpace/g,il).replace(/punct/g,rl).getRegex(),gl=J(ml,`gu`).replace(/notPunctSpace/g,ll).replace(/punctSpace/g,cl).replace(/punct/g,sl).getRegex(),_l=J(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,al).replace(/punctSpace/g,il).replace(/punct/g,rl).getRegex(),vl=J(/\\(punct)/,`gu`).replace(/punct/g,rl).getRegex(),yl=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(),bl=J(Kc).replace(`(?:-->|$)`,`-->`).getRegex(),xl=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`,bl).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Sl=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Cl=J(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,Sl).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),wl=J(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Sl).replace(`ref`,Hc).getRegex(),Tl=J(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Hc).getRegex(),El={_backpedal:kc,anyPunctuation:vl,autolink:yl,blockSkip:ul,br:tl,code:el,del:kc,emStrongLDelim:fl,emStrongRDelimAst:hl,emStrongRDelimUnd:_l,escape:$c,link:Cl,nolink:Tl,punctuation:ol,reflink:wl,reflinkSearch:J(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,wl).replace(`nolink`,Tl).getRegex(),tag:xl,text:nl,url:kc},Dl={...El,link:J(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Sl).getRegex(),reflink:J(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Sl).getRegex()},Ol={...El,emStrongRDelimAst:gl,emStrongLDelim:pl,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.!#$%&'*+\/=?_`{\|}~-]+@)))/},kl={...Ol,br:J(tl).replace(`{2,}`,`*`).getRegex(),text:J(Ol.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Al={normal:Yc,gfm:Zc,pedantic:Qc},jl={normal:El,gfm:Ol,breaks:kl,pedantic:Dl},Ml={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},Nl=e=>Ml[e];function Pl(e,t){if(t){if(Ac.escapeTest.test(e))return e.replace(Ac.escapeReplace,Nl)}else if(Ac.escapeTestNoEncode.test(e))return e.replace(Ac.escapeReplaceNoEncode,Nl);return e}function Fl(e){try{e=encodeURI(e).replace(Ac.percentDecode,`%`)}catch{return null}return e}function Il(e,t){let n=e.replace(Ac.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Ac.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(Ac.slashPipe,`|`);return n}function Ll(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 Rl(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 zl(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 Bl(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
4
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
5
  `)}var Vl=class{options;rules;lexer;constructor(e){this.options=e||Dc}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:Ll(e,`
@@ -54,15 +54,15 @@ ${e}</tr>
54
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
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>${Pl(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=Fl(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+Pl(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=Fl(e);if(i===null)return Pl(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${Pl(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Pl(e.text)}},Wl=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``}},Gl=class e{options;renderer;textRenderer;constructor(e){this.options=e||Dc,this.options.renderer=this.options.renderer||new Ul,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Wl}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
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}},Kl=class{options;block;constructor(e){this.options=e||Dc}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?Hl.lex:Hl.lexInline}provideParser(){return this.block?Gl.parse:Gl.parseInline}},ql=class{defaults=Ec();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Gl;Renderer=Ul;TextRenderer=Wl;Lexer=Hl;Tokenizer=Vl;Hooks=Kl;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 Ul(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 Vl(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 Kl;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];Kl.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 Hl.lex(e,t??this.defaults)}parser(e,t){return Gl.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?Hl.lex:Hl.lexInline,s=i.hooks?i.hooks.provideParser():e?Gl.parse:Gl.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>`+Pl(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},Jl=new ql;function Y(e,t){return Jl.parse(e,t)}Y.options=Y.setOptions=function(e){return Jl.setOptions(e),Y.defaults=Jl.defaults,Oc(Y.defaults),Y},Y.getDefaults=Ec,Y.defaults=Dc,Y.use=function(...e){return Jl.use(...e),Y.defaults=Jl.defaults,Oc(Y.defaults),Y},Y.walkTokens=function(e,t){return Jl.walkTokens(e,t)},Y.parseInline=Jl.parseInline,Y.Parser=Gl,Y.parser=Gl.parse,Y.Renderer=Ul,Y.TextRenderer=Wl,Y.Lexer=Hl,Y.lexer=Hl.lex,Y.Tokenizer=Vl,Y.Hooks=Kl,Y.parse=Y,Y.options,Y.setOptions,Y.use,Y.walkTokens,Y.parseInline,Gl.parse,Hl.lex;var Yl=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,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#x27;`)}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 V(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function te(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 ne(e,t){Array.isArray(e.illegal)&&(e.illegal=y(...e.illegal))}function re(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 ie(e,t){e.relevance===void 0&&(e.relevance=1)}var H=(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},ae=[`of`,`and`,`for`,`in`,`not`,`or`,`if`,`then`,`parent`,`list`,`value`],oe=`keyword`;function se(e,t,n=oe){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,se(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,ce(n[0],n[1])]})}}function ce(e,t){return t?Number(t):+!le(e)}function le(e){return ae.includes(e.toLowerCase())}var ue={},de=e=>{console.error(e)},fe=(e,...t)=>{console.log(`WARN: ${e}`,...t)},pe=(e,t)=>{ue[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),ue[`${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 de(`skip, excludeBegin, returnBegin not compatible with beginScope: {}`),me;if(typeof e.beginScope!=`object`||e.beginScope===null)throw de(`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 de(`skip, excludeEnd, returnEnd not compatible with endScope: {}`),me;if(typeof e.endScope!=`object`||e.endScope===null)throw de(`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;[V,re,ye,H].forEach(e=>e(n,r)),e.compilerExtensions.forEach(e=>e(n,r)),n.__beforeBegin=null,[te,ne,ie].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&&=se(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||(fe(s.replace(`{}`,n[1])),fe(`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):(pe(`10.7.0`,`highlight(lang, code, ...args) has been deprecated.`),pe(`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 de(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(),pe(`10.6.0`,`initHighlighting() deprecated. Use highlightAll() now.`)};function D(){k(),pe(`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(de(`Language definition for '{}' could not be registered.`.replace(`{}`,n)),o)de(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 pe(`10.7.0`,`highlightBlock will be removed entirely in v12.0`),pe(`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 Xl(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 Zl=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_-]*/}}),Ql=`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(`.`),$l=`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(`.`),eu=[...Ql,...$l],tu=`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(),nu=`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(),ru=[`after`,`backdrop`,`before`,`cue`,`cue-region`,`first-letter`,`first-line`,`grammar-error`,`marker`,`part`,`placeholder`,`selection`,`slotted`,`spelling-error`].sort().reverse(),iu=`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 au(e){let t=e.regex,n=Zl(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:`:(`+nu.join(`|`)+`)`},{begin:`:(:)?(`+ru.join(`|`)+`)`}]},n.CSS_VARIABLE,{className:`attribute`,begin:`\\b(`+iu.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:tu.join(` `)},contains:[{begin:/[a-z-]+(?=:)/,className:`attribute`},...a,n.CSS_NUMBER_MODE]}]},{className:`selector-tag`,begin:`\\b(`+eu.join(`|`)+`)\\b`}]}}function ou(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 su=`[A-Za-z$_][0-9A-Za-z$_]*`,cu=`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(`.`),lu=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],uu=`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(`.`),du=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],fu=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],pu=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],mu=[].concat(fu,uu,du);function hu(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=su,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:su,keyword:cu,literal:lu,built_in:mu,"variable.language":pu},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:{_:[...uu,...du]}},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([...fu,`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 gu(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 _u(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 vu(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 yu(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 bu(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 xu=`[A-Za-z$_][0-9A-Za-z$_]*`,Su=`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(`.`),Cu=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],wu=`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(`.`),Tu=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],Eu=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],Du=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],Ou=[].concat(Eu,wu,Tu);function ku(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=xu,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:xu,keyword:Su,literal:Cu,built_in:Ou,"variable.language":Du},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:{_:[...wu,...Tu]}},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([...Eu,`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 Au(e){let t=e.regex,n=ku(e),r=xu,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:xu,keyword:Su.concat([`type`,`interface`,`public`,`private`,`protected`,`implements`,`declare`,`abstract`,`readonly`,`enum`,`override`,`satisfies`]),literal:Cu,built_in:Ou.concat(i),"variable.language":Du},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 ju(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 Mu(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 Nu=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`],Pu=Object.freeze({bold:!1,dim:!1,italic:!1,underline:!1,inverse:!1,hidden:!1,strike:!1}),Fu=`ansi-esc`,Iu=/^(?:color:#[0-9a-f]{6}(?:;background-color:#[0-9a-f]{6})?|background-color:#[0-9a-f]{6})$/,Lu=String.raw`(?:\x1b|�|\\x1[bB]|\\u001[bB]|\\033|\\e|\^\[)`,Ru=new RegExp(Lu,`g`),zu=/\[([0-?]{0,64})[ -/]{0,8}([@-~])/y,Bu=new RegExp(String.raw`\][^\n]{0,2048}?(?:${Lu}\\\\?|\x07|�|\\a|\\x07|\\007|\\u0007)`,`y`),Vu=/[()][0-9A-Za-z]/y;function Hu(e){let t=``,n={...Pu},r=``,i=0,a=n=>{if(n<=i)return;let a=Yu(e.slice(i,n));t+=r?`${r}${a}</span>`:a};Ru.lastIndex=0;for(let o=Ru.exec(e);o;o=Ru.exec(e)){let s=o.index,c=s+o[0].length,l=-1,u;for(let t of[zu,Bu,Vu]){t.lastIndex=c;let n=t.exec(e);if(n){l=c+n[0].length,t===zu&&n[2]===`m`&&(u=n[1]);break}}l<0&&o[0]===`\x1B`&&(l=c),!(l<0)&&(a(s),t+=`<span class="${Fu}">${Yu(e.slice(s,l))}</span>`,u!==void 0&&(n=Uu(n,u),r=Ju(n)),i=l,Ru.lastIndex=l)}return a(e.length),t}function Uu(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=Wu(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=Wu(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,Pu,{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 Wu(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 Gu(n[0]);if(e===`2`&&n.length===3)return{hex:Ku(n[0],n[1],n[2])}}}function Gu(e){if(e<16)return{index:e};if(e>=232){let t=8+(e-232)*10;return{hex:Ku(t,t,t)}}let t=e=>e===0?0:55+e*40,n=e-16;return{hex:Ku(t(Math.floor(n/36)),t(Math.floor(n/6)%6),t(n%6))}}function Ku(...e){return`#${e.map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function qu(e){return e<8?Nu[e]:`bright-${Nu[e-8]}`}function Ju(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-${qu(t.index)}`):t?i.push(`color:${t.hex}`):e.inverse&&r.push(`ansi-fg-inverse`),n&&`index`in n?r.push(`ansi-bg-${qu(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 Yu(e){return e.replace(/[&<>"']/g,e=>e===`&`?`&amp;`:e===`<`?`&lt;`:e===`>`?`&gt;`:e===`"`?`&quot;`:`&#39;`)}var Xu={bash:Xl,css:au,diff:ou,javascript:hu,json:gu,markdown:_u,python:vu,rust:yu,sql:bu,typescript:Au,xml:ju,yaml:Mu};for(let[e,t]of Object.entries(Xu))Yl.registerLanguage(e,t);function Zu(e,t){if(t===`plaintext`)return is(e);if(t===`ansi`)return Hu(e);try{return Yl.highlight(e,{language:t,ignoreIllegals:!0}).value}catch{return is(e)}}function Qu(e,t,n=t){return`<code class="hljs language-${n}">${Zu(`${e.replace(/\n$/,``)}\n`,t)}</code>`}var $u=`<button type="button" class="${cn}" title="${D}"></button>`;function ed(e,t){let n=gn(t);return`<span class="${ps}"><pre>${Qu(e,n,/^\s*(lightbox|mermaid)\s*$/i.exec(t??``)?.[1].toLowerCase()??n)}</pre>${$u}</span>\n`}var td=/<span\b[^>]*>|<\/span>|\n|[^<\n]+|</g;function nd(e){let t=[],n=[],r=``;for(let[i]of e.matchAll(td))i===`
57
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Pl(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},Jl=new ql;function Y(e,t){return Jl.parse(e,t)}Y.options=Y.setOptions=function(e){return Jl.setOptions(e),Y.defaults=Jl.defaults,Oc(Y.defaults),Y},Y.getDefaults=Ec,Y.defaults=Dc,Y.use=function(...e){return Jl.use(...e),Y.defaults=Jl.defaults,Oc(Y.defaults),Y},Y.walkTokens=function(e,t){return Jl.walkTokens(e,t)},Y.parseInline=Jl.parseInline,Y.Parser=Gl,Y.parser=Gl.parse,Y.Renderer=Ul,Y.TextRenderer=Wl,Y.Lexer=Hl,Y.lexer=Hl.lex,Y.Tokenizer=Vl,Y.Hooks=Kl,Y.parse=Y,Y.options,Y.setOptions,Y.use,Y.walkTokens,Y.parseInline,Gl.parse,Hl.lex;var Yl=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,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#x27;`)}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(`/\\*`,`\\*/`),ee=I(`#`,`$`),z=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:ee,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 te(e,t){e.input[e.index-1]===`.`&&t.ignoreMatch()}function ne(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function B(e,t){t&&e.beginKeywords&&(e.begin=`\\b(`+e.beginKeywords.split(` `).join(`|`)+`)(?!\\.)(?=\\b|\\s)`,e.__beforeBegin=te,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 V(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 ie(e,t){e.relevance===void 0&&(e.relevance=1)}var H=(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},ae=[`of`,`and`,`for`,`in`,`not`,`or`,`if`,`then`,`parent`,`list`,`value`],oe=`keyword`;function se(e,t,n=oe){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,se(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,ce(n[0],n[1])]})}}function ce(e,t){return t?Number(t):+!le(e)}function le(e){return ae.includes(e.toLowerCase())}var ue={},de=e=>{console.error(e)},fe=(e,...t)=>{console.log(`WARN: ${e}`,...t)},pe=(e,t)=>{ue[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),ue[`${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 de(`skip, excludeBegin, returnBegin not compatible with beginScope: {}`),me;if(typeof e.beginScope!=`object`||e.beginScope===null)throw de(`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 de(`skip, excludeEnd, returnEnd not compatible with endScope: {}`),me;if(typeof e.endScope!=`object`||e.endScope===null)throw de(`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;[ne,V,ye,H].forEach(e=>e(n,r)),e.compilerExtensions.forEach(e=>e(n,r)),n.__beforeBegin=null,[B,re,ie].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&&=se(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||(fe(s.replace(`{}`,n[1])),fe(`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):(pe(`10.7.0`,`highlight(lang, code, ...args) has been deprecated.`),pe(`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};ee(`before:highlight`,a);let o=a.result?a.result:v(a.language,a.code,n);return o.code=a.code,ee(`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 de(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(ee(`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}),ee(`after:highlightElement`,{el:e,result:i,text:r})}function T(e){l=Ee(l,e)}let E=()=>{k(),pe(`10.6.0`,`initHighlighting() deprecated. Use highlightAll() now.`)};function D(){k(),pe(`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(de(`Language definition for '{}' could not be registered.`.replace(`{}`,n)),o)de(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 ee(e,t){let n=e;a.forEach(function(e){e[n]&&e[n](t)})}function te(e){return pe(`10.7.0`,`highlightBlock will be removed entirely in v12.0`),pe(`10.7.0`,`Please use highlightElement now.`),w(e)}Object.assign(e,{highlight:p,highlightAuto:S,highlightAll:k,highlightElement:w,highlightBlock:te,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 z)typeof z[e]==`object`&&n(z[e]);return Object.assign(e,z),e},Ae=ke({});Ae.newInstance=()=>ke({}),t.exports=Ae,Ae.HighlightJS=Ae,Ae.default=Ae}))()).default;function Xl(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 Zl=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_-]*/}}),Ql=`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(`.`),$l=`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(`.`),eu=[...Ql,...$l],tu=`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(),nu=`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(),ru=[`after`,`backdrop`,`before`,`cue`,`cue-region`,`first-letter`,`first-line`,`grammar-error`,`marker`,`part`,`placeholder`,`selection`,`slotted`,`spelling-error`].sort().reverse(),iu=`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 au(e){let t=e.regex,n=Zl(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:`:(`+nu.join(`|`)+`)`},{begin:`:(:)?(`+ru.join(`|`)+`)`}]},n.CSS_VARIABLE,{className:`attribute`,begin:`\\b(`+iu.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:tu.join(` `)},contains:[{begin:/[a-z-]+(?=:)/,className:`attribute`},...a,n.CSS_NUMBER_MODE]}]},{className:`selector-tag`,begin:`\\b(`+eu.join(`|`)+`)\\b`}]}}function ou(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 su=`[A-Za-z$_][0-9A-Za-z$_]*`,cu=`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(`.`),lu=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],uu=`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(`.`),du=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],fu=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],pu=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],mu=[].concat(fu,uu,du);function hu(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=su,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:su,keyword:cu,literal:lu,built_in:mu,"variable.language":pu},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:{_:[...uu,...du]}},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([...fu,`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 gu(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 _u(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 vu(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 yu(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 bu(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 xu=`[A-Za-z$_][0-9A-Za-z$_]*`,Su=`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(`.`),Cu=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],wu=`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(`.`),Tu=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],Eu=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],Du=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],Ou=[].concat(Eu,wu,Tu);function ku(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=xu,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:xu,keyword:Su,literal:Cu,built_in:Ou,"variable.language":Du},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:{_:[...wu,...Tu]}},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([...Eu,`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 Au(e){let t=e.regex,n=ku(e),r=xu,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:xu,keyword:Su.concat([`type`,`interface`,`public`,`private`,`protected`,`implements`,`declare`,`abstract`,`readonly`,`enum`,`override`,`satisfies`]),literal:Cu,built_in:Ou.concat(i),"variable.language":Du},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 ju(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 Mu(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 Nu=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`],Pu=Object.freeze({bold:!1,dim:!1,italic:!1,underline:!1,inverse:!1,hidden:!1,strike:!1}),Fu=`ansi-esc`,Iu=/^(?:color:#[0-9a-f]{6}(?:;background-color:#[0-9a-f]{6})?|background-color:#[0-9a-f]{6})$/,Lu=String.raw`(?:\x1b|�|\\x1[bB]|\\u001[bB]|\\033|\\e|\^\[)`,Ru=new RegExp(Lu,`g`),zu=/\[([0-?]{0,64})[ -/]{0,8}([@-~])/y,Bu=new RegExp(String.raw`\][^\n]{0,2048}?(?:${Lu}\\\\?|\x07|�|\\a|\\x07|\\007|\\u0007)`,`y`),Vu=/[()][0-9A-Za-z]/y;function Hu(e){let t=``,n={...Pu},r=``,i=0,a=n=>{if(n<=i)return;let a=Yu(e.slice(i,n));t+=r?`${r}${a}</span>`:a};Ru.lastIndex=0;for(let o=Ru.exec(e);o;o=Ru.exec(e)){let s=o.index,c=s+o[0].length,l=-1,u;for(let t of[zu,Bu,Vu]){t.lastIndex=c;let n=t.exec(e);if(n){l=c+n[0].length,t===zu&&n[2]===`m`&&(u=n[1]);break}}l<0&&o[0]===`\x1B`&&(l=c),!(l<0)&&(a(s),t+=`<span class="${Fu}">${Yu(e.slice(s,l))}</span>`,u!==void 0&&(n=Uu(n,u),r=Ju(n)),i=l,Ru.lastIndex=l)}return a(e.length),t}function Uu(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=Wu(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=Wu(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,Pu,{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 Wu(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 Gu(n[0]);if(e===`2`&&n.length===3)return{hex:Ku(n[0],n[1],n[2])}}}function Gu(e){if(e<16)return{index:e};if(e>=232){let t=8+(e-232)*10;return{hex:Ku(t,t,t)}}let t=e=>e===0?0:55+e*40,n=e-16;return{hex:Ku(t(Math.floor(n/36)),t(Math.floor(n/6)%6),t(n%6))}}function Ku(...e){return`#${e.map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function qu(e){return e<8?Nu[e]:`bright-${Nu[e-8]}`}function Ju(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-${qu(t.index)}`):t?i.push(`color:${t.hex}`):e.inverse&&r.push(`ansi-fg-inverse`),n&&`index`in n?r.push(`ansi-bg-${qu(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 Yu(e){return e.replace(/[&<>"']/g,e=>e===`&`?`&amp;`:e===`<`?`&lt;`:e===`>`?`&gt;`:e===`"`?`&quot;`:`&#39;`)}var Xu={bash:Xl,css:au,diff:ou,javascript:hu,json:gu,markdown:_u,python:vu,rust:yu,sql:bu,typescript:Au,xml:ju,yaml:Mu};for(let[e,t]of Object.entries(Xu))Yl.registerLanguage(e,t);function Zu(e,t){if(t===`plaintext`)return is(e);if(t===`ansi`)return Hu(e);try{return Yl.highlight(e,{language:t,ignoreIllegals:!0}).value}catch{return is(e)}}function Qu(e,t,n=t){return`<code class="hljs language-${n}">${Zu(`${e.replace(/\n$/,``)}\n`,t)}</code>`}var $u=`<button type="button" class="${cn}" title="${D}"></button>`;function ed(e,t){let n=gn(t);return`<span class="${ps}"><pre>${Qu(e,n,/^\s*(lightbox|mermaid)\s*$/i.exec(t??``)?.[1].toLowerCase()??n)}</pre>${$u}</span>\n`}var td=/<span\b[^>]*>|<\/span>|\n|[^<\n]+|</g;function nd(e){let t=[],n=[],r=``;for(let[i]of e.matchAll(td))i===`
60
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 rd=/^(\s*\d+\t)([\s\S]*)$/,id=/^\s*\d+$/;function ad(e){let t=0,n=0,r=0;for(let i of e)i.trim()&&(t++,rd.test(i)?(n++,r++):id.test(i)&&n++);return t>0&&n===t&&r>0}function od(e){return e.replace(/[&<>"']/g,e=>e===`&`?`&amp;`:e===`<`?`&lt;`:e===`>`?`&gt;`:e===`"`?`&quot;`:`&#39;`)}var sd=`frizz-code-gutter`;function cd(e,t){let n=e.split(`
61
61
  `);if(!ad(n))return Zu(e,t);let r=[],i=[];for(let e of n){let t=rd.exec(e);t?(r.push(t[1]),i.push(t[2])):e.trim()&&id.test(e)?(r.push(e),i.push(``)):(r.push(``),i.push(e))}let a=nd(Zu(i.join(`
62
62
  `),t));return r.map((e,t)=>(e?`<span class="${sd}">${od(e)}</span>`:``)+(a[t]??``)).join(`
63
63
  `)}var ld=`md-diff-row`,ud=/(?:^|\s)lang(?:uage)?\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"']+))/i;function dd(e){let t=(e??``).trim(),n=t.split(/\s+/,1)[0].toLowerCase(),r=ud.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 fd=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,pd=/^(?:index [0-9a-f]+\.\.[0-9a-f]+|(?:new|deleted) file mode |(?:old|new) mode |(?:dis)?similarity index |(?:rename|copy) (?:from|to) |Binary files )/;function md(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=fd.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&&pd.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 hd(e){let t=e.slice(4).split(` `,1)[0].trim().replace(/^[ab]\//,``);return t&&t!==`/dev/null`?t:null}function gd(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(`+++ `)?hd(r.raw):null)??hd(e[n].raw);i&&t.push(i)}return t}var _d=e=>e.map(is);function vd(e,t){return e.length===0?[]:t===`plaintext`||t===`ansi`?_d(e):nd(Zu(e.join(`
64
64
  `),t))}function yd(e,t={}){let n=e.replace(/\n$/,``).split(`
65
- `),r=md(n),i=gd(r),a=re(t.label),o=t.declared?gn(t.declared):a===`plaintext`?re(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="${ld} md-diff-${t.kind}">${is(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=vd(i.filter(({row:e})=>e.kind!==`add`).map(({parts:e})=>e[1]),o),s=vd(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="${ld} md-diff-${e.kind}">${r}<span class="md-diff-sign">${is(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 bd=`md-line`,xd=`is-marked`,Sd=/\{\s*(\d[\d\s,–-]*)\}/;function Cd(e){let t=Sd.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 wd(e,t){return e.some(([e,n])=>t>=e&&t<=n)}function Td(e,t){let n=nd(e);return n.at(-1)?.replace(/<[^>]*>/g,``)===``&&n.pop(),n.map((e,n)=>`<span class="${bd}${wd(t,n+1)?` ${xd}`:``}">${e}\n</span>`).join(``)}var Ed=`md-code-frame`,Dd=`md-code-lined`,Od=`md-diff`,kd=/^(?:lightbox|mermaid)$/i,Ad=!0;function jd(e){let t=Ad;Ad=!1;try{return e()}finally{Ad=t}}function Md(e){if(e.label===void 0)return gn(e.info);let t=Lr(e.info)?.language;return t?gn(t):re(e.label)}function Nd(e){let t=`${e.text.replace(/\n$/,``)}\n`,n=t.split(`
65
+ `),r=md(n),i=gd(r),a=V(t.label),o=t.declared?gn(t.declared):a===`plaintext`?V(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="${ld} md-diff-${t.kind}">${is(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=vd(i.filter(({row:e})=>e.kind!==`add`).map(({parts:e})=>e[1]),o),s=vd(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="${ld} md-diff-${e.kind}">${r}<span class="md-diff-sign">${is(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 bd=`md-line`,xd=`is-marked`,Sd=/\{\s*(\d[\d\s,–-]*)\}/;function Cd(e){let t=Sd.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 wd(e,t){return e.some(([e,n])=>t>=e&&t<=n)}function Td(e,t){let n=nd(e);return n.at(-1)?.replace(/<[^>]*>/g,``)===``&&n.pop(),n.map((e,n)=>`<span class="${bd}${wd(t,n+1)?` ${xd}`:``}">${e}\n</span>`).join(``)}var Ed=`md-code-frame`,Dd=`md-code-lined`,Od=`md-diff`,kd=/^(?:lightbox|mermaid)$/i,Ad=!0;function jd(e){let t=Ad;Ad=!1;try{return e()}finally{Ad=t}}function Md(e){if(e.label===void 0)return gn(e.info);let t=Lr(e.info)?.language;return t?gn(t):V(e.label)}function Nd(e){let t=`${e.text.replace(/\n$/,``)}\n`,n=t.split(`
66
66
  `).length-1,r=dd(e.info),i=r?null:Cd(e.info),a=[],o,s;if(r){let t=yd(e.text,{declared:r.declared,label:e.label});o=`<code class="hljs language-diff">${t.html}</code>`,a.push(Od),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=Md(e);o=`<code class="hljs language-${n}">${Td(Zu(t,n),i)}</code>`,a.push(Dd)}else o=Qu(e.text,Md(e));let c=!1;if(i)for(let e=25;e<=n&&!c;e++)c=wd(i,e);let l=Ad&&e.closed&&n>40&&!c,u=l&&Or(e.text);return l&&a.push(u?Hi:`${Hi} ${Na}`),{code:o,classes:a,lines:n,long:l,open:u,diff:s}}var Pd=28,Fd=e=>e.length>=Pd?` title="${is(e)}"`:``;function Id({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 Ld=e=>`<button type="button" class="${ho}" aria-expanded="${e.open}">${Ha(e.lines,e.open)}</button>`;function Rd(e){let t=e.length===1;if(t&&kd.test(e[0].info.trim().split(/\s+/,1)[0]))return ed(e[0].text,e[0].closed?e[0].info:``);let n=e.map(Nd),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?ed(e[0].text,e[0].info):`<span class="${ps}"><pre class="${r.join(` `)}">${t}</pre>${$u}</span>\n`}let a=t?0:Ss(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="${gi}"><span class="${wi}"${Fd(r)}>${is(r)}</span>${n[0].diff?Id(n[0].diff):``}</span>`):t||(o=`<span class="${gi}" role="tablist">`+e.map((e,t)=>{let n=t===a,r=e.label??``;return`<button type="button" class="${Ni}${n?` ${wa}`:``}" role="tab" aria-selected="${n}"${Fd(r)}>${is(r)}</button>`}).join(``)+`</span>`);let s=n.map((e,n)=>{let r=[...i?[n===a?`${$r} ${wa}`:$r]:[],...e.classes];return`<pre${r.length>0?` class="${r.join(` `)}"`:``}${t?``:` role="tabpanel"`}>${e.code}</pre>`+(e.long?Ld(e):``)}).join(``);return`<span class="${ps} ${Ed}${i?` ${Za}`:``}">${o}${s}${$u}</span>\n`}var zd={name:`codeTabs`,level:`block`,tokenizer(){},renderer(e){return Rd(e.tabs)}},Bd=/^[a-zA-Z]:\\(?!\\)/,Vd=/(?<![A-Za-z0-9])[A-Za-z]:\\/,Hd=Hl.rules.inline.normal.link;function Ud(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||=Vd.test(r),e.tail=r.slice(-3)}function Wd(e){if(!/^[a-zA-Z]:/.test(e.href))return;let t=Hd.exec(e.raw);if(!t)return;let n=t[2].trim();n.startsWith(`<`)&&n.endsWith(`>`)&&(n=n.slice(1,-1)),Bd.test(n)&&(e.href=n)}function Gd(e){let t={inPath:!1,tail:``};for(let n=0;n<e.length;n++){let r=e[n];(r.type===`link`||r.type===`image`)&&Wd(r);let i=rn(r);for(let e of i)Gd(e);if(r.type===`text`&&i.length===0){Ud(t,r.raw);continue}if(r.type===`escape`){Ud(t,r.raw),r.raw!==`\\\\`&&t.inPath&&(e[n]={type:`text`,raw:r.raw,text:r.raw});continue}t.inPath=!1,t.tail=``}}var Kd=`md-callout`,qd=`md-callout-title`,Jd={note:`Note`,tip:`Tip`,important:`Important`,warning:`Warning`,caution:`Caution`},Yd={info:`note`,hint:`tip`,attention:`warning`,danger:`caution`,error:`caution`};function Xd(e){let t=e.toLowerCase();return Object.hasOwn(Jd,t)?t:Object.hasOwn(Yd,t)?Yd[t]:null}var Zd=/^\[!([A-Za-z]+)\](?=[ \t]|\n|$)/;function Qd(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.type===`list`){for(let e of n.items)Qd(e.tokens);continue}if(n.type!==`blockquote`)continue;let r=n,i=$d(r);i&&(e[t]=i),Qd(i?i.tokens:r.tokens)}}function $d(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=Zd.exec(a.text);if(!o||!a.raw.startsWith(o[0]))return null;let s=Xd(o[1]);if(!s)return null;let c=[],l=i.slice();for(l[0]=ef(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
67
  `);if(t<0){c.push(l.shift());continue}c.push(ef(e,0,t)),l[0]=ef(e,t+1);break}if(e.raw.includes(`
68
68
  `))break;c.push(l.shift())}tf(c),tf(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:nf(c),tokens:u}}function ef(e,t,n){return{...e,raw:e.raw.slice(t,n),text:e.text.slice(t,n)}}function tf(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 nf(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:nf(t)}:e})}var rf={name:`callout`,level:`block`,childTokens:[`titleTokens`,`tokens`],tokenizer(){},renderer(e){let{kind:t,titleTokens:n,tokens:r}=e;return`<blockquote class="${Kd} ${Kd}-${t}"><p class="${qd}">${n.length>0?this.parser.parseInline(n):Jd[t]}</p>\n${this.parser.parse(r)}</blockquote>\n`}},X=At();function af({caption:e,children:t}){return(0,X.jsxs)(`figure`,{className:of,children:[(0,X.jsx)(`div`,{className:sf,children:t}),e]})}var of=`frizz-image-frame max-w-full`,sf=`flex justify-center bg-panel-2 p-1.5`,cf=`block max-h-[420px] max-w-full w-auto rounded-md object-contain`,lf=/^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,uf={del(e){let t=lf.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}},df=/^:?-+:?$/,ff=/^ {0,3}$/,pf=/^[ \t]*$/;function mf(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||!ff.test(t[0])||!pf.test(t.at(-1))?null:t.slice(1,-1).map(e=>e.trim())}function hf(e){let t=[],n=0;for(let r of e.split(`
@@ -90,7 +90,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
90
90
  `&&!t)break;o++}i(e.slice(a,o),`str`),a=o;continue}if(rp(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(tp(n)){let n=a+1;for(;n<r&&np(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($f(e,n))?`key`:e[n]===`(`?`fn`:`plain`),a=n;continue}if(ip.has(n)){i(n,`punct`),a++;continue}if(ap.has(n)){let t=a+1;for(;t<r&&ap.has(e[t]);)t++;i(e.slice(a,t),`op`),a=t;continue}let o=a+1;for(;o<r&&!tp(e[o])&&!rp(e[o])&&!t.quotes.includes(e[o])&&!ip.has(e[o])&&!ap.has(e[o])&&!(t.line&&e.startsWith(t.line,o));)o++;i(e.slice(a,o),`plain`),a=o}return n}function sp(e){let t=[[]];for(let n of e){let e=n.text.split(`
91
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 cp(e,t){if(e===``)return[];let n=Zf[t];return n?sp(op(e,n)):e.split(`
92
92
  `).map(e=>e?[{text:e,kind:`plain`}]:[])}var lp={".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`},up={Dockerfile:`shell`,Makefile:`shell`,".gitignore":`shell`,".env":`shell`,".bashrc":`shell`,".zshrc":`shell`};function dp(e){let t=Nt(e),n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=up[t]??lp[r]??`text`;return ep.has(i)?i:`text`}function fp(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 pp(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(...fp(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 mp=3,hp=e=>e===``?[]:e.split(`
93
- `);function gp(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 _p(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]-mp),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+mp),!(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-mp)))}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 vp(e,t,n){let r=dp(n),i=cp(e,r),a=cp(t,r),o=hp(e),s=hp(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=pp(o,s).map(e=>gp(e,i,a)),u=l.filter(e=>e.type===`add`).length,d=l.filter(e=>e.type===`del`).length,{hunks:f,collapsedAfter:p}=_p(l);return{file:n,lang:r,status:c,hunks:f,collapsedAfter:p,additions:u,deletions:d}}var yp=`flex min-w-0 items-baseline gap-2`,bp=`flex shrink-0 items-baseline gap-2`;function xp(e){return e===`failed`||e===`cancelled`?e:void 0}function Sp(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`))+1;return{dir:e.slice(0,t),base:e.slice(t)}}var Cp=`a, button, input, select, textarea, summary, label, [role="button"], [role="link"]`;function wp(e){let t=e;return typeof t?.closest==`function`&&t.closest(Cp)!=null}function Tp({children:e,className:t,controls:n,expanded:r,label:i,meta:a,onToggle:o}){function s(e){if(wp(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:yp},e),(0,q.createElement)(`span`,{className:bp},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)(Kt,{"aria-hidden":!0,size:12,className:`frizz-tool-chevron${r?` rotate-90`:``}`}))))}function Ep(e){let t=W.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function Dp({path:e}){let{dir:t,base:n}=Sp(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 Op({open:e=!1,shown:t=!0}){return t?(0,X.jsx)(Kt,{"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 kp({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 Ap({edits:e,meta:t}){let n=(0,q.useId)(),r=e[0].file,i=(0,q.useMemo)(()=>e.map(e=>vp(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)(Tp,{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)(kp,{path:r,children:(0,X.jsx)(Dp,{path:Ep(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)(jp,{hunks:e.hunks,collapsedAfter:e.collapsedAfter})},t))})]})}function jp({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)(Mp,{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)(Mp,{n:t},`safter`)),(0,X.jsx)(X.Fragment,{children:r})}function Mp({n:e}){return(0,X.jsxs)(`div`,{className:`frizz-diff-sep`,children:[e,` unchanged line`,e===1?``:`s`]})}function Np(e){return(0,q.useMemo)(()=>({__html:e}),[e])}var Pp=/^[\w.@+-]+\.[a-z][a-z0-9]{0,7}$/i,Fp=/^(?:[A-Za-z]:\\|\\\\)?[\w.@+~-]+(?:\\[\w.@+~-]+)*(?::\d+(?::\d+)?)?$/;function Ip(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(`\\`)&&Fp.test(t)?!0:Pp.test(t)}var Lp=/^(?:~(?:[\\/]|$)|\/|[A-Za-z]:[\\/]|\\\\)/;function Rp(e,t){return e?{key:`project:${e}`,apiFor:()=>ct(e)}:hr(t)?{key:`console`,apiFor:e=>Lp.test(e)?wo(e):null}:{key:`page:${Ba(t)??``}`,apiFor:()=>U}}var zp=new Map,Bp=(e,t)=>`${e.key}\n${t}`;function Vp(e,t){return zp.get(Bp(e,t))}var Hp=new Set,Up=0,Wp=new Set,Gp=e=>(Wp.add(e),()=>{Wp.delete(e)}),Kp=()=>Up,qp=128;async function Jp(e,t){let n=[...new Set(t)].filter(t=>!zp.has(Bp(e,t))&&!Hp.has(Bp(e,t)));if(!n.length)return;for(let t of n)Hp.add(Bp(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+=qp)i.push({api:e,paths:t.slice(n,n+qp)});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=Bp(e,n.input);zp.has(t)||(zp.set(t,n.path),o=!0)}for(let t of n)Hp.delete(Bp(e,t));if(o){Up+=1;for(let e of Wp)e()}}function Yp(e,t){e.setAttribute(`data-local-path`,t),e.setAttribute(`title`,`Open ${t}`),e.classList.add(`local-file-code`)}function Xp(e,t){let n=(0,q.useSyncExternalStore)(Gp,Kp,Kp),r=Ii();(0,q.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=Rp(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(!Ip(t))continue;let r=Vp(n,t);r===void 0?i.push(t):r&&Yp(e,r)}i.length&&Jp(n,i)},[e,t,n,r])}var Zp=0;function Qp(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}-${++Zp}`,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 $p=`[overflow-wrap:anywhere]`,em=`rounded-xl`,tm=`rounded-b-[calc(var(--block-radius)_-_1px)]`,nm={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`}},rm=`card-icon-offset`;function im(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 am({icon:e,className:t}){return(0,X.jsx)(e,{ref:im(e),"aria-hidden":`true`,size:16,className:`shrink-0 ${rm} ${t}`})}function om({icon:e,label:t,head:n=nm.neutral.head,aside:r}){return(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[e&&(0,X.jsx)(am,{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 sm=`flex min-w-0 items-center gap-[5px] text-[12px] font-medium leading-4`,cm=12,lm=cm*22/24;function um({icon:e,children:t,className:n=`text-muted`,evenInk:r=!1}){let i=im(e,r?lm:void 0);return(0,X.jsxs)(`span`,{"data-card-kind":!0,className:`${sm} ${n}`,children:[e&&(0,X.jsx)(e,{ref:i,"aria-hidden":`true`,size:cm,className:`shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0`,children:t})]})}function dm({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)(um,{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 fm({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 pm({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}=nm[e],f=n!=null&&(i??o!=null);return(0,X.jsxs)(`div`,{...l,className:`min-w-0 ${em} border ${c===`question`?`border-question-border bg-question`:`${u} bg-panel-2`} p-4 ${s}`,children:[n==null?(0,X.jsx)(om,{icon:t,label:r,head:d,aside:a}):(0,X.jsx)(dm,{icon:t,kind:n,kindClass:e===`neutral`?`text-muted`:d,label:r,head:e===`neutral`?d:nm.neutral.head,aside:a,ruled:f,evenInk:c===`question`}),o!=null&&(0,X.jsx)(fm,{gap:n==null?`plain`:f?`ruled`:`band`,children:o})]})}var mm=`block min-w-0 text-[13px] leading-5 text-fg/75`;function hm({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 ${tm} ${t}`,children:e})}var gm=`min-w-0 flex-1 text-[11px] leading-snug text-muted-70`,_m=`text-accent underline underline-offset-2 decoration-accent/40 hover:decoration-accent`,vm=`bg-fg px-2.5 py-1 text-bg hover:opacity-90`,ym=`rounded-md`,bm=`flex shrink-0 items-center gap-1 ${ym} text-[11px] font-medium outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${vm}`;function xm(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 Sm=e=>new Promise(t=>setTimeout(t,e));function Cm(e,{retryAfterMs:t=800,wait:n=Sm}={}){let r;return()=>(r??=e().catch(()=>n(t).then(e)).catch(e=>{throw r=void 0,e}),r)}function wm(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function Tm(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function Em(e,t){let n=wm(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function Dm({directive:e,icon:t,title:n,meta:r,children:i}){return(0,X.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${em} 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 Om({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 km({directive:e}){let t=e.attrs,n=wm(t,`display_name`)??wm(t,`skill_name`)??`Artifact template`,r=wm(t,`artifact_kind`),i=wm(t,`skill_name`),a=wm(t,`skill_directory`),[o,s]=(0,q.useState)(!!a);return(0,X.jsxs)(Dm,{directive:e,icon:(0,X.jsx)(rc,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,X.jsx)(Om,{mono:!0,children:i.startsWith(`$`)?i:`$${i}`}),o&&a&&(0,X.jsx)(`img`,{src:go(`${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 Am({directive:e}){let t=e.attrs,n=wm(t,`file`),r=Tm(t,`start`),i=Tm(t,`end`)??r,a=Tm(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,X.jsxs)(Dm,{directive:e,icon:(0,X.jsx)(cc,{size:15}),title:wm(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[wm(t,`body`)&&(0,X.jsx)(Om,{children:wm(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)(Om,{mono:!0,children:o})]})}var jm={"git-stage":[fc,`Changes staged`],"git-commit":[Oe,`Commit created`],"git-create-branch":[ec,`Branch created`],"git-push":[Sc,`Branch pushed`],"git-create-pr":[Ms,`Pull request created`]};function Mm({directive:e}){let[t,n]=jm[e.name],r=wm(e.attrs,`branch`),i=Em(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,X.jsx)(Dm,{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 Nm({directive:e}){let t=wm(e.attrs,`threadId`),n=wm(e.attrs,`pendingWorktreeId`);return(0,X.jsx)(Dm,{directive:e,icon:(0,X.jsx)(dc,{size:15}),title:n?`Thread setup queued`:`Thread created`,meta:(t||n)&&(0,X.jsx)(`span`,{className:`font-mono-keep`,children:t??n})})}function Pm({directive:e}){let t=wm(e.attrs,`reason`);return(0,X.jsx)(Dm,{directive:e,icon:(0,X.jsx)(Bs,{size:15}),title:`Archive suggested`,meta:t})}function Fm(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 Im({directive:e}){let t=e.attrs,n=wm(t,`mode`),r=wm(t,`name`)??`Automation`,i=Fm(t.rrule),a=[r,n,wm(t,`status`),i].filter(Boolean).join(` · `);return(0,X.jsx)(Dm,{directive:e,icon:(0,X.jsx)(Ws,{size:15}),title:`Automation suggested`,meta:a,children:wm(t,`prompt`)&&(0,X.jsx)(Om,{children:wm(t,`prompt`)})})}function Lm({directive:e}){return e.name===`artifact-template`?(0,X.jsx)(km,{directive:e}):e.name===`code-comment`?(0,X.jsx)(Am,{directive:e}):e.name.startsWith(`git-`)?(0,X.jsx)(Mm,{directive:e}):e.name===`created-thread`?(0,X.jsx)(Nm,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,X.jsx)(Pm,{directive:e}):(0,X.jsx)(Im,{directive:e})}var Rm=0,zm=Cm(()=>as(async()=>{let{default:e}=await import(`./mermaid.core-B9-DVS7z.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 Bm(){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 Vm=xm(async e=>{let t=await zm();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 Hm({source:e}){let t=(0,q.useId)(),{resolved:n}=(0,q.useSyncExternalStore)(Lt,bt,bt),[r,i]=(0,q.useState)({}),a=(0,q.useRef)(0),o=Np(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,``)}-${++Rm}`;return Vm.enqueue({id:s,source:e,resolved:n,palette:Bm()}).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:`${em} 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 ${em} 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 ${em} bg-panel-2`})}var Um=e=>e.replace(/\n$/,``);function Wm(e,t){return Qp(e,t,`mermaid`,`md-mermaid`,Um).map(({key:e,host:t,value:n})=>(0,Tc.createPortal)((0,X.jsx)(Hm,{source:n}),t,e))}function Gm(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 Km={scale:1,x:0,y:0},qm=(e,t,n)=>Math.min(Math.max(e,t),n);function Jm(e,t,n,r,i){let a=t*n/2;return 2*a<=i-r?qm(0,r+a,i-a):qm(e,i-a,r+a)}function Ym(e,t){let n=qm(e.scale,1,t.max);return n===1?Km:{scale:n,x:Jm(e.x,t.width,n,t.left,t.right),y:Jm(e.y,t.height,n,t.top,t.bottom)}}function Xm(e,t,n,r){let i=qm(e.scale*t,1,r.max),a=i/e.scale;return Ym({scale:i,x:n.x-(n.x-e.x)*a,y:n.y-(n.y-e.y)*a},r)}function Zm(e,t,n,r){return Ym({scale:e.scale,x:e.x+t,y:e.y+n},r)}function Qm(e,t,n,r,i,a){let o=qm(e.scale*(i/Math.max(n,1)),1,a.max),s=o/e.scale;return Ym({scale:o,x:r.x-(t.x-e.x)*s,y:r.y-(t.y-e.y)*s},a)}function $m(e,t){return qm(t/Math.max(e,1),2,4)}function eh(e,t){return qm(2*t/Math.max(e,1),4,12)}var th=6,nh=420,rh=16/10,ih=.4,ah=3,oh=(e,t,n)=>Math.min(Math.max(e,t),n),sh=e=>oh(e/4,112,180);function ch({entries:e,baseDir:t,framed:n=!0}){let r=Wf(),i=(0,q.useMemo)(()=>t?{...r,dir:t}:r,[r,t]),a=(0,q.useMemo)(()=>e.map(e=>{let t=ze(e.target,i);return{entry:e,path:t,label:Ht(e,t)}}),[e,i]),[o,s]=(0,q.useState)({}),[c,l]=(0,q.useState)({}),[u,d]=(0,q.useState)(null),f=ph(u),p=a.filter(e=>e.path!==null&&!c[e.path]),m=a.filter(e=>!p.includes(e)),h=e=>oh(o[e.path]||rh,ih,ah),g=Gm(p.map(h),f,{gap:th,target:sh(f),maxHeight:nh,maxPerRow:8}),_=a.some(e=>e.entry.caption),v=p.map(e=>Tt(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)(fh,{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)(uh,{tile:t,ratio:h(t),labelled:_,onOpen:()=>xi(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)(fh,{tile:e},t))]});return n?(0,X.jsx)(af,{children:y}):(0,X.jsx)(`div`,{className:sf,children:y})}function lh(e){return{flex:`${e} 1 0%`}}function uh({tile:e,ratio:t,labelled:n,onOpen:r,onShape:i,onBroken:a}){let o=ra(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:lh(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:`${go(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)(dh,{})]}):(0,X.jsx)(`img`,{src:go(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 dh(){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)(pc,{size:14,strokeWidth:Bh,absoluteStrokeWidth:!0,fill:`currentColor`})})}function fh({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 ph(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 mh(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 hh(e,t,n){return Qp(e,t,`lightbox`,`md-lightbox`,ge).map(({key:e,host:t,value:r})=>(0,Tc.createPortal)((0,X.jsx)(ch,{entries:r,baseDir:n}),t,e))}function gh(){let{lightbox:e}=un(W);return e?(0,X.jsx)(Re,{children:(0,X.jsx)(kh,{images:e.images,index:e.index})}):null}var _h={x:0,y:0},vh=e=>({path:e,zoom:Km,pull:_h,animate:!1,max:1/0,panning:!1}),yh={mouse:4,touch:10},bh=48,xh=96,Sh=300,Ch=40,wh=1.5,Th=1.1,Eh=`transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1)`,Dh=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Oh=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function kh({images:e,index:t}){Oo(sr(),!1,ii);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),s=(0,q.useCallback)(e=>{i.current=e,o(e)},[]),c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=e[t],d=u?.path??``,f=ra(d),p=(0,q.useId)(),[m,h]=(0,q.useState)(null),g=mh(m),_=u?.caption?g:0,v=(0,q.useRef)(vh(d)),[y,b]=(0,q.useState)(v.current),x=()=>v.current.path===d?v.current:vh(d),S=e=>{let t={...x(),...e};v.current=t,b(t)},C=y.path===d?y:vh(d),w=(0,q.useRef)(new Map),T=(0,q.useRef)(`mouse`),E=(0,q.useRef)(null),D=(0,q.useRef)(!1),O=(0,q.useRef)(null),k=()=>{let e=c.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},l=t.getBoundingClientRect();return{centre:s,bounds:{width:a,height:o,left:l.left-s.x,right:l.right-s.x,top:l.top-s.y,bottom:l.bottom-s.y,max:eh(a,e.naturalWidth)},detail:$m(a,e.naturalWidth)}},A=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),j=(e,t)=>{let n=k();n&&S({zoom:e(x().zoom,n),animate:t,max:n.bounds.max})},M=e=>j((t,n)=>t.scale>1?Km:Xm(Km,n.detail,A(e,n.centre),n.bounds),!0),N=e=>j((t,n)=>Xm(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(oh(-e.deltaY*t*.01,-.5,.5));j((t,r)=>Xm(t,n,A({x:e.clientX,y:e.clientY},r.centre),r.bounds),!1)}else x().zoom.scale>1&&(e.preventDefault(),j((n,r)=>Zm(n,-e.deltaX*t,-e.deltaY*t,r.bounds),!1))},t=null,n=e=>{e.preventDefault();let n=e;if(e.type===`gesturestart`)t=x().zoom;else if(e.type===`gesturechange`&&t&&w.current.size===0){let e=t;j((t,r)=>Xm(e,n.scale,A({x:n.clientX,y:n.clientY},r.centre),r.bounds),!1)}},r=new ResizeObserver(()=>{x().zoom.scale>1&&j((e,t)=>Ym(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,d]),!u)return null;let P=e.length>1,F=C.zoom.scale>1,L=t=>{let n=!t.ctrlKey&&!t.metaKey&&!t.altKey;if(t.key===`ArrowLeft`)vs(-1);else if(t.key===`ArrowRight`)vs(1);else if(t.key===`Home`)vs(-e.length);else if(t.key===`End`)vs(e.length);else if(n&&(t.key===`+`||t.key===`=`))N(wh);else if(n&&(t.key===`-`||t.key===`_`))N(1/wh);else if(n&&t.key===`0`)S({zoom:Km,animate:!0});else if(n&&t.key===` `&&f&&t.target!==l.current){let e=l.current;e?.paused?e.play().catch(()=>void 0):e?.pause()}else if(t.key===`Escape`)ii();else return;t.preventDefault(),t.stopPropagation()},R=e=>{e.target===e.currentTarget&&ii()},z=e=>{if(!(e.pointerType===`mouse`&&e.button!==0)&&!e.target.closest(`button, video`)){if(w.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),w.current.size===1)T.current=e.pointerType,D.current=!1,E.current={kind:`press`,id:e.pointerId,x:e.clientX,y:e.clientY};else if(w.current.size===2){let e=k(),[t,n]=[...w.current.values()];D.current=!0,O.current=null,E.current=e?{kind:`pinch`,start:x().zoom,mid:A(Dh(t,n),e.centre),distance:Oh(t,n)}:null,x().pull!==_h&&S({pull:_h,animate:!0})}}},B=n=>{if(!w.current.has(n.pointerId))return;w.current.set(n.pointerId,{x:n.clientX,y:n.clientY});let r=E.current;if(r?.kind===`pinch`){let e=r,[t,n]=[...w.current.values()];j((r,i)=>Qm(e.start,e.mid,e.distance,A(Dh(t,n),i.centre),Oh(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`?yh.mouse:yh.touch))return;if(D.current=!0,O.current=null,x().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(E.current=r,!r)return;i.current?.setPointerCapture(n.pointerId),r.kind===`pan`&&S({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,j((n,r)=>Zm(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;S({pull:r.axis===`x`?{x:o?i/4:i,y:0}:{x:0,y:a},animate:!1})}}},ee=e=>{if(!w.current.delete(e.pointerId))return;let t=E.current;if(t?.kind===`pinch`){let[e]=[...w.current.entries()];x().zoom.scale<Th&&S({zoom:Km,animate:!0}),E.current=e&&x().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;E.current=null;let n=e.type===`pointercancel`;if(t.kind===`pan`&&S({panning:!1}),t.kind===`swipe`){let r=e.clientX-t.x,i=e.clientY-t.y;if(S({pull:_h,animate:!0}),n)return;t.axis===`x`&&Math.abs(r)>bh?vs(r<0?1:-1):t.axis===`y`&&Math.abs(i)>xh&&ii();return}if(t.kind===`press`&&!n&&e.pointerType!==`mouse`){let t=O.current;t&&e.timeStamp-t.t<Sh&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<Ch?(O.current=null,D.current=!0,M({x:e.clientX,y:e.clientY})):O.current={t:e.timeStamp,x:e.clientX,y:e.clientY}}},V=e=>{if(D.current){D.current=!1;return}if(e.target.closest(`button, video, [data-lightbox-caption]`))return;let t=T.current===`mouse`;e.target===c.current?t&&M({x:e.clientX,y:e.clientY}):x().zoom.scale>1?t&&S({zoom:Km,animate:!0}):ii()},te=1-Math.min(Math.abs(C.pull.y)/(xh*3),.6);return(0,X.jsx)(va,{open:!0,onOpenChange:e=>{e||ii()},children:(0,X.jsxs)(yi,{children:[(0,X.jsx)(ni,{className:`overlay-in fixed inset-0 ${Nr} bg-black/95 backdrop-blur-md`,style:{opacity:te}}),(0,X.jsxs)(Wo,{ref:r,"data-lightbox":!0,"aria-modal":`true`,"aria-describedby":u.caption?p:void 0,onEscapeKeyDown:st,onOpenAutoFocus:e=>{e.preventDefault(),r.current?.focus({preventScroll:!0})},onCloseAutoFocus:e=>{e.preventDefault(),n.current?.isConnected&&n.current.focus({preventScroll:!0})},onKeyDown:L,className:`overlay-in fixed inset-0 ${Nr} flex flex-col text-white outline-none`,children:[(0,X.jsxs)(`header`,{onClick:R,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:te},children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(eo,{className:`truncate text-[13px] font-medium leading-5 text-white/90 ${u.titled?``:`font-mono-keep`}`,children:u.label}),(0,X.jsx)(`div`,{className:`truncate font-mono-keep text-[11px] leading-4 text-white/45`,children:u.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:[P&&(0,X.jsxs)(`span`,{"data-lightbox-counter":!0,className:`mr-2.5 text-[12px] tabular-nums text-[#787a7d]`,children:[t+1,` / `,e.length]}),!f&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(zh,{label:`Zoom out`,onClick:()=>N(1/wh),disabled:!F,className:`pointer-coarse:hidden`,children:(0,X.jsx)(wc,{size:14,strokeWidth:2})}),(0,X.jsx)(zh,{label:`Zoom in`,onClick:()=>N(wh),disabled:C.zoom.scale>=C.max-1e-6,className:`pointer-coarse:hidden`,children:(0,X.jsx)(Cc,{size:14,strokeWidth:2})})]}),(0,X.jsx)(zh,{label:`Download`,onClick:()=>Ah(u),children:(0,X.jsx)(Xs,{size:14,strokeWidth:2,className:Rh})}),(0,X.jsx)(zh,{label:f?`Open in default player`:`Open in default viewer`,onClick:()=>I(u.path,!0),children:(0,X.jsx)(Zs,{size:14,strokeWidth:2,className:Rh})}),(0,X.jsx)(zh,{label:`Close`,onClick:ii,children:(0,X.jsx)(sa,{size:15,strokeWidth:2,className:Rh})})]})]}),(0,X.jsxs)(`div`,{ref:s,"data-lightbox-stage":!0,onClick:V,onPointerDown:z,onPointerMove:B,onPointerUp:ee,onPointerCancel:ee,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 ${F?C.panning?`cursor-grabbing`:`cursor-grab`:``}`,style:{touchAction:`none`},children:[f?(0,X.jsx)(Ph,{image:u,view:C,reserve:_,videoRef:l},u.path):(0,X.jsx)(Nh,{image:u,view:C,reserve:_,pictureRef:c},u.path),u.caption&&(0,X.jsx)(`p`,{ref:h,id:p,"data-lightbox-caption":!0,className:`max-w-2xl shrink-0 text-balance pt-3 text-center text-[13px] leading-5 text-white/75 ${F?`pointer-events-none`:``}`,style:{transform:`translate(${C.pull.x}px, ${C.pull.y}px)`,transition:`${C.animate?Eh:`transform 0s`}, opacity 150ms ease-out`,opacity:F?0:te},children:u.caption}),P&&t>0&&(0,X.jsx)(Vh,{side:`left`,onClick:()=>vs(-1)}),P&&t<e.length-1&&(0,X.jsx)(Vh,{side:`right`,onClick:()=>vs(1)})]})]})]})})}function Ah(e){let t=document.createElement(`a`);t.href=go(e.path),t.download=_t(e),document.body.append(t),t.click(),t.remove()}function jh({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 Mh=e=>e?`calc(100% - ${e}px)`:void 0;function Nh({image:e,view:t,reserve:n,pictureRef:r}){let[i,a]=(0,q.useState)(!1);if(i)return(0,X.jsx)(jh,{what:`Image`,path:e.path});let{scale:o,x:s,y:c}=t.zoom;return(0,X.jsx)(`img`,{ref:r,src:go(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:Mh(n),transform:`translate(${s+t.pull.x}px, ${c+t.pull.y}px) scale(${o})`,transition:t.animate?Eh:`none`,borderRadius:6/o,boxShadow:`0 0 0 ${1/o}px rgb(255 255 255 / 0.1)`}})}function Ph({image:e,view:t,reserve:n,videoRef:r}){let[i,a]=(0,q.useState)(!1);return i?(0,X.jsx)(jh,{what:`Video`,path:e.path}):(0,X.jsx)(`video`,{ref:r,src:go(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:Mh(n),transform:`translate(${t.pull.x}px, ${t.pull.y}px)`,transition:t.animate?Eh:`none`,boxShadow:`0 0 0 1px rgb(255 255 255 / 0.1)`}})}var Fh=`icon-focus-outline text-[#787a7d] transition-colors hover:bg-white/[0.04] hover:text-[#e6e7e9]`,Ih=`cursor-default text-[#303132]`,Lh=`pointer-coarse:size-11 pointer-coarse:rounded-full pointer-coarse:text-[#cfd0d2]`,Rh=`pointer-coarse:size-[21px] pointer-coarse:[stroke-width:2.1]`;function zh({label:e,onClick:t,disabled:n,className:r=``,children:i}){return(0,X.jsx)(me,{label:e,side:`bottom`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":e,"aria-disabled":n||void 0,onClick:()=>{n||t()},className:`${Wt} focus-visible:ring-1 focus-visible:ring-white/60 ${n?Ih:Fh} ${Lh} ${r}`,children:i})})}var Bh=1.5;function Vh({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`?Gs:Kt,{size:20,strokeWidth:Bh,absoluteStrokeWidth:!0})})}function Hh({as:e=`div`,className:t,html:n}){let r=Np(n),i=(0,q.useRef)(null);Xp(i,n);let a=hh(i,n),o=Wm(i,n);return(0,X.jsxs)(X.Fragment,{children:[(0,q.createElement)(e,{ref:i,className:t,dangerouslySetInnerHTML:r}),a,o]})}function Uh({text:e,language:t,className:n=``,...r}){let i=Np((0,q.useMemo)(()=>cd(e,t),[e,t]));return(0,X.jsx)(`pre`,{...r,className:`hljs ${n}`,dangerouslySetInnerHTML:i})}var Wh=`Todos`,Gh={pending:{Icon:xc,className:`text-muted-50`},in_progress:{Icon:yc,className:`text-accent`},completed:{Icon:vc,className:`text-muted-75`}},Kh={pending:`text-fg/75`,in_progress:`text-fg`,completed:`text-muted-70`};function qh({status:e}){let{Icon:t,className:n}=Gh[e];return(0,X.jsx)(t,{"aria-hidden":`true`,size:`1em`,strokeWidth:2,className:`frizz-todo-mark shrink-0 ${n}`})}var Jh={pending:`to do`,in_progress:`in progress`,completed:`done`};function Yh({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`} `:``}${Wh}${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:yp,children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:Wh}),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)(qh,{status:`in_progress`}),(0,X.jsx)(`span`,{className:`frizz-tool-detail`,children:d})]})]}),(0,X.jsxs)(`span`,{className:bp,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)(Op,{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)(qh,{status:e.status}),(0,X.jsx)(`span`,{className:`min-w-0 ${Kh[e.status]}`,children:e.text}),(0,X.jsx)(`span`,{className:`sr-only`,children:` — ${Jh[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 Xh=/^```question(?:[ \t]+([A-Za-z][^\r\n]*?))?[ \t]*\r?\n(?:([\s\S]*?)\r?\n)??```[ \t]*$/gm,Zh=/^qst_[a-z0-9]+$/;function Qh(e){let t=(e??``).toLowerCase().split(/\s+/).filter(Boolean),n=e=>t.includes(e),r=t.find(e=>Zh.test(e));return{kind:n(`multi`)?`multi`:`question`,danger:n(`danger`),...r?{registeredId:r}:{}}}function $h(e){let t=[],n=xr(e),r=0;Xh.lastIndex=0;for(let i=Xh.exec(e);i!==null;i=Xh.exec(e)){if(n(i.index)){Xh.lastIndex=i.index+1;continue}let{kind:a,danger:o,registeredId:s}=Qh(i[1]);if(i[2]===void 0&&!s){Xh.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}),og(t)}function eg(e,t,n){if(!t||!Zo(e))return $h(e);let r=Ea(e).filter(e=>e.read.form!==`invalid`||rg(e.body));if(r.length===0)return $h(e);let i=[],a=0;for(let t of r){if(i.push(...$h(e.slice(a,t.start))),a=t.end,t.read.form===`ref`&&tg(t.read,n)){i.push({kind:`refusedRef`,id:t.read.id});continue}if(t.read.form===`ask`&&tg(t.read,n)){i.push({kind:`refusedAsk`,id:t.read.id,spec:t.read.spec});continue}if(t.read.form===`invalid`){let n=Fi(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(...$h(e.slice(a))),i}function tg(e,t){return t!==void 0&&t.size>0&&t.has(e.id.toLowerCase())}var ng=RegExp(`^[ \\t]*(?:${$a.join(`|`)}):(?:[ \\t]|$)`);function rg(e){let t=e.split(/\r?\n/).find(e=>e.trim()!==``);return t!==void 0&&ng.test(t)}function ig(e,t){if(!Zo(e))return[];let n=[];for(let r of Ea(e)){let e=r.read;e.form===`invalid`||tg(e,t)||(e.form===`ref`||e.form===`ask`&&!e.when)&&n.push(e.id.toLowerCase())}for(let r of ag(e,t))n.includes(r)||n.push(r);return n}function ag(e,t){if(!Zo(e)||!e.includes(`when:`))return[];let n=Ea(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||tg(e,t))continue;let n=e.when.parent.toLowerCase();!r.has(n)&&!i.includes(n)&&i.push(n)}return i}function og(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=vg(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=Cg(i.options[i.options.length-1]);if(!/^([A-Z]|\d+)$/.test(e))continue;a=e}let o=sg(r.text,a);o!==null&&(e[t]={...n,text:n.text.replace(/\s+$/,``)+`
93
+ `);function gp(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 _p(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]-mp),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+mp),!(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-mp)))}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 vp(e,t,n){let r=dp(n),i=cp(e,r),a=cp(t,r),o=hp(e),s=hp(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=pp(o,s).map(e=>gp(e,i,a)),u=l.filter(e=>e.type===`add`).length,d=l.filter(e=>e.type===`del`).length,{hunks:f,collapsedAfter:p}=_p(l);return{file:n,lang:r,status:c,hunks:f,collapsedAfter:p,additions:u,deletions:d}}var yp=`flex min-w-0 items-baseline gap-2`,bp=`flex shrink-0 items-baseline gap-2`;function xp(e){return e===`failed`||e===`cancelled`?e:void 0}function Sp(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`))+1;return{dir:e.slice(0,t),base:e.slice(t)}}var Cp=`a, button, input, select, textarea, summary, label, [role="button"], [role="link"]`;function wp(e){let t=e;return typeof t?.closest==`function`&&t.closest(Cp)!=null}function Tp({children:e,className:t,controls:n,expanded:r,label:i,meta:a,onToggle:o}){function s(e){if(wp(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:yp},e),(0,q.createElement)(`span`,{className:bp},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)(Kt,{"aria-hidden":!0,size:12,className:`frizz-tool-chevron${r?` rotate-90`:``}`}))))}function Ep(e){let t=W.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function Dp({path:e}){let{dir:t,base:n}=Sp(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 Op({open:e=!1,shown:t=!0}){return t?(0,X.jsx)(Kt,{"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 kp({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 Ap({edits:e,meta:t}){let n=(0,q.useId)(),r=e[0].file,i=(0,q.useMemo)(()=>e.map(e=>vp(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)(Tp,{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)(kp,{path:r,children:(0,X.jsx)(Dp,{path:Ep(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)(jp,{hunks:e.hunks,collapsedAfter:e.collapsedAfter})},t))})]})}function jp({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)(Mp,{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)(Mp,{n:t},`safter`)),(0,X.jsx)(X.Fragment,{children:r})}function Mp({n:e}){return(0,X.jsxs)(`div`,{className:`frizz-diff-sep`,children:[e,` unchanged line`,e===1?``:`s`]})}function Np(e){return(0,q.useMemo)(()=>({__html:e}),[e])}var Pp=/^[\w.@+-]+\.[a-z][a-z0-9]{0,7}$/i,Fp=/^(?:[A-Za-z]:\\|\\\\)?[\w.@+~-]+(?:\\[\w.@+~-]+)*(?::\d+(?::\d+)?)?$/;function Ip(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(`\\`)&&Fp.test(t)?!0:Pp.test(t)}var Lp=/^(?:~(?:[\\/]|$)|\/|[A-Za-z]:[\\/]|\\\\)/;function Rp(e,t){return e?{key:`project:${e}`,apiFor:()=>ct(e)}:hr(t)?{key:`console`,apiFor:e=>Lp.test(e)?wo(e):null}:{key:`page:${Ba(t)??``}`,apiFor:()=>U}}var zp=new Map,Bp=(e,t)=>`${e.key}\n${t}`;function Vp(e,t){return zp.get(Bp(e,t))}var Hp=new Set,Up=0,Wp=new Set,Gp=e=>(Wp.add(e),()=>{Wp.delete(e)}),Kp=()=>Up,qp=128;async function Jp(e,t){let n=[...new Set(t)].filter(t=>!zp.has(Bp(e,t))&&!Hp.has(Bp(e,t)));if(!n.length)return;for(let t of n)Hp.add(Bp(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+=qp)i.push({api:e,paths:t.slice(n,n+qp)});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=Bp(e,n.input);zp.has(t)||(zp.set(t,n.path),o=!0)}for(let t of n)Hp.delete(Bp(e,t));if(o){Up+=1;for(let e of Wp)e()}}function Yp(e,t){e.setAttribute(`data-local-path`,t),e.setAttribute(`title`,`Open ${t}`),e.classList.add(`local-file-code`)}function Xp(e,t){let n=(0,q.useSyncExternalStore)(Gp,Kp,Kp),r=Ii();(0,q.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=Rp(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(!Ip(t))continue;let r=Vp(n,t);r===void 0?i.push(t):r&&Yp(e,r)}i.length&&Jp(n,i)},[e,t,n,r])}var Zp=0;function Qp(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}-${++Zp}`,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 $p=`[overflow-wrap:anywhere]`,em=`rounded-xl`,tm=`rounded-b-[calc(var(--block-radius)_-_1px)]`,nm={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`}},rm=`card-icon-offset`;function im(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 am({icon:e,className:t}){return(0,X.jsx)(e,{ref:im(e),"aria-hidden":`true`,size:16,className:`shrink-0 ${rm} ${t}`})}function om({icon:e,label:t,head:n=nm.neutral.head,aside:r}){return(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[e&&(0,X.jsx)(am,{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 sm=`flex min-w-0 items-center gap-[5px] text-[12px] font-medium leading-4`,cm=12,lm=cm*22/24;function um({icon:e,children:t,className:n=`text-muted`,evenInk:r=!1}){let i=im(e,r?lm:void 0);return(0,X.jsxs)(`span`,{"data-card-kind":!0,className:`${sm} ${n}`,children:[e&&(0,X.jsx)(e,{ref:i,"aria-hidden":`true`,size:cm,className:`shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0`,children:t})]})}function dm({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)(um,{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 fm({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 pm({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}=nm[e],f=n!=null&&(i??o!=null);return(0,X.jsxs)(`div`,{...l,className:`min-w-0 ${em} border ${c===`question`?`border-question-border bg-question`:`${u} bg-panel-2`} p-4 ${s}`,children:[n==null?(0,X.jsx)(om,{icon:t,label:r,head:d,aside:a}):(0,X.jsx)(dm,{icon:t,kind:n,kindClass:e===`neutral`?`text-muted`:d,label:r,head:e===`neutral`?d:nm.neutral.head,aside:a,ruled:f,evenInk:c===`question`}),o!=null&&(0,X.jsx)(fm,{gap:n==null?`plain`:f?`ruled`:`band`,children:o})]})}var mm=`block min-w-0 text-[13px] leading-5 text-fg/75`;function hm({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 ${tm} ${t}`,children:e})}var gm=`min-w-0 flex-1 text-[11px] leading-snug text-muted-70`,_m=`text-accent underline underline-offset-2 decoration-accent/40 hover:decoration-accent`,vm=`bg-fg px-2.5 py-1 text-bg hover:opacity-90`,ym=`rounded-md`,bm=`flex shrink-0 items-center gap-1 ${ym} text-[11px] font-medium outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${vm}`;function xm(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 Sm=e=>new Promise(t=>setTimeout(t,e));function Cm(e,{retryAfterMs:t=800,wait:n=Sm}={}){let r;return()=>(r??=e().catch(()=>n(t).then(e)).catch(e=>{throw r=void 0,e}),r)}function wm(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function Tm(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function Em(e,t){let n=wm(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function Dm({directive:e,icon:t,title:n,meta:r,children:i}){return(0,X.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${em} 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 Om({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 km({directive:e}){let t=e.attrs,n=wm(t,`display_name`)??wm(t,`skill_name`)??`Artifact template`,r=wm(t,`artifact_kind`),i=wm(t,`skill_name`),a=wm(t,`skill_directory`),[o,s]=(0,q.useState)(!!a);return(0,X.jsxs)(Dm,{directive:e,icon:(0,X.jsx)(rc,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,X.jsx)(Om,{mono:!0,children:i.startsWith(`$`)?i:`$${i}`}),o&&a&&(0,X.jsx)(`img`,{src:go(`${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 Am({directive:e}){let t=e.attrs,n=wm(t,`file`),r=Tm(t,`start`),i=Tm(t,`end`)??r,a=Tm(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,X.jsxs)(Dm,{directive:e,icon:(0,X.jsx)(cc,{size:15}),title:wm(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[wm(t,`body`)&&(0,X.jsx)(Om,{children:wm(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)(Om,{mono:!0,children:o})]})}var jm={"git-stage":[fc,`Changes staged`],"git-commit":[Oe,`Commit created`],"git-create-branch":[ec,`Branch created`],"git-push":[Sc,`Branch pushed`],"git-create-pr":[Ms,`Pull request created`]};function Mm({directive:e}){let[t,n]=jm[e.name],r=wm(e.attrs,`branch`),i=Em(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,X.jsx)(Dm,{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 Nm({directive:e}){let t=wm(e.attrs,`threadId`),n=wm(e.attrs,`pendingWorktreeId`);return(0,X.jsx)(Dm,{directive:e,icon:(0,X.jsx)(dc,{size:15}),title:n?`Thread setup queued`:`Thread created`,meta:(t||n)&&(0,X.jsx)(`span`,{className:`font-mono-keep`,children:t??n})})}function Pm({directive:e}){let t=wm(e.attrs,`reason`);return(0,X.jsx)(Dm,{directive:e,icon:(0,X.jsx)(Bs,{size:15}),title:`Archive suggested`,meta:t})}function Fm(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 Im({directive:e}){let t=e.attrs,n=wm(t,`mode`),r=wm(t,`name`)??`Automation`,i=Fm(t.rrule),a=[r,n,wm(t,`status`),i].filter(Boolean).join(` · `);return(0,X.jsx)(Dm,{directive:e,icon:(0,X.jsx)(Ws,{size:15}),title:`Automation suggested`,meta:a,children:wm(t,`prompt`)&&(0,X.jsx)(Om,{children:wm(t,`prompt`)})})}function Lm({directive:e}){return e.name===`artifact-template`?(0,X.jsx)(km,{directive:e}):e.name===`code-comment`?(0,X.jsx)(Am,{directive:e}):e.name.startsWith(`git-`)?(0,X.jsx)(Mm,{directive:e}):e.name===`created-thread`?(0,X.jsx)(Nm,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,X.jsx)(Pm,{directive:e}):(0,X.jsx)(Im,{directive:e})}var Rm=0,zm=Cm(()=>as(async()=>{let{default:e}=await import(`./mermaid.core-eLZc0PEp.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 Bm(){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 Vm=xm(async e=>{let t=await zm();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 Hm({source:e}){let t=(0,q.useId)(),{resolved:n}=(0,q.useSyncExternalStore)(Lt,bt,bt),[r,i]=(0,q.useState)({}),a=(0,q.useRef)(0),o=Np(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,``)}-${++Rm}`;return Vm.enqueue({id:s,source:e,resolved:n,palette:Bm()}).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:`${em} 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 ${em} 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 ${em} bg-panel-2`})}var Um=e=>e.replace(/\n$/,``);function Wm(e,t){return Qp(e,t,`mermaid`,`md-mermaid`,Um).map(({key:e,host:t,value:n})=>(0,Tc.createPortal)((0,X.jsx)(Hm,{source:n}),t,e))}function Gm(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 Km={scale:1,x:0,y:0},qm=(e,t,n)=>Math.min(Math.max(e,t),n);function Jm(e,t,n,r,i){let a=t*n/2;return 2*a<=i-r?qm(0,r+a,i-a):qm(e,i-a,r+a)}function Ym(e,t){let n=qm(e.scale,1,t.max);return n===1?Km:{scale:n,x:Jm(e.x,t.width,n,t.left,t.right),y:Jm(e.y,t.height,n,t.top,t.bottom)}}function Xm(e,t,n,r){let i=qm(e.scale*t,1,r.max),a=i/e.scale;return Ym({scale:i,x:n.x-(n.x-e.x)*a,y:n.y-(n.y-e.y)*a},r)}function Zm(e,t,n,r){return Ym({scale:e.scale,x:e.x+t,y:e.y+n},r)}function Qm(e,t,n,r,i,a){let o=qm(e.scale*(i/Math.max(n,1)),1,a.max),s=o/e.scale;return Ym({scale:o,x:r.x-(t.x-e.x)*s,y:r.y-(t.y-e.y)*s},a)}function $m(e,t){return qm(t/Math.max(e,1),2,4)}function eh(e,t){return qm(2*t/Math.max(e,1),4,12)}var th=6,nh=420,rh=16/10,ih=.4,ah=3,oh=(e,t,n)=>Math.min(Math.max(e,t),n),sh=e=>oh(e/4,112,180);function ch({entries:e,baseDir:t,framed:n=!0}){let r=Wf(),i=(0,q.useMemo)(()=>t?{...r,dir:t}:r,[r,t]),a=(0,q.useMemo)(()=>e.map(e=>{let t=ze(e.target,i);return{entry:e,path:t,label:Ht(e,t)}}),[e,i]),[o,s]=(0,q.useState)({}),[c,l]=(0,q.useState)({}),[u,d]=(0,q.useState)(null),f=ph(u),p=a.filter(e=>e.path!==null&&!c[e.path]),m=a.filter(e=>!p.includes(e)),h=e=>oh(o[e.path]||rh,ih,ah),g=Gm(p.map(h),f,{gap:th,target:sh(f),maxHeight:nh,maxPerRow:8}),_=a.some(e=>e.entry.caption),v=p.map(e=>Tt(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)(fh,{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)(uh,{tile:t,ratio:h(t),labelled:_,onOpen:()=>xi(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)(fh,{tile:e},t))]});return n?(0,X.jsx)(af,{children:y}):(0,X.jsx)(`div`,{className:sf,children:y})}function lh(e){return{flex:`${e} 1 0%`}}function uh({tile:e,ratio:t,labelled:n,onOpen:r,onShape:i,onBroken:a}){let o=ra(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:lh(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:`${go(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)(dh,{})]}):(0,X.jsx)(`img`,{src:go(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 dh(){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)(pc,{size:14,strokeWidth:Bh,absoluteStrokeWidth:!0,fill:`currentColor`})})}function fh({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 ph(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 mh(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 hh(e,t,n){return Qp(e,t,`lightbox`,`md-lightbox`,ge).map(({key:e,host:t,value:r})=>(0,Tc.createPortal)((0,X.jsx)(ch,{entries:r,baseDir:n}),t,e))}function gh(){let{lightbox:e}=un(W);return e?(0,X.jsx)(Re,{children:(0,X.jsx)(kh,{images:e.images,index:e.index})}):null}var _h={x:0,y:0},vh=e=>({path:e,zoom:Km,pull:_h,animate:!1,max:1/0,panning:!1}),yh={mouse:4,touch:10},bh=48,xh=96,Sh=300,Ch=40,wh=1.5,Th=1.1,Eh=`transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1)`,Dh=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Oh=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function kh({images:e,index:t}){Oo(sr(),!1,ii);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),s=(0,q.useCallback)(e=>{i.current=e,o(e)},[]),c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=e[t],d=u?.path??``,f=ra(d),p=(0,q.useId)(),[m,h]=(0,q.useState)(null),g=mh(m),_=u?.caption?g:0,v=(0,q.useRef)(vh(d)),[y,b]=(0,q.useState)(v.current),x=()=>v.current.path===d?v.current:vh(d),S=e=>{let t={...x(),...e};v.current=t,b(t)},C=y.path===d?y:vh(d),w=(0,q.useRef)(new Map),T=(0,q.useRef)(`mouse`),E=(0,q.useRef)(null),D=(0,q.useRef)(!1),O=(0,q.useRef)(null),k=()=>{let e=c.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},l=t.getBoundingClientRect();return{centre:s,bounds:{width:a,height:o,left:l.left-s.x,right:l.right-s.x,top:l.top-s.y,bottom:l.bottom-s.y,max:eh(a,e.naturalWidth)},detail:$m(a,e.naturalWidth)}},A=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),j=(e,t)=>{let n=k();n&&S({zoom:e(x().zoom,n),animate:t,max:n.bounds.max})},M=e=>j((t,n)=>t.scale>1?Km:Xm(Km,n.detail,A(e,n.centre),n.bounds),!0),N=e=>j((t,n)=>Xm(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(oh(-e.deltaY*t*.01,-.5,.5));j((t,r)=>Xm(t,n,A({x:e.clientX,y:e.clientY},r.centre),r.bounds),!1)}else x().zoom.scale>1&&(e.preventDefault(),j((n,r)=>Zm(n,-e.deltaX*t,-e.deltaY*t,r.bounds),!1))},t=null,n=e=>{e.preventDefault();let n=e;if(e.type===`gesturestart`)t=x().zoom;else if(e.type===`gesturechange`&&t&&w.current.size===0){let e=t;j((t,r)=>Xm(e,n.scale,A({x:n.clientX,y:n.clientY},r.centre),r.bounds),!1)}},r=new ResizeObserver(()=>{x().zoom.scale>1&&j((e,t)=>Ym(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,d]),!u)return null;let P=e.length>1,F=C.zoom.scale>1,L=t=>{let n=!t.ctrlKey&&!t.metaKey&&!t.altKey;if(t.key===`ArrowLeft`)vs(-1);else if(t.key===`ArrowRight`)vs(1);else if(t.key===`Home`)vs(-e.length);else if(t.key===`End`)vs(e.length);else if(n&&(t.key===`+`||t.key===`=`))N(wh);else if(n&&(t.key===`-`||t.key===`_`))N(1/wh);else if(n&&t.key===`0`)S({zoom:Km,animate:!0});else if(n&&t.key===` `&&f&&t.target!==l.current){let e=l.current;e?.paused?e.play().catch(()=>void 0):e?.pause()}else if(t.key===`Escape`)ii();else return;t.preventDefault(),t.stopPropagation()},R=e=>{e.target===e.currentTarget&&ii()},ee=e=>{if(!(e.pointerType===`mouse`&&e.button!==0)&&!e.target.closest(`button, video`)){if(w.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),w.current.size===1)T.current=e.pointerType,D.current=!1,E.current={kind:`press`,id:e.pointerId,x:e.clientX,y:e.clientY};else if(w.current.size===2){let e=k(),[t,n]=[...w.current.values()];D.current=!0,O.current=null,E.current=e?{kind:`pinch`,start:x().zoom,mid:A(Dh(t,n),e.centre),distance:Oh(t,n)}:null,x().pull!==_h&&S({pull:_h,animate:!0})}}},z=n=>{if(!w.current.has(n.pointerId))return;w.current.set(n.pointerId,{x:n.clientX,y:n.clientY});let r=E.current;if(r?.kind===`pinch`){let e=r,[t,n]=[...w.current.values()];j((r,i)=>Qm(e.start,e.mid,e.distance,A(Dh(t,n),i.centre),Oh(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`?yh.mouse:yh.touch))return;if(D.current=!0,O.current=null,x().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(E.current=r,!r)return;i.current?.setPointerCapture(n.pointerId),r.kind===`pan`&&S({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,j((n,r)=>Zm(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;S({pull:r.axis===`x`?{x:o?i/4:i,y:0}:{x:0,y:a},animate:!1})}}},te=e=>{if(!w.current.delete(e.pointerId))return;let t=E.current;if(t?.kind===`pinch`){let[e]=[...w.current.entries()];x().zoom.scale<Th&&S({zoom:Km,animate:!0}),E.current=e&&x().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;E.current=null;let n=e.type===`pointercancel`;if(t.kind===`pan`&&S({panning:!1}),t.kind===`swipe`){let r=e.clientX-t.x,i=e.clientY-t.y;if(S({pull:_h,animate:!0}),n)return;t.axis===`x`&&Math.abs(r)>bh?vs(r<0?1:-1):t.axis===`y`&&Math.abs(i)>xh&&ii();return}if(t.kind===`press`&&!n&&e.pointerType!==`mouse`){let t=O.current;t&&e.timeStamp-t.t<Sh&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<Ch?(O.current=null,D.current=!0,M({x:e.clientX,y:e.clientY})):O.current={t:e.timeStamp,x:e.clientX,y:e.clientY}}},ne=e=>{if(D.current){D.current=!1;return}if(e.target.closest(`button, video, [data-lightbox-caption]`))return;let t=T.current===`mouse`;e.target===c.current?t&&M({x:e.clientX,y:e.clientY}):x().zoom.scale>1?t&&S({zoom:Km,animate:!0}):ii()},B=1-Math.min(Math.abs(C.pull.y)/(xh*3),.6);return(0,X.jsx)(va,{open:!0,onOpenChange:e=>{e||ii()},children:(0,X.jsxs)(yi,{children:[(0,X.jsx)(ni,{className:`overlay-in fixed inset-0 ${Nr} bg-black/95 backdrop-blur-md`,style:{opacity:B}}),(0,X.jsxs)(Wo,{ref:r,"data-lightbox":!0,"aria-modal":`true`,"aria-describedby":u.caption?p:void 0,onEscapeKeyDown:st,onOpenAutoFocus:e=>{e.preventDefault(),r.current?.focus({preventScroll:!0})},onCloseAutoFocus:e=>{e.preventDefault(),n.current?.isConnected&&n.current.focus({preventScroll:!0})},onKeyDown:L,className:`overlay-in fixed inset-0 ${Nr} flex flex-col text-white outline-none`,children:[(0,X.jsxs)(`header`,{onClick:R,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:B},children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(eo,{className:`truncate text-[13px] font-medium leading-5 text-white/90 ${u.titled?``:`font-mono-keep`}`,children:u.label}),(0,X.jsx)(`div`,{className:`truncate font-mono-keep text-[11px] leading-4 text-white/45`,children:u.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:[P&&(0,X.jsxs)(`span`,{"data-lightbox-counter":!0,className:`mr-2.5 text-[12px] tabular-nums text-[#787a7d]`,children:[t+1,` / `,e.length]}),!f&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(zh,{label:`Zoom out`,onClick:()=>N(1/wh),disabled:!F,className:`pointer-coarse:hidden`,children:(0,X.jsx)(wc,{size:14,strokeWidth:2})}),(0,X.jsx)(zh,{label:`Zoom in`,onClick:()=>N(wh),disabled:C.zoom.scale>=C.max-1e-6,className:`pointer-coarse:hidden`,children:(0,X.jsx)(Cc,{size:14,strokeWidth:2})})]}),(0,X.jsx)(zh,{label:`Download`,onClick:()=>Ah(u),children:(0,X.jsx)(Xs,{size:14,strokeWidth:2,className:Rh})}),(0,X.jsx)(zh,{label:f?`Open in default player`:`Open in default viewer`,onClick:()=>I(u.path,!0),children:(0,X.jsx)(Zs,{size:14,strokeWidth:2,className:Rh})}),(0,X.jsx)(zh,{label:`Close`,onClick:ii,children:(0,X.jsx)(sa,{size:15,strokeWidth:2,className:Rh})})]})]}),(0,X.jsxs)(`div`,{ref:s,"data-lightbox-stage":!0,onClick:ne,onPointerDown:ee,onPointerMove:z,onPointerUp:te,onPointerCancel:te,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 ${F?C.panning?`cursor-grabbing`:`cursor-grab`:``}`,style:{touchAction:`none`},children:[f?(0,X.jsx)(Ph,{image:u,view:C,reserve:_,videoRef:l},u.path):(0,X.jsx)(Nh,{image:u,view:C,reserve:_,pictureRef:c},u.path),u.caption&&(0,X.jsx)(`p`,{ref:h,id:p,"data-lightbox-caption":!0,className:`max-w-2xl shrink-0 text-balance pt-3 text-center text-[13px] leading-5 text-white/75 ${F?`pointer-events-none`:``}`,style:{transform:`translate(${C.pull.x}px, ${C.pull.y}px)`,transition:`${C.animate?Eh:`transform 0s`}, opacity 150ms ease-out`,opacity:F?0:B},children:u.caption}),P&&t>0&&(0,X.jsx)(Vh,{side:`left`,onClick:()=>vs(-1)}),P&&t<e.length-1&&(0,X.jsx)(Vh,{side:`right`,onClick:()=>vs(1)})]})]})]})})}function Ah(e){let t=document.createElement(`a`);t.href=go(e.path),t.download=_t(e),document.body.append(t),t.click(),t.remove()}function jh({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 Mh=e=>e?`calc(100% - ${e}px)`:void 0;function Nh({image:e,view:t,reserve:n,pictureRef:r}){let[i,a]=(0,q.useState)(!1);if(i)return(0,X.jsx)(jh,{what:`Image`,path:e.path});let{scale:o,x:s,y:c}=t.zoom;return(0,X.jsx)(`img`,{ref:r,src:go(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:Mh(n),transform:`translate(${s+t.pull.x}px, ${c+t.pull.y}px) scale(${o})`,transition:t.animate?Eh:`none`,borderRadius:6/o,boxShadow:`0 0 0 ${1/o}px rgb(255 255 255 / 0.1)`}})}function Ph({image:e,view:t,reserve:n,videoRef:r}){let[i,a]=(0,q.useState)(!1);return i?(0,X.jsx)(jh,{what:`Video`,path:e.path}):(0,X.jsx)(`video`,{ref:r,src:go(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:Mh(n),transform:`translate(${t.pull.x}px, ${t.pull.y}px)`,transition:t.animate?Eh:`none`,boxShadow:`0 0 0 1px rgb(255 255 255 / 0.1)`}})}var Fh=`icon-focus-outline text-[#787a7d] transition-colors hover:bg-white/[0.04] hover:text-[#e6e7e9]`,Ih=`cursor-default text-[#303132]`,Lh=`pointer-coarse:size-11 pointer-coarse:rounded-full pointer-coarse:text-[#cfd0d2]`,Rh=`pointer-coarse:size-[21px] pointer-coarse:[stroke-width:2.1]`;function zh({label:e,onClick:t,disabled:n,className:r=``,children:i}){return(0,X.jsx)(me,{label:e,side:`bottom`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":e,"aria-disabled":n||void 0,onClick:()=>{n||t()},className:`${Wt} focus-visible:ring-1 focus-visible:ring-white/60 ${n?Ih:Fh} ${Lh} ${r}`,children:i})})}var Bh=1.5;function Vh({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`?Gs:Kt,{size:20,strokeWidth:Bh,absoluteStrokeWidth:!0})})}function Hh({as:e=`div`,className:t,html:n}){let r=Np(n),i=(0,q.useRef)(null);Xp(i,n);let a=hh(i,n),o=Wm(i,n);return(0,X.jsxs)(X.Fragment,{children:[(0,q.createElement)(e,{ref:i,className:t,dangerouslySetInnerHTML:r}),a,o]})}function Uh({text:e,language:t,className:n=``,...r}){let i=Np((0,q.useMemo)(()=>cd(e,t),[e,t]));return(0,X.jsx)(`pre`,{...r,className:`hljs ${n}`,dangerouslySetInnerHTML:i})}var Wh=`Todos`,Gh={pending:{Icon:xc,className:`text-muted-50`},in_progress:{Icon:yc,className:`text-accent`},completed:{Icon:vc,className:`text-muted-75`}},Kh={pending:`text-fg/75`,in_progress:`text-fg`,completed:`text-muted-70`};function qh({status:e}){let{Icon:t,className:n}=Gh[e];return(0,X.jsx)(t,{"aria-hidden":`true`,size:`1em`,strokeWidth:2,className:`frizz-todo-mark shrink-0 ${n}`})}var Jh={pending:`to do`,in_progress:`in progress`,completed:`done`};function Yh({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`} `:``}${Wh}${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:yp,children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:Wh}),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)(qh,{status:`in_progress`}),(0,X.jsx)(`span`,{className:`frizz-tool-detail`,children:d})]})]}),(0,X.jsxs)(`span`,{className:bp,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)(Op,{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)(qh,{status:e.status}),(0,X.jsx)(`span`,{className:`min-w-0 ${Kh[e.status]}`,children:e.text}),(0,X.jsx)(`span`,{className:`sr-only`,children:` — ${Jh[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 Xh=/^```question(?:[ \t]+([A-Za-z][^\r\n]*?))?[ \t]*\r?\n(?:([\s\S]*?)\r?\n)??```[ \t]*$/gm,Zh=/^qst_[a-z0-9]+$/;function Qh(e){let t=(e??``).toLowerCase().split(/\s+/).filter(Boolean),n=e=>t.includes(e),r=t.find(e=>Zh.test(e));return{kind:n(`multi`)?`multi`:`question`,danger:n(`danger`),...r?{registeredId:r}:{}}}function $h(e){let t=[],n=xr(e),r=0;Xh.lastIndex=0;for(let i=Xh.exec(e);i!==null;i=Xh.exec(e)){if(n(i.index)){Xh.lastIndex=i.index+1;continue}let{kind:a,danger:o,registeredId:s}=Qh(i[1]);if(i[2]===void 0&&!s){Xh.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}),og(t)}function eg(e,t,n){if(!t||!Zo(e))return $h(e);let r=Ea(e).filter(e=>e.read.form!==`invalid`||rg(e.body));if(r.length===0)return $h(e);let i=[],a=0;for(let t of r){if(i.push(...$h(e.slice(a,t.start))),a=t.end,t.read.form===`ref`&&tg(t.read,n)){i.push({kind:`refusedRef`,id:t.read.id});continue}if(t.read.form===`ask`&&tg(t.read,n)){i.push({kind:`refusedAsk`,id:t.read.id,spec:t.read.spec});continue}if(t.read.form===`invalid`){let n=Fi(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(...$h(e.slice(a))),i}function tg(e,t){return t!==void 0&&t.size>0&&t.has(e.id.toLowerCase())}var ng=RegExp(`^[ \\t]*(?:${$a.join(`|`)}):(?:[ \\t]|$)`);function rg(e){let t=e.split(/\r?\n/).find(e=>e.trim()!==``);return t!==void 0&&ng.test(t)}function ig(e,t){if(!Zo(e))return[];let n=[];for(let r of Ea(e)){let e=r.read;e.form===`invalid`||tg(e,t)||(e.form===`ref`||e.form===`ask`&&!e.when)&&n.push(e.id.toLowerCase())}for(let r of ag(e,t))n.includes(r)||n.push(r);return n}function ag(e,t){if(!Zo(e)||!e.includes(`when:`))return[];let n=Ea(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||tg(e,t))continue;let n=e.when.parent.toLowerCase();!r.has(n)&&!i.includes(n)&&i.push(n)}return i}function og(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=vg(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=Cg(i.options[i.options.length-1]);if(!/^([A-Z]|\d+)$/.test(e))continue;a=e}let o=sg(r.text,a);o!==null&&(e[t]={...n,text:n.text.replace(/\s+$/,``)+`
94
94
 
95
95
  `+o.run},o.rest.trim()?e[t+1]={kind:`prose`,text:o.rest}:e.splice(t+1,1))}return e}function sg(e,t){let n=e.split(`
96
96
  `).map(e=>e.replace(/\r$/,``)),r=0;for(;r<n.length&&n[r].trim()===``;)r++;if(r>=n.length||!lg.test(n[r]))return null;let i=fg(n[r]);if(t===null?!mg(i):!pg(t,i))return null;let a=r,o=i;for(let e=r+1;e<n.length;e++){let t=n[e];if(lg.test(t)){if(!pg(o,fg(t)))break;o=fg(t),a=e;continue}if(t.trim()===``)continue;if(ug.test(t)){a=e;break}let r=n.findIndex((t,n)=>n>e&&lg.test(t));if(r===-1||!pg(o,fg(n[r])))break}let s=n.slice(r,a+1);return s.filter(e=>lg.test(e)).length<(t===null?2:1)?null:{run:s.join(`
@@ -99,7 +99,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
99
99
  `).map(e=>e.replace(/\r$/,``)),i=e=>r.findIndex((t,n)=>n>e&&lg.test(t)),a=e=>{let t=[];for(let n=e;n<r.length;n++){if(lg.test(r[n])){t.push(n);continue}if(t.length===0||r[n].trim()===``)continue;if(ug.test(r[n]))break;let e=i(n);if(e===-1||!pg(fg(r[t[t.length-1]]),fg(r[e])))break}return t},o=e=>{for(let t=e.length-1;t>0;t--)if(!pg(fg(r[e[t-1]]),fg(r[e[t]])))return mg(fg(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}=_g(dg(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
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
101
  `),g,_=[];for(let e of r.slice(l+1))g===void 0&&ug.test(e)?g=e.trim():_.push(e);let v=m(_).join(`
102
- `)||void 0;if(d.length===0&&g){let e=bg(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 yg=/^[*_`~\s]+/;function bg(e,t){if(!e)return null;let n=e.replace(/^\s*recommendation\s*:?\s*/i,``).replace(yg,``).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(yg,``).match(/^([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase()===r:!1});return i===-1?null:i}function xg(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 Sg(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 Cg(e){let t=e.match(/^\s*([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase():e.trim()}function wg(e,t){let n=t.text.trim();if(e.kind===`multi`){let r=(t.chosenSet??[]).slice().sort((e,t)=>e-t).map(t=>Cg(e.options[t]??``)).filter(Boolean).join(`, `);return r&&n?`${r} — ${n}`:r||n}return t.chosen==null?n:e.options[t.chosen]??``}function Tg(e,t){return t===`done`?Wi(e):_o(e)}function Eg(e){let t=vi(e);if(!t)return e.trim()?[{kind:`prose`,text:e}]:[];let n=[],r=``,i=0;for(let a of ti(e).filter(e=>e.start<=t.start)){r+=e.slice(i,a.start),i=a.end;let{body:o,hints:s}=Tg(a.raw,a.kind);if(a.start!==t.start){let e=a.kind===`awaiting`?rs(o)??``:o;e.trim()&&(r+=`\n\n${e}\n\n`);continue}r.trim()&&n.push({kind:`prose`,text:r}),r=``,n.push({kind:`fence`,fenceKind:a.kind,body:o,hints:s})}return r+=e.slice(i),r.trim()&&n.push({kind:`prose`,text:r}),n}function Dg(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`)&&Eg(t.text).some(e=>e.kind===`fence`&&e.fenceKind===`awaiting`&&ds(e.hints)))return n}return-1}function Og(e,t){let n=e?.lastFence;return!(!n||n.kind!==`done`||n.registered!==!0||t&&Eg(t).some(e=>e.kind===`fence`&&e.fenceKind===`done`))}var kg=(e,t)=>[`registeredDone`,e,t.bodyElided??-1,t.body];function Ag(e){return e?.kind===`done`&&e.registered===!0&&e.bodyElided!==void 0}function jg(e,t){return e!==void 0&&e.length===t.bodyElided&&Uo(e)===t.body}function Mg(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=Ag(t)?t:void 0,a=i&&r.current?.slug===n&&jg(r.current.body,i)?r.current.body:void 0,o=R(),s=H({queryKey:i?kg(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(kg(n,i))===void 0&&o.setQueryData(kg(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 Ng(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||te(e)||e.answersInFlight||e.operatorStopped||e.pendingAsk||e.pendingInteraction||e.awaitingBackground||e.limitPause||e.providerFault||!e.lastAssistantAt||t===void 0||Eg(t).some(e=>e.kind===`fence`))return!1;if(!c(e.spawnedAt)){let r=new Set((e.questions??[]).flatMap(e=>Ei(e.spec).map(e=>e.toLowerCase()))),i=(e.closedQuestions??[]).filter(e=>!r.has(e.handle.toLowerCase()));return!eg(t,!0,i.length===0?n:new Set([...n??[],...i.map(e=>e.handle.toLowerCase())])).some(e=>e.kind===`question`)}return!cg(t)}function Pg({thread:e}){return e.crashed===!0?(0,X.jsx)(pm,{"data-rested-card":`stalled`,icon:d,label:`Stalled`,children:(0,X.jsx)(`p`,{className:mm,children:`The agent's process exited mid-turn. Retry, in the header, re-sends the last message.`})}):(0,X.jsx)(pm,{"data-rested-card":`bare`,icon:Xn,label:`Rested without a sign-off`,children:(0,X.jsx)(`p`,{className:mm,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 Fg(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 Ig({error:e,provider:t}){return(0,X.jsxs)(pm,{"data-codex-error":e.code??`unknown`,tone:e.retrying?`caution`:`danger`,icon:d,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:`${mm} 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 Lg=e=>Fa(e.replace(/\r\n?/g,`
102
+ `)||void 0;if(d.length===0&&g){let e=bg(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 yg=/^[*_`~\s]+/;function bg(e,t){if(!e)return null;let n=e.replace(/^\s*recommendation\s*:?\s*/i,``).replace(yg,``).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(yg,``).match(/^([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase()===r:!1});return i===-1?null:i}function xg(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 Sg(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 Cg(e){let t=e.match(/^\s*([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase():e.trim()}function wg(e,t){let n=t.text.trim();if(e.kind===`multi`){let r=(t.chosenSet??[]).slice().sort((e,t)=>e-t).map(t=>Cg(e.options[t]??``)).filter(Boolean).join(`, `);return r&&n?`${r} — ${n}`:r||n}return t.chosen==null?n:e.options[t.chosen]??``}function Tg(e,t){return t===`done`?Wi(e):_o(e)}function Eg(e){let t=vi(e);if(!t)return e.trim()?[{kind:`prose`,text:e}]:[];let n=[],r=``,i=0;for(let a of ti(e).filter(e=>e.start<=t.start)){r+=e.slice(i,a.start),i=a.end;let{body:o,hints:s}=Tg(a.raw,a.kind);if(a.start!==t.start){let e=a.kind===`awaiting`?rs(o)??``:o;e.trim()&&(r+=`\n\n${e}\n\n`);continue}r.trim()&&n.push({kind:`prose`,text:r}),r=``,n.push({kind:`fence`,fenceKind:a.kind,body:o,hints:s})}return r+=e.slice(i),r.trim()&&n.push({kind:`prose`,text:r}),n}function Dg(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`)&&Eg(t.text).some(e=>e.kind===`fence`&&e.fenceKind===`awaiting`&&ds(e.hints)))return n}return-1}function Og(e,t){let n=e?.lastFence;return!(!n||n.kind!==`done`||n.registered!==!0||t&&Eg(t).some(e=>e.kind===`fence`&&e.fenceKind===`done`))}var kg=(e,t)=>[`registeredDone`,e,t.bodyElided??-1,t.body];function Ag(e){return e?.kind===`done`&&e.registered===!0&&e.bodyElided!==void 0}function jg(e,t){return e!==void 0&&e.length===t.bodyElided&&Uo(e)===t.body}function Mg(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=Ag(t)?t:void 0,a=i&&r.current?.slug===n&&jg(r.current.body,i)?r.current.body:void 0,o=R(),s=H({queryKey:i?kg(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(kg(n,i))===void 0&&o.setQueryData(kg(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 Ng(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||B(e)||e.answersInFlight||e.operatorStopped||e.pendingAsk||e.pendingInteraction||e.awaitingBackground||e.limitPause||e.providerFault||!e.lastAssistantAt||t===void 0||Eg(t).some(e=>e.kind===`fence`))return!1;if(!c(e.spawnedAt)){let r=new Set((e.questions??[]).flatMap(e=>Ei(e.spec).map(e=>e.toLowerCase()))),i=(e.closedQuestions??[]).filter(e=>!r.has(e.handle.toLowerCase()));return!eg(t,!0,i.length===0?n:new Set([...n??[],...i.map(e=>e.handle.toLowerCase())])).some(e=>e.kind===`question`)}return!cg(t)}function Pg({thread:e}){return e.crashed===!0?(0,X.jsx)(pm,{"data-rested-card":`stalled`,icon:d,label:`Stalled`,children:(0,X.jsx)(`p`,{className:mm,children:`The agent's process exited mid-turn. Retry, in the header, re-sends the last message.`})}):(0,X.jsx)(pm,{"data-rested-card":`bare`,icon:Xn,label:`Rested without a sign-off`,children:(0,X.jsx)(`p`,{className:mm,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 Fg(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 Ig({error:e,provider:t}){return(0,X.jsxs)(pm,{"data-codex-error":e.code??`unknown`,tone:e.retrying?`caution`:`danger`,icon:d,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:`${mm} 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 Lg=e=>Fa(e.replace(/\r\n?/g,`
103
103
  `)).answers;function Rg(e){return!e||Kg(e)===null?``:Fa(e.replace(/\r\n?/g,`
104
104
  `)).note}var zg=/^(\d+)\.\s+(.*)$/;function Bg(e,t){let n=t.startsWith(` `)?t.slice(2):t;e.answer=e.answer?`${e.answer}\n${n}`:n}function Vg(e){if(!e)return null;let t=Lg(e).split(`
105
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)Bg(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 Hg=Ya,Ug=RegExp(`^(\\d+)\\.\\s+(⤷\\s+)?(?:\`(${Fr})\`\\s+)?[“"]`),Wg=/[”"]\s+→\s+/;function Gg(e){if(!e)return null;let t=Lg(e).split(`
@@ -120,24 +120,24 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
120
120
  `):t);return!b&&!v&&!y?(0,X.jsx)(`div`,{"data-frizz-msg":n,"data-frizz-wake":!0,className:`min-w-0 max-w-[85%]`,children:(0,X.jsx)(pm,{icon:Hs,label:`Frizz`,children:(0,X.jsx)(nb,{text:Ar(t)})})}):v||y?(0,X.jsxs)(`div`,{"data-frizz-wake":!0,className:`flex flex-col`,children:[v&&(0,X.jsx)(_b,{wake:v,sourceId:n,at:r}),y&&(0,X.jsxs)(X.Fragment,{children:[v&&(0,X.jsx)(Zy,{}),(0,X.jsx)(vb,{wake:y,sourceId:v?void 0:n,at:r})]}),b&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Zy,{}),(0,X.jsx)(yb,{steer:b,text:t,at:r})]})]}):(0,X.jsx)(yb,{steer:b,text:t,sourceId:n,at:r})}function tb({parts:e,sourceId:t,at:n}){let r=e.map(e=>Ar(e.body)).filter(e=>!vt(e)&&!ia(e));return r.length?(0,X.jsx)(`div`,{"data-frizz-wake":`merged`,className:`flex flex-col`,children:r.map((e,r)=>(0,X.jsxs)(q.Fragment,{children:[r>0&&(0,X.jsx)(Zy,{}),(0,X.jsx)(eb,{text:e,sourceId:r===0?t:void 0,at:n})]},r))}):null}function nb({text:e}){let t=Gf(e),n=Np(t),r=(0,q.useRef)(null),i=Wm(r,t);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{ref:r,className:`md-body [overflow-wrap:anywhere]`,dangerouslySetInnerHTML:n}),i]})}function rb({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:Ra,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)(Ky,{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 ib({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:sc,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:Uy,children:i})]})})}function ab({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:Uy,children:s})]});return e.items.length?(0,X.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,X.jsxs)(Q,{icon:at,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)(Ky,{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
121
  `)})]}):(0,X.jsx)(Q,{icon:at,sourceId:t,marker:`event`,ariaLabel:`${o}${s}`,at:n,children:c})}function ob({watchRef:e,sentence:t=`Watcher expired`,sourceId:n,at:r}){let i=Ur(e);return(0,X.jsx)(Q,{icon:en,sourceId:n,marker:`event`,ariaLabel:`${t} on ${e}`,at:r,children:(0,X.jsx)(sb,{sentence:t,children:i?(0,X.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:$y,children:(0,X.jsx)(lb,{value:e})}):(0,X.jsx)(lb,{value:e})})})}function sb({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)(cb,{}),` `,t]})]})}function cb(){return(0,X.jsx)(`span`,{className:Uy,children:` on`})}function lb({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:Uy,children:e.slice(0,t)}),e.slice(t)]})}function ub({kind:e,sourceId:t,at:n}){let r=` on a ${e===`agent`?`sub-agent`:`background shell`}`;return(0,X.jsx)(Q,{icon:e===`agent`?Us:bc,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:Uy,children:r})]})})}function db({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:xt,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 ${Wy}`,children:`${o.charAt(0).toUpperCase()}${o.slice(1)}`}),(0,X.jsx)(`span`,{className:`flex min-w-0 items-center gap-1 ${Uy}`,children:(0,X.jsx)(qy,{lead:`Monitor`,title:yy(e.command),tail:e.kind===`cancelled`?`stopped by Frizz`:o})}),(0,X.jsx)(Ky,{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 fb({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:Rt,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 ${Wy}`,children:s}),(0,X.jsx)(`span`,{className:`flex min-w-0 items-center gap-1 ${Uy}`,children:(0,X.jsx)(qy,{lead:`Monitor`,title:e.label??yy(e.command??e.id),tail:c})}),(0,X.jsx)(Ky,{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 pb({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)(Zy,{}),(0,X.jsx)(Q,{icon:Us,marker:`event`,ariaLabel:`Sub-agent ${e.label} stopped by the interrupt`,at:n,children:(0,X.jsx)(qy,{lead:`Sub-agent`,title:e.label,tail:`stopped`,note:`by the interrupt`})})]},t))})}function mb({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:at,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:Uy,children:` usage`}),` limit`]}):r,` reset`,(0,X.jsx)(`span`,{className:Uy,children:` — resuming`})]})})}function hb({capped:e,to:t,sourceId:n,at:r}){return(0,X.jsx)(Q,{icon:at,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:Uy,children:` limit — switched to `}),(0,X.jsx)(`span`,{className:Wy,children:` → `}),t]})})}function gb({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:bc,sourceId:t,marker:`event`,ariaLabel:`Background task «${r}» ${e.outcome}`,at:n,children:(0,X.jsx)(qy,{lead:`Background task`,title:r,tail:e.outcome})})}function _b({wake:e,sourceId:t,at:n}){let r=Ur(e.ref),i=r?(0,X.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:$y,children:(0,X.jsx)(lb,{value:e.ref})}):(0,X.jsx)(`span`,{children:(0,X.jsx)(lb,{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:en,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)(cb,{}),` `,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 vb({wake:e,sourceId:t,at:n}){let r=Ur(e.ref),i=r?(0,X.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:$y,children:(0,X.jsx)(lb,{value:e.ref})}):(0,X.jsx)(`span`,{children:(0,X.jsx)(lb,{value:e.ref})});return(0,X.jsx)(Q,{icon:en,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)(cb,{}),` `,i,`: ${e.detail}`]})})}function yb({steer:e,text:t,sourceId:n,at:r}){let i=Ur(e.ref),a=e.items.length+e.omitted,o=_(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`:Qy(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:$y,children:(0,X.jsx)(lb,{value:e.ref})}):(0,X.jsx)(`span`,{children:(0,X.jsx)(lb,{value:e.ref})});return(0,X.jsx)(Q,{icon:en,sourceId:n,marker:`github`,at:s?.at??r,ariaLabel:c?void 0:`${l} on ${e.ref}`,children:(0,X.jsx)(sb,{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 bb=/(^|[^\w/.@-])(https?:\/\/[^\s<>`]+|www\.[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:[^\s<>`]*)?)/gi,xb=new Set([`.`,`,`,`:`,`;`,`!`,`?`,`*`,`_`,`~`,`'`,`"`]),Sb={")":`(`,"]":`[`,"}":`{`};function Cb(e){let t=e;for(;;){let e=t[t.length-1];if(e!==void 0&&xb.has(e)){t=t.slice(0,-1);continue}let n=e===void 0?void 0:Sb[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 wb(e,t,n){if(t===``)return;let r=0;for(let i of je(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:Fs(i.href)}),r=i.start+i.text.length;r<t.length&&e.push({kind:`text`,text:t.slice(r)})}function Tb(e,t){let n=[],r=0;bb.lastIndex=0;for(let i=bb.exec(e);i;i=bb.exec(e)){let[,a,o]=i,s=Cb(o);if(/^https?:\/\/$/i.test(s)||s===``)continue;let c=i.index+a.length;bb.lastIndex=c+s.length;let l=/^www\./i.test(s)?`http://${s}`:s;c>r&&wb(n,e.slice(r,c),t),n.push({kind:`link`,text:s,href:l,ghRef:Fs(l)}),r=c+s.length}return r<e.length&&wb(n,e.slice(r),t),n}function Eb({text:e}){let t=Uf(),n=(0,q.useMemo)(()=>Tb(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&&he(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 Db({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 ${em} rounded-br-sm border border-border-strong bg-elevated p-4`,children:[(0,X.jsx)(om,{icon:ic,label:`Answers`}),(0,X.jsx)(fm,{children:(0,X.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:qg(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)(kb,{answer:e.answer})]})]},t))})})]})})}var Ob=`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 kb({answer:e}){let{picks:t,note:n}=Yg(e);return t.length===0?(0,X.jsx)(`span`,{className:`${Ob} flex-1 whitespace-pre-wrap`,children:(0,X.jsx)(Eb,{text:e})}):(0,X.jsxs)(`div`,{className:`${Ob} 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)(fi,{size:10,strokeWidth:3})}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Eb,{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)(Eb,{text:n})})]})}function Ab(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`&&e[t].kind!==`event`)return t;return-1}function jb(e){return e.sourceId??`legacy-${Bb(e.text)}`}function Mb(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 Nb=e=>$h(e).filter(e=>e.kind===`question`).map(e=>e.kind===`question`?vg(e.text,e.questionKind,e.danger):vg(``,`question`));function Pb(){let e=new Set;return(t,n)=>{let r=jb(t);return e.has(r)&&(r=`${r}#${n}`),e.add(r),r}}function Fb(e){let t=Mb(e),n=Pb(),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=Nb(a.text);o.length>0&&r.push({idx:i,identity:n(a,i),blocks:o,isLive:i===t})}return r}function Ib(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}. ${Ft(t)}`).join(`
122
122
  `)}`:`${Ya}\n${t.map((e,t)=>`${t+1}. “${e.question}” → ${Ft(e.answer)}`).join(`
123
- `)}`}function Lb(e,t,n,r={}){let i=F(e),[a,o]=(0,q.useState)({}),s=(0,q.useMemo)(()=>Fb(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=B(),u=Mt(e),d=(0,q.useCallback)((t,n)=>fn.answer(l,e,u,t,n),[l,e,u]),f=(0,q.useMemo)(()=>s.flatMap(e=>e.blocks.map((t,n)=>d(e.identity,n))),[s,d]),p=oe(f),m=(0,q.useRef)(n);m.current=n;let h=(0,q.useRef)(r.onSendFailed);h.current=r.onSendFailed;let g=(0,q.useCallback)((e,t)=>({...a[`${e}::${t}`]??{chosen:null,text:``},text:p.get(d(e,t))??``}),[a,p,d]),_=(0,q.useMemo)(()=>{let e=new Map;for(let t of s)e.set(t.identity,t);return e},[s]),v=(0,q.useCallback)((e,t,n)=>{let r=_.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}}})},[_]),y=(0,q.useCallback)((e,t,n)=>{let r=_.get(e)?.blocks[t];j.set(d(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}}})},[_,d]),b=s.reduce((e,t)=>e+t.blocks.filter((e,n)=>wg(e,g(t.identity,n))!==``).length,0),x=b>0,S=(0,q.useCallback)((e,t={})=>{i.submit(e,{...t,onRollback:e=>{t.onRollback?.(e),h.current?.()}})&&m.current?.()},[i]),C=(0,q.useCallback)(e=>{let t=e?s.filter(t=>t.identity===e):s,n=e?t.flatMap(e=>e.blocks.map((t,n)=>d(e.identity,n))):f,r=t.flatMap(e=>e.blocks.map((t,n)=>`${e.identity}::${n}`)),i=(e,t)=>wg(e.blocks[t],g(e.identity,t)),c=t.flatMap(e=>e.blocks.map((t,n)=>({ask:e,bi:n,question:zb(t),answer:i(e,n)})).filter(e=>e.answer!==``));if(c.length===0)return null;let l=t.find(e=>e.isLive),u=Ib({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!==``)}}),p=a,m=n.map(e=>[e,j.get(e)]);return{wire:u,onOptimistic:()=>{n.forEach(e=>j.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)p[e]?t[e]=p[e]:delete t[e];return t}),m.forEach(([e,t])=>{t&&!j.get(e)&&j.set(e,t)})}}},[a,s,g,f,d]),w=(0,q.useCallback)(()=>C(),[C]),T=r.composer,E=(0,q.useCallback)(e=>{if(T?.run())return;let t=C(typeof e==`string`?e:void 0);t&&S(t.wire,{onOptimistic:t.onOptimistic,onRollback:t.onRollback})},[T,C,S]),D=(0,q.useCallback)(e=>{let t=_.get(jb(e));if(t)return{answerFor:e=>g(t.identity,e),onChip:(e,n)=>v(t.identity,e,n),onText:(e,n)=>y(t.identity,e,n),onSubmit:()=>E(t.identity),anyAnswered:t.blocks.some((e,n)=>wg(e,g(t.identity,n))!==``),sending:i.pending}},[_,g,v,y,E,i.pending]);return{liveMsg:c,answering:(0,q.useMemo)(()=>c?D(c):void 0,[c,D]),answeringForMessage:D,anyAnswered:x,sending:i.pending,sendAnswers:E,sendMessage:S,stagedCount:b,takeAnswers:w}}function Rb(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 zb(e){return Rb(e.contextMd)||Rb(e.options.join(` / `))||`earlier question`}function Bb(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 Vb(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 Hb(e,t,n){if(n.length===0)return{agents:e,key:void 0};let{launched:r,finished:i}=Vb(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 Ub(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}:Hb(a,n.current,t),s=o.key;(0,q.useEffect)(()=>{if(s===void 0)return;let e=setTimeout(()=>i(s),Qo);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 Wb(e,t,n){return e===t||n(e,t)?e:t}function Gb(e,t){let n=(0,q.useRef)(e);return n.current=t(n.current,e),n.current}function Kb(e,t){return Gb(e,(e,n)=>Wb(e,n,t))}function qb(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 Jb(e,t){return qb(e,t,Xb)}function Yb(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 Xb(e,t){return!e||!t?e===t:e.length===t.length&&e.every((e,n)=>Object.is(e,t[n]))}function Zb(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!Jo(n))return n.kind===`event`&&n.boundary===`rest`?n.sourceId??`rest@${n.at??t}`:void 0}}function Qb(e,t,n){if(!e||e.runtime!==`running`&&e.runtime!==`spawning`)return;let r=Zb(t);return r!==void 0&&r!==n?r:void 0}function $b(e,t){let n=(0,q.useRef)(null),[r,i]=(0,q.useState)(void 0),a=n.current&&n.current.messages.length>0?Qb(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:Zb(o)})},[o]),o}function ex(e,t,n=!0){return e.held>0&&n?`release`:e.steered>0&&t?`interrupt`:null}function tx(e){if(!e)return!1;let t=ls(W.board,e);return Hr(t?.backend).interrupt&&t?.runtime===`running`}function nx(e){return Hr(e?ls(W.board,e)?.backend:void 0).steer}function rx(e){return(0,q.useSyncExternalStore)(e=>os(W,e),()=>nx(e),()=>!0)}function ix(e){return(0,q.useSyncExternalStore)(e=>os(W,e),()=>tx(e),()=>!1)}var ax=new Set,ox=new Set;function sx(e,t){if(t!==ax.has(e)){t?ax.add(e):ax.delete(e);for(let e of ox)e()}}function cx(e){return(0,q.useSyncExternalStore)((0,q.useCallback)(e=>(ox.add(e),()=>ox.delete(e)),[]),()=>e?ax.has(e):!1,()=>!1)}function lx(e,t){let n=ex(t,tx(e),nx(e));if(!n)return!1;if(ax.has(e))return!0;let r=ls(W.board,e)?.sessionId;if(!r)return G(`This thread has no live session to send to`),!0;sx(e,!0);let i=n===`release`;return U.deliverQueuedNow({slug:e,sessionId:r,...i?{releaseOnly:!0}:{}}).then(t=>{sx(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=>{sx(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 ux=`input, textarea, select, [contenteditable]:not([contenteditable='false'])`;function dx(e,t){if(e.defaultPrevented||e.repeat||!Tr(e))return!1;let n=e.target;if(!(n instanceof Element)||!t.contains(n))return!1;let r=n.closest(ux);return r?r instanceof HTMLTextAreaElement&&r.closest(`[data-thread-composer-box]`)!==null&&r.value.trim()===``:!0}var fx=new Set;function px(e){if(e.defaultPrevented||e.repeat||!Tr(e))return;let t=document.activeElement;if(t&&t!==document.body&&t!==document.documentElement)return;let n=[...fx],r=xn();(r?n.find(e=>e.slug===r):new Set(n.map(e=>e.slug)).size===1?n[0]:void 0)?.press()&&e.preventDefault()}function mx(e,t){let n=(0,q.useRef)(t);return n.current=t,(0,q.useEffect)(()=>{let t={slug:e,press:()=>lx(e,n.current)};return fx.size===0&&window.addEventListener(`keydown`,px),fx.add(t),()=>{fx.delete(t),fx.size===0&&window.removeEventListener(`keydown`,px)}},[e]),(0,q.useCallback)(t=>{dx(t.nativeEvent,t.currentTarget)&&lx(e,n.current)&&t.preventDefault()},[e])}function hx(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 gx(e,t){let n=t;for(;n>0&&e[n].kind===`event`;)n--;return n}function _x(e){let t=e.findIndex(e=>e.queued===!0);return t<0?e.length:t}function vx(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)?hx(e,i):_x(e);if(s===0)continue;let c=e.slice(0,s),l=k_(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 h_(c,u))e<0||a(r,gx(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 yx=e=>e.role===`user`&&!e.queued,bx=e=>e.wake===!0&&e.text.trimStart().startsWith(`**This message is from frizz, not from the human.**`);function xx(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&&!yx(e[i]);)i--;if(i<=t||!bx(e[i]))break;let a=i-1;for(;a>t&&e[a].signOff!==!0&&!yx(e[a]);)a--;if(a<=t||e[a].signOff!==!0)break;r.push(a),n=a}return r.reverse()}function Sx(e){return e.status===`pending`&&e.backgroundState===`background`}function Cx(e){let t=[];for(let n of e)for(let e of n.tools)Sx(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 wx(e){return e.map(e=>{if(!e.tools.some(Sx))return e;let t=e.tools.filter(e=>!Sx(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!Sx(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}var Tx=2e3;function Ex(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&&Zo(a.text)){r??=w_(e);for(let e of Ea(a.text))if(e.read.form!==`invalid`&&r.includes(e.read.id.toLowerCase()))return!1}if(Number.isFinite(o))break}return!0}function Dx(e,t,n,r){let i,a=new Set;for(let o of e){if(!Ex(o,t)){n.delete(o.id);continue}let e=n.get(o.id)??r;n.set(o.id,e);let s=e+Tx;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 Ox(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 kx(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&&Zo(r))for(let e of Ea(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=Ox(e,Date.parse(i.at));if(o<0||!a(o).has(t)||n.some(n=>w_(n).includes(t)&&Ox(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 Ax=new WeakMap;function jx(e,t,n=[]){let r=kx(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=Ax.get(e);if(a?.key===i)return a.message;let o={...e,refusedFences:new Set(n.keys()),refusedReasons:n};return Ax.set(e,{key:i,message:o}),o})}function Mx(e){return e?.length?e.map(e=>`${e.at}|${e.id??``}|${e.faults.join(`\0`)}`).join(`
126
- `):``}function Nx(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 Px(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 w_(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:Ox(e,Date.parse(t.askedAt))})).sort((e,t)=>e.askedMs-t.askedMs)}));return e.forEach((e,t)=>{if(e.role!==`assistant`||!e.text||!(Zo(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 Fx=new WeakMap;function Ix(e,t){let n=Px(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=Fx.get(e);if(a?.key===i)return a.message;let o={...e,questionOwners:r};return Fx.set(e,{key:i,message:o}),o})}function Lx(e,t){let n=t.description?.trim(),r=n&&!n.includes(`
123
+ `)}`}function Lb(e,t,n,r={}){let i=F(e),[a,o]=(0,q.useState)({}),s=(0,q.useMemo)(()=>Fb(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=z(),u=Mt(e),d=(0,q.useCallback)((t,n)=>fn.answer(l,e,u,t,n),[l,e,u]),f=(0,q.useMemo)(()=>s.flatMap(e=>e.blocks.map((t,n)=>d(e.identity,n))),[s,d]),p=oe(f),m=(0,q.useRef)(n);m.current=n;let h=(0,q.useRef)(r.onSendFailed);h.current=r.onSendFailed;let g=(0,q.useCallback)((e,t)=>({...a[`${e}::${t}`]??{chosen:null,text:``},text:p.get(d(e,t))??``}),[a,p,d]),_=(0,q.useMemo)(()=>{let e=new Map;for(let t of s)e.set(t.identity,t);return e},[s]),v=(0,q.useCallback)((e,t,n)=>{let r=_.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}}})},[_]),y=(0,q.useCallback)((e,t,n)=>{let r=_.get(e)?.blocks[t];j.set(d(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}}})},[_,d]),b=s.reduce((e,t)=>e+t.blocks.filter((e,n)=>wg(e,g(t.identity,n))!==``).length,0),x=b>0,S=(0,q.useCallback)((e,t={})=>{i.submit(e,{...t,onRollback:e=>{t.onRollback?.(e),h.current?.()}})&&m.current?.()},[i]),C=(0,q.useCallback)(e=>{let t=e?s.filter(t=>t.identity===e):s,n=e?t.flatMap(e=>e.blocks.map((t,n)=>d(e.identity,n))):f,r=t.flatMap(e=>e.blocks.map((t,n)=>`${e.identity}::${n}`)),i=(e,t)=>wg(e.blocks[t],g(e.identity,t)),c=t.flatMap(e=>e.blocks.map((t,n)=>({ask:e,bi:n,question:zb(t),answer:i(e,n)})).filter(e=>e.answer!==``));if(c.length===0)return null;let l=t.find(e=>e.isLive),u=Ib({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!==``)}}),p=a,m=n.map(e=>[e,j.get(e)]);return{wire:u,onOptimistic:()=>{n.forEach(e=>j.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)p[e]?t[e]=p[e]:delete t[e];return t}),m.forEach(([e,t])=>{t&&!j.get(e)&&j.set(e,t)})}}},[a,s,g,f,d]),w=(0,q.useCallback)(()=>C(),[C]),T=r.composer,E=(0,q.useCallback)(e=>{if(T?.run())return;let t=C(typeof e==`string`?e:void 0);t&&S(t.wire,{onOptimistic:t.onOptimistic,onRollback:t.onRollback})},[T,C,S]),D=(0,q.useCallback)(e=>{let t=_.get(jb(e));if(t)return{answerFor:e=>g(t.identity,e),onChip:(e,n)=>v(t.identity,e,n),onText:(e,n)=>y(t.identity,e,n),onSubmit:()=>E(t.identity),anyAnswered:t.blocks.some((e,n)=>wg(e,g(t.identity,n))!==``),sending:i.pending}},[_,g,v,y,E,i.pending]);return{liveMsg:c,answering:(0,q.useMemo)(()=>c?D(c):void 0,[c,D]),answeringForMessage:D,anyAnswered:x,sending:i.pending,sendAnswers:E,sendMessage:S,stagedCount:b,takeAnswers:w}}function Rb(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 zb(e){return Rb(e.contextMd)||Rb(e.options.join(` / `))||`earlier question`}function Bb(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 Vb(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 Hb(e,t,n){if(n.length===0)return{agents:e,key:void 0};let{launched:r,finished:i}=Vb(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 Ub(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}:Hb(a,n.current,t),s=o.key;(0,q.useEffect)(()=>{if(s===void 0)return;let e=setTimeout(()=>i(s),Qo);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 Wb(e,t,n){return e===t||n(e,t)?e:t}function Gb(e,t){let n=(0,q.useRef)(e);return n.current=t(n.current,e),n.current}function Kb(e,t){return Gb(e,(e,n)=>Wb(e,n,t))}function qb(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 Jb(e,t){return qb(e,t,Xb)}function Yb(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 Xb(e,t){return!e||!t?e===t:e.length===t.length&&e.every((e,n)=>Object.is(e,t[n]))}function Zb(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!Jo(n))return n.kind===`event`&&n.boundary===`rest`?n.sourceId??`rest@${n.at??t}`:void 0}}function Qb(e,t,n){if(!e||e.runtime!==`running`&&e.runtime!==`spawning`)return;let r=Zb(t);return r!==void 0&&r!==n?r:void 0}function $b(e,t){let n=(0,q.useRef)(null),[r,i]=(0,q.useState)(void 0),a=n.current&&n.current.messages.length>0?Qb(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:Zb(o)})},[o]),o}var ex=e=>(e??``).replace(/\s+/g,` `).trim();function tx(e,t){let n=ks(t.hints),r=ks(e.hints);if(n.length>0){let e=new Set(r.map(ex));return n.every(t=>e.has(ex(t)))}if(r.length>0)return!1;let i=ex(ji(t.hints)),a=ex(rs(t.body));return!i&&!a?!1:i===ex(ji(e.hints))&&a===ex(rs(e.body))}function nx(e,t,n){let r=new Set;if(!n)return r;for(let i=Math.min(t,e.length)-1;i>=0;i--){let t=e[i];if(c_(t))break;if(t.role!==`assistant`||t.kind||!t.text.includes("```awaiting"))continue;let a=Eg(t.text).filter(e=>e.kind===`fence`&&e.fenceKind===`awaiting`);a.length>0&&a.every(e=>e.kind===`fence`&&tx(n,e))&&r.add(i)}return r}function rx(e,t,n=!0){return e.held>0&&n?`release`:e.steered>0&&t?`interrupt`:null}function ix(e){if(!e)return!1;let t=ls(W.board,e);return Hr(t?.backend).interrupt&&t?.runtime===`running`}function ax(e){return Hr(e?ls(W.board,e)?.backend:void 0).steer}function ox(e){return(0,q.useSyncExternalStore)(e=>os(W,e),()=>ax(e),()=>!0)}function sx(e){return(0,q.useSyncExternalStore)(e=>os(W,e),()=>ix(e),()=>!1)}var cx=new Set,lx=new Set;function ux(e,t){if(t!==cx.has(e)){t?cx.add(e):cx.delete(e);for(let e of lx)e()}}function dx(e){return(0,q.useSyncExternalStore)((0,q.useCallback)(e=>(lx.add(e),()=>lx.delete(e)),[]),()=>e?cx.has(e):!1,()=>!1)}function fx(e,t){let n=rx(t,ix(e),ax(e));if(!n)return!1;if(cx.has(e))return!0;let r=ls(W.board,e)?.sessionId;if(!r)return G(`This thread has no live session to send to`),!0;ux(e,!0);let i=n===`release`;return U.deliverQueuedNow({slug:e,sessionId:r,...i?{releaseOnly:!0}:{}}).then(t=>{ux(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=>{ux(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 px=`input, textarea, select, [contenteditable]:not([contenteditable='false'])`;function mx(e,t){if(e.defaultPrevented||e.repeat||!Tr(e))return!1;let n=e.target;if(!(n instanceof Element)||!t.contains(n))return!1;let r=n.closest(px);return r?r instanceof HTMLTextAreaElement&&r.closest(`[data-thread-composer-box]`)!==null&&r.value.trim()===``:!0}var hx=new Set;function gx(e){if(e.defaultPrevented||e.repeat||!Tr(e))return;let t=document.activeElement;if(t&&t!==document.body&&t!==document.documentElement)return;let n=[...hx],r=xn();(r?n.find(e=>e.slug===r):new Set(n.map(e=>e.slug)).size===1?n[0]:void 0)?.press()&&e.preventDefault()}function _x(e,t){let n=(0,q.useRef)(t);return n.current=t,(0,q.useEffect)(()=>{let t={slug:e,press:()=>fx(e,n.current)};return hx.size===0&&window.addEventListener(`keydown`,gx),hx.add(t),()=>{hx.delete(t),hx.size===0&&window.removeEventListener(`keydown`,gx)}},[e]),(0,q.useCallback)(t=>{mx(t.nativeEvent,t.currentTarget)&&fx(e,n.current)&&t.preventDefault()},[e])}function vx(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 yx(e,t){let n=t;for(;n>0&&e[n].kind===`event`;)n--;return n}function bx(e){let t=e.findIndex(e=>e.queued===!0);return t<0?e.length:t}function xx(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)?vx(e,i):bx(e);if(s===0)continue;let c=e.slice(0,s),l=k_(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 h_(c,u))e<0||a(r,yx(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 Sx=e=>e.role===`user`&&!e.queued,Cx=e=>e.wake===!0&&e.text.trimStart().startsWith(`**This message is from frizz, not from the human.**`);function wx(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&&!Sx(e[i]);)i--;if(i<=t||!Cx(e[i]))break;let a=i-1;for(;a>t&&e[a].signOff!==!0&&!Sx(e[a]);)a--;if(a<=t||e[a].signOff!==!0)break;r.push(a),n=a}return r.reverse()}function Tx(e){return e.status===`pending`&&e.backgroundState===`background`}function Ex(e){let t=[];for(let n of e)for(let e of n.tools)Tx(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 Dx(e){return e.map(e=>{if(!e.tools.some(Tx))return e;let t=e.tools.filter(e=>!Tx(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!Tx(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}var Ox=2e3;function kx(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&&Zo(a.text)){r??=w_(e);for(let e of Ea(a.text))if(e.read.form!==`invalid`&&r.includes(e.read.id.toLowerCase()))return!1}if(Number.isFinite(o))break}return!0}function Ax(e,t,n,r){let i,a=new Set;for(let o of e){if(!kx(o,t)){n.delete(o.id);continue}let e=n.get(o.id)??r;n.set(o.id,e);let s=e+Ox;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 jx(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 Mx(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&&Zo(r))for(let e of Ea(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=jx(e,Date.parse(i.at));if(o<0||!a(o).has(t)||n.some(n=>w_(n).includes(t)&&jx(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 Nx=new WeakMap;function Px(e,t,n=[]){let r=Mx(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=Nx.get(e);if(a?.key===i)return a.message;let o={...e,refusedFences:new Set(n.keys()),refusedReasons:n};return Nx.set(e,{key:i,message:o}),o})}function Fx(e){return e?.length?e.map(e=>`${e.at}|${e.id??``}|${e.faults.join(`\0`)}`).join(`
126
+ `):``}function Ix(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 Lx(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 w_(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:jx(e,Date.parse(t.askedAt))})).sort((e,t)=>e.askedMs-t.askedMs)}));return e.forEach((e,t)=>{if(e.role!==`assistant`||!e.text||!(Zo(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 Rx=new WeakMap;function zx(e,t){let n=Lx(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=Rx.get(e);if(a?.key===i)return a.message;let o={...e,questionOwners:r};return Rx.set(e,{key:i,message:o}),o})}function Bx(e,t){let n=t.description?.trim(),r=n&&!n.includes(`
128
128
  `)?n:void 0,i=[r?void 0:n,t.preview?.trim()].filter(Boolean).join(`
129
129
 
130
- `)||void 0;return{line:`${xg(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var Rx=`root`;function zx(e,t,n){return`${e}/${t}.${n}`}function Bx(e){let t=e.options??[],n=t.map((e,t)=>Lx(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 Vx(e){return e.secret||e.danger||!e.options?.length?!0:e.options.some(e=>e.followUps?.some(Vx))}function Hx(e,t){return!t||e.kind===`multi`?null:t.chosen}function Ux(e,t){let n=[],r=(e,i,a)=>{let{question:o,optionLabels:s}=Bx(e);n.push({path:i,spec:e,question:o,optionLabels:s,depth:a});let c=Hx(e,t.get(i));c!==null&&(e.options?.[c]?.followUps??[]).forEach((e,t)=>r(e,zx(i,c,t),a+1))};return r(e,Rx,1),n}function Wx(e,t){return t?t.text.trim()?!0:e.kind===`multi`?(t.chosenSet??[]).length>0:t.chosen!==null:!1}function Gx(e,t){if(!Wx(e.spec,t.get(`root`)))return;let n=(r,i)=>{let a=t.get(i),o=(r.options??[]).map(e=>e.label),s=Hx(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,zx(i,s,t)));return{questionId:e.id,question:r.question,chosen:c,...l?{text:l}:{},...u.length>0?{followUps:u}:{}}};return n(e.spec,Rx)}function Kx(e,t){let n=[],r=(e,t,i,a)=>{let o=e.options??[],{question:s}=Bx(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,zx(i,d,n),a+1)})};return r(e,t,Rx,1),n}function qx(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 Jx(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 Yx(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 Xx(e,t){return Zx.has(e.key)?`keep`:e.repeat||e.defaultPrevented||!ts(e)||t.keepsOwnEnter||t.surfaceGone?`spend`:`send`}var Zx=new Set([`Shift`,`Control`,`Alt`,`Meta`,`CapsLock`,`Fn`]),Qx=[`input`,`textarea`,`select`,`[contenteditable]:not([contenteditable='false'])`,`button`,`a[href]`,`summary`,`[role=button]`,`[role=link]`,`[role=menuitem]`,`[role=option]`,`[role=checkbox]`,`[role=radio]`,`[role=switch]`,`[role=tab]`,`[data-question-grid]`,`[data-awaiting-steps]`].join(`, `);function $x(e){return!(e instanceof Element)||e===document.body||e===document.documentElement?!1:e.closest(Qx)!==null}var eS=null;function tS(e){if(!eS)return;let t=eS,n=Xx(e,{keepsOwnEnter:$x(e.target),surfaceGone:t.surface!==null&&!t.surface.isConnected});n!==`keep`&&(eS=null,n===`send`&&(e.preventDefault(),t.submit()))}function nS(){eS=null}var rS=!1;function iS(e,t){eS={submit:e,surface:t?.closest(`[data-thread-surface]`)??null},!(rS||typeof window>`u`)&&(rS=!0,window.addEventListener(`keydown`,tS,!0),window.addEventListener(`pointerdown`,nS,!0))}function aS({className:e}){return(0,X.jsxs)(`div`,{className:`flex items-baseline gap-[0.3em] ${e}`,children:[(0,X.jsx)(oc,{"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 oS({raw:e,question:t,questionKind:n,danger:r,interactive:i,aside:a,label:o,settled:s,pending:c}){let l=(0,q.useMemo)(()=>t??vg(e??``,n??`question`,r),[t,e,n,r]),u=Gf(l.contextMd),f=Gf(l.detailMd??``),p=Gf(l.trailingMd??``),m=l.recommendedIdxs,h=qf(l.recommendation??``),g=l.kind===`multi`,_=l.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.useRef)(i?.onSubmit);C.current=i?.onSubmit;let w=(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 T=_?d:l.secret?tc:g?ic:Ue,E=o??(l.secret?`Secret`:g?`Select multiple`:`Question`);return(0,X.jsxs)(pm,{tone:_?`risk`:`neutral`,surface:`question`,icon:T,kind:E,label:null,aside:a,children:[u&&(0,X.jsx)(`div`,{id:w,className:`text-fg`,children:(0,X.jsx)(Hh,{className:`md-body`,html:u})}),l.detailMd&&(0,X.jsx)(`div`,{"data-question-context":!0,className:u?`mt-[13px]`:void 0,children:(0,X.jsx)(Hh,{className:`md-body`,html:f})}),(l.options.length>0||i||c)&&(0,X.jsxs)(`div`,{ref:S,tabIndex:-1,onKeyDown:e=>{!i||e.target!==e.currentTarget||ts({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":u?w:void 0,"aria-label":u?void 0:E,className:`mt-2 grid grid-cols-1 gap-1.5 outline-none`,children:[l.options.map((e,t)=>(0,X.jsxs)(q.Fragment,{children:[l.optionHeadings?.[t]&&(0,X.jsx)(sS,{md:l.optionHeadings[t]}),(0,X.jsx)(cS,{label:e,index:t,bodyMd:l.optionBodies?.[t],multi:g,recommended:m.includes(t),recTitle:m[0]===t?l.recommendedNote:void 0,selected:g?y.includes(t):v===t,settledPick:s?.chosenIdxs.includes(t)??!1,disabled:!i,onClick:n=>{if(!i)return;let r=g?y.includes(t):v===t;n>1&&r||i.onChip(t,e),iS(()=>C.current?.(),S.current),!(g&&x.current&&document.activeElement===x.current)&&S.current?.focus()}})]},t)),i&&!i.optionsOnly&&(0,X.jsxs)(`div`,{className:`relative col-span-full${l.options.length>0?` flex items-baseline`:``}`,children:[l.options.length>0&&(0,X.jsx)(`span`,{className:`pointer-events-none relative ml-[13px] -mr-[29px] flex`,children:(0,X.jsx)(uS,{id:xg(l.options.length).slice(0,-1),live:!0})}),l.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)(aS,{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}ts({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…`:l.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 ${l.options.length>0?lS:`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&&c&&(0,X.jsx)(`div`,{"data-question-pending-text":!0,className:`relative col-span-full`,children:l.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)(aS,{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:l.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`}),l.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)(uS,{id:xg(l.options.length).slice(0,-1)})}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:g?`Add a note…`:`Something else…`})]})]})})]}),s?.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:l.secret?`••••••••••••`:s.text}),s&&s.chosenIdxs.length===0&&!s.text&&(0,X.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-70`,children:`Not answered`}),l.trailingMd&&(0,X.jsx)(`div`,{"data-question-note":!0,className:`mt-2 text-muted-70`,children:(0,X.jsx)(Hh,{className:`md-body`,html:p})}),l.recommendation&&m.length===0&&(0,X.jsx)(Hh,{className:`md-inline mt-1.5 text-[11px] text-muted-70`,html:h})]})}function sS({md:e}){return(0,X.jsx)(`div`,{className:`mt-1 text-fg`,children:(0,X.jsx)(Hh,{className:`md-body`,html:qf(e.split(`
131
- `).join(` `))})})}function cS({label:e,index:t,bodyMd:n,selected:r,settledPick:i,disabled:a,multi:o,recommended:s,recTitle:c,onClick:l}){let u=Sg(e),d=u.id??xg(t).slice(0,-1),f=qf(u.rest),p=Gf(n??``),m=(0,q.useId)();return(0,X.jsxs)(`div`,{"data-question-option":!0,title:c,onClick:e=>{a||e.target.closest(`a, button, summary, img[data-local-path], .local-file-action, .local-file-code`)||window.getSelection()?.toString()||l(e.detail)},className:`relative flex items-baseline gap-2 rounded-md border px-3 py-1.5 text-[12px] leading-snug transition-colors ${r?`border-selection-border bg-selection text-fg`:i?`border-border-strong border-l-2 border-l-accent/40 bg-bg/50 pl-[11px] text-fg`:a?`border-border text-muted-80`:`border-border text-fg/90 hover:bg-elevated`}`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:a,"aria-labelledby":m,"aria-pressed":r||i,onClick:e=>l(e.detail),onMouseDown:e=>e.preventDefault(),className:`absolute inset-0 rounded-md outline-none`}),(0,X.jsx)(uS,{id:d,live:!a,selected:r}),o&&(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 ${r?`border-accent bg-accent-fill text-on-accent`:i?`border-control-strong text-fg`:`border-control-strong`}`,children:(r||i)&&(0,X.jsx)(fi,{size:10,strokeWidth:3})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{id:m,children:[s&&(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)(Hh,{as:`span`,className:`md-inline`,html:f})]}),n!==void 0&&(0,X.jsx)(Hh,{className:`md-body mt-1.5 opacity-90`,html:p})]})]})}var lS=`pl-9`;function uS({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 dS=(0,q.createContext)(null);function fS(){return(0,q.useContext)(dS)}function pS({questions:e}){let t=fS();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)(mS,{q:e,n:t?.numberOf(e.id)??n+1})},e.id))})}function mS({q:e,n:t}){let n=Gf(e.spec.question),r=e.spec.options??[],i=Is();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)(Hh,{className:`min-w-0 flex-1 ${hS}`,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:xg(t).slice(0,-1)}),(0,X.jsxs)(`span`,{className:`min-w-0`,children:[(0,X.jsx)(_S,{md:e.label}),e.recommended&&(0,X.jsx)(`span`,{className:`ml-1 text-[11px] font-semibold leading-none text-accent`,children:`RECOMMENDED`})]})]},t)),i&&Vx(e.spec)&&(0,X.jsxs)(lt,{className:`px-3.5 pt-1 text-[13px] text-muted`,children:[`This question has to be answered on `,i,`.`]})]})}var hS=`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 gS({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)(nc,{"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 _S({md:e}){return(0,X.jsx)(Hh,{as:`span`,className:`md-inline`,html:qf(e)})}function vS(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var yS=(0,q.createContext)(null);function bS(e){let t=e?.id,n=e?.questions??[],r=B(),i=Is(),[a,o]=(0,q.useState)(()=>new Map),[s,c]=(0,q.useState)(),l=(0,q.useContext)(pv),u=(0,q.useContext)(iv),d=oe((0,q.useMemo)(()=>t?n.flatMap(e=>e.spec.secret?[]:YS(e).flatMap(n=>[fn.question(r,t,e.id,n),fn.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=Yx(e.spec,n),o=i?Jx(i,t?d.get(fn.questionPick(r,t,e.id,n))??``:``):void 0;return{chosen:o?.chosen??null,chosenSet:o?.chosenSet??[],text:(t?d.get(fn.question(r,t,e.id,n)):void 0)??``}},p=e=>new Map(YS(e).map(t=>[t,f(e,t)])),m=n.flatMap(e=>{let t=Gx(e,p(e));return t?[{q:e,answer:t}]:[]}),h=m.map(e=>e.answer),g=R(),_=vn({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??[])j.clear(e)}},onError:e=>{l?.cancel(),t&&Ts(t),c(vS(e))},onSettled:()=>{t&&g.invalidateQueries({queryKey:SS(t)})}}),v=vn({mutationFn:async e=>U.dismissQuestions({slug:t,ids:[e]}),onError:e=>c(vS(e))}),y=e=>e.map(({q:e,answer:t})=>e.spec.secret?{...t,text:`(secret sent)`}:t),b=(e,t)=>{let n=SS(e);g.cancelQueries({queryKey:n});let r=new Date().toISOString(),i=new Set(t.map(e=>e.q.id));zr(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?[]:YS(t).flatMap(n=>[fn.question(r,e,t.id,n),fn.questionPick(r,e,t.id,n)])})),S=()=>{!t||h.length===0||_.isPending||(c(void 0),(l?.sent??l?.dismiss)?.(),gs(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:SS(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)j.clear(t)};return{answers:h,display:y(e).map((t,n)=>Ut(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=Yx(e.spec,n);if(!t||!o||e.spec.secret||!o.options?.[a])return;let s=fn.questionPick(r,t,e.id,n),c=Jx(o,j.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};j.set(s,qx(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}j.set(fn.question(r,t,e.id,n),s),a||j.clear(fn.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 xS=[],SS=e=>[`settledQuestions`,e],CS=[],wS=e=>e.questions,TS=e=>e.closed;function ES(e,t){return H({queryKey:SS(e??``),queryFn:async()=>{let t=await U.threadSettledQuestions({slug:e});return{questions:t.questions,closed:t.closed??[]}},enabled:!!e,refetchOnWindowFocus:!1,select:t})}function DS(e){let t=e?.id,n=R(),r=ES(t,wS),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:SS(t)})},[i,n,t]),r.data??xS}function OS(e){return ES(e?.id,TS).data??CS}var kS=[];function AS(e,t){let n=e?.questions??kS;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 jS({s:e,copy:t}){let n=(0,q.useMemo)(()=>Kx(e.spec,e.answer),[e.spec,e.answer]),r=e=>(0,X.jsx)(oS,{question:e.question,label:e.depth>1?`Follow-up`:void 0,settled:e.settled},e.path),i=n.slice(1);return(0,X.jsxs)(`article`,{...t?{"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:[r(n[0]),i.length>0&&(0,X.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:i.map(e=>(0,X.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:r(e)},e.path))})]})}function MS({questions:e,className:t=``}){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 ${t}`,children:e.map(e=>(0,X.jsx)(jS,{s:e},e.id))})}function NS(e){return`settledAt`in e?e:void 0}function PS(e,t,n,r,i=CS){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 FS(e,t){let n=(0,q.useRef)(new Map),[,r]=(0,q.useState)(0),{shown:i,wakeAt:a}=Dx(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 IS(e,t,n,r){let i=t?.questionFaults,a=(0,q.useMemo)(()=>i,[Mx(i)]),o=t?.closedQuestions,s=(0,q.useMemo)(()=>a?.length?[...n,...r,...o??[]]:[],[a,n,r,o]);return(0,q.useMemo)(()=>a?.length?jx(e,a,s):e,[e,a,s])}function LS(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)(()=>Ix(e,a),[e,a])}function RS({spec:e}){let t=(0,q.useMemo)(()=>Bx(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)(oS,{question:t,pending:!0})})}function zS({spec:e,state:t,copyOf:n}){let r=(0,q.useMemo)(()=>Bx(e).question,[e]);return(0,X.jsx)(`article`,{...n?{"data-question-copy":n}:{"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)(oS,{question:r,label:t===`dismissed`?`Question dismissed`:`Question withdrawn`,settled:BS})})}var BS={chosenIdxs:[]};function VS({q:e,above:t}){let n=(0,q.useMemo)(()=>Bx(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)(oS,{question:n,label:t?`Still open, answer it above`:`Still open, answer it below`})})}function HS({spec:e,reasons:t,unread:n}){let r=(0,q.useMemo)(()=>Bx(e).question,[e]);return(0,X.jsx)(WS,{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)(oS,{question:r})})})}function US({faults:e,children:t}){return(0,X.jsx)(WS,{reasons:e,"data-question-invalid":``,children:t})}function WS({reasons:e,children:t,...n}){let r=Nx(e),i=qf(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)(Hh,{as:`span`,className:`md-inline`,html:i})}),t]})}function GS({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 KS({thread:e,children:t}){let n=bS(e);return(0,X.jsx)(yS.Provider,{value:n,children:t})}function qS({q:e,answering:t}){let n=(0,q.useContext)(yS),r=fS(),i=t??n;if(!i||!i.slug)return null;if(r)return(0,X.jsx)(pS,{questions:[e]});if(i.readAndAnswerHost&&Vx(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)(oS,{question:Bx(e.spec).question}),(0,X.jsxs)(lt,{className:`text-[12px] text-muted`,children:[`This question has to be answered on `,i.readAndAnswerHost,`.`]})]});let a=Ux(e.spec,i.answersOf(e)),o=t=>(0,X.jsx)(oS,{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)(sa,{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 JS({thread:e,questions:t,inFlight:n=null,showSend:r=!1,className:i=``}){let a=e?.id,o=t??e?.questions??[],s=(0,q.useContext)(yS),c=bS(s?void 0:e),l=s??c,u=fS(),d=dv(),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)(Db,{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)(pS,{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)(qS,{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 YS(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,Rx),t}function XS(e,t){let n=DS(e);Mg(e);let r=(0,q.useMemo)(()=>AS(e,n),[e,n]),i=$b(e,t),a=(0,q.useMemo)(()=>Cx(i),[i]),o=(0,q.useMemo)(()=>wx(i),[i]),s=FS(r,i);return{messages:ZS(LS(IS(o,e,s,n),e,s,n),e),openQuestions:s,settledQuestions:n,transcriptShells:a}}function ZS(e,t){let n=t?.runtime===`running`||t?.runtime===`spawning`;return(0,q.useMemo)(()=>{if(n)return e;let t=xx(e,s_(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 QS=(0,q.createContext)(null),$S=(0,q.createContext)(null);function eC(){let e=(0,q.useContext)(QS);if(!e)throw Error(`A thread's prompt box must be rendered inside a <ThreadSurface>`);return e}function tC(){let e=(0,q.useContext)($S);if(!e)throw Error(`A thread's transcript must be rendered inside a <ThreadSurface>`);return e}function nC(e){let t=(0,q.useContext)($S)?.opsThread;return t&&t.id===e.id?t:e}var rC=(e,t)=>e===t||e!==`all`&&t!==`all`&&e.size===t.size&&[...e].every(e=>t.has(e)),iC=(e,t)=>qb(e,t,rC);function aC(e,t={}){let{slug:n,thread:r,messages:i}=e,a=Gb(e.openQuestions,ca),o=Gb(e.settledQuestions,ca),{exit:s}=t,l=ov(),u=cv(l),d=Lb(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=sv(l,{stagedCount:f,takeAnswers:p}),g=r?.runtime===`running`||r?.runtime===`spawning`,_=(0,q.useMemo)(()=>Ab(i),[i]),v=g?i.length:_,y=(0,q.useMemo)(()=>r?.heldHandoff?Dg(i,v):-1,[r?.heldHandoff,i,v]),b=My(r),x=c(r?.spawnedAt),S=Kb(PS(x,a,o,r,OS(r)),Xb),C=Gb((0,q.useMemo)(()=>v_(i,a),[i,a]),Jb),w=(0,q.useMemo)(()=>k_(i,a),[i,a]),T=Gb(w.placed,Jb),E=(0,q.useMemo)(()=>({...w,placed:T}),[w,T]),D=Kb((0,q.useMemo)(()=>A_(i,a,E),[i,a,E]),Yb),O=(0,q.useMemo)(()=>vx(i,o),[i,o]),k=Gb(O.placed,Jb),A=(0,q.useMemo)(()=>({...O,placed:k}),[O,k]),j=Gb((0,q.useMemo)(()=>i_(i),[i]),ca),M=Gb((0,q.useMemo)(()=>Y_(i),[i]),iC),N=(0,q.useMemo)(()=>$g(i,r?.answersInFlight),[i,r?.answersInFlight]),P=Ub(r,i),F=(0,q.useMemo)(()=>si(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=Ji(),z=bo(e=>R.give(e)),B=(0,q.useMemo)(()=>({fileDrop:{over:z.over,intake:R}}),[z.over,R]),ee=s?.dismiss,V=s?.cancel,te=s?.sent,ne=(0,q.useMemo)(()=>ee&&V?{dismiss:ee,cancel:V,sent:te}:null,[ee,V,te]);return{slug:n,answering:d,transcript:L,promptBoxSends:u,fileOver:z.over,queuedRun:I,exit:ne,sendScope:h,zone:z.handlers,box:B}}function oC({surface:e,children:t,...n}){let r=$t(),i=mx(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)(fv.Provider,{value:e.slug,children:(0,X.jsx)(pv.Provider,{value:e.exit,children:(0,X.jsx)(iv.Provider,{value:e.sendScope,children:(0,X.jsx)(av.Provider,{value:e.sendScope.composer,children:(0,X.jsx)(KS,{thread:e.transcript.thread,children:(0,X.jsx)($S.Provider,{value:e.transcript,children:(0,X.jsx)(mv.Provider,{value:e.queuedRun,children:(0,X.jsx)(QS.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 sC({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)(Zi,{"data-mobile-answer-sheet":!0,label:`Answer questions`,className:`fixed inset-0 ${qa} 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)(sa,{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)(oS,{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 cC=(e,t)=>`${e}|${t}`;function lC(e,t){return e.flatMap(e=>Ux(e.spec,t(e)).map(t=>({key:cC(e.id,t.path),q:e,path:t.path,spec:t.spec,depth:t.depth})))}function uC(e,t,n,r){return dC(lC(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 dC(e,t){let n=e.findIndex(e=>e.key===t);return n===-1?null:e[n+1]?.key??null}function fC(e,t){return e.find(e=>!Wx(e.spec,t(e.q).get(e.path)))?.key??null}var pC=`••••••••`;function mC(e,t){if(!t||!Wx(e,t))return null;if(e.secret)return pC;let n=(e.options??[]).map(e=>hC(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 hC(e){return e.replace(/[`*_~]/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\s+/g,` `).trim()}function gC(e){let t=e?.trim();return t&&!t.includes(`
132
- `)?t:void 0}function _C({title:e,onRequestClose:t,children:n,footer:r,className:i=``,dataAttr:a}){let[o,s]=(0,q.useState)(!1),c=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=requestAnimationFrame(()=>s(!0));return()=>cancelAnimationFrame(e)},[]);let l=a?{[a]:``}:{};return(0,X.jsx)(va,{open:!0,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(yi,{children:[(0,X.jsx)(ni,{className:`fixed inset-0 ${qa} bg-scrim-50 transition-opacity duration-200 motion-reduce:transition-none ${o?`opacity-100`:`opacity-0`}`}),(0,X.jsxs)(Wo,{ref:c,...l,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})},onEscapeKeyDown:st,className:`fixed inset-x-0 bottom-0 ${qa} 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)(eo,{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 vC({questions:e,onClose:t}){let n=(0,q.useContext)(yS),r=Yr(t),i=n?lC(e,n.answersOf):[],[a,o]=(0,q.useState)(()=>n?fC(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)(_C,{title:d?`Question ${u+1} of ${i.length}`:`Review your answers`,onRequestClose:()=>r(),dataAttr:`data-answer-sheet`,footer:d?(0,X.jsx)(EC,{a:n,step:d,first:u===0,writing:s,onBack:()=>f(i[u-1]?.key??d.key),onNext:()=>f(dC(i,d.key))}):(0,X.jsx)(OC,{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)(yC,{a:n,step:d,writing:s,onWrite:()=>c(!0),onPick:t=>{let r=uC(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)(DC,{a:n,steps:i,onChange:e=>f(e)})]})}function yC({a:e,step:t,writing:n,onWrite:r,onPick:i}){let a=Gf(t.spec.question),o=Gf(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)(Hh,{className:`px-[18px] pb-3 pt-1 text-[17px] font-semibold leading-[23px] text-fg ${hS}`,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)(Hh,{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)(xC,{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:`${bC} text-left`,children:[(0,X.jsx)(CC,{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)(TC,{a:e,step:t,text:s.text}),u&&!t.spec.secret&&(0,X.jsx)(wC,{a:e,step:t,autoFocus:n,placeholder:c.length===0?`Type your answer…`:l?`Add a note…`:`Write a different answer…`})]})}var bC=`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 xC({option:e,multi:t,on:n,onClick:r}){let i=gC(e.description),a=[i?void 0:e.description?.trim(),e.preview?.trim()].filter(Boolean).join(`
130
+ `)||void 0;return{line:`${xg(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var Vx=`root`;function Hx(e,t,n){return`${e}/${t}.${n}`}function Ux(e){let t=e.options??[],n=t.map((e,t)=>Bx(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 Wx(e){return e.secret||e.danger||!e.options?.length?!0:e.options.some(e=>e.followUps?.some(Wx))}function Gx(e,t){return!t||e.kind===`multi`?null:t.chosen}function Kx(e,t){let n=[],r=(e,i,a)=>{let{question:o,optionLabels:s}=Ux(e);n.push({path:i,spec:e,question:o,optionLabels:s,depth:a});let c=Gx(e,t.get(i));c!==null&&(e.options?.[c]?.followUps??[]).forEach((e,t)=>r(e,Hx(i,c,t),a+1))};return r(e,Vx,1),n}function qx(e,t){return t?t.text.trim()?!0:e.kind===`multi`?(t.chosenSet??[]).length>0:t.chosen!==null:!1}function Jx(e,t){if(!qx(e.spec,t.get(`root`)))return;let n=(r,i)=>{let a=t.get(i),o=(r.options??[]).map(e=>e.label),s=Gx(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,Hx(i,s,t)));return{questionId:e.id,question:r.question,chosen:c,...l?{text:l}:{},...u.length>0?{followUps:u}:{}}};return n(e.spec,Vx)}function Yx(e,t){let n=[],r=(e,t,i,a)=>{let o=e.options??[],{question:s}=Ux(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,Hx(i,d,n),a+1)})};return r(e,t,Vx,1),n}function Xx(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 Zx(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 Qx(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 $x(e,t){return eS.has(e.key)?`keep`:e.repeat||e.defaultPrevented||!ts(e)||t.keepsOwnEnter||t.surfaceGone?`spend`:`send`}var eS=new Set([`Shift`,`Control`,`Alt`,`Meta`,`CapsLock`,`Fn`]),tS=[`input`,`textarea`,`select`,`[contenteditable]:not([contenteditable='false'])`,`button`,`a[href]`,`summary`,`[role=button]`,`[role=link]`,`[role=menuitem]`,`[role=option]`,`[role=checkbox]`,`[role=radio]`,`[role=switch]`,`[role=tab]`,`[data-question-grid]`,`[data-awaiting-steps]`].join(`, `);function nS(e){return!(e instanceof Element)||e===document.body||e===document.documentElement?!1:e.closest(tS)!==null}var rS=null;function iS(e){if(!rS)return;let t=rS,n=$x(e,{keepsOwnEnter:nS(e.target),surfaceGone:t.surface!==null&&!t.surface.isConnected});n!==`keep`&&(rS=null,n===`send`&&(e.preventDefault(),t.submit()))}function aS(){rS=null}var oS=!1;function sS(e,t){rS={submit:e,surface:t?.closest(`[data-thread-surface]`)??null},!(oS||typeof window>`u`)&&(oS=!0,window.addEventListener(`keydown`,iS,!0),window.addEventListener(`pointerdown`,aS,!0))}function cS({className:e}){return(0,X.jsxs)(`div`,{className:`flex items-baseline gap-[0.3em] ${e}`,children:[(0,X.jsx)(oc,{"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 lS({raw:e,question:t,questionKind:n,danger:r,interactive:i,aside:a,label:o,settled:s,pending:c}){let l=(0,q.useMemo)(()=>t??vg(e??``,n??`question`,r),[t,e,n,r]),u=Gf(l.contextMd),f=Gf(l.detailMd??``),p=Gf(l.trailingMd??``),m=l.recommendedIdxs,h=qf(l.recommendation??``),g=l.kind===`multi`,_=l.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.useRef)(i?.onSubmit);C.current=i?.onSubmit;let w=(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 T=_?d:l.secret?tc:g?ic:Ue,E=o??(l.secret?`Secret`:g?`Select multiple`:`Question`);return(0,X.jsxs)(pm,{tone:_?`risk`:`neutral`,surface:`question`,icon:T,kind:E,label:null,aside:a,children:[u&&(0,X.jsx)(`div`,{id:w,className:`text-fg`,children:(0,X.jsx)(Hh,{className:`md-body`,html:u})}),l.detailMd&&(0,X.jsx)(`div`,{"data-question-context":!0,className:u?`mt-[13px]`:void 0,children:(0,X.jsx)(Hh,{className:`md-body`,html:f})}),(l.options.length>0||i||c)&&(0,X.jsxs)(`div`,{ref:S,tabIndex:-1,onKeyDown:e=>{!i||e.target!==e.currentTarget||ts({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":u?w:void 0,"aria-label":u?void 0:E,className:`mt-2 grid grid-cols-1 gap-1.5 outline-none`,children:[l.options.map((e,t)=>(0,X.jsxs)(q.Fragment,{children:[l.optionHeadings?.[t]&&(0,X.jsx)(uS,{md:l.optionHeadings[t]}),(0,X.jsx)(dS,{label:e,index:t,bodyMd:l.optionBodies?.[t],multi:g,recommended:m.includes(t),recTitle:m[0]===t?l.recommendedNote:void 0,selected:g?y.includes(t):v===t,settledPick:s?.chosenIdxs.includes(t)??!1,disabled:!i,onClick:n=>{if(!i)return;let r=g?y.includes(t):v===t;n>1&&r||i.onChip(t,e),sS(()=>C.current?.(),S.current),!(g&&x.current&&document.activeElement===x.current)&&S.current?.focus()}})]},t)),i&&!i.optionsOnly&&(0,X.jsxs)(`div`,{className:`relative col-span-full${l.options.length>0?` flex items-baseline`:``}`,children:[l.options.length>0&&(0,X.jsx)(`span`,{className:`pointer-events-none relative ml-[13px] -mr-[29px] flex`,children:(0,X.jsx)(pS,{id:xg(l.options.length).slice(0,-1),live:!0})}),l.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)(cS,{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}ts({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…`:l.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 ${l.options.length>0?fS:`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&&c&&(0,X.jsx)(`div`,{"data-question-pending-text":!0,className:`relative col-span-full`,children:l.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)(cS,{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:l.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`}),l.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)(pS,{id:xg(l.options.length).slice(0,-1)})}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:g?`Add a note…`:`Something else…`})]})]})})]}),s?.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:l.secret?`••••••••••••`:s.text}),s&&s.chosenIdxs.length===0&&!s.text&&(0,X.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-70`,children:`Not answered`}),l.trailingMd&&(0,X.jsx)(`div`,{"data-question-note":!0,className:`mt-2 text-muted-70`,children:(0,X.jsx)(Hh,{className:`md-body`,html:p})}),l.recommendation&&m.length===0&&(0,X.jsx)(Hh,{className:`md-inline mt-1.5 text-[11px] text-muted-70`,html:h})]})}function uS({md:e}){return(0,X.jsx)(`div`,{className:`mt-1 text-fg`,children:(0,X.jsx)(Hh,{className:`md-body`,html:qf(e.split(`
131
+ `).join(` `))})})}function dS({label:e,index:t,bodyMd:n,selected:r,settledPick:i,disabled:a,multi:o,recommended:s,recTitle:c,onClick:l}){let u=Sg(e),d=u.id??xg(t).slice(0,-1),f=qf(u.rest),p=Gf(n??``),m=(0,q.useId)();return(0,X.jsxs)(`div`,{"data-question-option":!0,title:c,onClick:e=>{a||e.target.closest(`a, button, summary, img[data-local-path], .local-file-action, .local-file-code`)||window.getSelection()?.toString()||l(e.detail)},className:`relative flex items-baseline gap-2 rounded-md border px-3 py-1.5 text-[12px] leading-snug transition-colors ${r?`border-selection-border bg-selection text-fg`:i?`border-border-strong border-l-2 border-l-accent/40 bg-bg/50 pl-[11px] text-fg`:a?`border-border text-muted-80`:`border-border text-fg/90 hover:bg-elevated`}`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:a,"aria-labelledby":m,"aria-pressed":r||i,onClick:e=>l(e.detail),onMouseDown:e=>e.preventDefault(),className:`absolute inset-0 rounded-md outline-none`}),(0,X.jsx)(pS,{id:d,live:!a,selected:r}),o&&(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 ${r?`border-accent bg-accent-fill text-on-accent`:i?`border-control-strong text-fg`:`border-control-strong`}`,children:(r||i)&&(0,X.jsx)(fi,{size:10,strokeWidth:3})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{id:m,children:[s&&(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)(Hh,{as:`span`,className:`md-inline`,html:f})]}),n!==void 0&&(0,X.jsx)(Hh,{className:`md-body mt-1.5 opacity-90`,html:p})]})]})}var fS=`pl-9`;function pS({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 mS=(0,q.createContext)(null);function hS(){return(0,q.useContext)(mS)}function gS({questions:e}){let t=hS();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)(_S,{q:e,n:t?.numberOf(e.id)??n+1})},e.id))})}function _S({q:e,n:t}){let n=Gf(e.spec.question),r=e.spec.options??[],i=Is();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)(Hh,{className:`min-w-0 flex-1 ${vS}`,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:xg(t).slice(0,-1)}),(0,X.jsxs)(`span`,{className:`min-w-0`,children:[(0,X.jsx)(bS,{md:e.label}),e.recommended&&(0,X.jsx)(`span`,{className:`ml-1 text-[11px] font-semibold leading-none text-accent`,children:`RECOMMENDED`})]})]},t)),i&&Wx(e.spec)&&(0,X.jsxs)(lt,{className:`px-3.5 pt-1 text-[13px] text-muted`,children:[`This question has to be answered on `,i,`.`]})]})}var vS=`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 yS({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)(nc,{"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 bS({md:e}){return(0,X.jsx)(Hh,{as:`span`,className:`md-inline`,html:qf(e)})}function xS(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var SS=(0,q.createContext)(null);function CS(e){let t=e?.id,n=e?.questions??[],r=z(),i=Is(),[a,o]=(0,q.useState)(()=>new Map),[s,c]=(0,q.useState)(),l=(0,q.useContext)(pv),u=(0,q.useContext)(iv),d=oe((0,q.useMemo)(()=>t?n.flatMap(e=>e.spec.secret?[]:QS(e).flatMap(n=>[fn.question(r,t,e.id,n),fn.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=Qx(e.spec,n),o=i?Zx(i,t?d.get(fn.questionPick(r,t,e.id,n))??``:``):void 0;return{chosen:o?.chosen??null,chosenSet:o?.chosenSet??[],text:(t?d.get(fn.question(r,t,e.id,n)):void 0)??``}},p=e=>new Map(QS(e).map(t=>[t,f(e,t)])),m=n.flatMap(e=>{let t=Jx(e,p(e));return t?[{q:e,answer:t}]:[]}),h=m.map(e=>e.answer),g=R(),_=vn({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??[])j.clear(e)}},onError:e=>{l?.cancel(),t&&Ts(t),c(xS(e))},onSettled:()=>{t&&g.invalidateQueries({queryKey:TS(t)})}}),v=vn({mutationFn:async e=>U.dismissQuestions({slug:t,ids:[e]}),onError:e=>c(xS(e))}),y=e=>e.map(({q:e,answer:t})=>e.spec.secret?{...t,text:`(secret sent)`}:t),b=(e,t)=>{let n=TS(e);g.cancelQueries({queryKey:n});let r=new Date().toISOString(),i=new Set(t.map(e=>e.q.id));zr(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?[]:QS(t).flatMap(n=>[fn.question(r,e,t.id,n),fn.questionPick(r,e,t.id,n)])})),S=()=>{!t||h.length===0||_.isPending||(c(void 0),(l?.sent??l?.dismiss)?.(),gs(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:TS(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)j.clear(t)};return{answers:h,display:y(e).map((t,n)=>Ut(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=Qx(e.spec,n);if(!t||!o||e.spec.secret||!o.options?.[a])return;let s=fn.questionPick(r,t,e.id,n),c=Zx(o,j.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};j.set(s,Xx(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}j.set(fn.question(r,t,e.id,n),s),a||j.clear(fn.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 wS=[],TS=e=>[`settledQuestions`,e],ES=[],DS=e=>e.questions,OS=e=>e.closed;function kS(e,t){return H({queryKey:TS(e??``),queryFn:async()=>{let t=await U.threadSettledQuestions({slug:e});return{questions:t.questions,closed:t.closed??[]}},enabled:!!e,refetchOnWindowFocus:!1,select:t})}function AS(e){let t=e?.id,n=R(),r=kS(t,DS),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:TS(t)})},[i,n,t]),r.data??wS}function jS(e){return kS(e?.id,OS).data??ES}var MS=[];function NS(e,t){let n=e?.questions??MS;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 PS({s:e,copy:t}){let n=(0,q.useMemo)(()=>Yx(e.spec,e.answer),[e.spec,e.answer]),r=e=>(0,X.jsx)(lS,{question:e.question,label:e.depth>1?`Follow-up`:void 0,settled:e.settled},e.path),i=n.slice(1);return(0,X.jsxs)(`article`,{...t?{"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:[r(n[0]),i.length>0&&(0,X.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:i.map(e=>(0,X.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:r(e)},e.path))})]})}function FS({questions:e,className:t=``}){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 ${t}`,children:e.map(e=>(0,X.jsx)(PS,{s:e},e.id))})}function IS(e){return`settledAt`in e?e:void 0}function LS(e,t,n,r,i=ES){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 RS(e,t){let n=(0,q.useRef)(new Map),[,r]=(0,q.useState)(0),{shown:i,wakeAt:a}=Ax(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 zS(e,t,n,r){let i=t?.questionFaults,a=(0,q.useMemo)(()=>i,[Fx(i)]),o=t?.closedQuestions,s=(0,q.useMemo)(()=>a?.length?[...n,...r,...o??[]]:[],[a,n,r,o]);return(0,q.useMemo)(()=>a?.length?Px(e,a,s):e,[e,a,s])}function BS(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)(()=>zx(e,a),[e,a])}function VS({spec:e}){let t=(0,q.useMemo)(()=>Ux(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)(lS,{question:t,pending:!0})})}function HS({spec:e,state:t,copyOf:n}){let r=(0,q.useMemo)(()=>Ux(e).question,[e]);return(0,X.jsx)(`article`,{...n?{"data-question-copy":n}:{"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)(lS,{question:r,label:t===`dismissed`?`Question dismissed`:`Question withdrawn`,settled:US})})}var US={chosenIdxs:[]};function WS({q:e,above:t}){let n=(0,q.useMemo)(()=>Ux(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)(lS,{question:n,label:t?`Still open, answer it above`:`Still open, answer it below`})})}function GS({spec:e,reasons:t,unread:n}){let r=(0,q.useMemo)(()=>Ux(e).question,[e]);return(0,X.jsx)(qS,{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)(lS,{question:r})})})}function KS({faults:e,children:t}){return(0,X.jsx)(qS,{reasons:e,"data-question-invalid":``,children:t})}function qS({reasons:e,children:t,...n}){let r=Ix(e),i=qf(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)(Hh,{as:`span`,className:`md-inline`,html:i})}),t]})}function JS({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 YS({thread:e,children:t}){let n=CS(e);return(0,X.jsx)(SS.Provider,{value:n,children:t})}function XS({q:e,answering:t}){let n=(0,q.useContext)(SS),r=hS(),i=t??n;if(!i||!i.slug)return null;if(r)return(0,X.jsx)(gS,{questions:[e]});if(i.readAndAnswerHost&&Wx(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)(lS,{question:Ux(e.spec).question}),(0,X.jsxs)(lt,{className:`text-[12px] text-muted`,children:[`This question has to be answered on `,i.readAndAnswerHost,`.`]})]});let a=Kx(e.spec,i.answersOf(e)),o=t=>(0,X.jsx)(lS,{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)(sa,{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 ZS({thread:e,questions:t,inFlight:n=null,showSend:r=!1,className:i=``}){let a=e?.id,o=t??e?.questions??[],s=(0,q.useContext)(SS),c=CS(s?void 0:e),l=s??c,u=hS(),d=dv(),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)(Db,{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)(gS,{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)(XS,{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 QS(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,Vx),t}function $S(e,t){let n=AS(e);Mg(e);let r=(0,q.useMemo)(()=>NS(e,n),[e,n]),i=$b(e,t),a=(0,q.useMemo)(()=>Ex(i),[i]),o=(0,q.useMemo)(()=>Dx(i),[i]),s=RS(r,i);return{messages:eC(BS(zS(o,e,s,n),e,s,n),e),openQuestions:s,settledQuestions:n,transcriptShells:a}}function eC(e,t){let n=t?.runtime===`running`||t?.runtime===`spawning`;return(0,q.useMemo)(()=>{if(n)return e;let t=wx(e,s_(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 tC=(0,q.createContext)(null),nC=(0,q.createContext)(null);function rC(){let e=(0,q.useContext)(tC);if(!e)throw Error(`A thread's prompt box must be rendered inside a <ThreadSurface>`);return e}function iC(){let e=(0,q.useContext)(nC);if(!e)throw Error(`A thread's transcript must be rendered inside a <ThreadSurface>`);return e}function aC(e){let t=(0,q.useContext)(nC)?.opsThread;return t&&t.id===e.id?t:e}var oC=(e,t)=>e===t||e!==`all`&&t!==`all`&&e.size===t.size&&[...e].every(e=>t.has(e)),sC=(e,t)=>qb(e,t,oC);function cC(e,t={}){let{slug:n,thread:r,messages:i}=e,a=Gb(e.openQuestions,ca),o=Gb(e.settledQuestions,ca),{exit:s}=t,l=ov(),u=cv(l),d=Lb(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=sv(l,{stagedCount:f,takeAnswers:p}),g=r?.runtime===`running`||r?.runtime===`spawning`,_=(0,q.useMemo)(()=>Ab(i),[i]),v=g?i.length:_,y=(0,q.useMemo)(()=>r?.heldHandoff?Dg(i,v):-1,[r?.heldHandoff,i,v]),b=My(r),x=b&&r?.lastFence?.kind===`awaiting`?r.lastFence:void 0,S=(0,q.useMemo)(()=>nx(i,v,x),[i,v,x]),C=c(r?.spawnedAt),w=Kb(LS(C,a,o,r,jS(r)),Xb),T=Gb((0,q.useMemo)(()=>v_(i,a),[i,a]),Jb),E=(0,q.useMemo)(()=>k_(i,a),[i,a]),D=Gb(E.placed,Jb),O=(0,q.useMemo)(()=>({...E,placed:D}),[E,D]),k=Kb((0,q.useMemo)(()=>A_(i,a,O),[i,a,O]),Yb),A=(0,q.useMemo)(()=>xx(i,o),[i,o]),j=Gb(A.placed,Jb),M=(0,q.useMemo)(()=>({...A,placed:j}),[A,j]),N=Gb((0,q.useMemo)(()=>i_(i),[i]),ca),P=Gb((0,q.useMemo)(()=>Y_(i),[i]),sC),F=(0,q.useMemo)(()=>$g(i,r?.answersInFlight),[i,r?.answersInFlight]),I=Ub(r,i),L=(0,q.useMemo)(()=>si(i),[i]),R=(0,q.useMemo)(()=>({held:L.held,steered:L.steered}),[L.held,L.steered]),ee=(0,q.useMemo)(()=>({thread:r,messages:i,running:g,lastAgentIdx:_,awaitingCut:v,heldIdx:y,restingShown:b,restated:S,hidesAwaiting:e=>[v>=0&&e<v&&e!==y,e===_&&b||S.has(e)],stepsDone:P,openQuestions:a,fencesLive:C,fenceQuestions:w,shadowedByMessage:T,placement:O,questionHomes:k,settledPlacement:M,paired:N,inFlightAnswers:F,answeringForMessage:m,opsThread:I}),[r,i,g,_,v,y,b,S,P,a,C,w,T,O,k,M,N,F,m,I]),z=Ji(),te=bo(e=>z.give(e)),ne=(0,q.useMemo)(()=>({fileDrop:{over:te.over,intake:z}}),[te.over,z]),B=s?.dismiss,re=s?.cancel,V=s?.sent,ie=(0,q.useMemo)(()=>B&&re?{dismiss:B,cancel:re,sent:V}:null,[B,re,V]);return{slug:n,answering:d,transcript:ee,promptBoxSends:u,fileOver:te.over,queuedRun:R,exit:ie,sendScope:h,zone:te.handlers,box:ne}}function lC({surface:e,children:t,...n}){let r=$t(),i=_x(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)(fv.Provider,{value:e.slug,children:(0,X.jsx)(pv.Provider,{value:e.exit,children:(0,X.jsx)(iv.Provider,{value:e.sendScope,children:(0,X.jsx)(av.Provider,{value:e.sendScope.composer,children:(0,X.jsx)(YS,{thread:e.transcript.thread,children:(0,X.jsx)(nC.Provider,{value:e.transcript,children:(0,X.jsx)(mv.Provider,{value:e.queuedRun,children:(0,X.jsx)(tC.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 uC({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)(Zi,{"data-mobile-answer-sheet":!0,label:`Answer questions`,className:`fixed inset-0 ${qa} 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)(sa,{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)(lS,{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 dC=(e,t)=>`${e}|${t}`;function fC(e,t){return e.flatMap(e=>Kx(e.spec,t(e)).map(t=>({key:dC(e.id,t.path),q:e,path:t.path,spec:t.spec,depth:t.depth})))}function pC(e,t,n,r){return mC(fC(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 mC(e,t){let n=e.findIndex(e=>e.key===t);return n===-1?null:e[n+1]?.key??null}function hC(e,t){return e.find(e=>!qx(e.spec,t(e.q).get(e.path)))?.key??null}var gC=`••••••••`;function _C(e,t){if(!t||!qx(e,t))return null;if(e.secret)return gC;let n=(e.options??[]).map(e=>vC(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 vC(e){return e.replace(/[`*_~]/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\s+/g,` `).trim()}function yC(e){let t=e?.trim();return t&&!t.includes(`
132
+ `)?t:void 0}function bC({title:e,onRequestClose:t,children:n,footer:r,className:i=``,dataAttr:a}){let[o,s]=(0,q.useState)(!1),c=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=requestAnimationFrame(()=>s(!0));return()=>cancelAnimationFrame(e)},[]);let l=a?{[a]:``}:{};return(0,X.jsx)(va,{open:!0,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(yi,{children:[(0,X.jsx)(ni,{className:`fixed inset-0 ${qa} bg-scrim-50 transition-opacity duration-200 motion-reduce:transition-none ${o?`opacity-100`:`opacity-0`}`}),(0,X.jsxs)(Wo,{ref:c,...l,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})},onEscapeKeyDown:st,className:`fixed inset-x-0 bottom-0 ${qa} 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)(eo,{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 xC({questions:e,onClose:t}){let n=(0,q.useContext)(SS),r=Yr(t),i=n?fC(e,n.answersOf):[],[a,o]=(0,q.useState)(()=>n?hC(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)(bC,{title:d?`Question ${u+1} of ${i.length}`:`Review your answers`,onRequestClose:()=>r(),dataAttr:`data-answer-sheet`,footer:d?(0,X.jsx)(kC,{a:n,step:d,first:u===0,writing:s,onBack:()=>f(i[u-1]?.key??d.key),onNext:()=>f(mC(i,d.key))}):(0,X.jsx)(jC,{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)(SC,{a:n,step:d,writing:s,onWrite:()=>c(!0),onPick:t=>{let r=pC(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)(AC,{a:n,steps:i,onChange:e=>f(e)})]})}function SC({a:e,step:t,writing:n,onWrite:r,onPick:i}){let a=Gf(t.spec.question),o=Gf(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)(Hh,{className:`px-[18px] pb-3 pt-1 text-[17px] font-semibold leading-[23px] text-fg ${vS}`,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)(Hh,{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)(wC,{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:`${CC} text-left`,children:[(0,X.jsx)(EC,{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)(OC,{a:e,step:t,text:s.text}),u&&!t.spec.secret&&(0,X.jsx)(DC,{a:e,step:t,autoFocus:n,placeholder:c.length===0?`Type your answer…`:l?`Add a note…`:`Write a different answer…`})]})}var CC=`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 wC({option:e,multi:t,on:n,onClick:r}){let i=yC(e.description),a=[i?void 0:e.description?.trim(),e.preview?.trim()].filter(Boolean).join(`
133
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:`${bC} text-left`,children:[(0,X.jsx)(CC,{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)(_S,{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)(SC,{md:a})]})]})}function SC({md:e}){return(0,X.jsx)(`div`,{className:`card-md mt-1 text-muted`,children:(0,X.jsx)(Hh,{className:`md-body`,html:Gf(e)})})}function CC({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)(fi,{size:14,strokeWidth:3}):(0,X.jsx)(`span`,{className:`size-2.5 rounded-full bg-fg`}))})}function wC({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 TC({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)(aS,{className:`mt-2 text-[13px] leading-[18px] text-muted`})]})}function EC({a:e,step:t,first:n,writing:r,onBack:i,onNext:a}){let o=e.answerFor(t.q,t.path),s=Wx(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)(MC,{children:[(0,X.jsx)(`button`,{type:`button`,"data-answer-back":!0,disabled:n,onClick:i,className:`${kC} ${AC} 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:`${kC} ${AC}`,children:s?`Next`:`Skip`}),u&&(0,X.jsx)(`button`,{type:`button`,"data-answer-continue":!0,disabled:!s,onClick:a,className:`${kC} ${jC} px-6 disabled:opacity-35`,children:`Continue`})]})}function DC({a:e,steps:t,onChange:n}){let r=t.map(t=>({s:t,said:mC(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:NC(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 OC({a:e,onSent:t}){return(0,X.jsx)(MC,{children:(0,X.jsx)(`button`,{type:`button`,"data-answer-send":!0,disabled:e.staged===0||e.sending,onClick:()=>{e.submit(),t()},className:`${kC} ${jC} flex-1 disabled:opacity-35`,children:e.sending?`Sending…`:`Send answers`})})}var kC=`flex h-[46px] shrink-0 items-center justify-center rounded-[12px] text-[15.5px] font-semibold outline-none`,AC=`px-[18px] text-muted active:bg-hover focus-visible:bg-hover`,jC=`bg-fg text-bg active:opacity-90`;function MC({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=Pr(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 NC(e){return hC(e.trim().split(/\n\s*\n/)[0]??``)}function PC(e){return(0,q.useSyncExternalStore)(e=>os(W,e),()=>e?FC(e)!==`codex`:!1,()=>!1)}function FC(e){return ls(W.board,e)?.backend}function IC(e,t,n,r){let i=fn.followUp(e,t,n);return cs(i,r),i}function LC(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 RC(e){let t=R(),n=B(),[r,i]=(0,q.useState)(!1);return{unqueue:(0,q.useCallback)(a=>{if(!e||r)return;let o=ls(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}Le(t,e,a.rawText,a.deliveryId),IC(n,e,o,a.text),LC(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 zC(e){let t=R(),n=B(),[r,i]=(0,q.useState)(!1),a=(0,q.useCallback)(n=>{!e||r||hn(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||(IC(n,e,ls(W.board,e)?.sessionId,t.text),LC(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 BC=new Map;function VC(e,t){let n=(BC.get(e)??[]).filter(e=>e.deliveryId!==t.deliveryId);n.push(t),BC.set(e,n.slice(-8))}var HC=e=>e.replace(/\s+/g,` `).trim();function UC(e,t){let n=BC.get(e);if(!n?.length)return;let r=HC(t);for(let t=n.length-1;t>=0;t--){let i=HC(n[t].text);if(!i||!r.includes(i))continue;let[a]=n.splice(t,1);return n.length||BC.delete(e),a.deliveryId}}function WC(e){return e.project?`${zo(e.project)}/thread/${e.slug}`:Yt(`/thread/${e.slug}`)}function GC({peer:e,text:t,queued:n,sourceId:r,at:i}){let[a,o]=(0,q.useState)(!1),s=(0,q.useId)(),c=e.thread,l=We(c&&!c.project?c.slug:void 0),u=l?P(l):c?.title,d=Gf(t),f=Np(d),p=(0,q.useRef)(null),m=Wm(p,d),h=(0,q.useRef)(null),g=(0,q.useRef)(!1),_=()=>{g.current=document.activeElement===h.current,o(e=>!e)};(0,q.useLayoutEffect)(()=>{g.current&&(g.current=!1,h.current?.focus())},[a]);let v=e=>{e.target.closest(`a, button`)||_()},y=e=>e.preventDefault(),b=c?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`shrink-0 ${Uy}`,children:`Message from `}),(0,X.jsx)(`a`,{href:WC(c),"data-session-peer-link":!0,title:`Open the thread that sent this`,onMouseDown:y,className:`min-w-0 truncate [font-variant-caps:normal] ${$y}`,children:u})]}):(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name?`Message from session ${e.name}`:`Message from another session`}),x=(0,X.jsx)(`button`,{ref:h,type:`button`,"data-session-message-toggle":!0,onClick:_,onMouseDown:y,"aria-expanded":a,"aria-controls":s,"aria-label":a?`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)(Kt,{"aria-hidden":`true`,size:12,className:`${Yy} ${a?`-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:a?(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:v,onMouseDown:y,className:`group/wake mx-auto max-w-[calc(100%-66px)] cursor-pointer px-3`,children:(0,X.jsx)(Vy,{icon:lc,at:i,trailing:x,children:b})}),(0,X.jsxs)(`div`,{id:s,className:`card-md text-fg/85`,children:[(0,X.jsx)(`div`,{ref:p,className:`md-body [overflow-wrap:anywhere]`,dangerouslySetInnerHTML:f}),m]})]}):(0,X.jsx)(`div`,{onClick:v,onMouseDown:y,className:`group/wake cursor-pointer`,children:(0,X.jsx)(Q,{icon:lc,marker:`session-message`,at:i,trailing:x,children:b})})})}function KC(e){return e.role===`assistant`&&!e.kind&&e.text.trim()!==``&&Eg(e.text).some(e=>e.kind===`prose`)}function qC(e,t){let n=e.length>0&&!c_(e[0])?[-1]:[];e.forEach((e,t)=>{c_(e)&&n.push(t)});let r=[];return n.forEach((i,a)=>{let o=a+1<n.length?n[a+1]-1:e.length-1,s=xx(e.slice(0,o+1),i);if(s.length===0)return;let c=-1;if(i>=0){for(let t=i+1;t<s[0];t++)if(KC(e[t])){c=t;break}}let l=c>=0?c+1:i+1;for(let[e,t]of s.entries())t>l&&r.push({from:l,to:t-1,...e===0&&c>=0?{lead:c}:{}}),l=t+1;!(t.running&&a===n.length-1)&&l<=o&&r.push({from:l,to:o})}),r}function JC(e,t){let n=0,r=t.lead===void 0?0:e[t.lead].tools?.length??0;for(let i=t.from;i<=t.to;i++){let t=e[i];(t.role===`user`&&t.wake||t.boundary===`wake`)&&n++,r+=t.tools?.length??0}return{rounds:n,calls:r}}function YC(e,t,n){return{type:`frizz-inline-vis-theme`,requestId:e,colorScheme:t,vars:n}}function XC(e,t){return typeof e==`object`&&!!e&&e.type===`frizz-inline-vis-applied`&&e.requestId===t}var ZC=new Set([`planning`,`planned`,`active`,`needs-human`,`blocked`]);function QC(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&&ZC.has(e.status))}function $C(e,t){return e.pending?`loading`:e.failed?`failed`:t.running?`starting`:t.adoptable?`adopt`:`empty`}var ew=`sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3 ${kt} 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`,tw=`flex min-w-0 flex-1 items-center gap-2.5 pl-1 max-[640px]:basis-full`,nw=`flex shrink-0 items-center max-[640px]:w-full`;function rw(e){return e?.trim()?{kind:`profile-error`,message:`Profile controls unavailable: ${e.trim().slice(0,160)}`}:null}function iw(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 aw(e){return e.permissionChangePending===!0||e.permissionPending!==void 0||e.profileChangePending===!0||e.runtimeControlPending===!0}function ow(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 sw(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 cw(e){let t=We(e),n=H({queryKey:[`threadProfileOptions`,e],queryFn:()=>U.threadProfileOptions({slug:e}),enabled:!!(t&&!t.foreign&&t.kind===`session`),staleTime:5e3}),r=vn({mutationFn:t=>U.setThreadProfile({slug:e,model:t.model,...t.effort?{effort:t.effort}:{}})}),i=vn({mutationFn:t=>U.setThreadPermission({slug:e,permissionMode:t})}),o=vn({mutationFn:t=>U.upgradeThreadModel({slug:e,sessionId:t})}),s=sr(),c=vn({mutationFn:t=>U.stopThreadTurn({slug:e,sessionId:t})}),l=r.isPending||i.isPending||o.isPending,u=t?.backend===`codex`?`codex`:t?.backend===`acp`?`acp`:t?.backend===`opencode`?`opencode`:`claude`,d=t?uo(t.id):void 0,f=H({queryKey:Da([`acpAgents`],d),queryFn:()=>ct(d).acpAgents(),enabled:!!t&&u===`acp`}),p=Ro(d,!!t&&u===`opencode`),m=u===`acp`?Bi(t?.model?.trim()):void 0,h=pi(d,m?[m]:[],m);if(!t||t.foreign||t.kind!==`session`)return{busy:l,footer:null,phoneTools:null,status:null};let g=l||aw(t),_=t.model?.trim(),v=t.effort?.trim(),y=u===`acp`?Bi(_):void 0,b=r.isPending?r.variables:void 0,x=t.profilePendingModel??b?.model,C=t.profilePendingEffort??b?.effort,w=n.data?.options??[],{modelSelectable:T}=sw(w,_,v,t.runtime===`exited`),E=n.data!==void 0,D=f.data?.find(e=>e.id===y)?.label??y,O=[{id:u,label:u===`codex`?`Codex`:`Claude Code`,options:w}],k=rw(n.isError?n.error.message:void 0),A=t.permissionMode?gr(t.permissionMode):`auto`,j=cr.some(e=>e.value===A)?A:`auto`,M=i.isPending?i.variables:j,N=iw(t);function P(e){e!==j&&i.mutate(e,{onSuccess:e=>G(ow(e.effect,`claude`)),onError:e=>G(`Permission change failed: ${e.message.slice(0,120)}`)})}let F=u===`claude`?iw(t):null;function I(){t?.sessionId&&o.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(u===`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:[(u===`claude`||u===`codex`)&&(0,X.jsx)(ht,{groups:O,value:{provider:u,model:_,effort:v},pending:x||C?{provider:u,model:x,effort:C}: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 ${u===`codex`?`Codex`:`Claude Code`} model and effort`,title:T?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:g||!E||!T||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:o.isPending,onUpgrade:I}:void 0}),u===`acp`&&y&&_&&(0,X.jsx)(ht,{groups:[or({agent:{id:y,label:D??y},models:h.models[y],loading:h.loading[y]??!1,saved:_,onRequestOptions:()=>h.request(y)})],value:Qn(_),pending:x?Qn(x):void 0,onValueChange:e=>L({model:e.model,effort:``}),ariaLabel:`Thread model and effort`,menuAriaLabel:`Choose ${D??y} model`,title:`This thread's ${D??y} model`,disabled:g,compact:!0,side:`top`,className:`max-w-[20rem]`}),u===`opencode`&&(0,X.jsx)(ht,{groups:[mr({models:p.models,loading:p.loading,saved:_,onRequestOptions:p.request})],value:Jt(_),pending:x?Jt(x):void 0,onValueChange:e=>L({model:a(e),effort:``}),ariaLabel:`Thread model and effort`,menuAriaLabel:`Choose OpenCode model and effort`,title:`This thread's OpenCode model and reasoning level`,disabled:g,compact:!0,side:`top`,className:`max-w-[20rem]`})]});return{busy:g,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)(Bt,{children:[R,u===`claude`&&(0,X.jsx)(Ct,{variant:`readout`,side:`top`,value:M,onValueChange:e=>P(e),options:cr,ariaLabel:`Thread permission mode`,title:N?`${N} — changing permissions restarts this thread's worker process`:M===`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:g||N!==null,className:`shrink-0`}),u===`opencode`&&(0,X.jsx)(Ct,{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:er,ariaLabel:`Thread permission mode`,title:`Applied to the session at once, and to its sub-agents.`,disabled:g,className:`shrink-0`})]}),u===`opencode`&&t.runtime===`running`&&t.sessionId&&(0,X.jsxs)(`button`,{type:`button`,"data-stop-turn":!0,onClick:()=>c.mutate(t.sessionId,{onError:e=>G(`Stop failed: ${e.message.slice(0,120)}`)}),disabled:c.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)(xc,{size:8,fill:`currentColor`,strokeWidth:0,"aria-hidden":!0}),!s&&`Stop`]}),(0,X.jsx)(S,{gauge:u===`acp`||u===`opencode`?void 0:{backend:u,model:_},mcp:{slug:e},side:`top`})]}),x&&C&&(0,X.jsxs)(`span`,{className:`min-w-0 truncate text-[9px] text-muted-50`,children:[`→ `,x,` · `,C,` pending`]})]}),phoneTools:R,status:k?(0,X.jsx)(`div`,{"data-thread-control-error":``,className:`px-1 pt-1 text-[9.5px] leading-tight text-muted-65`,children:k.message}):null}}function lw({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 Vn(e,{terminateLive:t});n.kind===`needs-confirmation`&&a({hold:n.hold}),n.kind!==`done`&&r(!1)}let s=Xe(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)(Ie,{"aria-hidden":!0,size:t?15:17,className:`animate-spin`}):(0,X.jsx)(fi,{"aria-hidden":!0,size:t?15:17,strokeWidth:2.6,className:`translate-y-[0.1em]`}),`Done`]}),(0,X.jsx)(ft,{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)(Ie,{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 uw={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 dw({checked:e,onChange:t,disabled:n,label:r,size:i=`sm`,testId:a}){let o=uw[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 fw({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 pw({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(`[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:ko(n?.width??e.clientWidth,mw),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),hw)}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)(Wn,{open:t!==`closed`,onOpenChange:e=>{e||(clearTimeout(i.current),n(`closed`))},children:[(0,X.jsx)(Se,{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 ${zi} items-center justify-center outline-none transition-[color,background-color] hover:bg-hover-strong`,children:(0,X.jsx)(fw,{...Aa,className:u?`text-attention-90`:`text-muted group-hover/goal:text-fg group-focus-visible/goal:text-fg`})})}),t===`preview`?(0,X.jsx)($e,{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)(gw,{armed:l})}):(0,X.jsx)($e,{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)(Ew,{thread:e,armed:l,close:()=>n(`closed`)})})]})}var mw=736,hw=260;function gw({armed:e}){let t=e?.prompt?.trim(),n=e?Tw({stopHook:e.stopHook===!0,heartbeat:e.heartbeat===!0,postCompaction:e.postCompaction===!0,seconds:e.intervalSeconds??yw}):[];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 _w=1,vw=1440,yw=600;function bw(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(vw,Math.max(_w,n))*60:t}var xw=null;function Sw(e){return{prompt:e.text.trim(),stopHook:e.stopHook,heartbeat:e.heartbeat,postCompaction:e.postCompaction,seconds:e.seconds}}function Cw(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 ww(e,t){return!e.archived&&!t}function Tw(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 Ew({thread:e,armed:t,close:n,heading:r=!0}){let i=ww(e,t)?Ao:``,a=xw?.slug===e.id?xw.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??yw),g=c||u||f,[_,v]=(0,q.useState)(String(Math.round((a?.seconds??t?.intervalSeconds??yw)/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??yw}),x=e=>({text:o,stopHook:c,heartbeat:u,postCompaction:f,seconds:bw(_,m),...e}),S=(0,q.useRef)(x());S.current=x(),(0,q.useEffect)(()=>()=>{let n=S.current;if(Cw(n,b.current)){xw?.slug===e.id&&(xw=null);return}if(n.text.trim()===``&&!t){xw={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?xw?.slug===e.id&&(xw=null):xw={slug:e.id,draft:t},n});return C.current=n,n}async function T(t){let n=t.text.trim()||null;if(Cw(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={...Sw(t),prompt:n??``};let r=Tw(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(Cw(x(),b.current)||o.trim()===``&&!t){n();return}w(x()).then(e=>{e&&n()})}function D(){let e=bw(_,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 ${ui(k.at)}`:`Last sent ${k.how} ${ui(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:Sa,onChange:e=>s(e.target.value),onKeyDown:e=>{ts({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)(dw,{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)(dw,{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:_w,max:vw,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)(dw,{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 Dw=`frizz:send-mode`;function Ow(){try{return localStorage.getItem(Dw)===`queue`?`queue`:`steer`}catch{return`steer`}}var kw=k({mode:typeof window>`u`?`steer`:Ow()});typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`storage`,e=>{(e.key===Dw||e.key===null)&&(kw.mode=Ow())});function Aw(e){kw.mode!==e&&(kw.mode=e);try{e===`steer`?localStorage.removeItem(Dw):localStorage.setItem(Dw,e)}catch{}}function jw(){return un(kw).mode}function Mw(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 Nw=new Map;function Pw(e){let t=Nw.get(e);if(t)return t;let n=U.threadSkills({slug:e}).then(e=>e.skills,()=>(Nw.delete(e),[]));return Nw.set(e,n),n}function Fw({className:e,above:t,phoneBarOverride:n,phoneChrome:r,readAndAnswerHost:i}){let a=(0,q.useContext)(yS),o=sr(),s=r??o;return(0,X.jsxs)(`div`,{"data-thread-composer-box":Iw,"data-remote-composer":!0,"data-thread-action-bar":``,className:s?`flex flex-col gap-2 px-3 py-2.5`:e,children:[t,s&&n&&(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:n({editReply:()=>{}})}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 ${s?``:`px-3 py-2`}`,children:[(0,X.jsx)(an,{host:i}),!s&&(a?.staged??0)>0&&(0,X.jsx)(`button`,{type:`button`,"data-remote-send-answers":!0,disabled:a.sending,onClick:a.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:a.sending?`Sending…`:`Send answers`})]})]})}var Iw=`chatComposer`;function Lw(e){let t=Is();return t?(0,X.jsx)(Fw,{...e,readAndAnswerHost:t}):(0,X.jsx)(Rw,{...e})}function Rw({slug:e,className:t,id:n,above:r,phoneBarOverride:i,phoneChrome:a}){let{fileDrop:o}=eC(),s=un(W),c=We(e),l=(0,q.useContext)(yS),u=(0,q.useContext)(iv),d=(0,q.useContext)(pv),f=Z_(c),p=(l?.staged??0)+(u?.fencedCount??0)+ +!!f.staged,h=c?.runtime===`running`,g=(0,q.useContext)(mv)?.held??0,_=h||g>0,{steer:v}=Hr(c?.backend),y=jw(),b=v?y:`queue`,x=c?.foreign?`Send a message to take over this session…`:Mw({staged:p,openQuestions:!!c?.pendingQuestion||(c?te(c):!1),running:_,mode:b,steerable:v}),S=B(),C=fn.followUp(S,e,c?.sessionId),[w,T,E]=bn(C),D=cw(e),O=F(e),[k,A]=(0,q.useState)(null),j=(0,q.useMemo)(()=>()=>Pw(e),[e]),[N,P]=(0,q.useState)(null),I=s.composerContext[e],L=(0,q.useMemo)(()=>I?.map(e=>e.token)??[],[I]);(0,q.useEffect)(()=>{let t=W.composerContext[e];if(!t?.length)return;let{prose:n}=fa(w),r=t.filter(e=>ys(n,e.token));r.length!==t.length&&(W.composerContext[e]=r)},[e,w,I]);let R=Ai(c),z=sr(),ee=a??z,V=c?.runtime===`running`||c?.runtime===`spawning`,ne=P_(c),re=c?oo(c).archive&&!V&&!ne:!1,ie=c&&c.kind===`session`&&c.foreign!==!0?(0,X.jsx)(pw,{thread:c}):void 0;function H(t=!1){let n=w.trim(),r=ee?null:l?.take()??null,i=ee?null:u?.takeFenced()??null,a=ee?null:f.take();if(!n&&!r&&!i&&!a)return;let o=Ae(n);if(o){if(E(),c?.backend===`acp`){G(`An ACP agent signs in through its own CLI — Frizz holds no account for it`);return}if(c?.backend===`opencode`){G("OpenCode signs in through its own CLI: run `opencode auth login`");return}let e=c?.backend===`codex`?`codex`:`claude`;o===`login`?A(e):P(e);return}let s=M(e),p=n?Os(n,s,S):``,m=a?a.compose(p):p,h=i?To(i.wire,m):m,g=r?To(Zt(r.display),h):h,y={onOptimistic:()=>{E(),r?.onOptimistic(),i?.onOptimistic(),a?.onOptimistic()},onSuccess:()=>{r?.onSuccess(),a?.onSuccess()},...r?{answers:r.answers,displayText:g}:{},...a?{todos:a.todos}:{},...b===`queue`&&!t&&(_||c?.deliveryInFlight===!0)?{hold:!0}:{},...v?{}:{failureToast:e=>`Send failed — ${e.slice(0,160)}`},supersedes:UC(C,h),onRollback:t=>{cs(C,w),Ds(e,s),VC(C,{...t,text:w}),r?.onRollback(t.kept),i?.onRollback(),a?.onRollback()}};O.submit(h,{...y,interrupt:t}),d?.sent?.()}let ae=(0,q.useRef)(H);ae.current=H;let oe=ee?void 0:u?.composer;return(0,q.useEffect)(()=>oe?(oe.set(()=>ae.current()),()=>oe.set(null)):void 0,[oe]),ee?(0,X.jsxs)(`div`,{"data-thread-composer-box":Iw,"data-thread-action-bar":``,"data-phone-thread-bar":``,children:[(0,X.jsx)(za,{contextTokens:L,id:n,surface:Iw,value:w,onChange:T,onSubmit:()=>H(),onInterruptSubmit:R?()=>H(!0):void 0,slashSuggest:j,placeholder:c?.foreign?x:V?v?`Steer…`:`Queue…`:`Reply…`,busy:D.busy,fileDrop:o,phone:{layout:`bar`,tools:D.phoneTools,idlePrimary:re&&c?e=>(0,X.jsx)(lw,{thread:c,compact:e}):void 0,override:i,onLongPressSend:R?()=>H(!0):void 0}}),D.status,k&&(0,X.jsx)(m,{backend:k,onClose:()=>A(null),onAuthed:()=>A(null)}),N&&(0,X.jsx)(ua,{backend:N,onClose:()=>P(null)})]}):(0,X.jsxs)(`div`,{"data-thread-composer-box":Iw,"data-thread-action-bar":``,className:t,children:[r,(0,X.jsx)(za,{contextTokens:L,id:n,surface:Iw,value:w,onChange:T,onSubmit:()=>H(),onInterruptSubmit:R?()=>H(!0):void 0,slashSuggest:j,placeholder:x,busy:D.busy,footer:D.footer,railLead:ie,fileDrop:o,send:c?.foreign?void 0:{mode:b,onMode:Aw,running:_,staged:p,steerable:v}}),D.status,k&&(0,X.jsx)(m,{backend:k,onClose:()=>A(null),onAuthed:()=>A(null)}),N&&(0,X.jsx)(ua,{backend:N,onClose:()=>P(null)})]})}function zw({slug:e,above:t,phoneBarOverride:n,phoneChrome:r}){return We(e)?(0,X.jsx)(Lw,{slug:e,id:`followup-input`,className:`shrink-0 px-3 py-3`,above:t,phoneBarOverride:n,phoneChrome:r}):null}var Bw=24,Vw=2;function Hw(e,t,n,r,i,a){return(n-e)*(a-t)-(r-t)*(i-e)}function Uw(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 Ww(e,t,n){if(Math.hypot(t.x-e.x,t.y-e.y)<Vw)return!1;if(t.x>=n.left&&t.x<=n.right&&t.y>=n.top&&t.y<=n.bottom)return!0;let r=Uw(e,n);if(!r)return!1;let[i,a,o,s]=r,c=Hw(e.x,e.y,i,a,t.x,t.y),l=Hw(i,a,o,s,t.x,t.y),u=Hw(o,s,e.x,e.y,t.x,t.y);return!((c<0||l<0||u<0)&&(c>0||l>0||u>0))}function Gw(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 Kw(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)>=Bw){i=n;break}}return Ww(i,r,n)}function qw(e,t=[],n=[]){let{todos:r,agents:i,children:a,shells:o,prs:s,issues:c,commands:l,timers:u,files:d,links:f}=Q_(e,t,n),p=r.filter(e=>!e.done).length;return[{key:`todo`,n:e.runtime===`turn-idle`&&e.lastFence?.kind===`awaiting`&&ks(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(ms)},{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 Jw({slug:e,subAgents:t,className:n=`px-1 pt-1.5`,density:r=`card`}){let i=Jr(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)(sn,{kind:`AGENT`,label:t.label,state:t.state,density:r,depth:t.depth,startedAt:t.startedAt,parentSlug:e,onOpen:t.id?()=>es(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:aa(e,t)},t.id??`${t.startedAt}-${n}`))})}var Yw=300,Xw=50,Zw=480,Qw=12,$w=6,eT={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 tT({thread:e,transcriptShells:t=[],only:n}){let r=nC(e),i=x(r.id),[a,o]=(0,q.useState)(null),s=(0,q.useRef)(void 0),c=(0,q.useRef)(void 0);(0,q.useEffect)(()=>()=>{clearTimeout(s.current),clearTimeout(c.current)},[]);let l=qw(r,t,i).filter(e=>!n||n.includes(e.key)),u=(0,q.useRef)(null),d=(0,q.useRef)([]),f=a!==null,p=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!f){p.current=null;return}let e=e=>{d.current=Gw(d.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}),d.current=[]}},[f]);let m=(0,q.useRef)(null),h=(0,q.useCallback)(e=>{e&&(m.current=e)},[]),g=()=>{let e=m.current?.isConnected?m.current.getBoundingClientRect():void 0;return!!e&&Kw(d.current,performance.now(),e)},_=a!==null&&!l.some(e=>e.key===a);if((0,q.useEffect)(()=>{_&&(clearTimeout(s.current),clearTimeout(c.current),o(null))},[_]),l.length===0)return null;let v=e=>{clearTimeout(s.current),clearTimeout(c.current),o(e)},y=e=>{if(clearTimeout(s.current),clearTimeout(c.current),a===null||a===e||!g()){o(e);return}c.current=setTimeout(()=>y(e),Xw)},b=()=>{clearTimeout(s.current),clearTimeout(c.current)},S=()=>{clearTimeout(s.current),clearTimeout(c.current);let e=()=>{g()?s.current=setTimeout(e,Xw):o(null)};s.current=setTimeout(e,Yw)};return(0,X.jsxs)(`div`,{"data-queue-ops-summary":!0,ref:u,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`}),l.map(e=>(0,X.jsx)(nT,{group:e,line:u,open:a===e.key,onOpen:()=>v(e.key),onHover:t=>{d.current=Gw(d.current,{x:t.clientX,y:t.clientY,at:performance.now()}),y(e.key)},onHoverPanel:b,onCloseSoon:S,registerPanel:h,caretAt:p,onOpenChange:t=>t?v(e.key):o(t=>t===e.key?null:t),children:e.key===`todo`?(0,X.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,X.jsx)(Sv,{thread:r})}):e.key===`agent`?(0,X.jsx)(Jw,{slug:r.id,subAgents:r.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)(dt,{parent:r.id,childThreads:i,density:`panel`})}):e.key===`command`||e.key===`timer`?(0,X.jsx)(oT,{thread:r,kind:e.key}):(0,X.jsx)(Ek,{slug:r.id,includeAgents:!1,only:e.key,transcriptShells:t,className:``,density:`panel`})},e.key))]})}function nT({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)(Wn,{open:n,onOpenChange:l,children:[(0,X.jsx)(Se,{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)(iT,{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)($e,{side:`top`,align:`end`,sideOffset:0,"data-queue-ops-panel":e.key,"aria-label":eT[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:ko(t.current?.getBoundingClientRect().width??Zw,Zw)}:void 0,children:[(0,X.jsx)(`div`,{className:`max-h-[min(20rem,50vh)] overflow-y-auto scrollbar-none`,children:u}),(0,X.jsx)(rT,{count:d,line:t,caretAt:c})]})]})}function rT({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)-Qw/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:Qw,height:$w,viewBox:`0 0 ${Qw} ${$w}`,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 iT({kind:e,states:t}){switch(e){case`todo`:return(0,X.jsx)(ac,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`});case`agent`:case`child`:return(0,X.jsx)(aT,{hue:`agent`,states:t});case`shell`:return(0,X.jsx)(aT,{hue:`shell`,states:t});case`pr`:case`issue`:return(0,X.jsx)(aT,{hue:`github`,states:t});case`command`:case`timer`:return(0,X.jsx)(aT,{hue:`github`,states:t});case`file`:return(0,X.jsx)(En,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`});case`link`:return(0,X.jsx)(Zs,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`})}}function aT({hue:e,states:t}){return t.some(to)?(0,X.jsx)(Li,{hue:e}):(0,X.jsx)(`span`,{className:t.includes(`rested`)?rt:Ye})}function oT({thread:e,kind:t}){let n=Oi(),{commands:r,timers:i}=Q_(e);return(0,X.jsx)(`div`,{className:`flex flex-col`,children:t===`timer`?i.map(e=>(0,X.jsx)(sn,{kind:`TIMER`,label:e.timer?.prompt?.split(`
135
- `)[0]||e.target,state:`running`,density:`panel`,counter:vy(e,n),title:_y(e)},e.id)):r.map(t=>(0,X.jsx)(sn,{kind:`COMMAND`,label:by(t),state:`running`,density:`panel`,startedAt:t.createdAt,counter:Cy(t),title:Sy(t,n),onOpen:t.command?.monitor?()=>wr(e.id,t.target,{label:by(t)}):void 0},t.id))})}function sT(e,t){let n=e.trim();if(!(!n||n===t.trim()))return n}function cT(e,t){let n=e.trim();return!n||n===t||n===`Untitled thread`||n===`Spinning up a thread…`?``:n}function lT(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 uT(e,t){return new Promise(n=>{hn(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 dT(){return qr(w().data??null)}function fT(e,t){return!t||e.kind!==`session`||e.foreign||e.backend===`codex`||e.backend===`acp`||e.backend===`opencode`?!1:e.runtime!==`exited`}function pT({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,m]=(0,q.useState)(``),[h,g]=(0,q.useState)(``),_=(0,q.useId)(),y=(0,q.useId)(),b=(0,q.useId)(),x=Cn(e),S=e.snoozePrompt?.trim(),C=(0,q.useMemo)(()=>p(new Date(Date.now()+6e4)),[c]),w=(0,q.useMemo)(()=>ae.map(e=>{let t=la(mt(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]),T=(0,q.useMemo)(()=>z(e),[n,e.runtime,e.wakesOnItsOwn]),E=!x&&jt(e),D=!!x||E,O=x?S?`Bumps ${la(x)}`:`Snoozed until ${la(x)}`:E?`Snoozed until activity`:null,k=O?S?`${O}\n${S}`:O:`Snooze`;async function A(){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 j(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`} · ${la(n)}`),t?.()):G(`Snooze cleared`),l(!1),g(``)}catch(e){let t=e instanceof Error?e.message:`Snooze failed`;G(t.slice(0,100)),g(t)}finally{s(!1)}}function M(){d(p(new Date(x??mt(`1d`)))),m(e.snoozePrompt??``),g(``),l(!0)}function N(){let e=ea(u);if(!e.ok){g(e.message);return}let t=f.trim();if(t.length>4e3){g(`Prompt is too long (${t.length}/${io})`);return}j(e.until,t||null)}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(ue,{open:n,onOpenChange:e=>{r(e),e||a(!0)},children:[(0,X.jsx)(me,{label:k,multiline:!!S,disabled:n||i,children:(0,X.jsx)(v,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,disabled:o,"data-snooze-menu":!0,"data-snoozed":D?`true`:`false`,"aria-label":O??`Snooze`,"aria-description":x&&S?S:void 0,onMouseDown:e=>e.preventDefault(),onBlur:()=>a(!1),onPointerLeave:()=>a(!1),className:`${D?Dt.replace(/(^| )text-muted( |$)/,`$1text-attention-90$2`):Dt} ${n?`bg-panel-2`:``}`,children:o?(0,X.jsx)(Ie,{size:14,strokeWidth:2,className:`animate-spin`}):(0,X.jsx)(Ra,{size:14,strokeWidth:2})})})}),(0,X.jsxs)(ne,{align:`end`,children:[(0,X.jsx)(`div`,{className:`px-2.5 pb-1 pt-1.5 text-[11px] text-muted-60`,children:O??`Snooze`}),D&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(It,{onSelect:()=>void j(null),icon:(0,X.jsx)(zs,{size:12}),children:`Wake now`}),(0,X.jsx)(ma,{})]}),w.map(e=>(0,X.jsx)(It,{onSelect:()=>void j(mt(e.value)),icon:(0,X.jsx)(Ra,{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)(It,{onSelect:()=>void A(),disabled:!T.enabled,children:(0,X.jsx)(me,{label:T.enabled?``:T.reason,side:`left`,disabled:T.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)(Ra,{size:12})}),(0,X.jsx)(`span`,{children:`Until activity`})]})})}),(0,X.jsx)(ma,{}),(0,X.jsx)(It,{onSelect:M,children:`Custom time & prompt…`})]})]}),(0,X.jsx)(ft,{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:b,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)(Ie,{size:12,className:`animate-spin`}),f.trim()?`Snooze & bump`:`Snooze`]})]}),children:(0,X.jsxs)(`form`,{id:b,className:`flex flex-col gap-2.5 p-4`,onSubmit:e=>{e.preventDefault(),N()},children:[(0,X.jsx)(`label`,{htmlFor:_,className:`text-[11px] font-medium text-muted`,children:`Wake at this local time`}),(0,X.jsx)(`input`,{id:_,type:`datetime-local`,required:!0,min:C,value:u,onChange:e=>{d(e.target.value),g(``)},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:y,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:y,"data-1p-ignore":!0,autoFocus:!0,rows:3,maxLength:io,placeholder:`e.g. Check whether CI went green and land it if so.`,value:f,onChange:e=>{m(e.target.value),g(``)},onKeyDown:e=>{ts({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(),N())},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.`}),h&&(0,X.jsx)(`p`,{role:`alert`,className:`text-[11px] text-danger`,children:h})]})})]})}function mT({thread:e,onArchived:t,onDismissCancel:n,onSnoozed:r}){let i=oo(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)(hT,{}):(0,X.jsxs)(X.Fragment,{children:[i.snooze&&(0,X.jsx)(pT,{thread:e,onSnoozed:r}),(0,X.jsx)(_T,{thread:e,onArchived:t,onDismissCancel:n,iconOnly:!0})]})]}):null}function hT(){return(0,X.jsx)(gT,{"data-thread-done":``,check:!0,tooltip:`Marked done — send a message to reopen it`,children:`Done`})}function gT({check:e=!1,tooltip:t,children:n,...r}){return(0,X.jsx)(me,{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)(fi,{size:12}),n]})})}function _T({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,pinChoice:s}){let{doneUnpins:c}=un(yn),l=c&&Nn(e)?`Mark as done & unpin`:`Mark as done`,[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(void 0),g=(r,i)=>{d(!0),i&&t?.(),(r||ye(e))&&Sr(e.id),U.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:r}).then(r=>{if(r.needsConfirmation){Di(e.id),i&&n?.(),h(r.hold),p(!0),d(!1);return}p(!1),De(`Done`,e),i||t?.()}).catch(t=>{Di(e.id),i&&n?.(),G(`Couldn’t finish: ${t.message.slice(0,80)}`),d(!1)})},_=!!t&&!!n&&ye(e);return(0,X.jsxs)(X.Fragment,{children:[o?(0,X.jsx)(me,{label:l,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>g(!1,_),disabled:u,"aria-label":l,onMouseDown:e=>e.preventDefault(),className:Dt,children:(0,X.jsx)(fi,{size:15,strokeWidth:2})})}):s&&Nn(e)?(0,X.jsx)(yT,{className:s,pending:u,children:(0,X.jsxs)(`button`,{type:`button`,"data-done-split-label":!0,onClick:()=>g(!1,_),disabled:u,"aria-label":l,title:l,onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-1 rounded-l-[inherit] py-1 pl-2.5 pr-[7px] font-medium outline-none transition-colors hover:bg-bg/10 focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:opacity-45`,children:[(0,X.jsx)(fi,{size:a,className:i}),l]})}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>g(!1,_),disabled:u,"aria-label":l,title:l,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)(fi,{size:a,className:i}),l]}),(0,X.jsx)(ft,{open:f,onOpenChange:e=>{u||p(e)},title:m?.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:u,onClick:()=>p(!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:u,onClick:()=>g(!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:[u&&(0,X.jsx)(Ie,{size:12,className:`animate-spin`}),m?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,X.jsx)(bT,{hold:m})})]})}var vT=[{unpins:!1,name:`Mark as done`,says:`It stays pinned at the top of the sidebar.`},{unpins:!0,name:`Mark as done & unpin`,says:`It leaves the pinned list and files under Done.`}];function yT({className:e,pending:t,children:n}){let{doneUnpins:i}=un(yn);return(0,X.jsxs)(`span`,{"data-done-split":!0,className:`flex items-stretch font-medium ${e}`,children:[n,(0,X.jsx)(`span`,{"aria-hidden":!0,className:`w-px shrink-0 bg-bg/10`}),(0,X.jsxs)(Si,{modal:!1,children:[(0,X.jsx)(ro,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,"data-done-split-menu":!0,disabled:t,"aria-label":`Choose what Mark as done does to the pin`,onMouseDown:e=>e.preventDefault(),className:`flex items-center rounded-r-[inherit] pl-[5px] pr-[6px] outline-none transition-colors hover:bg-bg/10 focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:opacity-45`,children:(0,X.jsx)(r,{size:12,strokeWidth:2.5})})}),(0,X.jsx)(xa,{children:(0,X.jsxs)(Xr,{"data-done-pin-choices":!0,side:`bottom`,align:`start`,sideOffset:6,className:`${Ja} w-[300px] rounded-lg p-1`,children:[(0,X.jsx)(qo,{value:i?`unpin`:`keep`,onValueChange:e=>{yn.doneUnpins=e===`unpin`},children:vT.map(e=>{let t=e.unpins===i;return(0,X.jsxs)(ai,{value:e.unpins?`unpin`:`keep`,"data-done-pin-choice":e.unpins?`unpin`:`keep`,className:`flex cursor-pointer select-none items-start gap-2 rounded-md px-2 py-1.5 text-left outline-none transition-colors data-[highlighted]:bg-panel-2`,children:[(0,X.jsx)(`span`,{className:`flex h-[18px] w-3.5 shrink-0 items-center justify-center text-fg`,children:t&&(0,X.jsx)(fi,{size:13,strokeWidth:2.5})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block text-[12px] font-medium leading-[18px] text-fg`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-[11.5px] leading-[16px] text-muted`,children:e.says})]})]},e.name)})}),(0,X.jsx)(`div`,{className:`px-2 pb-1 pt-1.5 text-[11px] leading-[15px] text-muted-70`,children:`Remembered for every Done in this browser.`})]})})]})]})}function bT({hold:e}){let t=Xe(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:Rs,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 xT({slug:e,onClose:t,onArchived:n,initialView:r=`actions`}){let i=un(W),a=ls(i.board,e),[o,s]=(0,q.useState)(r),c=Yr(t);if((0,q.useEffect)(()=>{i.board&&!a&&c()},[i.board,a,c]),!a)return null;let l=P(a);return(0,X.jsx)(_C,{title:`Thread actions: ${l}`,onRequestClose:()=>c(),dataAttr:`data-thread-actions-sheet`,children:o===`actions`?(0,X.jsx)(ST,{thread:a,title:l,setView:s,dismiss:c,onArchived:n}):o===`snooze`?(0,X.jsx)(wT,{thread:a,back:()=>s(`actions`),custom:()=>s(`snooze-custom`),dismiss:c}):o===`snooze-custom`?(0,X.jsx)(TT,{thread:a,back:()=>s(`snooze`),dismiss:c}):o===`goal`?(0,X.jsx)(ET,{thread:a,back:()=>s(`actions`)}):o===`todos`?(0,X.jsx)(DT,{thread:a,back:()=>s(`actions`)}):o===`files`?(0,X.jsx)(OT,{thread:a,back:r===`files`?void 0:()=>s(`actions`),dismiss:c}):(0,X.jsx)(jT,{thread:a,back:()=>s(`actions`),dismiss:c})})}function ST({thread:e,title:t,setView:n,dismiss:r,onArchived:i}){let a=R(),o=dT(),s=un(yn).snoozePreset,c=oo(e),l=e.kind===`session`&&e.foreign!==!0,u=Cn(e),d=e.recurringPrompt?.stopHook===!0||e.recurringPrompt?.heartbeat===!0||e.recurringPrompt?.postCompaction===!0,f=e.links??[],p=e.humanTodos??[],m=e.runtime===`running`||e.runtime===`spawning`,h=l&&O(e),g=fT(e,o),_=MT(e),v=[Me(e.context),_].filter(Boolean).join(` · `);return(0,X.jsxs)(`div`,{"data-thread-actions-list":!0,children:[(0,X.jsx)(FT,{children:t}),c.snooze&&(0,X.jsx)(PT,{data:`snooze`,icon:(0,X.jsx)(Ra,{size:19}),label:`Snooze`,value:u?la(u):St(s),chevron:!0,onClick:()=>n(`snooze`)}),l&&(0,X.jsx)(PT,{data:`goal`,icon:(0,X.jsx)(fw,{size:19,className:d?`text-attention-90`:void 0}),label:`Goal`,value:d?`on`:`off`,chevron:!0,onClick:()=>n(`goal`)}),p.length>0&&(0,X.jsx)(PT,{data:`todos`,icon:(0,X.jsx)(ac,{size:19}),label:`To-do`,value:String(p.filter(e=>!e.done).length),chevron:!0,onClick:()=>n(`todos`)}),f.length>0&&(0,X.jsx)(PT,{data:`files`,icon:(0,X.jsx)(En,{size:19}),label:`Files and links`,value:String(f.length),chevron:!0,onClick:()=>n(`files`)}),m&&c.archive&&(0,X.jsx)(_T,{thread:e,iconSize:19,iconClassName:`shrink-0 text-muted`,onArchived:()=>r(i),className:`${NT} !gap-[14px] !font-normal`}),(0,X.jsx)(`div`,{className:`my-1 h-px bg-border`}),l&&(0,X.jsx)(PT,{data:`rename`,icon:(0,X.jsx)(fe,{size:19}),label:`Rename`,onClick:()=>n(`rename`)}),(0,X.jsx)(PT,{data:`copy-link`,icon:(0,X.jsx)(be,{size:19}),label:`Copy link`,onClick:()=>{let t=new URL(et(e.id),location.origin).href;r(()=>{ta(t).then(()=>G(`Link copied`)).catch(e=>G(`Couldn’t copy: ${e.message.slice(0,80)}`))})}}),h&&(0,X.jsx)(PT,{data:`retry`,icon:(0,X.jsx)(pt,{size:19}),label:`Retry`,onClick:()=>r(()=>void xs(a,e.id))}),g&&(0,X.jsx)(PT,{data:`restart-worker`,icon:(0,X.jsx)(xt,{size:19}),label:`Restart worker`,onClick:()=>r(()=>void uT(a,e.id))}),v&&(0,X.jsx)(`div`,{"data-thread-actions-foot":!0,className:`px-[18px] pt-2.5 text-[12.5px] leading-[17px] text-muted`,children:v})]})}function CT(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`} · ${la(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 wT({thread:e,back:t,custom:n,dismiss:r}){let i=un(yn).snoozePreset,a=Cn(e),{busy:o,apply:s}=CT(e,r),c=e=>{yn.snoozePreset=e,s(mt(e))};return(0,X.jsxs)(`div`,{"data-thread-actions-snooze":!0,children:[(0,X.jsx)(IT,{back:t,children:`Snooze`}),a&&(0,X.jsxs)(`p`,{className:`px-[18px] pb-2 text-[13px] text-muted`,children:[`Snoozed until `,la(a).replace(/^(Today|Tomorrow)/,e=>e.toLowerCase())]}),ae.map(e=>(0,X.jsx)(PT,{data:`snooze-${e.value}`,disabled:o,icon:(0,X.jsx)(Ra,{size:19}),label:e.label,value:e.detail,trailing:e.value===i?(0,X.jsx)(fi,{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)(PT,{data:`snooze-custom`,disabled:o,icon:(0,X.jsx)(fe,{size:19}),label:`Custom time & prompt…`,chevron:!0,onClick:n}),a&&(0,X.jsx)(PT,{data:`snooze-wake`,disabled:o,icon:(0,X.jsx)(pt,{size:19}),label:`Wake now`,onClick:()=>void s(null)})]})}function TT({thread:e,back:t,dismiss:n}){let r=un(yn).snoozePreset,i=Cn(e),{busy:a,error:o,setError:s,apply:c}=CT(e,n),[l,u]=(0,q.useState)(()=>p(new Date(i??mt(r)))),[d,f]=(0,q.useState)(e.snoozePrompt??``),m=(0,q.useMemo)(()=>p(new Date(Date.now()+6e4)),[]),h=(0,q.useId)(),g=(0,q.useId)(),_=()=>{let e=ea(l);if(!e.ok)return s(e.message);let t=d.trim();if(t.length>4e3)return s(`Prompt is too long (${t.length}/${io})`);c(e.until,t||null)};return(0,X.jsxs)(`form`,{"data-thread-actions-snooze-custom":!0,className:`flex flex-col`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,X.jsx)(IT,{back:t,children:`Custom snooze`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 px-[18px]`,children:[(0,X.jsx)(`label`,{htmlFor:h,className:`text-[13px] font-medium text-muted`,children:`Wake at this local time`}),(0,X.jsx)(`input`,{id:h,type:`datetime-local`,required:!0,min:m,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:g,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:g,"data-1p-ignore":!0,rows:3,maxLength:io,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)(Ie,{size:16,className:`animate-spin`}),d.trim()?`Snooze and bump`:`Snooze`]})]})]})}function ET({thread:e,back:t}){return(0,X.jsxs)(`div`,{"data-thread-actions-goal":!0,children:[(0,X.jsx)(IT,{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)(Ew,{thread:e,armed:e.recurringPrompt,close:t,heading:!1})})]})}function DT({thread:e,back:t}){return(0,X.jsxs)(`div`,{"data-thread-actions-todos":!0,children:[(0,X.jsx)(IT,{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)(Sv,{thread:e,sends:!0})})]})}function OT({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)(IT,{back:t,count:r.length,children:`Files and links`}):(0,X.jsx)(FT,{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)(kT,{link:e,dismiss:n},e.id))]})}function kT({link:e,dismiss:t}){let n=e.kind===`link`,r=n&&we(e.target),i=un(W).board?.projectDir,a=n?r?`${An(e.target)} — not reachable from this phone`:An(e.target):AT(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)(Zs,{size:19}):(0,X.jsx)(En,{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)(Kt,{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 AT(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 jT({thread:e,back:t,dismiss:n}){let r=P(e),[i,a]=(0,q.useState)(()=>cT(r,e.id)),o=(0,q.useRef)(null),s=vn({mutationFn:t=>U.renameThread({slug:e.id,title:t})}),c=vn({mutationFn:()=>U.aiRenameThread({slug:e.id})}),l=lT(e);(0,q.useEffect)(()=>{let e=requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>cancelAnimationFrame(e)},[]);let u=()=>{let e=sT(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)(IT,{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)(Ie,{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)(PT,{data:`ai-rename`,disabled:c.isPending,icon:c.isPending?(0,X.jsx)(Ie,{size:19,className:`animate-spin`}):(0,X.jsx)(hc,{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 MT(e){let t=!!(e&&!e.foreign&&e.kind===`session`),n=Is(),r=H({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=nn([{id:e.backend??`claude`,label:``,options:r.data?.options??[]}],{model:i,effort:a},``,e.runningModelLabel);return[[o.name,o.edition].filter(Boolean).join(` `)||null,Kn(o.effort)].filter(Boolean).join(` · `)||null}var NT=`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 PT({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:NT,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)(Kt,{size:15,className:`text-muted-70`}),i]})]})}function FT({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 IT({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)(Gs,{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 LT({slug:e,onClose:t}){let n=We(e),[r,i]=(0,q.useState)(!1),a=Oi(),o=ar(e,{poll:n?.runtime===`running`||n?.runtime===`spawning`}),s=(0,q.useMemo)(()=>qe(o.data?.messages??[]),[o.data]),c=MT(n);if(!n)return null;let l=fo(n),u=tt(n,l,s,a),d=l===`needs-you`?`font-semibold text-accent`:l===`working`?`font-semibold text-live`:``,f=P(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:()=>{Pi()?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)(Lo,{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:f,children:f}),(0,X.jsxs)(`div`,{"data-mobile-thread-subtitle":!0,"data-state":l,className:`truncate text-[13px] text-muted`,children:[(0,X.jsx)(`span`,{className:d,children:Rn[l]}),u&&(0,X.jsxs)(X.Fragment,{children:[` · `,u]}),c&&(0,X.jsxs)(X.Fragment,{children:[` · `,c]})]})]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Thread actions`,"aria-haspopup":`dialog`,"aria-expanded":r,"data-mobile-thread-more":!0,onClick:()=>i(!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)(Hn,{size:21,strokeWidth:2.1})}),r&&(0,X.jsx)(xT,{slug:e,onClose:()=>i(!1),onArchived:()=>Tn(e)})]})}function RT({thread:e}){let t=R(),[n,r]=(0,q.useState)(!1);return fT(e,dT())?(0,X.jsx)(me,{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),uT(t,e.id).finally(()=>r(!1))},className:`${Dt} mr-[2px]`,children:n?(0,X.jsx)(Ie,{size:14,strokeWidth:2,className:`animate-spin`}):(0,X.jsx)(xt,{size:14,strokeWidth:2})})}):null}function zT(e){return ve(e)??br(`/`)}function BT(e){Xo(zT(e),{viewTransition:!ee()})}function VT({slug:e,label:t=`Exit fullscreen`}){let n=ka()?Ti(e):zT(e);function r(t){if(Ce(t)){if(t.preventDefault(),ka()){Cs(!1);return}BT(e)}}return(0,X.jsx)(me,{label:t,children:(0,X.jsx)(`a`,{href:n,"aria-label":t,"data-standalone-return":!0,onMouseDown:e=>e.preventDefault(),onClick:r,className:Dt,children:(0,X.jsx)(uc,{size:14})})})}function HT({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)(WT,{label:o?`Expand`:`Collapse`,icon:o?qs:Ks,size:13,onClick:a}),(0,X.jsx)(RT,{thread:e}),r&&(0,X.jsx)(WT,{label:`Frizz document`,icon:En,size:14,onClick:r}),t&&(0,X.jsx)(yt,{slug:e.id}),n&&(0,X.jsx)(VT,{slug:e.id}),d?O(e)?(0,X.jsx)(UT,{slug:e.id}):null:(0,X.jsx)(`div`,{className:`ml-1`,children:(0,X.jsx)(wn,{slug:e.id,onDone:i,doneBusy:s,onMutateStart:c,onApplied:l,onFailed:u})})]})}function UT({slug:e}){let t=R(),[n,r]=(0,q.useState)(!1);return(0,X.jsx)(me,{label:`Retry — resume this session where it left off`,children:(0,X.jsxs)(`button`,{onClick:()=>{r(!0),xs(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)(Ie,{size:12,className:`animate-spin`}):(0,X.jsx)(pt,{size:12}),`Retry`]})})}function WT({label:e,icon:t,size:n,busy:r,...i}){return(0,X.jsx)(me,{label:e,children:(0,X.jsx)(`button`,{...i,"aria-label":e,onMouseDown:e=>e.preventDefault(),className:Dt,children:r?(0,X.jsx)(Ie,{size:n,strokeWidth:2,className:`animate-spin`}):(0,X.jsx)(t,{size:n,strokeWidth:2})})})}var GT=1.25,KT=7.5-GT/2,qT=2*Math.PI*KT;function JT(e,t){return Math.max(0,Math.min(100,Math.floor(e/t*100)))}var YT=150;function XT(e){return!!e.context&&e.context.window>0}function ZT({thread:e}){let t=e.context;if(!t||!XT(e))return null;let n=nE(e,t.tokens);return(0,X.jsx)(QT,{context:t,action:Wa(e)?t=>(0,X.jsx)(rE,{thread:e,compacting:n,onRequested:t}):void 0})}function QT({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),YT)},l=e=>{a.current?.contains(e.target)&&e.preventDefault()},u=JT(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)(Wn,{open:n,onOpenChange:r,children:[(0,X.jsx)(Se,{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:KT,fill:`none`,stroke:`currentColor`,strokeOpacity:.3,strokeWidth:GT}),(0,X.jsx)(`circle`,{cx:`8`,cy:`8`,r:KT,fill:`none`,stroke:`currentColor`,strokeWidth:GT,strokeDasharray:`${qT*d} ${qT}`,transform:`rotate(-90 8 8)`})]}),(0,X.jsxs)(`span`,{children:[u,`% context`]})]})}),(0,X.jsxs)($e,{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 $T(e){return e.runtime===`running`||e.runtime===`spawning`||e.runtime===`perm-prompt`}var eE=new Map,tE=2*6e4;function nE(e,t){let n=e.sessionId;if(!n)return!1;let r=eE.get(n);return r?!$T(e)&&(r.tokens!==t||e.lastActivityAt!==r.activity)||Date.now()-r.at>tE?(eE.delete(n),!1):!0:!1}function rE({thread:e,compacting:t,onRequested:n}){let[r,i]=(0,q.useState)(!1),a=e.context?.tokens??0,o=$T(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(()=>{eE.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)(Ie,{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 iE({thread:e}){let t=uo(e.id);return(0,X.jsx)(aE,{"data-thread-header-facts":``,lead:t?(0,X.jsx)(oE,{slug:t}):null,lastActiveAt:ln(e),fallbackAt:e.spawnedAt,reading:XT(e)?(0,X.jsx)(ZT,{thread:e}):null})}function aE({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)(Fe,{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 oE({slug:e}){let t=H({queryKey:[`projectsList`],queryFn:()=>U.projectsList()}).data?.find(t=>t.slug===e),n=t?.name??e,r=zo(e);function i(e){e.stopPropagation(),Ce(e)&&(e.preventDefault(),Xo(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)(fs,{project:t,size:14}):null,(0,X.jsx)(`span`,{className:`truncate`,children:n})]})}function sE({thread:e,hidden:t=!1}){let n=vn({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=lT(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)(me,{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)(Ie,{size:12,className:`animate-spin`}):(0,X.jsx)(hc,{size:12})})})}function cE({thread:e,className:t=``}){let n=e.id,r=vn({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=P(e);function d(){a(!1),s(``)}function f(){let e=sT(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(cT(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)(sE,{thread:e,hidden:i})]})}function lE(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 uE={completed:`finished`,killed:`stopped`,failed:`failed`};function dE(e){let t=uE[e.agentStatus??`completed`],n=e.agentElapsedMs===void 0?void 0:vo(e.agentElapsedMs);return{outcome:t,tail:`${t}${n?` · ${n}`:``}`}}var fE=e=>e===void 0?void 0:jr(e),pE=e=>{if(e!==void 0)return vo(e)||void 0};function mE(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=fE(n);return{label:t===`completed`?void 0:uE[t],duration:pE(n),tone:r?`failed`:`muted`,title:`${e?`Stopped`:r?`Failed`:`Ran for`}${e||r?` after`:``} ${i??`an unknown time`}`}}if(r){let e=fE(i);return{label:void 0,duration:pE(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=fE(o);return{label:c?uE.killed:s?uE.failed:void 0,duration:pE(o),tone:s?`failed`:`muted`,title:`${c?`Stopped after`:s?`Failed after`:`Ran for`} ${l??`an unknown time`}`}}var hE=`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`,gE=`${Jn} -mt-[1em] self-baseline`,_E=`h-[1em] w-[1em] shrink-0 translate-y-[calc(0.5em_-_0.5cap)] text-muted-45`,vE=`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 yE({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:La,children:(0,X.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(t?Zs:En,{"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:vE,onClick:e=>e.stopPropagation(),children:n},e.id):(0,X.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${vE} cursor-pointer`,onClick:t=>{t.stopPropagation(),I(e.target)},children:n},e.id)})})}function bE({links:e,panel:t=!1}){return e.length?t?(0,X.jsx)(yE,{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:Rs,children:`⤷`}),(0,X.jsx)(`span`,{className:gE,children:(0,X.jsx)(t?Zs:En,{"aria-hidden":!0,className:_E})}),(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:hE,onClick:e=>e.stopPropagation(),children:n},e.id):(0,X.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${hE} cursor-pointer`,onClick:t=>{t.stopPropagation(),I(e.target)},children:n},e.id)})}):null}var xE=`text-[14px] leading-5 text-muted`,SE=`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 CE(e){return`${SE} ${e?`-mx-[0.208em] rotate-90`:`-mx-[0.333em]`}`}var $=q.createElement;function wE({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,$(TE,{label:`Redacted command preview`,text:e.command.preview}),e.command.actions?$(EE,{actions:e.command.actions}):null,e.capabilities?$(OE,{capabilities:e.capabilities}):null):e.kind===`file-approval`?$(q.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},ME(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?$(TE,{label:`Plain-text diff preview`,text:e.diffPreview}):null,e.changes?$(DE,{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?$(OE,{capabilities:e.capabilities}):null)}function TE({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 EE({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`},jE(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,$(TE,{label:`${jE(e.kind)} command detail`,text:e.commandPreview})))))}function DE({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`},ME(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?$(TE,{label:`${ME(e.operation)} plain-text diff`,text:e.diffPreview}):null))))}function OE({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`},$(kE,{capability:e})))))}function kE({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?$(AE,{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),$(AE,{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`),$(AE,{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`),$(AE,{label:`Hosts`,values:e.hosts}))}function AE({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 jE(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 ME(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 NE(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 PE={semantic:`approve`,label:`Approve once`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`},FE={semantic:`approve`,label:`Approve for session`,order:20,tone:`primary`,durable:!0,scope:`Persists for later matching requests in this thread session.`},IE={semantic:`approve`,label:`Grant for turn`,order:10,tone:`primary`,durable:!1,scope:`Applies to this turn only.`},LE={semantic:`approve`,label:`Grant for session`,order:20,tone:`primary`,durable:!0,scope:`Persists until this thread session ends.`},RE={semantic:`deny`,label:`Deny`,order:70,tone:`danger`,durable:!1,scope:`Rejects this request.`},zE={semantic:`decline`,label:`Decline`,order:70,tone:`danger`,durable:!1,scope:`Declines this request.`},BE={semantic:`cancel`,label:`Cancel request`,order:80,tone:`neutral`,durable:!1,scope:`Cancels this pending request.`};function VE(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`?PE:n===`acceptForSession`&&r===`approve`?FE:(n===`decline`||n===`deny`)&&r===`deny`?RE:n===`cancel`&&r===`cancel`?BE:void 0;if(e.kind===`permission-approval`)return n===`grant-turn`&&r===`approve`?IE:n===`grant-session`&&r===`approve`?LE:(n===`deny`||n===`decline`)&&r===`deny`?RE:n===`cancel`&&r===`cancel`?BE: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`?zE:n===`cancel`&&r===`cancel`?BE: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 zE;if(n===`cancel`&&r===`cancel`)return BE}function HE(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=VE(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 UE(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 WE(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 GE(e,t){let n=e.options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t));return n<0?``:String(n)}function KE(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?``:GE(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 qE(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 JE(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=hs(i,a);e?r[i.id]=`Value ${e}.`:n[i.id]=a}}if(Object.keys(r).length>0)return{errors:r};let i=ws.safeParse(n);return i.success?{errors:r,values:i.data}:{errors:r,formError:`The response is too large or contains invalid values.`}}function YE(e,t){return JSON.stringify([e,t??null])}function XE(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)=>`${xg(t)} ${e.label}`),recommendedIdxs:[]},...e?{optionFieldId:e.id}:{},optionValues:r.map(e=>e.value),...t?{notesFieldId:t.id}:{}}}function ZE(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=XE(r,a);if(!e)return null;n.push(e)}else if(r.input===`text`||r.input===`multiline`){let e=XE(void 0,r);if(!e)return null;n.push(e)}else return null}return n.length>0?n:null}function QE(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)=>`${xg(t)} ${e.label}${e.description?` — ${e.description}`:``}`),recommendedIdxs:[]},chosenIdxs:n,text:r}}function $E(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 eD(e){let t=e instanceof Error?e.message:`The request could not be updated.`;return t.length>240?`${t.slice(0,239)}…`:t}function tD(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`frizz-response-${Date.now()}-${Math.random().toString(36).slice(2)}`}function nD({thread:e,className:t=``,autoFocusFirst:n=!1}){let r=pe(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:`${em} 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:eD(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)(iD,{record:e,autoFocus:n&&t===0,siblings:a},e.id))}):null}function rD({record:e,questions:t,autoFocus:n,siblings:r}){let i=R(),a=Is(),o=cD(e,r),s=(0,q.useRef)(null),c=(0,q.useRef)(new Map),l=B(),u=NE(e.delivery?.effect),d=(0,q.useMemo)(()=>HE(e).find(e=>e.semantic===`answer`),[e]),f=oe(t.flatMap(t=>t.notesFieldId?[fn.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(fn.interaction(l,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId))??``:``})),g=$E(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=vn({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),Ta(i,t.interaction),i.invalidateQueries({queryKey:Qa(e.owner.threadSlug,e.owner.sessionId)}),i.invalidateQueries({queryKey:_i(e.owner.threadSlug,e.owner.sessionId,e.id)})},onError:t=>{ei(i,e),o.rollback(),v(eD(t)),U.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{Ta(i,t),i.setQueryData(_i(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t}),i.invalidateQueries({queryKey:Qa(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}}),S=()=>{if(!d||!g||x.isPending||y||!u.actionsEnabled)return;v(void 0);let e=YE(d.id,g),t=c.current.get(e)??tD();c.current.set(e,t),o.release(!0),x.mutate({decisionId:d.id,values:g,responseId:t})},C=(t,n)=>{t.notesFieldId&&j.set(fn.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)(oS,{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)(lt,{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 iD({record:e,autoFocus:t=!1,siblings:n}){let r=(0,q.useMemo)(()=>ZE(e),[e]),i=n??[e];return r?(0,X.jsx)(rD,{record:e,questions:r,autoFocus:t,siblings:i}):(0,X.jsx)(lD,{record:e,autoFocus:t,siblings:i})}function aD(e){return e.semantic!==`cancel`}var oD=new Set,sD=new Set;function cD(e,t){let n=(0,q.useContext)(pv),r=e.owner.threadSlug;return{release:i=>{oD.add(e.id),i&&t.every(t=>t.id===e.id||oD.has(t.id)||t.delivery?.effect===`sending`)&&(sD.add(r),gs(r),(n?.sent??n?.dismiss)?.())},rollback:()=>{oD.delete(e.id),sD.delete(r)&&(Ts(r),n?.cancel())}}}function lD({record:e,autoFocus:t=!1,siblings:n}){let r=R(),i=Is(),a=cD(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),f=B(),p=l.filter(e=>!e.secret&&(e.input===`text`||e.input===`multiline`)).map(t=>fn.interaction(f,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.id)),m=oe(p),[h,g]=(0,q.useState)(()=>KE(l)),_=(0,q.useMemo)(()=>{let t={...h};return l.forEach(n=>{if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=fn.interaction(f,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id);t[n.id]=m.get(r)??``}}),t},[l,h,m,f,e.id,e.owner]),[v,y]=(0,q.useState)({}),[b,x]=(0,q.useState)(),[S,C]=(0,q.useState)(),[w,T]=(0,q.useState)(!1),[E,D]=(0,q.useState)(),[O,k]=(0,q.useState)(!1),A=NE(e.delivery?.effect),M=(0,q.useMemo)(()=>HE(e),[e]).filter(e=>!(u&&e.requiresValues)),N=e.allowedDecisions.length-M.length,P=(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`&&j.set(fn.interaction(f,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id),r)}g(t)},[l,f,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)(()=>{A.actionsEnabled||(D(void 0),k(!1))},[A.actionsEnabled]);let F=vn({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(YE(n.decision.id,n.values)),x(void 0),D(void 0),k(!1),T(!0),p.forEach(e=>j.clear(e)),C(t.waitingForProvider?`Response sent. Waiting for the provider to acknowledge it…`:`Request completed.`),Ta(r,t.interaction),r.setQueryData(_i(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t.interaction}),r.invalidateQueries({queryKey:Qa(e.owner.threadSlug,e.owner.sessionId),exact:!0}),t.waitingForProvider&&window.setTimeout(()=>{r.invalidateQueries({queryKey:Qa(e.owner.threadSlug,e.owner.sessionId),exact:!0})},1e3)},onError:t=>{C(void 0),a.rollback(),x(eD(t)),ei(r,e),U.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{Ta(r,t),r.setQueryData(_i(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t}),t.delivery?.effect===`sending`?(x(void 0),C(void 0),T(!0)):t.delivery?.effect===`reconnect-required`?(x(void 0),C(void 0)):(t.lifecycle!==`pending`||t.recordRevision!==e.recordRevision)&&(x(void 0),C(t.lifecycle===`expired`?`This request expired.`:`This request changed in another client.`),r.invalidateQueries({queryKey:Qa(e.owner.threadSlug,e.owner.sessionId),exact:!0})),r.invalidateQueries({queryKey:Qa(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}});function I(e){if(!e.requiresValues){y({});return}let t=JE(l,_);return y(t.errors),t.formError?(x(t.formError),null):t.values?t.values:null}function L(e,t=!1){if(!A.actionsEnabled||F.isPending||w)return;x(void 0);let n=I(e);if(n===null)return;if(e.durable&&!t){D(e),k(!1);return}let r=YE(e.id,n),i=c.current.get(r)??tD();c.current.set(r,i),a.release(aD(e)),F.mutate({decision:e,values:n,responseId:i})}let z=M.find(e=>e.requiresValues&&e.tone===`primary`);function ee(e){e.preventDefault(),A.actionsEnabled&&z&&L(z)}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 ${em} 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)(gc,{"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:ee,onKeyDown:e=>{e.target instanceof HTMLButtonElement||ts({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(),A.actionsEnabled&&z&&L(z))},className:`min-w-0 px-4 py-3.5`,noValidate:!0,children:(0,X.jsxs)(`fieldset`,{disabled:!A.actionsEnabled,className:`min-w-0 border-0 p-0`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`Interaction request`}),(0,X.jsx)(dD,{record:e,instanceId:o,draft:_,setDraft:P,errors:v,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)(tc,{"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.`})]}),N>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)(d,{"aria-hidden":`true`,size:13,className:`mt-0.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[N===1?`One advertised choice`:`${N} advertised choices`,` cannot be safely labeled or delivered in Frizz and is not shown.`]})]}),E&&(0,X.jsxs)(`div`,{"data-durable-confirmation":!0,role:`group`,"aria-label":`Confirm ${E.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:E.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:O,onChange:e=>k(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:()=>{D(void 0),k(!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:!O||F.isPending,onClick:()=>L(E,!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 `,E.label.toLowerCase()]})]})]}),b&&(0,X.jsx)(`div`,{role:`alert`,className:`mt-3 break-words text-[11px] leading-snug text-danger-soft`,children:b}),(A.status??S)&&(0,X.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`mt-3 text-[11px] leading-snug text-muted`,children:A.status??S}),i&&(0,X.jsxs)(lt,{className:`mt-3 text-[12px] text-muted`,children:[`This has to be answered on `,i,`.`]}),A.actionsEnabled&&!E&&!w&&M.length>0&&!i&&(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap justify-start gap-2`,children:[M.map(e=>(0,X.jsxs)(`button`,{type:e===z?`submit`:`button`,"data-interaction-decision":e.id,disabled:F.isPending,"aria-describedby":e.durable?`${o}-scope-${e.id}`:void 0,onClick:e===z?void 0:()=>L(e),className:uD(e),children:[F.isPending?`Sending…`:e.label,e.durable&&(0,X.jsx)(`span`,{className:`sr-only`,children:`; persistent approval`})]},e.id)),M.filter(e=>e.durable).map(e=>(0,X.jsx)(`span`,{id:`${o}-scope-${e.id}`,className:`sr-only`,children:e.scope},`scope-${e.id}`))]}),!fD.has(e.payload.kind)&&(0,X.jsx)(hD,{record:e})]})})]})}function uD(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 dD({record:e,instanceId:t,draft:n,setDraft:r,errors:i,autoFocus:a}){let o=e.payload,s=(e,t)=>r(qE(n,e,t)),c;return c=o.kind===`command-approval`||o.kind===`file-approval`||o.kind===`permission-approval`?(0,X.jsx)(wE,{payload:o}):o.kind===`mcp-elicitation-url`?(0,X.jsx)(mD,{url:o.url}):(0,X.jsx)(gD,{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)(pD,{text:o.message}),(0,X.jsx)(`div`,{className:`message`in o&&o.message?`mt-3`:``,children:c})]})}var fD=new Set([`command-approval`,`file-approval`,`permission-approval`]);function pD({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 mD({url:e}){let t=oa(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)(Zs,{"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 hD({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:UE(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:WE(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 gD({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)(_D,{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 _D({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 vD(e,t=Date.now()){return e!==void 0&&Cn(e,t)!==void 0}function yD(){let[e,t]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function bD({thread:e}){let t=yD(),[n,r]=(0,q.useState)(!1),i=Cn(e,t);if(!i)return null;let a=Date.parse(i),o=la(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)(pm,{"data-snooze-card":!0,icon:Ra,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:Ia(a-t)}),(0,X.jsx)(`p`,{className:mm,children:s?(0,X.jsxs)(X.Fragment,{children:[`Resumes `,o,` and sends: “`,zt(s),`”`]}):(0,X.jsxs)(X.Fragment,{children:[`Returns to the queue `,o,`.`]})}),e.foreign!==!0&&(0,X.jsx)(hm,{children:(0,X.jsx)(`button`,{type:`button`,"data-snooze-wake-now":!0,disabled:n,onClick:()=>void c(),className:`${bm} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}function xD(e){return e?.foreign&&e.pendingInteraction!==!0?e.pendingAsk:void 0}function SD(e,t){return e?.actionableInteraction===!0?!1:t||e?.runtime===`perm-prompt`}async function CD({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],ga(s,o)),o)}function wD(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 TD(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 ED(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function DD(e,t,n){let r=[],i=new Map,a=null;return e.forEach((e,o)=>{if(Jo(e)||t(e))return;let s=e.sourceId??ED(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 OD(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(!(Jo(t)||n(t)))return!!t.boundary||t.wake===!0||lE(t)!==void 0}return!0}function kD(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!OD(n,r,t))}var AD=(0,q.createContext)(null);function jD(){let e=(0,q.useContext)(fv),t=(0,q.useContext)(AD);return e??t}function MD({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1,pane:i}){We(e);let a=sr()&&n!==void 0,{splitFileViewer:o}=un(W);return(0,X.jsx)(PD,{slug:e,phone:a,railBeside:(i?i.railBeside===!0:r)&&o,pane:i,header:a?(0,X.jsx)(LT,{slug:e,onClose:n}):(0,X.jsx)(eO,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r,pane:i})})}var ND=[`todo`];function PD({slug:e,phone:t=!1,railBeside:n=!1,header:r,pane:i}){let a=We(e),o=ar(e,{poll:a?.runtime===`running`||a?.runtime===`spawning`}),s=R(),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}=XS(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=s_(p);x(e>0?p[e]?.sourceId??null:null)}let S=b?Math.max(0,p.findIndex(e=>e.sourceId===b)):0,C=Is(),w=(0,q.useMemo)(()=>C?m.filter(e=>!Vx(e.spec)):m,[C,m]),T=A()[e],E=(0,q.useMemo)(()=>Ci(p,T===void 0?void 0:new Date(T).toISOString()),[p,T]),D=(0,q.useMemo)(()=>Ab(E),[E]),O=(0,q.useMemo)(()=>dn(a,E,D,T),[a,E,D,T]),k=ss(O,E),j=k?.runtime===`running`||k?.runtime===`spawning`,M=O===a?void 0:O?.lastUserAt,N=aC({slug:e,thread:k,messages:p,openQuestions:m,settledQuestions:h},i?{exit:i.exit}:void 0),{inFlightAnswers:P}=N.transcript,F=(0,q.useRef)(null),[I,L]=(0,q.useState)(null),z=o.data?.messages.length??0,B=$C({pending:o.isPending,failed:o.isError},{running:j,adoptable:QC(k)}),ee=(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 CD({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]),V=(0,q.useCallback)(()=>{if(S===0)return void ee();let e=Ho(p,S);x(e!==null&&e>0?p[e]?.sourceId??null:null)},[ee,p,S]);return(0,X.jsxs)(oC,{surface:N,className:`flex-1 min-h-0 flex flex-col`,children:[r,(0,X.jsx)(dS.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:F,"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:z>0?(0,X.jsx)(QD,{slug:e,transcriptRef:F,transcriptKey:o.data?.transcriptKey,messages:E,steerSince:M,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:V,jumpOverlay:I,openAtLastMessage:(t||i!==void 0)&&!j,windowStart:S,openAtTop:i?.queueWindow===!0,sentAt:i?T:void 0}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(nD,{thread:k,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,X.jsx)(JS,{thread:k,inFlight:P,className:`px-6 pt-5`}),o.transportFallback&&(0,X.jsx)(WD,{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:B===`loading`?(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Nk,{}),` Loading…`]}):B===`failed`?(0,X.jsx)(GD,{error:o.error,retry:()=>o.refetch()}):B===`starting`?(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Nk,{}),` Session starting…`]}):B===`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:L,"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)(zw,{slug:e,above:t||!k?void 0:(0,X.jsx)(tT,{thread:k,transcriptShells:g,only:n?ND:void 0}),phoneBarOverride:t&&w.length>0?e=>(0,X.jsx)(gS,{count:w.length,onAnswer:()=>y(!0),onReply:C?void 0:e.editReply}):void 0,phoneChrome:t})}),t&&v&&(0,X.jsx)(vC,{questions:w,onClose:()=>y(!1)})]})})]})}var FD=700,ID=`button, a[href], input, textarea, select, summary, label, [role='button'], [role='checkbox'], [role='radio'], [contenteditable='true']`;function LD(e){return e.target instanceof Element&&e.target.closest(ID)!==null}var RD=250,zD=900,BD=.6,VD=.25,HD=160,UD=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function WD({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 ${em} 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)(d,{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 GD({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 KD({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`:xD(e)?`pending-ask`:SD(e,t)?`working`:e?.providerError?i?null:`provider-error`:vD(e)?`snooze`:My(e)?`resting`:n?`registered-done`:r?`rested`:null}function qD(e,t){return KD(e)===`working`?SO(t):14}function JD({state:e,slug:t,retryText:n,liveRuntimeStart:r,liveActivityLabel:i,liveToolRun:a,onRestingExit:o,onRestingExitFailed:s,onRestingReplied:c}){let l=e.thread;switch(KD(e)){case`provider-fault`:return(0,X.jsx)(Ck,{slug:t,sessionId:l.sessionId,fault:l.providerFault,retryText:n});case`provider-error`:return(0,X.jsx)(pk,{error:l.providerError});case`limit-pause`:return(0,X.jsx)(wk,{slug:t,sessionId:l.sessionId,pause:l.limitPause});case`pending-ask`:return(0,X.jsx)(Dk,{ask:xD(l)});case`working`:return(0,X.jsx)(Pk,{since:l?.lastUserAt,startedAt:r,activityLabel:i,run:a});case`snooze`:return(0,X.jsx)(bD,{thread:l});case`resting`:return(0,X.jsx)(Fy,{thread:l,onSnooze:o,onSnoozeFailed:s,onReplied:c??o,onReplyFailed:s});case`registered-done`:return(0,X.jsx)(YD,{thread:l});case`rested`:return(0,X.jsx)(Pg,{thread:l});default:return null}}function YD({thread:e}){let t=Mg(e);return t===void 0?null:(0,X.jsx)(Sk,{fenceKind:`done`,body:t,hints:e.lastFence.hints})}function XD(e,t,n,r){let{thread:i,messages:a,running:o,lastAgentIdx:s}=e,c=xe(),l=(0,q.useMemo)(()=>o_(a),[a]);return(0,q.useMemo)(()=>{let e=s>=0?a[s]:void 0,u={thread:i,showWorking:o,registeredDone:Og(i,e?.text),restedCard:Ng(i,e?.text,e?.refusedFences),errorVisible:Fg(t.map(e=>e.message),i?.providerError)},d=KD(u),f=o?Ir(t):void 0;return{state:u,rung:d,shown:d!==null||!!i?.permPolicy,gap:qD(u,n.map(e=>e.message)),retryText:l>=0?a[l]?.text:void 0,liveRuntimeStart:o?_O(So(t),r):void 0,liveActivityLabel:f?Ca(f,c):void 0,liveToolRun:o?Xi(t):void 0}},[i,a,o,s,l,t,n,r,c])}function ZD({tail:e}){let t=(0,q.useContext)(fv),n=(0,q.useContext)(pv),r=e.state.thread;return!e.shown||!t?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Zy,{h:e.gap}),(0,X.jsx)(JD,{state:e.state,slug:t,retryText:e.retryText,liveRuntimeStart:e.liveRuntimeStart,liveActivityLabel:e.liveActivityLabel,liveToolRun:e.liveToolRun,onRestingExit:n?.dismiss,onRestingExitFailed:n?.cancel,onRestingReplied:n?.sent}),r?.permPolicy?(0,X.jsx)(`div`,{className:e.rung===null?``:`mt-3`,children:(0,X.jsx)(Tk,{policy:r.permPolicy,denies:r.permDenies})}):null]})}function QD({slug:e,transcriptRef:t,transcriptKey:r,messages:i,steerSince:a,transportFallback:o,isFetching:s,refresh:c,retryLiveUpdates:l,hasEarlier:u,beforeCursor:d,loadingEarlier:f,earlierError:p,loadEarlier:m,jumpOverlay:h,openAtLastMessage:g=!1,windowStart:_=0,openAtTop:v=!1,sentAt:y}){let b=tC(),{thread:x,running:S,lastAgentIdx:C,awaitingCut:w,restingShown:T,heldIdx:E,paired:D,inFlightAnswers:O,settledPlacement:k,openQuestions:A}=b,j=(0,q.useMemo)(()=>j_(b.placement,_),[b.placement,_]),M=(0,q.useMemo)(()=>{let e=dr(i);return _>0?e.filter(e=>e.messageIndex>=_):e},[i,_]),N=(0,q.useMemo)(()=>{let e=S?n(M):M;return kD(e,vO(e,w,T,E))},[M,S,w,T,E]),P=(0,q.useMemo)(()=>{let e=DD(N.map(e=>e.message),vO(N,w,T,E),mO);return e.map((t,n)=>({...t,messageIndex:N[t.messageIndex].messageIndex,restGap:fO(t.message,e[n+1]?.message)}))},[N,w,T,E]),F=XD(b,M,N,a),I=F.shown,L=(0,q.useMemo)(()=>{let e=[],t=new Map,n=i.length-1,r=e=>{let t=-1;for(let n=0;n<P.length&&!(P[n].messageIndex>e);n++)t=n;return t},a=A.filter(e=>!j.placedIds.has(e.id));for(let[o,s]of h_(i,a,{from:_})){if(o>=n){e.push(...s);continue}let i=r(o),a=t.get(i);a?a.push(...s):t.set(i,[...s])}let o=!1,s=new Set;for(let e of M_(i,j)){if(e>=n){o=!0;continue}let i=r(e);s.add(i),t.has(i)||t.set(i,[])}return{byRow:t,tail:e,tailSend:o,sendRows:s}},[P,i,A,j,_]),R=(0,q.useMemo)(()=>{let e=new Map;for(let[t,n]of k.anchored){let r=-1;for(let e=0;e<P.length&&!(P[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},[P,k.anchored]),z=(0,q.useMemo)(()=>qC(i,{running:S}),[i,S]),[B,ee]=(0,q.useState)(()=>new Set),V=(0,q.useMemo)(()=>{let e=[{key:`head-anchor`,kind:`head-anchor`}];o&&e.push({key:`transport-fallback`,kind:`transport-fallback`}),(u||f||p||_>0)&&e.push({key:`earlier-history:${d??`complete`}`,kind:`earlier-history`});let t=L.byRow.get(-1);t&&e.push({key:`questions:head`,kind:`questions`,questions:t,send:L.sendRows.has(-1)});let n=(t,n,r=P[t].message)=>{let i=P[t];e.push({...i,message:r,gap:n,kind:`message`});let a=R.get(t);a&&e.push({key:`settled-questions:${i.key}`,kind:`settled-questions`,questions:a});let o=L.byRow.get(t);o&&e.push({key:`questions:${i.key}`,kind:`questions`,questions:o,send:L.sendRows.has(t)})},r=e=>L.byRow.has(e)||j.placed.has(P[e].messageIndex),a=new Map,s=new Set,c=0;for(let e=0;e<P.length;){let t=P[e].messageIndex;for(;c<z.length&&z[c].to<t;)c++;let n=z[c],i=e;if(n&&t>=n.from)for(;i<P.length&&P[i].messageIndex<=n.to&&!r(i);)i++;let o=n?.lead!==void 0&&e>0&&P[e-1].messageIndex===n.lead?e-1:-1,l=`fold:${P[e].key}`;if(i-e>=(o>=0?1:2)){if(!B.has(l)){let t=i<P.length&&P[i].messageIndex<=n.to?P[i].messageIndex-1:n.to;a.set(e,{end:i,key:l,range:n,to:t}),o>=0&&s.add(o)}e=i}else e++}let l=!1;for(let t=0;t<P.length;){let r=a.get(t);if(!r){let e=l?mO(NO,P[t].message):P[t].gap,r=P[t].message;s.has(t)?n(t,e,{...r,tools:[],parts:(r.parts??[]).filter(e=>e.kind!==`tools`)}):n(t,e),l=!1,t++;continue}let o=JC(i,{from:P[t].messageIndex,to:r.to,lead:s.has(t-1)?r.range.lead:void 0});e.push({key:r.key,kind:`fold`,...o,gap:t===0?0:mO(P[t-1].message,NO)}),l=!0,t=r.end}e.push({key:`interactions`,kind:`interactions`}),I&&e.push({key:`runtime-status`,kind:`runtime-status`});let m=null;return i.forEach((t,n)=>{if(!Jo(t))return;let r=`queued:${t.deliveryId??t.sourceId??n}`,i=m?mO(m,t):I||P.length>0?14:0;e.push({key:r,kind:`queued`,message:t,messageIndex:n,gap:i}),m=t}),m&&e.push({key:`queued-send-now`,kind:`queued-send-now`}),e},[d,p,z,u,I,f,P,i,B,j,L,R,o,_]),te=(0,q.useRef)(null),ne=Br({count:V.length,getScrollElement:()=>t.current,getItemKey:e=>V[e]?.key??e,estimateSize:e=>{let t=V[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===`fold`?28+t.gap:t.kind===`message`?108+t.gap:82+t.gap:80},overscan:8,rangeExtractor:e=>{let t=_s(e),n=te.current?.rowKey,r=n?V.findIndex(e=>e.key===n):-1;if(r<0)return t;let i=[];for(let e=Math.max(0,r-2);e<=Math.min(V.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})}}),[re,ie]=(0,q.useState)(!0),H=(0,q.useRef)(!0),ae=(0,q.useRef)(-1),oe=(0,q.useRef)(-1),se=(0,q.useRef)(0),ce=(0,q.useRef)(null),le=(0,q.useRef)(!1),ue=(0,q.useRef)(!1),de=(0,q.useRef)(!0),fe=(0,q.useRef)(void 0),pe=(0,q.useRef)(null),me=(0,q.useRef)(void 0),he=(0,q.useRef)(0),ge=(0,q.useRef)(0),_e=(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&&(te.current={rowKey:r,viewportTop:n.getBoundingClientRect().top-t})}m()},[m,t]),ve=(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(!r||V.length===0||fe.current===r)return;fe.current=r,le.current=!1,ue.current=!1,de.current=!0;let n=Ve(e)?.candidates.map(e=>({candidate:e,index:V.findIndex(t=>t.kind===`message`&&t.message.sourceId===e.sourceId)})).find(e=>e.index>=0),a=xx(i,s_(i))[0]??-1,o=!n&&a>=0&&(v||g)?V.findIndex(e=>e.kind===`message`&&e.messageIndex===a):-1,s=o>=0&&!v?o:!n&&g&&C>=0?V.reduce((e,t,n)=>t.kind===`message`&&t.messageIndex<=C&&t.message.role===`assistant`&&t.message.kind!==`event`?n:e,-1):-1,c=requestAnimationFrame(()=>{if(!n&&(v||s>=0)){let e=v?null:V[s].key,n=v&&o>=0?V[o].key:null;v?t.current?.scrollTo({top:0}):ne.scrollToIndex(s,{align:`start`,behavior:`instant`}),H.current=!1,ie(!1),le.current=!0;let r=performance.now()+zD;he.current=r;let i=()=>{let a=t.current;if(!a||performance.now()>=r||performance.now()<se.current){he.current=0,ge.current=0,a&&a.scrollHeight-a.clientHeight-a.scrollTop<=4&&(H.current=!0,ae.current=a.scrollHeight,ie(!0));return}if(e===null){let e=n?a.querySelector(`[data-transcript-row-key="${CSS.escape(n)}"]`):null;if(!e&&o>=0)ne.scrollToIndex(o,{align:`start`,behavior:`instant`});else if(!e)a.scrollTop=0;else{let t=e.getBoundingClientRect().top-a.getBoundingClientRect().top+a.scrollTop;a.scrollTop=t<=a.clientHeight*BD?0:t-Math.min(a.clientHeight*VD,HD)}}else{let t=a.querySelector(`[data-transcript-row-key="${CSS.escape(e)}"]`);t&&(a.scrollTop+=t.getBoundingClientRect().top-a.getBoundingClientRect().top)}ge.current=requestAnimationFrame(i)};i();return}if(!n){ne.scrollToEnd({behavior:`instant`}),ie(!0),le.current=!0;return}ne.scrollToIndex(n.index,{align:`start`,behavior:`instant`}),H.current=!1,ie(!1),le.current=!0;let e=performance.now()+RD;he.current=e;let r=()=>{performance.now()>=e||performance.now()<se.current||(ve(n.candidate.sourceId,n.candidate.screenTop),c=requestAnimationFrame(r))};r()});return()=>cancelAnimationFrame(c)},[ve,V.length,e,r,ne]),(0,q.useEffect)(()=>()=>cancelAnimationFrame(ge.current),[]);let ye=(0,q.useRef)(y);(0,q.useEffect)(()=>{let e=y!==ye.current;ye.current=y;let n=t.current;!e||y===void 0||!n||(he.current=0,H.current=!0,ie(!0),n.scrollTop=n.scrollHeight)},[y,t]);let be=(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]),xe=(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]),Se=P[0]?.key;(0,q.useLayoutEffect)(()=>{let e=me.current;if(me.current=Se,e===void 0||e===Se||!le.current||H.current||te.current)return;let t=pe.current;if(!t)return;xe(t);let n=()=>{if(performance.now()<se.current)return;let e=pe.current;e&&xe(e)},r=0,i=requestAnimationFrame(()=>{n(),r=requestAnimationFrame(n)});return()=>{cancelAnimationFrame(i),cancelAnimationFrame(r)}},[xe,Se]);let Ce=(0,q.useCallback)(()=>{let e=t.current;if(!e||te.current||performance.now()<he.current)return;let n=wD({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,previousScrollHeight:ae.current,previousClientHeight:oe.current,following:H.current,readerMoved:performance.now()<se.current});if(H.current=n.following,n.scrollTop!==null&&(e.scrollTop=n.scrollTop),ae.current=e.scrollHeight,oe.current=e.clientHeight,ie(e=>e===n.following?e:n.following),UD&&!n.following&&performance.now()>=se.current){let t=pe.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}`)}}pe.current=be()??pe.current},[be,t]),we=(0,q.useCallback)(e=>{let n=t.current,r=V.findIndex(t=>t.key===e),i=r>0?V[r-1].key:null,a=i?n?.querySelector(`[data-transcript-row-key="${CSS.escape(i)}"]`):null;if(n&&i&&a){let e={rowKey:i,viewportTop:a.getBoundingClientRect().top-n.getBoundingClientRect().top};H.current=!1;let t=performance.now()+RD;he.current=t;let r=()=>{if(performance.now()>=t||performance.now()<se.current){he.current===t&&(he.current=0),Ce();return}xe(e),requestAnimationFrame(r)};requestAnimationFrame(r)}ee(t=>new Set(t).add(e))},[xe,V,Ce,t]);(0,q.useLayoutEffect)(()=>{let e=ce.current;if(!e)return;let t=new Map(ne.getVirtualItems().map(e=>[e.index,e.size])),n=[],r=0;for(let i of e.querySelectorAll(`:scope > [data-index]`)){let e=ne.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=`${ne.getTotalSize()+r}px`;for(let{index:e,size:t}of n)ne.resizeItem(e,t)}});let Te=(0,q.useRef)(null);(0,q.useLayoutEffect)(()=>{let e=te.current,n=t.current;if(!e||!n||f)return;let r=()=>{let t=Array.from(n.querySelectorAll(`[data-transcript-row-key]`)).find(t=>t.dataset.transcriptRowKey===e.rowKey);if(!t){let t=V.findIndex(t=>t.key===e.rowKey),r=t>=0?ne.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(),Te.current?.anchor===e)return;let i=0,a=0,o=()=>{if(i=r()?i+1:0,a++,i>=2||a>=10){te.current===e&&(te.current=null),Te.current=null;return}Te.current&&(Te.current.frame=requestAnimationFrame(o))};Te.current={anchor:e,frame:requestAnimationFrame(o)}}),(0,q.useEffect)(()=>()=>{Te.current&&cancelAnimationFrame(Te.current.frame)},[]),(0,q.useLayoutEffect)(Ce),(0,q.useEffect)(()=>{let e=ce.current;if(!e)return;let n=new ResizeObserver(Ce);n.observe(e);let r=t.current;return r&&n.observe(r),()=>n.disconnect()},[Ce,t]),(0,q.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{Ce();let t=TD({armed:de.current,scrollTop:e.scrollTop,readerMoved:le.current&&ue.current,hasEarlier:u&&_===0,loading:f});de.current=t.armed,t.shouldLoad&&_e()},r=()=>{ue.current=!0,se.current=performance.now()+FD,requestAnimationFrame(n)},i=t=>{![`ArrowUp`,`PageUp`,`Home`,` `].includes(t.key)||LD(t)||(e.scrollTop<=480&&(de.current=!0),r())},a=t=>{t.deltaY<0&&e.scrollTop<=480&&(de.current=!0),r()},o=t=>{t.type===`touchstart`&&LD(t)||(e.scrollTop<=480&&(de.current=!0),r())},s=e=>{LD(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)}},[u,f,_e,Ce,t,_]);let Ee=ne.getVirtualItems(),De=ne.getTotalSize();return(0,X.jsxs)(`div`,{ref:ce,"data-virtualized-transcript":!0,"data-virtual-row-count":Ee.length,className:`relative w-full`,style:{height:De},children:[Ee.map(e=>{let t=V[e.index];return t?(0,X.jsx)(`div`,{ref:ne.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)(nD,{thread:x,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,X.jsx)(JS,{thread:x,questions:L.tail,inFlight:O,showSend:L.tailSend,className:`px-6 pt-5`})]}):t.kind===`questions`?(0,X.jsx)(JS,{thread:x,questions:t.questions,showSend:t.send,className:`px-6 pt-5`}):t.kind===`settled-questions`?(0,X.jsx)(MS,{questions:t.questions,className:`px-6 pt-5`}):t.kind===`transport-fallback`?o?(0,X.jsx)(`div`,{className:`px-6 pt-3`,children:(0,X.jsx)(WD,{fallback:o,isFetching:s,onRefresh:c,onRetryLive:l})}):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:p?(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-2 text-center`,children:[(0,X.jsx)(`span`,{children:p}),(0,X.jsx)(`button`,{type:`button`,onClick:_e,className:`rounded-md border border-border px-2 py-1 text-fg/90 hover:bg-panel-2`,children:`Retry`})]}):f?(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Ie,{size:12,className:`animate-spin`}),` Loading earlier messages…`]}):(0,X.jsx)(`button`,{type:`button`,"data-load-earlier":!0,onClick:_e,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)(pO,{rest:t.message,at:t.restGap}):(0,X.jsx)(dk,{m:t.message,index:t.messageIndex,showSendButton:!0})}):t.kind===`fold`?(0,X.jsx)(`div`,{className:`flex flex-col px-6`,style:{paddingTop:t.gap},children:(0,X.jsx)(jO,{rounds:t.rounds,calls:t.calls,onExpand:()=>we(t.key)})}):t.kind===`runtime-status`?(0,X.jsx)(`div`,{className:`px-6`,children:(0,X.jsx)(ZD,{tail:F})}):t.kind===`queued-send-now`?(0,X.jsx)(`div`,{className:`flex flex-col px-6`,children:(0,X.jsx)(ck,{})}):(0,X.jsx)(`div`,{className:`relative flex flex-col px-6`,style:{paddingTop:t.gap},children:(0,X.jsx)(fk,{m:t.message,paired:D[t.messageIndex]})})},t.key):null}),(0,X.jsx)($D,{overlay:h,hidden:re,onJump:()=>ne.scrollToEnd({behavior:`smooth`})})]})}function $D({overlay:e,hidden:t,onJump:n}){return!e||t?null:(0,Tc.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)(Vs,{size:12}),`Jump to latest`]}),e)}function eO({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1,pane:i}){let a=We(e),o=vn({mutationFn:()=>U.markComplete({slug:e})}),s=Df(H({queryKey:[`threadBody`,e],queryFn:()=>U.threadBody({slug:e})}).data?.markdown??``).trim().length>0;return a?(0,X.jsxs)(`header`,{"data-thread-header":!0,className:ew,children:[(0,X.jsxs)(`div`,{className:tw,children:[n&&(0,X.jsx)(ie,{onClose:n}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 leading-tight`,children:[(0,X.jsx)(cE,{thread:a}),(0,X.jsx)(iE,{thread:a})]})]}),(0,X.jsx)(`div`,{className:nw,children:(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,X.jsx)(HT,{thread:a,collapse:r,expand:!!n||i?.expand===!0,onDoc:s?()=>ki(`doc`,a.id):void 0,onDone:()=>o.mutate(void 0,{onSuccess:t??i?.exit.dismiss}),doneBusy:o.isPending,onStatusApplied:t}),(0,X.jsx)(mT,{thread:a,onArchived:t??i?.exit.dismiss,onDismissCancel:i?.exit.cancel,onSnoozed:t??i?.exit.dismiss})]})})]}):null}function tO(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||lE(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 nO(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||lE(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 rO(e){return tO(e)!==null}function iO(e){return nO(e)!==null}function aO(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function oO(e){return aO(e)||rO(e)}function sO(e){return aO(e)||iO(e)}function cO(e){if(aO(e))return!0;let t=tO(e);return t!==null&&!Va(t[t.length-1])}function lO(e){if(aO(e))return!0;let t=nO(e);return t!==null&&!Va(t[0])}function uO(e){let t=tO(e);return t!==null&&hi(t[t.length-1])}function dO(e){let t=nO(e);return t!==null&&hi(t[0])}function fO(e,t){return e.kind!==`event`||e.boundary!==`rest`||!t||!hO(t)?null:Ly(e.at,t.at)}function pO({rest:e,at:t}){let{day:n,time:r}=zy(t),i=By(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 mO(e,t){if(hO(e)&&hO(t))return 6;let n=uO(e)||dO(t),r=!n&&oO(e)&&sO(t)&&!(cO(e)&&lO(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function hO(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`||e.providerError||e.sessionPeer||e.peerFrom||e.agentInstruction?!1:!e.wake||Zg(e)}function gO(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:yO(e,r.text,t,n)):(e.tools?.length??0)===0&&yO(e,e.text,t,n)}function _O(e,t){let n=Date.parse(e??``),r=Date.parse(t??``);return Number.isFinite(r)?Number.isFinite(n)&&n>=r?e:t:e}function vO(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=>gO(e,i.has(e),a.has(e))}function yO(e,t,n,r){return!e.fenceRefused&&!n&&!r?t.includes("```awaiting")?Eg(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`&&Dr(e.hints)&&!rs(e.body)):!t.trim():Eg(t).every(t=>t.kind===`fence`&&t.fenceKind===`awaiting`&&(e.fenceRefused||r||!(bO(t.hints)||xO(e,t))))}function bO(e){return ks(e).length>0}function xO(e,t){return e.latestSignOff?!Dr(t.hints)||rs(t.body)!==null:!1}function SO(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(Jo(n)||gO(n)))return uO(n)?22:oO(n)&&!cO(n)?6:14+(n.role===`user`?3:0)}return 0}function CO(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||gO(e)||(i!==null&&r.push((0,X.jsx)(Zy,{h:mO(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function wO(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 TO(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)(Zy,{h:i},`vs${n}`)),r.push(e)}),r}var EO={head:!1,tail:!1};function DO(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function OO(e){return{head:hi(e[0]),tail:hi(e[e.length-1])}}function kO(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}):Bo(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 AO(e){return e.split(`__`).pop()||e}function jO({rounds:e,calls:t,onExpand:n}){let r=e>0?`${e} more round${e===1?``:`s`}`:``,i=t>0?`${t} tool call${t===1?``:`s`}`:``;return(0,X.jsx)(Q,{icon:MO,marker:`stretch-fold`,onClick:n,ariaLabel:`Expand ${[r,i].filter(Boolean).join(` and `)||`the work`} before the sign-off`,children:r||i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:r||i}),r&&i&&(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:i})]}),(0,X.jsx)(Ky,{})]}):(0,X.jsx)(`span`,{className:`shrink-0`,children:`Click to expand`})})}var MO=(0,q.forwardRef)(({className:e,...t},n)=>(0,X.jsx)(qs,{ref:n,...t,className:`${e??``} -mr-[1.5px]`})),NO={role:`user`,wake:!0,text:``,tools:[],parts:[]};function PO({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=jo(a,Gt(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 ${xE}`,children:[(0,X.jsx)(`span`,{"data-tool-activity-label":!0,title:o,className:`min-w-0 truncate text-muted`,children:o}),(0,X.jsx)(Kt,{"data-tool-activity-chevron":!0,"aria-hidden":`true`,size:13,className:CE(n)})]}),n&&(0,X.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:(0,X.jsx)(FO,{tools:e,at:t})}),!n&&(0,X.jsx)(`div`,{id:i,hidden:!0})]})}function FO({tools:e,at:t}){let n=(0,q.useContext)(fv)!==null,r=e=>!Bo(e)&&!(n&&(e.sendTo!==void 0||e.sendBody!==void 0));return(0,X.jsx)(X.Fragment,{children:TO(e.map((e,n)=>(0,X.jsx)(LO,{t:e,startedAt:t},n)),t=>hi(e[t-1])||hi(e[t])?22:r(e[t-1])&&r(e[t])?0:6)})}function IO({tools:e,at:t}){let n=[];for(let t of e){let e=Va(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:TO(n.map((e,n)=>e.exceptional?(0,X.jsx)(`div`,{className:`flex flex-col`,children:(0,X.jsx)(FO,{tools:e.tools,at:t})},`exceptions-${n}`):(0,X.jsx)(PO,{tools:e.tools,at:t},`activity-${n}`)),DO(n.map(e=>OO(e.tools)),6))})}function LO({t:e,startedAt:t}){let n=Oa(e,We((0,q.useContext)(fv))?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,X.jsx)(Ap,{edits:e.edits,meta:(0,X.jsx)(HO,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:n,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,X.jsx)(ZO,{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)(JO,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,X.jsx)($O,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,X.jsx)(tk,{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)(rk,{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)(YO,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,X.jsx)(Yh,{todos:e.todos,note:e.input,node:xp(e.status),meta:(0,X.jsx)(HO,{status:e.status,durationMs:e.durationMs})}):Bo(e)?(0,X.jsx)(RO,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,X.jsx)(ZO,{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)(qO,{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 RO({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=QE(e,t?.[n]);return(0,X.jsx)(oS,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function zO({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 BO(e,t,n){let[r,i]=(0,q.useState)(()=>Date.now()),a=bi(e,t),o=Go(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(ya-(Date.now()-e),0));return()=>clearTimeout(t)},[a,o,n]),o}function VO({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=BO(e,t,r),a=n===`running`?(0,X.jsx)(Li,{"aria-hidden":!0,hue:`shell`,"data-running-indicator":`tool-disclosure`}):n===`stale`?(0,X.jsx)(`span`,{className:Ye,title:ur}):ri(e,t)||i?(0,X.jsx)(Li,{"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 HO({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:jr(i);if(!a&&!s)return null;let c=[o,s].filter(Boolean).join(` · `);return(0,X.jsx)(zO,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-attention`:`text-faint`,title:c,label:a,duration:s})}function UO(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 WO(e,t,n){let r=t&&t!==W.board?.projectDir?`in ${Ep(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function GO(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function KO({detail:e,shown:t=e}){return t?e&&GO(e)?(0,X.jsx)(`span`,{className:`min-w-0`,children:(0,X.jsx)(kp,{path:e,children:(0,X.jsx)(Dp,{path:Ep(e)})})}):(0,X.jsx)(`span`,{className:`frizz-tool-detail frizz-tool-detail--mono`,title:t,children:Ep(t)}):null}function qO({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=WO(t,s,c);return(0,X.jsx)(`div`,{className:`frizz-bash`,title:d,"data-tool-node":xp(r),children:(0,X.jsxs)(`div`,{className:`frizz-bash-header`,children:[(0,X.jsxs)(`span`,{className:yp,children:[(0,X.jsx)(VO,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:AO(e)}),(0,X.jsx)(KO,{detail:t,shown:d})]}),(0,X.jsxs)(`span`,{className:bp,children:[(0,X.jsx)(HO,{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)(Op,{shown:!1})]})]})})}function JO({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=AO(e),f=t?Ep(t):void 0;return(0,X.jsxs)(`div`,{"data-tool-image":!0,className:`frizz-bash`,"data-tool-node":xp(i),children:[(0,X.jsxs)(Tp,{className:`frizz-bash-header`,controls:u,expanded:o,label:`${o?`Collapse`:`Expand`} ${d}${t?`: ${t}`:``}`,onToggle:()=>s(e=>!e),meta:(0,X.jsx)(HO,{status:i,durationMs:a}),children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:d}),(0,X.jsx)(KO,{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:go(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 YO({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":xp(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:yp,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:bp,children:[(0,X.jsx)(HO,{status:r,durationMs:i}),(0,X.jsx)(Op,{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)(ch,{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)(_k,{path:e},`f${t}`))}),n&&(0,X.jsx)(`div`,{className:`max-w-[65%] font-sans text-[12px] leading-snug text-muted`,children:n})]})]})})]})}var XO=16;function ZO({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=UO(a,f,u),x=(0,q.useMemo)(()=>e.split(`
137
- `).length,[e]),S=x>XO,C=(0,q.useMemo)(()=>r?r.split(`
138
- `).length:0,[r]),w=C>XO,T=WO(t,void 0,l),E=!!(e||r);return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":xp(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`} `:``}${AO(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:yp,children:[(0,X.jsx)(VO,{status:a,backgroundState:o,liveBackgroundState:s,startedAt:f}),(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:AO(i)}),(0,X.jsx)(`span`,{className:`frizz-tool-detail${n?` frizz-tool-detail--mono`:``}`,title:T,children:T??``})]}),(0,X.jsxs)(`span`,{className:bp,children:[(0,X.jsx)(HO,{status:a,backgroundState:o,liveBackgroundState:s,exitCode:c,durationMs:b}),(0,X.jsx)(Op,{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)(Uh,{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 QO=16;function $O({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>QO;return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":xp(n),children:[(0,X.jsxs)(Tp,{className:`frizz-bash-header`,controls:c,expanded:i,label:`${i?`Collapse`:`Expand`} Read${e?`: ${e}`:``}`,onToggle:()=>a(e=>!e),meta:(0,X.jsx)(HO,{status:n,durationMs:r}),children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:`Read`}),(0,X.jsx)(KO,{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)(Uh,{text:t,language:re(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 ek=16;function tk({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>ek,g=jD(),_=We(g),v=!i&&r?(_?.subAgents??[]).find(e=>e.id===r):void 0,y=v?.state===`running`,b=!!(g&&r),x=e??`sub-agent`,S=Cr(n),C=Oi(),w=mE({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)(Li,{"aria-hidden":!0,hue:`agent`,"data-running-indicator":`subagent-disclosure`}):v?.state===`stale`?(0,X.jsx)(`span`,{className:Ye,title:nr}):v?.state===`rested`?(0,X.jsx)(`span`,{className:rt,title:mo}):null;function E(){!g||!r||es(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)(Tp,{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)(zO,{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 nk(e,t){return t===`shutdown_request`?`Shutdown`:t===`codex_followup`?`Followed up`:e===`main`?`Reported`:`Steered`}function rk({to:e,summary:t,body:n,type:r,dispatchId:i,targetLabel:a,status:o,durationMs:s,at:c}){return(0,q.useContext)(fv)===null?(0,X.jsx)(ak,{to:e,summary:t,body:n,type:r,status:o,durationMs:s}):(0,X.jsx)(Ak,{to:e,type:r,dispatchId:i,targetLabel:a,at:c})}var ik=16;function ak({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=Gf(n),f=(0,q.useMemo)(()=>n.split(`
141
- `).length,[n]),p=f>ik,m=!!n.trim(),h=nk(e,r);return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":xp(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:yp,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:bp,children:[(0,X.jsx)(HO,{status:i,durationMs:a}),(0,X.jsx)(Op,{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)(Hh,{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 ok({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)(()=>Sn(e,[...i.keys()]),[e,i]).map((e,t)=>{let a=e.token?i.get(e.token):void 0;if(!a)return(0,X.jsx)(Eb,{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:ce(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 sk({deliveryId:e,text:t,rawText:n,error:r}){let i=(0,q.useContext)(fv),{retry:a,edit:o,dismiss:s,pending:c}=zC(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 ck(){let e=(0,q.useContext)(fv),t=(0,q.useContext)(mv),n=ix(e),r=rx(e),i=cx(e);if(!e||!t)return null;let a=ex(t,n,r);if(!a)return r||t.held+t.steered===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Zy,{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)(Zy,{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:()=>lx(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)(Ie,{"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 lk({m:e,answers:t,note:n}){let r=(t,n)=>{if(!t)return null;let i=n<2?Kg(t):null;return i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Db,{answers:i,queued:e.queued}),r(Rg(t),n+1)]}):(0,X.jsx)(uk,{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)(Db,{answers:t,queued:e.queued}),r(n,0)]})}function uk({text:e,rawText:t,queued:n,held:r,deliveryUnconfirmed:i,deliveryFailed:a,deliveryError:o,deliveryId:s,sourceId:c}){let l=(0,q.useContext)(fv),u=PC(l),{unqueue:d,pending:f}=RC(l),p=!!(n&&s&&l&&(u||r)),{prose:m,attachments:h}=(0,q.useMemo)(()=>fa(e),[e]),g=(0,q.useMemo)(()=>us(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)(ok,{body:g.body,items:g.items}):(0,X.jsx)(Eb,{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)(gk,{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)(_k,{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)(sk,{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 dk({m:e,index:t,showSendButton:n}){let r=tC(),[i,a]=r.hidesAwaiting(t);return(0,X.jsx)(fk,{m:e,showSendButton:n,answering:r.fencesLive?r.answeringForMessage(e):void 0,paired:r.paired[t],staleAwaiting:i,restingCardShown:a,stepsDone:r.stepsDone.get(t),shadowedBy:r.shadowedByMessage.get(t),placed:r.placement.placed.get(t),settledPlaced:r.settledPlacement.placed.get(t),fenceQuestions:r.fenceQuestions,index:t,questionHomes:r.questionHomes})}var fk=(0,q.memo)(function(e){return(0,X.jsx)(`div`,{title:(e.m.queued?null:By(e.m.at))??void 0,className:`contents`,children:(0,X.jsx)(mk,{...e})})});function pk({error:e}){let t=(0,q.useContext)(fv);return(0,X.jsx)(Ig,{error:e,provider:(0,q.useSyncExternalStore)(e=>os(W,e),()=>{let e=t?ls(W.board,t):void 0;return On(e?.backend,e?.model)},()=>`Agent`)})}function mk({m:e,answering:t,paired:n,showSendButton:r,staleAwaiting:i,shadowedBy:a,placed:o,settledPlaced:s,fenceQuestions:c,index:l,questionHomes:u,restingCardShown:d,stepsDone:f}){let p=sr(),[m,h]=(0,q.useState)(!1),_=dv();if(e.providerError)return(0,X.jsx)(pk,{error:e.providerError});if(e.kind===`event`)return(0,X.jsx)(jk,{text:e.text,boundary:e.boundary,sourceId:e.sourceId,at:e.at});if(e.kind===`reasoning`)return(0,X.jsx)(Mk,{text:e.text,sourceId:e.sourceId});let v=lE(e);if(v)return(0,X.jsx)(Ok,{call:v,sourceId:e.sourceId,at:e.at});if(e.role===`user`){let t=a_(e).replace(/\r\n?/g,`
143
- `),r=n===void 0?Kg(t):n;if(e.deliveryState!==`failed`&&({text:t,answers:r}=Jg(t,r)),r&&e.deliveryState!==`failed`){let n=Rg(t);return!n&&e.deliveryState!==`held`?(0,X.jsx)(Db,{answers:r,queued:e.queued,sourceId:e.sourceId}):(0,X.jsx)(lk,{m:e,answers:r,note:n})}return e.wake?(0,X.jsx)(eb,{steer:e.wakeSteer,text:t,sourceId:e.sourceId,at:e.at}):e.sessionPeer?(0,X.jsx)(GC,{peer:e.sessionPeer,text:t,queued:e.queued,sourceId:e.sourceId,at:e.at}):e.peerFrom?(0,X.jsx)(kk,{from:e.peerFrom,unnamed:e.peerUnnamed,dispatchId:e.peerDispatchId,sourceId:e.sourceId,at:e.at}):(0,X.jsx)(uk,{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 y=[],b=[],x=(e,t=EO)=>{y.push(e),b.push(t)},S={n:-1},C=[],w=new Set,T,E=()=>T??=new Set(ag(e.text,e.refusedFences)),D=(n,r)=>{for(let[m,h]of Eg(n).entries()){if(h.kind===`fence`){if(h.fenceKind===`awaiting`&&i&&!e.fenceRefused&&!d&&bO(h.hints)){x((0,X.jsx)(Fy,{fence:{body:h.body,hints:h.hints},stepsDone:f},`${r}-f${m}`));continue}if(h.fenceKind===`awaiting`&&i&&!e.fenceRefused&&!d&&e.latestSignOff){if(Dr(h.hints)){let e=rs(h.body);e&&x((0,X.jsx)(hk,{md:e},`${r}-f${m}`))}else x((0,X.jsx)(Fy,{fence:{body:h.body,hints:h.hints}},`${r}-f${m}`));continue}if(h.fenceKind===`awaiting`&&(e.fenceRefused||i||d))continue;if(h.fenceKind===`awaiting`&&Dr(h.hints)){let e=rs(h.body);e&&x((0,X.jsx)(hk,{md:e},`${r}-f${m}`));continue}x((0,X.jsx)(Sk,{fenceKind:h.fenceKind,body:h.body,hints:h.hints,pastRest:i},`${r}-f${m}`));continue}for(let[n,i]of eg(h.text,c!==void 0,e.refusedFences).entries()){if(i.kind===`prose`){for(let[e,t]of g(i.text).entries()){let i=`${r}-${m}-p${n}-${e}`;x(t.kind===`image`?(0,X.jsx)(gk,{path:t.path},i):t.kind===`file`?(0,X.jsx)(_k,{path:t.path},i):t.kind===`visualization`?(0,X.jsx)(bk,{file:t.file},i):t.kind===`directive`?(0,X.jsx)(Lm,{directive:t.directive},i):t.kind===`mermaid`?(0,X.jsx)(Hm,{source:t.source},i):t.kind===`lightbox`?(0,X.jsx)(ch,{entries:t.entries},i):(0,X.jsx)(hk,{md:t.text},i))}continue}if(i.kind===`refusedRef`){let t=T_(i.id,c??[],e.questionOwners)?.closed;x((0,X.jsx)(GS,{id:i.id,closed:t},`${r}-${m}-r${n}`));continue}if(i.kind===`refusedAsk`){x((0,X.jsx)(HS,{spec:i.spec,reasons:e.refusedReasons?.get(i.id.toLowerCase())},`${r}-${m}-x${n}`));continue}if(i.kind===`invalidFence`){x(i.draft?(0,X.jsx)(HS,{spec:i.draft,reasons:i.faults,unread:!0},`${r}-${m}-i${n}`):(0,X.jsx)(US,{faults:i.faults,children:(0,X.jsx)(hk,{md:`<details>\n<summary>What the worker wrote</summary>\n\n${i.text}\n\n</details>`})},`${r}-${m}-i${n}`));continue}S.n+=1;let d=S.n;if(i.fence){let t=i.fence.form===`ask`?i.fence.when:void 0;if(t&&!E().has(t.parent.toLowerCase()))continue;let a=T_(t?t.parent:i.fence.id,c??[],e.questionOwners);if(a&&w.has(a.id))continue;if(a?.closed){let e=i.fence.form===`ask`&&!t?i.fence.spec:void 0,o=e??a.asked;o&&(w.add(a.id),x((0,X.jsx)(zS,{spec:o,state:a.closed,copyOf:e?void 0:a.id},`${r}-${m}-q${n}`)));continue}if(a){w.add(a.id);let e=o?.find(e=>e.id===a.id);if(e){x((0,X.jsx)(qS,{q:e},`${r}-${m}-q${n}`));continue}let t=s?.find(e=>e.id===a.id);if(t){x((0,X.jsx)(jS,{s:t},`${r}-${m}-q${n}`));continue}let i=NS(a),c=u?.get(a.id);x(i?(0,X.jsx)(jS,{s:i,copy:!0},`${r}-${m}-q${n}`):(0,X.jsx)(VS,{q:a,above:c!==void 0&&l!==void 0&&c<l},`${r}-${m}-q${n}`));continue}i.fence.form===`ask`&&!t&&!w.has(`fence:${i.fence.id}`)&&(w.add(`fence:${i.fence.id}`),x((0,X.jsx)(RS,{spec:i.fence.spec},`${r}-${m}-q${n}`)));continue}let f=o&&i.registeredId?o.find(e=>e.id.toLowerCase()===i.registeredId):void 0;if(f&&!w.has(f.id)){w.add(f.id),x((0,X.jsx)(qS,{q:f},`${r}-${m}-q${n}`));continue}if(a&&C_(i,a)!==void 0)continue;let h=s&&i.registeredId?s.find(e=>e.id.toLowerCase()===i.registeredId):void 0;if(h&&!w.has(h.id)){w.add(h.id),x((0,X.jsx)(jS,{s:h},`${r}-${m}-q${n}`));continue}if(i.registeredId&&i.text.trim()===``)continue;t&&C.push({raw:i.text,kind:i.questionKind,danger:i.danger,bi:d});let _=t&&!p?{answer:t.answerFor(d),onChip:(e,n)=>t.onChip(d,e,n),onText:e=>t.onText(d,e),onSubmit:t.onSubmit}:void 0;x((0,X.jsx)(oS,{raw:i.text,questionKind:i.questionKind,danger:i.danger,interactive:_},`${r}-${m}-q${n}`))}}};if(e.parts&&e.parts.length>0)wO(e.parts).forEach((t,n)=>{if(t.kind===`tools`){let r=kO(t.tools);r.length&&x((0,X.jsx)(IO,{tools:r,at:e.at},`t${n}`),OO(r))}else D(t.text,`x${n}`)});else{let t=kO(e.tools);t.length>0&&x((0,X.jsx)(IO,{tools:t,at:e.at},`tools`),OO(t)),D(e.text,`leg`)}return y.length===0?null:(r&&t&&p&&C.length>0?x((0,X.jsx)(`div`,{className:`flex justify-start`,children:(0,X.jsx)(`button`,{type:`button`,"data-mobile-answer-open":!0,onClick:()=>h(!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:C.length>1?`Answer ${C.length} questions`:`Answer`})},`answer-open`)):r&&t&&C.length>0&&!_&&x((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:[TO(y,DO(b,14)),m&&t&&C.length>0?(0,X.jsx)(sC,{blocks:C,answering:t,onClose:()=>h(!1)}):null]}))}function hk({md:e,wrap:t}){let n=Gf(e);return n?(0,X.jsx)(Hh,{className:`md-body${t?` ${$p}`:``}`,html:n}):null}function gk({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=Nt(e);return(0,X.jsx)(af,{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:go(e),alt:n??a,"data-local-path":e,"data-local-image":`true`,onError:()=>i(!0),className:`cursor-zoom-in ${cf}`})})}function _k({path:e}){let t=Nt(e);return(0,X.jsxs)(`button`,{type:`button`,className:`local-file-action inline-flex max-w-full items-center gap-1.5 ${em} 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)(En,{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 vk={"--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 yk(e){let t=getComputedStyle(document.documentElement),n=Object.fromEntries(Object.entries(vk).map(([e,n])=>[e,t.getPropertyValue(n).trim()]));return n[`--font-size-base`]=getComputedStyle(document.body).fontSize,YC(e,t.colorScheme===`light`?`light`:`dark`,n)}function bk({file:e}){let t=(0,q.useContext)(fv),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)(Lt,bt,bt),p=t?Ke(t):null,m=t?`${p?mi(p.project):$n()}/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(yk(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(XC(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:`${em} 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 ${em} 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 xk(e,t,n){return e?.kind===`awaiting`&&e.body===t&&JSON.stringify(e.hints)===JSON.stringify(n)}function Sk({fenceKind:e,body:t,hints:n,pastRest:r}){let i=Gf(t),a=(0,q.useContext)(fv),o=(0,q.useContext)(pv),s=We(a),c=s?oo(s):void 0,l=!!(s&&c?.archive),u=(0,q.useRef)(null);l&&s&&(u.current=s);let d=l&&s?s:u.current,f=sr();if(e===`done`){let e=ji(n),t=d&&!f&&!r?(0,X.jsx)(hm,{children:(0,X.jsx)(_T,{thread:d,pinChoice:`${ym} text-[11px] bg-fg text-bg`,className:`${ym} text-[11px] ${vm}`,iconClassName:nv,onArchived:o?.dismiss,onDismissCancel:o?.cancel})}):null;return(0,X.jsx)(pm,{icon:fi,kind:`Done`,label:e?(0,X.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:e}):null,ruled:!!i,children:i||t?(0,X.jsxs)(X.Fragment,{children:[i&&(0,X.jsx)(Hh,{className:`md-body`,html:i}),t]}):null})}return s&&My(s)&&xk(s.lastFence,t,n)?null:(0,X.jsx)(Fy,{thread:s,fence:{body:t,hints:n}})}function Ck({slug:e,sessionId:t,fault:n,retryText:r}){let[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1),c=R(),l=In[n.backend],u=t=>{s(!0),hn(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)(pm,{"data-provider-fault":!0,tone:`danger`,icon:tc,label:`${l} sign-in required`,children:[(0,X.jsx)(`span`,{className:mm,children:`The provider rejected this session's credential. Sign in, then retry.`}),(0,X.jsxs)(hm,{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:bm,children:`Sign in`})]}),i&&(0,X.jsx)(m,{backend:n.backend,onClose:()=>a(!1),onAuthed:()=>a(!1)})]})}function wk({slug:e,sessionId:t,pause:n}){let r=n.backend===`acp`?`The agent`:n.backend===`opencode`?`OpenCode`:In[n.backend],i=n.window===`weekly`?`weekly limit`:n.window===`session`?`5-hour limit`:`usage limit`,[a,o]=(0,q.useState)(!1),s=R();return(0,X.jsxs)(pm,{"data-limit-pause":!0,tone:`caution`,icon:at,label:`Paused by the ${r} ${i}`,children:[(0,X.jsx)(`span`,{className:mm,children:n.autoResume?n.resumesAt?`Continuing automatically at ${Eo(n.resumesAt)}.`:`Continuing automatically once the window resets.`:`Continue it whenever you have capacity again.`}),(0,X.jsx)(hm,{children:(0,X.jsx)(`button`,{onClick:()=>{o(!0),hn(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 ${bm}`,children:`Continue now`})})]})}function Tk({policy:e,denies:t}){let n=[e.tool,e.command].filter(Boolean).join(`: `);return(0,X.jsxs)(pm,{tone:`caution`,icon:d,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:mm,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 Ek({slug:e,className:t=`px-4 pb-2 pt-1`,includeAgents:n=!0,only:r,transcriptShells:i=[],parentAgentId:a,density:o=`sheet`}){let s=We(e),c=s?.subAgents??[],l=n?a?Ki(c,a):c:[],u=s&&!a?Q_(s,i):void 0,d=r&&r!==`shell`?[]:a?[...i]:u?.shells??[],f=!u||r&&r!==`pr`&&r!==`issue`?[]:r===`pr`?u.prs:r===`issue`?u.issues:[...u.prs,...u.issues],p=u?r===`file`?u.files:r===`link`?u.links:r?[]:s?.links??[]:[],m=l.length+d.length+f.length,h=ev(s),[,g]=(0,q.useState)(0);(0,q.useEffect)(()=>{if(m===0)return;let e=setInterval(()=>g(e=>e+1),3e4);return()=>clearInterval(e)},[m]);let _=ot(e,d.flatMap(e=>e.id&&!e.outputUnavailable?[e.id]:[]));return m===0&&p.length===0?null:(0,X.jsxs)(`div`,{className:`flex flex-col ${o===`panel`?``:`gap-0.5`} ${t}`,"data-background-ops":!0,children:[Jr(l,`sheet`).map((t,n)=>(0,X.jsx)(sn,{kind:`AGENT`,label:t.label,state:t.state,density:o,depth:t.displayDepth??t.depth,startedAt:t.startedAt,onOpen:t.id?()=>es(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:aa(e,t)},`a${n}`)),Jr(d,`sheet`).map((t,n)=>(0,X.jsx)(sn,{kind:`SHELL`,label:t.label,state:t.state,density:o,startedAt:t.startedAt,counter:t.id?Do(_.get(t.id)):void 0,counterTitle:`Lines of output so far — open the row to read them`,onOpen:t.id&&!t.outputUnavailable?()=>Ri(e,t.id,{label:t.label,startedAt:t.startedAt}):void 0,onDismiss:aa(e,t,`SHELL`),title:h(t)?`${t.label}\n${tv}`:void 0},`s${n}`)),f.map(e=>(0,X.jsx)(sn,{kind:`GITHUB`,label:e.target,state:`running`,density:o,startedAt:e.createdAt,counter:e.subject===`issue`?Mr(e.issue):yo(e.github),counterTone:e.github?.checks===`failing`&&!le(e.github,Date.now())?`danger`:void 0,counterTitle:e.subject===`issue`?e.issue?`${e.target} — ${cy(e.issue)}`:void 0:e.github?`${e.target} — ${Xv(e.github)}`:void 0,onOpen:()=>window.open(Ur(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)(bE,{links:p,panel:o===`panel`})]})}function Dk({ask:e}){return(0,X.jsx)(pm,{tone:`attention`,icon:Ue,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 Ok({call:e,sourceId:t,at:n}){let r=jD(),i=e.detail??`sub-agent`,{outcome:a,tail:o}=dE(e),s=o.slice(a.length).trim(),c=!!(r&&e.agentId);return(0,X.jsxs)(Q,{icon:Us,sourceId:t,marker:`agent`,ariaLabel:c?void 0:`Sub-agent ${i} ${o}`,at:n,children:[(0,X.jsx)(`span`,{className:`shrink-0 ${Uy}`,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:Ee.AGENT,"aria-label":`${Ee.AGENT}: ${i}`,onClick:()=>es(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 kk({from:e,unnamed:t,dispatchId:n,sourceId:r,at:i}){let a=jD(),o=!!(a&&n),s=t?void 0:e,c=t&&e?`${Ee.AGENT} — ${e}`:Ee.AGENT;return s===void 0?(0,X.jsx)(Q,{icon:Us,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":`${Ee.AGENT}${e?`: ${e}`:``}`,onClick:()=>es(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:Us,sourceId:r,marker:`agent-report`,ariaLabel:o?void 0:`Sub-agent ${s} reported`,at:i,children:[(0,X.jsx)(`span`,{className:`shrink-0 ${Uy}`,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:Ee.AGENT,"aria-label":`${Ee.AGENT}: ${s}`,onClick:()=>es(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 Ak({to:e,type:t,dispatchId:n,targetLabel:r,sourceId:i,at:a}){let o=jD(),s=nk(e,t),c=e===`main`?void 0:r??e,l=!!(o&&n);return(0,X.jsxs)(Q,{icon:Us,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:Ee.AGENT,"aria-label":`${Ee.AGENT}: ${c}`,onClick:()=>es(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 jk({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`?bc:void 0,sourceId:n,marker:t===`rest`?`rest`:`event`,ariaLabel:e,at:r,children:i?(0,X.jsx)(qy,{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:xE,children:e})}function Mk({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:`${xE} 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)(Kt,{"aria-hidden":`true`,size:13,className:CE(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)(hk,{md:e,wrap:!0})})]})}function Nk(){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 Pk({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=Gi(Math.max(0,o-a)),f=(0,q.useMemo)(()=>kO([...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 ${xE}`,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??Qr(p)}),m&&(0,X.jsx)(Kt,{"data-working-chevron":!0,"aria-hidden":`true`,size:13,className:CE(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)(FO,{tools:f,at:r?.at})}),m&&!c&&(0,X.jsx)(`div`,{id:u,hidden:!0})]})}function Fk({label:e,stopping:t,onStop:n,...r}){return(0,X.jsx)(me,{label:e,children:(0,X.jsx)(`button`,{type:`button`,...r,"aria-label":e,disabled:t,onClick:n,onMouseDown:e=>e.preventDefault(),className:Dt,children:t?(0,X.jsx)(Ie,{size:14,className:`animate-spin`}):(0,X.jsx)(fi,{size:15,strokeWidth:2})})})}function Ik({id:e,slug:t,subId:r,label:i,subagentType:a,startedAt:o,depth:s,widthDepth:c}){let[l,u]=(0,q.useState)(!1),d=(0,q.useRef)(null),[f,p]=(0,q.useState)(!1),m=R(),h=Qe(t,r),g=xe(),_=(0,q.useMemo)(()=>h.data?.messages??[],[h.data]),v=h.data?.state,y=v===`running`,b=(0,q.useMemo)(()=>Cx(_),[_]),x=(0,q.useMemo)(()=>wx(_),[_]),S=(0,q.useMemo)(()=>dr(x),[x]),C=y?Xi(S):void 0,w=y?Ir(S):void 0,T=w?Ca(w,g):void 0,E=y?So(S):void 0,D=(0,q.useMemo)(()=>y?n(S):S,[S,y]),O=y,k=h.isError||v===`gone`||_.length===0&&(v===`done`||v===`stale`);(0,q.useEffect)(()=>{let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>u(!0))});return()=>{cancelAnimationFrame(t),e&&cancelAnimationFrame(e)}},[]);let[A,j]=(0,q.useState)(null),M=(0,q.useRef)(!0);(0,q.useLayoutEffect)(()=>{let e=d.current;e&&A&&M.current&&e.scrollHeight-e.scrollTop-e.clientHeight>.5&&(e.scrollTop=e.scrollHeight)}),(0,q.useLayoutEffect)(()=>{let e=d.current;if(!e||!A)return;M.current=!0;let t=()=>{M.current&&(e.scrollTop=e.scrollHeight)},n=()=>{M.current=e.scrollHeight-e.scrollTop-e.clientHeight<160};e.addEventListener(`scroll`,n,{passive:!0});let r=new ResizeObserver(t);return r.observe(A),r.observe(e),t(),()=>{e.removeEventListener(`scroll`,n),r.disconnect()}},[A]);function N(){f||(p(!0),U.subAgentStop({slug:t,id:r}).then(({descendantsStopped:e,note:n})=>{n?G(`Sub-agent stopped. ${n}`,{duration:7e3}):G(e>0?`Sub-agent and ${e} descendant${e===1?``:`s`} stopped`:`Sub-agent stopped`),m.invalidateQueries({queryKey:[`subAgentTranscript`,t,r]})}).catch(e=>{G(e instanceof Error?e.message:`Could not stop this sub-agent`)}).finally(()=>p(!1)))}let P=h.data?.stoppable?(0,X.jsx)(Fk,{"data-stop-subagent":``,label:`Stop sub-agent`,stopping:f,onStop:N}):h.data?.outcome?(0,X.jsx)(zk,{outcome:h.data.outcome,startedAt:h.data.startedAt??o,finishedAt:h.data.finishedAt}):null;return(0,X.jsx)(qi,{id:e,depth:s,widthDepth:c,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`header`,{"data-subagent-header":!0,className:`flex ${kt} 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)(ie,{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:i,children:i})}),(0,X.jsx)(aE,{"data-subagent-header-facts":``,lastActiveAt:h.data?.lastActivityAt,fallbackAt:h.data?.startedAt??o,reading:h.data?.context?(0,X.jsx)(QT,{context:h.data.context}):null})]})]}),P&&(0,X.jsx)(`div`,{className:`flex shrink-0 items-center`,children:P})]}),(0,X.jsx)(`div`,{ref:d,className:`flex-1 min-h-0 overflow-y-auto`,children:k?(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).`}):!l||h.isLoading||_.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)(AD.Provider,{value:t,children:(0,X.jsxs)(`div`,{ref:j,"data-transcript-column":!0,className:`flex flex-col px-6 py-5`,children:[CO(D.map(e=>e.message),(e,t)=>(0,X.jsx)(fk,{m:e},t)),O&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Zy,{h:SO(D.map(e=>e.message))}),(0,X.jsx)(Pk,{since:o,startedAt:E,activityLabel:T,run:C})]})]})})}),(0,X.jsx)(Lk,{slug:t,subId:r,subagentType:a,observedModel:h.data?.model,steerable:h.data?.steerable===!0,note:h.data?.steerNote??null,stoppable:h.data?.stoppable===!0,stopNote:h.data?.stopNote??null,stopping:f,ops:e=>(0,X.jsx)(Ek,{slug:t,parentAgentId:r,transcriptShells:b,className:e})})]})})}function Lk({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=R();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)(Rk,{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)(za,{value:u,onChange:d,onSubmit:h,surface:`subAgentComposer`,placeholder:`Steer this sub-agent…`,busy:f||c,footer:(0,X.jsx)(Rk,{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 Rk({subagentType:e,observedModel:t}){let n=$o(e,t),r=n?Es(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 ${Ps}`,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 zk({outcome:e,startedAt:t,finishedAt:n}){let r=uE[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 ${vo(a)}`:i;return(0,X.jsx)(gT,{"data-subagent-outcome":e,check:e===`completed`,tooltip:o,children:i})}function Bk({id:e,slug:t,title:n,depth:r,widthDepth:i}){let a=H({queryKey:[`threadBody`,t],queryFn:()=>U.threadBody({slug:t})}),o=un(W);(0,q.useEffect)(()=>{a.refetch()},[o.board]);let s=QC(ls(o.board,t)),c=B(),l=fn.adopt(c,t),[u,d,f]=bn(l),p=vn({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)=>{j.get(l)||d(t),G(`Start failed: ${e.message.slice(0,80)}`)}}),m=Gf(Df(a.data?.markdown??``)),h=Np(m),g=(0,q.useRef)(null),_=Wm(g,m);return(0,X.jsx)(qi,{id:e,depth:r,widthDepth:i,widthOffset:1,subagentParent:t,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{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)(za,{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 Vk=`font-mono-keep overflow-x-auto whitespace-pre-wrap break-words ${em} border border-border bg-bg/75 px-4 py-2.5 text-[12px] leading-relaxed text-fg/85`;function Hk({id:e,slug:t,shellId:n,label:r,startedAt:i,depth:a,widthDepth:o}){let c=tn(t,n),l=c.data?.state,[u,d]=(0,q.useState)(!1),f=R(),p=s(i),m=l===`running`?`running${p?` ${p}`:``}`:l===`done`?`finished`:l===`gone`?`unavailable`:``,h=c.isError||l===`gone`;function g(){u||(d(!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`),f.invalidateQueries({queryKey:[`backgroundShellOutput`,t,n]})}).catch(e=>{G(e instanceof Error?e.message:`Could not stop this background shell`)}).finally(()=>d(!1)))}return(0,X.jsx)(Wk,{id:e,depth:a,widthDepth:o,kind:`background-shell`,title:r,icon:(0,X.jsx)(bc,{"aria-hidden":!0,size:14,className:`shrink-0 text-muted-60`}),stateLabel:m,command:c.data?.command,output:c.data?.output??``,truncated:c.data?.truncated===!0,running:l===`running`,loading:c.isLoading,unavailable:h,unavailableText:`Background shell output is no longer available.`,noCommandText:`Command unavailable for this background operation.`,emptyText:l===`done`?`No output was captured.`:`No output yet.`,stop:!h&&c.data?.stoppable?{label:`Stop shell`,stopping:u,onStop:g}:void 0,footer:!h&&!c.data?.stoppable&&l===`running`?c.data?.stopNote??void 0:void 0})}function Uk({id:e,slug:t,monitorId:n,label:r,depth:i,widthDepth:a}){let o=Dn(t,n),c=o.data,[l,u]=(0,q.useState)(!1),d=R(),f=c?`${c.events} event${c.events===1?``:`s`}`:``,p=s(c?.startedAt??void 0),m=c?.state===`running`?[`running${p?` ${p}`:``}`,f].join(` · `):c?.state===`ended`?[c.ended??`ended`,f].join(` · `):c?.state===`gone`?`unavailable`:``,h=o.isError||c?.state===`gone`;function g(){l||(u(!0),U.stopMonitor({slug:t,id:n}).then(({stopped:e})=>{G(e?`Monitor stopped — the worker was told`:`This monitor had already ended`),d.invalidateQueries({queryKey:[`monitorOutput`,t,n]})}).catch(e=>{G(e instanceof Error?e.message:`Could not stop this monitor`)}).finally(()=>u(!1)))}return(0,X.jsx)(Wk,{id:e,depth:i,widthDepth:a,kind:`monitor`,title:c?.description||r,icon:(0,X.jsx)(Rt,{"aria-hidden":!0,size:14,className:`shrink-0 text-muted-60`}),stateLabel:m,command:c?.command,output:c?.output??``,truncated:c?.truncated===!0,running:c?.state===`running`,loading:o.isLoading,unavailable:h,unavailableText:`This monitor is no longer available.`,noCommandText:`Script unavailable for this monitor.`,emptyText:c?.state===`ended`?`It printed nothing.`:`Nothing printed yet.`,stop:!h&&c?.stoppable?{label:`Stop monitor`,stopping:l,onStop:g}:void 0})}function Wk({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 ta(s),G(`Command copied`)}catch{G(`Could not copy command`)}}return(0,X.jsx)(qi,{id:e,depth:t,widthDepth:n,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{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)(Fk,{...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)(be,{"aria-hidden":!0,size:11}),` Copy`]})]}),s?(0,X.jsx)(Uh,{...y(`command`),text:s,language:`bash`,className:Vk}):(0,X.jsx)(`pre`,{...y(`command`),className:Vk,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)(Li,{"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 ${em} 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 ${em} 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 Gk=64,Kk=12,qk=Gk-Kk-4,Jk=16,Yk=`#4a9eff`,Xk,Zk,Qk=!1;function $k(){return Xk??=[...document.querySelectorAll(`link[rel~="icon"]`)].map(e=>({link:e,href:e.getAttribute(`href`)??``,type:e.getAttribute(`type`),sizes:e.getAttribute(`sizes`)})),Xk}function eA(e){let t=document.createElement(`canvas`);t.width=t.height=Gk;let n=t.getContext(`2d`);return n.drawImage(e,0,0,Gk,Gk),n.globalCompositeOperation=`destination-out`,n.beginPath(),n.arc(qk,Jk,16,0,Math.PI*2),n.fill(),n.globalCompositeOperation=`source-over`,n.fillStyle=Yk,n.beginPath(),n.arc(qk,Jk,Kk,0,Math.PI*2),n.fill(),t.toDataURL(`image/png`)}function tA(e){return Zk??=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(eA(i)),i.onerror=()=>n(Error(`favicon did not load`)),i.src=r.href}),Zk}function nA(e){Qk=e;let t=$k();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}tA(t).then(e=>{if(Qk)for(let{link:n}of t)n.type=`image/png`,n.removeAttribute(`sizes`),n.href=e}).catch(()=>{Zk=void 0})}var rA=new Map,iA=12;function aA(e,t){let n=rA.get(e);if(n&&n.raw===t)return n.html;let r=cd(t,re(e));if(rA.set(e,{raw:t,html:r}),rA.size>iA){let e=rA.keys().next();e.done||rA.delete(e.value)}return r}function oA(e){let t=globalThis.requestIdleCallback;t?t(e,{timeout:500}):setTimeout(e,0)}function sA(e,t){i(t)||e.prefetchQuery(pr(t)).then(()=>{let n=e.getQueryData(pr(t).queryKey);!n?.markdown||n.binary||ci(t)||oA(()=>aA(n.path,n.markdown))}).catch(()=>{})}function cA(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 uA({path:e}){return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void dA(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)(Zs,{size:12,"aria-hidden":`true`}),` Open`]})}function dA(e){return wo(e).openLocalFile({path:e}).then(Ot).catch(e=>G(`Could not open local file: ${e.message.slice(0,100)}`))}function fA({path:e,revision:t,title:n}){return(0,X.jsx)(`iframe`,{"data-pdf-view":!0,src:`${Gr(e)}${t===void 0?``:`&v=${t}`}`,title:n,className:`block min-h-0 w-full flex-1 border-0`})}function pA({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 mA({source:e}){return(0,X.jsx)(Uh,{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 hA({id:e,path:t,title:n,depth:r,widthDepth:i}){let a=ke(t),o=H({...pr(t),refetchInterval:a?!1:Zn}),s=o.data?.path??t,c=ci(t),l=No(t)&&qt(),{front:u,body:d}=cA(c?o.data?.markdown??``:``),f=Pa(s),p=Gf(d,{baseDir:f,asDocument:!0}),m=Np(p),h=(0,q.useRef)(null);Xp(h,p);let g=hh(h,p,f),_=Wm(h,p),v=sr(),y=o.data?.markdown??``,b=Np((0,q.useMemo)(()=>c?``:aA(s,y),[c,y,s]));return(0,X.jsx)(qi,{id:e,depth:r,widthDepth:i,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{title:n,subtitle:s,onClose:e}),(0,X.jsxs)(`div`,{className:`flex-1 min-h-0 ${l&&o.data?`flex flex-col`:`overflow-y-auto px-5 py-4`}`,children:[l&&o.data?(0,X.jsx)(fA,{path:s,revision:o.data.modifiedAt,title:n}):o.isLoading?(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):o.error?(0,X.jsxs)(`div`,{className:`text-[13px] text-danger-90`,children:[`Couldn’t read this file: `,o.error.message]}):o.data?.binary?(0,X.jsx)(pA,{phone:v}):c?p?(0,X.jsxs)(X.Fragment,{children:[u&&(0,X.jsx)(mA,{source:u}),(0,X.jsx)(`div`,{ref:h,className:`md-body`,dangerouslySetInnerHTML:m}),g,_,o.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.`,v?``:` Open it to read the rest.`]})]}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):y?(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:b}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!c&&!o.isLoading&&!o.error&&o.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.`})]}),v?(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)(uA,{path:s})})]})})}function gA(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 _A(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 vA({slug:e,path:t,active:n}){let r=ci(t),i=No(t)&&qt(),a=ke(t),o=H({...pr(t),refetchInterval:a?!1:Zn}),s=o.data?.path??t,c=o.data?.markdown??``,{front:l,body:u}=cA(r?c:``),[d,f]=(0,q.useState)(r?`rendered`:`source`),p=Pa(s),m=Gf(u,{baseDir:p,asDocument:!0}),h=Np(m),g=Np((0,q.useMemo)(()=>d===`source`?aA(s,c):``,[c,s,d])),_=(0,q.useRef)(null),v=(0,q.useRef)(null),y=(0,q.useRef)(null);Xp(_,m);let b=hh(_,m,p),x=Wm(_,m),S=Nt(s),C=Fn(),w=B(),T=Mt(e);return(0,q.useEffect)(()=>{if(!n)return;let t=()=>document.querySelector(`[data-pane-thread] textarea, 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=y.current,a=window.getSelection(),o=a&&!a.isCollapsed&&a.rangeCount>0?a.getRangeAt(0):null,l=!!(i&&o&&i.contains(o.commonAncestorContainer)),u=l?a.toString():``;if(!l||!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=v.current;if(f&&f.contains(o.commonAncestorContainer)){let e=gA(f,o.startContainer,o.startOffset),t=gA(f,o.endContainer,o.endOffset);e!==null&&t!==null&&(d={startLine:_A(c,Math.min(e,t)),endLine:_A(c,Math.max(0,Math.max(e,t)-1))})}else d=N(c,u);let p=t(),m=fn.followUp(w,e,T),{prose:h,attachments:g}=fa(j.get(m)),_=V(Vr({path:s,...d??{}}),W.composerContext[e]??[],h),b=pn(h,r(p,h),_);j.set(m,Pt(b.prose,g.map(e=>e.path))),ba(e,{token:_,path:s,text:u,...d??{}}),a.removeAllRanges(),requestAnimationFrame(()=>{let e=t();e&&(e.setSelectionRange(b.caret,b.caret),e.focus())})}return window.addEventListener(`keydown`,i,!0),()=>window.removeEventListener(`keydown`,i,!0)},[n,e,s,c,w,T]),(0,X.jsxs)(`div`,{ref:y,"data-file-viewer-panel":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,X.jsx)(L,{title:S,subtitle:na(s,C),onClose:Ko,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:()=>f(e),"aria-pressed":d===e,className:`rounded px-2 py-0.5 transition-colors ${d===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 ${i&&o.data?`flex flex-col`:`overflow-y-auto px-5 py-4`}`,children:[i&&o.data?(0,X.jsx)(fA,{path:s,revision:o.data.modifiedAt,title:S}):o.isLoading?(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):o.error?(0,X.jsxs)(`div`,{className:`text-[13px] text-danger-90`,children:[`Couldn’t read this file: `,o.error.message]}):o.data?.binary?(0,X.jsx)(pA,{}):d===`source`?c?(0,X.jsx)(`pre`,{ref:v,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:g}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):m?(0,X.jsxs)(X.Fragment,{children:[l&&(0,X.jsx)(mA,{source:l}),(0,X.jsx)(`div`,{ref:_,className:`md-body`,dangerouslySetInnerHTML:h}),b,x]}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!o.isLoading&&!o.error&&o.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:[i||o.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)(uA,{path:s})]})]})}function yA(){return{dirs:new Map,files:new Map}}function bA(e,t,n){let r=e.replace(/[\\/]+$/,``);if(t){let e=da(t,r);if(e!==null)return h(e)}if(n){let e=da(n,r);if(e!==null)return[`~`,...h(e)]}let i=h(r);return/^[\\/]/.test(r)?[`/`,...i]:i}var xA=(e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`,numeric:!0});function SA(e,t,n=``){let r=[];for(let i of[...e.dirs.keys()].sort(xA)){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:SA(a,t+1,s)})}for(let n of[...e.files.keys()].sort(xA))r.push({kind:`file`,name:n,depth:t,file:e.files.get(n)});return r}function CA(e,t,n){let r=yA();for(let i of e){let e=bA(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=yA(),a.dirs.set(t,e)),a=e}a.files.set(e[e.length-1],i)}return SA(r,0)}function wA(e){let t=[],n=e=>{for(let r of e)t.push(r),r.kind===`dir`&&n(r.children)};return n(e),t}var TA=/(?:^|[\s;&|(])(?:rm|mv|unlink|git\s+(?:rm|mv|clean|checkout|restore|reset|stash|apply))\b/;function EA(e){if(e.edit||e.edits?.length)return!0;let t=Xa(e.name);return Yn.has(t)?!0:t!==`bash`||!e.command?!1:TA.test(e.command)||_a(e.command).length>0}function DA(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(EA(r[e]))return`${n.sourceId??n.at??`#${t}`}:${e}:${r[e].status??``}`}}var OA=10;function kA({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*OA},children:[(0,X.jsx)(`span`,{className:`flex shrink-0`,children:(0,X.jsx)($s,{size:12,className:`${Z} text-muted-45`})}),(0,X.jsx)(`span`,{className:`ml-[5px] min-w-0 truncate`,title:e,children:e})]})}function AA({files:e}){let t=xe(),n=Fn();return(0,X.jsx)(`div`,{"data-edited-file-tree":!0,className:`flex flex-col gap-y-px`,children:wA(CA(e,t,n)).map(e=>e.kind===`dir`?(0,X.jsx)(kA,{name:e.name,depth:e.depth},`d:${e.path}`):(0,X.jsx)(jA,{file:e.file,name:e.name,depth:e.depth,homeDir:n},e.file.path))})}function jA({file:e,name:t,depth:n,homeDir:r}){let i=R();return(0,X.jsx)(oy,{testKind:`file`,testId:e.path,mark:(0,X.jsx)(Qs,{size:12,className:`${Z} -mr-[2px] text-muted-60`}),name:t,indent:n*OA,onOpen:()=>I(e.path),onPrewarm:()=>sA(i,e.path),title:na(e.path,r),status:(0,X.jsxs)(X.Fragment,{children:[(e.added??0)>0&&(0,X.jsxs)(`span`,{style:{color:lo.fgSuccess},children:[`+`,e.added]}),(e.added??0)>0&&(e.removed??0)>0&&` `,(e.removed??0)>0&&(0,X.jsxs)(`span`,{style:{color:lo.fgDanger},children:[`−`,e.removed]})]})})}function MA({link:e}){let t=R(),n=Fn();return e.kind===`link`?(0,X.jsx)(oy,{testKind:`link`,testId:e.id,mark:(0,X.jsx)(Zs,{size:12,className:`${Z} text-muted-60`}),name:e.label,href:e.target,title:e.target,status:NA(e.target)}):(0,X.jsx)(oy,{testKind:`link`,testId:e.id,mark:(0,X.jsx)(En,{size:12,className:`${Z} text-muted-60`}),name:e.label,onOpen:()=>I(e.target),onPrewarm:()=>sA(t,e.target),title:na(e.target,n),status:null})}function NA(e){try{return new URL(e).host||e}catch{return e}}var PA=1500;function FA(e,t,n,r){let i=R(),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`})},PA))},[i,e,t,n,r])}function IA({thread:e,centred:t=!1}){let n=Oi(),r=ar(e.id,{poll:!1}),i=r.data?.editedFiles??[],a=(0,q.useMemo)(()=>DA(r.data?.messages??[]),[r.data?.messages]);FA(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}=Q_(e,(0,q.useMemo)(()=>Cx(r.data?.messages??[]),[r.data?.messages]),x(e.id)),p=ev(e),m=o.filter(pa),{railFilesCollapsed:h}=un(yn),g=[{head:`Sub-agents`,rows:m.map(t=>(0,X.jsx)(Ty,{agent:t,slug:e.id,now:n,onDismiss:aa(e.id,t)},t.id??t.label))},{head:`Child threads`,rows:s.map(e=>(0,X.jsx)(Ey,{child:e,now:n},e.id))},{head:`Background shells`,rows:c.map(t=>(0,X.jsx)(hy,{shell:t,slug:e.id,now:n,onDismiss:aa(e.id,t,`SHELL`),watched:p(t)},t.id??t.label))},{head:`Pull requests`,rows:l.map(e=>(0,X.jsx)(ly,{watch:e},e.id))},{head:`Issues`,rows:u.map(e=>(0,X.jsx)(ly,{watch:e},e.id))},{head:`Monitors`,rows:d.map(t=>(0,X.jsx)(xy,{watch:t,slug:e.id,now:n},t.id))},{head:`Timers`,rows:f.map(e=>(0,X.jsx)(gy,{watch:e,now:n},e.id))},{head:`Files and links`,rows:(e.links??[]).map(e=>(0,X.jsx)(MA,{link:e},e.id))},{head:`Edited files`,rows:i.length>0?[(0,X.jsx)(AA,{files:i},`tree`)]:[],count:i.length,collapsed:h,onToggle:()=>yn.railFilesCollapsed=!yn.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)(jy,{groups:g,divider:!1})})})}function LA({slug:e}){let t=un(W),n=t.filePanels.some(e=>!e.closing),r=Ns(),i=We(e),a=xo(r,e,()=>i),o=a.kind===`found`?a.thread:void 0;r?.projectDir,(0,q.useEffect)(()=>{let e=window.matchMedia?.(`(min-width: ${se}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 He(`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?P(o):e;document.title=t?`${n} · ${t} — Frizz`:`${n} · Frizz`},[r?.projectLabel,r?.projectName,e,o]);let f=o!==void 0&&bs(o);return(0,q.useEffect)(()=>(nA(f),()=>nA(!1)),[f]),(0,X.jsx)(Re,{children:(0,X.jsxs)(u,{className:`h-dvh min-h-0 bg-bg text-sm text-fg`,children:[(0,X.jsx)(it,{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:{...de,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)(js,{slug:e}):(0,X.jsx)(_n,{label:`this thread`,resetKeys:[e],children:(0,X.jsx)(rr,{slug:e,showReturnToQueue:!0})})}),o?(0,X.jsx)(_n,{label:`this thread's side pane`,resetKeys:[e],children:(0,X.jsx)(RA,{slug:e,thread:o})}):(0,X.jsx)(`div`,{className:`hidden w-[var(--full-pane)] shrink-0 split:block`,"aria-hidden":`true`})]})}),(0,X.jsx)(y,{onEscapeAtRest:()=>BT(e)})]})})}function RA({slug:e,thread:t,rail:n=!0,centredRail:r=!1}){let i=un(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)(IA,{thread:t,centred:r})}),i.filePanels.map((t,n)=>(0,X.jsx)(zA,{slug:e,path:t.path,closing:!!t.closing,active:n===i.filePanels.length-1&&!t.closing&&i.splitFileViewer},t.id))]})}function zA({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)(vA,{slug:e,path:t,active:r})})})}export{Hk as BackgroundShellSheet,gh as LightboxHost,hA as MarkdownDrawer,Uk as MonitorSheet,RA as SidePane,LA as StandaloneThreadPage,Ik as SubAgentSheet,xT as ThreadActionsSheet,Bk as ThreadDrawer,MD as ThreadView};
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:`${CC} text-left`,children:[(0,X.jsx)(EC,{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)(bS,{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)(TC,{md:a})]})]})}function TC({md:e}){return(0,X.jsx)(`div`,{className:`card-md mt-1 text-muted`,children:(0,X.jsx)(Hh,{className:`md-body`,html:Gf(e)})})}function EC({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)(fi,{size:14,strokeWidth:3}):(0,X.jsx)(`span`,{className:`size-2.5 rounded-full bg-fg`}))})}function DC({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 OC({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)(cS,{className:`mt-2 text-[13px] leading-[18px] text-muted`})]})}function kC({a:e,step:t,first:n,writing:r,onBack:i,onNext:a}){let o=e.answerFor(t.q,t.path),s=qx(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)(FC,{children:[(0,X.jsx)(`button`,{type:`button`,"data-answer-back":!0,disabled:n,onClick:i,className:`${MC} ${NC} 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:`${MC} ${NC}`,children:s?`Next`:`Skip`}),u&&(0,X.jsx)(`button`,{type:`button`,"data-answer-continue":!0,disabled:!s,onClick:a,className:`${MC} ${PC} px-6 disabled:opacity-35`,children:`Continue`})]})}function AC({a:e,steps:t,onChange:n}){let r=t.map(t=>({s:t,said:_C(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:IC(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 jC({a:e,onSent:t}){return(0,X.jsx)(FC,{children:(0,X.jsx)(`button`,{type:`button`,"data-answer-send":!0,disabled:e.staged===0||e.sending,onClick:()=>{e.submit(),t()},className:`${MC} ${PC} flex-1 disabled:opacity-35`,children:e.sending?`Sending…`:`Send answers`})})}var MC=`flex h-[46px] shrink-0 items-center justify-center rounded-[12px] text-[15.5px] font-semibold outline-none`,NC=`px-[18px] text-muted active:bg-hover focus-visible:bg-hover`,PC=`bg-fg text-bg active:opacity-90`;function FC({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=Pr(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 IC(e){return vC(e.trim().split(/\n\s*\n/)[0]??``)}function LC(e){return(0,q.useSyncExternalStore)(e=>os(W,e),()=>e?RC(e)!==`codex`:!1,()=>!1)}function RC(e){return ls(W.board,e)?.backend}function zC(e,t,n,r){let i=fn.followUp(e,t,n);return cs(i,r),i}function BC(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 VC(e){let t=R(),n=z(),[r,i]=(0,q.useState)(!1);return{unqueue:(0,q.useCallback)(a=>{if(!e||r)return;let o=ls(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}Le(t,e,a.rawText,a.deliveryId),zC(n,e,o,a.text),BC(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 HC(e){let t=R(),n=z(),[r,i]=(0,q.useState)(!1),a=(0,q.useCallback)(n=>{!e||r||hn(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||(zC(n,e,ls(W.board,e)?.sessionId,t.text),BC(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 UC=new Map;function WC(e,t){let n=(UC.get(e)??[]).filter(e=>e.deliveryId!==t.deliveryId);n.push(t),UC.set(e,n.slice(-8))}var GC=e=>e.replace(/\s+/g,` `).trim();function KC(e,t){let n=UC.get(e);if(!n?.length)return;let r=GC(t);for(let t=n.length-1;t>=0;t--){let i=GC(n[t].text);if(!i||!r.includes(i))continue;let[a]=n.splice(t,1);return n.length||UC.delete(e),a.deliveryId}}function qC(e){return e.project?`${zo(e.project)}/thread/${e.slug}`:Yt(`/thread/${e.slug}`)}function JC({peer:e,text:t,queued:n,sourceId:r,at:i}){let[a,o]=(0,q.useState)(!1),s=(0,q.useId)(),c=e.thread,l=We(c&&!c.project?c.slug:void 0),u=l?P(l):c?.title,d=Gf(t),f=Np(d),p=(0,q.useRef)(null),m=Wm(p,d),h=(0,q.useRef)(null),g=(0,q.useRef)(!1),_=()=>{g.current=document.activeElement===h.current,o(e=>!e)};(0,q.useLayoutEffect)(()=>{g.current&&(g.current=!1,h.current?.focus())},[a]);let v=e=>{e.target.closest(`a, button`)||_()},y=e=>e.preventDefault(),b=c?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`shrink-0 ${Uy}`,children:`Message from `}),(0,X.jsx)(`a`,{href:qC(c),"data-session-peer-link":!0,title:`Open the thread that sent this`,onMouseDown:y,className:`min-w-0 truncate [font-variant-caps:normal] ${$y}`,children:u})]}):(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name?`Message from session ${e.name}`:`Message from another session`}),x=(0,X.jsx)(`button`,{ref:h,type:`button`,"data-session-message-toggle":!0,onClick:_,onMouseDown:y,"aria-expanded":a,"aria-controls":s,"aria-label":a?`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)(Kt,{"aria-hidden":`true`,size:12,className:`${Yy} ${a?`-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:a?(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:v,onMouseDown:y,className:`group/wake mx-auto max-w-[calc(100%-66px)] cursor-pointer px-3`,children:(0,X.jsx)(Vy,{icon:lc,at:i,trailing:x,children:b})}),(0,X.jsxs)(`div`,{id:s,className:`card-md text-fg/85`,children:[(0,X.jsx)(`div`,{ref:p,className:`md-body [overflow-wrap:anywhere]`,dangerouslySetInnerHTML:f}),m]})]}):(0,X.jsx)(`div`,{onClick:v,onMouseDown:y,className:`group/wake cursor-pointer`,children:(0,X.jsx)(Q,{icon:lc,marker:`session-message`,at:i,trailing:x,children:b})})})}function YC(e){return e.role===`assistant`&&!e.kind&&e.text.trim()!==``&&Eg(e.text).some(e=>e.kind===`prose`)}function XC(e,t){let n=e.length>0&&!c_(e[0])?[-1]:[];e.forEach((e,t)=>{c_(e)&&n.push(t)});let r=[];return n.forEach((i,a)=>{let o=a+1<n.length?n[a+1]-1:e.length-1,s=wx(e.slice(0,o+1),i);if(s.length===0)return;let c=-1;if(i>=0){for(let t=i+1;t<s[0];t++)if(YC(e[t])){c=t;break}}let l=c>=0?c+1:i+1;for(let[e,t]of s.entries())t>l&&r.push({from:l,to:t-1,...e===0&&c>=0?{lead:c}:{}}),l=t+1;!(t.running&&a===n.length-1)&&l<=o&&r.push({from:l,to:o})}),r}function ZC(e,t){let n=0,r=t.lead===void 0?0:e[t.lead].tools?.length??0;for(let i=t.from;i<=t.to;i++){let t=e[i];(t.role===`user`&&t.wake||t.boundary===`wake`)&&n++,r+=t.tools?.length??0}return{rounds:n,calls:r}}function QC(e,t,n){return{type:`frizz-inline-vis-theme`,requestId:e,colorScheme:t,vars:n}}function $C(e,t){return typeof e==`object`&&!!e&&e.type===`frizz-inline-vis-applied`&&e.requestId===t}var ew=new Set([`planning`,`planned`,`active`,`needs-human`,`blocked`]);function tw(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&&ew.has(e.status))}function nw(e,t){return e.pending?`loading`:e.failed?`failed`:t.running?`starting`:t.adoptable?`adopt`:`empty`}var rw=`sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3 ${kt} 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`,iw=`flex min-w-0 flex-1 items-center gap-2.5 pl-1 max-[640px]:basis-full`,aw=`flex shrink-0 items-center max-[640px]:w-full`;function ow(e){return e?.trim()?{kind:`profile-error`,message:`Profile controls unavailable: ${e.trim().slice(0,160)}`}:null}function sw(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 cw(e){return e.permissionChangePending===!0||e.permissionPending!==void 0||e.profileChangePending===!0||e.runtimeControlPending===!0}function lw(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 uw(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 dw(e){let t=We(e),n=H({queryKey:[`threadProfileOptions`,e],queryFn:()=>U.threadProfileOptions({slug:e}),enabled:!!(t&&!t.foreign&&t.kind===`session`),staleTime:5e3}),r=vn({mutationFn:t=>U.setThreadProfile({slug:e,model:t.model,...t.effort?{effort:t.effort}:{}})}),i=vn({mutationFn:t=>U.setThreadPermission({slug:e,permissionMode:t})}),o=vn({mutationFn:t=>U.upgradeThreadModel({slug:e,sessionId:t})}),s=sr(),c=vn({mutationFn:t=>U.stopThreadTurn({slug:e,sessionId:t})}),l=r.isPending||i.isPending||o.isPending,u=t?.backend===`codex`?`codex`:t?.backend===`acp`?`acp`:t?.backend===`opencode`?`opencode`:`claude`,d=t?uo(t.id):void 0,f=H({queryKey:Da([`acpAgents`],d),queryFn:()=>ct(d).acpAgents(),enabled:!!t&&u===`acp`}),p=Ro(d,!!t&&u===`opencode`),m=u===`acp`?Bi(t?.model?.trim()):void 0,h=pi(d,m?[m]:[],m);if(!t||t.foreign||t.kind!==`session`)return{busy:l,footer:null,phoneTools:null,status:null};let g=l||cw(t),_=t.model?.trim(),v=t.effort?.trim(),y=u===`acp`?Bi(_):void 0,b=r.isPending?r.variables:void 0,x=t.profilePendingModel??b?.model,C=t.profilePendingEffort??b?.effort,w=n.data?.options??[],{modelSelectable:T}=uw(w,_,v,t.runtime===`exited`),E=n.data!==void 0,D=f.data?.find(e=>e.id===y)?.label??y,O=[{id:u,label:u===`codex`?`Codex`:`Claude Code`,options:w}],k=ow(n.isError?n.error.message:void 0),A=t.permissionMode?gr(t.permissionMode):`auto`,j=cr.some(e=>e.value===A)?A:`auto`,M=i.isPending?i.variables:j,N=sw(t);function P(e){e!==j&&i.mutate(e,{onSuccess:e=>G(lw(e.effect,`claude`)),onError:e=>G(`Permission change failed: ${e.message.slice(0,120)}`)})}let F=u===`claude`?sw(t):null;function I(){t?.sessionId&&o.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(u===`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:[(u===`claude`||u===`codex`)&&(0,X.jsx)(ht,{groups:O,value:{provider:u,model:_,effort:v},pending:x||C?{provider:u,model:x,effort:C}: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 ${u===`codex`?`Codex`:`Claude Code`} model and effort`,title:T?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:g||!E||!T||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:o.isPending,onUpgrade:I}:void 0}),u===`acp`&&y&&_&&(0,X.jsx)(ht,{groups:[or({agent:{id:y,label:D??y},models:h.models[y],loading:h.loading[y]??!1,saved:_,onRequestOptions:()=>h.request(y)})],value:Qn(_),pending:x?Qn(x):void 0,onValueChange:e=>L({model:e.model,effort:``}),ariaLabel:`Thread model and effort`,menuAriaLabel:`Choose ${D??y} model`,title:`This thread's ${D??y} model`,disabled:g,compact:!0,side:`top`,className:`max-w-[20rem]`}),u===`opencode`&&(0,X.jsx)(ht,{groups:[mr({models:p.models,loading:p.loading,saved:_,onRequestOptions:p.request})],value:Jt(_),pending:x?Jt(x):void 0,onValueChange:e=>L({model:a(e),effort:``}),ariaLabel:`Thread model and effort`,menuAriaLabel:`Choose OpenCode model and effort`,title:`This thread's OpenCode model and reasoning level`,disabled:g,compact:!0,side:`top`,className:`max-w-[20rem]`})]});return{busy:g,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)(Bt,{children:[R,u===`claude`&&(0,X.jsx)(Ct,{variant:`readout`,side:`top`,value:M,onValueChange:e=>P(e),options:cr,ariaLabel:`Thread permission mode`,title:N?`${N} — changing permissions restarts this thread's worker process`:M===`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:g||N!==null,className:`shrink-0`}),u===`opencode`&&(0,X.jsx)(Ct,{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:er,ariaLabel:`Thread permission mode`,title:`Applied to the session at once, and to its sub-agents.`,disabled:g,className:`shrink-0`})]}),u===`opencode`&&t.runtime===`running`&&t.sessionId&&(0,X.jsxs)(`button`,{type:`button`,"data-stop-turn":!0,onClick:()=>c.mutate(t.sessionId,{onError:e=>G(`Stop failed: ${e.message.slice(0,120)}`)}),disabled:c.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)(xc,{size:8,fill:`currentColor`,strokeWidth:0,"aria-hidden":!0}),!s&&`Stop`]}),(0,X.jsx)(S,{gauge:u===`acp`||u===`opencode`?void 0:{backend:u,model:_},mcp:{slug:e},side:`top`})]}),x&&C&&(0,X.jsxs)(`span`,{className:`min-w-0 truncate text-[9px] text-muted-50`,children:[`→ `,x,` · `,C,` pending`]})]}),phoneTools:R,status:k?(0,X.jsx)(`div`,{"data-thread-control-error":``,className:`px-1 pt-1 text-[9.5px] leading-tight text-muted-65`,children:k.message}):null}}function fw({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 Vn(e,{terminateLive:t});n.kind===`needs-confirmation`&&a({hold:n.hold}),n.kind!==`done`&&r(!1)}let s=Xe(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)(Ie,{"aria-hidden":!0,size:t?15:17,className:`animate-spin`}):(0,X.jsx)(fi,{"aria-hidden":!0,size:t?15:17,strokeWidth:2.6,className:`translate-y-[0.1em]`}),`Done`]}),(0,X.jsx)(ft,{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)(Ie,{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 pw={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 mw({checked:e,onChange:t,disabled:n,label:r,size:i=`sm`,testId:a}){let o=pw[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 hw({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 gw({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(`[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:ko(n?.width??e.clientWidth,_w),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),vw)}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)(Wn,{open:t!==`closed`,onOpenChange:e=>{e||(clearTimeout(i.current),n(`closed`))},children:[(0,X.jsx)(Se,{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 ${zi} items-center justify-center outline-none transition-[color,background-color] hover:bg-hover-strong`,children:(0,X.jsx)(hw,{...Aa,className:u?`text-attention-90`:`text-muted group-hover/goal:text-fg group-focus-visible/goal:text-fg`})})}),t===`preview`?(0,X.jsx)($e,{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)(yw,{armed:l})}):(0,X.jsx)($e,{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)(kw,{thread:e,armed:l,close:()=>n(`closed`)})})]})}var _w=736,vw=260;function yw({armed:e}){let t=e?.prompt?.trim(),n=e?Ow({stopHook:e.stopHook===!0,heartbeat:e.heartbeat===!0,postCompaction:e.postCompaction===!0,seconds:e.intervalSeconds??Sw}):[];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 bw=1,xw=1440,Sw=600;function Cw(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(xw,Math.max(bw,n))*60:t}var ww=null;function Tw(e){return{prompt:e.text.trim(),stopHook:e.stopHook,heartbeat:e.heartbeat,postCompaction:e.postCompaction,seconds:e.seconds}}function Ew(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 Dw(e,t){return!e.archived&&!t}function Ow(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 kw({thread:e,armed:t,close:n,heading:r=!0}){let i=Dw(e,t)?Ao:``,a=ww?.slug===e.id?ww.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??Sw),g=c||u||f,[_,v]=(0,q.useState)(String(Math.round((a?.seconds??t?.intervalSeconds??Sw)/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??Sw}),x=e=>({text:o,stopHook:c,heartbeat:u,postCompaction:f,seconds:Cw(_,m),...e}),S=(0,q.useRef)(x());S.current=x(),(0,q.useEffect)(()=>()=>{let n=S.current;if(Ew(n,b.current)){ww?.slug===e.id&&(ww=null);return}if(n.text.trim()===``&&!t){ww={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?ww?.slug===e.id&&(ww=null):ww={slug:e.id,draft:t},n});return C.current=n,n}async function T(t){let n=t.text.trim()||null;if(Ew(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={...Tw(t),prompt:n??``};let r=Ow(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(Ew(x(),b.current)||o.trim()===``&&!t){n();return}w(x()).then(e=>{e&&n()})}function D(){let e=Cw(_,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 ${ui(k.at)}`:`Last sent ${k.how} ${ui(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:Sa,onChange:e=>s(e.target.value),onKeyDown:e=>{ts({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)(mw,{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)(mw,{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:bw,max:xw,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)(mw,{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 Aw=`frizz:send-mode`;function jw(){try{return localStorage.getItem(Aw)===`queue`?`queue`:`steer`}catch{return`steer`}}var Mw=k({mode:typeof window>`u`?`steer`:jw()});typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`storage`,e=>{(e.key===Aw||e.key===null)&&(Mw.mode=jw())});function Nw(e){Mw.mode!==e&&(Mw.mode=e);try{e===`steer`?localStorage.removeItem(Aw):localStorage.setItem(Aw,e)}catch{}}function Pw(){return un(Mw).mode}function Fw(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 Iw=new Map;function Lw(e){let t=Iw.get(e);if(t)return t;let n=U.threadSkills({slug:e}).then(e=>e.skills,()=>(Iw.delete(e),[]));return Iw.set(e,n),n}function Rw({className:e,above:t,phoneBarOverride:n,phoneChrome:r,readAndAnswerHost:i}){let a=(0,q.useContext)(SS),o=sr(),s=r??o;return(0,X.jsxs)(`div`,{"data-thread-composer-box":zw,"data-remote-composer":!0,"data-thread-action-bar":``,className:s?`flex flex-col gap-2 px-3 py-2.5`:e,children:[t,s&&n&&(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:n({editReply:()=>{}})}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 ${s?``:`px-3 py-2`}`,children:[(0,X.jsx)(an,{host:i}),!s&&(a?.staged??0)>0&&(0,X.jsx)(`button`,{type:`button`,"data-remote-send-answers":!0,disabled:a.sending,onClick:a.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:a.sending?`Sending…`:`Send answers`})]})]})}var zw=`chatComposer`;function Bw(e){let t=Is();return t?(0,X.jsx)(Rw,{...e,readAndAnswerHost:t}):(0,X.jsx)(Vw,{...e})}function Vw({slug:e,className:t,id:n,above:r,phoneBarOverride:i,phoneChrome:a}){let{fileDrop:o}=rC(),s=un(W),c=We(e),l=(0,q.useContext)(SS),u=(0,q.useContext)(iv),d=(0,q.useContext)(pv),f=Z_(c),p=(l?.staged??0)+(u?.fencedCount??0)+ +!!f.staged,h=c?.runtime===`running`,g=(0,q.useContext)(mv)?.held??0,_=h||g>0,{steer:v}=Hr(c?.backend),y=Pw(),b=v?y:`queue`,x=c?.foreign?`Send a message to take over this session…`:Fw({staged:p,openQuestions:!!c?.pendingQuestion||(c?B(c):!1),running:_,mode:b,steerable:v}),S=z(),C=fn.followUp(S,e,c?.sessionId),[w,T,E]=bn(C),D=dw(e),O=F(e),[k,A]=(0,q.useState)(null),j=(0,q.useMemo)(()=>()=>Lw(e),[e]),[N,P]=(0,q.useState)(null),I=s.composerContext[e],L=(0,q.useMemo)(()=>I?.map(e=>e.token)??[],[I]);(0,q.useEffect)(()=>{let t=W.composerContext[e];if(!t?.length)return;let{prose:n}=fa(w),r=t.filter(e=>ys(n,e.token));r.length!==t.length&&(W.composerContext[e]=r)},[e,w,I]);let R=Ai(c),ee=sr(),te=a??ee,ne=c?.runtime===`running`||c?.runtime===`spawning`,re=P_(c),V=c?oo(c).archive&&!ne&&!re:!1,ie=c&&c.kind===`session`&&c.foreign!==!0?(0,X.jsx)(gw,{thread:c}):void 0;function H(t=!1){let n=w.trim(),r=te?null:l?.take()??null,i=te?null:u?.takeFenced()??null,a=te?null:f.take();if(!n&&!r&&!i&&!a)return;let o=Ae(n);if(o){if(E(),c?.backend===`acp`){G(`An ACP agent signs in through its own CLI — Frizz holds no account for it`);return}if(c?.backend===`opencode`){G("OpenCode signs in through its own CLI: run `opencode auth login`");return}let e=c?.backend===`codex`?`codex`:`claude`;o===`login`?A(e):P(e);return}let s=M(e),p=n?Os(n,s,S):``,m=a?a.compose(p):p,h=i?To(i.wire,m):m,g=r?To(Zt(r.display),h):h,y={onOptimistic:()=>{E(),r?.onOptimistic(),i?.onOptimistic(),a?.onOptimistic()},onSuccess:()=>{r?.onSuccess(),a?.onSuccess()},...r?{answers:r.answers,displayText:g}:{},...a?{todos:a.todos}:{},...b===`queue`&&!t&&(_||c?.deliveryInFlight===!0)?{hold:!0}:{},...v?{}:{failureToast:e=>`Send failed — ${e.slice(0,160)}`},supersedes:KC(C,h),onRollback:t=>{cs(C,w),Ds(e,s),WC(C,{...t,text:w}),r?.onRollback(t.kept),i?.onRollback(),a?.onRollback()}};O.submit(h,{...y,interrupt:t}),d?.sent?.()}let ae=(0,q.useRef)(H);ae.current=H;let oe=te?void 0:u?.composer;return(0,q.useEffect)(()=>oe?(oe.set(()=>ae.current()),()=>oe.set(null)):void 0,[oe]),te?(0,X.jsxs)(`div`,{"data-thread-composer-box":zw,"data-thread-action-bar":``,"data-phone-thread-bar":``,children:[(0,X.jsx)(za,{contextTokens:L,id:n,surface:zw,value:w,onChange:T,onSubmit:()=>H(),onInterruptSubmit:R?()=>H(!0):void 0,slashSuggest:j,placeholder:c?.foreign?x:ne?v?`Steer…`:`Queue…`:`Reply…`,busy:D.busy,fileDrop:o,phone:{layout:`bar`,tools:D.phoneTools,idlePrimary:V&&c?e=>(0,X.jsx)(fw,{thread:c,compact:e}):void 0,override:i,onLongPressSend:R?()=>H(!0):void 0}}),D.status,k&&(0,X.jsx)(m,{backend:k,onClose:()=>A(null),onAuthed:()=>A(null)}),N&&(0,X.jsx)(ua,{backend:N,onClose:()=>P(null)})]}):(0,X.jsxs)(`div`,{"data-thread-composer-box":zw,"data-thread-action-bar":``,className:t,children:[r,(0,X.jsx)(za,{contextTokens:L,id:n,surface:zw,value:w,onChange:T,onSubmit:()=>H(),onInterruptSubmit:R?()=>H(!0):void 0,slashSuggest:j,placeholder:x,busy:D.busy,footer:D.footer,railLead:ie,fileDrop:o,send:c?.foreign?void 0:{mode:b,onMode:Nw,running:_,staged:p,steerable:v}}),D.status,k&&(0,X.jsx)(m,{backend:k,onClose:()=>A(null),onAuthed:()=>A(null)}),N&&(0,X.jsx)(ua,{backend:N,onClose:()=>P(null)})]})}function Hw({slug:e,above:t,phoneBarOverride:n,phoneChrome:r}){return We(e)?(0,X.jsx)(Bw,{slug:e,id:`followup-input`,className:`shrink-0 px-3 py-3`,above:t,phoneBarOverride:n,phoneChrome:r}):null}var Uw=24,Ww=2;function Gw(e,t,n,r,i,a){return(n-e)*(a-t)-(r-t)*(i-e)}function Kw(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 qw(e,t,n){if(Math.hypot(t.x-e.x,t.y-e.y)<Ww)return!1;if(t.x>=n.left&&t.x<=n.right&&t.y>=n.top&&t.y<=n.bottom)return!0;let r=Kw(e,n);if(!r)return!1;let[i,a,o,s]=r,c=Gw(e.x,e.y,i,a,t.x,t.y),l=Gw(i,a,o,s,t.x,t.y),u=Gw(o,s,e.x,e.y,t.x,t.y);return!((c<0||l<0||u<0)&&(c>0||l>0||u>0))}function Jw(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 Yw(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)>=Uw){i=n;break}}return qw(i,r,n)}function Xw(e,t=[],n=[]){let{todos:r,agents:i,children:a,shells:o,prs:s,issues:c,commands:l,timers:u,files:d,links:f}=Q_(e,t,n),p=r.filter(e=>!e.done).length;return[{key:`todo`,n:e.runtime===`turn-idle`&&e.lastFence?.kind===`awaiting`&&ks(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(ms)},{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 Zw({slug:e,subAgents:t,className:n=`px-1 pt-1.5`,density:r=`card`}){let i=Jr(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)(sn,{kind:`AGENT`,label:t.label,state:t.state,density:r,depth:t.depth,startedAt:t.startedAt,parentSlug:e,onOpen:t.id?()=>es(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:aa(e,t)},t.id??`${t.startedAt}-${n}`))})}var Qw=300,$w=50,eT=480,tT=12,nT=6,rT={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 iT({thread:e,transcriptShells:t=[],only:n}){let r=aC(e),i=x(r.id),[a,o]=(0,q.useState)(null),s=(0,q.useRef)(void 0),c=(0,q.useRef)(void 0);(0,q.useEffect)(()=>()=>{clearTimeout(s.current),clearTimeout(c.current)},[]);let l=Xw(r,t,i).filter(e=>!n||n.includes(e.key)),u=(0,q.useRef)(null),d=(0,q.useRef)([]),f=a!==null,p=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!f){p.current=null;return}let e=e=>{d.current=Jw(d.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}),d.current=[]}},[f]);let m=(0,q.useRef)(null),h=(0,q.useCallback)(e=>{e&&(m.current=e)},[]),g=()=>{let e=m.current?.isConnected?m.current.getBoundingClientRect():void 0;return!!e&&Yw(d.current,performance.now(),e)},_=a!==null&&!l.some(e=>e.key===a);if((0,q.useEffect)(()=>{_&&(clearTimeout(s.current),clearTimeout(c.current),o(null))},[_]),l.length===0)return null;let v=e=>{clearTimeout(s.current),clearTimeout(c.current),o(e)},y=e=>{if(clearTimeout(s.current),clearTimeout(c.current),a===null||a===e||!g()){o(e);return}c.current=setTimeout(()=>y(e),$w)},b=()=>{clearTimeout(s.current),clearTimeout(c.current)},S=()=>{clearTimeout(s.current),clearTimeout(c.current);let e=()=>{g()?s.current=setTimeout(e,$w):o(null)};s.current=setTimeout(e,Qw)};return(0,X.jsxs)(`div`,{"data-queue-ops-summary":!0,ref:u,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`}),l.map(e=>(0,X.jsx)(aT,{group:e,line:u,open:a===e.key,onOpen:()=>v(e.key),onHover:t=>{d.current=Jw(d.current,{x:t.clientX,y:t.clientY,at:performance.now()}),y(e.key)},onHoverPanel:b,onCloseSoon:S,registerPanel:h,caretAt:p,onOpenChange:t=>t?v(e.key):o(t=>t===e.key?null:t),children:e.key===`todo`?(0,X.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,X.jsx)(Sv,{thread:r})}):e.key===`agent`?(0,X.jsx)(Zw,{slug:r.id,subAgents:r.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)(dt,{parent:r.id,childThreads:i,density:`panel`})}):e.key===`command`||e.key===`timer`?(0,X.jsx)(lT,{thread:r,kind:e.key}):(0,X.jsx)(Ak,{slug:r.id,includeAgents:!1,only:e.key,transcriptShells:t,className:``,density:`panel`})},e.key))]})}function aT({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)(Wn,{open:n,onOpenChange:l,children:[(0,X.jsx)(Se,{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)(sT,{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)($e,{side:`top`,align:`end`,sideOffset:0,"data-queue-ops-panel":e.key,"aria-label":rT[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:ko(t.current?.getBoundingClientRect().width??eT,eT)}:void 0,children:[(0,X.jsx)(`div`,{className:`max-h-[min(20rem,50vh)] overflow-y-auto scrollbar-none`,children:u}),(0,X.jsx)(oT,{count:d,line:t,caretAt:c})]})]})}function oT({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)-tT/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:tT,height:nT,viewBox:`0 0 ${tT} ${nT}`,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 sT({kind:e,states:t}){switch(e){case`todo`:return(0,X.jsx)(ac,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`});case`agent`:case`child`:return(0,X.jsx)(cT,{hue:`agent`,states:t});case`shell`:return(0,X.jsx)(cT,{hue:`shell`,states:t});case`pr`:case`issue`:return(0,X.jsx)(cT,{hue:`github`,states:t});case`command`:case`timer`:return(0,X.jsx)(cT,{hue:`github`,states:t});case`file`:return(0,X.jsx)(En,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`});case`link`:return(0,X.jsx)(Zs,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`})}}function cT({hue:e,states:t}){return t.some(to)?(0,X.jsx)(Li,{hue:e}):(0,X.jsx)(`span`,{className:t.includes(`rested`)?rt:Ye})}function lT({thread:e,kind:t}){let n=Oi(),{commands:r,timers:i}=Q_(e);return(0,X.jsx)(`div`,{className:`flex flex-col`,children:t===`timer`?i.map(e=>(0,X.jsx)(sn,{kind:`TIMER`,label:e.timer?.prompt?.split(`
135
+ `)[0]||e.target,state:`running`,density:`panel`,counter:vy(e,n),title:_y(e)},e.id)):r.map(t=>(0,X.jsx)(sn,{kind:`COMMAND`,label:by(t),state:`running`,density:`panel`,startedAt:t.createdAt,counter:Cy(t),title:Sy(t,n),onOpen:t.command?.monitor?()=>wr(e.id,t.target,{label:by(t)}):void 0},t.id))})}function uT(e,t){let n=e.trim();if(!(!n||n===t.trim()))return n}function dT(e,t){let n=e.trim();return!n||n===t||n===`Untitled thread`||n===`Spinning up a thread…`?``:n}function fT(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 pT(e,t){return new Promise(n=>{hn(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 mT(){return qr(w().data??null)}function hT(e,t){return!t||e.kind!==`session`||e.foreign||e.backend===`codex`||e.backend===`acp`||e.backend===`opencode`?!1:e.runtime!==`exited`}function gT({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,m]=(0,q.useState)(``),[h,g]=(0,q.useState)(``),_=(0,q.useId)(),y=(0,q.useId)(),b=(0,q.useId)(),x=Cn(e),S=e.snoozePrompt?.trim(),C=(0,q.useMemo)(()=>p(new Date(Date.now()+6e4)),[c]),w=(0,q.useMemo)(()=>ae.map(e=>{let t=la(mt(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]),T=(0,q.useMemo)(()=>ee(e),[n,e.runtime,e.wakesOnItsOwn]),E=!x&&jt(e),D=!!x||E,O=x?S?`Bumps ${la(x)}`:`Snoozed until ${la(x)}`:E?`Snoozed until activity`:null,k=O?S?`${O}\n${S}`:O:`Snooze`;async function A(){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 j(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`} · ${la(n)}`),t?.()):G(`Snooze cleared`),l(!1),g(``)}catch(e){let t=e instanceof Error?e.message:`Snooze failed`;G(t.slice(0,100)),g(t)}finally{s(!1)}}function M(){d(p(new Date(x??mt(`1d`)))),m(e.snoozePrompt??``),g(``),l(!0)}function N(){let e=ea(u);if(!e.ok){g(e.message);return}let t=f.trim();if(t.length>4e3){g(`Prompt is too long (${t.length}/${io})`);return}j(e.until,t||null)}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(ue,{open:n,onOpenChange:e=>{r(e),e||a(!0)},children:[(0,X.jsx)(me,{label:k,multiline:!!S,disabled:n||i,children:(0,X.jsx)(v,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,disabled:o,"data-snooze-menu":!0,"data-snoozed":D?`true`:`false`,"aria-label":O??`Snooze`,"aria-description":x&&S?S:void 0,onMouseDown:e=>e.preventDefault(),onBlur:()=>a(!1),onPointerLeave:()=>a(!1),className:`${D?Dt.replace(/(^| )text-muted( |$)/,`$1text-attention-90$2`):Dt} ${n?`bg-panel-2`:``}`,children:o?(0,X.jsx)(Ie,{size:14,strokeWidth:2,className:`animate-spin`}):(0,X.jsx)(Ra,{size:14,strokeWidth:2})})})}),(0,X.jsxs)(re,{align:`end`,children:[(0,X.jsx)(`div`,{className:`px-2.5 pb-1 pt-1.5 text-[11px] text-muted-60`,children:O??`Snooze`}),D&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(It,{onSelect:()=>void j(null),icon:(0,X.jsx)(zs,{size:12}),children:`Wake now`}),(0,X.jsx)(ma,{})]}),w.map(e=>(0,X.jsx)(It,{onSelect:()=>void j(mt(e.value)),icon:(0,X.jsx)(Ra,{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)(It,{onSelect:()=>void A(),disabled:!T.enabled,children:(0,X.jsx)(me,{label:T.enabled?``:T.reason,side:`left`,disabled:T.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)(Ra,{size:12})}),(0,X.jsx)(`span`,{children:`Until activity`})]})})}),(0,X.jsx)(ma,{}),(0,X.jsx)(It,{onSelect:M,children:`Custom time & prompt…`})]})]}),(0,X.jsx)(ft,{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:b,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)(Ie,{size:12,className:`animate-spin`}),f.trim()?`Snooze & bump`:`Snooze`]})]}),children:(0,X.jsxs)(`form`,{id:b,className:`flex flex-col gap-2.5 p-4`,onSubmit:e=>{e.preventDefault(),N()},children:[(0,X.jsx)(`label`,{htmlFor:_,className:`text-[11px] font-medium text-muted`,children:`Wake at this local time`}),(0,X.jsx)(`input`,{id:_,type:`datetime-local`,required:!0,min:C,value:u,onChange:e=>{d(e.target.value),g(``)},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:y,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:y,"data-1p-ignore":!0,autoFocus:!0,rows:3,maxLength:io,placeholder:`e.g. Check whether CI went green and land it if so.`,value:f,onChange:e=>{m(e.target.value),g(``)},onKeyDown:e=>{ts({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(),N())},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.`}),h&&(0,X.jsx)(`p`,{role:`alert`,className:`text-[11px] text-danger`,children:h})]})})]})}function _T({thread:e,onArchived:t,onDismissCancel:n,onSnoozed:r}){let i=oo(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)(vT,{}):(0,X.jsxs)(X.Fragment,{children:[i.snooze&&(0,X.jsx)(gT,{thread:e,onSnoozed:r}),(0,X.jsx)(bT,{thread:e,onArchived:t,onDismissCancel:n,iconOnly:!0})]})]}):null}function vT(){return(0,X.jsx)(yT,{"data-thread-done":``,check:!0,tooltip:`Marked done — send a message to reopen it`,children:`Done`})}function yT({check:e=!1,tooltip:t,children:n,...r}){return(0,X.jsx)(me,{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)(fi,{size:12}),n]})})}function bT({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,pinChoice:s}){let{doneUnpins:c}=un(yn),l=c&&Nn(e)?`Mark as done & unpin`:`Mark as done`,[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(void 0),g=(r,i)=>{d(!0),i&&t?.(),(r||ye(e))&&Sr(e.id),U.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:r}).then(r=>{if(r.needsConfirmation){Di(e.id),i&&n?.(),h(r.hold),p(!0),d(!1);return}p(!1),De(`Done`,e),i||t?.()}).catch(t=>{Di(e.id),i&&n?.(),G(`Couldn’t finish: ${t.message.slice(0,80)}`),d(!1)})},_=!!t&&!!n&&ye(e);return(0,X.jsxs)(X.Fragment,{children:[o?(0,X.jsx)(me,{label:l,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>g(!1,_),disabled:u,"aria-label":l,onMouseDown:e=>e.preventDefault(),className:Dt,children:(0,X.jsx)(fi,{size:15,strokeWidth:2})})}):s&&Nn(e)?(0,X.jsx)(ST,{className:s,pending:u,children:(0,X.jsxs)(`button`,{type:`button`,"data-done-split-label":!0,onClick:()=>g(!1,_),disabled:u,"aria-label":l,title:l,onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-1 rounded-l-[inherit] py-1 pl-2.5 pr-[7px] font-medium outline-none transition-colors hover:bg-bg/10 focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:opacity-45`,children:[(0,X.jsx)(fi,{size:a,className:i}),l]})}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>g(!1,_),disabled:u,"aria-label":l,title:l,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)(fi,{size:a,className:i}),l]}),(0,X.jsx)(ft,{open:f,onOpenChange:e=>{u||p(e)},title:m?.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:u,onClick:()=>p(!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:u,onClick:()=>g(!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:[u&&(0,X.jsx)(Ie,{size:12,className:`animate-spin`}),m?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,X.jsx)(CT,{hold:m})})]})}var xT=[{unpins:!1,name:`Mark as done`,says:`It stays pinned at the top of the sidebar.`},{unpins:!0,name:`Mark as done & unpin`,says:`It leaves the pinned list and files under Done.`}];function ST({className:e,pending:t,children:n}){let{doneUnpins:i}=un(yn);return(0,X.jsxs)(`span`,{"data-done-split":!0,className:`flex items-stretch font-medium ${e}`,children:[n,(0,X.jsx)(`span`,{"aria-hidden":!0,className:`w-px shrink-0 bg-bg/10`}),(0,X.jsxs)(Si,{modal:!1,children:[(0,X.jsx)(ro,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,"data-done-split-menu":!0,disabled:t,"aria-label":`Choose what Mark as done does to the pin`,onMouseDown:e=>e.preventDefault(),className:`flex items-center rounded-r-[inherit] pl-[5px] pr-[6px] outline-none transition-colors hover:bg-bg/10 focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:opacity-45`,children:(0,X.jsx)(r,{size:12,strokeWidth:2.5})})}),(0,X.jsx)(xa,{children:(0,X.jsxs)(Xr,{"data-done-pin-choices":!0,side:`bottom`,align:`start`,sideOffset:6,className:`${Ja} w-[300px] rounded-lg p-1`,children:[(0,X.jsx)(qo,{value:i?`unpin`:`keep`,onValueChange:e=>{yn.doneUnpins=e===`unpin`},children:xT.map(e=>{let t=e.unpins===i;return(0,X.jsxs)(ai,{value:e.unpins?`unpin`:`keep`,"data-done-pin-choice":e.unpins?`unpin`:`keep`,className:`flex cursor-pointer select-none items-start gap-2 rounded-md px-2 py-1.5 text-left outline-none transition-colors data-[highlighted]:bg-panel-2`,children:[(0,X.jsx)(`span`,{className:`flex h-[18px] w-3.5 shrink-0 items-center justify-center text-fg`,children:t&&(0,X.jsx)(fi,{size:13,strokeWidth:2.5})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block text-[12px] font-medium leading-[18px] text-fg`,children:e.name}),(0,X.jsx)(`span`,{className:`block text-[11.5px] leading-[16px] text-muted`,children:e.says})]})]},e.name)})}),(0,X.jsx)(`div`,{className:`px-2 pb-1 pt-1.5 text-[11px] leading-[15px] text-muted-70`,children:`Remembered for every Done in this browser.`})]})})]})]})}function CT({hold:e}){let t=Xe(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:Rs,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 wT({slug:e,onClose:t,onArchived:n,initialView:r=`actions`}){let i=un(W),a=ls(i.board,e),[o,s]=(0,q.useState)(r),c=Yr(t);if((0,q.useEffect)(()=>{i.board&&!a&&c()},[i.board,a,c]),!a)return null;let l=P(a);return(0,X.jsx)(bC,{title:`Thread actions: ${l}`,onRequestClose:()=>c(),dataAttr:`data-thread-actions-sheet`,children:o===`actions`?(0,X.jsx)(TT,{thread:a,title:l,setView:s,dismiss:c,onArchived:n}):o===`snooze`?(0,X.jsx)(DT,{thread:a,back:()=>s(`actions`),custom:()=>s(`snooze-custom`),dismiss:c}):o===`snooze-custom`?(0,X.jsx)(OT,{thread:a,back:()=>s(`snooze`),dismiss:c}):o===`goal`?(0,X.jsx)(kT,{thread:a,back:()=>s(`actions`)}):o===`todos`?(0,X.jsx)(AT,{thread:a,back:()=>s(`actions`)}):o===`files`?(0,X.jsx)(jT,{thread:a,back:r===`files`?void 0:()=>s(`actions`),dismiss:c}):(0,X.jsx)(PT,{thread:a,back:()=>s(`actions`),dismiss:c})})}function TT({thread:e,title:t,setView:n,dismiss:r,onArchived:i}){let a=R(),o=mT(),s=un(yn).snoozePreset,c=oo(e),l=e.kind===`session`&&e.foreign!==!0,u=Cn(e),d=e.recurringPrompt?.stopHook===!0||e.recurringPrompt?.heartbeat===!0||e.recurringPrompt?.postCompaction===!0,f=e.links??[],p=e.humanTodos??[],m=e.runtime===`running`||e.runtime===`spawning`,h=l&&O(e),g=hT(e,o),_=FT(e),v=[Me(e.context),_].filter(Boolean).join(` · `);return(0,X.jsxs)(`div`,{"data-thread-actions-list":!0,children:[(0,X.jsx)(RT,{children:t}),c.snooze&&(0,X.jsx)(LT,{data:`snooze`,icon:(0,X.jsx)(Ra,{size:19}),label:`Snooze`,value:u?la(u):St(s),chevron:!0,onClick:()=>n(`snooze`)}),l&&(0,X.jsx)(LT,{data:`goal`,icon:(0,X.jsx)(hw,{size:19,className:d?`text-attention-90`:void 0}),label:`Goal`,value:d?`on`:`off`,chevron:!0,onClick:()=>n(`goal`)}),p.length>0&&(0,X.jsx)(LT,{data:`todos`,icon:(0,X.jsx)(ac,{size:19}),label:`To-do`,value:String(p.filter(e=>!e.done).length),chevron:!0,onClick:()=>n(`todos`)}),f.length>0&&(0,X.jsx)(LT,{data:`files`,icon:(0,X.jsx)(En,{size:19}),label:`Files and links`,value:String(f.length),chevron:!0,onClick:()=>n(`files`)}),m&&c.archive&&(0,X.jsx)(bT,{thread:e,iconSize:19,iconClassName:`shrink-0 text-muted`,onArchived:()=>r(i),className:`${IT} !gap-[14px] !font-normal`}),(0,X.jsx)(`div`,{className:`my-1 h-px bg-border`}),l&&(0,X.jsx)(LT,{data:`rename`,icon:(0,X.jsx)(fe,{size:19}),label:`Rename`,onClick:()=>n(`rename`)}),(0,X.jsx)(LT,{data:`copy-link`,icon:(0,X.jsx)(be,{size:19}),label:`Copy link`,onClick:()=>{let t=new URL(et(e.id),location.origin).href;r(()=>{ta(t).then(()=>G(`Link copied`)).catch(e=>G(`Couldn’t copy: ${e.message.slice(0,80)}`))})}}),h&&(0,X.jsx)(LT,{data:`retry`,icon:(0,X.jsx)(pt,{size:19}),label:`Retry`,onClick:()=>r(()=>void xs(a,e.id))}),g&&(0,X.jsx)(LT,{data:`restart-worker`,icon:(0,X.jsx)(xt,{size:19}),label:`Restart worker`,onClick:()=>r(()=>void pT(a,e.id))}),v&&(0,X.jsx)(`div`,{"data-thread-actions-foot":!0,className:`px-[18px] pt-2.5 text-[12.5px] leading-[17px] text-muted`,children:v})]})}function ET(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`} · ${la(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 DT({thread:e,back:t,custom:n,dismiss:r}){let i=un(yn).snoozePreset,a=Cn(e),{busy:o,apply:s}=ET(e,r),c=e=>{yn.snoozePreset=e,s(mt(e))};return(0,X.jsxs)(`div`,{"data-thread-actions-snooze":!0,children:[(0,X.jsx)(zT,{back:t,children:`Snooze`}),a&&(0,X.jsxs)(`p`,{className:`px-[18px] pb-2 text-[13px] text-muted`,children:[`Snoozed until `,la(a).replace(/^(Today|Tomorrow)/,e=>e.toLowerCase())]}),ae.map(e=>(0,X.jsx)(LT,{data:`snooze-${e.value}`,disabled:o,icon:(0,X.jsx)(Ra,{size:19}),label:e.label,value:e.detail,trailing:e.value===i?(0,X.jsx)(fi,{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)(LT,{data:`snooze-custom`,disabled:o,icon:(0,X.jsx)(fe,{size:19}),label:`Custom time & prompt…`,chevron:!0,onClick:n}),a&&(0,X.jsx)(LT,{data:`snooze-wake`,disabled:o,icon:(0,X.jsx)(pt,{size:19}),label:`Wake now`,onClick:()=>void s(null)})]})}function OT({thread:e,back:t,dismiss:n}){let r=un(yn).snoozePreset,i=Cn(e),{busy:a,error:o,setError:s,apply:c}=ET(e,n),[l,u]=(0,q.useState)(()=>p(new Date(i??mt(r)))),[d,f]=(0,q.useState)(e.snoozePrompt??``),m=(0,q.useMemo)(()=>p(new Date(Date.now()+6e4)),[]),h=(0,q.useId)(),g=(0,q.useId)(),_=()=>{let e=ea(l);if(!e.ok)return s(e.message);let t=d.trim();if(t.length>4e3)return s(`Prompt is too long (${t.length}/${io})`);c(e.until,t||null)};return(0,X.jsxs)(`form`,{"data-thread-actions-snooze-custom":!0,className:`flex flex-col`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,X.jsx)(zT,{back:t,children:`Custom snooze`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 px-[18px]`,children:[(0,X.jsx)(`label`,{htmlFor:h,className:`text-[13px] font-medium text-muted`,children:`Wake at this local time`}),(0,X.jsx)(`input`,{id:h,type:`datetime-local`,required:!0,min:m,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:g,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:g,"data-1p-ignore":!0,rows:3,maxLength:io,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)(Ie,{size:16,className:`animate-spin`}),d.trim()?`Snooze and bump`:`Snooze`]})]})]})}function kT({thread:e,back:t}){return(0,X.jsxs)(`div`,{"data-thread-actions-goal":!0,children:[(0,X.jsx)(zT,{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)(kw,{thread:e,armed:e.recurringPrompt,close:t,heading:!1})})]})}function AT({thread:e,back:t}){return(0,X.jsxs)(`div`,{"data-thread-actions-todos":!0,children:[(0,X.jsx)(zT,{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)(Sv,{thread:e,sends:!0})})]})}function jT({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)(zT,{back:t,count:r.length,children:`Files and links`}):(0,X.jsx)(RT,{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)(MT,{link:e,dismiss:n},e.id))]})}function MT({link:e,dismiss:t}){let n=e.kind===`link`,r=n&&we(e.target),i=un(W).board?.projectDir,a=n?r?`${An(e.target)} — not reachable from this phone`:An(e.target):NT(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)(Zs,{size:19}):(0,X.jsx)(En,{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)(Kt,{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 NT(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 PT({thread:e,back:t,dismiss:n}){let r=P(e),[i,a]=(0,q.useState)(()=>dT(r,e.id)),o=(0,q.useRef)(null),s=vn({mutationFn:t=>U.renameThread({slug:e.id,title:t})}),c=vn({mutationFn:()=>U.aiRenameThread({slug:e.id})}),l=fT(e);(0,q.useEffect)(()=>{let e=requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>cancelAnimationFrame(e)},[]);let u=()=>{let e=uT(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)(zT,{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)(Ie,{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)(LT,{data:`ai-rename`,disabled:c.isPending,icon:c.isPending?(0,X.jsx)(Ie,{size:19,className:`animate-spin`}):(0,X.jsx)(hc,{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 FT(e){let t=!!(e&&!e.foreign&&e.kind===`session`),n=Is(),r=H({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=nn([{id:e.backend??`claude`,label:``,options:r.data?.options??[]}],{model:i,effort:a},``,e.runningModelLabel);return[[o.name,o.edition].filter(Boolean).join(` `)||null,Kn(o.effort)].filter(Boolean).join(` · `)||null}var IT=`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 LT({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:IT,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)(Kt,{size:15,className:`text-muted-70`}),i]})]})}function RT({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 zT({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)(Gs,{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 BT({slug:e,onClose:t}){let n=We(e),[r,i]=(0,q.useState)(!1),a=Oi(),o=ar(e,{poll:n?.runtime===`running`||n?.runtime===`spawning`}),s=(0,q.useMemo)(()=>qe(o.data?.messages??[]),[o.data]),c=FT(n);if(!n)return null;let l=fo(n),u=tt(n,l,s,a),d=l===`needs-you`?`font-semibold text-accent`:l===`working`?`font-semibold text-live`:``,f=P(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:()=>{Pi()?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)(Lo,{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:f,children:f}),(0,X.jsxs)(`div`,{"data-mobile-thread-subtitle":!0,"data-state":l,className:`truncate text-[13px] text-muted`,children:[(0,X.jsx)(`span`,{className:d,children:Rn[l]}),u&&(0,X.jsxs)(X.Fragment,{children:[` · `,u]}),c&&(0,X.jsxs)(X.Fragment,{children:[` · `,c]})]})]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Thread actions`,"aria-haspopup":`dialog`,"aria-expanded":r,"data-mobile-thread-more":!0,onClick:()=>i(!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)(Hn,{size:21,strokeWidth:2.1})}),r&&(0,X.jsx)(wT,{slug:e,onClose:()=>i(!1),onArchived:()=>Tn(e)})]})}function VT({thread:e}){let t=R(),[n,r]=(0,q.useState)(!1);return hT(e,mT())?(0,X.jsx)(me,{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),pT(t,e.id).finally(()=>r(!1))},className:`${Dt} mr-[2px]`,children:n?(0,X.jsx)(Ie,{size:14,strokeWidth:2,className:`animate-spin`}):(0,X.jsx)(xt,{size:14,strokeWidth:2})})}):null}function HT(e){return ve(e)??br(`/`)}function UT(e){Xo(HT(e),{viewTransition:!te()})}function WT({slug:e,label:t=`Exit fullscreen`}){let n=ka()?Ti(e):HT(e);function r(t){if(Ce(t)){if(t.preventDefault(),ka()){Cs(!1);return}UT(e)}}return(0,X.jsx)(me,{label:t,children:(0,X.jsx)(`a`,{href:n,"aria-label":t,"data-standalone-return":!0,onMouseDown:e=>e.preventDefault(),onClick:r,className:Dt,children:(0,X.jsx)(uc,{size:14})})})}function GT({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)(qT,{label:o?`Expand`:`Collapse`,icon:o?qs:Ks,size:13,onClick:a}),(0,X.jsx)(VT,{thread:e}),r&&(0,X.jsx)(qT,{label:`Frizz document`,icon:En,size:14,onClick:r}),t&&(0,X.jsx)(yt,{slug:e.id}),n&&(0,X.jsx)(WT,{slug:e.id}),d?O(e)?(0,X.jsx)(KT,{slug:e.id}):null:(0,X.jsx)(`div`,{className:`ml-1`,children:(0,X.jsx)(wn,{slug:e.id,onDone:i,doneBusy:s,onMutateStart:c,onApplied:l,onFailed:u})})]})}function KT({slug:e}){let t=R(),[n,r]=(0,q.useState)(!1);return(0,X.jsx)(me,{label:`Retry — resume this session where it left off`,children:(0,X.jsxs)(`button`,{onClick:()=>{r(!0),xs(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)(Ie,{size:12,className:`animate-spin`}):(0,X.jsx)(pt,{size:12}),`Retry`]})})}function qT({label:e,icon:t,size:n,busy:r,...i}){return(0,X.jsx)(me,{label:e,children:(0,X.jsx)(`button`,{...i,"aria-label":e,onMouseDown:e=>e.preventDefault(),className:Dt,children:r?(0,X.jsx)(Ie,{size:n,strokeWidth:2,className:`animate-spin`}):(0,X.jsx)(t,{size:n,strokeWidth:2})})})}var JT=1.25,YT=7.5-JT/2,XT=2*Math.PI*YT;function ZT(e,t){return Math.max(0,Math.min(100,Math.floor(e/t*100)))}var QT=150;function $T(e){return!!e.context&&e.context.window>0}function eE({thread:e}){let t=e.context;if(!t||!$T(e))return null;let n=aE(e,t.tokens);return(0,X.jsx)(tE,{context:t,action:Wa(e)?t=>(0,X.jsx)(oE,{thread:e,compacting:n,onRequested:t}):void 0})}function tE({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),QT)},l=e=>{a.current?.contains(e.target)&&e.preventDefault()},u=ZT(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)(Wn,{open:n,onOpenChange:r,children:[(0,X.jsx)(Se,{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:YT,fill:`none`,stroke:`currentColor`,strokeOpacity:.3,strokeWidth:JT}),(0,X.jsx)(`circle`,{cx:`8`,cy:`8`,r:YT,fill:`none`,stroke:`currentColor`,strokeWidth:JT,strokeDasharray:`${XT*d} ${XT}`,transform:`rotate(-90 8 8)`})]}),(0,X.jsxs)(`span`,{children:[u,`% context`]})]})}),(0,X.jsxs)($e,{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 nE(e){return e.runtime===`running`||e.runtime===`spawning`||e.runtime===`perm-prompt`}var rE=new Map,iE=2*6e4;function aE(e,t){let n=e.sessionId;if(!n)return!1;let r=rE.get(n);return r?!nE(e)&&(r.tokens!==t||e.lastActivityAt!==r.activity)||Date.now()-r.at>iE?(rE.delete(n),!1):!0:!1}function oE({thread:e,compacting:t,onRequested:n}){let[r,i]=(0,q.useState)(!1),a=e.context?.tokens??0,o=nE(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(()=>{rE.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)(Ie,{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 sE({thread:e}){let t=uo(e.id);return(0,X.jsx)(cE,{"data-thread-header-facts":``,lead:t?(0,X.jsx)(lE,{slug:t}):null,lastActiveAt:ln(e),fallbackAt:e.spawnedAt,reading:$T(e)?(0,X.jsx)(eE,{thread:e}):null})}function cE({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)(Fe,{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 lE({slug:e}){let t=H({queryKey:[`projectsList`],queryFn:()=>U.projectsList()}).data?.find(t=>t.slug===e),n=t?.name??e,r=zo(e);function i(e){e.stopPropagation(),Ce(e)&&(e.preventDefault(),Xo(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)(fs,{project:t,size:14}):null,(0,X.jsx)(`span`,{className:`truncate`,children:n})]})}function uE({thread:e,hidden:t=!1}){let n=vn({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=fT(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)(me,{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)(Ie,{size:12,className:`animate-spin`}):(0,X.jsx)(hc,{size:12})})})}function dE({thread:e,className:t=``}){let n=e.id,r=vn({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=P(e);function d(){a(!1),s(``)}function f(){let e=uT(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(dT(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)(uE,{thread:e,hidden:i})]})}function fE(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 pE={completed:`finished`,killed:`stopped`,failed:`failed`};function mE(e){let t=pE[e.agentStatus??`completed`],n=e.agentElapsedMs===void 0?void 0:vo(e.agentElapsedMs);return{outcome:t,tail:`${t}${n?` · ${n}`:``}`}}var hE=e=>e===void 0?void 0:jr(e),gE=e=>{if(e!==void 0)return vo(e)||void 0};function _E(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=hE(n);return{label:t===`completed`?void 0:pE[t],duration:gE(n),tone:r?`failed`:`muted`,title:`${e?`Stopped`:r?`Failed`:`Ran for`}${e||r?` after`:``} ${i??`an unknown time`}`}}if(r){let e=hE(i);return{label:void 0,duration:gE(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=hE(o);return{label:c?pE.killed:s?pE.failed:void 0,duration:gE(o),tone:s?`failed`:`muted`,title:`${c?`Stopped after`:s?`Failed after`:`Ran for`} ${l??`an unknown time`}`}}var vE=`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`,yE=`${Jn} -mt-[1em] self-baseline`,bE=`h-[1em] w-[1em] shrink-0 translate-y-[calc(0.5em_-_0.5cap)] text-muted-45`,xE=`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 SE({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:La,children:(0,X.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(t?Zs:En,{"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:xE,onClick:e=>e.stopPropagation(),children:n},e.id):(0,X.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${xE} cursor-pointer`,onClick:t=>{t.stopPropagation(),I(e.target)},children:n},e.id)})})}function CE({links:e,panel:t=!1}){return e.length?t?(0,X.jsx)(SE,{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:Rs,children:`⤷`}),(0,X.jsx)(`span`,{className:yE,children:(0,X.jsx)(t?Zs:En,{"aria-hidden":!0,className:bE})}),(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:vE,onClick:e=>e.stopPropagation(),children:n},e.id):(0,X.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${vE} cursor-pointer`,onClick:t=>{t.stopPropagation(),I(e.target)},children:n},e.id)})}):null}var wE=`text-[14px] leading-5 text-muted`,TE=`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 EE(e){return`${TE} ${e?`-mx-[0.208em] rotate-90`:`-mx-[0.333em]`}`}var $=q.createElement;function DE({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,$(OE,{label:`Redacted command preview`,text:e.command.preview}),e.command.actions?$(kE,{actions:e.command.actions}):null,e.capabilities?$(jE,{capabilities:e.capabilities}):null):e.kind===`file-approval`?$(q.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},FE(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?$(OE,{label:`Plain-text diff preview`,text:e.diffPreview}):null,e.changes?$(AE,{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?$(jE,{capabilities:e.capabilities}):null)}function OE({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 kE({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`},PE(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,$(OE,{label:`${PE(e.kind)} command detail`,text:e.commandPreview})))))}function AE({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`},FE(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?$(OE,{label:`${FE(e.operation)} plain-text diff`,text:e.diffPreview}):null))))}function jE({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`},$(ME,{capability:e})))))}function ME({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?$(NE,{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),$(NE,{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`),$(NE,{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`),$(NE,{label:`Hosts`,values:e.hosts}))}function NE({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 PE(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 FE(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 IE(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 LE={semantic:`approve`,label:`Approve once`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`},RE={semantic:`approve`,label:`Approve for session`,order:20,tone:`primary`,durable:!0,scope:`Persists for later matching requests in this thread session.`},zE={semantic:`approve`,label:`Grant for turn`,order:10,tone:`primary`,durable:!1,scope:`Applies to this turn only.`},BE={semantic:`approve`,label:`Grant for session`,order:20,tone:`primary`,durable:!0,scope:`Persists until this thread session ends.`},VE={semantic:`deny`,label:`Deny`,order:70,tone:`danger`,durable:!1,scope:`Rejects this request.`},HE={semantic:`decline`,label:`Decline`,order:70,tone:`danger`,durable:!1,scope:`Declines this request.`},UE={semantic:`cancel`,label:`Cancel request`,order:80,tone:`neutral`,durable:!1,scope:`Cancels this pending request.`};function WE(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`?LE:n===`acceptForSession`&&r===`approve`?RE:(n===`decline`||n===`deny`)&&r===`deny`?VE:n===`cancel`&&r===`cancel`?UE:void 0;if(e.kind===`permission-approval`)return n===`grant-turn`&&r===`approve`?zE:n===`grant-session`&&r===`approve`?BE:(n===`deny`||n===`decline`)&&r===`deny`?VE:n===`cancel`&&r===`cancel`?UE: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`?HE:n===`cancel`&&r===`cancel`?UE: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 HE;if(n===`cancel`&&r===`cancel`)return UE}function GE(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=WE(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 KE(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 qE(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 JE(e,t){let n=e.options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t));return n<0?``:String(n)}function YE(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?``:JE(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 XE(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 ZE(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=hs(i,a);e?r[i.id]=`Value ${e}.`:n[i.id]=a}}if(Object.keys(r).length>0)return{errors:r};let i=ws.safeParse(n);return i.success?{errors:r,values:i.data}:{errors:r,formError:`The response is too large or contains invalid values.`}}function QE(e,t){return JSON.stringify([e,t??null])}function $E(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)=>`${xg(t)} ${e.label}`),recommendedIdxs:[]},...e?{optionFieldId:e.id}:{},optionValues:r.map(e=>e.value),...t?{notesFieldId:t.id}:{}}}function eD(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=$E(r,a);if(!e)return null;n.push(e)}else if(r.input===`text`||r.input===`multiline`){let e=$E(void 0,r);if(!e)return null;n.push(e)}else return null}return n.length>0?n:null}function tD(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)=>`${xg(t)} ${e.label}${e.description?` — ${e.description}`:``}`),recommendedIdxs:[]},chosenIdxs:n,text:r}}function nD(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 rD(e){let t=e instanceof Error?e.message:`The request could not be updated.`;return t.length>240?`${t.slice(0,239)}…`:t}function iD(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`frizz-response-${Date.now()}-${Math.random().toString(36).slice(2)}`}function aD({thread:e,className:t=``,autoFocusFirst:n=!1}){let r=pe(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:`${em} 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:rD(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)(sD,{record:e,autoFocus:n&&t===0,siblings:a},e.id))}):null}function oD({record:e,questions:t,autoFocus:n,siblings:r}){let i=R(),a=Is(),o=dD(e,r),s=(0,q.useRef)(null),c=(0,q.useRef)(new Map),l=z(),u=IE(e.delivery?.effect),d=(0,q.useMemo)(()=>GE(e).find(e=>e.semantic===`answer`),[e]),f=oe(t.flatMap(t=>t.notesFieldId?[fn.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(fn.interaction(l,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId))??``:``})),g=nD(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=vn({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),Ta(i,t.interaction),i.invalidateQueries({queryKey:Qa(e.owner.threadSlug,e.owner.sessionId)}),i.invalidateQueries({queryKey:_i(e.owner.threadSlug,e.owner.sessionId,e.id)})},onError:t=>{ei(i,e),o.rollback(),v(rD(t)),U.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{Ta(i,t),i.setQueryData(_i(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t}),i.invalidateQueries({queryKey:Qa(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}}),S=()=>{if(!d||!g||x.isPending||y||!u.actionsEnabled)return;v(void 0);let e=QE(d.id,g),t=c.current.get(e)??iD();c.current.set(e,t),o.release(!0),x.mutate({decisionId:d.id,values:g,responseId:t})},C=(t,n)=>{t.notesFieldId&&j.set(fn.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)(lS,{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)(lt,{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 sD({record:e,autoFocus:t=!1,siblings:n}){let r=(0,q.useMemo)(()=>eD(e),[e]),i=n??[e];return r?(0,X.jsx)(oD,{record:e,questions:r,autoFocus:t,siblings:i}):(0,X.jsx)(fD,{record:e,autoFocus:t,siblings:i})}function cD(e){return e.semantic!==`cancel`}var lD=new Set,uD=new Set;function dD(e,t){let n=(0,q.useContext)(pv),r=e.owner.threadSlug;return{release:i=>{lD.add(e.id),i&&t.every(t=>t.id===e.id||lD.has(t.id)||t.delivery?.effect===`sending`)&&(uD.add(r),gs(r),(n?.sent??n?.dismiss)?.())},rollback:()=>{lD.delete(e.id),uD.delete(r)&&(Ts(r),n?.cancel())}}}function fD({record:e,autoFocus:t=!1,siblings:n}){let r=R(),i=Is(),a=dD(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),f=z(),p=l.filter(e=>!e.secret&&(e.input===`text`||e.input===`multiline`)).map(t=>fn.interaction(f,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.id)),m=oe(p),[h,g]=(0,q.useState)(()=>YE(l)),_=(0,q.useMemo)(()=>{let t={...h};return l.forEach(n=>{if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=fn.interaction(f,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id);t[n.id]=m.get(r)??``}}),t},[l,h,m,f,e.id,e.owner]),[v,y]=(0,q.useState)({}),[b,x]=(0,q.useState)(),[S,C]=(0,q.useState)(),[w,T]=(0,q.useState)(!1),[E,D]=(0,q.useState)(),[O,k]=(0,q.useState)(!1),A=IE(e.delivery?.effect),M=(0,q.useMemo)(()=>GE(e),[e]).filter(e=>!(u&&e.requiresValues)),N=e.allowedDecisions.length-M.length,P=(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`&&j.set(fn.interaction(f,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id),r)}g(t)},[l,f,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)(()=>{A.actionsEnabled||(D(void 0),k(!1))},[A.actionsEnabled]);let F=vn({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(QE(n.decision.id,n.values)),x(void 0),D(void 0),k(!1),T(!0),p.forEach(e=>j.clear(e)),C(t.waitingForProvider?`Response sent. Waiting for the provider to acknowledge it…`:`Request completed.`),Ta(r,t.interaction),r.setQueryData(_i(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t.interaction}),r.invalidateQueries({queryKey:Qa(e.owner.threadSlug,e.owner.sessionId),exact:!0}),t.waitingForProvider&&window.setTimeout(()=>{r.invalidateQueries({queryKey:Qa(e.owner.threadSlug,e.owner.sessionId),exact:!0})},1e3)},onError:t=>{C(void 0),a.rollback(),x(rD(t)),ei(r,e),U.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{Ta(r,t),r.setQueryData(_i(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t}),t.delivery?.effect===`sending`?(x(void 0),C(void 0),T(!0)):t.delivery?.effect===`reconnect-required`?(x(void 0),C(void 0)):(t.lifecycle!==`pending`||t.recordRevision!==e.recordRevision)&&(x(void 0),C(t.lifecycle===`expired`?`This request expired.`:`This request changed in another client.`),r.invalidateQueries({queryKey:Qa(e.owner.threadSlug,e.owner.sessionId),exact:!0})),r.invalidateQueries({queryKey:Qa(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}});function I(e){if(!e.requiresValues){y({});return}let t=ZE(l,_);return y(t.errors),t.formError?(x(t.formError),null):t.values?t.values:null}function L(e,t=!1){if(!A.actionsEnabled||F.isPending||w)return;x(void 0);let n=I(e);if(n===null)return;if(e.durable&&!t){D(e),k(!1);return}let r=QE(e.id,n),i=c.current.get(r)??iD();c.current.set(r,i),a.release(cD(e)),F.mutate({decision:e,values:n,responseId:i})}let ee=M.find(e=>e.requiresValues&&e.tone===`primary`);function te(e){e.preventDefault(),A.actionsEnabled&&ee&&L(ee)}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 ${em} 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)(gc,{"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:te,onKeyDown:e=>{e.target instanceof HTMLButtonElement||ts({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(),A.actionsEnabled&&ee&&L(ee))},className:`min-w-0 px-4 py-3.5`,noValidate:!0,children:(0,X.jsxs)(`fieldset`,{disabled:!A.actionsEnabled,className:`min-w-0 border-0 p-0`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`Interaction request`}),(0,X.jsx)(mD,{record:e,instanceId:o,draft:_,setDraft:P,errors:v,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)(tc,{"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.`})]}),N>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)(d,{"aria-hidden":`true`,size:13,className:`mt-0.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[N===1?`One advertised choice`:`${N} advertised choices`,` cannot be safely labeled or delivered in Frizz and is not shown.`]})]}),E&&(0,X.jsxs)(`div`,{"data-durable-confirmation":!0,role:`group`,"aria-label":`Confirm ${E.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:E.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:O,onChange:e=>k(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:()=>{D(void 0),k(!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:!O||F.isPending,onClick:()=>L(E,!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 `,E.label.toLowerCase()]})]})]}),b&&(0,X.jsx)(`div`,{role:`alert`,className:`mt-3 break-words text-[11px] leading-snug text-danger-soft`,children:b}),(A.status??S)&&(0,X.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`mt-3 text-[11px] leading-snug text-muted`,children:A.status??S}),i&&(0,X.jsxs)(lt,{className:`mt-3 text-[12px] text-muted`,children:[`This has to be answered on `,i,`.`]}),A.actionsEnabled&&!E&&!w&&M.length>0&&!i&&(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap justify-start gap-2`,children:[M.map(e=>(0,X.jsxs)(`button`,{type:e===ee?`submit`:`button`,"data-interaction-decision":e.id,disabled:F.isPending,"aria-describedby":e.durable?`${o}-scope-${e.id}`:void 0,onClick:e===ee?void 0:()=>L(e),className:pD(e),children:[F.isPending?`Sending…`:e.label,e.durable&&(0,X.jsx)(`span`,{className:`sr-only`,children:`; persistent approval`})]},e.id)),M.filter(e=>e.durable).map(e=>(0,X.jsx)(`span`,{id:`${o}-scope-${e.id}`,className:`sr-only`,children:e.scope},`scope-${e.id}`))]}),!hD.has(e.payload.kind)&&(0,X.jsx)(vD,{record:e})]})})]})}function pD(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 mD({record:e,instanceId:t,draft:n,setDraft:r,errors:i,autoFocus:a}){let o=e.payload,s=(e,t)=>r(XE(n,e,t)),c;return c=o.kind===`command-approval`||o.kind===`file-approval`||o.kind===`permission-approval`?(0,X.jsx)(DE,{payload:o}):o.kind===`mcp-elicitation-url`?(0,X.jsx)(_D,{url:o.url}):(0,X.jsx)(yD,{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)(gD,{text:o.message}),(0,X.jsx)(`div`,{className:`message`in o&&o.message?`mt-3`:``,children:c})]})}var hD=new Set([`command-approval`,`file-approval`,`permission-approval`]);function gD({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 _D({url:e}){let t=oa(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)(Zs,{"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 vD({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:KE(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:qE(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 yD({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)(bD,{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 bD({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 xD(e,t=Date.now()){return e!==void 0&&Cn(e,t)!==void 0}function SD(){let[e,t]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function CD({thread:e}){let t=SD(),[n,r]=(0,q.useState)(!1),i=Cn(e,t);if(!i)return null;let a=Date.parse(i),o=la(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)(pm,{"data-snooze-card":!0,icon:Ra,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:Ia(a-t)}),(0,X.jsx)(`p`,{className:mm,children:s?(0,X.jsxs)(X.Fragment,{children:[`Resumes `,o,` and sends: “`,zt(s),`”`]}):(0,X.jsxs)(X.Fragment,{children:[`Returns to the queue `,o,`.`]})}),e.foreign!==!0&&(0,X.jsx)(hm,{children:(0,X.jsx)(`button`,{type:`button`,"data-snooze-wake-now":!0,disabled:n,onClick:()=>void c(),className:`${bm} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}function wD(e){return e?.foreign&&e.pendingInteraction!==!0?e.pendingAsk:void 0}function TD(e,t){return e?.actionableInteraction===!0?!1:t||e?.runtime===`perm-prompt`}async function ED({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],ga(s,o)),o)}function DD(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 OD(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 kD(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function AD(e,t,n){let r=[],i=new Map,a=null;return e.forEach((e,o)=>{if(Jo(e)||t(e))return;let s=e.sourceId??kD(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 jD(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(!(Jo(t)||n(t)))return!!t.boundary||t.wake===!0||fE(t)!==void 0}return!0}function MD(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!jD(n,r,t))}var ND=(0,q.createContext)(null);function PD(){let e=(0,q.useContext)(fv),t=(0,q.useContext)(ND);return e??t}function FD({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1,pane:i}){We(e);let a=sr()&&n!==void 0,{splitFileViewer:o}=un(W);return(0,X.jsx)(LD,{slug:e,phone:a,railBeside:(i?i.railBeside===!0:r)&&o,pane:i,header:a?(0,X.jsx)(BT,{slug:e,onClose:n}):(0,X.jsx)(rO,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r,pane:i})})}var ID=[`todo`];function LD({slug:e,phone:t=!1,railBeside:n=!1,header:r,pane:i}){let a=We(e),o=ar(e,{poll:a?.runtime===`running`||a?.runtime===`spawning`}),s=R(),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}=$S(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=s_(p);x(e>0?p[e]?.sourceId??null:null)}let S=b?Math.max(0,p.findIndex(e=>e.sourceId===b)):0,C=Is(),w=(0,q.useMemo)(()=>C?m.filter(e=>!Wx(e.spec)):m,[C,m]),T=A()[e],E=(0,q.useMemo)(()=>Ci(p,T===void 0?void 0:new Date(T).toISOString()),[p,T]),D=(0,q.useMemo)(()=>Ab(E),[E]),O=(0,q.useMemo)(()=>dn(a,E,D,T),[a,E,D,T]),k=ss(O,E),j=k?.runtime===`running`||k?.runtime===`spawning`,M=O===a?void 0:O?.lastUserAt,N=cC({slug:e,thread:k,messages:p,openQuestions:m,settledQuestions:h},i?{exit:i.exit}:void 0),{inFlightAnswers:P}=N.transcript,F=(0,q.useRef)(null),[I,L]=(0,q.useState)(null),ee=o.data?.messages.length??0,z=nw({pending:o.isPending,failed:o.isError},{running:j,adoptable:tw(k)}),te=(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 ED({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]),ne=(0,q.useCallback)(()=>{if(S===0)return void te();let e=Ho(p,S);x(e!==null&&e>0?p[e]?.sourceId??null:null)},[te,p,S]);return(0,X.jsxs)(lC,{surface:N,className:`flex-1 min-h-0 flex flex-col`,children:[r,(0,X.jsx)(mS.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:F,"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:ee>0?(0,X.jsx)(tO,{slug:e,transcriptRef:F,transcriptKey:o.data?.transcriptKey,messages:E,steerSince:M,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:ne,jumpOverlay:I,openAtLastMessage:(t||i!==void 0)&&!j,windowStart:S,openAtTop:i?.queueWindow===!0,sentAt:i?T:void 0}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(aD,{thread:k,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,X.jsx)(ZS,{thread:k,inFlight:P,className:`px-6 pt-5`}),o.transportFallback&&(0,X.jsx)(qD,{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:z===`loading`?(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Lk,{}),` Loading…`]}):z===`failed`?(0,X.jsx)(JD,{error:o.error,retry:()=>o.refetch()}):z===`starting`?(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Lk,{}),` Session starting…`]}):z===`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:L,"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)(Hw,{slug:e,above:t||!k?void 0:(0,X.jsx)(iT,{thread:k,transcriptShells:g,only:n?ID:void 0}),phoneBarOverride:t&&w.length>0?e=>(0,X.jsx)(yS,{count:w.length,onAnswer:()=>y(!0),onReply:C?void 0:e.editReply}):void 0,phoneChrome:t})}),t&&v&&(0,X.jsx)(xC,{questions:w,onClose:()=>y(!1)})]})})]})}var RD=700,zD=`button, a[href], input, textarea, select, summary, label, [role='button'], [role='checkbox'], [role='radio'], [contenteditable='true']`;function BD(e){return e.target instanceof Element&&e.target.closest(zD)!==null}var VD=250,HD=900,UD=.6,WD=.25,GD=160,KD=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function qD({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 ${em} 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)(d,{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 JD({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 YD({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`:wD(e)?`pending-ask`:TD(e,t)?`working`:e?.providerError?i?null:`provider-error`:xD(e)?`snooze`:My(e)?`resting`:n?`registered-done`:r?`rested`:null}function XD(e,t){return YD(e)===`working`?EO(t):14}function ZD({state:e,slug:t,retryText:n,liveRuntimeStart:r,liveActivityLabel:i,liveToolRun:a,onRestingExit:o,onRestingExitFailed:s,onRestingReplied:c}){let l=e.thread;switch(YD(e)){case`provider-fault`:return(0,X.jsx)(Dk,{slug:t,sessionId:l.sessionId,fault:l.providerFault,retryText:n});case`provider-error`:return(0,X.jsx)(_k,{error:l.providerError});case`limit-pause`:return(0,X.jsx)(Ok,{slug:t,sessionId:l.sessionId,pause:l.limitPause});case`pending-ask`:return(0,X.jsx)(jk,{ask:wD(l)});case`working`:return(0,X.jsx)(Rk,{since:l?.lastUserAt,startedAt:r,activityLabel:i,run:a});case`snooze`:return(0,X.jsx)(CD,{thread:l});case`resting`:return(0,X.jsx)(Fy,{thread:l,onSnooze:o,onSnoozeFailed:s,onReplied:c??o,onReplyFailed:s});case`registered-done`:return(0,X.jsx)(QD,{thread:l});case`rested`:return(0,X.jsx)(Pg,{thread:l});default:return null}}function QD({thread:e}){let t=Mg(e);return t===void 0?null:(0,X.jsx)(Ek,{fenceKind:`done`,body:t,hints:e.lastFence.hints})}function $D(e,t,n,r){let{thread:i,messages:a,running:o,lastAgentIdx:s}=e,c=xe(),l=(0,q.useMemo)(()=>o_(a),[a]);return(0,q.useMemo)(()=>{let e=s>=0?a[s]:void 0,u={thread:i,showWorking:o,registeredDone:Og(i,e?.text),restedCard:Ng(i,e?.text,e?.refusedFences),errorVisible:Fg(t.map(e=>e.message),i?.providerError)},d=YD(u),f=o?Ir(t):void 0;return{state:u,rung:d,shown:d!==null||!!i?.permPolicy,gap:XD(u,n.map(e=>e.message)),retryText:l>=0?a[l]?.text:void 0,liveRuntimeStart:o?bO(So(t),r):void 0,liveActivityLabel:f?Ca(f,c):void 0,liveToolRun:o?Xi(t):void 0}},[i,a,o,s,l,t,n,r,c])}function eO({tail:e}){let t=(0,q.useContext)(fv),n=(0,q.useContext)(pv),r=e.state.thread;return!e.shown||!t?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Zy,{h:e.gap}),(0,X.jsx)(ZD,{state:e.state,slug:t,retryText:e.retryText,liveRuntimeStart:e.liveRuntimeStart,liveActivityLabel:e.liveActivityLabel,liveToolRun:e.liveToolRun,onRestingExit:n?.dismiss,onRestingExitFailed:n?.cancel,onRestingReplied:n?.sent}),r?.permPolicy?(0,X.jsx)(`div`,{className:e.rung===null?``:`mt-3`,children:(0,X.jsx)(kk,{policy:r.permPolicy,denies:r.permDenies})}):null]})}function tO({slug:e,transcriptRef:t,transcriptKey:r,messages:i,steerSince:a,transportFallback:o,isFetching:s,refresh:c,retryLiveUpdates:l,hasEarlier:u,beforeCursor:d,loadingEarlier:f,earlierError:p,loadEarlier:m,jumpOverlay:h,openAtLastMessage:g=!1,windowStart:_=0,openAtTop:v=!1,sentAt:y}){let b=iC(),{thread:x,running:S,lastAgentIdx:C,awaitingCut:w,restingShown:T,restated:E,heldIdx:D,paired:O,inFlightAnswers:k,settledPlacement:A,openQuestions:j}=b,M=(0,q.useMemo)(()=>j_(b.placement,_),[b.placement,_]),N=(0,q.useMemo)(()=>{let e=dr(i);return _>0?e.filter(e=>e.messageIndex>=_):e},[i,_]),P=(0,q.useMemo)(()=>{let e=S?n(N):N;return MD(e,xO(e,w,T,D,E))},[N,S,w,T,D,E]),F=(0,q.useMemo)(()=>{let e=AD(P.map(e=>e.message),xO(P,w,T,D,E),_O);return e.map((t,n)=>({...t,messageIndex:P[t.messageIndex].messageIndex,restGap:hO(t.message,e[n+1]?.message)}))},[P,w,T,D,E]),I=$D(b,N,P,a),L=I.shown,R=(0,q.useMemo)(()=>{let e=[],t=new Map,n=i.length-1,r=e=>{let t=-1;for(let n=0;n<F.length&&!(F[n].messageIndex>e);n++)t=n;return t},a=j.filter(e=>!M.placedIds.has(e.id));for(let[o,s]of h_(i,a,{from:_})){if(o>=n){e.push(...s);continue}let i=r(o),a=t.get(i);a?a.push(...s):t.set(i,[...s])}let o=!1,s=new Set;for(let e of M_(i,M)){if(e>=n){o=!0;continue}let i=r(e);s.add(i),t.has(i)||t.set(i,[])}return{byRow:t,tail:e,tailSend:o,sendRows:s}},[F,i,j,M,_]),ee=(0,q.useMemo)(()=>{let e=new Map;for(let[t,n]of A.anchored){let r=-1;for(let e=0;e<F.length&&!(F[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},[F,A.anchored]),z=(0,q.useMemo)(()=>XC(i,{running:S}),[i,S]),[te,ne]=(0,q.useState)(()=>new Set),B=(0,q.useMemo)(()=>{let e=[{key:`head-anchor`,kind:`head-anchor`}];o&&e.push({key:`transport-fallback`,kind:`transport-fallback`}),(u||f||p||_>0)&&e.push({key:`earlier-history:${d??`complete`}`,kind:`earlier-history`});let t=R.byRow.get(-1);t&&e.push({key:`questions:head`,kind:`questions`,questions:t,send:R.sendRows.has(-1)});let n=(t,n,r=F[t].message)=>{let i=F[t];e.push({...i,message:r,gap:n,kind:`message`});let a=ee.get(t);a&&e.push({key:`settled-questions:${i.key}`,kind:`settled-questions`,questions:a});let o=R.byRow.get(t);o&&e.push({key:`questions:${i.key}`,kind:`questions`,questions:o,send:R.sendRows.has(t)})},r=e=>R.byRow.has(e)||M.placed.has(F[e].messageIndex),a=new Map,s=new Set,c=0;for(let e=0;e<F.length;){let t=F[e].messageIndex;for(;c<z.length&&z[c].to<t;)c++;let n=z[c],i=e;if(n&&t>=n.from)for(;i<F.length&&F[i].messageIndex<=n.to&&!r(i);)i++;let o=n?.lead!==void 0&&e>0&&F[e-1].messageIndex===n.lead?e-1:-1,l=`fold:${F[e].key}`;if(i-e>=(o>=0?1:2)){if(!te.has(l)){let t=i<F.length&&F[i].messageIndex<=n.to?F[i].messageIndex-1:n.to;a.set(e,{end:i,key:l,range:n,to:t}),o>=0&&s.add(o)}e=i}else e++}let l=!1;for(let t=0;t<F.length;){let r=a.get(t);if(!r){let e=l?_O(LO,F[t].message):F[t].gap,r=F[t].message;s.has(t)?n(t,e,{...r,tools:[],parts:(r.parts??[]).filter(e=>e.kind!==`tools`)}):n(t,e),l=!1,t++;continue}let o=ZC(i,{from:F[t].messageIndex,to:r.to,lead:s.has(t-1)?r.range.lead:void 0});e.push({key:r.key,kind:`fold`,...o,gap:t===0?0:_O(F[t-1].message,LO)}),l=!0,t=r.end}e.push({key:`interactions`,kind:`interactions`}),L&&e.push({key:`runtime-status`,kind:`runtime-status`});let m=null;return i.forEach((t,n)=>{if(!Jo(t))return;let r=`queued:${t.deliveryId??t.sourceId??n}`,i=m?_O(m,t):L||F.length>0?14:0;e.push({key:r,kind:`queued`,message:t,messageIndex:n,gap:i}),m=t}),m&&e.push({key:`queued-send-now`,kind:`queued-send-now`}),e},[d,p,z,u,L,f,F,i,te,M,R,ee,o,_]),re=(0,q.useRef)(null),V=Br({count:B.length,getScrollElement:()=>t.current,getItemKey:e=>B[e]?.key??e,estimateSize:e=>{let t=B[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===`fold`?28+t.gap:t.kind===`message`?108+t.gap:82+t.gap:80},overscan:8,rangeExtractor:e=>{let t=_s(e),n=re.current?.rowKey,r=n?B.findIndex(e=>e.key===n):-1;if(r<0)return t;let i=[];for(let e=Math.max(0,r-2);e<=Math.min(B.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})}}),[ie,H]=(0,q.useState)(!0),ae=(0,q.useRef)(!0),oe=(0,q.useRef)(-1),se=(0,q.useRef)(-1),ce=(0,q.useRef)(0),le=(0,q.useRef)(null),ue=(0,q.useRef)(!1),de=(0,q.useRef)(!1),fe=(0,q.useRef)(!0),pe=(0,q.useRef)(void 0),me=(0,q.useRef)(null),he=(0,q.useRef)(void 0),ge=(0,q.useRef)(0),_e=(0,q.useRef)(0),ve=(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&&(re.current={rowKey:r,viewportTop:n.getBoundingClientRect().top-t})}m()},[m,t]),ye=(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(!r||B.length===0||pe.current===r)return;pe.current=r,ue.current=!1,de.current=!1,fe.current=!0;let n=Ve(e)?.candidates.map(e=>({candidate:e,index:B.findIndex(t=>t.kind===`message`&&t.message.sourceId===e.sourceId)})).find(e=>e.index>=0),a=wx(i,s_(i))[0]??-1,o=!n&&a>=0&&(v||g)?B.findIndex(e=>e.kind===`message`&&e.messageIndex===a):-1,s=o>=0&&!v?o:!n&&g&&C>=0?B.reduce((e,t,n)=>t.kind===`message`&&t.messageIndex<=C&&t.message.role===`assistant`&&t.message.kind!==`event`?n:e,-1):-1,c=requestAnimationFrame(()=>{if(!n&&(v||s>=0)){let e=v?null:B[s].key,n=v&&o>=0?B[o].key:null;v?t.current?.scrollTo({top:0}):V.scrollToIndex(s,{align:`start`,behavior:`instant`}),ae.current=!1,H(!1),ue.current=!0;let r=performance.now()+HD;ge.current=r;let i=()=>{let a=t.current;if(!a||performance.now()>=r||performance.now()<ce.current){ge.current=0,_e.current=0,a&&a.scrollHeight-a.clientHeight-a.scrollTop<=4&&(ae.current=!0,oe.current=a.scrollHeight,H(!0));return}if(e===null){let e=n?a.querySelector(`[data-transcript-row-key="${CSS.escape(n)}"]`):null;if(!e&&o>=0)V.scrollToIndex(o,{align:`start`,behavior:`instant`});else if(!e)a.scrollTop=0;else{let t=e.getBoundingClientRect().top-a.getBoundingClientRect().top+a.scrollTop;a.scrollTop=t<=a.clientHeight*UD?0:t-Math.min(a.clientHeight*WD,GD)}}else{let t=a.querySelector(`[data-transcript-row-key="${CSS.escape(e)}"]`);t&&(a.scrollTop+=t.getBoundingClientRect().top-a.getBoundingClientRect().top)}_e.current=requestAnimationFrame(i)};i();return}if(!n){V.scrollToEnd({behavior:`instant`}),H(!0),ue.current=!0;return}V.scrollToIndex(n.index,{align:`start`,behavior:`instant`}),ae.current=!1,H(!1),ue.current=!0;let e=performance.now()+VD;ge.current=e;let r=()=>{performance.now()>=e||performance.now()<ce.current||(ye(n.candidate.sourceId,n.candidate.screenTop),c=requestAnimationFrame(r))};r()});return()=>cancelAnimationFrame(c)},[ye,B.length,e,r,V]),(0,q.useEffect)(()=>()=>cancelAnimationFrame(_e.current),[]);let be=(0,q.useRef)(y);(0,q.useEffect)(()=>{let e=y!==be.current;be.current=y;let n=t.current;!e||y===void 0||!n||(ge.current=0,ae.current=!0,H(!0),n.scrollTop=n.scrollHeight)},[y,t]);let xe=(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]),Se=(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]),Ce=F[0]?.key;(0,q.useLayoutEffect)(()=>{let e=he.current;if(he.current=Ce,e===void 0||e===Ce||!ue.current||ae.current||re.current)return;let t=me.current;if(!t)return;Se(t);let n=()=>{if(performance.now()<ce.current)return;let e=me.current;e&&Se(e)},r=0,i=requestAnimationFrame(()=>{n(),r=requestAnimationFrame(n)});return()=>{cancelAnimationFrame(i),cancelAnimationFrame(r)}},[Se,Ce]);let we=(0,q.useCallback)(()=>{let e=t.current;if(!e||re.current||performance.now()<ge.current)return;let n=DD({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,previousScrollHeight:oe.current,previousClientHeight:se.current,following:ae.current,readerMoved:performance.now()<ce.current});if(ae.current=n.following,n.scrollTop!==null&&(e.scrollTop=n.scrollTop),oe.current=e.scrollHeight,se.current=e.clientHeight,H(e=>e===n.following?e:n.following),KD&&!n.following&&performance.now()>=ce.current){let t=me.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}`)}}me.current=xe()??me.current},[xe,t]),Te=(0,q.useCallback)(e=>{let n=t.current,r=B.findIndex(t=>t.key===e),i=r>0?B[r-1].key:null,a=i?n?.querySelector(`[data-transcript-row-key="${CSS.escape(i)}"]`):null;if(n&&i&&a){let e={rowKey:i,viewportTop:a.getBoundingClientRect().top-n.getBoundingClientRect().top};ae.current=!1;let t=performance.now()+VD;ge.current=t;let r=()=>{if(performance.now()>=t||performance.now()<ce.current){ge.current===t&&(ge.current=0),we();return}Se(e),requestAnimationFrame(r)};requestAnimationFrame(r)}ne(t=>new Set(t).add(e))},[Se,B,we,t]);(0,q.useLayoutEffect)(()=>{let e=le.current;if(!e)return;let t=new Map(V.getVirtualItems().map(e=>[e.index,e.size])),n=[],r=0;for(let i of e.querySelectorAll(`:scope > [data-index]`)){let e=V.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=`${V.getTotalSize()+r}px`;for(let{index:e,size:t}of n)V.resizeItem(e,t)}});let Ee=(0,q.useRef)(null);(0,q.useLayoutEffect)(()=>{let e=re.current,n=t.current;if(!e||!n||f)return;let r=()=>{let t=Array.from(n.querySelectorAll(`[data-transcript-row-key]`)).find(t=>t.dataset.transcriptRowKey===e.rowKey);if(!t){let t=B.findIndex(t=>t.key===e.rowKey),r=t>=0?V.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(),Ee.current?.anchor===e)return;let i=0,a=0,o=()=>{if(i=r()?i+1:0,a++,i>=2||a>=10){re.current===e&&(re.current=null),Ee.current=null;return}Ee.current&&(Ee.current.frame=requestAnimationFrame(o))};Ee.current={anchor:e,frame:requestAnimationFrame(o)}}),(0,q.useEffect)(()=>()=>{Ee.current&&cancelAnimationFrame(Ee.current.frame)},[]),(0,q.useLayoutEffect)(we),(0,q.useEffect)(()=>{let e=le.current;if(!e)return;let n=new ResizeObserver(we);n.observe(e);let r=t.current;return r&&n.observe(r),()=>n.disconnect()},[we,t]),(0,q.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{we();let t=OD({armed:fe.current,scrollTop:e.scrollTop,readerMoved:ue.current&&de.current,hasEarlier:u&&_===0,loading:f});fe.current=t.armed,t.shouldLoad&&ve()},r=()=>{de.current=!0,ce.current=performance.now()+RD,requestAnimationFrame(n)},i=t=>{![`ArrowUp`,`PageUp`,`Home`,` `].includes(t.key)||BD(t)||(e.scrollTop<=480&&(fe.current=!0),r())},a=t=>{t.deltaY<0&&e.scrollTop<=480&&(fe.current=!0),r()},o=t=>{t.type===`touchstart`&&BD(t)||(e.scrollTop<=480&&(fe.current=!0),r())},s=e=>{BD(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)}},[u,f,ve,we,t,_]);let De=V.getVirtualItems(),Oe=V.getTotalSize();return(0,X.jsxs)(`div`,{ref:le,"data-virtualized-transcript":!0,"data-virtual-row-count":De.length,className:`relative w-full`,style:{height:Oe},children:[De.map(e=>{let t=B[e.index];return t?(0,X.jsx)(`div`,{ref:V.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)(aD,{thread:x,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,X.jsx)(ZS,{thread:x,questions:R.tail,inFlight:k,showSend:R.tailSend,className:`px-6 pt-5`})]}):t.kind===`questions`?(0,X.jsx)(ZS,{thread:x,questions:t.questions,showSend:t.send,className:`px-6 pt-5`}):t.kind===`settled-questions`?(0,X.jsx)(FS,{questions:t.questions,className:`px-6 pt-5`}):t.kind===`transport-fallback`?o?(0,X.jsx)(`div`,{className:`px-6 pt-3`,children:(0,X.jsx)(qD,{fallback:o,isFetching:s,onRefresh:c,onRetryLive:l})}):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:p?(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-2 text-center`,children:[(0,X.jsx)(`span`,{children:p}),(0,X.jsx)(`button`,{type:`button`,onClick:ve,className:`rounded-md border border-border px-2 py-1 text-fg/90 hover:bg-panel-2`,children:`Retry`})]}):f?(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Ie,{size:12,className:`animate-spin`}),` Loading earlier messages…`]}):(0,X.jsx)(`button`,{type:`button`,"data-load-earlier":!0,onClick:ve,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)(gO,{rest:t.message,at:t.restGap}):(0,X.jsx)(hk,{m:t.message,index:t.messageIndex,showSendButton:!0})}):t.kind===`fold`?(0,X.jsx)(`div`,{className:`flex flex-col px-6`,style:{paddingTop:t.gap},children:(0,X.jsx)(FO,{rounds:t.rounds,calls:t.calls,onExpand:()=>Te(t.key)})}):t.kind===`runtime-status`?(0,X.jsx)(`div`,{className:`px-6`,children:(0,X.jsx)(eO,{tail:I})}):t.kind===`queued-send-now`?(0,X.jsx)(`div`,{className:`flex flex-col px-6`,children:(0,X.jsx)(fk,{})}):(0,X.jsx)(`div`,{className:`relative flex flex-col px-6`,style:{paddingTop:t.gap},children:(0,X.jsx)(gk,{m:t.message,paired:O[t.messageIndex]})})},t.key):null}),(0,X.jsx)(nO,{overlay:h,hidden:ie,onJump:()=>V.scrollToEnd({behavior:`smooth`})})]})}function nO({overlay:e,hidden:t,onJump:n}){return!e||t?null:(0,Tc.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)(Vs,{size:12}),`Jump to latest`]}),e)}function rO({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1,pane:i}){let a=We(e),o=vn({mutationFn:()=>U.markComplete({slug:e})}),s=Df(H({queryKey:[`threadBody`,e],queryFn:()=>U.threadBody({slug:e})}).data?.markdown??``).trim().length>0;return a?(0,X.jsxs)(`header`,{"data-thread-header":!0,className:rw,children:[(0,X.jsxs)(`div`,{className:iw,children:[n&&(0,X.jsx)(ie,{onClose:n}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 leading-tight`,children:[(0,X.jsx)(dE,{thread:a}),(0,X.jsx)(sE,{thread:a})]})]}),(0,X.jsx)(`div`,{className:aw,children:(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,X.jsx)(GT,{thread:a,collapse:r,expand:!!n||i?.expand===!0,onDoc:s?()=>ki(`doc`,a.id):void 0,onDone:()=>o.mutate(void 0,{onSuccess:t??i?.exit.dismiss}),doneBusy:o.isPending,onStatusApplied:t}),(0,X.jsx)(_T,{thread:a,onArchived:t??i?.exit.dismiss,onDismissCancel:i?.exit.cancel,onSnoozed:t??i?.exit.dismiss})]})})]}):null}function iO(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||fE(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 aO(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||fE(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 oO(e){return iO(e)!==null}function sO(e){return aO(e)!==null}function cO(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function lO(e){return cO(e)||oO(e)}function uO(e){return cO(e)||sO(e)}function dO(e){if(cO(e))return!0;let t=iO(e);return t!==null&&!Va(t[t.length-1])}function fO(e){if(cO(e))return!0;let t=aO(e);return t!==null&&!Va(t[0])}function pO(e){let t=iO(e);return t!==null&&hi(t[t.length-1])}function mO(e){let t=aO(e);return t!==null&&hi(t[0])}function hO(e,t){return e.kind!==`event`||e.boundary!==`rest`||!t||!vO(t)?null:Ly(e.at,t.at)}function gO({rest:e,at:t}){let{day:n,time:r}=zy(t),i=By(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 _O(e,t){if(vO(e)&&vO(t))return 6;let n=pO(e)||mO(t),r=!n&&lO(e)&&uO(t)&&!(dO(e)&&fO(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function vO(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`||e.providerError||e.sessionPeer||e.peerFrom||e.agentInstruction?!1:!e.wake||Zg(e)}function yO(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:CO(e,r.text,t,n)):(e.tools?.length??0)===0&&CO(e,e.text,t,n)}function bO(e,t){let n=Date.parse(e??``),r=Date.parse(t??``);return Number.isFinite(r)?Number.isFinite(n)&&n>=r?e:t:e}function xO(e,t,n=!1,r=-1,i=SO){let a=new WeakSet,o=new WeakSet;if(t>=0)for(let n of e)n.messageIndex<t&&n.messageIndex!==r&&a.add(n.message);if(t>=0&&n)for(let n of e)(n.messageIndex===t||i.has(n.messageIndex))&&o.add(n.message);return e=>yO(e,a.has(e),o.has(e))}var SO=new Set;function CO(e,t,n,r){return!e.fenceRefused&&!n&&!r?t.includes("```awaiting")?Eg(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`&&Dr(e.hints)&&!rs(e.body)):!t.trim():Eg(t).every(t=>t.kind===`fence`&&t.fenceKind===`awaiting`&&(e.fenceRefused||r||!(wO(t.hints)||TO(e,t))))}function wO(e){return ks(e).length>0}function TO(e,t){return e.latestSignOff?!Dr(t.hints)||rs(t.body)!==null:!1}function EO(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(Jo(n)||yO(n)))return pO(n)?22:lO(n)&&!dO(n)?6:14+(n.role===`user`?3:0)}return 0}function DO(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||yO(e)||(i!==null&&r.push((0,X.jsx)(Zy,{h:_O(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function OO(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 kO(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)(Zy,{h:i},`vs${n}`)),r.push(e)}),r}var AO={head:!1,tail:!1};function jO(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function MO(e){return{head:hi(e[0]),tail:hi(e[e.length-1])}}function NO(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}):Bo(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 PO(e){return e.split(`__`).pop()||e}function FO({rounds:e,calls:t,onExpand:n}){let r=e>0?`${e} more round${e===1?``:`s`}`:``,i=t>0?`${t} tool call${t===1?``:`s`}`:``;return(0,X.jsx)(Q,{icon:IO,marker:`stretch-fold`,onClick:n,ariaLabel:`Expand ${[r,i].filter(Boolean).join(` and `)||`the work`} before the sign-off`,children:r||i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:r||i}),r&&i&&(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:i})]}),(0,X.jsx)(Ky,{})]}):(0,X.jsx)(`span`,{className:`shrink-0`,children:`Click to expand`})})}var IO=(0,q.forwardRef)(({className:e,...t},n)=>(0,X.jsx)(qs,{ref:n,...t,className:`${e??``} -mr-[1.5px]`})),LO={role:`user`,wake:!0,text:``,tools:[],parts:[]};function RO({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=jo(a,Gt(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 ${wE}`,children:[(0,X.jsx)(`span`,{"data-tool-activity-label":!0,title:o,className:`min-w-0 truncate text-muted`,children:o}),(0,X.jsx)(Kt,{"data-tool-activity-chevron":!0,"aria-hidden":`true`,size:13,className:EE(n)})]}),n&&(0,X.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:(0,X.jsx)(zO,{tools:e,at:t})}),!n&&(0,X.jsx)(`div`,{id:i,hidden:!0})]})}function zO({tools:e,at:t}){let n=(0,q.useContext)(fv)!==null,r=e=>!Bo(e)&&!(n&&(e.sendTo!==void 0||e.sendBody!==void 0));return(0,X.jsx)(X.Fragment,{children:kO(e.map((e,n)=>(0,X.jsx)(VO,{t:e,startedAt:t},n)),t=>hi(e[t-1])||hi(e[t])?22:r(e[t-1])&&r(e[t])?0:6)})}function BO({tools:e,at:t}){let n=[];for(let t of e){let e=Va(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:kO(n.map((e,n)=>e.exceptional?(0,X.jsx)(`div`,{className:`flex flex-col`,children:(0,X.jsx)(zO,{tools:e.tools,at:t})},`exceptions-${n}`):(0,X.jsx)(RO,{tools:e.tools,at:t},`activity-${n}`)),jO(n.map(e=>MO(e.tools)),6))})}function VO({t:e,startedAt:t}){let n=Oa(e,We((0,q.useContext)(fv))?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,X.jsx)(Ap,{edits:e.edits,meta:(0,X.jsx)(KO,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:n,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,X.jsx)(tk,{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)(QO,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,X.jsx)(rk,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,X.jsx)(ak,{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)(sk,{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)($O,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,X.jsx)(Yh,{todos:e.todos,note:e.input,node:xp(e.status),meta:(0,X.jsx)(KO,{status:e.status,durationMs:e.durationMs})}):Bo(e)?(0,X.jsx)(HO,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,X.jsx)(tk,{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)(ZO,{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 HO({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=tD(e,t?.[n]);return(0,X.jsx)(lS,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function UO({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 WO(e,t,n){let[r,i]=(0,q.useState)(()=>Date.now()),a=bi(e,t),o=Go(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(ya-(Date.now()-e),0));return()=>clearTimeout(t)},[a,o,n]),o}function GO({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=WO(e,t,r),a=n===`running`?(0,X.jsx)(Li,{"aria-hidden":!0,hue:`shell`,"data-running-indicator":`tool-disclosure`}):n===`stale`?(0,X.jsx)(`span`,{className:Ye,title:ur}):ri(e,t)||i?(0,X.jsx)(Li,{"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 KO({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:jr(i);if(!a&&!s)return null;let c=[o,s].filter(Boolean).join(` · `);return(0,X.jsx)(UO,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-attention`:`text-faint`,title:c,label:a,duration:s})}function qO(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 JO(e,t,n){let r=t&&t!==W.board?.projectDir?`in ${Ep(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function YO(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function XO({detail:e,shown:t=e}){return t?e&&YO(e)?(0,X.jsx)(`span`,{className:`min-w-0`,children:(0,X.jsx)(kp,{path:e,children:(0,X.jsx)(Dp,{path:Ep(e)})})}):(0,X.jsx)(`span`,{className:`frizz-tool-detail frizz-tool-detail--mono`,title:t,children:Ep(t)}):null}function ZO({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=JO(t,s,c);return(0,X.jsx)(`div`,{className:`frizz-bash`,title:d,"data-tool-node":xp(r),children:(0,X.jsxs)(`div`,{className:`frizz-bash-header`,children:[(0,X.jsxs)(`span`,{className:yp,children:[(0,X.jsx)(GO,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:PO(e)}),(0,X.jsx)(XO,{detail:t,shown:d})]}),(0,X.jsxs)(`span`,{className:bp,children:[(0,X.jsx)(KO,{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)(Op,{shown:!1})]})]})})}function QO({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=PO(e),f=t?Ep(t):void 0;return(0,X.jsxs)(`div`,{"data-tool-image":!0,className:`frizz-bash`,"data-tool-node":xp(i),children:[(0,X.jsxs)(Tp,{className:`frizz-bash-header`,controls:u,expanded:o,label:`${o?`Collapse`:`Expand`} ${d}${t?`: ${t}`:``}`,onToggle:()=>s(e=>!e),meta:(0,X.jsx)(KO,{status:i,durationMs:a}),children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:d}),(0,X.jsx)(XO,{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:go(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 $O({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":xp(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:yp,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:bp,children:[(0,X.jsx)(KO,{status:r,durationMs:i}),(0,X.jsx)(Op,{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)(ch,{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)(xk,{path:e},`f${t}`))}),n&&(0,X.jsx)(`div`,{className:`max-w-[65%] font-sans text-[12px] leading-snug text-muted`,children:n})]})]})})]})}var ek=16;function tk({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=qO(a,f,u),x=(0,q.useMemo)(()=>e.split(`
137
+ `).length,[e]),S=x>ek,C=(0,q.useMemo)(()=>r?r.split(`
138
+ `).length:0,[r]),w=C>ek,T=JO(t,void 0,l),E=!!(e||r);return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":xp(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`} `:``}${PO(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:yp,children:[(0,X.jsx)(GO,{status:a,backgroundState:o,liveBackgroundState:s,startedAt:f}),(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:PO(i)}),(0,X.jsx)(`span`,{className:`frizz-tool-detail${n?` frizz-tool-detail--mono`:``}`,title:T,children:T??``})]}),(0,X.jsxs)(`span`,{className:bp,children:[(0,X.jsx)(KO,{status:a,backgroundState:o,liveBackgroundState:s,exitCode:c,durationMs:b}),(0,X.jsx)(Op,{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)(Uh,{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 nk=16;function rk({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>nk;return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":xp(n),children:[(0,X.jsxs)(Tp,{className:`frizz-bash-header`,controls:c,expanded:i,label:`${i?`Collapse`:`Expand`} Read${e?`: ${e}`:``}`,onToggle:()=>a(e=>!e),meta:(0,X.jsx)(KO,{status:n,durationMs:r}),children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:`Read`}),(0,X.jsx)(XO,{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)(Uh,{text:t,language:V(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 ik=16;function ak({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>ik,g=PD(),_=We(g),v=!i&&r?(_?.subAgents??[]).find(e=>e.id===r):void 0,y=v?.state===`running`,b=!!(g&&r),x=e??`sub-agent`,S=Cr(n),C=Oi(),w=_E({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)(Li,{"aria-hidden":!0,hue:`agent`,"data-running-indicator":`subagent-disclosure`}):v?.state===`stale`?(0,X.jsx)(`span`,{className:Ye,title:nr}):v?.state===`rested`?(0,X.jsx)(`span`,{className:rt,title:mo}):null;function E(){!g||!r||es(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)(Tp,{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)(UO,{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 ok(e,t){return t===`shutdown_request`?`Shutdown`:t===`codex_followup`?`Followed up`:e===`main`?`Reported`:`Steered`}function sk({to:e,summary:t,body:n,type:r,dispatchId:i,targetLabel:a,status:o,durationMs:s,at:c}){return(0,q.useContext)(fv)===null?(0,X.jsx)(lk,{to:e,summary:t,body:n,type:r,status:o,durationMs:s}):(0,X.jsx)(Pk,{to:e,type:r,dispatchId:i,targetLabel:a,at:c})}var ck=16;function lk({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=Gf(n),f=(0,q.useMemo)(()=>n.split(`
141
+ `).length,[n]),p=f>ck,m=!!n.trim(),h=ok(e,r);return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":xp(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:yp,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:bp,children:[(0,X.jsx)(KO,{status:i,durationMs:a}),(0,X.jsx)(Op,{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)(Hh,{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 uk({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)(()=>Sn(e,[...i.keys()]),[e,i]).map((e,t)=>{let a=e.token?i.get(e.token):void 0;if(!a)return(0,X.jsx)(Eb,{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:ce(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 dk({deliveryId:e,text:t,rawText:n,error:r}){let i=(0,q.useContext)(fv),{retry:a,edit:o,dismiss:s,pending:c}=HC(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 fk(){let e=(0,q.useContext)(fv),t=(0,q.useContext)(mv),n=sx(e),r=ox(e),i=dx(e);if(!e||!t)return null;let a=rx(t,n,r);if(!a)return r||t.held+t.steered===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Zy,{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)(Zy,{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:()=>fx(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)(Ie,{"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 pk({m:e,answers:t,note:n}){let r=(t,n)=>{if(!t)return null;let i=n<2?Kg(t):null;return i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Db,{answers:i,queued:e.queued}),r(Rg(t),n+1)]}):(0,X.jsx)(mk,{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)(Db,{answers:t,queued:e.queued}),r(n,0)]})}function mk({text:e,rawText:t,queued:n,held:r,deliveryUnconfirmed:i,deliveryFailed:a,deliveryError:o,deliveryId:s,sourceId:c}){let l=(0,q.useContext)(fv),u=LC(l),{unqueue:d,pending:f}=VC(l),p=!!(n&&s&&l&&(u||r)),{prose:m,attachments:h}=(0,q.useMemo)(()=>fa(e),[e]),g=(0,q.useMemo)(()=>us(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)(uk,{body:g.body,items:g.items}):(0,X.jsx)(Eb,{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)(bk,{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)(xk,{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)(dk,{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 hk({m:e,index:t,showSendButton:n}){let r=iC(),[i,a]=r.hidesAwaiting(t);return(0,X.jsx)(gk,{m:e,showSendButton:n,answering:r.fencesLive?r.answeringForMessage(e):void 0,paired:r.paired[t],staleAwaiting:i,restingCardShown:a,stepsDone:r.stepsDone.get(t),shadowedBy:r.shadowedByMessage.get(t),placed:r.placement.placed.get(t),settledPlaced:r.settledPlacement.placed.get(t),fenceQuestions:r.fenceQuestions,index:t,questionHomes:r.questionHomes})}var gk=(0,q.memo)(function(e){return(0,X.jsx)(`div`,{title:(e.m.queued?null:By(e.m.at))??void 0,className:`contents`,children:(0,X.jsx)(vk,{...e})})});function _k({error:e}){let t=(0,q.useContext)(fv);return(0,X.jsx)(Ig,{error:e,provider:(0,q.useSyncExternalStore)(e=>os(W,e),()=>{let e=t?ls(W.board,t):void 0;return On(e?.backend,e?.model)},()=>`Agent`)})}function vk({m:e,answering:t,paired:n,showSendButton:r,staleAwaiting:i,shadowedBy:a,placed:o,settledPlaced:s,fenceQuestions:c,index:l,questionHomes:u,restingCardShown:d,stepsDone:f}){let p=sr(),[m,h]=(0,q.useState)(!1),_=dv();if(e.providerError)return(0,X.jsx)(_k,{error:e.providerError});if(e.kind===`event`)return(0,X.jsx)(Fk,{text:e.text,boundary:e.boundary,sourceId:e.sourceId,at:e.at});if(e.kind===`reasoning`)return(0,X.jsx)(Ik,{text:e.text,sourceId:e.sourceId});let v=fE(e);if(v)return(0,X.jsx)(Mk,{call:v,sourceId:e.sourceId,at:e.at});if(e.role===`user`){let t=a_(e).replace(/\r\n?/g,`
143
+ `),r=n===void 0?Kg(t):n;if(e.deliveryState!==`failed`&&({text:t,answers:r}=Jg(t,r)),r&&e.deliveryState!==`failed`){let n=Rg(t);return!n&&e.deliveryState!==`held`?(0,X.jsx)(Db,{answers:r,queued:e.queued,sourceId:e.sourceId}):(0,X.jsx)(pk,{m:e,answers:r,note:n})}return e.wake?(0,X.jsx)(eb,{steer:e.wakeSteer,text:t,sourceId:e.sourceId,at:e.at}):e.sessionPeer?(0,X.jsx)(JC,{peer:e.sessionPeer,text:t,queued:e.queued,sourceId:e.sourceId,at:e.at}):e.peerFrom?(0,X.jsx)(Nk,{from:e.peerFrom,unnamed:e.peerUnnamed,dispatchId:e.peerDispatchId,sourceId:e.sourceId,at:e.at}):(0,X.jsx)(mk,{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 y=[],b=[],x=(e,t=AO)=>{y.push(e),b.push(t)},S={n:-1},C=[],w=new Set,T,E=()=>T??=new Set(ag(e.text,e.refusedFences)),D=(n,r)=>{for(let[m,h]of Eg(n).entries()){if(h.kind===`fence`){if(h.fenceKind===`awaiting`&&i&&!e.fenceRefused&&!d&&wO(h.hints)){x((0,X.jsx)(Fy,{fence:{body:h.body,hints:h.hints},stepsDone:f},`${r}-f${m}`));continue}if(h.fenceKind===`awaiting`&&i&&!e.fenceRefused&&!d&&e.latestSignOff){if(Dr(h.hints)){let e=rs(h.body);e&&x((0,X.jsx)(yk,{md:e},`${r}-f${m}`))}else x((0,X.jsx)(Fy,{fence:{body:h.body,hints:h.hints}},`${r}-f${m}`));continue}if(h.fenceKind===`awaiting`&&(e.fenceRefused||i||d))continue;if(h.fenceKind===`awaiting`&&Dr(h.hints)){let e=rs(h.body);e&&x((0,X.jsx)(yk,{md:e},`${r}-f${m}`));continue}x((0,X.jsx)(Ek,{fenceKind:h.fenceKind,body:h.body,hints:h.hints,pastRest:i},`${r}-f${m}`));continue}for(let[n,i]of eg(h.text,c!==void 0,e.refusedFences).entries()){if(i.kind===`prose`){for(let[e,t]of g(i.text).entries()){let i=`${r}-${m}-p${n}-${e}`;x(t.kind===`image`?(0,X.jsx)(bk,{path:t.path},i):t.kind===`file`?(0,X.jsx)(xk,{path:t.path},i):t.kind===`visualization`?(0,X.jsx)(wk,{file:t.file},i):t.kind===`directive`?(0,X.jsx)(Lm,{directive:t.directive},i):t.kind===`mermaid`?(0,X.jsx)(Hm,{source:t.source},i):t.kind===`lightbox`?(0,X.jsx)(ch,{entries:t.entries},i):(0,X.jsx)(yk,{md:t.text},i))}continue}if(i.kind===`refusedRef`){let t=T_(i.id,c??[],e.questionOwners)?.closed;x((0,X.jsx)(JS,{id:i.id,closed:t},`${r}-${m}-r${n}`));continue}if(i.kind===`refusedAsk`){x((0,X.jsx)(GS,{spec:i.spec,reasons:e.refusedReasons?.get(i.id.toLowerCase())},`${r}-${m}-x${n}`));continue}if(i.kind===`invalidFence`){x(i.draft?(0,X.jsx)(GS,{spec:i.draft,reasons:i.faults,unread:!0},`${r}-${m}-i${n}`):(0,X.jsx)(KS,{faults:i.faults,children:(0,X.jsx)(yk,{md:`<details>\n<summary>What the worker wrote</summary>\n\n${i.text}\n\n</details>`})},`${r}-${m}-i${n}`));continue}S.n+=1;let d=S.n;if(i.fence){let t=i.fence.form===`ask`?i.fence.when:void 0;if(t&&!E().has(t.parent.toLowerCase()))continue;let a=T_(t?t.parent:i.fence.id,c??[],e.questionOwners);if(a&&w.has(a.id))continue;if(a?.closed){let e=i.fence.form===`ask`&&!t?i.fence.spec:void 0,o=e??a.asked;o&&(w.add(a.id),x((0,X.jsx)(HS,{spec:o,state:a.closed,copyOf:e?void 0:a.id},`${r}-${m}-q${n}`)));continue}if(a){w.add(a.id);let e=o?.find(e=>e.id===a.id);if(e){x((0,X.jsx)(XS,{q:e},`${r}-${m}-q${n}`));continue}let t=s?.find(e=>e.id===a.id);if(t){x((0,X.jsx)(PS,{s:t},`${r}-${m}-q${n}`));continue}let i=IS(a),c=u?.get(a.id);x(i?(0,X.jsx)(PS,{s:i,copy:!0},`${r}-${m}-q${n}`):(0,X.jsx)(WS,{q:a,above:c!==void 0&&l!==void 0&&c<l},`${r}-${m}-q${n}`));continue}i.fence.form===`ask`&&!t&&!w.has(`fence:${i.fence.id}`)&&(w.add(`fence:${i.fence.id}`),x((0,X.jsx)(VS,{spec:i.fence.spec},`${r}-${m}-q${n}`)));continue}let f=o&&i.registeredId?o.find(e=>e.id.toLowerCase()===i.registeredId):void 0;if(f&&!w.has(f.id)){w.add(f.id),x((0,X.jsx)(XS,{q:f},`${r}-${m}-q${n}`));continue}if(a&&C_(i,a)!==void 0)continue;let h=s&&i.registeredId?s.find(e=>e.id.toLowerCase()===i.registeredId):void 0;if(h&&!w.has(h.id)){w.add(h.id),x((0,X.jsx)(PS,{s:h},`${r}-${m}-q${n}`));continue}if(i.registeredId&&i.text.trim()===``)continue;t&&C.push({raw:i.text,kind:i.questionKind,danger:i.danger,bi:d});let _=t&&!p?{answer:t.answerFor(d),onChip:(e,n)=>t.onChip(d,e,n),onText:e=>t.onText(d,e),onSubmit:t.onSubmit}:void 0;x((0,X.jsx)(lS,{raw:i.text,questionKind:i.questionKind,danger:i.danger,interactive:_},`${r}-${m}-q${n}`))}}};if(e.parts&&e.parts.length>0)OO(e.parts).forEach((t,n)=>{if(t.kind===`tools`){let r=NO(t.tools);r.length&&x((0,X.jsx)(BO,{tools:r,at:e.at},`t${n}`),MO(r))}else D(t.text,`x${n}`)});else{let t=NO(e.tools);t.length>0&&x((0,X.jsx)(BO,{tools:t,at:e.at},`tools`),MO(t)),D(e.text,`leg`)}return y.length===0?null:(r&&t&&p&&C.length>0?x((0,X.jsx)(`div`,{className:`flex justify-start`,children:(0,X.jsx)(`button`,{type:`button`,"data-mobile-answer-open":!0,onClick:()=>h(!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:C.length>1?`Answer ${C.length} questions`:`Answer`})},`answer-open`)):r&&t&&C.length>0&&!_&&x((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:[kO(y,jO(b,14)),m&&t&&C.length>0?(0,X.jsx)(uC,{blocks:C,answering:t,onClose:()=>h(!1)}):null]}))}function yk({md:e,wrap:t}){let n=Gf(e);return n?(0,X.jsx)(Hh,{className:`md-body${t?` ${$p}`:``}`,html:n}):null}function bk({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=Nt(e);return(0,X.jsx)(af,{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:go(e),alt:n??a,"data-local-path":e,"data-local-image":`true`,onError:()=>i(!0),className:`cursor-zoom-in ${cf}`})})}function xk({path:e}){let t=Nt(e);return(0,X.jsxs)(`button`,{type:`button`,className:`local-file-action inline-flex max-w-full items-center gap-1.5 ${em} 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)(En,{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 Sk={"--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 Ck(e){let t=getComputedStyle(document.documentElement),n=Object.fromEntries(Object.entries(Sk).map(([e,n])=>[e,t.getPropertyValue(n).trim()]));return n[`--font-size-base`]=getComputedStyle(document.body).fontSize,QC(e,t.colorScheme===`light`?`light`:`dark`,n)}function wk({file:e}){let t=(0,q.useContext)(fv),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)(Lt,bt,bt),p=t?Ke(t):null,m=t?`${p?mi(p.project):$n()}/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(Ck(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($C(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:`${em} 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 ${em} 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 Tk(e,t,n){return e?.kind===`awaiting`&&e.body===t&&JSON.stringify(e.hints)===JSON.stringify(n)}function Ek({fenceKind:e,body:t,hints:n,pastRest:r}){let i=Gf(t),a=(0,q.useContext)(fv),o=(0,q.useContext)(pv),s=We(a),c=s?oo(s):void 0,l=!!(s&&c?.archive),u=(0,q.useRef)(null);l&&s&&(u.current=s);let d=l&&s?s:u.current,f=sr();if(e===`done`){let e=ji(n),t=d&&!f&&!r?(0,X.jsx)(hm,{children:(0,X.jsx)(bT,{thread:d,pinChoice:`${ym} text-[11px] bg-fg text-bg`,className:`${ym} text-[11px] ${vm}`,iconClassName:nv,onArchived:o?.dismiss,onDismissCancel:o?.cancel})}):null;return(0,X.jsx)(pm,{icon:fi,kind:`Done`,label:e?(0,X.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:e}):null,ruled:!!i,children:i||t?(0,X.jsxs)(X.Fragment,{children:[i&&(0,X.jsx)(Hh,{className:`md-body`,html:i}),t]}):null})}return s&&My(s)&&Tk(s.lastFence,t,n)?null:(0,X.jsx)(Fy,{thread:s,fence:{body:t,hints:n}})}function Dk({slug:e,sessionId:t,fault:n,retryText:r}){let[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1),c=R(),l=In[n.backend],u=t=>{s(!0),hn(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)(pm,{"data-provider-fault":!0,tone:`danger`,icon:tc,label:`${l} sign-in required`,children:[(0,X.jsx)(`span`,{className:mm,children:`The provider rejected this session's credential. Sign in, then retry.`}),(0,X.jsxs)(hm,{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:bm,children:`Sign in`})]}),i&&(0,X.jsx)(m,{backend:n.backend,onClose:()=>a(!1),onAuthed:()=>a(!1)})]})}function Ok({slug:e,sessionId:t,pause:n}){let r=n.backend===`acp`?`The agent`:n.backend===`opencode`?`OpenCode`:In[n.backend],i=n.window===`weekly`?`weekly limit`:n.window===`session`?`5-hour limit`:`usage limit`,[a,o]=(0,q.useState)(!1),s=R();return(0,X.jsxs)(pm,{"data-limit-pause":!0,tone:`caution`,icon:at,label:`Paused by the ${r} ${i}`,children:[(0,X.jsx)(`span`,{className:mm,children:n.autoResume?n.resumesAt?`Continuing automatically at ${Eo(n.resumesAt)}.`:`Continuing automatically once the window resets.`:`Continue it whenever you have capacity again.`}),(0,X.jsx)(hm,{children:(0,X.jsx)(`button`,{onClick:()=>{o(!0),hn(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 ${bm}`,children:`Continue now`})})]})}function kk({policy:e,denies:t}){let n=[e.tool,e.command].filter(Boolean).join(`: `);return(0,X.jsxs)(pm,{tone:`caution`,icon:d,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:mm,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 Ak({slug:e,className:t=`px-4 pb-2 pt-1`,includeAgents:n=!0,only:r,transcriptShells:i=[],parentAgentId:a,density:o=`sheet`}){let s=We(e),c=s?.subAgents??[],l=n?a?Ki(c,a):c:[],u=s&&!a?Q_(s,i):void 0,d=r&&r!==`shell`?[]:a?[...i]:u?.shells??[],f=!u||r&&r!==`pr`&&r!==`issue`?[]:r===`pr`?u.prs:r===`issue`?u.issues:[...u.prs,...u.issues],p=u?r===`file`?u.files:r===`link`?u.links:r?[]:s?.links??[]:[],m=l.length+d.length+f.length,h=ev(s),[,g]=(0,q.useState)(0);(0,q.useEffect)(()=>{if(m===0)return;let e=setInterval(()=>g(e=>e+1),3e4);return()=>clearInterval(e)},[m]);let _=ot(e,d.flatMap(e=>e.id&&!e.outputUnavailable?[e.id]:[]));return m===0&&p.length===0?null:(0,X.jsxs)(`div`,{className:`flex flex-col ${o===`panel`?``:`gap-0.5`} ${t}`,"data-background-ops":!0,children:[Jr(l,`sheet`).map((t,n)=>(0,X.jsx)(sn,{kind:`AGENT`,label:t.label,state:t.state,density:o,depth:t.displayDepth??t.depth,startedAt:t.startedAt,onOpen:t.id?()=>es(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:aa(e,t)},`a${n}`)),Jr(d,`sheet`).map((t,n)=>(0,X.jsx)(sn,{kind:`SHELL`,label:t.label,state:t.state,density:o,startedAt:t.startedAt,counter:t.id?Do(_.get(t.id)):void 0,counterTitle:`Lines of output so far — open the row to read them`,onOpen:t.id&&!t.outputUnavailable?()=>Ri(e,t.id,{label:t.label,startedAt:t.startedAt}):void 0,onDismiss:aa(e,t,`SHELL`),title:h(t)?`${t.label}\n${tv}`:void 0},`s${n}`)),f.map(e=>(0,X.jsx)(sn,{kind:`GITHUB`,label:e.target,state:`running`,density:o,startedAt:e.createdAt,counter:e.subject===`issue`?Mr(e.issue):yo(e.github),counterTone:e.github?.checks===`failing`&&!le(e.github,Date.now())?`danger`:void 0,counterTitle:e.subject===`issue`?e.issue?`${e.target} — ${cy(e.issue)}`:void 0:e.github?`${e.target} — ${Xv(e.github)}`:void 0,onOpen:()=>window.open(Ur(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)(CE,{links:p,panel:o===`panel`})]})}function jk({ask:e}){return(0,X.jsx)(pm,{tone:`attention`,icon:Ue,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 Mk({call:e,sourceId:t,at:n}){let r=PD(),i=e.detail??`sub-agent`,{outcome:a,tail:o}=mE(e),s=o.slice(a.length).trim(),c=!!(r&&e.agentId);return(0,X.jsxs)(Q,{icon:Us,sourceId:t,marker:`agent`,ariaLabel:c?void 0:`Sub-agent ${i} ${o}`,at:n,children:[(0,X.jsx)(`span`,{className:`shrink-0 ${Uy}`,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:Ee.AGENT,"aria-label":`${Ee.AGENT}: ${i}`,onClick:()=>es(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 Nk({from:e,unnamed:t,dispatchId:n,sourceId:r,at:i}){let a=PD(),o=!!(a&&n),s=t?void 0:e,c=t&&e?`${Ee.AGENT} — ${e}`:Ee.AGENT;return s===void 0?(0,X.jsx)(Q,{icon:Us,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":`${Ee.AGENT}${e?`: ${e}`:``}`,onClick:()=>es(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:Us,sourceId:r,marker:`agent-report`,ariaLabel:o?void 0:`Sub-agent ${s} reported`,at:i,children:[(0,X.jsx)(`span`,{className:`shrink-0 ${Uy}`,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:Ee.AGENT,"aria-label":`${Ee.AGENT}: ${s}`,onClick:()=>es(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 Pk({to:e,type:t,dispatchId:n,targetLabel:r,sourceId:i,at:a}){let o=PD(),s=ok(e,t),c=e===`main`?void 0:r??e,l=!!(o&&n);return(0,X.jsxs)(Q,{icon:Us,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:Ee.AGENT,"aria-label":`${Ee.AGENT}: ${c}`,onClick:()=>es(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 Fk({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`?bc:void 0,sourceId:n,marker:t===`rest`?`rest`:`event`,ariaLabel:e,at:r,children:i?(0,X.jsx)(qy,{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:wE,children:e})}function Ik({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:`${wE} 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)(Kt,{"aria-hidden":`true`,size:13,className:EE(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)(yk,{md:e,wrap:!0})})]})}function Lk(){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 Rk({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=Gi(Math.max(0,o-a)),f=(0,q.useMemo)(()=>NO([...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 ${wE}`,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??Qr(p)}),m&&(0,X.jsx)(Kt,{"data-working-chevron":!0,"aria-hidden":`true`,size:13,className:EE(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)(zO,{tools:f,at:r?.at})}),m&&!c&&(0,X.jsx)(`div`,{id:u,hidden:!0})]})}function zk({label:e,stopping:t,onStop:n,...r}){return(0,X.jsx)(me,{label:e,children:(0,X.jsx)(`button`,{type:`button`,...r,"aria-label":e,disabled:t,onClick:n,onMouseDown:e=>e.preventDefault(),className:Dt,children:t?(0,X.jsx)(Ie,{size:14,className:`animate-spin`}):(0,X.jsx)(fi,{size:15,strokeWidth:2})})})}function Bk({id:e,slug:t,subId:r,label:i,subagentType:a,startedAt:o,depth:s,widthDepth:c}){let[l,u]=(0,q.useState)(!1),d=(0,q.useRef)(null),[f,p]=(0,q.useState)(!1),m=R(),h=Qe(t,r),g=xe(),_=(0,q.useMemo)(()=>h.data?.messages??[],[h.data]),v=h.data?.state,y=v===`running`,b=(0,q.useMemo)(()=>Ex(_),[_]),x=(0,q.useMemo)(()=>Dx(_),[_]),S=(0,q.useMemo)(()=>dr(x),[x]),C=y?Xi(S):void 0,w=y?Ir(S):void 0,T=w?Ca(w,g):void 0,E=y?So(S):void 0,D=(0,q.useMemo)(()=>y?n(S):S,[S,y]),O=y,k=h.isError||v===`gone`||_.length===0&&(v===`done`||v===`stale`);(0,q.useEffect)(()=>{let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>u(!0))});return()=>{cancelAnimationFrame(t),e&&cancelAnimationFrame(e)}},[]);let[A,j]=(0,q.useState)(null),M=(0,q.useRef)(!0);(0,q.useLayoutEffect)(()=>{let e=d.current;e&&A&&M.current&&e.scrollHeight-e.scrollTop-e.clientHeight>.5&&(e.scrollTop=e.scrollHeight)}),(0,q.useLayoutEffect)(()=>{let e=d.current;if(!e||!A)return;M.current=!0;let t=()=>{M.current&&(e.scrollTop=e.scrollHeight)},n=()=>{M.current=e.scrollHeight-e.scrollTop-e.clientHeight<160};e.addEventListener(`scroll`,n,{passive:!0});let r=new ResizeObserver(t);return r.observe(A),r.observe(e),t(),()=>{e.removeEventListener(`scroll`,n),r.disconnect()}},[A]);function N(){f||(p(!0),U.subAgentStop({slug:t,id:r}).then(({descendantsStopped:e,note:n})=>{n?G(`Sub-agent stopped. ${n}`,{duration:7e3}):G(e>0?`Sub-agent and ${e} descendant${e===1?``:`s`} stopped`:`Sub-agent stopped`),m.invalidateQueries({queryKey:[`subAgentTranscript`,t,r]})}).catch(e=>{G(e instanceof Error?e.message:`Could not stop this sub-agent`)}).finally(()=>p(!1)))}let P=h.data?.stoppable?(0,X.jsx)(zk,{"data-stop-subagent":``,label:`Stop sub-agent`,stopping:f,onStop:N}):h.data?.outcome?(0,X.jsx)(Uk,{outcome:h.data.outcome,startedAt:h.data.startedAt??o,finishedAt:h.data.finishedAt}):null;return(0,X.jsx)(qi,{id:e,depth:s,widthDepth:c,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`header`,{"data-subagent-header":!0,className:`flex ${kt} 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)(ie,{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:i,children:i})}),(0,X.jsx)(cE,{"data-subagent-header-facts":``,lastActiveAt:h.data?.lastActivityAt,fallbackAt:h.data?.startedAt??o,reading:h.data?.context?(0,X.jsx)(tE,{context:h.data.context}):null})]})]}),P&&(0,X.jsx)(`div`,{className:`flex shrink-0 items-center`,children:P})]}),(0,X.jsx)(`div`,{ref:d,className:`flex-1 min-h-0 overflow-y-auto`,children:k?(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).`}):!l||h.isLoading||_.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)(ND.Provider,{value:t,children:(0,X.jsxs)(`div`,{ref:j,"data-transcript-column":!0,className:`flex flex-col px-6 py-5`,children:[DO(D.map(e=>e.message),(e,t)=>(0,X.jsx)(gk,{m:e},t)),O&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Zy,{h:EO(D.map(e=>e.message))}),(0,X.jsx)(Rk,{since:o,startedAt:E,activityLabel:T,run:C})]})]})})}),(0,X.jsx)(Vk,{slug:t,subId:r,subagentType:a,observedModel:h.data?.model,steerable:h.data?.steerable===!0,note:h.data?.steerNote??null,stoppable:h.data?.stoppable===!0,stopNote:h.data?.stopNote??null,stopping:f,ops:e=>(0,X.jsx)(Ak,{slug:t,parentAgentId:r,transcriptShells:b,className:e})})]})})}function Vk({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=R();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)(Hk,{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)(za,{value:u,onChange:d,onSubmit:h,surface:`subAgentComposer`,placeholder:`Steer this sub-agent…`,busy:f||c,footer:(0,X.jsx)(Hk,{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 Hk({subagentType:e,observedModel:t}){let n=$o(e,t),r=n?Es(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 ${Ps}`,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 Uk({outcome:e,startedAt:t,finishedAt:n}){let r=pE[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 ${vo(a)}`:i;return(0,X.jsx)(yT,{"data-subagent-outcome":e,check:e===`completed`,tooltip:o,children:i})}function Wk({id:e,slug:t,title:n,depth:r,widthDepth:i}){let a=H({queryKey:[`threadBody`,t],queryFn:()=>U.threadBody({slug:t})}),o=un(W);(0,q.useEffect)(()=>{a.refetch()},[o.board]);let s=tw(ls(o.board,t)),c=z(),l=fn.adopt(c,t),[u,d,f]=bn(l),p=vn({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)=>{j.get(l)||d(t),G(`Start failed: ${e.message.slice(0,80)}`)}}),m=Gf(Df(a.data?.markdown??``)),h=Np(m),g=(0,q.useRef)(null),_=Wm(g,m);return(0,X.jsx)(qi,{id:e,depth:r,widthDepth:i,widthOffset:1,subagentParent:t,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{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)(za,{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 Gk=`font-mono-keep overflow-x-auto whitespace-pre-wrap break-words ${em} border border-border bg-bg/75 px-4 py-2.5 text-[12px] leading-relaxed text-fg/85`;function Kk({id:e,slug:t,shellId:n,label:r,startedAt:i,depth:a,widthDepth:o}){let c=tn(t,n),l=c.data?.state,[u,d]=(0,q.useState)(!1),f=R(),p=s(i),m=l===`running`?`running${p?` ${p}`:``}`:l===`done`?`finished`:l===`gone`?`unavailable`:``,h=c.isError||l===`gone`;function g(){u||(d(!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`),f.invalidateQueries({queryKey:[`backgroundShellOutput`,t,n]})}).catch(e=>{G(e instanceof Error?e.message:`Could not stop this background shell`)}).finally(()=>d(!1)))}return(0,X.jsx)(Jk,{id:e,depth:a,widthDepth:o,kind:`background-shell`,title:r,icon:(0,X.jsx)(bc,{"aria-hidden":!0,size:14,className:`shrink-0 text-muted-60`}),stateLabel:m,command:c.data?.command,output:c.data?.output??``,truncated:c.data?.truncated===!0,running:l===`running`,loading:c.isLoading,unavailable:h,unavailableText:`Background shell output is no longer available.`,noCommandText:`Command unavailable for this background operation.`,emptyText:l===`done`?`No output was captured.`:`No output yet.`,stop:!h&&c.data?.stoppable?{label:`Stop shell`,stopping:u,onStop:g}:void 0,footer:!h&&!c.data?.stoppable&&l===`running`?c.data?.stopNote??void 0:void 0})}function qk({id:e,slug:t,monitorId:n,label:r,depth:i,widthDepth:a}){let o=Dn(t,n),c=o.data,[l,u]=(0,q.useState)(!1),d=R(),f=c?`${c.events} event${c.events===1?``:`s`}`:``,p=s(c?.startedAt??void 0),m=c?.state===`running`?[`running${p?` ${p}`:``}`,f].join(` · `):c?.state===`ended`?[c.ended??`ended`,f].join(` · `):c?.state===`gone`?`unavailable`:``,h=o.isError||c?.state===`gone`;function g(){l||(u(!0),U.stopMonitor({slug:t,id:n}).then(({stopped:e})=>{G(e?`Monitor stopped — the worker was told`:`This monitor had already ended`),d.invalidateQueries({queryKey:[`monitorOutput`,t,n]})}).catch(e=>{G(e instanceof Error?e.message:`Could not stop this monitor`)}).finally(()=>u(!1)))}return(0,X.jsx)(Jk,{id:e,depth:i,widthDepth:a,kind:`monitor`,title:c?.description||r,icon:(0,X.jsx)(Rt,{"aria-hidden":!0,size:14,className:`shrink-0 text-muted-60`}),stateLabel:m,command:c?.command,output:c?.output??``,truncated:c?.truncated===!0,running:c?.state===`running`,loading:o.isLoading,unavailable:h,unavailableText:`This monitor is no longer available.`,noCommandText:`Script unavailable for this monitor.`,emptyText:c?.state===`ended`?`It printed nothing.`:`Nothing printed yet.`,stop:!h&&c?.stoppable?{label:`Stop monitor`,stopping:l,onStop:g}:void 0})}function Jk({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 ta(s),G(`Command copied`)}catch{G(`Could not copy command`)}}return(0,X.jsx)(qi,{id:e,depth:t,widthDepth:n,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{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)(zk,{...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)(be,{"aria-hidden":!0,size:11}),` Copy`]})]}),s?(0,X.jsx)(Uh,{...y(`command`),text:s,language:`bash`,className:Gk}):(0,X.jsx)(`pre`,{...y(`command`),className:Gk,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)(Li,{"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 ${em} 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 ${em} 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 Yk=64,Xk=12,Zk=Yk-Xk-4,Qk=16,$k=`#4a9eff`,eA,tA,nA=!1;function rA(){return eA??=[...document.querySelectorAll(`link[rel~="icon"]`)].map(e=>({link:e,href:e.getAttribute(`href`)??``,type:e.getAttribute(`type`),sizes:e.getAttribute(`sizes`)})),eA}function iA(e){let t=document.createElement(`canvas`);t.width=t.height=Yk;let n=t.getContext(`2d`);return n.drawImage(e,0,0,Yk,Yk),n.globalCompositeOperation=`destination-out`,n.beginPath(),n.arc(Zk,Qk,16,0,Math.PI*2),n.fill(),n.globalCompositeOperation=`source-over`,n.fillStyle=$k,n.beginPath(),n.arc(Zk,Qk,Xk,0,Math.PI*2),n.fill(),t.toDataURL(`image/png`)}function aA(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(iA(i)),i.onerror=()=>n(Error(`favicon did not load`)),i.src=r.href}),tA}function oA(e){nA=e;let t=rA();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}aA(t).then(e=>{if(nA)for(let{link:n}of t)n.type=`image/png`,n.removeAttribute(`sizes`),n.href=e}).catch(()=>{tA=void 0})}var sA=new Map,cA=12;function lA(e,t){let n=sA.get(e);if(n&&n.raw===t)return n.html;let r=cd(t,V(e));if(sA.set(e,{raw:t,html:r}),sA.size>cA){let e=sA.keys().next();e.done||sA.delete(e.value)}return r}function uA(e){let t=globalThis.requestIdleCallback;t?t(e,{timeout:500}):setTimeout(e,0)}function dA(e,t){i(t)||e.prefetchQuery(pr(t)).then(()=>{let n=e.getQueryData(pr(t).queryKey);!n?.markdown||n.binary||ci(t)||uA(()=>lA(n.path,n.markdown))}).catch(()=>{})}function fA(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 pA={paddingBottom:`max(0.75rem, env(safe-area-inset-bottom))`};function mA({path:e}){return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void hA(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)(Zs,{size:12,"aria-hidden":`true`}),` Open`]})}function hA(e){return wo(e).openLocalFile({path:e}).then(Ot).catch(e=>G(`Could not open local file: ${e.message.slice(0,100)}`))}function gA({path:e,revision:t,title:n}){return(0,X.jsx)(`iframe`,{"data-pdf-view":!0,src:`${Gr(e)}${t===void 0?``:`&v=${t}`}`,title:n,className:`block min-h-0 w-full flex-1 border-0`})}function _A({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 vA({source:e}){return(0,X.jsx)(Uh,{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 yA({id:e,path:t,title:n,depth:r,widthDepth:i}){let a=ke(t),o=H({...pr(t),refetchInterval:a?!1:Zn}),s=o.data?.path??t,c=ci(t),l=No(t)&&qt(),{front:u,body:d}=fA(c?o.data?.markdown??``:``),f=Pa(s),p=Gf(d,{baseDir:f,asDocument:!0}),m=Np(p),h=(0,q.useRef)(null);Xp(h,p);let g=hh(h,p,f),_=Wm(h,p),v=sr(),y=o.data?.markdown??``,b=Np((0,q.useMemo)(()=>c?``:lA(s,y),[c,y,s]));return(0,X.jsx)(qi,{id:e,depth:r,widthDepth:i,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{title:n,subtitle:s,onClose:e}),(0,X.jsxs)(`div`,{className:`flex-1 min-h-0 ${l&&o.data?`flex flex-col`:`overflow-y-auto px-5 py-4`}`,children:[l&&o.data?(0,X.jsx)(gA,{path:s,revision:o.data.modifiedAt,title:n}):o.isLoading?(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):o.error?(0,X.jsxs)(`div`,{className:`text-[13px] text-danger-90`,children:[`Couldn’t read this file: `,o.error.message]}):o.data?.binary?(0,X.jsx)(_A,{phone:v}):c?p?(0,X.jsxs)(X.Fragment,{children:[u&&(0,X.jsx)(vA,{source:u}),(0,X.jsx)(`div`,{ref:h,className:`md-body`,dangerouslySetInnerHTML:m}),g,_,o.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.`,v?``:` Open it to read the rest.`]})]}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):y?(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:b}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!c&&!o.isLoading&&!o.error&&o.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.`})]}),v?(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:pA,children:(0,X.jsx)(mA,{path:s})})]})})}function bA(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 xA(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 SA({slug:e,path:t,active:n}){let r=ci(t),i=No(t)&&qt(),a=ke(t),o=H({...pr(t),refetchInterval:a?!1:Zn}),s=o.data?.path??t,c=o.data?.markdown??``,{front:l,body:u}=fA(r?c:``),[d,f]=(0,q.useState)(r?`rendered`:`source`),p=Pa(s),m=Gf(u,{baseDir:p,asDocument:!0}),h=Np(m),g=Np((0,q.useMemo)(()=>d===`source`?lA(s,c):``,[c,s,d])),_=(0,q.useRef)(null),v=(0,q.useRef)(null),y=(0,q.useRef)(null);Xp(_,m);let b=hh(_,m,p),x=Wm(_,m),S=Nt(s),C=Fn(),w=z(),T=Mt(e);return(0,q.useEffect)(()=>{if(!n)return;let t=()=>document.querySelector(`[data-pane-thread] textarea, 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=y.current,a=window.getSelection(),o=a&&!a.isCollapsed&&a.rangeCount>0?a.getRangeAt(0):null,l=!!(i&&o&&i.contains(o.commonAncestorContainer)),u=l?a.toString():``;if(!l||!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=v.current;if(f&&f.contains(o.commonAncestorContainer)){let e=bA(f,o.startContainer,o.startOffset),t=bA(f,o.endContainer,o.endOffset);e!==null&&t!==null&&(d={startLine:xA(c,Math.min(e,t)),endLine:xA(c,Math.max(0,Math.max(e,t)-1))})}else d=N(c,u);let p=t(),m=fn.followUp(w,e,T),{prose:h,attachments:g}=fa(j.get(m)),_=ne(Vr({path:s,...d??{}}),W.composerContext[e]??[],h),b=pn(h,r(p,h),_);j.set(m,Pt(b.prose,g.map(e=>e.path))),ba(e,{token:_,path:s,text:u,...d??{}}),a.removeAllRanges(),requestAnimationFrame(()=>{let e=t();e&&(e.setSelectionRange(b.caret,b.caret),e.focus())})}return window.addEventListener(`keydown`,i,!0),()=>window.removeEventListener(`keydown`,i,!0)},[n,e,s,c,w,T]),(0,X.jsxs)(`div`,{ref:y,"data-file-viewer-panel":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,X.jsx)(L,{title:S,subtitle:na(s,C),onClose:Ko,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:()=>f(e),"aria-pressed":d===e,className:`rounded px-2 py-0.5 transition-colors ${d===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 ${i&&o.data?`flex flex-col`:`overflow-y-auto px-5 py-4`}`,children:[i&&o.data?(0,X.jsx)(gA,{path:s,revision:o.data.modifiedAt,title:S}):o.isLoading?(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):o.error?(0,X.jsxs)(`div`,{className:`text-[13px] text-danger-90`,children:[`Couldn’t read this file: `,o.error.message]}):o.data?.binary?(0,X.jsx)(_A,{}):d===`source`?c?(0,X.jsx)(`pre`,{ref:v,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:g}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):m?(0,X.jsxs)(X.Fragment,{children:[l&&(0,X.jsx)(vA,{source:l}),(0,X.jsx)(`div`,{ref:_,className:`md-body`,dangerouslySetInnerHTML:h}),b,x]}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!o.isLoading&&!o.error&&o.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:pA,children:[i||o.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)(mA,{path:s})]})]})}function CA(){return{dirs:new Map,files:new Map}}function wA(e,t,n){let r=e.replace(/[\\/]+$/,``);if(t){let e=da(t,r);if(e!==null)return h(e)}if(n){let e=da(n,r);if(e!==null)return[`~`,...h(e)]}let i=h(r);return/^[\\/]/.test(r)?[`/`,...i]:i}var TA=(e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`,numeric:!0});function EA(e,t,n=``){let r=[];for(let i of[...e.dirs.keys()].sort(TA)){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:EA(a,t+1,s)})}for(let n of[...e.files.keys()].sort(TA))r.push({kind:`file`,name:n,depth:t,file:e.files.get(n)});return r}function DA(e,t,n){let r=CA();for(let i of e){let e=wA(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=CA(),a.dirs.set(t,e)),a=e}a.files.set(e[e.length-1],i)}return EA(r,0)}function OA(e){let t=[],n=e=>{for(let r of e)t.push(r),r.kind===`dir`&&n(r.children)};return n(e),t}var kA=/(?:^|[\s;&|(])(?:rm|mv|unlink|git\s+(?:rm|mv|clean|checkout|restore|reset|stash|apply))\b/;function AA(e){if(e.edit||e.edits?.length)return!0;let t=Xa(e.name);return Yn.has(t)?!0:t!==`bash`||!e.command?!1:kA.test(e.command)||_a(e.command).length>0}function jA(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(AA(r[e]))return`${n.sourceId??n.at??`#${t}`}:${e}:${r[e].status??``}`}}var MA=10;function NA({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*MA},children:[(0,X.jsx)(`span`,{className:`flex shrink-0`,children:(0,X.jsx)($s,{size:12,className:`${Z} text-muted-45`})}),(0,X.jsx)(`span`,{className:`ml-[5px] min-w-0 truncate`,title:e,children:e})]})}function PA({files:e}){let t=xe(),n=Fn();return(0,X.jsx)(`div`,{"data-edited-file-tree":!0,className:`flex flex-col gap-y-px`,children:OA(DA(e,t,n)).map(e=>e.kind===`dir`?(0,X.jsx)(NA,{name:e.name,depth:e.depth},`d:${e.path}`):(0,X.jsx)(FA,{file:e.file,name:e.name,depth:e.depth,homeDir:n},e.file.path))})}function FA({file:e,name:t,depth:n,homeDir:r}){let i=R();return(0,X.jsx)(oy,{testKind:`file`,testId:e.path,mark:(0,X.jsx)(Qs,{size:12,className:`${Z} -mr-[2px] text-muted-60`}),name:t,indent:n*MA,onOpen:()=>I(e.path),onPrewarm:()=>dA(i,e.path),title:na(e.path,r),status:(0,X.jsxs)(X.Fragment,{children:[(e.added??0)>0&&(0,X.jsxs)(`span`,{style:{color:lo.fgSuccess},children:[`+`,e.added]}),(e.added??0)>0&&(e.removed??0)>0&&` `,(e.removed??0)>0&&(0,X.jsxs)(`span`,{style:{color:lo.fgDanger},children:[`−`,e.removed]})]})})}function IA({link:e}){let t=R(),n=Fn();return e.kind===`link`?(0,X.jsx)(oy,{testKind:`link`,testId:e.id,mark:(0,X.jsx)(Zs,{size:12,className:`${Z} text-muted-60`}),name:e.label,href:e.target,title:e.target,status:LA(e.target)}):(0,X.jsx)(oy,{testKind:`link`,testId:e.id,mark:(0,X.jsx)(En,{size:12,className:`${Z} text-muted-60`}),name:e.label,onOpen:()=>I(e.target),onPrewarm:()=>dA(t,e.target),title:na(e.target,n),status:null})}function LA(e){try{return new URL(e).host||e}catch{return e}}var RA=1500;function zA(e,t,n,r){let i=R(),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`})},RA))},[i,e,t,n,r])}function BA({thread:e,centred:t=!1}){let n=Oi(),r=ar(e.id,{poll:!1}),i=r.data?.editedFiles??[],a=(0,q.useMemo)(()=>jA(r.data?.messages??[]),[r.data?.messages]);zA(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}=Q_(e,(0,q.useMemo)(()=>Ex(r.data?.messages??[]),[r.data?.messages]),x(e.id)),p=ev(e),m=o.filter(pa),{railFilesCollapsed:h}=un(yn),g=[{head:`Sub-agents`,rows:m.map(t=>(0,X.jsx)(Ty,{agent:t,slug:e.id,now:n,onDismiss:aa(e.id,t)},t.id??t.label))},{head:`Child threads`,rows:s.map(e=>(0,X.jsx)(Ey,{child:e,now:n},e.id))},{head:`Background shells`,rows:c.map(t=>(0,X.jsx)(hy,{shell:t,slug:e.id,now:n,onDismiss:aa(e.id,t,`SHELL`),watched:p(t)},t.id??t.label))},{head:`Pull requests`,rows:l.map(e=>(0,X.jsx)(ly,{watch:e},e.id))},{head:`Issues`,rows:u.map(e=>(0,X.jsx)(ly,{watch:e},e.id))},{head:`Monitors`,rows:d.map(t=>(0,X.jsx)(xy,{watch:t,slug:e.id,now:n},t.id))},{head:`Timers`,rows:f.map(e=>(0,X.jsx)(gy,{watch:e,now:n},e.id))},{head:`Files and links`,rows:(e.links??[]).map(e=>(0,X.jsx)(IA,{link:e},e.id))},{head:`Edited files`,rows:i.length>0?[(0,X.jsx)(PA,{files:i},`tree`)]:[],count:i.length,collapsed:h,onToggle:()=>yn.railFilesCollapsed=!yn.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)(jy,{groups:g,divider:!1})})})}function VA({slug:e}){let t=un(W),n=t.filePanels.some(e=>!e.closing),r=Ns(),i=We(e),a=xo(r,e,()=>i),o=a.kind===`found`?a.thread:void 0;r?.projectDir,(0,q.useEffect)(()=>{let e=window.matchMedia?.(`(min-width: ${se}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 He(`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?P(o):e;document.title=t?`${n} · ${t} — Frizz`:`${n} · Frizz`},[r?.projectLabel,r?.projectName,e,o]);let f=o!==void 0&&bs(o);return(0,q.useEffect)(()=>(oA(f),()=>oA(!1)),[f]),(0,X.jsx)(Re,{children:(0,X.jsxs)(u,{className:`h-dvh min-h-0 bg-bg text-sm text-fg`,children:[(0,X.jsx)(it,{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:{...de,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)(js,{slug:e}):(0,X.jsx)(_n,{label:`this thread`,resetKeys:[e],children:(0,X.jsx)(rr,{slug:e,showReturnToQueue:!0})})}),o?(0,X.jsx)(_n,{label:`this thread's side pane`,resetKeys:[e],children:(0,X.jsx)(HA,{slug:e,thread:o})}):(0,X.jsx)(`div`,{className:`hidden w-[var(--full-pane)] shrink-0 split:block`,"aria-hidden":`true`})]})}),(0,X.jsx)(y,{onEscapeAtRest:()=>UT(e)})]})})}function HA({slug:e,thread:t,rail:n=!0,centredRail:r=!1}){let i=un(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)(BA,{thread:t,centred:r})}),i.filePanels.map((t,n)=>(0,X.jsx)(UA,{slug:e,path:t.path,closing:!!t.closing,active:n===i.filePanels.length-1&&!t.closing&&i.splitFileViewer},t.id))]})}function UA({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)(SA,{slug:e,path:t,active:r})})})}export{Kk as BackgroundShellSheet,gh as LightboxHost,yA as MarkdownDrawer,qk as MonitorSheet,HA as SidePane,VA as StandaloneThreadPage,Bk as SubAgentSheet,wT as ThreadActionsSheet,Wk as ThreadDrawer,FD as ThreadView};