local-operator-ui 0.41.0 → 0.41.1

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 (94) hide show
  1. package/out/main/index.js +0 -24
  2. package/out/renderer/assets/{_basePickBy--UFblcLV.js → _basePickBy-BP7Q8i4W.js} +1 -1
  3. package/out/renderer/assets/{_baseUniq-Ct7pRnI4.js → _baseUniq-D36dAcoY.js} +1 -1
  4. package/out/renderer/assets/{agent-details-page-Col1VcjS.js → agent-details-page-D3ljlPdf.js} +2 -2
  5. package/out/renderer/assets/{agent-hub-page-CTPn6yGs.js → agent-hub-page-BMyIHnNM.js} +2 -2
  6. package/out/renderer/assets/{agents-page-CBWj1DTr.js → agents-page-mMqgQd2V.js} +3 -3
  7. package/out/renderer/assets/{arc-B-YNVaQW.js → arc-GVvow4so.js} +1 -1
  8. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DCzmuMLj.js → architectureDiagram-IEHRJDOE-BjGwXAtH.js} +1 -1
  9. package/out/renderer/assets/{blockDiagram-JOT3LUYC-f1GS2_U0.js → blockDiagram-JOT3LUYC-BTuigKlt.js} +1 -1
  10. package/out/renderer/assets/{book-open-Cb4F-cRs.js → book-open-C1uak1LZ.js} +1 -1
  11. package/out/renderer/assets/browser-page-B3mjDx8k.js +1 -0
  12. package/out/renderer/assets/{browser-webauthn-prompt-ghcPWp0R.js → browser-webauthn-prompt-CzYoJfO4.js} +1 -1
  13. package/out/renderer/assets/{building-2-C_YBTC7O.js → building-2-Bpz1qaDa.js} +1 -1
  14. package/out/renderer/assets/{c4Diagram-VJAJSXHY-BlePs8Im.js → c4Diagram-VJAJSXHY-DK7eaKE8.js} +1 -1
  15. package/out/renderer/assets/channel-B05rL6In.js +1 -0
  16. package/out/renderer/assets/{chunk-4BMEZGHF-Bse1IaHb.js → chunk-4BMEZGHF-DkQrsDhM.js} +1 -1
  17. package/out/renderer/assets/{chunk-A2AXSNBT-CncpJ5It.js → chunk-A2AXSNBT-guh0INPR.js} +1 -1
  18. package/out/renderer/assets/{chunk-AEK57VVT-37Z6jWz2.js → chunk-AEK57VVT-DvgIx6-r.js} +1 -1
  19. package/out/renderer/assets/{chunk-D6G4REZN-BR9ZpBMV.js → chunk-D6G4REZN-FNdvnFYo.js} +1 -1
  20. package/out/renderer/assets/{chunk-RZ5BOZE2-KrZ6g0pV.js → chunk-RZ5BOZE2-CgCQC9Mn.js} +1 -1
  21. package/out/renderer/assets/{chunk-XZIHB7SX-BUwRYMe9.js → chunk-XZIHB7SX-D1VRTTc4.js} +1 -1
  22. package/out/renderer/assets/classDiagram-GIVACNV2-DpB8-8cT.js +1 -0
  23. package/out/renderer/assets/classDiagram-v2-COTLJTTW-DpB8-8cT.js +1 -0
  24. package/out/renderer/assets/clone-BHHjv3HP.js +1 -0
  25. package/out/renderer/assets/{console-mirror-DPVG6sWK.js → console-mirror-DRkz3vUY.js} +1 -1
  26. package/out/renderer/assets/{consoleCapture-Coky9UhD.js → consoleCapture-BJfSUatx.js} +1 -1
  27. package/out/renderer/assets/{conversation-input-sync-C2vqs6ad.js → conversation-input-sync-CJU5GIzR.js} +5 -5
  28. package/out/renderer/assets/{dagre-OKDRZEBW-CGv1CEcm.js → dagre-OKDRZEBW-DeeYQh6O.js} +1 -1
  29. package/out/renderer/assets/{diagram-SSKATNLV-u_zFGYu8.js → diagram-SSKATNLV-DD-xNxKH.js} +1 -1
  30. package/out/renderer/assets/{diagram-VNBRO52H-Bme6bFvQ.js → diagram-VNBRO52H-YAoPlXaR.js} +1 -1
  31. package/out/renderer/assets/{erDiagram-Q7BY3M3F-B-KkjVtc.js → erDiagram-Q7BY3M3F-OKzGXyMI.js} +1 -1
  32. package/out/renderer/assets/{error-boundary-DJSaJHcb.js → error-boundary-ZYkSCpZC.js} +2 -2
  33. package/out/renderer/assets/{flowDiagram-4HSFHLVR-CSZy2b_d.js → flowDiagram-4HSFHLVR-BG-3pPqS.js} +1 -1
  34. package/out/renderer/assets/{ganttDiagram-APWFNJXF-CpYOSVKU.js → ganttDiagram-APWFNJXF-CRyD5vsE.js} +1 -1
  35. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-WOOSBsBb.js → gitGraphDiagram-7IBYFJ6S-aly2C__q.js} +1 -1
  36. package/out/renderer/assets/{graph-Du8nFp-Q.js → graph-CCWwMmhg.js} +1 -1
  37. package/out/renderer/assets/hash-BN0ECl3H.js +6 -0
  38. package/out/renderer/assets/{heart-CVGkdUzT.js → heart-tKYqMVIH.js} +1 -1
  39. package/out/renderer/assets/index-BDzV3bGH.js +57 -0
  40. package/out/renderer/assets/{index-fw54FEnm.js → index-BaNzqqGN.js} +1 -1
  41. package/out/renderer/assets/{index-D8L83jtw.js → index-CRjnV9wx.js} +199 -199
  42. package/out/renderer/assets/{index-AGCqaeOI.js → index-DaCf2W9T.js} +1 -1
  43. package/out/renderer/assets/index-ZovyVTxQ.css +1 -0
  44. package/out/renderer/assets/{infoDiagram-PH2N3AL5-BprulvMk.js → infoDiagram-PH2N3AL5-BY536sF5.js} +1 -1
  45. package/out/renderer/assets/{installer-muZhWyyS.js → installer-Dw1P6j8q.js} +1 -1
  46. package/out/renderer/assets/{journeyDiagram-U35MCT3I-DfdLRQAF.js → journeyDiagram-U35MCT3I-DGvx__t6.js} +1 -1
  47. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-R6IsuYWB.js → kanban-definition-NDS4AKOZ-CG2Lgkpw.js} +1 -1
  48. package/out/renderer/assets/{layout-05Xak_7z.js → layout-vpRrwE7T.js} +1 -1
  49. package/out/renderer/assets/{legacy-agents-page-Dpl33Kla.js → legacy-agents-page-D6Yma1Gm.js} +6 -6
  50. package/out/renderer/assets/library-page-B0gC-rRh.js +157 -0
  51. package/out/renderer/assets/{mermaid.core-BzKfajYZ.js → mermaid.core-COeGB8I0.js} +5 -5
  52. package/out/renderer/assets/{mesh-page-D6ZzFOeG.js → mesh-page-PabU05tN.js} +1 -1
  53. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-Dn_l0i7j.js → mindmap-definition-ALO5MXBD-B0hkjZLY.js} +1 -1
  54. package/out/renderer/assets/{mini-BgJE9L7J.js → mini-Df5C4rpd.js} +1 -1
  55. package/out/renderer/assets/{notebook-pen-CtAKsfVm.js → notebook-pen-C3CwzwGA.js} +1 -1
  56. package/out/renderer/assets/{org-access-BHt55LAw.js → org-access-BacMtLkn.js} +1 -1
  57. package/out/renderer/assets/{org-surface-gate-CqFJQYmV.js → org-surface-gate-tkB025lu.js} +1 -1
  58. package/out/renderer/assets/{page-header-BlIvE-Ti.js → page-header-6mrV9W-E.js} +1 -1
  59. package/out/renderer/assets/{path-utils-CYBk4q7C.js → path-utils-Ct0VTUZS.js} +2 -2
  60. package/out/renderer/assets/{pieDiagram-IB7DONF6-_W_OzAAk.js → pieDiagram-IB7DONF6-DfFtQXU5.js} +1 -1
  61. package/out/renderer/assets/{projects-page-DtZ_g9gZ.js → projects-page-CoHTKLZH.js} +1 -1
  62. package/out/renderer/assets/{publication-validation-D7f3xAgF.js → publication-validation-B0Mf3mmP.js} +1 -1
  63. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-FQ5Wvxqm.js → quadrantDiagram-7GDLP6J5-C4eDJWaK.js} +1 -1
  64. package/out/renderer/assets/{radar-MK3ICKWK-BRufXucA.js → radar-MK3ICKWK-BEv1HS9Q.js} +1 -1
  65. package/out/renderer/assets/{radient-auth-buttons-7i7blC-7.js → radient-auth-buttons-BX5vf982.js} +1 -1
  66. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-CHO8Cq1H.js → requirementDiagram-KVF5MWMF-B7f3qUcB.js} +1 -1
  67. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-C4JDJOwX.js → sankeyDiagram-QLVOVGJD-xM7E-74l.js} +1 -1
  68. package/out/renderer/assets/{schedules-page-6tPgFgS_.js → schedules-page-5q7pvL1H.js} +1 -1
  69. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-BFf3HnKw.js → sequenceDiagram-X6HHIX6F-upwR02kU.js} +1 -1
  70. package/out/renderer/assets/{settings-page-CXOFCx8w.js → settings-page-DcnGr-GP.js} +9 -9
  71. package/out/renderer/assets/{smartart-crAq3DvJ.js → smartart-CYnMNs5u.js} +1 -1
  72. package/out/renderer/assets/{stateDiagram-DGXRK772-BqFVSIKA.js → stateDiagram-DGXRK772-BqTri7Q-.js} +1 -1
  73. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-D8Sl1QhX.js +1 -0
  74. package/out/renderer/assets/team-bridge-page-vnNJdCi3.js +16 -0
  75. package/out/renderer/assets/{timeline-definition-BDJGKUSR-Cp3uYUSs.js → timeline-definition-BDJGKUSR-Bi2is17s.js} +1 -1
  76. package/out/renderer/assets/{use-download-agent-mutation-C_W8yx0C.js → use-download-agent-mutation-PHtokPlg.js} +2 -2
  77. package/out/renderer/assets/{use-session-snapshot-vFZD5qIO.js → use-session-snapshot-B5sxthdQ.js} +1 -1
  78. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-DFcICu1Q.js → xychartDiagram-VJFVF3MP-B0TrjzLJ.js} +1 -1
  79. package/out/renderer/console-capture.html +5 -5
  80. package/out/renderer/index.html +7 -7
  81. package/out/renderer/installer.html +4 -4
  82. package/out/renderer/mini.html +7 -7
  83. package/package.json +2 -2
  84. package/out/renderer/assets/browser-page-BfJd3-qS.js +0 -1
  85. package/out/renderer/assets/channel-BFAjMbH6.js +0 -1
  86. package/out/renderer/assets/classDiagram-GIVACNV2-CmW0Ezdi.js +0 -1
  87. package/out/renderer/assets/classDiagram-v2-COTLJTTW-CmW0Ezdi.js +0 -1
  88. package/out/renderer/assets/clone-B_pc7cSP.js +0 -1
  89. package/out/renderer/assets/hash--PQTQMu2.js +0 -6
  90. package/out/renderer/assets/index-ALGblIL0.css +0 -1
  91. package/out/renderer/assets/index-BYeiLB51.js +0 -57
  92. package/out/renderer/assets/library-page-BNrffbLi.js +0 -157
  93. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-aaVC-oiG.js +0 -1
  94. package/out/renderer/assets/team-bridge-page-BgjJrT3v.js +0 -26
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-AGCqaeOI.js","./index-BYeiLB51.js","./index-ALGblIL0.css","./path-utils-CYBk4q7C.js","./error-boundary-DJSaJHcb.js","./index-fw54FEnm.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-BzKfajYZ.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
- import{m as fy,b as ee,r as $,l as rPe,j as f,c as E,u as $C,g as Gn,t as Y,J as yie,L as KO,f as yC,K as $v,k as ln,h as dE}from"./index-BYeiLB51.js";import{dp as vC,av as iPe,dq as aPe,dr as oU,ds as oPe,aw as vie,u as Yc,aD as sPe,dt as lPe,du as cPe,dv as uPe,dw as OPe,E as WS,Z as bie,dx as dPe,dy as sU,dz as fPe,dA as hPe,dB as pPe,D as Nn,dC as yn,a7 as Sc,dD as z0,bn as mPe,da as nu,dE as gPe,l as Rt,r as ja,t as $Pe,a0 as ga,a4 as aO,dF as wie,k as Qs,aZ as xie,aX as yPe,aT as Sie,aY as Qie,c$ as vPe,aQ as bPe,_ as A0,dG as go,d as je,A as Cn,w as Wr,dH as wPe,dI as xPe,dJ as SPe,dK as QPe,dL as lU,dM as kPe,cr as PPe,cB as _Pe,dN as TPe,df as XPe,dO as RPe,dP as EPe,ct as cU,cu as qPe,dQ as YS,dR as Yh,dS as bC,dT as jPe,dU as uU,a as ni,c as Qr,a3 as ui,B as Yn,cn as ur,dV as kie,dW as Pie,cD as Xa,aU as _ie,dX as CPe,dY as zPe,dZ as APe,d_ as UPe,d$ as WPe,e0 as sw,e1 as Tie,e2 as U0,e3 as YPe,e4 as OU,af as NS,e5 as NPe,e6 as wC,e7 as GPe,e8 as ZPe,e9 as IPe,ae as ku,ea as DPe,eb as VPe,ec as MPe,bw as LPe,bu as FPe,ed as BPe,ee as ks,ef as Qc,eg as vn,cL as GS,bl as Xie,eh as HPe,ei as KPe,ej as Rie,ek as JPe,el as e5e,em as Du,en as xC,eo as t5e,ep as n5e,eq as r5e,er as W0,es as i5e,et as f1,eu as a5e,ev as o5e,ew as fE,ex as s5e,ey as dU,ez as l5e,eA as c5e,eB as u5e,eC as lw,eD as O5e,eE as d5e,eF as Eie,eG as f5e,eH as h5e,eI as p5e,eJ as m5e,eK as g5e,eL as $5e,eM as y5e,eN as v5e,eO as b5e,eP as w5e,eQ as x5e,eR as S5e,eS as Q5e,eT as k5e,eU as P5e,j as ZS,eV as _5e,eW as qie,eX as T5e,eY as X5e,eZ as hy,e_ as jie,e$ as Cie,f0 as R5e,f1 as E5e,f2 as q5e,f3 as j5e,d9 as C5e,e as SC,f4 as z5e,dk as QC,f5 as A5e,s as U5e,ap as W5e,f6 as Y5e,f7 as N5e,f8 as G5e,f9 as Z5e,fa as hE,fb as zie,fc as fU,fd as Aie,fe as I5e,ff as hU,fg as D5e,fh as V5e,fi as M5e,fj as L5e,fk as yv,fl as pU,fm as F5e,fn as mU,fo as B5e,ar as gU,fp as $U,fq as H5e,fr as K5e,fs as yU,aV as J5e,ft as vU,fu as e_e,fv as bU,fw as kP,fx as t_e,an as n_e,br as IS,bp as r_e,cw as Uie,cv as Wie,ag as Yie,fy as i_e,ai as Nie,fz as pE,bI as a_e,ah as o_e,aR as s_e,fA as l_e,fB as DS,cj as c_e,fC as u_e,O as O_e,fD as VS,fE as kC,fF as d_e,aN as Gie,fG as Y0,fH as sc,fI as f_e,fJ as h_e,fK as p_e,cH as m_e,fL as g_e,fM as $_e,fN as wU,fO as y_e,fP as PP,fQ as v_e,fR as b_e,fS as w_e,fT as x_e,fU as S_e,fV as Q_e,S as k_e,fW as P_e,bo as xU,fX as mE}from"./path-utils-CYBk4q7C.js";import{ai as __e,c as Ae,aw as T_e,ax as Zie,ay as X_e,az as R_e,aA as E_e,aB as q_e,aC as j_e,aD as C_e,aE as Em,aF as z_e,B as Se,D as PC,a as _C,b as A_e,d as TC,f as U_e,l as wt,x as cw,y as Iie,T as bd,z as cd,g as _l,X as zi,u as ut,aj as gE,ae as W_e,af as Y_e,at as N_e,A as pl,S as po,a7 as py,p as Die,q as XC,r as RC,s as EC,w as rl,m as Kg,n as Jg,as as qC,o as Nh,aG as G_e,a2 as Z_e,a8 as I_e,a4 as D_e,ad as V_e,N as M_e,Y as L_e,Z as F_e,_ as B_e,I as za,F as Vie,G as Mie,H as Lie,J as Fie,K as $E,M as H_e,e as yE,L as Bie,C as K_e,k as no,P as J_e,Q as eTe,R as SU,U as QU,V as tTe,W as kU,ak as nTe,aH as rTe,h as iTe,t as _P,v as PU,E as _U}from"./error-boundary-DJSaJHcb.js";function aTe(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.artifacts;if(!oTe(n)||!Array.isArray(r)||r.length===0||r.some(s=>!s||typeof s!="object"||typeof s.name!="string"))return null;const i=new Map,a=new Set(r.map(s=>s.name)),o=new Set;return r.map(s=>{const l=s,c=typeof l.name=="string"?l.name:"",u=(i.get(c)??0)+1;i.set(c,u);let O=u,d=u===1?c:`${c} (${O})`;for(;o.has(d)||d!==c&&a.has(d);)d=`${c} (${++O})`;o.add(d);const h=t.find(p=>p.kind==="audio"&&typeof l.digest=="string"&&p.attachment===l.digest)??null;return{id:JSON.stringify([l.request_id??null,c,u]),name:c,label:d,audio:h,costCaption:Hie(l,!0),status:l.status==="cancelled"?"cancelled":l.status==="failed"||l.error?"failed":l.status==="completed"?"completed":"unknown",error:typeof l.error=="string"?l.error:null}})}function Hie(e,t=!1){const n=e.cost&&typeof e.cost=="object"?e.cost:null;if(t&&(e.status==="failed"||e.error)&&e.cost_usd===0){if(n?.basis==="billed")return"No charge.";if(n?.basis==="estimated")return"Estimated cost $0; final charge not confirmed."}return vC({...e,billing_basis:n?.basis??e.billing_basis})}function TP(e){const t=e,n=Hie(t);if(!n)return"Total cost not yet known.";const r=t.cost_complete===!0;return`${r?"Total cost":"Known total cost"} ${n.slice(5)}${r?"":" Unknown or late charges are not included."}`}function oTe(e){return"cost_complete"in e||["completed","failed","cancelled"].some(t=>t in e)}function sTe(e,t){const n=e,r=s=>{const l=n[s];return typeof l=="number"&&Number.isInteger(l)&&l>=0?l:t.filter(c=>c.status===s).length},i=r("cancelled"),a=t.filter(s=>s.status==="unknown").length,o=t.filter(s=>s.status!=="completed");return`${r("completed")} completed · ${r("failed")} failed${i?` · ${i} cancelled/stopped`:""}${a?` · ${a} status unknown`:""}${o.length?`. Needs attention: ${o.map(s=>s.label).join("; ")}`:""}`}function lTe(e,t){const n=e;if(typeof n.error=="string"&&n.error)return n.error;const r=t?.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-DaCf2W9T.js","./index-BDzV3bGH.js","./index-ZovyVTxQ.css","./path-utils-Ct0VTUZS.js","./error-boundary-ZYkSCpZC.js","./index-BaNzqqGN.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-COeGB8I0.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
+ import{m as fy,b as ee,r as $,l as rPe,j as f,c as E,u as $C,g as Gn,t as Y,J as yie,L as KO,f as yC,K as $v,k as ln,h as dE}from"./index-BDzV3bGH.js";import{dp as vC,av as iPe,dq as aPe,dr as oU,ds as oPe,aw as vie,u as Yc,aD as sPe,dt as lPe,du as cPe,dv as uPe,dw as OPe,z as WS,T as bie,dx as dPe,dy as sU,dz as fPe,dA as hPe,dB as pPe,D as Nn,dC as yn,a7 as Sc,dD as z0,bn as mPe,da as nu,dE as gPe,h as Rt,r as ja,n as $Pe,X as ga,_ as aO,dF as wie,g as Qs,aZ as xie,aX as yPe,aT as Sie,aY as Qie,c$ as vPe,aQ as bPe,V as A0,dG as go,d as je,w as Cn,q as Wr,dH as wPe,dI as xPe,dJ as SPe,dK as QPe,dL as lU,dM as kPe,cr as PPe,cB as _Pe,dN as TPe,df as XPe,dO as RPe,dP as EPe,ct as cU,cu as qPe,dQ as YS,dR as Yh,dS as bC,dT as jPe,dU as uU,a as ni,c as Qr,$ as ui,x as Yn,cn as ur,dV as kie,dW as Pie,cD as Xa,aU as _ie,dX as CPe,dY as zPe,dZ as APe,d_ as UPe,d$ as WPe,e0 as sw,e1 as Tie,e2 as U0,e3 as YPe,e4 as OU,af as NS,e5 as NPe,e6 as wC,e7 as GPe,e8 as ZPe,e9 as IPe,ae as ku,ea as DPe,eb as VPe,ec as MPe,bw as LPe,bu as FPe,ed as BPe,ee as ks,ef as Qc,eg as vn,cL as GS,bl as Xie,eh as HPe,ei as KPe,ej as Rie,ek as JPe,el as e5e,em as Du,en as xC,eo as t5e,ep as n5e,eq as r5e,er as W0,es as i5e,et as f1,eu as a5e,ev as o5e,ew as fE,ex as s5e,ey as dU,ez as l5e,eA as c5e,eB as u5e,eC as lw,eD as O5e,eE as d5e,eF as Eie,eG as f5e,eH as h5e,eI as p5e,eJ as m5e,eK as g5e,eL as $5e,eM as y5e,eN as v5e,eO as b5e,eP as w5e,eQ as x5e,eR as S5e,eS as Q5e,eT as k5e,eU as P5e,f as ZS,eV as _5e,eW as qie,eX as T5e,eY as X5e,eZ as hy,e_ as jie,e$ as Cie,f0 as R5e,f1 as E5e,f2 as q5e,f3 as j5e,d9 as C5e,e as SC,f4 as z5e,dk as QC,f5 as A5e,m as U5e,ap as W5e,f6 as Y5e,f7 as N5e,f8 as G5e,f9 as Z5e,fa as hE,fb as zie,fc as fU,fd as Aie,fe as I5e,ff as hU,fg as D5e,fh as V5e,fi as M5e,fj as L5e,fk as yv,fl as pU,fm as F5e,fn as mU,fo as B5e,ar as gU,fp as $U,fq as H5e,fr as K5e,fs as yU,aV as J5e,ft as vU,fu as e_e,fv as bU,fw as kP,fx as t_e,an as n_e,br as IS,bp as r_e,cw as Uie,cv as Wie,ag as Yie,fy as i_e,ai as Nie,fz as pE,bI as a_e,ah as o_e,aR as s_e,fA as l_e,fB as DS,cj as c_e,fC as u_e,K as O_e,fD as VS,fE as kC,fF as d_e,aN as Gie,fG as Y0,fH as sc,fI as f_e,fJ as h_e,fK as p_e,cH as m_e,fL as g_e,fM as $_e,fN as wU,fO as y_e,fP as PP,fQ as v_e,fR as b_e,fS as w_e,fT as x_e,fU as S_e,fV as Q_e,S as k_e,fW as P_e,bo as xU,fX as mE}from"./path-utils-Ct0VTUZS.js";import{ai as __e,c as Ae,aw as T_e,ax as Zie,ay as X_e,az as R_e,aA as E_e,aB as q_e,aC as j_e,aD as C_e,aE as Em,aF as z_e,B as Se,D as PC,a as _C,b as A_e,d as TC,f as U_e,l as wt,x as cw,y as Iie,T as bd,z as cd,g as _l,X as zi,u as ut,aj as gE,ad as W_e,ae as Y_e,at as N_e,A as pl,S as po,a4 as py,p as Die,q as XC,r as RC,s as EC,w as rl,m as Kg,n as Jg,as as qC,o as Nh,aG as G_e,a5 as Z_e,a6 as I_e,a7 as D_e,ac as V_e,N as M_e,Y as L_e,Z as F_e,_ as B_e,I as za,F as Vie,G as Mie,H as Lie,J as Fie,K as $E,M as H_e,e as yE,L as Bie,C as K_e,k as no,P as J_e,Q as eTe,R as SU,U as QU,V as tTe,W as kU,ak as nTe,aH as rTe,h as iTe,t as _P,v as PU,E as _U}from"./error-boundary-ZYkSCpZC.js";function aTe(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.artifacts;if(!oTe(n)||!Array.isArray(r)||r.length===0||r.some(s=>!s||typeof s!="object"||typeof s.name!="string"))return null;const i=new Map,a=new Set(r.map(s=>s.name)),o=new Set;return r.map(s=>{const l=s,c=typeof l.name=="string"?l.name:"",u=(i.get(c)??0)+1;i.set(c,u);let O=u,d=u===1?c:`${c} (${O})`;for(;o.has(d)||d!==c&&a.has(d);)d=`${c} (${++O})`;o.add(d);const h=t.find(p=>p.kind==="audio"&&typeof l.digest=="string"&&p.attachment===l.digest)??null;return{id:JSON.stringify([l.request_id??null,c,u]),name:c,label:d,audio:h,costCaption:Hie(l,!0),status:l.status==="cancelled"?"cancelled":l.status==="failed"||l.error?"failed":l.status==="completed"?"completed":"unknown",error:typeof l.error=="string"?l.error:null}})}function Hie(e,t=!1){const n=e.cost&&typeof e.cost=="object"?e.cost:null;if(t&&(e.status==="failed"||e.error)&&e.cost_usd===0){if(n?.basis==="billed")return"No charge.";if(n?.basis==="estimated")return"Estimated cost $0; final charge not confirmed."}return vC({...e,billing_basis:n?.basis??e.billing_basis})}function TP(e){const t=e,n=Hie(t);if(!n)return"Total cost not yet known.";const r=t.cost_complete===!0;return`${r?"Total cost":"Known total cost"} ${n.slice(5)}${r?"":" Unknown or late charges are not included."}`}function oTe(e){return"cost_complete"in e||["completed","failed","cancelled"].some(t=>t in e)}function sTe(e,t){const n=e,r=s=>{const l=n[s];return typeof l=="number"&&Number.isInteger(l)&&l>=0?l:t.filter(c=>c.status===s).length},i=r("cancelled"),a=t.filter(s=>s.status==="unknown").length,o=t.filter(s=>s.status!=="completed");return`${r("completed")} completed · ${r("failed")} failed${i?` · ${i} cancelled/stopped`:""}${a?` · ${a} status unknown`:""}${o.length?`. Needs attention: ${o.map(s=>s.label).join("; ")}`:""}`}function lTe(e,t){const n=e;if(typeof n.error=="string"&&n.error)return n.error;const r=t?.split(`
3
3
  `)[0];if(!r)return null;const i=r.indexOf("Batch ");return i>=0?r.slice(i):null}function cTe(e,t){const n=t&&typeof t=="object"?t:{},r=e&&typeof e=="object"?e.sounds:null,i=typeof n.total=="number"&&Number.isInteger(n.total)&&n.total>0?n.total:Array.isArray(r)&&r.length?r.length:null;if(i===null)return null;const a=n.item,o=typeof a=="number"&&Number.isInteger(a)&&a>=1&&a<=i&&typeof n.name=="string"?`Latest update: ${n.name} (item ${a} of ${i}).`:null;return{total:i,note:o}}const jC="generate_video",CC="generate_voiceover",zC="generate_sound_effect",uTe=new Set(["generate_image",jC,CC,zC]);function Kie(e){return uTe.has(e)}function OTe(e){return e===jC}function dTe(e){return e===CC||e===zC}function fTe(e){return e===jC?"video":e===CC?"voiceover":e===zC?"sound-effect":"image"}const TU="Stopped before the provider was called; you will not be charged.",vE="Stop requested. The provider has no cancellation endpoint; the generation continues and will be charged if it produces audio. Checking for settlement.",hTe="Audio generation is busy right now. Wait a moment and try again.";function sh(e){switch(e){case"video":return"video";case"voiceover":return"voiceover";case"sound-effect":return"sound effect";default:return"image"}}function pTe(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n.message;typeof r=="string"&&r&&t.push(r)}return t}function mTe(e){const t=e??{};return{stage:typeof t.stage=="string"?t.stage:null,fraction:typeof t.progress_fraction=="number"&&Number.isFinite(t.progress_fraction)?t.progress_fraction:null,logs:pTe(t.log_lines),queuePosition:typeof t.queue_position=="number"&&Number.isInteger(t.queue_position)?t.queue_position:null,error:typeof t.error=="string"&&t.error?t.error:null,errorType:typeof t.error_type=="string"&&t.error_type?t.error_type:null}}function XU(e){return e.fraction===null&&e.logs.length===0&&e.queuePosition===null?Jie:{fraction:e.fraction,logs:e.logs,queuePosition:e.queuePosition}}const Jie=Object.freeze({fraction:null,logs:[],queuePosition:null});function gTe(e,{stopping:t=!1,settled:n=!1}={}){const r=mTe(e.details),i=fTe(e.toolName),a=i==="voiceover"||i==="sound-effect",o=a&&e.phase==="done"?aTe(e.details,e.images??[]):null,s=a?cTe(e.args,e.details):null,l=o?{batch:o,batchSummary:sTe(e.details,o),batchNote:lTe(e.details,e.output)}:{},c=a?vTe(e.details):null;if(e.stopped===!0)return{state:"cancelled",generating:e.startedAt!==null,message:r.error??e.output,...o?{...l,material:i,costCaption:TP(e.details)}:{},...c?{settlementCaption:c}:{},...c||n?{settled:!0}:{}};if(e.notRunKind==="skipped"||e.notRunKind==="aborted")return{state:"cancelled",generating:!1,message:e.output};if(e.notRunReason)return{state:"failed",material:i,message:e.notRunReason,errorType:a?XP(e.notRunKind,e.notRunReason):null};if(e.neverSent===!0)return{state:"cancelled",generating:!1,message:e.output};if(o&&e.isError)return{state:"failed",material:i,message:r.error??e.output,errorType:XP(r.errorType,r.error??e.output),...l,costCaption:TP(e.details)};if(e.isError===!0)return r.errorType==="media_already_completed"?{state:"done",images:e.images??[],material:i,durationS:e.durationS??null,receipt:"already-finished"}:r.stage==="cancelled"&&r.errorType===null?{state:"cancelled",generating:e.startedAt!==null,message:r.error??e.output,...c?{settlementCaption:c}:{},...c||n?{settled:!0}:{}}:{state:"failed",material:i,message:r.error??e.output??(r.errorType==="audio_rate_limited"?hTe:null),errorType:a?XP(r.errorType,r.error??e.output):null};switch(e.phase){case"composing":case"queued":return t?{state:"cancelling",generating:!1,material:i,startedAtMs:null,progress:Jie}:{state:"queued",material:i,composing:e.phase==="composing",argumentBytes:e.argumentBytes??0,queuePosition:r.queuePosition};case"running":{const u=e.startedAt??null;return t?{state:"cancelling",generating:!0,material:i,startedAtMs:u,progress:XU(r)}:{state:"running",material:i,startedAtMs:u,progress:XU(r),note:r.error,...s?{batchProgress:s}:{}}}case"done":{const u=a?vC(e.details,e.output):null;return{state:"done",images:e.images??[],material:i,durationS:e.durationS??null,receipt:"generated",batch:o,...l,costCaption:o?TP(e.details):u}}}}const $Te=/\s*Checking for settlement\.?\s*$/;function yTe(e){return e.replace($Te,"").trimEnd()}function vTe(e){if(!e||typeof e!="object")return null;const t=e,n=t.cost;return t.settled===!0?vC(e):t.settled===null&&t.cost_usd===null&&n?.basis==="quote"?"Settlement pending — the final charge will appear once the provider reports it.":null}function XP(e,t){if(!e)return null;const n=e.replace(/_/g," ");return t?.toLowerCase().startsWith(n.toLowerCase())?null:n.charAt(0).toUpperCase()+n.slice(1)}function bTe(e,t){const n=[],r=e.state==="queued"||e.state==="running"||e.state==="cancelling";t?.onCancel&&r&&n.push({kind:"cancel",disabled:e.state==="cancelling"});const i=e.state==="failed"||e.state==="cancelled";return t?.onRestart&&i&&n.push({kind:"restart",disabled:!1}),t?.onEditRestart&&i&&n.push({kind:"editRestart",disabled:!1}),n}function wTe(e,t){if(!OTe(e))return t?{onCancel:t}:void 0}const RU=new Map,EU=new Map,qU=new Map;function AC(e){return e===void 0?"":JSON.stringify(e)}function UC(e,t){const n=`${e}\0${AC(t)}`;let r=RU.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),RU.set(n,r)),r}function xTe(e,t){const n=`${e}\0${AC(t)}`;let r=EU.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),EU.set(n,r)),r}function eae(e,t,n){return UC(n??fy(),t).format(e)}function STe(e,t,n){return UC(n??fy(),t).format(e)}function QTe(e,t,n){return UC(n??fy(),t).format(e)}function tae(e,t,n){return xTe(n??fy(),t).format(e)}function bKt(e,t,n,r){const i=r??fy(),a=`${i}\0${AC(n)}`;let o=qU.get(a);return o===void 0&&(o=new Intl.RelativeTimeFormat(i,n),qU.set(a,o)),o.format(e,t)}function kTe(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const PTe=e=>{switch(e){case"success":return XTe;case"info":return ETe;case"warning":return RTe;case"error":return qTe;default:return null}},_Te=Array(12).fill(0),TTe=({visible:e,className:t})=>ee.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ee.createElement("div",{className:"sonner-spinner"},_Te.map((n,r)=>ee.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),XTe=ee.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ee.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),RTe=ee.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ee.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),ETe=ee.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ee.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),qTe=ee.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ee.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),jTe=ee.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ee.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ee.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),CTe=()=>{const[e,t]=ee.useState(document.hidden);return ee.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let bE=1;class zTe{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:r,...i}=t,a=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:bE++,o=this.toasts.find(l=>l.id===a),s=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),o?this.toasts=this.toasts.map(l=>l.id===a?(this.publish({...l,...t,id:a,title:r}),{...l,...t,id:a,dismissible:s,title:r}):l):this.addToast({title:r,...i,dismissible:s,id:a}),a},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const i=Promise.resolve(t instanceof Function?t():t);let a=r!==void 0,o;const s=i.then(async c=>{if(o=["resolve",c],ee.isValidElement(c))a=!1,this.create({id:r,type:"default",message:c});else if(UTe(c)&&!c.ok){a=!1;const O=typeof n.error=="function"?await n.error(`HTTP error! status: ${c.status}`):n.error,d=typeof n.description=="function"?await n.description(`HTTP error! status: ${c.status}`):n.description,p=typeof O=="object"&&!ee.isValidElement(O)?O:{message:O};this.create({id:r,type:"error",description:d,...p})}else if(c instanceof Error){a=!1;const O=typeof n.error=="function"?await n.error(c):n.error,d=typeof n.description=="function"?await n.description(c):n.description,p=typeof O=="object"&&!ee.isValidElement(O)?O:{message:O};this.create({id:r,type:"error",description:d,...p})}else if(n.success!==void 0){a=!1;const O=typeof n.success=="function"?await n.success(c):n.success,d=typeof n.description=="function"?await n.description(c):n.description,p=typeof O=="object"&&!ee.isValidElement(O)?O:{message:O};this.create({id:r,type:"success",description:d,...p})}}).catch(async c=>{if(o=["reject",c],n.error!==void 0){a=!1;const u=typeof n.error=="function"?await n.error(c):n.error,O=typeof n.description=="function"?await n.description(c):n.description,h=typeof u=="object"&&!ee.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:O,...h})}}).finally(()=>{a&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),l=()=>new Promise((c,u)=>s.then(()=>o[0]==="reject"?u(o[1]):c(o[1])).catch(u));return typeof r!="string"&&typeof r!="number"?{unwrap:l}:Object.assign(r,{unwrap:l})},this.custom=(t,n)=>{const r=n?.id||bE++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const ka=new zTe,ATe=(e,t)=>{const n=t?.id||bE++;return ka.addToast({title:e,...t,id:n}),n},UTe=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",WTe=ATe,YTe=()=>ka.toasts,NTe=()=>ka.getActiveToasts(),Dd=Object.assign(WTe,{success:ka.success,info:ka.info,warning:ka.warning,error:ka.error,custom:ka.custom,message:ka.message,promise:ka.promise,dismiss:ka.dismiss,loading:ka.loading},{getHistory:YTe,getToasts:NTe});kTe("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}[data-sonner-toaster][data-lifted=true]{transform:translateY(-8px)}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function vv(e){return e.label!==void 0}const GTe=3,ZTe="24px",ITe="16px",jU=4e3,DTe=356,VTe=14,MTe=45,LTe=200;function Ns(...e){return e.filter(Boolean).join(" ")}function FTe(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const BTe=e=>{var t,n,r,i,a,o,s,l,c;const{invert:u,toast:O,unstyled:d,interacting:h,setHeights:p,visibleToasts:m,heights:g,index:y,toasts:v,expanded:x,removeToast:S,defaultRichColors:b,closeButton:w,style:Q,cancelButtonStyle:P,actionButtonStyle:T,className:_="",descriptionClassName:R="",duration:q,position:A,gap:C,expandByDefault:N,classNames:I,icons:W,closeButtonAriaLabel:G="Close toast"}=e,[D,j]=ee.useState(null),[V,J]=ee.useState(null),[U,te]=ee.useState(!1),[L,B]=ee.useState(!1),[Oe,F]=ee.useState(!1),[H,ne]=ee.useState(!1),[oe,ie]=ee.useState(!1),[we,ye]=ee.useState(0),[Re,ze]=ee.useState(0),Ge=ee.useRef(O.duration||q||jU),qe=ee.useRef(null),Ve=ee.useRef(null),lt=y===0,Ot=y+1<=m,dt=O.type,fe=O.dismissible!==!1,$e=O.className||"",ke=O.descriptionClassName||"",ce=ee.useMemo(()=>g.findIndex(Qt=>Qt.toastId===O.id)||0,[g,O.id]),me=ee.useMemo(()=>{var Qt;return(Qt=O.closeButton)!=null?Qt:w},[O.closeButton,w]),ve=ee.useMemo(()=>O.duration||q||jU,[O.duration,q]),Je=ee.useRef(0),ct=ee.useRef(0),bt=ee.useRef(0),Dt=ee.useRef(null),[rn,Ze]=A.split("-"),jt=ee.useMemo(()=>g.reduce((Qt,Xn,mr)=>mr>=ce?Qt:Qt+Xn.height,0),[g,ce]),St=CTe(),an=O.invert||u,on=dt==="loading";ct.current=ee.useMemo(()=>ce*C+jt,[ce,jt]),ee.useEffect(()=>{Ge.current=ve},[ve]),ee.useEffect(()=>{te(!0)},[]),ee.useEffect(()=>{const Qt=Ve.current;if(Qt){const Xn=Qt.getBoundingClientRect().height;return ze(Xn),p(mr=>[{toastId:O.id,height:Xn,position:O.position},...mr]),()=>p(mr=>mr.filter(_r=>_r.toastId!==O.id))}},[p,O.id]),ee.useLayoutEffect(()=>{if(!U)return;const Qt=Ve.current,Xn=Qt.style.height;Qt.style.height="auto";const mr=Qt.getBoundingClientRect().height;Qt.style.height=Xn,ze(mr),p(_r=>_r.find(tr=>tr.toastId===O.id)?_r.map(tr=>tr.toastId===O.id?{...tr,height:mr}:tr):[{toastId:O.id,height:mr,position:O.position},..._r])},[U,O.title,O.description,p,O.id]);const pr=ee.useCallback(()=>{B(!0),ye(ct.current),p(Qt=>Qt.filter(Xn=>Xn.toastId!==O.id)),setTimeout(()=>{S(O)},LTe)},[O,S,p,ct]);ee.useEffect(()=>{if(O.promise&&dt==="loading"||O.duration===1/0||O.type==="loading")return;let Qt;return x||h||St?(()=>{if(bt.current<Je.current){const _r=new Date().getTime()-Je.current;Ge.current=Ge.current-_r}bt.current=new Date().getTime()})():(()=>{Ge.current!==1/0&&(Je.current=new Date().getTime(),Qt=setTimeout(()=>{O.onAutoClose==null||O.onAutoClose.call(O,O),pr()},Ge.current))})(),()=>clearTimeout(Qt)},[x,h,O,dt,St,pr]),ee.useEffect(()=>{O.delete&&pr()},[pr,O.delete]);function De(){var Qt;if(W?.loading){var Xn;return ee.createElement("div",{className:Ns(I?.loader,O==null||(Xn=O.classNames)==null?void 0:Xn.loader,"sonner-loader"),"data-visible":dt==="loading"},W.loading)}return ee.createElement(TTe,{className:Ns(I?.loader,O==null||(Qt=O.classNames)==null?void 0:Qt.loader),visible:dt==="loading"})}const pt=O.icon||W?.[dt]||PTe(dt);var Vt,Ai;return ee.createElement("li",{tabIndex:0,ref:Ve,className:Ns(_,$e,I?.toast,O==null||(t=O.classNames)==null?void 0:t.toast,I?.default,I?.[dt],O==null||(n=O.classNames)==null?void 0:n[dt]),"data-sonner-toast":"","data-rich-colors":(Vt=O.richColors)!=null?Vt:b,"data-styled":!(O.jsx||O.unstyled||d),"data-mounted":U,"data-promise":!!O.promise,"data-swiped":oe,"data-removed":L,"data-visible":Ot,"data-y-position":rn,"data-x-position":Ze,"data-index":y,"data-front":lt,"data-swiping":Oe,"data-dismissible":fe,"data-type":dt,"data-invert":an,"data-swipe-out":H,"data-swipe-direction":V,"data-expanded":!!(x||N&&U),style:{"--index":y,"--toasts-before":y,"--z-index":v.length-y,"--offset":`${L?we:ct.current}px`,"--initial-height":N?"auto":`${Re}px`,...Q,...O.style},onDragEnd:()=>{F(!1),j(null),Dt.current=null},onPointerDown:Qt=>{on||!fe||(qe.current=new Date,ye(ct.current),Qt.target.setPointerCapture(Qt.pointerId),Qt.target.tagName!=="BUTTON"&&(F(!0),Dt.current={x:Qt.clientX,y:Qt.clientY}))},onPointerUp:()=>{var Qt,Xn,mr;if(H||!fe)return;Dt.current=null;const _r=Number(((Qt=Ve.current)==null?void 0:Qt.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),na=Number(((Xn=Ve.current)==null?void 0:Xn.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),tr=new Date().getTime()-((mr=qe.current)==null?void 0:mr.getTime()),Tr=D==="x"?_r:na,Ga=Math.abs(Tr)/tr;if(Math.abs(Tr)>=MTe||Ga>.11){ye(ct.current),O.onDismiss==null||O.onDismiss.call(O,O),J(D==="x"?_r>0?"right":"left":na>0?"down":"up"),pr(),ne(!0);return}else{var yt,Rn;(yt=Ve.current)==null||yt.style.setProperty("--swipe-amount-x","0px"),(Rn=Ve.current)==null||Rn.style.setProperty("--swipe-amount-y","0px")}ie(!1),F(!1),j(null)},onPointerMove:Qt=>{var Xn,mr,_r;if(!Dt.current||!fe||((Xn=window.getSelection())==null?void 0:Xn.toString().length)>0)return;const tr=Qt.clientY-Dt.current.y,Tr=Qt.clientX-Dt.current.x;var Ga;const yt=(Ga=e.swipeDirections)!=null?Ga:FTe(A);!D&&(Math.abs(Tr)>1||Math.abs(tr)>1)&&j(Math.abs(Tr)>Math.abs(tr)?"x":"y");let Rn={x:0,y:0};const gr=$r=>1/(1.5+Math.abs($r)/20);if(D==="y"){if(yt.includes("top")||yt.includes("bottom"))if(yt.includes("top")&&tr<0||yt.includes("bottom")&&tr>0)Rn.y=tr;else{const $r=tr*gr(tr);Rn.y=Math.abs($r)<Math.abs(tr)?$r:tr}}else if(D==="x"&&(yt.includes("left")||yt.includes("right")))if(yt.includes("left")&&Tr<0||yt.includes("right")&&Tr>0)Rn.x=Tr;else{const $r=Tr*gr(Tr);Rn.x=Math.abs($r)<Math.abs(Tr)?$r:Tr}(Math.abs(Rn.x)>0||Math.abs(Rn.y)>0)&&ie(!0),(mr=Ve.current)==null||mr.style.setProperty("--swipe-amount-x",`${Rn.x}px`),(_r=Ve.current)==null||_r.style.setProperty("--swipe-amount-y",`${Rn.y}px`)}},me&&!O.jsx&&dt!=="loading"?ee.createElement("button",{"aria-label":G,"data-disabled":on,"data-close-button":!0,onClick:on||!fe?()=>{}:()=>{pr(),O.onDismiss==null||O.onDismiss.call(O,O)},className:Ns(I?.closeButton,O==null||(r=O.classNames)==null?void 0:r.closeButton)},(Ai=W?.close)!=null?Ai:jTe):null,(dt||O.icon||O.promise)&&O.icon!==null&&(W?.[dt]!==null||O.icon)?ee.createElement("div",{"data-icon":"",className:Ns(I?.icon,O==null||(i=O.classNames)==null?void 0:i.icon)},O.promise||O.type==="loading"&&!O.icon?O.icon||De():null,O.type!=="loading"?pt:null):null,ee.createElement("div",{"data-content":"",className:Ns(I?.content,O==null||(a=O.classNames)==null?void 0:a.content)},ee.createElement("div",{"data-title":"",className:Ns(I?.title,O==null||(o=O.classNames)==null?void 0:o.title)},O.jsx?O.jsx:typeof O.title=="function"?O.title():O.title),O.description?ee.createElement("div",{"data-description":"",className:Ns(R,ke,I?.description,O==null||(s=O.classNames)==null?void 0:s.description)},typeof O.description=="function"?O.description():O.description):null),ee.isValidElement(O.cancel)?O.cancel:O.cancel&&vv(O.cancel)?ee.createElement("button",{"data-button":!0,"data-cancel":!0,style:O.cancelButtonStyle||P,onClick:Qt=>{vv(O.cancel)&&fe&&(O.cancel.onClick==null||O.cancel.onClick.call(O.cancel,Qt),pr())},className:Ns(I?.cancelButton,O==null||(l=O.classNames)==null?void 0:l.cancelButton)},O.cancel.label):null,ee.isValidElement(O.action)?O.action:O.action&&vv(O.action)?ee.createElement("button",{"data-button":!0,"data-action":!0,style:O.actionButtonStyle||T,onClick:Qt=>{vv(O.action)&&(O.action.onClick==null||O.action.onClick.call(O.action,Qt),!Qt.defaultPrevented&&pr())},className:Ns(I?.actionButton,O==null||(c=O.classNames)==null?void 0:c.actionButton)},O.action.label):null)};function CU(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function HTe(e,t){const n={};return[e,t].forEach((r,i)=>{const a=i===1,o=a?"--mobile-offset":"--offset",s=a?ITe:ZTe;function l(c){["top","right","bottom","left"].forEach(u=>{n[`${o}-${u}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${o}-${c}`]=s:n[`${o}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(s)}),n}const KTe=ee.forwardRef(function(t,n){const{invert:r,position:i="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:s,className:l,offset:c,mobileOffset:u,theme:O="light",richColors:d,duration:h,style:p,visibleToasts:m=GTe,toastOptions:g,dir:y=CU(),gap:v=VTe,icons:x,containerAriaLabel:S="Notifications"}=t,[b,w]=ee.useState([]),Q=ee.useMemo(()=>Array.from(new Set([i].concat(b.filter(V=>V.position).map(V=>V.position)))),[b,i]),[P,T]=ee.useState([]),[_,R]=ee.useState(!1),[q,A]=ee.useState(!1),[C,N]=ee.useState(O!=="system"?O:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),I=ee.useRef(null),W=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),G=ee.useRef(null),D=ee.useRef(!1),j=ee.useCallback(V=>{w(J=>{var U;return(U=J.find(te=>te.id===V.id))!=null&&U.delete||ka.dismiss(V.id),J.filter(({id:te})=>te!==V.id)})},[]);return ee.useEffect(()=>ka.subscribe(V=>{if(V.dismiss){requestAnimationFrame(()=>{w(J=>J.map(U=>U.id===V.id?{...U,delete:!0}:U))});return}setTimeout(()=>{__e.flushSync(()=>{w(J=>{const U=J.findIndex(te=>te.id===V.id);return U!==-1?[...J.slice(0,U),{...J[U],...V},...J.slice(U+1)]:[V,...J]})})})}),[b]),ee.useEffect(()=>{if(O!=="system"){N(O);return}if(O==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?N("dark"):N("light")),typeof window>"u")return;const V=window.matchMedia("(prefers-color-scheme: dark)");try{V.addEventListener("change",({matches:J})=>{N(J?"dark":"light")})}catch{V.addListener(({matches:U})=>{try{N(U?"dark":"light")}catch(te){console.error(te)}})}},[O]),ee.useEffect(()=>{b.length<=1&&R(!1)},[b]),ee.useEffect(()=>{const V=J=>{var U;if(a.every(B=>J[B]||J.code===B)){var L;R(!0),(L=I.current)==null||L.focus()}J.code==="Escape"&&(document.activeElement===I.current||(U=I.current)!=null&&U.contains(document.activeElement))&&R(!1)};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[a]),ee.useEffect(()=>{if(I.current)return()=>{G.current&&(G.current.focus({preventScroll:!0}),G.current=null,D.current=!1)}},[I.current]),ee.createElement("section",{ref:n,"aria-label":`${S} ${W}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},Q.map((V,J)=>{var U;const[te,L]=V.split("-");return b.length?ee.createElement("ol",{key:V,dir:y==="auto"?CU():y,tabIndex:-1,ref:I,className:l,"data-sonner-toaster":!0,"data-sonner-theme":C,"data-y-position":te,"data-lifted":_&&b.length>1&&!o,"data-x-position":L,style:{"--front-toast-height":`${((U=P[0])==null?void 0:U.height)||0}px`,"--width":`${DTe}px`,"--gap":`${v}px`,...p,...HTe(c,u)},onBlur:B=>{D.current&&!B.currentTarget.contains(B.relatedTarget)&&(D.current=!1,G.current&&(G.current.focus({preventScroll:!0}),G.current=null))},onFocus:B=>{B.target instanceof HTMLElement&&B.target.dataset.dismissible==="false"||D.current||(D.current=!0,G.current=B.relatedTarget)},onMouseEnter:()=>R(!0),onMouseMove:()=>R(!0),onMouseLeave:()=>{q||R(!1)},onDragEnd:()=>R(!1),onPointerDown:B=>{B.target instanceof HTMLElement&&B.target.dataset.dismissible==="false"||A(!0)},onPointerUp:()=>A(!1)},b.filter(B=>!B.position&&J===0||B.position===V).map((B,Oe)=>{var F,H;return ee.createElement(BTe,{key:B.id,icons:x,index:Oe,toast:B,defaultRichColors:d,duration:(F=g?.duration)!=null?F:h,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:m,closeButton:(H=g?.closeButton)!=null?H:s,interacting:q,position:V,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:j,toasts:b.filter(ne=>ne.position==B.position),heights:P.filter(ne=>ne.position==B.position),setHeights:T,expandByDefault:o,gap:v,expanded:_,swipeDirections:t.swipeDirections})})):null}))}),JTe=["ERR_INTERNET_DISCONNECTED","ERR_NETWORK_CHANGED","ERR_NAME_NOT_RESOLVED","ERR_TIMED_OUT","ERR_CONNECTION_RESET","ERR_CONNECTION_REFUSED","ERR_CONNECTION_CLOSED","ERR_CONNECTION_FAILED","ERR_CONNECTION_TIMED_OUT","ERR_ADDRESS_UNREACHABLE","ERR_NETWORK_IO_SUSPENDED","ERR_PROXY_CONNECTION_FAILED"],e2e=["ENOTFOUND","EAI_AGAIN","ETIMEDOUT","ECONNRESET","ECONNREFUSED","EHOSTUNREACH","ENETUNREACH","ENETDOWN","ENETRESET","ECONNABORTED","EPIPE"],t2e=["Failed to fetch","Load failed","NetworkError when attempting to fetch resource."],n2e=new Set(JTe),r2e=/[:\-\u2014\n]$/,i2e=/^[:\n]/,zU=/[:\uff1a\n\u2014]| - /g,a2e=/^(?:\s*Error:\s*)+/,o2e=/:\s+Error:\s+/g,s2e=/\b(?:net::)?(ERR_[A-Z0-9_]+)\b/g,l2e=e2e.map(e=>({code:e,pattern:new RegExp(`\\b${e}\\b`)}));function RP(e,t,n){const r=e.slice(0,t).trimEnd(),i=e.slice(t+n).trimStart(),a=r===""||r2e.test(r),o=i===""||i2e.test(i);return a&&o}function nae(e){const t=u2e(e);if(!t)return null;const n=rae(t);for(const r of n.matchAll(s2e)){const i=r[1];if(!n2e.has(i))continue;const a=r.index??0,o=a+r[0].length;return{code:`net::${i}`,start:a,end:o,clauseText:EP(n,a,o),clause:RP(n,a,o-a)}}for(const{code:r,pattern:i}of l2e){const a=i.exec(n);if(a){const o=a.index,s=o+a[0].length;return{code:r,start:o,end:s,clauseText:EP(n,o,s),clause:RP(n,o,s-o)}}}for(const r of t2e){const i=n.indexOf(r);if(i!==-1&&RP(n,i,r.length))return{code:r,start:i,end:i+r.length,clauseText:EP(n,i,i+r.length),clause:!0}}return null}function c2e(e){return nae(e)?.code??null}function wKt(e){return c2e(e)!==null}function u2e(e){if(typeof e=="string")return e;if(e instanceof Error)return e.message||e.name||"";if(e&&typeof e=="object"&&"message"in e){const t=e.message;return typeof t=="string"?t:""}return""}function EP(e,t,n){let r=0;for(const a of e.slice(0,t).matchAll(zU))r=(a.index??0)+a[0].length;let i=e.length;for(const a of e.slice(n).matchAll(zU)){i=n+(a.index??0);break}return e.slice(r,i).trim()}function rae(e){return e.replace(a2e,"").replace(o2e,": ")}const qm=new Map,qP=new Map,jP=new Map,AU=5e3,O2e=1,d2e={CONNECTION:["Failed to fetch","Network error","ERR_CONNECTION_REFUSED","Server is offline","Connection failed"]},f2e={"Failed to fetch":!0,"TypeError: Failed to fetch":!0,"Load failed":!0,"NetworkError when attempting to fetch resource.":!0,ERR_CONNECTION_REFUSED:!0,"net::ERR_CONNECTION_REFUSED":!0},CP="Could not reach the server. Check that it is running, then try again.",iae=e=>{const t=e.trim();if(Object.prototype.hasOwnProperty.call(f2e,t))return CP;const n=rae(t),r=nae(n);return r===null?e:r.clause?`${n.slice(0,r.start)}${CP}${n.slice(r.end)}`:CP},h2e=e=>{for(const[t,n]of Object.entries(d2e))if(n.some(r=>e.includes(r)))return t;return null},xKt=(e,t)=>Dd.loading(e,t),Kr=(e,t)=>{const n=Date.now(),i=h2e(e)||e,a=iae(e),o=qP.get(i);if(o&&n-o<AU)return null;const s=jP.get(i)||0;if(s>=O2e)return null;if(qm.has(i))return qP.set(i,n),qm.get(i);const l=Dd.error(a,{...t,onDismiss:c=>{qm.delete(i),t?.onDismiss?.(c)},onAutoClose:c=>{qm.delete(i),t?.onAutoClose?.(c)}});return qm.set(i,l),qP.set(i,n),jP.set(i,s+1),setTimeout(()=>{jP.set(i,0)},AU),l},SKt=(e,t)=>Dd.error(iae(e),t),Uu=(e,t)=>Dd.info(e,t),e0=e=>{Dd.dismiss(e)},wd=(e,t)=>Dd.success(e,t),jm=(e,t)=>Dd.warning(e,t),p2e={"under-window":{dark:{canvas:.59,surface:.67,elevated:.87},light:{canvas:.61,surface:.5,elevated:.45}},menu:{dark:{canvas:.73,surface:.79,elevated:.94},light:{canvas:.79,surface:.7,elevated:.65}},popover:{dark:{canvas:.79,surface:.85,elevated:.97},light:{canvas:.86,surface:.79,elevated:.75}}},m2e={dark:.09,light:.12},g2e={dark:{role:"sunken",scale:.73},light:{role:"surface",scale:.72}},$2e={dark:.91,light:.78},y2e={"under-window":{dark:.15,light:.2},menu:{dark:.15,light:.2},popover:{dark:.15,light:.15}},v2e={hover:.05,selected:.08,field:.05,work:.08},Bs={alphaFloor:p2e,blockVeil:m2e,laneWash:g2e,bandFloor:$2e,controlMix:y2e,stateAlpha:v2e},QKt=["sidebars","full"],aae=(e,t)=>e!=="vibrancy"?"popover":t==="menu"?"menu":t==="popover"?"popover":"under-window",b2e=.96,oae=e=>Math.round(e*100)/100;function w2e(e,t,n){const r=Bs.alphaFloor[aae(e,t)][n];return{canvas:r.canvas,surface:r.surface,elevated:r.elevated}}function x2e(e){const t=Math.min(100,Math.max(0,e.intensity))/100,n=w2e(e.mechanism,e.material,e.scheme),r=i=>{const a=Math.max(b2e,i);return oae(a-t*(a-i))};return{canvas:r(n.canvas),surface:r(n.surface),elevated:r(n.elevated)}}const S2e={sidebars:["sidebar"],full:["sidebar","canvas","pane"]};function Q2e(e,t,n){return Bs.controlMix[aae(e,t)][n]}function k2e(e){const t=x2e(e),n=i=>oae(Math.min(1,Math.max(0,1-(1-i)/(1-t.canvas)))),r={"--lo-glass-a-canvas":String(t.canvas),"--lo-glass-a-surface":String(t.surface),"--lo-glass-a-elevated":String(t.elevated),"--lo-glass-a-row-hover":String(Bs.stateAlpha.hover),"--lo-glass-a-row-selected":String(Bs.stateAlpha.selected),"--lo-glass-a-row-work":String(Bs.stateAlpha.work),"--lo-glass-a-field":String(Bs.stateAlpha.field),"--lo-glass-a-block-veil":String(Bs.blockVeil[e.scheme]),"--lo-glass-a-band-floor":String(Bs.bandFloor[e.scheme]),"--lo-glass-a-lane":String(Math.round(t.canvas*Bs.laneWash[e.scheme].scale*100)/100),"--lo-glass-lane-tone":Bs.laneWash[e.scheme].role==="sunken"?"var(--lo-sunken)":"var(--lo-surface)","--lo-glass-control-mix":String(Q2e(e.mechanism,e.material,e.scheme)),"--lo-glass-in-surface":String(n(t.surface)),"--lo-glass-in-elevated":String(n(t.elevated))};return{kinds:S2e[e.coverage].join(" "),vars:r}}const sae=()=>document.documentElement,P2e=["--lo-glass-a-canvas","--lo-glass-a-surface","--lo-glass-a-elevated","--lo-glass-a-row-hover","--lo-glass-a-row-selected","--lo-glass-a-row-work","--lo-glass-a-block-veil","--lo-glass-a-band-floor","--lo-glass-a-lane","--lo-glass-lane-tone","--lo-glass-a-field","--lo-glass-control-mix","--lo-glass-in-surface","--lo-glass-in-elevated"];let h1=null;const uw=()=>sae().classList.contains("dark")?"dark":"light";function Ow(e){h1=e;const t=sae();if(!e||!e.active){delete t.dataset.glass;for(const i of P2e)t.style.removeProperty(i);return}const{kinds:n,vars:r}=k2e({coverage:e.settings.coverage,intensity:e.settings.intensity,mechanism:e.mechanism,material:e.settings.material,scheme:e.scheme});t.dataset.glass=n;for(const[i,a]of Object.entries(r))t.style.setProperty(i,a)}function kKt(e){Ow(e?{active:!0,scheme:e.scheme,mechanism:e.mechanism,settings:{coverage:e.coverage,intensity:e.intensity,material:e.material}}:null)}function wE(e){if(!e||!e.active||e.capability.mechanism==="none"){Ow(null);return}e.restartRequired&&e.active||Ow({active:!0,scheme:uw(),mechanism:e.capability.mechanism,settings:{coverage:e.settings.coverage,intensity:e.settings.intensity,material:e.settings.material}})}function PKt(){!h1||!h1.active||(Ow({...h1,scheme:uw()}),window.api?.windowGlass?.reportScheme?.(uw()))}function _Kt(){const e=window.api?.windowGlass;if(!e)return()=>{};const t=e.onState(r=>wE(r)),n=r=>{r&&wE(r)};return typeof CSS<"u"&&e.reportRenderer?.({backdropFilter:CSS.supports("backdrop-filter: blur(1px)")}).then(n,()=>{}),e.get?.().then(n,()=>{}),t}function TKt(){const[e,t]=$.useState(null);return $.useEffect(()=>{const r=window.api?.windowGlass;if(!r)return;let i=!1;r.get().then(o=>{i||t(o)});const a=r.onState(o=>t(o));return()=>{i=!0,a()}},[]),{state:e,set:async r=>{const i=await window.api?.windowGlass?.set(r);i&&(t(i),wE(i),window.api?.windowGlass?.reportScheme?.(uw()))}}}var _2e=class extends iPe{#n;#r=void 0;#e;#t;constructor(t,n){super(),this.#n=t,this.setOptions(n),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const n=this.options;this.options=this.#n.defaultMutationOptions(t),aPe(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#e,observer:this}),n?.mutationKey&&this.options.mutationKey&&oU(n.mutationKey)!==oU(this.options.mutationKey)?this.reset():this.#e?.state.status==="pending"&&this.#e.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#e?.removeObserver(this)}onMutationUpdate(t){this.#i(),this.#a(t)}getCurrentResult(){return this.#r}reset(){this.#e?.removeObserver(this),this.#e=void 0,this.#i(),this.#a()}mutate(t,n){return this.#t=n,this.#e?.removeObserver(this),this.#e=this.#n.getMutationCache().build(this.#n,this.options),this.#e.addObserver(this),this.#e.execute(t)}#i(){const t=this.#e?.state??oPe();this.#r={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#a(t){vie.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#r.variables,r=this.#r.context;t?.type==="success"?(this.#t.onSuccess?.(t.data,n,r),this.#t.onSettled?.(t.data,null,n,r)):t?.type==="error"&&(this.#t.onError?.(t.error,n,r),this.#t.onSettled?.(void 0,t.error,n,r))}this.listeners.forEach(n=>{n(this.#r)})})}};function xE(e,t){const n=Yc(t),[r]=$.useState(()=>new _2e(n,e));$.useEffect(()=>{r.setOptions(e)},[r,e]);const i=$.useSyncExternalStore($.useCallback(o=>r.subscribe(vie.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=$.useCallback((o,s)=>{r.mutate(o,s).catch(sPe)},[r]);if(i.error&&lPe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const T2e=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),X2e=function(e,t){return new URL(e,t).href},UU={},ge=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){const o=document.getElementsByTagName("link"),s=document.querySelector("meta[property=csp-nonce]"),l=s?.nonce||s?.getAttribute("nonce");i=Promise.allSettled(n.map(c=>{if(c=X2e(c,r),c in UU)return;UU[c]=!0;const u=c.endsWith(".css"),O=u?'[rel="stylesheet"]':"";if(!!r)for(let p=o.length-1;p>=0;p--){const m=o[p];if(m.href===c&&(!u||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${O}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":T2e,u||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),u)return new Promise((p,m)=>{h.addEventListener("load",p),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(o){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=o,window.dispatchEvent(s),!s.defaultPrevented)throw o}return i.then(o=>{for(const s of o||[])s.status==="rejected"&&a(s.reason);return t().catch(a)})};/**
4
4
  * React Router DOM v6.30.0
5
5
  *
@@ -783,7 +783,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
783
783
  `))};if(c.from==this.from&&a<this.from?c.from=a:c.to==this.to&&a>this.to&&(c.to=a),c.from==c.to&&!c.insert.length){let u=Ue.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((it.mac||it.android)&&c.from==o-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:s,to:l,insert:zn.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);Rz(t,c,Ue.single(this.toEditorPos(r.selectionStart,u),this.toEditorPos(r.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))},this.handlers.characterboundsupdate=r=>{let i=[],a=null;for(let o=this.toEditorPos(r.rangeStart),s=this.toEditorPos(r.rangeEnd);o<s;o++){let l=t.coordsForChar(o);a=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||a||new DOMRect,i.push(a)}n.updateCharacterBounds(r.rangeStart,i)},this.handlers.textformatupdate=r=>{let i=[];for(let a of r.getTextFormats()){let o=a.underlineStyle,s=a.underlineThickness;if(o!="None"&&s!="None"){let l=this.toEditorPos(a.rangeStart),c=this.toEditorPos(a.rangeEnd);if(l<c){let u=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${s=="Thin"?1:2}px`;i.push(Ft.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:IOe.of(Ft.set(i))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(t.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{this.editContext.updateControlBounds(r.contentDOM.getBoundingClientRect());let i=n$(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let n=0,r=!1,i=this.pendingContextChange;return t.changes.iterChanges((a,o,s,l,c)=>{if(r)return;let u=c.length-(o-a);if(i&&o>=i.to)if(i.from==a&&i.to==o&&i.insert.eq(c)){i=this.pendingContextChange=null,n+=u,this.to+=u;return}else i=null,this.revertPending(t.state);if(a+=n,o+=n,o<=this.from)this.from+=u,this.to+=u;else if(a<this.to){if(a<this.from||o>this.to||this.to-this.from+c.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(o),c.toString()),this.to+=u}n+=u}),i&&!r&&this.revertPending(t.state),!r}update(t){let n=this.pendingContextChange,r=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(r.from,r.to)&&t.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||n)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:n}=t.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(t.doc.length,n+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),t.doc.sliceString(n.from,n.to))}setSelection(t){let{main:n}=t.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(t){let{head:n}=t.selection.main;return!(this.from>0&&n-this.from<500||this.to<t.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(t,n=this.to-this.from){t=Math.min(t,n);let r=this.composing;return r&&r.drifted?r.editorBase+(t-r.contextBase):t+this.from}toContextPos(t){let n=this.composing;return n&&n.drifted?n.contextBase+(t-n.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class vt{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:r}=t;this.dispatchTransactions=t.dispatchTransactions||r&&(i=>i.forEach(a=>r(a,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=t.root||mVe(t.parent)||document,this.viewState=new DG(t.state||kn.create(t)),t.scrollTo&&t.scrollTo.is(Vv)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(uh).map(i=>new L5(i));for(let i of this.plugins)i.update(this);this.observer=new jMe(this),this.inputState=new rMe(this),this.inputState.ensureHandlers(this.plugins),this.docView=new kG(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let n=t.length==1&&t[0]instanceof ji?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(n,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,a=this.state;for(let d of t){if(d.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=d.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,l=null;t.some(d=>d.annotation(rde))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=ide(a,o),l||(s=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(kn.phrases)!=this.state.facet(kn.phrases))return this.setState(a);i=Uw.create(this,a,t),i.flags|=s;let O=this.viewState.scrollTarget;try{this.updateState=2;for(let d of t){if(O&&(O=O.map(d.changes)),d.scrollIntoView){let{main:h}=d.state.selection;O=new kh(h.empty?h:Ue.cursor(h.head,h.head>h.anchor?-1:1))}for(let h of d.effects)h.is(Vv)&&(O=h.value.clip(this.state))}this.viewState.update(i,O),this.bidiCache=Yw.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Cg)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(Kv)!=i.state.facet(Kv)&&(this.viewState.mustMeasureContent=!0),(n||r||O||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let d of this.state.facet(Mq))try{d(i)}catch(h){Ea(this.state,h,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!HOe(this,u)&&c.force&&Qh(this.contentDOM,c.key,c.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new DG(t),this.plugins=t.facet(uh).map(r=>new L5(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new kG(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(t){let n=t.startState.facet(uh),r=t.state.facet(uh);if(n!=r){let i=[];for(let a of r){let o=n.indexOf(a);if(o<0)i.push(new L5(a));else{let s=this.plugins[o];s.mustUpdate=t,i.push(s)}}for(let a of this.plugins)a.mustUpdate!=t&&a.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=t;for(let i=0;i<this.plugins.length;i++)this.plugins[i].update(this);n!=r&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let n=t.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(r){Ea(this.state,r,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let n=null,r=this.scrollDOM,i=r.scrollTop*this.scaleY,{scrollAnchorPos:a,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let s=0;;s++){if(o<0)if($Oe(r))a=-1,o=this.viewState.heightMap.height;else{let h=this.viewState.scrollAnchorAt(i);a=h.from,o=h.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(s>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(h=>{try{return h.read(this)}catch(p){return Ea(this.state,p),FG}}),O=Uw.create(this,this.state,[]),d=!1;O.flags|=l,n?n.flags|=l:n=O,this.updateState=2,O.empty||(this.updatePlugins(O),this.inputState.update(O),this.updateAttrs(),d=this.docView.update(O),d&&this.docViewUpdate());for(let h=0;h<c.length;h++)if(u[h]!=FG)try{let p=c[h];p.write&&p.write(u[h],this)}catch(p){Ea(this.state,p)}if(d&&this.docView.updateSelection(!0),!O.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=(a<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(a).top)-o;if(p>1||p<-1){i=i+p,r.scrollTop=i/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let s of this.state.facet(Mq))s(n)}get themeClasses(){return Kq+" "+(this.state.facet(Hq)?lde:sde)+" "+this.state.facet(Kv)}updateAttrs(){let t=BG(this,DOe,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ac)?"true":"false",class:"cm-content",style:`${it.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),BG(this,_z,n);let r=this.observer.ignore(()=>{let i=Gq(this.contentDOM,this.contentAttrs,n),a=Gq(this.dom,this.editorAttrs,t);return i||a});return this.editorAttrs=t,this.contentAttrs=n,r}showAnnouncements(t){let n=!0;for(let r of t)for(let i of r.effects)if(i.is(vt.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(Cg);let t=this.state.facet(vt.cspNonce);Ju.mount(this.root,this.styleModules.concat(EMe).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===t.key){this.measureRequests[n]=t;return}}this.measureRequests.push(t)}}plugin(t){let n=this.pluginMap.get(t);return(n===void 0||n&&n.plugin!=t)&&this.pluginMap.set(t,n=this.plugins.find(r=>r.plugin==t)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,n,r){return B5(this,t,RG(this,t,n,r))}moveByGroup(t,n){return B5(this,t,RG(this,t,n,r=>LVe(this,t.head,r)))}visualLineSide(t,n){let r=this.bidiSpans(t),i=this.textDirectionAt(t.from),a=r[n?r.length-1:0];return Ue.cursor(a.side(n,i)+t.from,a.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return MVe(this,t,n,r)}moveVertically(t,n,r){return B5(this,t,FVe(this,t,n,r))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,n=0){return this.docView.posFromDOM(t,n)}posAtCoords(t,n=!0){return this.readMeasured(),BOe(this,t,n)}coordsAtPos(t,n=1){this.readMeasured();let r=this.docView.coordsAt(t,n);if(!r||r.left==r.right)return r;let i=this.state.doc.lineAt(t),a=this.bidiSpans(i),o=a[Xu.find(a,t-i.from,-1,n)];return Ry(r,o.dir==Or.LTR==n>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(NOe)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>AMe)return qOe(t.length);let n=this.textDirectionAt(t.from),r;for(let a of this.bidiCache)if(a.from==t.from&&a.dir==n&&(a.fresh||EOe(a.isolates,r=QG(this,t))))return a.order;r||(r=QG(this,t));let i=RVe(t.text,n,r);return this.bidiCache.push(new Yw(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||it.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{mOe(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,n={}){return Vv.of(new kh(typeof t=="number"?Ue.cursor(t):t,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(t);return Vv.of(new kh(Ue.cursor(r.from),"start","start",r.top-t,n,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return pi.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return pi.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=Ju.newName(),i=[Kv.of(r),Cg.of(Jq(`.${r}`,t))];return n&&n.dark&&i.push(Hq.of(!0)),i}static baseTheme(t){return uO.lowest(Cg.of(Jq("."+Kq,t,cde)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&Vn.get(r)||Vn.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}vt.styleModule=Cg;vt.inputHandler=WOe;vt.clipboardInputFilter=kz;vt.clipboardOutputFilter=Pz;vt.scrollHandler=ZOe;vt.focusChangeEffect=YOe;vt.perLineTextDirection=NOe;vt.exceptionSink=UOe;vt.updateListener=Mq;vt.editable=ac;vt.mouseSelectionStyle=AOe;vt.dragMovesSelection=zOe;vt.clickAddsSelectionRange=COe;vt.decorations=r$;vt.outerDecorations=VOe;vt.atomicRanges=Tz;vt.bidiIsolatedRanges=MOe;vt.scrollMargins=LOe;vt.darkTheme=Hq;vt.cspNonce=st.define({combine:e=>e.length?e[0]:""});vt.contentAttributes=_z;vt.editorAttributes=DOe;vt.lineWrapping=vt.contentAttributes.of({class:"cm-lineWrapping"});vt.announce=pn.define();const AMe=4096,FG={};class Yw{constructor(t,n,r,i,a,o){this.from=t,this.to=n,this.dir=r,this.isolates=i,this.fresh=a,this.order=o}static update(t,n){if(n.empty&&!t.some(a=>a.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:Or.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new Yw(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function BG(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let a=r[i],o=typeof a=="function"?a(e):a;o&&Nq(o,n)}return n}const UMe=it.mac?"mac":it.windows?"win":it.linux?"linux":"key";function WMe(e,t){const n=e.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,a,o,s;for(let l=0;l<n.length-1;++l){const c=n[l];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))i=!0;else if(/^(c|ctrl|control)$/i.test(c))a=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))t=="mac"?s=!0:a=!0;else throw new Error("Unrecognized modifier name: "+c)}return i&&(r="Alt-"+r),a&&(r="Ctrl-"+r),s&&(r="Meta-"+r),o&&(r="Shift-"+r),r}function Jv(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n!==!1&&t.shiftKey&&(e="Shift-"+e),e}const YMe=uO.default(vt.domEventHandlers({keydown(e,t){return Ode(ude(t.state),e,t,"editor")}})),kQ=st.define({enables:YMe}),HG=new WeakMap;function ude(e){let t=e.facet(kQ),n=HG.get(t);return n||HG.set(t,n=GMe(t.reduce((r,i)=>r.concat(i),[]))),n}function Nen(e,t,n){return Ode(ude(e.state),t,e,n)}let xu=null;const NMe=4e3;function GMe(e,t=UMe){let n=Object.create(null),r=Object.create(null),i=(o,s)=>{let l=r[o];if(l==null)r[o]=s;else if(l!=s)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},a=(o,s,l,c,u)=>{var O,d;let h=n[o]||(n[o]=Object.create(null)),p=s.split(/ (?!$)/).map(y=>WMe(y,t));for(let y=1;y<p.length;y++){let v=p.slice(0,y).join(" ");i(v,!0),h[v]||(h[v]={preventDefault:!0,stopPropagation:!1,run:[x=>{let S=xu={view:x,prefix:v,scope:o};return setTimeout(()=>{xu==S&&(xu=null)},NMe),!0}]})}let m=p.join(" ");i(m,!1);let g=h[m]||(h[m]={preventDefault:!1,stopPropagation:!1,run:((d=(O=h._any)===null||O===void 0?void 0:O.run)===null||d===void 0?void 0:d.slice())||[]});l&&g.run.push(l),c&&(g.preventDefault=!0),u&&(g.stopPropagation=!0)};for(let o of e){let s=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of s){let u=n[c]||(n[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:O}=o;for(let d in u)u[d].run.push(h=>O(h,e3))}let l=o[t]||o.key;if(l)for(let c of s)a(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&a(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return n}let e3=null;function Ode(e,t,n,r){e3=t;let i=OVe(t),a=io(i,0),o=ic(a)==i.length&&i!=" ",s="",l=!1,c=!1,u=!1;xu&&xu.view==n&&xu.scope==r&&(s=xu.prefix+" ",JOe.indexOf(t.keyCode)<0&&(c=!0,xu=null));let O=new Set,d=g=>{if(g){for(let y of g.run)if(!O.has(y)&&(O.add(y),y(n)))return g.stopPropagation&&(u=!0),!0;g.preventDefault&&(g.stopPropagation&&(u=!0),c=!0)}return!1},h=e[r],p,m;return h&&(d(h[s+Jv(i,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(it.windows&&t.ctrlKey&&t.altKey)&&(p=eO[t.keyCode])&&p!=i?(d(h[s+Jv(p,t,!0)])||t.shiftKey&&(m=t$[t.keyCode])!=i&&m!=p&&d(h[s+Jv(m,t,!1)]))&&(l=!0):o&&t.shiftKey&&d(h[s+Jv(i,t,!0)])&&(l=!0),!l&&d(h._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),e3=null,l}class jy{constructor(t,n,r,i,a){this.className=t,this.left=n,this.top=r,this.width=i,this.height=a}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,n){return n.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=dde(t);return[new jy(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return ZMe(t,n,r)}}function dde(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Or.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function KG(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),l=e.posAtCoords({x:a.right-1,y:o});return s==null||l==null?r:{from:Math.max(r.from,Math.min(s,l)),to:Math.min(r.to,Math.max(s,l))}}function ZMe(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==Or.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),l=dde(e),c=o.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),O=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),d=s.right-(u?parseInt(u.paddingRight):0),h=Fq(e,r,1),p=Fq(e,i,-1),m=h.type==pa.Text?h:null,g=p.type==pa.Text?p:null;if(m&&(e.lineWrapping||h.widgetLineBreaks)&&(m=KG(e,r,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=KG(e,i,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return v(x(n.from,n.to,m));{let b=m?x(n.from,null,m):S(h,!1),w=g?x(null,n.to,g):S(p,!0),Q=[];return(m||h).to<(g||p).from-(m&&g?1:0)||h.widgetLineBreaks>1&&b.bottom+e.defaultLineHeight/2<w.top?Q.push(y(O,b.bottom,d,w.top)):b.bottom<w.top&&e.elementAtHeight((b.bottom+w.top)/2).type==pa.Text&&(b.bottom=w.top=(b.bottom+w.top)/2),v(b).concat(Q).concat(v(w))}function y(b,w,Q,P){return new jy(t,b-l.left,w-l.top,Q-b,P-w)}function v({top:b,bottom:w,horizontal:Q}){let P=[];for(let T=0;T<Q.length;T+=2)P.push(y(Q[T],b,Q[T+1],w));return P}function x(b,w,Q){let P=1e9,T=-1e9,_=[];function R(C,N,I,W,G){let D=e.coordsAtPos(C,C==Q.to?-2:2),j=e.coordsAtPos(I,I==Q.from?2:-2);!D||!j||(P=Math.min(D.top,j.top,P),T=Math.max(D.bottom,j.bottom,T),G==Or.LTR?_.push(a&&N?O:D.left,a&&W?d:j.right):_.push(!a&&W?O:j.left,!a&&N?d:D.right))}let q=b??Q.from,A=w??Q.to;for(let C of e.visibleRanges)if(C.to>q&&C.from<A)for(let N=Math.max(C.from,q),I=Math.min(C.to,A);;){let W=e.state.doc.lineAt(N);for(let G of e.bidiSpans(W)){let D=G.from+W.from,j=G.to+W.from;if(D>=I)break;j>N&&R(Math.max(D,N),b==null&&D<=q,Math.min(j,I),w==null&&j>=A,G.dir)}if(N=W.to+1,N>=I)break}return _.length==0&&R(q,b==null,A,w==null,e.textDirection),{top:P,bottom:T,horizontal:_}}function S(b,w){let Q=s.top+(w?b.top:b.bottom);return{top:Q,bottom:Q,horizontal:[]}}}function IMe(e,t){return e.constructor==t.constructor&&e.eq(t)}class DMe{constructor(t,n){this.view=t,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,t)}update(t){t.startState.facet(T1)!=t.state.facet(T1)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){this.layer.updateOnDocViewUpdate!==!1&&t.requestMeasure(this.measureReq)}setOrder(t){let n=0,r=t.facet(T1);for(;n<r.length&&r[n]!=this.layer;)n++;this.dom.style.zIndex=String((this.layer.above?150:-1)-n)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:n}=this.view;(t!=this.scaleX||n!=this.scaleY)&&(this.scaleX=t,this.scaleY=n,this.dom.style.transform=`scale(${1/t}, ${1/n})`)}draw(t){if(t.length!=this.drawn.length||t.some((n,r)=>!IMe(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let i of t)i.update&&n&&i.constructor&&this.drawn[r].constructor&&i.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(i.draw(),n);for(;n;){let i=n.nextSibling;n.remove(),n=i}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const T1=st.define();function fde(e){return[pi.define(t=>new DMe(t,e)),T1.of(e)]}const i$=st.define({combine(e){return em(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function Gen(e={}){return[i$.of(e),VMe,MMe,LMe,GOe.of(!0)]}function hde(e){return e.startState.facet(i$)!=e.state.facet(i$)}const VMe=fde({above:!0,markers(e){let{state:t}=e,n=t.facet(i$),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor){let o=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",s=i.empty?i:Ue.cursor(i.head,i.head>i.anchor?-1:1);for(let l of jy.forRange(e,o,s))r.push(l)}}return r},update(e,t){e.transactions.some(r=>r.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=hde(e);return n&&JG(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){JG(t.state,e)},class:"cm-cursorLayer"});function JG(e,t){t.style.animationDuration=e.facet(i$).cursorBlinkRate+"ms"}const MMe=fde({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:jy.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||hde(e)},class:"cm-selectionLayer"}),LMe=uO.highest(vt.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),pde=pn.define({map(e,t){return e==null?null:t.mapPos(e)}}),Ug=Wa.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(pde)?r.value:n,e)}}),FMe=pi.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(Ug);n==null?this.cursor!=null&&((t=this.cursor)===null||t===void 0||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(Ug)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(Ug),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(Ug)!=e&&this.view.dispatch({effects:pde.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Zen(){return[Ug,FMe]}function eZ(e,t,n,r,i){t.lastIndex=0;for(let a=e.iterRange(n,r),o=n,s;!a.next().done;o+=a.value.length)if(!a.lineBreak)for(;s=t.exec(a.value);)i(o+s.index,s)}function BMe(e,t){let n=e.visibleRanges;if(n.length==1&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:a}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),a=Math.min(e.state.doc.lineAt(a).to,a+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=a:r.push({from:i,to:a});return r}class HMe{constructor(t){const{regexp:n,decoration:r,decorate:i,boundary:a,maxLength:o=1e3}=t;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,i)this.addMatch=(s,l,c,u)=>i(u,c,c+s[0].length,s,l);else if(typeof r=="function")this.addMatch=(s,l,c,u)=>{let O=r(s,l,c);O&&u(c,c+s[0].length,O)};else if(r)this.addMatch=(s,l,c,u)=>u(c,c+s[0].length,r);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=a,this.maxLength=o}createDeco(t){let n=new Qd,r=n.add.bind(n);for(let{from:i,to:a}of BMe(t,this.maxLength))eZ(t.state.doc,this.regexp,i,a,(o,s)=>this.addMatch(s,t,o,r));return n.finish()}updateDeco(t,n){let r=1e9,i=-1;return t.docChanged&&t.changes.iterChanges((a,o,s,l)=>{l>=t.view.viewport.from&&s<=t.view.viewport.to&&(r=Math.min(s,r),i=Math.max(l,i))}),t.viewportMoved||i-r>1e3?this.createDeco(t.view):i>-1?this.updateRange(t.view,n.map(t.changes),r,i):n}updateRange(t,n,r,i){for(let a of t.visibleRanges){let o=Math.max(a.from,r),s=Math.min(a.to,i);if(s>=o){let l=t.state.doc.lineAt(o),c=l.to<s?t.state.doc.lineAt(s):l,u=Math.max(a.from,l.from),O=Math.min(a.to,c.to);if(this.boundary){for(;o>l.from;o--)if(this.boundary.test(l.text[o-1-l.from])){u=o;break}for(;s<c.to;s++)if(this.boundary.test(c.text[s-c.from])){O=s;break}}let d=[],h,p=(m,g,y)=>d.push(y.range(m,g));if(l==c)for(this.regexp.lastIndex=u-l.from;(h=this.regexp.exec(l.text))&&h.index<O-l.from;)this.addMatch(h,t,h.index+l.from,p);else eZ(t.state.doc,this.regexp,u,O,(m,g)=>this.addMatch(g,t,m,p));n=n.update({filterFrom:u,filterTo:O,filter:(m,g)=>m<u||g>O,add:d})}}return n}}const t3=/x/.unicode!=null?"gu":"g",KMe=new RegExp(`[\0-\b
784
784
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,t3),JMe={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let J5=null;function eLe(){var e;if(J5==null&&typeof document<"u"&&document.body){let t=document.body.style;J5=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return J5||!1}const X1=st.define({combine(e){let t=em(e,{render:null,specialChars:KMe,addSpecialChars:null});return(t.replaceTabs=!eLe())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,t3)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,t3)),t}});function Ien(e={}){return[X1.of(e),tLe()]}let tZ=null;function tLe(){return tZ||(tZ=pi.fromClass(class{constructor(e){this.view=e,this.decorations=Ft.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(X1)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new HMe({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=io(t[0],0);if(a==9){let o=i.lineAt(r),s=n.state.tabSize,l=Ku(o.text,s,r-o.from);return Ft.replace({widget:new aLe((s-l%s)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=Ft.replace({widget:new iLe(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(X1);e.startState.facet(X1)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))}const nLe="•";function rLe(e){return e>=32?nLe:e==10?"␤":String.fromCharCode(9216+e)}class iLe extends Dc{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=rLe(this.code),r=t.state.phrase("Control character")+" "+(JMe[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,n);if(i)return i;let a=document.createElement("span");return a.textContent=n,a.title=r,a.setAttribute("aria-label",r),a.className="cm-specialChar",a}ignoreEvent(){return!1}}class aLe extends Dc{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function Den(){return sLe}const oLe=Ft.line({class:"cm-activeLine"}),sLe=pi.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(oLe.range(i.from)),t=i.from)}return Ft.set(n)}},{decorations:e=>e.decorations});class lLe extends Dc{constructor(t){super(),this.content=t}toDOM(t){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(t){let n=t.firstChild?Kh(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=Ry(n[0],r.direction!="rtl"),a=parseInt(r.lineHeight);return i.bottom-i.top>a*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+a}:i}ignoreEvent(){return!1}}function Ven(e){let t=pi.fromClass(class{constructor(n){this.view=n,this.placeholder=e?Ft.set([Ft.widget({widget:new lLe(e),side:1}).range(0)]):Ft.none}get decorations(){return this.view.state.doc.length?Ft.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,vt.contentAttributes.of({"aria-placeholder":e})]:t}const n3=2e3;function cLe(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>n3||n.off>n3||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let l=r;l<=i;l++){let c=e.doc.line(l);c.length<=s&&a.push(Ue.range(c.from+o,c.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let l=r;l<=i;l++){let c=e.doc.line(l),u=jq(c.text,o,e.tabSize,!0);if(u<0)a.push(Ue.cursor(c.to));else{let O=jq(c.text,s,e.tabSize);a.push(Ue.range(c.from+u,c.from+O))}}}return a}function uLe(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function nZ(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,a=i>n3?-1:i==r.length?uLe(e,t.clientX):Ku(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function OLe(e,t){let n=nZ(e,t),r=e.state.selection;return n?{update(i){if(i.docChanged){let a=i.changes.mapPos(i.startState.doc.line(n.line).from),o=i.state.doc.lineAt(a);n={line:o.number,col:n.col,off:Math.min(n.off,o.length)},r=r.map(i.changes)}},get(i,a,o){let s=nZ(e,i);if(!s)return r;let l=cLe(e.state,n,s);return l.length?o?Ue.create(l.concat(r.ranges)):Ue.create(l):r}}:null}function Men(e){let t=n=>n.altKey&&n.button==0;return vt.mouseSelectionStyle.of((n,r)=>t(r)?OLe(n,r):null)}const dLe={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},fLe={style:"cursor: crosshair"};function Len(e={}){let[t,n]=dLe[e.key||"Alt"],r=pi.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==t||n(i))},keyup(i){(i.keyCode==t||!n(i))&&this.set(!1)},mousemove(i){this.set(n(i))}}});return[r,vt.contentAttributes.of(i=>{var a;return!((a=i.plugin(r))===null||a===void 0)&&a.isDown?fLe:null})]}const Vm="-10000px";class mde{constructor(t,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=t.state.facet(n),this.tooltips=this.input.filter(o=>o);let a=null;this.tooltipViews=this.tooltips.map(o=>a=r(o,a))}update(t,n){var r;let i=t.state.facet(this.facet),a=i.filter(l=>l);if(i===this.input){for(let l of this.tooltipViews)l.update&&l.update(t);return!1}let o=[],s=n?[]:null;for(let l=0;l<a.length;l++){let c=a[l],u=-1;if(c){for(let O=0;O<this.tooltips.length;O++){let d=this.tooltips[O];d&&d.create==c.create&&(u=O)}if(u<0)o[l]=this.createTooltipView(c,l?o[l-1]:null),s&&(s[l]=!!c.above);else{let O=o[l]=this.tooltipViews[u];s&&(s[l]=n[u]),O.update&&O.update(t)}}}for(let l of this.tooltipViews)o.indexOf(l)<0&&(this.removeTooltipView(l),(r=l.destroy)===null||r===void 0||r.call(l));return n&&(s.forEach((l,c)=>n[c]=l),n.length=s.length),this.input=i,this.tooltips=a,this.tooltipViews=o,!0}}function hLe(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const e_=st.define({combine:e=>{var t,n,r;return{position:it.ios?"absolute":((t=e.find(i=>i.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((n=e.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=e.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||hLe}}}),rZ=new WeakMap,jz=pi.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(e_);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new mde(e,Cz,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(e_);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=Vm,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(e=r.destroy)===null||e===void 0||e.call(r);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:a}=this.manager.tooltipViews[0];if(it.gecko)n=a.offsetParent!=this.container.ownerDocument.body;else if(a.style.top==Vm&&a.style.left=="0px"){let o=a.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}}if(n||this.position=="absolute")if(this.parent){let a=this.parent.getBoundingClientRect();a.width&&a.height&&(e=a.width/this.parent.offsetWidth,t=a.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Xz(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((a,o)=>{let s=this.manager.tooltipViews[o];return s.getCoords?s.getCoords(a.pos):this.view.coordsAtPos(a.pos)}),size:this.manager.tooltipViews.map(({dom:a})=>a.getBoundingClientRect()),space:this.view.state.facet(e_).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let s of this.manager.tooltipViews)s.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:a}=e,o=[];for(let s=0;s<this.manager.tooltips.length;s++){let l=this.manager.tooltips[s],c=this.manager.tooltipViews[s],{dom:u}=c,O=e.pos[s],d=e.size[s];if(!O||l.clip!==!1&&(O.bottom<=Math.max(n.top,r.top)||O.top>=Math.min(n.bottom,r.bottom)||O.right<Math.max(n.left,r.left)-.1||O.left>Math.min(n.right,r.right)+.1)){u.style.top=Vm;continue}let h=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,m=d.right-d.left,g=(t=rZ.get(c))!==null&&t!==void 0?t:d.bottom-d.top,y=c.offset||mLe,v=this.view.textDirection==Or.LTR,x=d.width>r.right-r.left?v?r.left:r.right-d.width:v?Math.max(r.left,Math.min(O.left-(h?14:0)+y.x,r.right-m)):Math.min(Math.max(r.left,O.left-m+(h?14:0)-y.x),r.right-m),S=this.above[s];!l.strictSide&&(S?O.top-g-p-y.y<r.top:O.bottom+g+p+y.y>r.bottom)&&S==r.bottom-O.bottom>O.top-r.top&&(S=this.above[s]=!S);let b=(S?O.top-r.top:r.bottom-O.bottom)-p;if(b<g&&c.resize!==!1){if(b<this.view.defaultLineHeight){u.style.top=Vm;continue}rZ.set(c,g),u.style.height=(g=b)/a+"px"}else u.style.height&&(u.style.height="");let w=S?O.top-g-p-y.y:O.bottom+p+y.y,Q=x+m;if(c.overlap!==!0)for(let P of o)P.left<Q&&P.right>x&&P.top<w+g&&P.bottom>w&&(w=S?P.top-g-2-p:P.bottom+p+2);if(this.position=="absolute"?(u.style.top=(w-e.parent.top)/a+"px",iZ(u,(x-e.parent.left)/i)):(u.style.top=w/a+"px",iZ(u,x/i)),h){let P=O.left+(v?y.x:-y.x)-(x+14-7);h.style.left=P/i+"px"}c.overlap!==!0&&o.push({left:x,top:w,right:Q,bottom:w+g}),u.classList.toggle("cm-tooltip-above",S),u.classList.toggle("cm-tooltip-below",!S),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=Vm}},{eventObservers:{scroll(){this.maybeMeasure()}}});function iZ(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const pLe=vt.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),mLe={x:0,y:0},Cz=st.define({enables:[jz,pLe]}),Nw=st.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class PQ{static create(t){return new PQ(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new mde(t,Nw,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(t,n){let r=t.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(t){for(let n of this.manager.tooltipViews)n.mount&&n.mount(t);this.mounted=!0}positioned(t){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let n of this.manager.tooltipViews)(t=n.destroy)===null||t===void 0||t.call(n)}passProp(t){let n;for(let r of this.manager.tooltipViews){let i=r[t];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const gLe=Cz.compute([Nw],e=>{let t=e.facet(Nw);return t.length===0?null:{pos:Math.min(...t.map(n=>n.pos)),end:Math.max(...t.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:PQ.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class $Le{constructor(t,n,r,i,a){this.view=t,this.source=n,this.field=r,this.setHover=i,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:n}=this,r=t.docView.nearest(n.target);if(!r)return;let i,a=1;if(r instanceof Tu)i=r.posAtStart;else{if(i=t.posAtCoords(n),i==null)return;let s=t.coordsAtPos(i);if(!s||n.y<s.top||n.y>s.bottom||n.x<s.left-t.defaultCharacterWidth||n.x>s.right+t.defaultCharacterWidth)return;let l=t.bidiSpans(t.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),c=l&&l.dir==Or.RTL?-1:1;a=n.x<s.left?-c:c}let o=this.source(t,i,a);if(o?.then){let s=this.pending={pos:i};o.then(l=>{this.pending==s&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Ea(t.state,l,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let t=this.view.plugin(jz),n=t?t.manager.tooltips.findIndex(r=>r.create==PQ.create):-1;return n>-1?t.manager.tooltipViews[n]:null}mousemove(t){var n,r;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:a}=this;if(i.length&&a&&!yLe(a.dom,t)||this.pending){let{pos:o}=i[0]||this.pending,s=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==s?this.view.posAtCoords(this.lastMove)!=o:!vLe(this.view,o,s,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length){let{tooltip:r}=this;r&&r.dom.contains(t.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let n=r=>{t.removeEventListener("mouseleave",n),this.active.length&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const eb=4;function yLe(e,t){let{left:n,right:r,top:i,bottom:a}=e.getBoundingClientRect(),o;if(o=e.querySelector(".cm-tooltip-arrow")){let s=o.getBoundingClientRect();i=Math.min(s.top,i),a=Math.max(s.bottom,a)}return t.clientX>=n-eb&&t.clientX<=r+eb&&t.clientY>=i-eb&&t.clientY<=a+eb}function vLe(e,t,n,r,i,a){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,s)<i)return!1;let l=e.posAtCoords({x:r,y:i},!1);return l>=t&&l<=n}function Fen(e,t={}){let n=pn.define(),r=Wa.define({create(){return[]},update(i,a){if(i.length&&(t.hideOnChange&&(a.docChanged||a.selection)?i=[]:t.hideOn&&(i=i.filter(o=>!t.hideOn(a,o))),a.docChanged)){let o=[];for(let s of i){let l=a.changes.mapPos(s.pos,-1,Ei.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),s);c.pos=l,c.end!=null&&(c.end=a.changes.mapPos(c.end)),o.push(c)}}i=o}for(let o of a.effects)o.is(n)&&(i=o.value),o.is(bLe)&&(i=[]);return i},provide:i=>Nw.from(i)});return{active:r,extension:[r,pi.define(i=>new $Le(i,e,r,n,t.hoverTime||300)),gLe]}}function gde(e,t){let n=e.plugin(jz);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const bLe=pn.define(),aZ=st.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function Ben(e,t){let n=e.plugin($de),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const $de=pi.fromClass(class{constructor(e){this.input=e.state.facet(sZ),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(aZ);this.top=new tb(e,!0,t.topContainer),this.bottom=new tb(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(e){let t=e.state.facet(aZ);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new tb(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new tb(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(sZ);if(n!=this.input){let r=n.filter(l=>l),i=[],a=[],o=[],s=[];for(let l of r){let c=this.specs.indexOf(l),u;c<0?(u=l(e.view),s.push(u)):(u=this.panels[c],u.update&&u.update(e)),i.push(u),(u.top?a:o).push(u)}this.specs=r,this.panels=i,this.top.sync(a),this.bottom.sync(o);for(let l of s)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let r of this.panels)r.update&&r.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>vt.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class tb{constructor(t,n,r){this.view=t,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let n of this.panels)n.destroy&&t.indexOf(n)<0&&n.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let t=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;t!=n.dom;)t=oZ(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=oZ(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function oZ(e){let t=e.nextSibling;return e.remove(),t}const sZ=st.define({enables:$de});class Xc extends Sd{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Xc.prototype.elementClass="";Xc.prototype.toDOM=void 0;Xc.prototype.mapMode=Ei.TrackBefore;Xc.prototype.startSide=Xc.prototype.endSide=-1;Xc.prototype.point=!0;const R1=st.define(),wLe=st.define(),xLe={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>hn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},d0=st.define();function SLe(e){return[yde(),d0.of({...xLe,...e})]}const lZ=st.define({combine:e=>e.some(t=>t)});function yde(e){return[QLe]}const QLe=pi.fromClass(class{constructor(e){this.view=e,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(d0).map(t=>new uZ(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(lZ),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}e.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(lZ)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&this.dom.remove();let n=hn.iter(this.view.state.facet(R1),this.view.viewport.from),r=[],i=this.gutters.map(a=>new kLe(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let o=!0;for(let s of a.type)if(s.type==pa.Text&&o){r3(n,r,s.from);for(let l of i)l.line(this.view,s,r);o=!1}else if(s.widget)for(let l of i)l.widget(this.view,s)}else if(a.type==pa.Text){r3(n,r,a.from);for(let o of i)o.line(this.view,a,r)}else if(a.widget)for(let o of i)o.widget(this.view,a);for(let a of i)a.finish();e&&this.view.scrollDOM.insertBefore(this.dom,t)}updateGutters(e){let t=e.startState.facet(d0),n=e.state.facet(d0),r=e.docChanged||e.heightChanged||e.viewportChanged||!hn.eq(e.startState.facet(R1),e.state.facet(R1),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let i of this.gutters)i.update(e)&&(r=!0);else{r=!0;let i=[];for(let a of n){let o=t.indexOf(a);o<0?i.push(new uZ(this.view,a)):(this.gutters[o].update(e),i.push(this.gutters[o]))}for(let a of this.gutters)a.dom.remove(),i.indexOf(a)<0&&a.destroy();for(let a of i)this.dom.appendChild(a.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove()}},{provide:e=>vt.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==Or.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function cZ(e){return Array.isArray(e)?e:[e]}function r3(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class kLe{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=hn.iter(t.markers,n.from)}addElement(t,n,r){let{gutter:i}=this,a=(n.top-this.height)/t.scaleY,o=n.height/t.scaleY;if(this.i==i.elements.length){let s=new vde(t,o,a,r);i.elements.push(s),i.dom.appendChild(s.dom)}else i.elements[this.i].update(t,o,a,r);this.height=n.bottom,this.i++}line(t,n,r){let i=[];r3(this.cursor,i,n.from),r.length&&(i=i.concat(r));let a=this.gutter.config.lineMarker(t,n,i);a&&i.unshift(a);let o=this.gutter;i.length==0&&!o.config.renderEmptyElements||this.addElement(t,n,i)}widget(t,n){let r=this.gutter.config.widgetMarker(t,n.widget,n),i=r?[r]:null;for(let a of t.state.facet(wLe)){let o=a(t,n.widget,n);o&&(i||(i=[])).push(o)}i&&this.addElement(t,n,i)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let n=t.elements.pop();t.dom.removeChild(n.dom),n.destroy()}}}class uZ{constructor(t,n){this.view=t,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,i=>{let a=i.target,o;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let l=a.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=i.clientY;let s=t.lineBlockAtHeight(o-t.documentTop);n.domEventHandlers[r](t,s,i)&&i.preventDefault()});this.markers=cZ(n.markers(t)),n.initialSpacer&&(this.spacer=new vde(t,0,0,[n.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let n=this.markers;if(this.markers=cZ(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],t);i!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[i])}let r=t.view.viewport;return!hn.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class vde{constructor(t,n,r,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,n,r,i)}update(t,n,r,i){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),PLe(this.markers,i)||this.setMarkers(t,i)}setMarkers(t,n){let r="cm-gutterElement",i=this.dom.firstChild;for(let a=0,o=0;;){let s=o,l=a<n.length?n[a++]:null,c=!1;if(l){let u=l.elementClass;u&&(r+=" "+u);for(let O=o;O<this.markers.length;O++)if(this.markers[O].compare(l)){s=O,c=!0;break}}else s=this.markers.length;for(;o<s;){let u=this.markers[o++];if(u.toDOM){u.destroy(i);let O=i.nextSibling;i.remove(),i=O}}if(!l)break;l.toDOM&&(c?i=i.nextSibling:this.dom.insertBefore(l.toDOM(t),i)),c&&o++}this.dom.className=r,this.markers=n}destroy(){this.setMarkers(null,[])}}function PLe(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}const _Le=st.define(),TLe=st.define(),Oh=st.define({combine(e){return em(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,n){let r=Object.assign({},t);for(let i in n){let a=r[i],o=n[i];r[i]=a?(s,l,c)=>a(s,l,c)||o(s,l,c):o}return r}})}});class t_ extends Xc{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function n_(e,t){return e.state.facet(Oh).formatNumber(t,e.state)}const XLe=d0.compute([Oh],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(_Le)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new t_(n_(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(TLe)){let a=i(t,n,r);if(a)return a}return null},lineMarkerChange:t=>t.startState.facet(Oh)!=t.state.facet(Oh),initialSpacer(t){return new t_(n_(t,OZ(t.state.doc.lines)))},updateSpacer(t,n){let r=n_(n.view,OZ(n.view.state.doc.lines));return r==t.number?t:new t_(r)},domEventHandlers:e.facet(Oh).domEventHandlers}));function Hen(e={}){return[Oh.of(e),yde(),XLe]}function OZ(e){let t=9;for(;t<e;)t=t*10+9;return t}const RLe=new class extends Xc{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},ELe=R1.compute(["selection"],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(RLe.range(i)))}return hn.of(t)});function Ken(){return ELe}let qLe=0;class Be{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=qLe++}toString(){let{name:t}=this;for(let n of this.modified)n.name&&(t=`${n.name}(${t})`);return t}static define(t,n){let r=typeof t=="string"?t:"?";if(t instanceof Be&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new Be(r,[],null,[]);if(i.set.push(i),n)for(let a of n.set)i.set.push(a);return i}static defineModifier(t){let n=new Gw(t);return r=>r.modified.indexOf(n)>-1?r:Gw.get(r.base||r,r.modified.concat(n).sort((i,a)=>i.id-a.id))}}let jLe=0;class Gw{constructor(t){this.name=t,this.instances=[],this.id=jLe++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(s=>s.base==t&&CLe(n,s.modified));if(r)return r;let i=[],a=new Be(t.name,i,t,n);for(let s of n)s.instances.push(a);let o=zLe(n);for(let s of t.set)if(!s.modified.length)for(let l of o)i.push(Gw.get(s,l));return a}}function CLe(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function zLe(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((n,r)=>r.length-n.length)}function wn(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let a=[],o=2,s=i;for(let O=0;;){if(s=="..."&&O>0&&O+3==i.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!d)throw new RangeError("Invalid path: "+i);if(a.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),O+=d[0].length,O==i.length)break;let h=i[O++];if(O==i.length&&h=="!"){o=0;break}if(h!="/")throw new RangeError("Invalid path: "+i);s=i.slice(O)}let l=a.length-1,c=a[l];if(!c)throw new RangeError("Invalid path: "+i);let u=new Zw(r,o,l>0?a.slice(0,l):null);t[c]=u.sort(t[c])}}return bde.add(t)}const bde=new qt;let Zw=class{constructor(t,n,r,i){this.tags=t,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}};Zw.empty=new Zw([],2,null);function wde(e,t){let n=Object.create(null);for(let a of e)if(!Array.isArray(a.tag))n[a.tag.id]=a.class;else for(let o of a.tag)n[o.id]=a.class;let{scope:r,all:i=null}=t||{};return{style:a=>{let o=i;for(let s of a)for(let l of s.set){let c=n[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:r}}function ALe(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function ULe(e,t,n,r=0,i=e.length){let a=new WLe(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,"",a.highlighters),a.flush(i)}class WLe{constructor(t,n,r){this.at=t,this.highlighters=n,this.span=r,this.class=""}startSpan(t,n){n!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=n)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,n,r,i,a){let{type:o,from:s,to:l}=t;if(s>=r||l<=n)return;o.isTop&&(a=this.highlighters.filter(h=>!h.scope||h.scope(o)));let c=i,u=YLe(t)||Zw.empty,O=ALe(a,u.tags);if(O&&(c&&(c+=" "),c+=O,u.mode==1&&(i+=(i?" ":"")+O)),this.startSpan(Math.max(n,s),c),u.opaque)return;let d=t.tree&&t.tree.prop(qt.mounted);if(d&&d.overlay){let h=t.node.enter(d.overlay[0].from+s,1),p=this.highlighters.filter(g=>!g.scope||g.scope(d.tree.type)),m=t.firstChild();for(let g=0,y=s;;g++){let v=g<d.overlay.length?d.overlay[g]:null,x=v?v.from+s:l,S=Math.max(n,y),b=Math.min(r,x);if(S<b&&m)for(;t.from<b&&(this.highlightRange(t,S,b,i,a),this.startSpan(Math.min(b,t.to),c),!(t.to>=x||!t.nextSibling())););if(!v||x>r)break;y=v.to+s,y>n&&(this.highlightRange(h.cursor(),Math.max(n,v.from+s),Math.min(r,y),"",p),this.startSpan(Math.min(r,y),c))}m&&t.parent()}else if(t.firstChild()){d&&(i="");do if(!(t.to<=n)){if(t.from>=r)break;this.highlightRange(t,n,r,i,a),this.startSpan(Math.min(r,t.to),c)}while(t.nextSibling());t.parent()}}}function YLe(e){let t=e.type.prop(bde);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const Fe=Be.define,nb=Fe(),mu=Fe(),dZ=Fe(mu),fZ=Fe(mu),gu=Fe(),rb=Fe(gu),r_=Fe(gu),Fs=Fe(),qO=Fe(Fs),Zs=Fe(),Is=Fe(),i3=Fe(),Mm=Fe(i3),ib=Fe(),k={comment:nb,lineComment:Fe(nb),blockComment:Fe(nb),docComment:Fe(nb),name:mu,variableName:Fe(mu),typeName:dZ,tagName:Fe(dZ),propertyName:fZ,attributeName:Fe(fZ),className:Fe(mu),labelName:Fe(mu),namespace:Fe(mu),macroName:Fe(mu),literal:gu,string:rb,docString:Fe(rb),character:Fe(rb),attributeValue:Fe(rb),number:r_,integer:Fe(r_),float:Fe(r_),bool:Fe(gu),regexp:Fe(gu),escape:Fe(gu),color:Fe(gu),url:Fe(gu),keyword:Zs,self:Fe(Zs),null:Fe(Zs),atom:Fe(Zs),unit:Fe(Zs),modifier:Fe(Zs),operatorKeyword:Fe(Zs),controlKeyword:Fe(Zs),definitionKeyword:Fe(Zs),moduleKeyword:Fe(Zs),operator:Is,derefOperator:Fe(Is),arithmeticOperator:Fe(Is),logicOperator:Fe(Is),bitwiseOperator:Fe(Is),compareOperator:Fe(Is),updateOperator:Fe(Is),definitionOperator:Fe(Is),typeOperator:Fe(Is),controlOperator:Fe(Is),punctuation:i3,separator:Fe(i3),bracket:Mm,angleBracket:Fe(Mm),squareBracket:Fe(Mm),paren:Fe(Mm),brace:Fe(Mm),content:Fs,heading:qO,heading1:Fe(qO),heading2:Fe(qO),heading3:Fe(qO),heading4:Fe(qO),heading5:Fe(qO),heading6:Fe(qO),contentSeparator:Fe(Fs),list:Fe(Fs),quote:Fe(Fs),emphasis:Fe(Fs),strong:Fe(Fs),link:Fe(Fs),monospace:Fe(Fs),strikethrough:Fe(Fs),inserted:Fe(),deleted:Fe(),changed:Fe(),invalid:Fe(),meta:ib,documentMeta:Fe(ib),annotation:Fe(ib),processingInstruction:Fe(ib),definition:Be.defineModifier("definition"),constant:Be.defineModifier("constant"),function:Be.defineModifier("function"),standard:Be.defineModifier("standard"),local:Be.defineModifier("local"),special:Be.defineModifier("special")};for(let e in k){let t=k[e];t instanceof Be&&(t.name=e)}wde([{tag:k.link,class:"tok-link"},{tag:k.heading,class:"tok-heading"},{tag:k.emphasis,class:"tok-emphasis"},{tag:k.strong,class:"tok-strong"},{tag:k.keyword,class:"tok-keyword"},{tag:k.atom,class:"tok-atom"},{tag:k.bool,class:"tok-bool"},{tag:k.url,class:"tok-url"},{tag:k.labelName,class:"tok-labelName"},{tag:k.inserted,class:"tok-inserted"},{tag:k.deleted,class:"tok-deleted"},{tag:k.literal,class:"tok-literal"},{tag:k.string,class:"tok-string"},{tag:k.number,class:"tok-number"},{tag:[k.regexp,k.escape,k.special(k.string)],class:"tok-string2"},{tag:k.variableName,class:"tok-variableName"},{tag:k.local(k.variableName),class:"tok-variableName tok-local"},{tag:k.definition(k.variableName),class:"tok-variableName tok-definition"},{tag:k.special(k.variableName),class:"tok-variableName2"},{tag:k.definition(k.propertyName),class:"tok-propertyName tok-definition"},{tag:k.typeName,class:"tok-typeName"},{tag:k.namespace,class:"tok-namespace"},{tag:k.className,class:"tok-className"},{tag:k.macroName,class:"tok-macroName"},{tag:k.propertyName,class:"tok-propertyName"},{tag:k.operator,class:"tok-operator"},{tag:k.comment,class:"tok-comment"},{tag:k.meta,class:"tok-meta"},{tag:k.invalid,class:"tok-invalid"},{tag:k.punctuation,class:"tok-punctuation"}]);var i_;const Ru=new qt;function _Q(e){return st.define({combine:e?t=>t.concat(e):void 0})}const zz=new qt;class co{constructor(t,n,r=[],i=""){this.data=t,this.name=i,kn.prototype.hasOwnProperty("tree")||Object.defineProperty(kn.prototype,"tree",{get(){return An(this)}}),this.parser=n,this.extension=[nO.of(this),kn.languageData.of((a,o,s)=>{let l=hZ(a,o,s),c=l.type.prop(Ru);if(!c)return[];let u=a.facet(c),O=l.type.prop(zz);if(O){let d=l.resolve(o-l.from,s);for(let h of O)if(h.test(d,a)){let p=a.facet(h.facet);return h.type=="replace"?p:p.concat(u)}}return u})].concat(r)}isActiveAt(t,n,r=-1){return hZ(t,n,r).type.prop(Ru)==this.data}findRegions(t){let n=t.facet(nO);if(n?.data==this.data)return[{from:0,to:t.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(a,o)=>{if(a.prop(Ru)==this.data){r.push({from:o,to:o+a.length});return}let s=a.prop(qt.mounted);if(s){if(s.tree.prop(Ru)==this.data){if(s.overlay)for(let l of s.overlay)r.push({from:l.from+o,to:l.to+o});else r.push({from:o,to:o+a.length});return}else if(s.overlay){let l=r.length;if(i(s.tree,s.overlay[0].from+o),r.length>l)return}}for(let l=0;l<a.children.length;l++){let c=a.children[l];c instanceof en&&i(c,a.positions[l]+o)}};return i(An(t),0),r}get allowsNesting(){return!0}}co.setState=pn.define();function hZ(e,t,n){let r=e.facet(nO),i=An(e).topNode;if(!r||r.allowsNesting)for(let a=i;a;a=a.enter(t,n,Dn.ExcludeBuffers))a.type.isTop&&(i=a);return i}class gn extends co{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=_Q(t.languageData);return new gn(n,t.parser.configure({props:[Ru.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new gn(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function An(e){let t=e.field(co.state,!1);return t?t.tree:en.empty}class NLe{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,n){let r=this.cursorPos-this.string.length;return t<r||n>=this.cursorPos?this.doc.sliceString(t,n):this.string.slice(t-r,n-r)}}let Lm=null;class Td{constructor(t,n,r=[],i,a,o,s,l){this.parser=t,this.state=n,this.fragments=r,this.tree=i,this.treeLen=a,this.viewport=o,this.skipped=s,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new Td(t,n,[],en.empty,0,r,[],null)}startParse(){return this.parser.startParse(new NLe(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=en.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let i=Date.now()+t;t=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped($c.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,n;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=t,this.tree=n,this.fragments=this.withoutTempSkipped($c.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=Lm;Lm=this;try{return t()}finally{Lm=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=pZ(t,n.from,n.to);return t}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((c,u,O,d)=>l.push({fromA:c,toA:u,fromB:O,toB:d})),r=$c.applyChanges(r,l),i=en.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let c of this.skipped){let u=t.mapPos(c.from,1),O=t.mapPos(c.to,-1);u<O&&s.push({from:u,to:O})}}}return new Td(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let n=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:a}=this.skipped[r];i<t.to&&a>t.from&&(this.fragments=pZ(this.fragments,i,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,n){this.skipped.push({from:t,to:n})}static getSkippingParser(t){return new class extends wQ{createParse(n,r,i){let a=i[0].from,o=i[i.length-1].to;return{parsedPos:a,advance(){let l=Lm;if(l){for(let c of i)l.tempSkipped.push(c);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=o,new en(ti.none,[],[],o-a)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let n=this.fragments;return this.treeLen>=t&&n.length&&n[0].from==0&&n[0].to>=t}static get(){return Lm}}function pZ(e,t,n){return $c.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class np{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new np(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=Td.create(t.facet(nO).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new np(r)}}co.state=Wa.define({create:np.init,update(e,t){for(let n of t.effects)if(n.is(co.setState))return n.value;return t.startState.facet(nO)!=t.state.facet(nO)?np.init(t.state):e.apply(t)}});let xde=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(xde=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const a_=typeof navigator<"u"&&(!((i_=navigator.scheduling)===null||i_===void 0)&&i_.isInputPending)?()=>navigator.scheduling.isInputPending():null,GLe=pi.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let n=this.view.state.field(co.state).context;(n.updateViewport(t.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:t}=this.view,n=t.field(co.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=xde(this.work))}work(t){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,a=r.field(co.state);if(a.tree==a.context.tree&&a.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!a_?Math.max(25,t.timeRemaining()-5):1e9),s=a.context.treeLen<i&&r.doc.length>i+1e3,l=a.context.work(()=>a_&&a_()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:co.setState.of(new np(a.context))})),this.chunkBudget>0&&!(l&&!s)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Ea(this.view.state,n)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),nO=st.define({combine(e){return e.length?e[0]:null},enables:e=>[co.state,GLe,vt.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class un{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class pe{constructor(t,n,r,i,a,o=void 0){this.name=t,this.alias=n,this.extensions=r,this.filename=i,this.loadFunc=a,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");n=()=>Promise.resolve(r)}return new pe(t.name,(t.alias||[]).concat(t.name).map(i=>i.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(t,n){for(let i of t)if(i.filename&&i.filename.test(n))return i;let r=/\.([^.]+)$/.exec(n);if(r){for(let i of t)if(i.extensions.indexOf(r[1])>-1)return i}return null}static matchLanguageName(t,n,r=!0){n=n.toLowerCase();for(let i of t)if(i.alias.some(a=>a==n))return i;if(r)for(let i of t)for(let a of i.alias){let o=n.indexOf(a);if(o>-1&&(a.length>2||!/\w/.test(n[o-1])&&!/\w/.test(n[o+a.length])))return i}return null}}const ZLe=st.define(),TQ=st.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(n=>n!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function Iw(e){let t=e.facet(TQ);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function ILe(e,t){let n="",r=e.tabSize,i=e.facet(TQ)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let a=0;a<t;a++)n+=i;return n}function DLe(e,t){e instanceof kn&&(e=new Sde(e));for(let r of e.state.facet(ZLe)){let i=r(e,t);if(i!==void 0)return i}let n=An(e.state);return n.length>=t?VLe(e,n,t):null}class Sde{constructor(t,n={}){this.state=t,this.options=n,this.unit=Iw(t)}lineAt(t,n=1){let r=this.state.doc.lineAt(t),{simulateBreak:i,simulateDoubleBreak:a}=this.options;return i!=null&&i>=r.from&&i<=r.to?a&&i==t?{text:"",from:t}:(n<0?i<t:i<=t)?{text:r.text.slice(i-r.from),from:i}:{text:r.text.slice(0,i-r.from),from:r.from}:r}textAfterPos(t,n=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:r,from:i}=this.lineAt(t,n);return r.slice(t-i,Math.min(r.length,t+100-i))}column(t,n=1){let{text:r,from:i}=this.lineAt(t,n),a=this.countColumn(r,t-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(a+=o-this.countColumn(r,r.search(/\S|$/))),a}countColumn(t,n=t.length){return Ku(t,this.state.tabSize,n)}lineIndent(t,n=1){let{text:r,from:i}=this.lineAt(t,n),a=this.options.overrideIndentation;if(a){let o=a(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Pr=new qt;function VLe(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let a=[];for(let o=i;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)a.push(o);for(let o=a.length-1;o>=0;o--)r={node:a[o],next:r}}return Qde(r,e,n)}function Qde(e,t,n){for(let r=e;r;r=r.next){let i=LLe(r.node);if(i)return i(Az.create(t,n,r))}return 0}function MLe(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function LLe(e){let t=e.type.prop(Pr);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(qt.closedBy))){let i=e.lastChild,a=i&&r.indexOf(i.name)>-1;return o=>kde(o,!0,1,void 0,a&&!MLe(o)?i.from:void 0)}return e.parent==null?FLe:null}function FLe(){return 0}class Az extends Sde{constructor(t,n,r){super(t.state,t.options),this.base=t,this.pos=n,this.context=r}get node(){return this.context.node}static create(t,n,r){return new Az(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let n=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(BLe(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Qde(this.context.next,this.base,this.pos)}}function BLe(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function HLe(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let s=n.to;;){let l=t.childAfter(s);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let c=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+c}}s=l.to}}function Io({closing:e,align:t=!0,units:n=1}){return r=>kde(r,t,n,e)}function kde(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,l=t?HLe(e):null;return l?s?e.column(l.from):e.column(l.to):e.baseIndent+(s?0:e.unit*n)}const Uz=e=>e.baseIndent;function Cr({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const KLe=200;function ttn(){return kn.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+KLe)return e;let a=n.sliceString(i.from,r);if(!t.some(c=>c.test(a)))return e;let{state:o}=e,s=-1,l=[];for(let{head:c}of o.selection.ranges){let u=o.doc.lineAt(c);if(u.from==s)continue;s=u.from;let O=DLe(o,u.from);if(O==null)continue;let d=/^\s*/.exec(u.text)[0],h=ILe(o,O);d!=h&&l.push({from:u.from,to:u.from+d.length,insert:h})}return l.length?[e,{changes:l,sequential:!0}]:e})}const Pde=st.define(),hr=new qt;function ea(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function JLe(e,t,n){let r=An(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let s=o.node;if(s.to<=n||s.from>n)continue;if(a&&s.from<t)break;let l=s.type.prop(hr);if(l&&(s.to<r.length-50||r.length==e.doc.length||!eFe(s))){let c=l(s,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(a=c)}}return a}function eFe(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function Dw(e,t,n){for(let r of e.facet(Pde)){let i=r(e,t,n);if(i)return i}return JLe(e,t,n)}function _de(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const XQ=pn.define({map:_de}),Cy=pn.define({map:_de});function Tde(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(r=>r.from<=n&&r.to>=n)||t.push(e.lineBlockAt(n));return t}const Xd=Wa.define({create(){return Ft.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(XQ)&&!tFe(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(Ede),i=r?Ft.replace({widget:new sFe(r(t.state,n.value))}):mZ;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(Cy)&&(e=e.update({filter:(r,i)=>n.value.from!=r||n.value.to!=i,filterFrom:n.value.from,filterTo:n.value.to}));if(t.selection){let n=!1,{head:r}=t.selection.main;e.between(r,r,(i,a)=>{i<r&&a>r&&(n=!0)}),n&&(e=e.update({filterFrom:r,filterTo:r,filter:(i,a)=>a<=r||i>=r}))}return e},provide:e=>vt.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(r,i)=>{n.push(r,i)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");t.push(mZ.range(r,i))}return Ft.set(t,!0)}});function Vw(e,t,n){var r;let i=null;return(r=e.field(Xd,!1))===null||r===void 0||r.between(t,n,(a,o)=>{(!i||i.from>a)&&(i={from:a,to:o})}),i}function tFe(e,t,n){let r=!1;return e.between(t,t,(i,a)=>{i==t&&a==n&&(r=!0)}),r}function Xde(e,t){return e.field(Xd,!1)?t:t.concat(pn.appendConfig.of(qde()))}const nFe=e=>{for(let t of Tde(e)){let n=Dw(e.state,t.from,t.to);if(n)return e.dispatch({effects:Xde(e.state,[XQ.of(n),Rde(e,n)])}),!0}return!1},rFe=e=>{if(!e.state.field(Xd,!1))return!1;let t=[];for(let n of Tde(e)){let r=Vw(e.state,n.from,n.to);r&&t.push(Cy.of(r),Rde(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function Rde(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return vt.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const iFe=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=Dw(t,i.from,i.to);a&&n.push(XQ.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:Xde(e.state,n)}),!!n.length},aFe=e=>{let t=e.state.field(Xd,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(Cy.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},ntn=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:nFe},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:rFe},{key:"Ctrl-Alt-[",run:iFe},{key:"Ctrl-Alt-]",run:aFe}],oFe={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Ede=st.define({combine(e){return em(e,oFe)}});function qde(e){return[Xd,cFe]}function jde(e,t){let{state:n}=e,r=n.facet(Ede),i=o=>{let s=e.lineBlockAt(e.posAtDOM(o.target)),l=Vw(e.state,s.from,s.to);l&&e.dispatch({effects:Cy.of(l)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement("span");return a.textContent=r.placeholderText,a.setAttribute("aria-label",n.phrase("folded code")),a.title=n.phrase("unfold"),a.className="cm-foldPlaceholder",a.onclick=i,a}const mZ=Ft.replace({widget:new class extends Dc{toDOM(e){return jde(e,null)}}});class sFe extends Dc{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return jde(t,this.value)}}const lFe={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class o_ extends Xc{constructor(t,n){super(),this.config=t,this.open=n}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=t.state.phrase(this.open?"Fold line":"Unfold line"),n}}function rtn(e={}){let t={...lFe,...e},n=new o_(t,!0),r=new o_(t,!1),i=pi.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(nO)!=o.state.facet(nO)||o.startState.field(Xd,!1)!=o.state.field(Xd,!1)||An(o.startState)!=An(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let s=new Qd;for(let l of o.viewportLineBlocks){let c=Vw(o.state,l.from,l.to)?r:Dw(o.state,l.from,l.to)?n:null;c&&s.add(l.from,l.from,c)}return s.finish()}}),{domEventHandlers:a}=t;return[i,SLe({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(i))===null||s===void 0?void 0:s.markers)||hn.empty},initialSpacer(){return new o_(t,!1)},domEventHandlers:{...a,click:(o,s,l)=>{if(a.click&&a.click(o,s,l))return!0;let c=Vw(o.state,s.from,s.to);if(c)return o.dispatch({effects:Cy.of(c)}),!0;let u=Dw(o.state,s.from,s.to);return u?(o.dispatch({effects:XQ.of(u)}),!0):!1}}}),qde()]}const cFe=vt.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class RQ{constructor(t,n){this.specs=t;let r;function i(s){let l=Ju.newName();return(r||(r=Object.create(null)))["."+l]=s,l}const a=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,o=n.scope;this.scope=o instanceof co?s=>s.prop(Ru)==o.data:o?s=>s==o:void 0,this.style=wde(t.map(s=>({tag:s.tag,class:s.class||i(Object.assign({},s,{tag:null}))})),{all:a}).style,this.module=r?new Ju(r):null,this.themeType=n.themeType}static define(t,n){return new RQ(t,n||{})}}const a3=st.define(),Cde=st.define({combine(e){return e.length?[e[0]]:null}});function s_(e){let t=e.facet(a3);return t.length?t:e.facet(Cde)}function itn(e,t){let n=[OFe],r;return e instanceof RQ&&(e.module&&n.push(vt.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(Cde.of(e)):r?n.push(a3.computeN([vt.darkTheme],i=>i.facet(vt.darkTheme)==(r=="dark")?[e]:[])):n.push(a3.of(e)),n}class uFe{constructor(t){this.markCache=Object.create(null),this.tree=An(t.state),this.decorations=this.buildDeco(t,s_(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=An(t.state),r=s_(t.state),i=r!=s_(t.startState),{viewport:a}=t.view,o=t.changes.mapPos(this.decoratedTo,1);n.length<a.to&&!i&&n.type==this.tree.type&&o>=a.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(n!=this.tree||t.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=a.to)}buildDeco(t,n){if(!n||!this.tree.length)return Ft.none;let r=new Qd;for(let{from:i,to:a}of t.visibleRanges)ULe(this.tree,n,(o,s,l)=>{r.add(o,s,this.markCache[l]||(this.markCache[l]=Ft.mark({class:l})))},i,a);return r.finish()}}const OFe=uO.high(pi.fromClass(uFe,{decorations:e=>e.decorations})),atn=RQ.define([{tag:k.meta,color:"#404740"},{tag:k.link,textDecoration:"underline"},{tag:k.heading,textDecoration:"underline",fontWeight:"bold"},{tag:k.emphasis,fontStyle:"italic"},{tag:k.strong,fontWeight:"bold"},{tag:k.strikethrough,textDecoration:"line-through"},{tag:k.keyword,color:"#708"},{tag:[k.atom,k.bool,k.url,k.contentSeparator,k.labelName],color:"#219"},{tag:[k.literal,k.inserted],color:"#164"},{tag:[k.string,k.deleted],color:"#a11"},{tag:[k.regexp,k.escape,k.special(k.string)],color:"#e40"},{tag:k.definition(k.variableName),color:"#00f"},{tag:k.local(k.variableName),color:"#30a"},{tag:[k.typeName,k.namespace],color:"#085"},{tag:k.className,color:"#167"},{tag:[k.special(k.variableName),k.macroName],color:"#256"},{tag:k.definition(k.propertyName),color:"#00c"},{tag:k.comment,color:"#940"},{tag:k.invalid,color:"#f00"}]),dFe=vt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),zde=1e4,Ade="()[]{}",Ude=st.define({combine(e){return em(e,{afterCursor:!0,brackets:Ade,maxScanDistance:zde,renderMatch:pFe})}}),fFe=Ft.mark({class:"cm-matchingBracket"}),hFe=Ft.mark({class:"cm-nonmatchingBracket"});function pFe(e){let t=[],n=e.matched?fFe:hFe;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const mFe=Wa.define({create(){return Ft.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(Ude);for(let i of t.state.selection.ranges){if(!i.empty)continue;let a=ab(t.state,i.head,-1,r)||i.head>0&&ab(t.state,i.head-1,1,r)||r.afterCursor&&(ab(t.state,i.head,1,r)||i.head<t.state.doc.length&&ab(t.state,i.head+1,-1,r));a&&(n=n.concat(r.renderMatch(a,t.state)))}return Ft.set(n,!0)},provide:e=>vt.decorations.from(e)}),gFe=[mFe,dFe];function otn(e={}){return[Ude.of(e),gFe]}const Wz=new qt;function o3(e,t,n){let r=e.prop(t<0?qt.openedBy:qt.closedBy);if(r)return r;if(e.name.length==1){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function s3(e){let t=e.type.prop(Wz);return t?t(e.node):e}function ab(e,t,n,r={}){let i=r.maxScanDistance||zde,a=r.brackets||Ade,o=An(e),s=o.resolveInner(t,n);for(let l=s;l;l=l.parent){let c=o3(l.type,n,a);if(c&&l.from<l.to){let u=s3(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return $Fe(e,t,n,l,u,c,a)}}return yFe(e,t,n,o,s.type,i,a)}function $Fe(e,t,n,r,i,a,o){let s=r.parent,l={from:i.from,to:i.to},c=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(c==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let O=s3(u);return{start:l,end:O?{from:O.from,to:O.to}:void 0,matched:!0}}else if(o3(u.type,n,o))c++;else if(o3(u.type,-n,o)){if(c==0){let O=s3(u);return{start:l,end:O&&O.from<O.to?{from:O.from,to:O.to}:void 0,matched:!1}}c--}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function yFe(e,t,n,r,i,a,o){let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=o.indexOf(s);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),O=0;for(let d=0;!u.next().done&&d<=a;){let h=u.value;n<0&&(d+=h.length);let p=t+d*n;for(let m=n>0?0:h.length-1,g=n>0?h.length:-1;m!=g;m+=n){let y=o.indexOf(h[m]);if(!(y<0||r.resolveInner(p+m,1).type!=i))if(y%2==0==n>0)O++;else{if(O==1)return{start:c,end:{from:p+m,to:p+m+1},matched:y>>1==l>>1};O--}}n>0&&(d+=h.length)}return u.done?{start:c,matched:!1}:null}function gZ(e,t,n,r=0,i=0){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let o=r;o<t;o++)e.charCodeAt(o)==9?a+=n-a%n:a++;return a}class Wde{constructor(t,n,r,i){this.string=t,this.tabSize=n,this.indentUnit=r,this.overrideIndent=i,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let n=this.string.charAt(this.pos),r;if(typeof t=="string"?r=n==t:r=n&&(t instanceof RegExp?t.test(n):t(n)),r)return++this.pos,n}eatWhile(t){let n=this.pos;for(;this.eat(t););return this.pos>n}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let n=this.string.indexOf(t,this.pos);if(n>-1)return this.pos=n,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=gZ(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:gZ(this.string,null,this.tabSize)}match(t,n,r){if(typeof t=="string"){let i=o=>r?o.toLowerCase():o,a=this.string.substr(this.pos,t.length);return i(a)==i(t)?(n!==!1&&(this.pos+=t.length),!0):null}else{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&n!==!1&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function vFe(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||bFe,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||Nz,mergeTokens:e.mergeTokens!==!1}}function bFe(e){if(typeof e!="object")return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}const $Z=new WeakMap;class Te extends co{constructor(t){let n=_Q(t.languageData),r=vFe(t),i,a=new class extends wQ{createParse(o,s,l){return new xFe(i,o,s,l)}};super(n,a,[],t.name),this.topNode=kFe(n,this),i=this,this.streamParser=r,this.stateAfter=new qt({perNode:!0}),this.tokenTable=t.tokenTable?new Zde(r.tokenTable):QFe}static define(t){return new Te(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=$Z.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=Yz(this,t.node.tree,t.node.from,t.node.from,n??t.pos),a,o;if(i?(o=i.state,a=i.pos+1):(o=this.streamParser.startState(t.unit),a=t.node.from),t.pos-a>1e4)return null;for(;a<t.pos;){let l=t.state.doc.lineAt(a),c=Math.min(t.pos,l.to);if(l.length){let u=r?r(l.from):-1,O=new Wde(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;O.pos<c-l.from;)Nde(this.streamParser.token,O,o)}else this.streamParser.blankLine(o,t.unit);if(c==t.pos)break;a=l.to+1}let s=t.lineAt(t.pos);return r&&n==null&&$Z.set(t.state,s.from),this.streamParser.indent(o,/^\s*(.*)/.exec(s.text)[1],t)}get allowsNesting(){return!1}}function Yz(e,t,n,r,i){let a=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(a)return{state:e.streamParser.copyState(a),pos:n+t.length};for(let o=t.children.length-1;o>=0;o--){let s=t.children[o],l=n+t.positions[o],c=s instanceof en&&l<i&&Yz(e,s,l,r,i);if(c)return c}return null}function Yde(e,t,n,r,i){if(i&&n<=0&&r>=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let a=t.children.length-1;a>=0;a--){let o=t.positions[a],s=t.children[a],l;if(o<r&&s instanceof en){if(!(l=Yde(e,s,n-o,r-o,i)))break;return i?new en(t.type,t.children.slice(0,a).concat(l),t.positions.slice(0,a+1),o+l.length):l}}return null}function wFe(e,t,n,r,i){for(let a of t){let o=a.from+(a.openStart?25:0),s=a.to-(a.openEnd?25:0),l=o<=n&&s>n&&Yz(e,a.tree,0-a.offset,n,s),c;if(l&&l.pos<=r&&(c=Yde(e,a.tree,n+a.offset,l.pos+a.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?Iw(i):4),tree:en.empty}}let xFe=class{constructor(t,n,r,i){this.lang=t,this.input=n,this.fragments=r,this.ranges=i,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=i[i.length-1].to;let a=Td.get(),o=i[0].from,{state:s,tree:l}=wFe(t,r,o,this.to,a?.state);this.state=s,this.parsedPos=this.chunkStart=o+l.length;for(let c=0;c<l.children.length;c++)this.chunks.push(l.children[c]),this.chunkPos.push(l.positions[c]);a&&this.parsedPos<a.viewport.from-1e5&&i.some(c=>c.from<=a.viewport.from&&c.to>=a.viewport.from)&&(this.state=this.lang.streamParser.startState(Iw(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let t=Td.get(),n=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(n,this.chunkStart+2048);for(t&&(r=Math.min(r,t.viewport.to));this.parsedPos<r;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=n?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,n),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let n=this.input.chunk(t);if(this.input.lineChunks)n==`
785
785
  `&&(n="");else{let r=n.indexOf(`
786
- `);r>-1&&(n=n.slice(0,r))}return t+n.length<=this.to?n:n.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,n=this.lineAfter(t),r=t+n.length;for(let i=this.rangeIndex;;){let a=this.ranges[i].to;if(a>=r||(n=n.slice(0,a-(r-n.length)),i++,i==this.ranges.length))break;let o=this.ranges[i].from,s=this.lineAfter(o);n+=s,r=o+s.length}return{line:n,end:r}}skipGapsTo(t,n,r){for(;;){let i=this.ranges[this.rangeIndex].to,a=t+n;if(r>0?i>a:i>=a)break;let o=this.ranges[++this.rangeIndex].from;n+=o-i}return n}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,n,r,i){let a=4;if(this.ranges.length>1){i=this.skipGapsTo(n,i,1),n+=i;let s=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,a+=this.chunk.length-s}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&a==4&&o>=0&&this.chunk[o]==t&&this.chunk[o+2]==n?this.chunk[o+2]=r:this.chunk.push(t,n,r,a),i}parseLine(t){let{line:n,end:r}=this.nextLine(),i=0,{streamParser:a}=this.lang,o=new Wde(n,t?t.state.tabSize:4,t?Iw(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=Nde(a.token,o,this.state);if(s&&(i=this.emitToken(this.lang.tokenTable.resolve(s),this.parsedPos+o.start,this.parsedPos+o.pos,i)),o.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=en.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:SFe,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new en(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new en(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Nde(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let i=e(t,n);if(t.pos>t.start)return i}throw new Error("Stream parser failed to advance stream.")}const Nz=Object.create(null),a$=[ti.none],SFe=new Jp(a$),yZ=[],vZ=Object.create(null),Gde=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Gde[e]=Ide(Nz,t);class Zde{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Gde)}resolve(t){return t?this.table[t]||(this.table[t]=Ide(this.extra,t)):0}}const QFe=new Zde(Nz);function l_(e,t){yZ.indexOf(e)>-1||(yZ.push(e),console.warn(t))}function Ide(e,t){let n=[];for(let s of t.split(" ")){let l=[];for(let c of s.split(".")){let u=e[c]||k[c];u?typeof u=="function"?l.length?l=l.map(u):l_(c,`Modifier ${c} used at start of tag`):l.length?l_(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:l_(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(s=>s.id),a=vZ[i];if(a)return a.id;let o=vZ[i]=ti.define({id:a$.length,name:r,props:[wn({[r]:n})]});return a$.push(o),o.id}function kFe(e,t){let n=ti.define({id:a$.length,name:"Document",props:[Ru.add(()=>e),Pr.add(()=>r=>t.getIndent(r))],top:!0});return a$.push(n),n}Or.RTL,Or.LTR;function Qe(e){return new un(Te.define(e))}function ou(e){return ge(()=>Promise.resolve().then(()=>Kit),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const PFe=[pe.of({name:"C",extensions:["c","h","ino"],load(){return ge(()=>Promise.resolve().then(()=>OD),void 0,import.meta.url).then(e=>e.cpp())}}),pe.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return ge(()=>Promise.resolve().then(()=>OD),void 0,import.meta.url).then(e=>e.cpp())}}),pe.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return ou("Cassandra")}}),pe.of({name:"CSS",extensions:["css"],load(){return ge(()=>Promise.resolve().then(()=>OKe),void 0,import.meta.url).then(e=>e.css())}}),pe.of({name:"Go",extensions:["go"],load(){return ge(()=>import("./index-AGCqaeOI.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>e.go())}}),pe.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return ge(()=>Promise.resolve().then(()=>nJe),void 0,import.meta.url).then(e=>e.html())}}),pe.of({name:"Java",extensions:["java"],load(){return ge(()=>Promise.resolve().then(()=>nat),void 0,import.meta.url).then(e=>e.java())}}),pe.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return ge(()=>Promise.resolve().then(()=>cb),void 0,import.meta.url).then(e=>e.javascript())}}),pe.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return ge(()=>Promise.resolve().then(()=>set),void 0,import.meta.url).then(e=>e.json())}}),pe.of({name:"JSX",extensions:["jsx"],load(){return ge(()=>Promise.resolve().then(()=>cb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),pe.of({name:"LESS",extensions:["less"],load(){return ge(()=>Promise.resolve().then(()=>xJe),void 0,import.meta.url).then(e=>e.less())}}),pe.of({name:"Liquid",extensions:["liquid"],load(){return ge(()=>Promise.resolve().then(()=>Nst),void 0,import.meta.url).then(e=>e.liquid())}}),pe.of({name:"MariaDB SQL",load(){return ou("MariaSQL")}}),pe.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return ge(()=>Promise.resolve().then(()=>dJe),void 0,import.meta.url).then(e=>e.markdown())}}),pe.of({name:"MS SQL",load(){return ou("MSSQL")}}),pe.of({name:"MySQL",load(){return ou("MySQL")}}),pe.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return ge(()=>Promise.resolve().then(()=>$st),void 0,import.meta.url).then(e=>e.php())}}),pe.of({name:"PLSQL",extensions:["pls"],load(){return ou("PLSQL")}}),pe.of({name:"PostgreSQL",load(){return ou("PostgreSQL")}}),pe.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return ge(()=>Promise.resolve().then(()=>Nrt),void 0,import.meta.url).then(e=>e.python())}}),pe.of({name:"Rust",extensions:["rs"],load(){return ge(()=>Promise.resolve().then(()=>wat),void 0,import.meta.url).then(e=>e.rust())}}),pe.of({name:"Sass",extensions:["sass"],load(){return ge(()=>Promise.resolve().then(()=>kI),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),pe.of({name:"SCSS",extensions:["scss"],load(){return ge(()=>Promise.resolve().then(()=>kI),void 0,import.meta.url).then(e=>e.sass())}}),pe.of({name:"SQL",extensions:["sql"],load(){return ou("StandardSQL")}}),pe.of({name:"SQLite",load(){return ou("SQLite")}}),pe.of({name:"TSX",extensions:["tsx"],load(){return ge(()=>Promise.resolve().then(()=>cb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),pe.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return ge(()=>Promise.resolve().then(()=>cb),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),pe.of({name:"WebAssembly",extensions:["wat","wast"],load(){return ge(()=>Promise.resolve().then(()=>Ist),void 0,import.meta.url).then(e=>e.wast())}}),pe.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return ge(()=>Promise.resolve().then(()=>cit),void 0,import.meta.url).then(e=>e.xml())}}),pe.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return ge(()=>import("./index-fw54FEnm.js"),__vite__mapDeps([5,1,2,3,4]),import.meta.url).then(e=>e.yaml())}}),pe.of({name:"APL",extensions:["dyalog","apl"],load(){return ge(()=>Promise.resolve().then(()=>yut),void 0,import.meta.url).then(e=>Qe(e.apl))}}),pe.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return ge(()=>Promise.resolve().then(()=>vut),void 0,import.meta.url).then(e=>Qe(e.asciiArmor))}}),pe.of({name:"ASN.1",extensions:["asn","asn1"],load(){return ge(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>Qe(e.asn1({})))}}),pe.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return ge(()=>Promise.resolve().then(()=>Qut),void 0,import.meta.url).then(e=>Qe(e.asterisk))}}),pe.of({name:"Brainfuck",extensions:["b","bf"],load(){return ge(()=>Promise.resolve().then(()=>Put),void 0,import.meta.url).then(e=>Qe(e.brainfuck))}}),pe.of({name:"Cobol",extensions:["cob","cpy"],load(){return ge(()=>Promise.resolve().then(()=>tOt),void 0,import.meta.url).then(e=>Qe(e.cobol))}}),pe.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return ge(()=>Promise.resolve().then(()=>AO),void 0,import.meta.url).then(e=>Qe(e.csharp))}}),pe.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return ge(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Qe(e.clojure))}}),pe.of({name:"ClojureScript",extensions:["cljs"],load(){return ge(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Qe(e.clojure))}}),pe.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return ge(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>Qe(e.gss))}}),pe.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return ge(()=>Promise.resolve().then(()=>Vut),void 0,import.meta.url).then(e=>Qe(e.cmake))}}),pe.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return ge(()=>Promise.resolve().then(()=>hOt),void 0,import.meta.url).then(e=>Qe(e.coffeeScript))}}),pe.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return ge(()=>Promise.resolve().then(()=>vOt),void 0,import.meta.url).then(e=>Qe(e.commonLisp))}}),pe.of({name:"Cypher",extensions:["cyp","cypher"],load(){return ge(()=>Promise.resolve().then(()=>UOt),void 0,import.meta.url).then(e=>Qe(e.cypher))}}),pe.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return ge(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>Qe(e.cython))}}),pe.of({name:"Crystal",extensions:["cr"],load(){return ge(()=>Promise.resolve().then(()=>EOt),void 0,import.meta.url).then(e=>Qe(e.crystal))}}),pe.of({name:"D",extensions:["d"],load(){return ge(()=>Promise.resolve().then(()=>DOt),void 0,import.meta.url).then(e=>Qe(e.d))}}),pe.of({name:"Dart",extensions:["dart"],load(){return ge(()=>Promise.resolve().then(()=>AO),void 0,import.meta.url).then(e=>Qe(e.dart))}}),pe.of({name:"diff",extensions:["diff","patch"],load(){return ge(()=>Promise.resolve().then(()=>VOt),void 0,import.meta.url).then(e=>Qe(e.diff))}}),pe.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return ge(()=>Promise.resolve().then(()=>adt),void 0,import.meta.url).then(e=>Qe(e.dockerFile))}}),pe.of({name:"DTD",extensions:["dtd"],load(){return ge(()=>Promise.resolve().then(()=>ldt),void 0,import.meta.url).then(e=>Qe(e.dtd))}}),pe.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return ge(()=>Promise.resolve().then(()=>fdt),void 0,import.meta.url).then(e=>Qe(e.dylan))}}),pe.of({name:"EBNF",load(){return ge(()=>Promise.resolve().then(()=>hdt),void 0,import.meta.url).then(e=>Qe(e.ebnf))}}),pe.of({name:"ECL",extensions:["ecl"],load(){return ge(()=>Promise.resolve().then(()=>wdt),void 0,import.meta.url).then(e=>Qe(e.ecl))}}),pe.of({name:"edn",extensions:["edn"],load(){return ge(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Qe(e.clojure))}}),pe.of({name:"Eiffel",extensions:["e"],load(){return ge(()=>Promise.resolve().then(()=>_dt),void 0,import.meta.url).then(e=>Qe(e.eiffel))}}),pe.of({name:"Elm",extensions:["elm"],load(){return ge(()=>Promise.resolve().then(()=>Wdt),void 0,import.meta.url).then(e=>Qe(e.elm))}}),pe.of({name:"Erlang",extensions:["erl"],load(){return ge(()=>Promise.resolve().then(()=>cft),void 0,import.meta.url).then(e=>Qe(e.erlang))}}),pe.of({name:"Esper",load(){return ge(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>Qe(e.esper))}}),pe.of({name:"Factor",extensions:["factor"],load(){return ge(()=>Promise.resolve().then(()=>uft),void 0,import.meta.url).then(e=>Qe(e.factor))}}),pe.of({name:"FCL",load(){return ge(()=>Promise.resolve().then(()=>pft),void 0,import.meta.url).then(e=>Qe(e.fcl))}}),pe.of({name:"Forth",extensions:["forth","fth","4th"],load(){return ge(()=>Promise.resolve().then(()=>$ft),void 0,import.meta.url).then(e=>Qe(e.forth))}}),pe.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return ge(()=>Promise.resolve().then(()=>Qft),void 0,import.meta.url).then(e=>Qe(e.fortran))}}),pe.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return ge(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Qe(e.fSharp))}}),pe.of({name:"Gas",extensions:["s"],load(){return ge(()=>Promise.resolve().then(()=>Pft),void 0,import.meta.url).then(e=>Qe(e.gas))}}),pe.of({name:"Gherkin",extensions:["feature"],load(){return ge(()=>Promise.resolve().then(()=>_ft),void 0,import.meta.url).then(e=>Qe(e.gherkin))}}),pe.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return ge(()=>Promise.resolve().then(()=>Wft),void 0,import.meta.url).then(e=>Qe(e.groovy))}}),pe.of({name:"Haskell",extensions:["hs"],load(){return ge(()=>Promise.resolve().then(()=>Vft),void 0,import.meta.url).then(e=>Qe(e.haskell))}}),pe.of({name:"Haxe",extensions:["hx"],load(){return ge(()=>Promise.resolve().then(()=>jV),void 0,import.meta.url).then(e=>Qe(e.haxe))}}),pe.of({name:"HXML",extensions:["hxml"],load(){return ge(()=>Promise.resolve().then(()=>jV),void 0,import.meta.url).then(e=>Qe(e.hxml))}}),pe.of({name:"HTTP",load(){return ge(()=>Promise.resolve().then(()=>pht),void 0,import.meta.url).then(e=>Qe(e.http))}}),pe.of({name:"IDL",extensions:["pro"],load(){return ge(()=>Promise.resolve().then(()=>wht),void 0,import.meta.url).then(e=>Qe(e.idl))}}),pe.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return ge(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>Qe(e.jsonld))}}),pe.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return ge(()=>Promise.resolve().then(()=>kht),void 0,import.meta.url).then(e=>Qe(e.jinja2))}}),pe.of({name:"Julia",extensions:["jl"],load(){return ge(()=>Promise.resolve().then(()=>Hht),void 0,import.meta.url).then(e=>Qe(e.julia))}}),pe.of({name:"Kotlin",extensions:["kt","kts"],load(){return ge(()=>Promise.resolve().then(()=>AO),void 0,import.meta.url).then(e=>Qe(e.kotlin))}}),pe.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return ge(()=>Promise.resolve().then(()=>tpt),void 0,import.meta.url).then(e=>Qe(e.liveScript))}}),pe.of({name:"Lua",extensions:["lua"],load(){return ge(()=>Promise.resolve().then(()=>cpt),void 0,import.meta.url).then(e=>Qe(e.lua))}}),pe.of({name:"mIRC",extensions:["mrc"],load(){return ge(()=>Promise.resolve().then(()=>Ept),void 0,import.meta.url).then(e=>Qe(e.mirc))}}),pe.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return ge(()=>Promise.resolve().then(()=>gpt),void 0,import.meta.url).then(e=>Qe(e.mathematica))}}),pe.of({name:"Modelica",extensions:["mo"],load(){return ge(()=>Promise.resolve().then(()=>Gpt),void 0,import.meta.url).then(e=>Qe(e.modelica))}}),pe.of({name:"MUMPS",extensions:["mps"],load(){return ge(()=>Promise.resolve().then(()=>imt),void 0,import.meta.url).then(e=>Qe(e.mumps))}}),pe.of({name:"Mbox",extensions:["mbox"],load(){return ge(()=>Promise.resolve().then(()=>Tpt),void 0,import.meta.url).then(e=>Qe(e.mbox))}}),pe.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return ge(()=>Promise.resolve().then(()=>cmt),void 0,import.meta.url).then(e=>Qe(e.nginx))}}),pe.of({name:"NSIS",extensions:["nsh","nsi"],load(){return ge(()=>Promise.resolve().then(()=>umt),void 0,import.meta.url).then(e=>Qe(e.nsis))}}),pe.of({name:"NTriples",extensions:["nt","nq"],load(){return ge(()=>Promise.resolve().then(()=>Omt),void 0,import.meta.url).then(e=>Qe(e.ntriples))}}),pe.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return ge(()=>Promise.resolve().then(()=>AO),void 0,import.meta.url).then(e=>Qe(e.objectiveC))}}),pe.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return ge(()=>Promise.resolve().then(()=>AO),void 0,import.meta.url).then(e=>Qe(e.objectiveCpp))}}),pe.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return ge(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Qe(e.oCaml))}}),pe.of({name:"Octave",extensions:["m"],load(){return ge(()=>Promise.resolve().then(()=>wmt),void 0,import.meta.url).then(e=>Qe(e.octave))}}),pe.of({name:"Oz",extensions:["oz"],load(){return ge(()=>Promise.resolve().then(()=>jmt),void 0,import.meta.url).then(e=>Qe(e.oz))}}),pe.of({name:"Pascal",extensions:["p","pas"],load(){return ge(()=>Promise.resolve().then(()=>Ymt),void 0,import.meta.url).then(e=>Qe(e.pascal))}}),pe.of({name:"Perl",extensions:["pl","pm"],load(){return ge(()=>Promise.resolve().then(()=>Nmt),void 0,import.meta.url).then(e=>Qe(e.perl))}}),pe.of({name:"Pig",extensions:["pig"],load(){return ge(()=>Promise.resolve().then(()=>Imt),void 0,import.meta.url).then(e=>Qe(e.pig))}}),pe.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return ge(()=>Promise.resolve().then(()=>ogt),void 0,import.meta.url).then(e=>Qe(e.powerShell))}}),pe.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return ge(()=>Promise.resolve().then(()=>sgt),void 0,import.meta.url).then(e=>Qe(e.properties))}}),pe.of({name:"ProtoBuf",extensions:["proto"],load(){return ge(()=>Promise.resolve().then(()=>dgt),void 0,import.meta.url).then(e=>Qe(e.protobuf))}}),pe.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return ge(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>Qe(e.pug))}}),pe.of({name:"Puppet",extensions:["pp"],load(){return ge(()=>Promise.resolve().then(()=>pgt),void 0,import.meta.url).then(e=>Qe(e.puppet))}}),pe.of({name:"Q",extensions:["q"],load(){return ge(()=>Promise.resolve().then(()=>xgt),void 0,import.meta.url).then(e=>Qe(e.q))}}),pe.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return ge(()=>Promise.resolve().then(()=>Xgt),void 0,import.meta.url).then(e=>Qe(e.r))}}),pe.of({name:"RPM Changes",load(){return ge(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Qe(e.rpmChanges))}}),pe.of({name:"RPM Spec",extensions:["spec"],load(){return ge(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Qe(e.rpmSpec))}}),pe.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return ge(()=>Promise.resolve().then(()=>Wgt),void 0,import.meta.url).then(e=>Qe(e.ruby))}}),pe.of({name:"SAS",extensions:["sas"],load(){return ge(()=>Promise.resolve().then(()=>Zgt),void 0,import.meta.url).then(e=>Qe(e.sas))}}),pe.of({name:"Scala",extensions:["scala"],load(){return ge(()=>Promise.resolve().then(()=>AO),void 0,import.meta.url).then(e=>Qe(e.scala))}}),pe.of({name:"Scheme",extensions:["scm","ss"],load(){return ge(()=>Promise.resolve().then(()=>n0t),void 0,import.meta.url).then(e=>Qe(e.scheme))}}),pe.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return ge(()=>Promise.resolve().then(()=>o0t),void 0,import.meta.url).then(e=>Qe(e.shell))}}),pe.of({name:"Sieve",extensions:["siv","sieve"],load(){return ge(()=>Promise.resolve().then(()=>O0t),void 0,import.meta.url).then(e=>Qe(e.sieve))}}),pe.of({name:"Smalltalk",extensions:["st"],load(){return ge(()=>Promise.resolve().then(()=>h0t),void 0,import.meta.url).then(e=>Qe(e.smalltalk))}}),pe.of({name:"Solr",load(){return ge(()=>Promise.resolve().then(()=>b0t),void 0,import.meta.url).then(e=>Qe(e.solr))}}),pe.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return ge(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Qe(e.sml))}}),pe.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return ge(()=>Promise.resolve().then(()=>_0t),void 0,import.meta.url).then(e=>Qe(e.sparql))}}),pe.of({name:"Spreadsheet",alias:["excel","formula"],load(){return ge(()=>Promise.resolve().then(()=>T0t),void 0,import.meta.url).then(e=>Qe(e.spreadsheet))}}),pe.of({name:"Squirrel",extensions:["nut"],load(){return ge(()=>Promise.resolve().then(()=>AO),void 0,import.meta.url).then(e=>Qe(e.squirrel))}}),pe.of({name:"Stylus",extensions:["styl"],load(){return ge(()=>Promise.resolve().then(()=>H0t),void 0,import.meta.url).then(e=>Qe(e.stylus))}}),pe.of({name:"Swift",extensions:["swift"],load(){return ge(()=>Promise.resolve().then(()=>g$t),void 0,import.meta.url).then(e=>Qe(e.swift))}}),pe.of({name:"sTeX",load(){return ge(()=>Promise.resolve().then(()=>QM),void 0,import.meta.url).then(e=>Qe(e.stex))}}),pe.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return ge(()=>Promise.resolve().then(()=>QM),void 0,import.meta.url).then(e=>Qe(e.stex))}}),pe.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return ge(()=>Promise.resolve().then(()=>DM),void 0,import.meta.url).then(e=>Qe(e.verilog))}}),pe.of({name:"Tcl",extensions:["tcl"],load(){return ge(()=>Promise.resolve().then(()=>b$t),void 0,import.meta.url).then(e=>Qe(e.tcl))}}),pe.of({name:"Textile",extensions:["textile"],load(){return ge(()=>Promise.resolve().then(()=>Q$t),void 0,import.meta.url).then(e=>Qe(e.textile))}}),pe.of({name:"TiddlyWiki",load(){return ge(()=>Promise.resolve().then(()=>V$t),void 0,import.meta.url).then(e=>Qe(e.tiddlyWiki))}}),pe.of({name:"Tiki wiki",load(){return ge(()=>Promise.resolve().then(()=>J$t),void 0,import.meta.url).then(e=>Qe(e.tiki))}}),pe.of({name:"TOML",extensions:["toml"],load(){return ge(()=>Promise.resolve().then(()=>eyt),void 0,import.meta.url).then(e=>Qe(e.toml))}}),pe.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return ge(()=>Promise.resolve().then(()=>ryt),void 0,import.meta.url).then(e=>Qe(e.troff))}}),pe.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return ge(()=>Promise.resolve().then(()=>byt),void 0,import.meta.url).then(e=>Qe(e.ttcn))}}),pe.of({name:"TTCN_CFG",extensions:["cfg"],load(){return ge(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>Qe(e.ttcnCfg))}}),pe.of({name:"Turtle",extensions:["ttl"],load(){return ge(()=>Promise.resolve().then(()=>Syt),void 0,import.meta.url).then(e=>Qe(e.turtle))}}),pe.of({name:"Web IDL",extensions:["webidl"],load(){return ge(()=>Promise.resolve().then(()=>gvt),void 0,import.meta.url).then(e=>Qe(e.webIDL))}}),pe.of({name:"VB.NET",extensions:["vb"],load(){return ge(()=>Promise.resolve().then(()=>Wyt),void 0,import.meta.url).then(e=>Qe(e.vb))}}),pe.of({name:"VBScript",extensions:["vbs"],load(){return ge(()=>Promise.resolve().then(()=>Nyt),void 0,import.meta.url).then(e=>Qe(e.vbScript))}}),pe.of({name:"Velocity",extensions:["vtl"],load(){return ge(()=>Promise.resolve().then(()=>Iyt),void 0,import.meta.url).then(e=>Qe(e.velocity))}}),pe.of({name:"Verilog",extensions:["v"],load(){return ge(()=>Promise.resolve().then(()=>DM),void 0,import.meta.url).then(e=>Qe(e.verilog))}}),pe.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return ge(()=>Promise.resolve().then(()=>Jyt),void 0,import.meta.url).then(e=>Qe(e.vhdl))}}),pe.of({name:"XQuery",extensions:["xy","xquery"],load(){return ge(()=>Promise.resolve().then(()=>Pvt),void 0,import.meta.url).then(e=>Qe(e.xQuery))}}),pe.of({name:"Yacas",extensions:["ys"],load(){return ge(()=>Promise.resolve().then(()=>Avt),void 0,import.meta.url).then(e=>Qe(e.yacas))}}),pe.of({name:"Z80",extensions:["z80"],load(){return ge(()=>Promise.resolve().then(()=>Gvt),void 0,import.meta.url).then(e=>Qe(e.z80))}}),pe.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return ge(()=>Promise.resolve().then(()=>hT),void 0,import.meta.url).then(e=>Qe(e.mscgen))}}),pe.of({name:"Xù",extensions:["xu"],load(){return ge(()=>Promise.resolve().then(()=>hT),void 0,import.meta.url).then(e=>Qe(e.xu))}}),pe.of({name:"MsGenny",extensions:["msgenny"],load(){return ge(()=>Promise.resolve().then(()=>hT),void 0,import.meta.url).then(e=>Qe(e.msgenny))}}),pe.of({name:"Vue",extensions:["vue"],load(){return ge(()=>Promise.resolve().then(()=>Kst),void 0,import.meta.url).then(e=>e.vue())}}),pe.of({name:"Angular Template",load(){return ge(()=>Promise.resolve().then(()=>glt),void 0,import.meta.url).then(e=>e.angular())}})];class Gz{constructor(t,n,r,i){this.state=t,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let n=An(this.state).resolveInner(this.pos,-1);for(;n&&t.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(t){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),a=i.search(Dde(t,!1));return a<0?null:{from:r+a,to:this.pos,text:i.slice(a)}}get aborted(){return this.abortListeners==null}addEventListener(t,n,r){t=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function bZ(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function _Fe(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let a=1;a<i.length;a++)n[i[a]]=!0}let r=bZ(t)+bZ(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function zy(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:_Fe(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function EQ(e,t){return n=>{for(let r=An(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(e.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return t(n)}}class wZ{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function hd(e){return e.selection.main.from}function Dde(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",a=r[r.length-1]!="$";return!i&&!a?e:new RegExp(`${i?"^":""}(?:${r})${a?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const Zz=Hd.define();function TFe(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return Object.assign(Object.assign({},e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let l=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:l},range:Ue.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const xZ=new WeakMap;function XFe(e){if(!Array.isArray(e))return e;let t=xZ.get(e);return t||xZ.set(e,t=zy(e)),t}const Mw=pn.define(),o$=pn.define();class RFe{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<t.length;){let r=io(t,n),i=ic(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(io(o==a?a.toLowerCase():o,0)),n+=i}this.astral=t.length!=this.chars.length}ret(t,n){return this.score=t,this.matched=n,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:a,byWord:o}=this;if(n.length==1){let v=io(t,0),x=ic(v),S=x==t.length?0:-100;if(v!=n[0])if(v==r[0])S+=-200;else return null;return this.ret(S,[0,x])}let s=t.indexOf(this.pattern);if(s==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(s<0){for(let v=0,x=Math.min(t.length,200);v<x&&c<l;){let S=io(t,v);(S==n[c]||S==r[c])&&(i[c++]=v),v+=ic(S)}if(c<l)return null}let u=0,O=0,d=!1,h=0,p=-1,m=-1,g=/[a-z]/.test(t),y=!0;for(let v=0,x=Math.min(t.length,200),S=0;v<x&&O<l;){let b=io(t,v);s<0&&(u<l&&b==n[u]&&(a[u++]=v),h<l&&(b==n[h]||b==r[h]?(h==0&&(p=v),m=v+1,h++):h=0));let w,Q=b<255?b>=48&&b<=57||b>=97&&b<=122?2:b>=65&&b<=90?1:0:(w=nOe(b))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!v||Q==1&&g||S==0&&Q!=0)&&(n[O]==b||r[O]==b&&(d=!0)?o[O++]=v:o.length&&(y=!1)),S=Q,v+=ic(b)}return O==l&&o[0]==0&&y?this.result(-100+(d?-200:0),o,t):h==l&&p==0?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):h==l?this.ret(-900-t.length,[p,m]):O==l?this.result(-100+(d?-200:0)+-700+(y?0:-1100),o,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],a=0;for(let o of n){let s=o+(this.astral?ic(io(r,o)):1);a&&i[a-1]==o?i[a-1]=s:(i[a++]=o,i[a++]=s)}return this.ret(t-r.length,i)}}class EFe{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let n=t.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(t.length==this.pattern.length?0:-100),this)}}const Si=st.define({combine(e){return em(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:qFe,filterStrict:!1,compareCompletions:(t,n)=>t.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>r=>SZ(t(r),n(r)),optionClass:(t,n)=>r=>SZ(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function SZ(e,t){return e?t?e+" "+t:e:t}function qFe(e,t,n,r,i,a){let o=e.textDirection==Or.RTL,s=o,l=!1,c="top",u,O,d=t.left-i.left,h=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(s&&d<Math.min(p,h)?s=!1:!s&&h<Math.min(p,d)&&(s=!0),p<=(s?d:h))u=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,O=Math.min(400,s?d:h);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let v=i.bottom-t.bottom;v>=m||v>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,y=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${O/y}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function jFe(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),t.push({render(n,r,i,a){let o=document.createElement("span");o.className="cm-completionLabel";let s=n.displayLabel||n.label,l=0;for(let c=0;c<a.length;){let u=a[c++],O=a[c++];u>l&&o.appendChild(document.createTextNode(s.slice(l,u)));let d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(s.slice(u,O))),d.className="cm-completionMatchedText",l=O}return l<s.length&&o.appendChild(document.createTextNode(s.slice(l))),o},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),t.sort((n,r)=>n.position-r.position).map(n=>n.render)}function c_(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let i=Math.floor(t/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class CFe{constructor(t,n,r){this.view=t,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=t.state.field(n),{options:a,selected:o}=i.open,s=t.state.facet(Si);this.optionContent=jFe(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=c_(a.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=t.state.field(n).open;for(let u=l.target,O;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(O=/-(\d+)$/.exec(u.id))&&+O[1]<c.length){this.applyCompletion(t,c[+O[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=t.state.field(this.stateField,!1);c&&c.tooltip&&t.state.facet(Si).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:o$.of(null)})}),this.showOptions(a,i.id)}mount(){this.updateSel()}showOptions(t,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var n;let r=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),r!=i){let{options:a,selected:o,disabled:s}=r.open;(!i.open||i.open.options!=a)&&(this.range=c_(a.length,o,t.state.facet(Si).maxRenderedOptions),this.showOptions(a,r.id)),this.updateSel(),s!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(t){let n=this.tooltipClass(t);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),n=t.open;if((n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=c_(n.options.length,n.selected,this.view.state.facet(Si).maxRenderedOptions),this.showOptions(n.options,t.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let a=typeof i=="string"?document.createTextNode(i):i(r);if(!a)return;"then"in a?a.then(o=>{o&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(o,r)}).catch(o=>Ea(this.view.state,o,"completion info")):this.addInfoPane(a,r)}}addInfoPane(t,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",t.nodeType!=null)r.appendChild(t),this.infoDestroy=null;else{let{dom:i,destroy:a}=t;r.appendChild(i),this.infoDestroy=a||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==t?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&AFe(this.list,n),n}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),a=this.space;if(!a){let o=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return i.top>Math.min(a.bottom,n.bottom)-10||i.bottom<Math.max(a.top,n.top)+10?null:this.view.state.facet(Si).positionInfo(this.view,n,i,r,a,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",o=>{o.target==i&&o.preventDefault()});let a=null;for(let o=r.from;o<r.to;o++){let{completion:s,match:l}=t[o],{section:c}=s;if(c){let d=typeof c=="string"?c:c.name;if(d!=a&&(o>r.from||r.from==0))if(a=d,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let h=i.appendChild(document.createElement("completion-section"));h.textContent=d}}const u=i.appendChild(document.createElement("li"));u.id=n+"-"+o,u.setAttribute("role","option");let O=this.optionClass(s);O&&(u.className=O);for(let d of this.optionContent){let h=d(s,this.view.state,this.view,l);h&&u.appendChild(h)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function zFe(e,t){return n=>new CFe(n,e,t)}function AFe(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function QZ(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function UFe(e,t){let n=[],r=null,i=c=>{n.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let O=typeof u=="string"?u:u.name;r.some(d=>d.name==O)||r.push(typeof u=="string"?{name:O}:u)}},a=t.facet(Si);for(let c of e)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let O of c.result.options)i(new wZ(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,h=a.filterStrict?new EFe(O):new RFe(O);for(let p of c.result.options)if(d=h.match(p.label)){let m=p.displayLabel?u?u(p,d.matched):[]:d.matched;i(new wZ(p,c.source,m,d.score+(p.boost||0)))}}}if(r){let c=Object.create(null),u=0,O=(d,h)=>{var p,m;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((m=h.rank)!==null&&m!==void 0?m:1e9)||(d.name<h.name?-1:1)};for(let d of r.sort(O))u-=1e5,c[d.name]=u;for(let d of n){let{section:h}=d.completion;h&&(d.score+=c[typeof h=="string"?h:h.name])}}let o=[],s=null,l=a.compareCompletions;for(let c of n.sort((u,O)=>O.score-u.score||l(u.completion,O.completion))){let u=c.completion;!s||s.label!=u.label||s.detail!=u.detail||s.type!=null&&u.type!=null&&s.type!=u.type||s.apply!=u.apply||s.boost!=u.boost?o.push(c):QZ(c.completion)>QZ(s)&&(o[o.length-1]=c),s=c.completion}return o}class dh{constructor(t,n,r,i,a,o){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=a,this.disabled=o}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new dh(this.options,kZ(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(c=>c.isPending))return i.setDisabled();let s=UFe(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Si).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<s.length;u++)if(s[u].completion==c){l=u;break}}return new dh(s,kZ(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:IFe,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new dh(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new dh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Lw{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new Lw(GFe,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Si),a=(r.override||n.languageDataAt("autocomplete",hd(n)).map(XFe)).map(l=>(this.active.find(u=>u.source==l)||new Yo(l,this.active.some(u=>u.state!=0)?1:0)).update(t,r));a.length==this.active.length&&a.every((l,c)=>l==this.active[c])&&(a=this.active);let o=this.open,s=t.effects.some(l=>l.is(Iz));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!WFe(a,this.active)||s?o=dh.build(a,n,this.id,o,r,s):o&&o.disabled&&!a.some(l=>l.isPending)&&(o=null),!o&&a.every(l=>!l.isPending)&&a.some(l=>l.hasResult())&&(a=a.map(l=>l.hasResult()?new Yo(l.source,0):l));for(let l of t.effects)l.is(Mde)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new Lw(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?YFe:NFe}}function WFe(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}const YFe={"aria-autocomplete":"list"},NFe={};function kZ(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const GFe=[];function Vde(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(Zz);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class Yo{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=Vde(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Yo(i.source,0)),r&4&&i.state==0&&(i=new Yo(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(Mw))i=new Yo(i.source,1,a.value);else if(a.is(o$))i=new Yo(i.source,0);else if(a.is(Iz))for(let o of a.value)o.source==i.source&&(i=o);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(hd(t.state))}}class Ph extends Yo{constructor(t,n,r,i,a,o){super(t,3,n),this.limit=r,this.result=i,this.from=a,this.to=o}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let a=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),s=hd(t.state);if(s>o||!i||n&2&&(hd(t.startState)==this.from||s<this.limit))return new Yo(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return ZFe(i.validFor,t.state,a,o)?new Ph(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new Gz(t.state,s,!1)))?new Ph(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:hd(t.state)):new Yo(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Ph(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Yo(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function ZFe(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Dde(e,!0).test(i)}const Iz=pn.define({map(e,t){return e.map(n=>n.map(t))}}),Mde=pn.define(),_a=Wa.define({create(){return Lw.start()},update(e,t){return e.update(t)},provide:e=>[Cz.from(e,t=>t.tooltip),vt.contentAttributes.from(e,t=>t.attrs)]});function Dz(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(_a).active.find(i=>i.source==t.source);return r instanceof Ph?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},TFe(e.state,n,r.from,r.to)),{annotations:Zz.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const IFe=zFe(_a,Dz);function ob(e,t="option"){return n=>{let r=n.state.field(_a,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Si).interactionDelay)return!1;let i=1,a;t=="page"&&(a=gde(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector("li").offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t=="page"?0:o-1:s>=o&&(s=t=="page"?o-1:0),n.dispatch({effects:Mde.of(s)}),!0}}const DFe=e=>{let t=e.state.field(_a,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Si).interactionDelay?!1:Dz(e,t.open.options[t.open.selected])},PZ=e=>e.state.field(_a,!1)?(e.dispatch({effects:Mw.of(!0)}),!0):!1,VFe=e=>{let t=e.state.field(_a,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:o$.of(null)}),!0)};class MFe{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const LFe=50,FFe=1e3,BFe=pi.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(_a).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(_a),n=e.state.facet(Si);if(!e.selectionSet&&!e.docChanged&&e.startState.field(_a)==t)return;let r=e.transactions.some(a=>{let o=Vde(a,n);return o&8||(a.selection||a.docChanged)&&!(o&3)});for(let a=0;a<this.running.length;a++){let o=this.running[a];if(r||o.context.abortOnDocChange&&e.docChanged||o.updates.length+e.transactions.length>LFe&&Date.now()-o.time>FFe){for(let s of o.context.abortListeners)try{s()}catch(l){Ea(this.view.state,l)}o.context.abortListeners=null,this.running.splice(a--,1)}else o.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(a=>a.effects.some(o=>o.is(Mw)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(a=>a.isPending&&!this.running.some(o=>o.active.source==a.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let a of e.transactions)a.isUserEvent("input.type")?this.composing=2:this.composing==2&&a.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(_a);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Si).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=hd(t),r=new Gz(t,n,e.explicit,this.view),i=new MFe(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(a=>{i.context.aborted||(i.done=a||null,this.scheduleAccept())},a=>{this.view.dispatch({effects:o$.of(null)}),Ea(this.view.state,a)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Si).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Si),r=this.view.state.field(_a);for(let i=0;i<this.running.length;i++){let a=this.running[i];if(a.done===void 0)continue;if(this.running.splice(i--,1),a.done){let s=hd(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new Ph(a.active.source,a.active.explicit,l,a.done,a.done.from,(e=a.done.to)!==null&&e!==void 0?e:s);for(let u of a.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let o=r.active.find(s=>s.source==a.active.source);if(o&&o.isPending)if(a.done==null){let s=new Yo(a.active.source,0);for(let l of a.updates)s=s.update(l,n);s.isPending||t.push(s)}else this.startQuery(o)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:Iz.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(_a,!1);if(t&&t.tooltip&&this.view.state.facet(Si).closeOnBlur){let n=t.open&&gde(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:o$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Mw.of(!1)}),20),this.composing=0}}}),HFe=typeof navigator=="object"&&/Win/.test(navigator.platform),KFe=uO.highest(vt.domEventHandlers({keydown(e,t){let n=t.state.field(_a,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(HFe&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(o=>o.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&Dz(t,r),!1}})),Lde=vt.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class JFe{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class Vz{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Ei.TrackDel),r=t.mapPos(this.to,1,Ei.TrackDel);return n==null||r==null?null:new Vz(this.field,n,r)}}class Mz{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],a=t.doc.lineAt(n),o=/^\s*/.exec(a.text)[0];for(let l of this.lines){if(r.length){let c=o,u=/^\t*/.exec(l)[0].length;for(let O=0;O<u;O++)c+=t.facet(TQ);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let s=this.fieldPositions.map(l=>new Vz(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:s}}static parse(t){let n=[],r=[],i=[],a;for(let o of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(o);){let s=a[1]?+a[1]:null,l=a[2]||a[3]||"",c=-1,u=l.replace(/\\[{}]/g,O=>O[1]);for(let O=0;O<n.length;O++)(s!=null?n[O].seq==s:u&&n[O].name==u)&&(c=O);if(c<0){let O=0;for(;O<n.length&&(s==null||n[O].seq!=null&&n[O].seq<s);)O++;n.splice(O,0,{seq:s,name:u}),c=O;for(let d of i)d.field>=c&&d.field++}i.push(new JFe(c,r.length,a.index,a.index+u.length)),o=o.slice(0,a.index)+l+o.slice(a.index+a[0].length)}o=o.replace(/\\([{}])/g,(s,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(o)}return new Mz(r,i)}}let eBe=Ft.widget({widget:new class extends Dc{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),tBe=Ft.mark({class:"cm-snippetField"});class tm{constructor(t,n){this.ranges=t,this.active=n,this.deco=Ft.set(t.map(r=>(r.from==r.to?eBe:tBe).range(r.from,r.to)))}map(t){let n=[];for(let r of this.ranges){let i=r.map(t);if(!i)return null;n.push(i)}return new tm(n,this.active)}selectionInsideField(t){return t.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const Ay=pn.define({map(e,t){return e&&e.map(t)}}),nBe=pn.define(),s$=Wa.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Ay))return n.value;if(n.is(nBe)&&e)return new tm(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>vt.decorations.from(e,t=>t?t.deco:Ft.none)});function Lz(e,t){return Ue.create(e.filter(n=>n.field==t).map(n=>Ue.range(n.from,n.to)))}function rBe(e){let t=Mz.parse(e);return(n,r,i,a)=>{let{text:o,ranges:s}=t.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:a==l.from?l.to:a,insert:zn.of(o)},scrollIntoView:!0,annotations:r?[Zz.of(r),ji.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=Lz(s,0)),s.some(u=>u.field>0)){let u=new tm(s,0),O=c.effects=[Ay.of(u)];n.state.field(s$,!1)===void 0&&O.push(pn.appendConfig.of([s$,lBe,cBe,Lde]))}n.dispatch(n.state.update(c))}}function Fde(e){return({state:t,dispatch:n})=>{let r=t.field(s$,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(o=>o.field==i+e);return n(t.update({selection:Lz(r.ranges,i),effects:Ay.of(a?null:new tm(r.ranges,i)),scrollIntoView:!0})),!0}}const iBe=({state:e,dispatch:t})=>e.field(s$,!1)?(t(e.update({effects:Ay.of(null)})),!0):!1,aBe=Fde(1),oBe=Fde(-1),sBe=[{key:"Tab",run:aBe,shift:oBe},{key:"Escape",run:iBe}],_Z=st.define({combine(e){return e.length?e[0]:sBe}}),lBe=uO.highest(kQ.compute([_Z],e=>e.facet(_Z)));function ir(e,t){return Object.assign(Object.assign({},t),{apply:rBe(e)})}const cBe=vt.domEventHandlers({mousedown(e,t){let n=t.state.field(s$,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(a=>a.from<=r&&a.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:Lz(n.ranges,i.field),effects:Ay.of(n.ranges.some(a=>a.field>i.field)?new tm(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),l$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},nd=pn.define({map(e,t){let n=t.mapPos(e,-1,Ei.TrackAfter);return n??void 0}}),Fz=new class extends Sd{};Fz.startSide=1;Fz.endSide=-1;const Bde=Wa.define({create(){return hn.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of t.effects)n.is(nd)&&(e=e.update({add:[Fz.range(n.value,n.value+1)]}));return e}});function ltn(){return[OBe,Bde]}const u_="()[]{}<>«»»«[]{}";function Hde(e){for(let t=0;t<u_.length;t+=2)if(u_.charCodeAt(t)==e)return u_.charAt(t+1);return nOe(e<128?e:e+1)}function Kde(e,t){return e.languageDataAt("closeBrackets",t)[0]||l$}const uBe=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),OBe=vt.inputHandler.of((e,t,n,r)=>{if((uBe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&ic(io(r,0))==1||t!=i.from||n!=i.to)return!1;let a=fBe(e.state,r);return a?(e.dispatch(a),!0):!1}),dBe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Kde(e,e.selection.main.head).brackets||l$.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=hBe(e.doc,o.head);for(let l of r)if(l==s&&qQ(e.doc,o.head)==Hde(io(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ue.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},ctn=[{key:"Backspace",run:dBe}];function fBe(e,t){let n=Kde(e,e.selection.main.head),r=n.brackets||l$.brackets;for(let i of r){let a=Hde(io(i,0));if(t==i)return a==i?gBe(e,i,r.indexOf(i+i+i)>-1,n):pBe(e,i,a,n.before||l$.before);if(t==a&&Jde(e,e.selection.main.from))return mBe(e,i,a)}return null}function Jde(e,t){let n=!1;return e.field(Bde).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function qQ(e,t){let n=e.sliceString(t,t+2);return n.slice(0,ic(io(n,0)))}function hBe(e,t){let n=e.sliceString(t-2,t);return ic(io(n,0))==n.length?n:n.slice(1)}function pBe(e,t,n,r){let i=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:nd.of(o.to+t.length),range:Ue.range(o.anchor+t.length,o.head+t.length)};let s=qQ(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:nd.of(o.head+t.length),range:Ue.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function mBe(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&qQ(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ue.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function gBe(e,t,n,r){let i=r.stringPrefixes||l$.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:nd.of(s.to+t.length),range:Ue.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=qQ(e.doc,l),u;if(c==t){if(TZ(e,l))return{changes:{insert:t+t,from:l},effects:nd.of(l+t.length),range:Ue.cursor(l+t.length)};if(Jde(e,l)){let d=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+d.length,insert:d},range:Ue.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=XZ(e,l-2*t.length,i))>-1&&TZ(e,u))return{changes:{insert:t+t+t+t,from:l},effects:nd.of(l+t.length),range:Ue.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=Wo.Word&&XZ(e,l,i)>-1&&!$Be(e,l,t,i))return{changes:{insert:t+t,from:l},effects:nd.of(l+t.length),range:Ue.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function TZ(e,t){let n=An(e).resolveInner(t+1);return n.parent&&n.from==t}function $Be(e,t,n,r){let i=An(e).resolveInner(t,-1),a=r.reduce((o,s)=>Math.max(o,s.length),0);for(let o=0;o<5;o++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),l=s.indexOf(n);if(!l||l>-1&&r.indexOf(s.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>n.length+l;){if(e.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function XZ(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Wo.Word)return t;for(let i of n){let a=t-i.length;if(e.sliceDoc(a,t)==i&&r(e.sliceDoc(a-1,a))!=Wo.Word)return a}return-1}function utn(e={}){return[KFe,_a,Si.of(e),BFe,vBe,Lde]}const yBe=[{key:"Ctrl-Space",run:PZ},{mac:"Alt-`",run:PZ},{key:"Escape",run:VFe},{key:"ArrowDown",run:ob(!0)},{key:"ArrowUp",run:ob(!1)},{key:"PageDown",run:ob(!0,"page")},{key:"PageUp",run:ob(!1,"page")},{key:"Enter",run:DFe}],vBe=uO.highest(kQ.computeN([Si],e=>e.facet(Si).defaultKeymap?[yBe]:[]));class Fw{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new Fw(t,n,r,o,a,[],[])}constructor(t,n,r,i,a,o,s){this.type=t,this.value=n,this.from=r,this.hash=i,this.end=a,this.children=o,this.positions=s,this.hashProp=[[qt.contextHash,i]]}addChild(t,n){t.prop(qt.contextHash)!=this.hash&&(t=new en(t.type,t.children,t.positions,t.length,this.hashProp)),this.children.push(t),this.positions.push(n)}toTree(t,n=this.end){let r=this.children.length-1;return r>=0&&(n=Math.max(n,this.positions[r]+this.children[r].length+this.from)),new en(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new en(ti.none,i,a,o,this.hashProp)})}}var Ye;(function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"})(Ye||(Ye={}));class bBe{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let wBe=class{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let t=this.skipSpace(this.basePos);this.indent=this.countIndent(t,this.pos,this.indent),this.pos=t,this.next=t==this.text.length?-1:this.text.charCodeAt(t)}skipSpace(t){return f0(this.text,t)}reset(t){for(this.text=t,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(t){this.basePos=t,this.baseIndent=this.countIndent(t,this.pos,this.indent)}moveBaseColumn(t){this.baseIndent=t,this.basePos=this.findColumn(t)}addMarker(t){this.markers.push(t)}countIndent(t,n=0,r=0){for(let i=n;i<t;i++)r+=this.text.charCodeAt(i)==9?4-r%4:1;return r}findColumn(t){let n=0;for(let r=0;n<this.text.length&&r<t;n++)r+=this.text.charCodeAt(n)==9?4-r%4:1;return n}scrub(){if(!this.baseIndent)return this.text;let t="";for(let n=0;n<this.basePos;n++)t+=" ";return t+this.text.slice(this.basePos)}};function RZ(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==Ye.OrderedList?Kz:Hz)(n,t,!1);return r>0&&(e.type!=Ye.BulletList||Bz(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const efe={[Ye.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(cn(Ye.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Jo(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Ye.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Ye.OrderedList]:RZ,[Ye.BulletList]:RZ,[Ye.Document](){return!0}};function Jo(e){return e==32||e==9||e==10||e==13}function f0(e,t=0){for(;t<e.length&&Jo(e.charCodeAt(t));)t++;return t}function EZ(e,t,n){for(;t>n&&Jo(e.charCodeAt(t-1));)t--;return t}function tfe(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function nfe(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function Bz(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let i=e.pos+1;i<e.text.length;i++){let a=e.text.charCodeAt(i);if(a==e.next)r++;else if(!Jo(a))return-1}return n&&e.next==45&&afe(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(cfe.SetextHeading)>-1||r<3?-1:1}function rfe(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function Hz(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Jo(e.text.charCodeAt(e.pos+1)))&&(!n||rfe(t,Ye.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Kz(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){r++;if(r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!Jo(e.text.charCodeAt(r+1))||n&&!rfe(t,Ye.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function ife(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function afe(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&Jo(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const l3=/^[ \t]*$/,ofe=/-->/,sfe=/\?>/,c3=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,ofe],[/^\s*<\?/,sfe],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,l3],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,l3]];function lfe(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=c3.length-(n?1:0);i<a;i++)if(c3[i][0].test(r))return i;return-1}function qZ(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function jO(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Ye.CodeText?e[r].to=n:e.push(cn(Ye.CodeText,t,n))}const sb={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(jO(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){jO(s,e.lineStart-1,e.lineStart);for(let l of t.markers)s.push(l)}else{if(t.indent<n)break;{if(s.length){for(let c of s)c.type==Ye.CodeText?jO(o,c.from,c.to):o.push(c);s=[]}jO(o,e.lineStart-1,e.lineStart);for(let c of t.markers)o.push(c);a=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<a&&jO(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Ye.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Ye.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=tfe(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=EZ(t.text,t.text.length,o),l=[cn(Ye.CodeMark,r,r+a)];o<s&&l.push(cn(Ye.CodeInfo,e.lineStart+o,e.lineStart+s));for(let c=!0;e.nextLine()&&t.depth>=e.stack.length;c=!1){let u=t.pos;if(t.indent-t.baseIndent<4)for(;u<t.text.length&&t.text.charCodeAt(u)==i;)u++;if(u-t.pos>=a&&t.skipSpace(u)==t.text.length){for(let O of t.markers)l.push(O);l.push(cn(Ye.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||jO(l,e.lineStart-1,e.lineStart);for(let h of t.markers)l.push(h);let O=e.lineStart+t.basePos,d=e.lineStart+t.text.length;O<d&&jO(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Ye.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=nfe(t);return n<0?!1:(e.startContext(Ye.Blockquote,t.pos),e.addNode(Ye.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(Bz(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Ye.HorizontalRule,n),!0},BulletList(e,t){let n=Hz(t,e,!1);if(n<0)return!1;e.block.type!=Ye.BulletList&&e.startContext(Ye.BulletList,t.basePos,t.next);let r=qZ(t,t.pos+1);return e.startContext(Ye.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ye.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=Kz(t,e,!1);if(n<0)return!1;e.block.type!=Ye.OrderedList&&e.startContext(Ye.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=qZ(t,t.pos+n);return e.startContext(Ye.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ye.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=ife(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=EZ(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!Jo(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Ye.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Ye.HeaderMark,o-r,a-r);let l=s.finish(Ye.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=lfe(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=c3[n][1],a=[],o=i!=l3;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let c of t.markers)a.push(c)}o&&e.nextLine();let s=i==ofe?Ye.CommentBlock:i==sfe?Ye.ProcessingInstructionBlock:Ye.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class xBe{constructor(t){this.stage=0,this.elts=[],this.pos=0,this.start=t.start,this.advance(t.content)}nextLine(t,n,r){if(this.stage==-1)return!1;let i=r.content+`
786
+ `);r>-1&&(n=n.slice(0,r))}return t+n.length<=this.to?n:n.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,n=this.lineAfter(t),r=t+n.length;for(let i=this.rangeIndex;;){let a=this.ranges[i].to;if(a>=r||(n=n.slice(0,a-(r-n.length)),i++,i==this.ranges.length))break;let o=this.ranges[i].from,s=this.lineAfter(o);n+=s,r=o+s.length}return{line:n,end:r}}skipGapsTo(t,n,r){for(;;){let i=this.ranges[this.rangeIndex].to,a=t+n;if(r>0?i>a:i>=a)break;let o=this.ranges[++this.rangeIndex].from;n+=o-i}return n}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,n,r,i){let a=4;if(this.ranges.length>1){i=this.skipGapsTo(n,i,1),n+=i;let s=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,a+=this.chunk.length-s}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&a==4&&o>=0&&this.chunk[o]==t&&this.chunk[o+2]==n?this.chunk[o+2]=r:this.chunk.push(t,n,r,a),i}parseLine(t){let{line:n,end:r}=this.nextLine(),i=0,{streamParser:a}=this.lang,o=new Wde(n,t?t.state.tabSize:4,t?Iw(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=Nde(a.token,o,this.state);if(s&&(i=this.emitToken(this.lang.tokenTable.resolve(s),this.parsedPos+o.start,this.parsedPos+o.pos,i)),o.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=en.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:SFe,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new en(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new en(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Nde(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let i=e(t,n);if(t.pos>t.start)return i}throw new Error("Stream parser failed to advance stream.")}const Nz=Object.create(null),a$=[ti.none],SFe=new Jp(a$),yZ=[],vZ=Object.create(null),Gde=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Gde[e]=Ide(Nz,t);class Zde{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Gde)}resolve(t){return t?this.table[t]||(this.table[t]=Ide(this.extra,t)):0}}const QFe=new Zde(Nz);function l_(e,t){yZ.indexOf(e)>-1||(yZ.push(e),console.warn(t))}function Ide(e,t){let n=[];for(let s of t.split(" ")){let l=[];for(let c of s.split(".")){let u=e[c]||k[c];u?typeof u=="function"?l.length?l=l.map(u):l_(c,`Modifier ${c} used at start of tag`):l.length?l_(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:l_(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(s=>s.id),a=vZ[i];if(a)return a.id;let o=vZ[i]=ti.define({id:a$.length,name:r,props:[wn({[r]:n})]});return a$.push(o),o.id}function kFe(e,t){let n=ti.define({id:a$.length,name:"Document",props:[Ru.add(()=>e),Pr.add(()=>r=>t.getIndent(r))],top:!0});return a$.push(n),n}Or.RTL,Or.LTR;function Qe(e){return new un(Te.define(e))}function ou(e){return ge(()=>Promise.resolve().then(()=>Kit),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const PFe=[pe.of({name:"C",extensions:["c","h","ino"],load(){return ge(()=>Promise.resolve().then(()=>OD),void 0,import.meta.url).then(e=>e.cpp())}}),pe.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return ge(()=>Promise.resolve().then(()=>OD),void 0,import.meta.url).then(e=>e.cpp())}}),pe.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return ou("Cassandra")}}),pe.of({name:"CSS",extensions:["css"],load(){return ge(()=>Promise.resolve().then(()=>OKe),void 0,import.meta.url).then(e=>e.css())}}),pe.of({name:"Go",extensions:["go"],load(){return ge(()=>import("./index-DaCf2W9T.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>e.go())}}),pe.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return ge(()=>Promise.resolve().then(()=>nJe),void 0,import.meta.url).then(e=>e.html())}}),pe.of({name:"Java",extensions:["java"],load(){return ge(()=>Promise.resolve().then(()=>nat),void 0,import.meta.url).then(e=>e.java())}}),pe.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return ge(()=>Promise.resolve().then(()=>cb),void 0,import.meta.url).then(e=>e.javascript())}}),pe.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return ge(()=>Promise.resolve().then(()=>set),void 0,import.meta.url).then(e=>e.json())}}),pe.of({name:"JSX",extensions:["jsx"],load(){return ge(()=>Promise.resolve().then(()=>cb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),pe.of({name:"LESS",extensions:["less"],load(){return ge(()=>Promise.resolve().then(()=>xJe),void 0,import.meta.url).then(e=>e.less())}}),pe.of({name:"Liquid",extensions:["liquid"],load(){return ge(()=>Promise.resolve().then(()=>Nst),void 0,import.meta.url).then(e=>e.liquid())}}),pe.of({name:"MariaDB SQL",load(){return ou("MariaSQL")}}),pe.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return ge(()=>Promise.resolve().then(()=>dJe),void 0,import.meta.url).then(e=>e.markdown())}}),pe.of({name:"MS SQL",load(){return ou("MSSQL")}}),pe.of({name:"MySQL",load(){return ou("MySQL")}}),pe.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return ge(()=>Promise.resolve().then(()=>$st),void 0,import.meta.url).then(e=>e.php())}}),pe.of({name:"PLSQL",extensions:["pls"],load(){return ou("PLSQL")}}),pe.of({name:"PostgreSQL",load(){return ou("PostgreSQL")}}),pe.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return ge(()=>Promise.resolve().then(()=>Nrt),void 0,import.meta.url).then(e=>e.python())}}),pe.of({name:"Rust",extensions:["rs"],load(){return ge(()=>Promise.resolve().then(()=>wat),void 0,import.meta.url).then(e=>e.rust())}}),pe.of({name:"Sass",extensions:["sass"],load(){return ge(()=>Promise.resolve().then(()=>kI),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),pe.of({name:"SCSS",extensions:["scss"],load(){return ge(()=>Promise.resolve().then(()=>kI),void 0,import.meta.url).then(e=>e.sass())}}),pe.of({name:"SQL",extensions:["sql"],load(){return ou("StandardSQL")}}),pe.of({name:"SQLite",load(){return ou("SQLite")}}),pe.of({name:"TSX",extensions:["tsx"],load(){return ge(()=>Promise.resolve().then(()=>cb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),pe.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return ge(()=>Promise.resolve().then(()=>cb),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),pe.of({name:"WebAssembly",extensions:["wat","wast"],load(){return ge(()=>Promise.resolve().then(()=>Ist),void 0,import.meta.url).then(e=>e.wast())}}),pe.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return ge(()=>Promise.resolve().then(()=>cit),void 0,import.meta.url).then(e=>e.xml())}}),pe.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return ge(()=>import("./index-BaNzqqGN.js"),__vite__mapDeps([5,1,2,3,4]),import.meta.url).then(e=>e.yaml())}}),pe.of({name:"APL",extensions:["dyalog","apl"],load(){return ge(()=>Promise.resolve().then(()=>yut),void 0,import.meta.url).then(e=>Qe(e.apl))}}),pe.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return ge(()=>Promise.resolve().then(()=>vut),void 0,import.meta.url).then(e=>Qe(e.asciiArmor))}}),pe.of({name:"ASN.1",extensions:["asn","asn1"],load(){return ge(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>Qe(e.asn1({})))}}),pe.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return ge(()=>Promise.resolve().then(()=>Qut),void 0,import.meta.url).then(e=>Qe(e.asterisk))}}),pe.of({name:"Brainfuck",extensions:["b","bf"],load(){return ge(()=>Promise.resolve().then(()=>Put),void 0,import.meta.url).then(e=>Qe(e.brainfuck))}}),pe.of({name:"Cobol",extensions:["cob","cpy"],load(){return ge(()=>Promise.resolve().then(()=>tOt),void 0,import.meta.url).then(e=>Qe(e.cobol))}}),pe.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return ge(()=>Promise.resolve().then(()=>AO),void 0,import.meta.url).then(e=>Qe(e.csharp))}}),pe.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return ge(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Qe(e.clojure))}}),pe.of({name:"ClojureScript",extensions:["cljs"],load(){return ge(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Qe(e.clojure))}}),pe.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return ge(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>Qe(e.gss))}}),pe.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return ge(()=>Promise.resolve().then(()=>Vut),void 0,import.meta.url).then(e=>Qe(e.cmake))}}),pe.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return ge(()=>Promise.resolve().then(()=>hOt),void 0,import.meta.url).then(e=>Qe(e.coffeeScript))}}),pe.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return ge(()=>Promise.resolve().then(()=>vOt),void 0,import.meta.url).then(e=>Qe(e.commonLisp))}}),pe.of({name:"Cypher",extensions:["cyp","cypher"],load(){return ge(()=>Promise.resolve().then(()=>UOt),void 0,import.meta.url).then(e=>Qe(e.cypher))}}),pe.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return ge(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>Qe(e.cython))}}),pe.of({name:"Crystal",extensions:["cr"],load(){return ge(()=>Promise.resolve().then(()=>EOt),void 0,import.meta.url).then(e=>Qe(e.crystal))}}),pe.of({name:"D",extensions:["d"],load(){return ge(()=>Promise.resolve().then(()=>DOt),void 0,import.meta.url).then(e=>Qe(e.d))}}),pe.of({name:"Dart",extensions:["dart"],load(){return ge(()=>Promise.resolve().then(()=>AO),void 0,import.meta.url).then(e=>Qe(e.dart))}}),pe.of({name:"diff",extensions:["diff","patch"],load(){return ge(()=>Promise.resolve().then(()=>VOt),void 0,import.meta.url).then(e=>Qe(e.diff))}}),pe.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return ge(()=>Promise.resolve().then(()=>adt),void 0,import.meta.url).then(e=>Qe(e.dockerFile))}}),pe.of({name:"DTD",extensions:["dtd"],load(){return ge(()=>Promise.resolve().then(()=>ldt),void 0,import.meta.url).then(e=>Qe(e.dtd))}}),pe.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return ge(()=>Promise.resolve().then(()=>fdt),void 0,import.meta.url).then(e=>Qe(e.dylan))}}),pe.of({name:"EBNF",load(){return ge(()=>Promise.resolve().then(()=>hdt),void 0,import.meta.url).then(e=>Qe(e.ebnf))}}),pe.of({name:"ECL",extensions:["ecl"],load(){return ge(()=>Promise.resolve().then(()=>wdt),void 0,import.meta.url).then(e=>Qe(e.ecl))}}),pe.of({name:"edn",extensions:["edn"],load(){return ge(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Qe(e.clojure))}}),pe.of({name:"Eiffel",extensions:["e"],load(){return ge(()=>Promise.resolve().then(()=>_dt),void 0,import.meta.url).then(e=>Qe(e.eiffel))}}),pe.of({name:"Elm",extensions:["elm"],load(){return ge(()=>Promise.resolve().then(()=>Wdt),void 0,import.meta.url).then(e=>Qe(e.elm))}}),pe.of({name:"Erlang",extensions:["erl"],load(){return ge(()=>Promise.resolve().then(()=>cft),void 0,import.meta.url).then(e=>Qe(e.erlang))}}),pe.of({name:"Esper",load(){return ge(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>Qe(e.esper))}}),pe.of({name:"Factor",extensions:["factor"],load(){return ge(()=>Promise.resolve().then(()=>uft),void 0,import.meta.url).then(e=>Qe(e.factor))}}),pe.of({name:"FCL",load(){return ge(()=>Promise.resolve().then(()=>pft),void 0,import.meta.url).then(e=>Qe(e.fcl))}}),pe.of({name:"Forth",extensions:["forth","fth","4th"],load(){return ge(()=>Promise.resolve().then(()=>$ft),void 0,import.meta.url).then(e=>Qe(e.forth))}}),pe.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return ge(()=>Promise.resolve().then(()=>Qft),void 0,import.meta.url).then(e=>Qe(e.fortran))}}),pe.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return ge(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Qe(e.fSharp))}}),pe.of({name:"Gas",extensions:["s"],load(){return ge(()=>Promise.resolve().then(()=>Pft),void 0,import.meta.url).then(e=>Qe(e.gas))}}),pe.of({name:"Gherkin",extensions:["feature"],load(){return ge(()=>Promise.resolve().then(()=>_ft),void 0,import.meta.url).then(e=>Qe(e.gherkin))}}),pe.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return ge(()=>Promise.resolve().then(()=>Wft),void 0,import.meta.url).then(e=>Qe(e.groovy))}}),pe.of({name:"Haskell",extensions:["hs"],load(){return ge(()=>Promise.resolve().then(()=>Vft),void 0,import.meta.url).then(e=>Qe(e.haskell))}}),pe.of({name:"Haxe",extensions:["hx"],load(){return ge(()=>Promise.resolve().then(()=>jV),void 0,import.meta.url).then(e=>Qe(e.haxe))}}),pe.of({name:"HXML",extensions:["hxml"],load(){return ge(()=>Promise.resolve().then(()=>jV),void 0,import.meta.url).then(e=>Qe(e.hxml))}}),pe.of({name:"HTTP",load(){return ge(()=>Promise.resolve().then(()=>pht),void 0,import.meta.url).then(e=>Qe(e.http))}}),pe.of({name:"IDL",extensions:["pro"],load(){return ge(()=>Promise.resolve().then(()=>wht),void 0,import.meta.url).then(e=>Qe(e.idl))}}),pe.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return ge(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>Qe(e.jsonld))}}),pe.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return ge(()=>Promise.resolve().then(()=>kht),void 0,import.meta.url).then(e=>Qe(e.jinja2))}}),pe.of({name:"Julia",extensions:["jl"],load(){return ge(()=>Promise.resolve().then(()=>Hht),void 0,import.meta.url).then(e=>Qe(e.julia))}}),pe.of({name:"Kotlin",extensions:["kt","kts"],load(){return ge(()=>Promise.resolve().then(()=>AO),void 0,import.meta.url).then(e=>Qe(e.kotlin))}}),pe.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return ge(()=>Promise.resolve().then(()=>tpt),void 0,import.meta.url).then(e=>Qe(e.liveScript))}}),pe.of({name:"Lua",extensions:["lua"],load(){return ge(()=>Promise.resolve().then(()=>cpt),void 0,import.meta.url).then(e=>Qe(e.lua))}}),pe.of({name:"mIRC",extensions:["mrc"],load(){return ge(()=>Promise.resolve().then(()=>Ept),void 0,import.meta.url).then(e=>Qe(e.mirc))}}),pe.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return ge(()=>Promise.resolve().then(()=>gpt),void 0,import.meta.url).then(e=>Qe(e.mathematica))}}),pe.of({name:"Modelica",extensions:["mo"],load(){return ge(()=>Promise.resolve().then(()=>Gpt),void 0,import.meta.url).then(e=>Qe(e.modelica))}}),pe.of({name:"MUMPS",extensions:["mps"],load(){return ge(()=>Promise.resolve().then(()=>imt),void 0,import.meta.url).then(e=>Qe(e.mumps))}}),pe.of({name:"Mbox",extensions:["mbox"],load(){return ge(()=>Promise.resolve().then(()=>Tpt),void 0,import.meta.url).then(e=>Qe(e.mbox))}}),pe.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return ge(()=>Promise.resolve().then(()=>cmt),void 0,import.meta.url).then(e=>Qe(e.nginx))}}),pe.of({name:"NSIS",extensions:["nsh","nsi"],load(){return ge(()=>Promise.resolve().then(()=>umt),void 0,import.meta.url).then(e=>Qe(e.nsis))}}),pe.of({name:"NTriples",extensions:["nt","nq"],load(){return ge(()=>Promise.resolve().then(()=>Omt),void 0,import.meta.url).then(e=>Qe(e.ntriples))}}),pe.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return ge(()=>Promise.resolve().then(()=>AO),void 0,import.meta.url).then(e=>Qe(e.objectiveC))}}),pe.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return ge(()=>Promise.resolve().then(()=>AO),void 0,import.meta.url).then(e=>Qe(e.objectiveCpp))}}),pe.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return ge(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Qe(e.oCaml))}}),pe.of({name:"Octave",extensions:["m"],load(){return ge(()=>Promise.resolve().then(()=>wmt),void 0,import.meta.url).then(e=>Qe(e.octave))}}),pe.of({name:"Oz",extensions:["oz"],load(){return ge(()=>Promise.resolve().then(()=>jmt),void 0,import.meta.url).then(e=>Qe(e.oz))}}),pe.of({name:"Pascal",extensions:["p","pas"],load(){return ge(()=>Promise.resolve().then(()=>Ymt),void 0,import.meta.url).then(e=>Qe(e.pascal))}}),pe.of({name:"Perl",extensions:["pl","pm"],load(){return ge(()=>Promise.resolve().then(()=>Nmt),void 0,import.meta.url).then(e=>Qe(e.perl))}}),pe.of({name:"Pig",extensions:["pig"],load(){return ge(()=>Promise.resolve().then(()=>Imt),void 0,import.meta.url).then(e=>Qe(e.pig))}}),pe.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return ge(()=>Promise.resolve().then(()=>ogt),void 0,import.meta.url).then(e=>Qe(e.powerShell))}}),pe.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return ge(()=>Promise.resolve().then(()=>sgt),void 0,import.meta.url).then(e=>Qe(e.properties))}}),pe.of({name:"ProtoBuf",extensions:["proto"],load(){return ge(()=>Promise.resolve().then(()=>dgt),void 0,import.meta.url).then(e=>Qe(e.protobuf))}}),pe.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return ge(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>Qe(e.pug))}}),pe.of({name:"Puppet",extensions:["pp"],load(){return ge(()=>Promise.resolve().then(()=>pgt),void 0,import.meta.url).then(e=>Qe(e.puppet))}}),pe.of({name:"Q",extensions:["q"],load(){return ge(()=>Promise.resolve().then(()=>xgt),void 0,import.meta.url).then(e=>Qe(e.q))}}),pe.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return ge(()=>Promise.resolve().then(()=>Xgt),void 0,import.meta.url).then(e=>Qe(e.r))}}),pe.of({name:"RPM Changes",load(){return ge(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Qe(e.rpmChanges))}}),pe.of({name:"RPM Spec",extensions:["spec"],load(){return ge(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Qe(e.rpmSpec))}}),pe.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return ge(()=>Promise.resolve().then(()=>Wgt),void 0,import.meta.url).then(e=>Qe(e.ruby))}}),pe.of({name:"SAS",extensions:["sas"],load(){return ge(()=>Promise.resolve().then(()=>Zgt),void 0,import.meta.url).then(e=>Qe(e.sas))}}),pe.of({name:"Scala",extensions:["scala"],load(){return ge(()=>Promise.resolve().then(()=>AO),void 0,import.meta.url).then(e=>Qe(e.scala))}}),pe.of({name:"Scheme",extensions:["scm","ss"],load(){return ge(()=>Promise.resolve().then(()=>n0t),void 0,import.meta.url).then(e=>Qe(e.scheme))}}),pe.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return ge(()=>Promise.resolve().then(()=>o0t),void 0,import.meta.url).then(e=>Qe(e.shell))}}),pe.of({name:"Sieve",extensions:["siv","sieve"],load(){return ge(()=>Promise.resolve().then(()=>O0t),void 0,import.meta.url).then(e=>Qe(e.sieve))}}),pe.of({name:"Smalltalk",extensions:["st"],load(){return ge(()=>Promise.resolve().then(()=>h0t),void 0,import.meta.url).then(e=>Qe(e.smalltalk))}}),pe.of({name:"Solr",load(){return ge(()=>Promise.resolve().then(()=>b0t),void 0,import.meta.url).then(e=>Qe(e.solr))}}),pe.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return ge(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Qe(e.sml))}}),pe.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return ge(()=>Promise.resolve().then(()=>_0t),void 0,import.meta.url).then(e=>Qe(e.sparql))}}),pe.of({name:"Spreadsheet",alias:["excel","formula"],load(){return ge(()=>Promise.resolve().then(()=>T0t),void 0,import.meta.url).then(e=>Qe(e.spreadsheet))}}),pe.of({name:"Squirrel",extensions:["nut"],load(){return ge(()=>Promise.resolve().then(()=>AO),void 0,import.meta.url).then(e=>Qe(e.squirrel))}}),pe.of({name:"Stylus",extensions:["styl"],load(){return ge(()=>Promise.resolve().then(()=>H0t),void 0,import.meta.url).then(e=>Qe(e.stylus))}}),pe.of({name:"Swift",extensions:["swift"],load(){return ge(()=>Promise.resolve().then(()=>g$t),void 0,import.meta.url).then(e=>Qe(e.swift))}}),pe.of({name:"sTeX",load(){return ge(()=>Promise.resolve().then(()=>QM),void 0,import.meta.url).then(e=>Qe(e.stex))}}),pe.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return ge(()=>Promise.resolve().then(()=>QM),void 0,import.meta.url).then(e=>Qe(e.stex))}}),pe.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return ge(()=>Promise.resolve().then(()=>DM),void 0,import.meta.url).then(e=>Qe(e.verilog))}}),pe.of({name:"Tcl",extensions:["tcl"],load(){return ge(()=>Promise.resolve().then(()=>b$t),void 0,import.meta.url).then(e=>Qe(e.tcl))}}),pe.of({name:"Textile",extensions:["textile"],load(){return ge(()=>Promise.resolve().then(()=>Q$t),void 0,import.meta.url).then(e=>Qe(e.textile))}}),pe.of({name:"TiddlyWiki",load(){return ge(()=>Promise.resolve().then(()=>V$t),void 0,import.meta.url).then(e=>Qe(e.tiddlyWiki))}}),pe.of({name:"Tiki wiki",load(){return ge(()=>Promise.resolve().then(()=>J$t),void 0,import.meta.url).then(e=>Qe(e.tiki))}}),pe.of({name:"TOML",extensions:["toml"],load(){return ge(()=>Promise.resolve().then(()=>eyt),void 0,import.meta.url).then(e=>Qe(e.toml))}}),pe.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return ge(()=>Promise.resolve().then(()=>ryt),void 0,import.meta.url).then(e=>Qe(e.troff))}}),pe.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return ge(()=>Promise.resolve().then(()=>byt),void 0,import.meta.url).then(e=>Qe(e.ttcn))}}),pe.of({name:"TTCN_CFG",extensions:["cfg"],load(){return ge(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>Qe(e.ttcnCfg))}}),pe.of({name:"Turtle",extensions:["ttl"],load(){return ge(()=>Promise.resolve().then(()=>Syt),void 0,import.meta.url).then(e=>Qe(e.turtle))}}),pe.of({name:"Web IDL",extensions:["webidl"],load(){return ge(()=>Promise.resolve().then(()=>gvt),void 0,import.meta.url).then(e=>Qe(e.webIDL))}}),pe.of({name:"VB.NET",extensions:["vb"],load(){return ge(()=>Promise.resolve().then(()=>Wyt),void 0,import.meta.url).then(e=>Qe(e.vb))}}),pe.of({name:"VBScript",extensions:["vbs"],load(){return ge(()=>Promise.resolve().then(()=>Nyt),void 0,import.meta.url).then(e=>Qe(e.vbScript))}}),pe.of({name:"Velocity",extensions:["vtl"],load(){return ge(()=>Promise.resolve().then(()=>Iyt),void 0,import.meta.url).then(e=>Qe(e.velocity))}}),pe.of({name:"Verilog",extensions:["v"],load(){return ge(()=>Promise.resolve().then(()=>DM),void 0,import.meta.url).then(e=>Qe(e.verilog))}}),pe.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return ge(()=>Promise.resolve().then(()=>Jyt),void 0,import.meta.url).then(e=>Qe(e.vhdl))}}),pe.of({name:"XQuery",extensions:["xy","xquery"],load(){return ge(()=>Promise.resolve().then(()=>Pvt),void 0,import.meta.url).then(e=>Qe(e.xQuery))}}),pe.of({name:"Yacas",extensions:["ys"],load(){return ge(()=>Promise.resolve().then(()=>Avt),void 0,import.meta.url).then(e=>Qe(e.yacas))}}),pe.of({name:"Z80",extensions:["z80"],load(){return ge(()=>Promise.resolve().then(()=>Gvt),void 0,import.meta.url).then(e=>Qe(e.z80))}}),pe.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return ge(()=>Promise.resolve().then(()=>hT),void 0,import.meta.url).then(e=>Qe(e.mscgen))}}),pe.of({name:"Xù",extensions:["xu"],load(){return ge(()=>Promise.resolve().then(()=>hT),void 0,import.meta.url).then(e=>Qe(e.xu))}}),pe.of({name:"MsGenny",extensions:["msgenny"],load(){return ge(()=>Promise.resolve().then(()=>hT),void 0,import.meta.url).then(e=>Qe(e.msgenny))}}),pe.of({name:"Vue",extensions:["vue"],load(){return ge(()=>Promise.resolve().then(()=>Kst),void 0,import.meta.url).then(e=>e.vue())}}),pe.of({name:"Angular Template",load(){return ge(()=>Promise.resolve().then(()=>glt),void 0,import.meta.url).then(e=>e.angular())}})];class Gz{constructor(t,n,r,i){this.state=t,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let n=An(this.state).resolveInner(this.pos,-1);for(;n&&t.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(t){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),a=i.search(Dde(t,!1));return a<0?null:{from:r+a,to:this.pos,text:i.slice(a)}}get aborted(){return this.abortListeners==null}addEventListener(t,n,r){t=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function bZ(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function _Fe(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let a=1;a<i.length;a++)n[i[a]]=!0}let r=bZ(t)+bZ(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function zy(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:_Fe(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function EQ(e,t){return n=>{for(let r=An(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(e.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return t(n)}}class wZ{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function hd(e){return e.selection.main.from}function Dde(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",a=r[r.length-1]!="$";return!i&&!a?e:new RegExp(`${i?"^":""}(?:${r})${a?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const Zz=Hd.define();function TFe(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return Object.assign(Object.assign({},e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let l=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:l},range:Ue.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const xZ=new WeakMap;function XFe(e){if(!Array.isArray(e))return e;let t=xZ.get(e);return t||xZ.set(e,t=zy(e)),t}const Mw=pn.define(),o$=pn.define();class RFe{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<t.length;){let r=io(t,n),i=ic(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(io(o==a?a.toLowerCase():o,0)),n+=i}this.astral=t.length!=this.chars.length}ret(t,n){return this.score=t,this.matched=n,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:a,byWord:o}=this;if(n.length==1){let v=io(t,0),x=ic(v),S=x==t.length?0:-100;if(v!=n[0])if(v==r[0])S+=-200;else return null;return this.ret(S,[0,x])}let s=t.indexOf(this.pattern);if(s==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(s<0){for(let v=0,x=Math.min(t.length,200);v<x&&c<l;){let S=io(t,v);(S==n[c]||S==r[c])&&(i[c++]=v),v+=ic(S)}if(c<l)return null}let u=0,O=0,d=!1,h=0,p=-1,m=-1,g=/[a-z]/.test(t),y=!0;for(let v=0,x=Math.min(t.length,200),S=0;v<x&&O<l;){let b=io(t,v);s<0&&(u<l&&b==n[u]&&(a[u++]=v),h<l&&(b==n[h]||b==r[h]?(h==0&&(p=v),m=v+1,h++):h=0));let w,Q=b<255?b>=48&&b<=57||b>=97&&b<=122?2:b>=65&&b<=90?1:0:(w=nOe(b))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!v||Q==1&&g||S==0&&Q!=0)&&(n[O]==b||r[O]==b&&(d=!0)?o[O++]=v:o.length&&(y=!1)),S=Q,v+=ic(b)}return O==l&&o[0]==0&&y?this.result(-100+(d?-200:0),o,t):h==l&&p==0?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):h==l?this.ret(-900-t.length,[p,m]):O==l?this.result(-100+(d?-200:0)+-700+(y?0:-1100),o,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],a=0;for(let o of n){let s=o+(this.astral?ic(io(r,o)):1);a&&i[a-1]==o?i[a-1]=s:(i[a++]=o,i[a++]=s)}return this.ret(t-r.length,i)}}class EFe{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let n=t.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(t.length==this.pattern.length?0:-100),this)}}const Si=st.define({combine(e){return em(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:qFe,filterStrict:!1,compareCompletions:(t,n)=>t.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>r=>SZ(t(r),n(r)),optionClass:(t,n)=>r=>SZ(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function SZ(e,t){return e?t?e+" "+t:e:t}function qFe(e,t,n,r,i,a){let o=e.textDirection==Or.RTL,s=o,l=!1,c="top",u,O,d=t.left-i.left,h=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(s&&d<Math.min(p,h)?s=!1:!s&&h<Math.min(p,d)&&(s=!0),p<=(s?d:h))u=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,O=Math.min(400,s?d:h);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let v=i.bottom-t.bottom;v>=m||v>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,y=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${O/y}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function jFe(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),t.push({render(n,r,i,a){let o=document.createElement("span");o.className="cm-completionLabel";let s=n.displayLabel||n.label,l=0;for(let c=0;c<a.length;){let u=a[c++],O=a[c++];u>l&&o.appendChild(document.createTextNode(s.slice(l,u)));let d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(s.slice(u,O))),d.className="cm-completionMatchedText",l=O}return l<s.length&&o.appendChild(document.createTextNode(s.slice(l))),o},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),t.sort((n,r)=>n.position-r.position).map(n=>n.render)}function c_(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let i=Math.floor(t/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class CFe{constructor(t,n,r){this.view=t,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=t.state.field(n),{options:a,selected:o}=i.open,s=t.state.facet(Si);this.optionContent=jFe(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=c_(a.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=t.state.field(n).open;for(let u=l.target,O;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(O=/-(\d+)$/.exec(u.id))&&+O[1]<c.length){this.applyCompletion(t,c[+O[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=t.state.field(this.stateField,!1);c&&c.tooltip&&t.state.facet(Si).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:o$.of(null)})}),this.showOptions(a,i.id)}mount(){this.updateSel()}showOptions(t,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var n;let r=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),r!=i){let{options:a,selected:o,disabled:s}=r.open;(!i.open||i.open.options!=a)&&(this.range=c_(a.length,o,t.state.facet(Si).maxRenderedOptions),this.showOptions(a,r.id)),this.updateSel(),s!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(t){let n=this.tooltipClass(t);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),n=t.open;if((n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=c_(n.options.length,n.selected,this.view.state.facet(Si).maxRenderedOptions),this.showOptions(n.options,t.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let a=typeof i=="string"?document.createTextNode(i):i(r);if(!a)return;"then"in a?a.then(o=>{o&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(o,r)}).catch(o=>Ea(this.view.state,o,"completion info")):this.addInfoPane(a,r)}}addInfoPane(t,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",t.nodeType!=null)r.appendChild(t),this.infoDestroy=null;else{let{dom:i,destroy:a}=t;r.appendChild(i),this.infoDestroy=a||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==t?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&AFe(this.list,n),n}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),a=this.space;if(!a){let o=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return i.top>Math.min(a.bottom,n.bottom)-10||i.bottom<Math.max(a.top,n.top)+10?null:this.view.state.facet(Si).positionInfo(this.view,n,i,r,a,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",o=>{o.target==i&&o.preventDefault()});let a=null;for(let o=r.from;o<r.to;o++){let{completion:s,match:l}=t[o],{section:c}=s;if(c){let d=typeof c=="string"?c:c.name;if(d!=a&&(o>r.from||r.from==0))if(a=d,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let h=i.appendChild(document.createElement("completion-section"));h.textContent=d}}const u=i.appendChild(document.createElement("li"));u.id=n+"-"+o,u.setAttribute("role","option");let O=this.optionClass(s);O&&(u.className=O);for(let d of this.optionContent){let h=d(s,this.view.state,this.view,l);h&&u.appendChild(h)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function zFe(e,t){return n=>new CFe(n,e,t)}function AFe(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function QZ(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function UFe(e,t){let n=[],r=null,i=c=>{n.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let O=typeof u=="string"?u:u.name;r.some(d=>d.name==O)||r.push(typeof u=="string"?{name:O}:u)}},a=t.facet(Si);for(let c of e)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let O of c.result.options)i(new wZ(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,h=a.filterStrict?new EFe(O):new RFe(O);for(let p of c.result.options)if(d=h.match(p.label)){let m=p.displayLabel?u?u(p,d.matched):[]:d.matched;i(new wZ(p,c.source,m,d.score+(p.boost||0)))}}}if(r){let c=Object.create(null),u=0,O=(d,h)=>{var p,m;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((m=h.rank)!==null&&m!==void 0?m:1e9)||(d.name<h.name?-1:1)};for(let d of r.sort(O))u-=1e5,c[d.name]=u;for(let d of n){let{section:h}=d.completion;h&&(d.score+=c[typeof h=="string"?h:h.name])}}let o=[],s=null,l=a.compareCompletions;for(let c of n.sort((u,O)=>O.score-u.score||l(u.completion,O.completion))){let u=c.completion;!s||s.label!=u.label||s.detail!=u.detail||s.type!=null&&u.type!=null&&s.type!=u.type||s.apply!=u.apply||s.boost!=u.boost?o.push(c):QZ(c.completion)>QZ(s)&&(o[o.length-1]=c),s=c.completion}return o}class dh{constructor(t,n,r,i,a,o){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=a,this.disabled=o}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new dh(this.options,kZ(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(c=>c.isPending))return i.setDisabled();let s=UFe(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Si).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<s.length;u++)if(s[u].completion==c){l=u;break}}return new dh(s,kZ(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:IFe,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new dh(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new dh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Lw{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new Lw(GFe,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Si),a=(r.override||n.languageDataAt("autocomplete",hd(n)).map(XFe)).map(l=>(this.active.find(u=>u.source==l)||new Yo(l,this.active.some(u=>u.state!=0)?1:0)).update(t,r));a.length==this.active.length&&a.every((l,c)=>l==this.active[c])&&(a=this.active);let o=this.open,s=t.effects.some(l=>l.is(Iz));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!WFe(a,this.active)||s?o=dh.build(a,n,this.id,o,r,s):o&&o.disabled&&!a.some(l=>l.isPending)&&(o=null),!o&&a.every(l=>!l.isPending)&&a.some(l=>l.hasResult())&&(a=a.map(l=>l.hasResult()?new Yo(l.source,0):l));for(let l of t.effects)l.is(Mde)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new Lw(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?YFe:NFe}}function WFe(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}const YFe={"aria-autocomplete":"list"},NFe={};function kZ(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const GFe=[];function Vde(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(Zz);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class Yo{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=Vde(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Yo(i.source,0)),r&4&&i.state==0&&(i=new Yo(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(Mw))i=new Yo(i.source,1,a.value);else if(a.is(o$))i=new Yo(i.source,0);else if(a.is(Iz))for(let o of a.value)o.source==i.source&&(i=o);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(hd(t.state))}}class Ph extends Yo{constructor(t,n,r,i,a,o){super(t,3,n),this.limit=r,this.result=i,this.from=a,this.to=o}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let a=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),s=hd(t.state);if(s>o||!i||n&2&&(hd(t.startState)==this.from||s<this.limit))return new Yo(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return ZFe(i.validFor,t.state,a,o)?new Ph(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new Gz(t.state,s,!1)))?new Ph(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:hd(t.state)):new Yo(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Ph(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Yo(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function ZFe(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Dde(e,!0).test(i)}const Iz=pn.define({map(e,t){return e.map(n=>n.map(t))}}),Mde=pn.define(),_a=Wa.define({create(){return Lw.start()},update(e,t){return e.update(t)},provide:e=>[Cz.from(e,t=>t.tooltip),vt.contentAttributes.from(e,t=>t.attrs)]});function Dz(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(_a).active.find(i=>i.source==t.source);return r instanceof Ph?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},TFe(e.state,n,r.from,r.to)),{annotations:Zz.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const IFe=zFe(_a,Dz);function ob(e,t="option"){return n=>{let r=n.state.field(_a,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Si).interactionDelay)return!1;let i=1,a;t=="page"&&(a=gde(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector("li").offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t=="page"?0:o-1:s>=o&&(s=t=="page"?o-1:0),n.dispatch({effects:Mde.of(s)}),!0}}const DFe=e=>{let t=e.state.field(_a,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Si).interactionDelay?!1:Dz(e,t.open.options[t.open.selected])},PZ=e=>e.state.field(_a,!1)?(e.dispatch({effects:Mw.of(!0)}),!0):!1,VFe=e=>{let t=e.state.field(_a,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:o$.of(null)}),!0)};class MFe{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const LFe=50,FFe=1e3,BFe=pi.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(_a).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(_a),n=e.state.facet(Si);if(!e.selectionSet&&!e.docChanged&&e.startState.field(_a)==t)return;let r=e.transactions.some(a=>{let o=Vde(a,n);return o&8||(a.selection||a.docChanged)&&!(o&3)});for(let a=0;a<this.running.length;a++){let o=this.running[a];if(r||o.context.abortOnDocChange&&e.docChanged||o.updates.length+e.transactions.length>LFe&&Date.now()-o.time>FFe){for(let s of o.context.abortListeners)try{s()}catch(l){Ea(this.view.state,l)}o.context.abortListeners=null,this.running.splice(a--,1)}else o.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(a=>a.effects.some(o=>o.is(Mw)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(a=>a.isPending&&!this.running.some(o=>o.active.source==a.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let a of e.transactions)a.isUserEvent("input.type")?this.composing=2:this.composing==2&&a.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(_a);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Si).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=hd(t),r=new Gz(t,n,e.explicit,this.view),i=new MFe(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(a=>{i.context.aborted||(i.done=a||null,this.scheduleAccept())},a=>{this.view.dispatch({effects:o$.of(null)}),Ea(this.view.state,a)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Si).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Si),r=this.view.state.field(_a);for(let i=0;i<this.running.length;i++){let a=this.running[i];if(a.done===void 0)continue;if(this.running.splice(i--,1),a.done){let s=hd(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new Ph(a.active.source,a.active.explicit,l,a.done,a.done.from,(e=a.done.to)!==null&&e!==void 0?e:s);for(let u of a.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let o=r.active.find(s=>s.source==a.active.source);if(o&&o.isPending)if(a.done==null){let s=new Yo(a.active.source,0);for(let l of a.updates)s=s.update(l,n);s.isPending||t.push(s)}else this.startQuery(o)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:Iz.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(_a,!1);if(t&&t.tooltip&&this.view.state.facet(Si).closeOnBlur){let n=t.open&&gde(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:o$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Mw.of(!1)}),20),this.composing=0}}}),HFe=typeof navigator=="object"&&/Win/.test(navigator.platform),KFe=uO.highest(vt.domEventHandlers({keydown(e,t){let n=t.state.field(_a,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(HFe&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(o=>o.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&Dz(t,r),!1}})),Lde=vt.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class JFe{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class Vz{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Ei.TrackDel),r=t.mapPos(this.to,1,Ei.TrackDel);return n==null||r==null?null:new Vz(this.field,n,r)}}class Mz{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],a=t.doc.lineAt(n),o=/^\s*/.exec(a.text)[0];for(let l of this.lines){if(r.length){let c=o,u=/^\t*/.exec(l)[0].length;for(let O=0;O<u;O++)c+=t.facet(TQ);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let s=this.fieldPositions.map(l=>new Vz(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:s}}static parse(t){let n=[],r=[],i=[],a;for(let o of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(o);){let s=a[1]?+a[1]:null,l=a[2]||a[3]||"",c=-1,u=l.replace(/\\[{}]/g,O=>O[1]);for(let O=0;O<n.length;O++)(s!=null?n[O].seq==s:u&&n[O].name==u)&&(c=O);if(c<0){let O=0;for(;O<n.length&&(s==null||n[O].seq!=null&&n[O].seq<s);)O++;n.splice(O,0,{seq:s,name:u}),c=O;for(let d of i)d.field>=c&&d.field++}i.push(new JFe(c,r.length,a.index,a.index+u.length)),o=o.slice(0,a.index)+l+o.slice(a.index+a[0].length)}o=o.replace(/\\([{}])/g,(s,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(o)}return new Mz(r,i)}}let eBe=Ft.widget({widget:new class extends Dc{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),tBe=Ft.mark({class:"cm-snippetField"});class tm{constructor(t,n){this.ranges=t,this.active=n,this.deco=Ft.set(t.map(r=>(r.from==r.to?eBe:tBe).range(r.from,r.to)))}map(t){let n=[];for(let r of this.ranges){let i=r.map(t);if(!i)return null;n.push(i)}return new tm(n,this.active)}selectionInsideField(t){return t.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const Ay=pn.define({map(e,t){return e&&e.map(t)}}),nBe=pn.define(),s$=Wa.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Ay))return n.value;if(n.is(nBe)&&e)return new tm(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>vt.decorations.from(e,t=>t?t.deco:Ft.none)});function Lz(e,t){return Ue.create(e.filter(n=>n.field==t).map(n=>Ue.range(n.from,n.to)))}function rBe(e){let t=Mz.parse(e);return(n,r,i,a)=>{let{text:o,ranges:s}=t.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:a==l.from?l.to:a,insert:zn.of(o)},scrollIntoView:!0,annotations:r?[Zz.of(r),ji.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=Lz(s,0)),s.some(u=>u.field>0)){let u=new tm(s,0),O=c.effects=[Ay.of(u)];n.state.field(s$,!1)===void 0&&O.push(pn.appendConfig.of([s$,lBe,cBe,Lde]))}n.dispatch(n.state.update(c))}}function Fde(e){return({state:t,dispatch:n})=>{let r=t.field(s$,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(o=>o.field==i+e);return n(t.update({selection:Lz(r.ranges,i),effects:Ay.of(a?null:new tm(r.ranges,i)),scrollIntoView:!0})),!0}}const iBe=({state:e,dispatch:t})=>e.field(s$,!1)?(t(e.update({effects:Ay.of(null)})),!0):!1,aBe=Fde(1),oBe=Fde(-1),sBe=[{key:"Tab",run:aBe,shift:oBe},{key:"Escape",run:iBe}],_Z=st.define({combine(e){return e.length?e[0]:sBe}}),lBe=uO.highest(kQ.compute([_Z],e=>e.facet(_Z)));function ir(e,t){return Object.assign(Object.assign({},t),{apply:rBe(e)})}const cBe=vt.domEventHandlers({mousedown(e,t){let n=t.state.field(s$,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(a=>a.from<=r&&a.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:Lz(n.ranges,i.field),effects:Ay.of(n.ranges.some(a=>a.field>i.field)?new tm(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),l$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},nd=pn.define({map(e,t){let n=t.mapPos(e,-1,Ei.TrackAfter);return n??void 0}}),Fz=new class extends Sd{};Fz.startSide=1;Fz.endSide=-1;const Bde=Wa.define({create(){return hn.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of t.effects)n.is(nd)&&(e=e.update({add:[Fz.range(n.value,n.value+1)]}));return e}});function ltn(){return[OBe,Bde]}const u_="()[]{}<>«»»«[]{}";function Hde(e){for(let t=0;t<u_.length;t+=2)if(u_.charCodeAt(t)==e)return u_.charAt(t+1);return nOe(e<128?e:e+1)}function Kde(e,t){return e.languageDataAt("closeBrackets",t)[0]||l$}const uBe=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),OBe=vt.inputHandler.of((e,t,n,r)=>{if((uBe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&ic(io(r,0))==1||t!=i.from||n!=i.to)return!1;let a=fBe(e.state,r);return a?(e.dispatch(a),!0):!1}),dBe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Kde(e,e.selection.main.head).brackets||l$.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=hBe(e.doc,o.head);for(let l of r)if(l==s&&qQ(e.doc,o.head)==Hde(io(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ue.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},ctn=[{key:"Backspace",run:dBe}];function fBe(e,t){let n=Kde(e,e.selection.main.head),r=n.brackets||l$.brackets;for(let i of r){let a=Hde(io(i,0));if(t==i)return a==i?gBe(e,i,r.indexOf(i+i+i)>-1,n):pBe(e,i,a,n.before||l$.before);if(t==a&&Jde(e,e.selection.main.from))return mBe(e,i,a)}return null}function Jde(e,t){let n=!1;return e.field(Bde).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function qQ(e,t){let n=e.sliceString(t,t+2);return n.slice(0,ic(io(n,0)))}function hBe(e,t){let n=e.sliceString(t-2,t);return ic(io(n,0))==n.length?n:n.slice(1)}function pBe(e,t,n,r){let i=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:nd.of(o.to+t.length),range:Ue.range(o.anchor+t.length,o.head+t.length)};let s=qQ(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:nd.of(o.head+t.length),range:Ue.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function mBe(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&qQ(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ue.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function gBe(e,t,n,r){let i=r.stringPrefixes||l$.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:nd.of(s.to+t.length),range:Ue.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=qQ(e.doc,l),u;if(c==t){if(TZ(e,l))return{changes:{insert:t+t,from:l},effects:nd.of(l+t.length),range:Ue.cursor(l+t.length)};if(Jde(e,l)){let d=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+d.length,insert:d},range:Ue.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=XZ(e,l-2*t.length,i))>-1&&TZ(e,u))return{changes:{insert:t+t+t+t,from:l},effects:nd.of(l+t.length),range:Ue.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=Wo.Word&&XZ(e,l,i)>-1&&!$Be(e,l,t,i))return{changes:{insert:t+t,from:l},effects:nd.of(l+t.length),range:Ue.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function TZ(e,t){let n=An(e).resolveInner(t+1);return n.parent&&n.from==t}function $Be(e,t,n,r){let i=An(e).resolveInner(t,-1),a=r.reduce((o,s)=>Math.max(o,s.length),0);for(let o=0;o<5;o++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),l=s.indexOf(n);if(!l||l>-1&&r.indexOf(s.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>n.length+l;){if(e.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function XZ(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Wo.Word)return t;for(let i of n){let a=t-i.length;if(e.sliceDoc(a,t)==i&&r(e.sliceDoc(a-1,a))!=Wo.Word)return a}return-1}function utn(e={}){return[KFe,_a,Si.of(e),BFe,vBe,Lde]}const yBe=[{key:"Ctrl-Space",run:PZ},{mac:"Alt-`",run:PZ},{key:"Escape",run:VFe},{key:"ArrowDown",run:ob(!0)},{key:"ArrowUp",run:ob(!1)},{key:"PageDown",run:ob(!0,"page")},{key:"PageUp",run:ob(!1,"page")},{key:"Enter",run:DFe}],vBe=uO.highest(kQ.computeN([Si],e=>e.facet(Si).defaultKeymap?[yBe]:[]));class Fw{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new Fw(t,n,r,o,a,[],[])}constructor(t,n,r,i,a,o,s){this.type=t,this.value=n,this.from=r,this.hash=i,this.end=a,this.children=o,this.positions=s,this.hashProp=[[qt.contextHash,i]]}addChild(t,n){t.prop(qt.contextHash)!=this.hash&&(t=new en(t.type,t.children,t.positions,t.length,this.hashProp)),this.children.push(t),this.positions.push(n)}toTree(t,n=this.end){let r=this.children.length-1;return r>=0&&(n=Math.max(n,this.positions[r]+this.children[r].length+this.from)),new en(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new en(ti.none,i,a,o,this.hashProp)})}}var Ye;(function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"})(Ye||(Ye={}));class bBe{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let wBe=class{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let t=this.skipSpace(this.basePos);this.indent=this.countIndent(t,this.pos,this.indent),this.pos=t,this.next=t==this.text.length?-1:this.text.charCodeAt(t)}skipSpace(t){return f0(this.text,t)}reset(t){for(this.text=t,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(t){this.basePos=t,this.baseIndent=this.countIndent(t,this.pos,this.indent)}moveBaseColumn(t){this.baseIndent=t,this.basePos=this.findColumn(t)}addMarker(t){this.markers.push(t)}countIndent(t,n=0,r=0){for(let i=n;i<t;i++)r+=this.text.charCodeAt(i)==9?4-r%4:1;return r}findColumn(t){let n=0;for(let r=0;n<this.text.length&&r<t;n++)r+=this.text.charCodeAt(n)==9?4-r%4:1;return n}scrub(){if(!this.baseIndent)return this.text;let t="";for(let n=0;n<this.basePos;n++)t+=" ";return t+this.text.slice(this.basePos)}};function RZ(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==Ye.OrderedList?Kz:Hz)(n,t,!1);return r>0&&(e.type!=Ye.BulletList||Bz(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const efe={[Ye.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(cn(Ye.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Jo(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Ye.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Ye.OrderedList]:RZ,[Ye.BulletList]:RZ,[Ye.Document](){return!0}};function Jo(e){return e==32||e==9||e==10||e==13}function f0(e,t=0){for(;t<e.length&&Jo(e.charCodeAt(t));)t++;return t}function EZ(e,t,n){for(;t>n&&Jo(e.charCodeAt(t-1));)t--;return t}function tfe(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function nfe(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function Bz(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let i=e.pos+1;i<e.text.length;i++){let a=e.text.charCodeAt(i);if(a==e.next)r++;else if(!Jo(a))return-1}return n&&e.next==45&&afe(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(cfe.SetextHeading)>-1||r<3?-1:1}function rfe(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function Hz(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Jo(e.text.charCodeAt(e.pos+1)))&&(!n||rfe(t,Ye.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Kz(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){r++;if(r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!Jo(e.text.charCodeAt(r+1))||n&&!rfe(t,Ye.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function ife(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function afe(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&Jo(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const l3=/^[ \t]*$/,ofe=/-->/,sfe=/\?>/,c3=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,ofe],[/^\s*<\?/,sfe],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,l3],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,l3]];function lfe(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=c3.length-(n?1:0);i<a;i++)if(c3[i][0].test(r))return i;return-1}function qZ(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function jO(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Ye.CodeText?e[r].to=n:e.push(cn(Ye.CodeText,t,n))}const sb={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(jO(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){jO(s,e.lineStart-1,e.lineStart);for(let l of t.markers)s.push(l)}else{if(t.indent<n)break;{if(s.length){for(let c of s)c.type==Ye.CodeText?jO(o,c.from,c.to):o.push(c);s=[]}jO(o,e.lineStart-1,e.lineStart);for(let c of t.markers)o.push(c);a=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<a&&jO(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Ye.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Ye.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=tfe(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=EZ(t.text,t.text.length,o),l=[cn(Ye.CodeMark,r,r+a)];o<s&&l.push(cn(Ye.CodeInfo,e.lineStart+o,e.lineStart+s));for(let c=!0;e.nextLine()&&t.depth>=e.stack.length;c=!1){let u=t.pos;if(t.indent-t.baseIndent<4)for(;u<t.text.length&&t.text.charCodeAt(u)==i;)u++;if(u-t.pos>=a&&t.skipSpace(u)==t.text.length){for(let O of t.markers)l.push(O);l.push(cn(Ye.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||jO(l,e.lineStart-1,e.lineStart);for(let h of t.markers)l.push(h);let O=e.lineStart+t.basePos,d=e.lineStart+t.text.length;O<d&&jO(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Ye.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=nfe(t);return n<0?!1:(e.startContext(Ye.Blockquote,t.pos),e.addNode(Ye.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(Bz(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Ye.HorizontalRule,n),!0},BulletList(e,t){let n=Hz(t,e,!1);if(n<0)return!1;e.block.type!=Ye.BulletList&&e.startContext(Ye.BulletList,t.basePos,t.next);let r=qZ(t,t.pos+1);return e.startContext(Ye.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ye.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=Kz(t,e,!1);if(n<0)return!1;e.block.type!=Ye.OrderedList&&e.startContext(Ye.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=qZ(t,t.pos+n);return e.startContext(Ye.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ye.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=ife(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=EZ(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!Jo(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Ye.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Ye.HeaderMark,o-r,a-r);let l=s.finish(Ye.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=lfe(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=c3[n][1],a=[],o=i!=l3;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let c of t.markers)a.push(c)}o&&e.nextLine();let s=i==ofe?Ye.CommentBlock:i==sfe?Ye.ProcessingInstructionBlock:Ye.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class xBe{constructor(t){this.stage=0,this.elts=[],this.pos=0,this.start=t.start,this.advance(t.content)}nextLine(t,n,r){if(this.stage==-1)return!1;let i=r.content+`
787
787
  `+n.scrub(),a=this.advance(i);return a>-1&&a<i.length?this.complete(t,r,a):!1}finish(t,n){return(this.stage==2||this.stage==3)&&f0(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,cn(Ye.LinkReference,this.start,this.start+r,this.elts)),!0}nextStage(t){return t?(this.pos=t.to-this.start,this.elts.push(t),this.stage++,!0):(t===!1&&(this.stage=-1),!1)}advance(t){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage($fe(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(cn(Ye.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(mfe(t,f0(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=f0(t,this.pos),r=0;if(n>this.pos){let i=gfe(t,n,this.start);if(i){let a=O_(t,i.to-this.start);a>0&&(this.nextStage(i),r=a)}}return r||(r=O_(t,this.pos)),r>0&&r<t.length?r:-1}else return O_(t,this.pos)}}}function O_(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!Jo(n))return-1}return t}class SBe{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:afe(n),a=n.next;if(i<0)return!1;let o=cn(Ye.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,cn(a==61?Ye.SetextHeading1:Ye.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),o])),!0}finish(){return!1}}const cfe={LinkReference(e,t){return t.content.charCodeAt(0)==91?new xBe(t):null},SetextHeading(){return new SBe}},QBe=[(e,t)=>ife(t)>=0,(e,t)=>tfe(t)>=0,(e,t)=>nfe(t)>=0,(e,t)=>Hz(t,e,!0)>=0,(e,t)=>Kz(t,e,!0)>=0,(e,t)=>Bz(t,e,!0)>=0,(e,t)=>lfe(t,e,!0)>=0],kBe={text:"",end:0};class PBe{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new wBe,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=i[i.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=i[0].from,this.block=Fw.create(Ye.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new RBe(r,n):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:t}=this;for(;;){for(let r=0;;){let i=t.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;r<t.markers.length&&(!i||t.markers[r].from<i.end);){let a=t.markers[r++];this.addNode(a.type,a.from,a.to)}if(!i)break;this.finishContext()}if(t.pos<t.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(t.basePos))return null;e:for(;;){for(let r of this.parser.blockParsers)if(r){let i=r(this,t);if(i!=!1){if(i==!0)return null;t.forward();continue e}}break}let n=new bBe(this.lineStart+t.pos,t.text.slice(t.pos));for(let r of this.parser.leafBlockParsers)if(r){let i=r(this,n);i&&n.parsers.push(i)}e:for(;this.nextLine()&&t.pos!=t.text.length;){if(t.indent<t.baseIndent+4){for(let r of this.parser.endLeafBlock)if(r(this,t,n))break e}for(let r of n.parsers)if(r.nextLine(this,t,n))return null;n.content+=`
788
788
  `+t.scrub();for(let r of t.markers)n.marks.push(r)}return this.finishLeaf(n),null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}reuseFragment(t){if(!this.fragments.moveTo(this.absoluteLineStart+t,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let n=this.fragments.takeNodes(this);return n?(this.absoluteLineStart+=n,this.lineStart=yfe(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(t=this.depth-1){return this.parser.nodeSet.types[this.stack[t].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(t){let n=kBe;if(n.end=t,t>=this.to)n.text="";else if(n.text=this.lineChunkAt(t),n.end+=n.text.length,this.ranges.length>1){let r=this.absoluteLineStart,i=this.rangeI;for(;this.ranges[i].to<n.end;){i++;let a=this.ranges[i].from,o=this.lineChunkAt(a);n.end=a+o.length,n.text=n.text.slice(0,this.ranges[i-1].to-r)+o,r=n.end-n.text.length}}return n}readLine(){let{line:t}=this,{text:n,end:r}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=r,t.reset(n);t.depth<this.stack.length;t.depth++){let i=this.stack[t.depth],a=this.parser.skipContextMarkup[i.type];if(!a)throw new Error("Unhandled block context "+Ye[i.type]);if(!a(i,this,t))break;t.forward()}}lineChunkAt(t){let n=this.input.chunk(t),r;if(this.input.lineChunks)r=n==`
789
789
  `?"":n;else{let i=n.indexOf(`
@@ -817,7 +817,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
817
817
  `,o.end),l=t.slice(o.end,s===-1?t.length:s);if(Kbt.test(l))return Ta;const c=l.length-l.replace(Jbt,"").length,u={start:o.start,end:o.end+c},O=e.typingAt;if(O!==null){const d=O+fp(e.value).length;return n<O||n>d?{arm:u,typingAt:null,value:""}:{arm:u,typingAt:O,value:e.value}}return a&&n===u.end&&t[n-1]===dk?{arm:u,typingAt:n,value:""}:{arm:u,typingAt:null,value:""}}const Ro=e=>e.typingAt!==null,o1t=e=>e.arm!==null;function sf(e){return e.typingAt===null?null:{start:e.typingAt,end:e.typingAt+fp(e.value).length}}function J9(e,t,n,r){const i=sf(e);if(i===null)return null;const{top:a,bottom:o,inserted:s}=r;if(a>i.end||o<i.start)return null;const l=fp(e.value),c=Oj(a-i.start,0,l.length),u=Oj(o-i.start,0,l.length),O=fp(s),d=[...l.slice(0,c),...O,...l.slice(u)].join(""),h=a+O.length,p=t.slice(0,a)+Jye.repeat(O.length)+t.slice(h),m=O.length-s.length,g=n>=h?n+m:n;return{buffer:p,caret:g,capture:{...e,value:d}}}function oL(e,t,n,r){const i={capture:e,buffer:t.slice(0,n.start)+r+t.slice(n.end),caret:n.start+r.length},a=Ro(e)&&e.value===""&&r.startsWith("-");if(Ro(e)&&(a||r.includes(`
818
818
  `))){const o=Sx(e);return r.includes(`
819
819
  `)?{...i,capture:o}:{...i,capture:ph(o,i.buffer,i.caret,"typing")}}return J9(e,i.buffer,i.caret,{top:n.start,bottom:n.end,inserted:r})??i}function Sx(e){return Ro(e)?{arm:e.arm,typingAt:null,value:""}:e}function s1t(e,t){let n=0;const r=Math.min(e.length,t.length);for(;n<r&&e[n]===t[n];)n++;let i=e.length,a=t.length;for(;i>n&&a>n&&e[i-1]===t[a-1];)i--,a--;return{top:n,bottom:i,inserted:t.slice(n,a)}}function l1t(e,t,n,r,i){const a=s1t(t,n),o=sf(e);let s={capture:e,buffer:n,caret:r};if(a.inserted!==""&&o!==null&&a.top<=o.end&&a.bottom>=o.start)s={capture:Sx(e),buffer:n,caret:r};else{const l=J9(e,n,r,a);l?s=l:Ro(e)&&a.inserted.includes(`
820
- `)&&(s={capture:Sx(e),buffer:n,caret:r})}return{...s,capture:ph(s.capture,s.buffer,s.caret,i)}}function c1t(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=sf(t);if(o===null||t.value==="")return{minted:!1,capture:t,buffer:n,caret:r,payload:null};const s=t.arm===null?o.start:t.arm.start,l=lve(i,t.value),c=l+dk,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Ta,buffer:u,caret:s+c.length,payload:{index:i,key:uve(a,e.draw),value:t.value,marker:l}}}const u1t=e=>Ro(e)&&e.value!=="";function O1t(e,t){const n=sf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,token:null};const r=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:Ta,buffer:t.slice(0,n.start)+t.slice(n.end),caret:n.start,token:{span:{start:r,end:n.start},text:t.slice(r,n.start)}}}function d1t(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function f1t(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=sf(e);return o===null?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:n.start<=o.start?{kind:"passthrough",capture:{...e,typingAt:o.start+r.length},buffer:i,caret:a,payload:null}:n.start>=o.end?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:{kind:"passthrough",capture:Sx(e),buffer:i,caret:a,payload:null}}function h1t(e){const{capture:t,buffer:n,caret:r,pasted:i}=e;if(t.arm===null)return null;if(t.typingAt!==null&&t.value!==""){if(i==="")return null;const u=J9(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=vn(i);if(!a)return i===""?null:f1t(t,n,e.selection,i);const o=t.arm,s=lve(e.index,a),l=s+dk,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Ta,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:uve(e.taken,e.draw),value:a,marker:s}}}const sve=e=>`${t1t(e)} chars`,lve=(e,t)=>`[Credential #${e}, ${sve(t)}]`;function p1t(e){dl.lastIndex=0;const t=dl.exec(e);return dl.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function m1t(e){dl.lastIndex=0;const t=dl.exec(e);if(dl.lastIndex=0,t===null||t[0]!==e)return null;const n=Number.parseInt(t[1],10);return{index:n,label:`#${n}`,chars:Number.parseInt(t[2],10)}}function Fy(e,t){if(p1t(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const RT=/\[credential ([A-Za-z_][A-Za-z0-9_]*) \((\d+) chars\) \u2014 available to bash and eval as \$([A-Za-z_][A-Za-z0-9_]*); its value cannot be read\]/y,ET=/\[credential NOT stored \u2014 [^\]\n]*\]/y,qT=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,g1t=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&uj.test(t[1])?t[1]:""};function $1t(e,t){if(e.charCodeAt(t)!==91)return null;RT.lastIndex=t;const n=RT.exec(e);if(RT.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};ET.lastIndex=t;const r=ET.exec(e);if(ET.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};qT.lastIndex=t;const i=qT.exec(e);return qT.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:g1t(i[0])}:null}function fk(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=$1t(e,r);if(i===null){r++;continue}r>n&&t.push({kind:"text",text:e.slice(n,r)}),t.push(i),r+=i.text.length,n=r}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}function sL(e,t){const n=[];for(const r of t){const i=Fy(e,r);i!==null&&n.push({at:i.start,payload:r})}return n.sort((r,i)=>r.at-i.at).map(r=>r.payload)}function y1t(e,t=""){return e==="unconfirmed"?t?`[credential unconfirmed — it may be held as $${t}, so check list_variables before assuming it is missing]`:"[credential unconfirmed — the session may hold it, so check list_variables before assuming it is missing]":e==="unreachable"?"[credential NOT stored — the session could not be reached; try again]":e==="rejected-key"?"[credential NOT stored — the store rejected its name]":"[credential NOT stored — its value did not survive; ask the operator to paste it again]"}const v1t=e=>`[credential ${e.key} (${sve(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function b1t(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=Fy(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of rve(e,r))i.push({span:o,payload:null});let a=e;for(const{span:o,payload:s}of i.sort((l,c)=>c.span.start-l.span.start)){const l=s===null?"lost":n.get(s.index),c=s===null||l!==void 0?y1t(l??"lost",s?.key):v1t(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const w1t=(e,t,n)=>`Removed ${e} (credential #${t}) from this message. Its value is gone — press ${n} to put it back, or paste it again after /credential to reuse it.`,x1t=e=>`Remove credential #${e}`,S1t=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,Q1t=(e,t,n)=>w1t(e,t,n),k1t="Undo",P1t=e=>`Credential #${e} removed`,_1t=e=>e.unredacted!==null?e.unredacted:e.armed?C1t:e.cleared!==null?Q1t(e.cleared.key,e.cleared.index,e.undoCap):null;function T1t(e){const{buffer:t,payload:n}=e,r=Fy(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===dk?r.end+1:r.end;return{cleared:!0,buffer:t.slice(0,r.start)+t.slice(i),caret:r.start,removed:t.slice(r.start,i)}}function X1t(e){const{buffer:t,cleared:n}=e;return n.removed===""||t!==n.buffer?null:{buffer:t.slice(0,n.caret)+n.removed+t.slice(n.caret),caret:n.caret+n.removed.length}}const lL=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function cL(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be stored (${[...e].sort().join(", ")}); the agent has been told so. Paste the value again after /credential to retry.`}const R1t="store unconfirmed",E1t="Credential store unconfirmed",q1t=e=>e===""?E1t:`${e} · ${R1t}`,cve="Paste the value again after /credential to store it again.",j1t=e=>`${e} ${cve}`;function uL(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be confirmed as stored (${[...e].sort().join(", ")}); the agent has been told to check before using it. ${cve}`}const C1t="armed — add a space, then type or paste the secret",z1t="masked as you type — Enter makes a pill, Esc twice discards",A1t="masked — Enter opens the credential picker; type or paste the secret into this span",U1t="Esc again discards it — still masked, Enter makes a pill",W1t="credential discarded — nothing was stored or sent",Y1t="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",N1t=e=>`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`;function G1t(e,t){const n=sf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const OL=(e,t)=>e&&e.over===t?e.chars:null,Z1t=e=>{const t=Math.floor(4294967296/e)*e,n=new Uint32Array(1);for(;;)if(globalThis.crypto.getRandomValues(n),n[0]<t)return n[0]%e},I1t=16,D1t=16;function uve(e=[],t=Z1t){const n=new Set(e);for(let r=0;r<I1t;r++){const i=aL+dL(8,t);if(!n.has(i))return i}return aL+dL(D1t,t)}const dL=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=iL[t(iL.length)];return n},V1t=8,M1t=256,L1t=/^[/@$#]/,F1t=/^\w+:\/\//,B1t=/^[A-Za-z]+$/,H1t=/^\d+$/,K1t=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],J1t=3,ewt=20,twt=/^[A-Za-z0-9_\-+/=.]+$/,nwt=new RegExp(`^[^${Qc}@]+@[^${Qc}@]+\\.[A-Za-z]{2,}$`),rwt=/^[\w.-]+(?:\/[\w.-]+)+$/,iwt=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,awt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,owt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,swt=/^[\w.-]+:\d{2,5}$/,lwt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,cwt=/^[a-z]+(?:_[a-z]+)+$/,uwt=/^[a-z]+(?:-[a-z]+)+$/,Owt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,dwt=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,fwt=/\d{4,}/,hwt=e=>{const t=e.trim();return t.length<V1t||t.length>M1t||ks.test(t)||L1t.test(t)||F1t.test(t)||Iae(t)!==null||nwt.test(t)||rwt.test(t)||iwt.test(t)||awt.test(t)||owt.test(t)||swt.test(t)||lwt.test(t)||cwt.test(t)||uwt.test(t)||Owt.test(t)||dwt.test(t)&&fwt.test(t)||B1t.test(t)||H1t.test(t)?!1:K1t.filter(r=>r.test(t)).length>=J1t?!0:t.length>=ewt&&twt.test(t)},Ove=E("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),dve=E("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),fve=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:o,style:s,small:l=!1})=>f.jsxs("span",{className:E("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?dve:Ove,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?f.jsx(Die,{"aria-hidden":"true",className:"size-3 shrink-0"}):f.jsx(FXe,{"aria-hidden":"true",className:"size-3 shrink-0"}),f.jsx("span",{className:"min-w-0 truncate",children:e}),t!==null&&f.jsx("span",{className:"shrink-0",children:`· ${t} chars`}),i&&f.jsx("button",{type:"button","aria-label":a,onClick:i,className:"pointer-events-auto -mr-1 flex shrink-0 cursor-pointer items-center rounded-xs p-0.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-offset-1! active:bg-sunken",children:f.jsx(zi,{"aria-hidden":"true",className:"size-3"})}),r&&f.jsx("span",{className:"sr-only",children:r})]}),x$="#lo-credential/",pwt=`${x$}unstored`,fL=`${x$}unconfirmed`,mwt=/^\d+$/,hve=e=>e.kind==="stored"?`${x$}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${fL}/${e.key}`:fL:pwt;function gwt(e){if(!e||!e.startsWith(x$))return null;const t=e.slice(x$.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return uj.test(a)?{kind:"unconfirmed",key:a}:null}const n=t.lastIndexOf("/");if(n===-1)return null;const r=t.slice(0,n),i=t.slice(n+1);return!uj.test(r)||!mwt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function hL(e,t){const n=gwt(e);if(n===null)return null;const r=fk(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return hve(i)!==e?null:n}const hk=()=>e=>{const t=n=>{if(!n.children)return;const r=[];let i=!1;for(const a of n.children){if(a.type!=="text"||typeof a.value!="string"){t(a),r.push(a);continue}const o=fk(a.value);if(o.length===1&&o[0].kind==="text"){r.push(a);continue}i=!0;for(const s of o){if(s.kind==="text"){r.push({type:"text",value:s.text});continue}r.push({type:"link",url:hve(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},$wt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?q1t(e.key):"Credential not stored",ywt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?j1t(t):t,vwt=({citation:e,title:t})=>f.jsx(fve,{tone:e.kind==="stored"?"live":"warning",label:$wt(e),chars:e.kind==="stored"?e.chars:null,title:ywt(e,t),className:"align-middle"}),bwt=(e,t)=>typeof t=="string"?hL(e,t):t==null?hL(e,""):null,wwt=e=>({href:t,title:n,children:r})=>{const i=bwt(t,r);if(i===null){const a=e;return f.jsx(a,{href:t,title:n,children:r})}return f.jsx(vwt,{citation:i,title:n})},pve=e=>oDe(e)?"artifact":e.startsWith("data:")?"data":e.startsWith("blob:")?"blob":e.startsWith("http://")||e.startsWith("https://")?"http":e.startsWith("file://")||e.startsWith("/")||e.startsWith("~")?"path":"other",mve=e=>{const t=pve(e);return t==="other"?"path":t},pL={id:"open-file",label:"Open file"},xwt={id:"show-in-canvas",label:"Show in canvas"},Swt={id:"save-as",label:"Save as…"},mL={id:"open-folder",label:"Open folder"},gL={id:"copy-file-path",label:"Copy file path"},dg={id:"copy-image",label:"Copy image"},Qwt={id:"copy-image-url",label:"Copy image URL"},kwt={id:"open-in-browser",label:"Open in browser"};function gve(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[xwt]:[],...a?[{id:"expand-image",label:"Expand image"}]:[]];switch(e){case"artifact":return[...o,...i?[pL,mL,gL]:[],Swt,...r==="video"||r==="audio"?[]:[dg]];case"path":return[...o,pL,mL,gL,...r==="video"||r==="audio"?[]:[dg]];case"data":return[...o,dg];case"blob":return[dg];case"http":return[...Pwt(n)?[dg]:[],Qwt,kwt];case"other":return[]}}const $ve=(e,t)=>gve(e,t).length>0;function Pwt(e){try{const t=new URL(e),n=t.hostname==="localhost"||t.hostname==="127.0.0.1";return t.protocol==="http:"&&n&&(t.port==="1111"||t.port==="8080")}catch{return!1}}const eA=e=>e.startsWith("file://")?e.slice(7):e;function _wt(e){const t=e.indexOf(",");if(t===-1)throw new Error("Malformed data URL");const n=e.slice(5,t),r=e.slice(t+1),i=n.split(";")[0]||"application/octet-stream";if(n.endsWith(";base64")){const s=atob(r),l=new Uint8Array(s.length);for(let c=0;c<s.length;c+=1)l[c]=s.charCodeAt(c);return new Blob([l],{type:i})}const a=decodeURIComponent(r),o=new Uint8Array(a.length);for(let s=0;s<a.length;s+=1)o[s]=a.charCodeAt(s);return new Blob([o],{type:i})}async function $L(e,t,n){if(e==="data")return _wt(t);if(e==="blob"){const o=Wse(n??t);if(o===null)throw new Error("These image bytes are not available in this window");return o}if(e==="http"){const o=await fetch(n??t);if(!o.ok)throw new Error(`The image server answered ${o.status}`);return o.blob()}const r=window.api?.readFileBytes;if(typeof r!="function")throw new Error("This window cannot read local files");const i=eA(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:g6(i)})}const Twt=e=>e.trim().toLowerCase()!=="image/png";async function Xwt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!Twt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await Rwt(t);if(n.naturalWidth===0||n.naturalHeight===0)throw new Error("This image could not be decoded for the clipboard");const r=document.createElement("canvas");r.width=n.naturalWidth,r.height=n.naturalHeight;const i=r.getContext("2d");if(i===null)throw new Error("This window cannot re-encode the image for the clipboard");i.drawImage(n,0,0);const a=await new Promise(o=>{r.toBlob(o,"image/png")});if(a===null)throw new Error("This image could not be re-encoded for the clipboard");return a}finally{URL.revokeObjectURL(t)}}function Rwt(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new Error("This image could not be decoded for the clipboard")),r.src=e})}const Ewt=6e4;function qwt(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),Ewt)}const L1=new Map;function jwt(e,t){const n=L1.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await Sc(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")return null;const a=y6(i.data,i.mimeType);return r.holders<=0?(xy(a),null):(Yse(t,a),a)}catch{return null}finally{L1.delete(t)}})(),L1.set(t,r),r.promise}class tA extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function yve(e,t){const n=v6(t),r=n?Wse(n):null;if(r)return r;const i=await Sc(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")throw i.status===404?new tA:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function Cwt(e){const t=L1.get(e);t&&(t.holders-=1)}function By(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?v6(e.attachment):null),[a,o]=$.useState(!1),s=t?.sessionId??null,l=t?.childId??null;$.useEffect(()=>{const u=e.attachment;if(n||!u||!s)return;let O=!0;const d=vw(u);if(d)return i(d),o(!1),()=>{O=!1,bw(u)};i(null),o(!1);let h=!0;return jwt({sessionId:s,childId:l},u).then(p=>{if(h=!1,!!O){if(!p){o(!0);return}i(vw(u))}}),()=>{O=!1,h&&Cwt(u),bw(u)}},[e.attachment,n,s,l]);const c=n??r;return c?{state:"ready",url:c}:e.attachment&&s&&!a?{state:"resolving"}:{state:"missing"}}function nA(e,t){return By(e,t)}const $tn=Object.freeze(Object.defineProperty({__proto__:null,AttachmentGoneError:tA,fetchAttachmentBlob:yve,useAttachmentSource:By,useAttachmentUrl:nA},Symbol.toStringTag,{value:"Module"})),zwt={"expand-image":f.jsx(mae,{"aria-hidden":"true"}),"open-file":f.jsx(gy,{"aria-hidden":"true"}),"show-in-canvas":f.jsx(pae,{"aria-hidden":"true"}),"save-as":f.jsx(my,{"aria-hidden":"true"}),"open-folder":f.jsx(Gh,{"aria-hidden":"true"}),"copy-file-path":f.jsx(NC,{"aria-hidden":"true"}),"copy-image":f.jsx(Vp,{"aria-hidden":"true"}),"copy-image-url":f.jsx(JXe,{"aria-hidden":"true"}),"open-in-browser":f.jsx(GC,{"aria-hidden":"true"})},yL=(e,t)=>t instanceof tA?`${e}: it is no longer in the session`:e,vve=({file:e,src:t,label:n,open:r,onOpenChange:i,onCloseAutoFocus:a,triggerTabIndex:o,resolvePath:s,missing:l,onShowInCanvas:c,mediaKind:u,onExpand:O,saveName:d,resolveBytes:h,tooltip:p="Image actions","aria-label":m})=>{const g=mve(e),y=gve(g,{canShowInCanvas:!!c,source:t??e,mediaKind:u,artifactPathActions:!!s,canExpand:!!O}).filter(Q=>(Q.id!=="save-as"||!!d)&&(!l||Q.id==="copy-file-path"));if(y.length===0)return null;const v=async(Q,P,T)=>{try{await navigator.clipboard.writeText(Q),wd(P)}catch(_){console.error(`${T}: `,_),Kr(T)}},x=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const Q=h?await h():await $L(g,e,t),P=await Xwt(Q);await navigator.clipboard.write([new ClipboardItem({[P.type]:P})]),wd("Image copied to clipboard")}catch(Q){console.error("Failed to copy image: ",Q),Kr(yL("Failed to copy image",Q))}},S=async()=>{try{const Q=h?await h():await $L(g,e,t);qwt(Q,d??"download")}catch(Q){console.error("Failed to save file: ",Q),Kr(yL("Failed to save file",Q))}},b=async Q=>{let P=eA(e);if(s&&["open-file","open-folder","copy-file-path"].includes(Q.id))try{P=await s()}catch{Kr(Y("ui.canvas.files.prepareError"));return}switch(Q.id){case"expand-image":O?.();return;case"open-file":rO(P);return;case"open-folder":B9(P);return;case"show-in-canvas":c?.();return;case"copy-file-path":v(P,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":x();return;case"save-as":S();return;case"copy-image-url":v(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":H9(t??e);return}},w=m??`Actions for ${n??"this image"}`;return f.jsxs(XC,{open:r,onOpenChange:i,children:[f.jsx(wt,{content:p,children:f.jsx(RC,{asChild:!0,children:f.jsx(Se,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":w,tabIndex:o,onClick:Q=>Q.stopPropagation(),children:f.jsx(kE,{"aria-hidden":"true"})})})}),f.jsxs(EC,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:Q=>Q.stopPropagation(),children:[s&&f.jsx("div",{role:"note",className:E("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:Y("ui.canvas.files.pathCopyNote")}),y.map(Q=>f.jsxs(rl,{onSelect:()=>b(Q),children:[zwt[Q.id],f.jsx("span",{children:Q.label})]},Q.id))]})]})},Awt=({src:e,alt:t,title:n,className:r})=>{const i=ck(),a=e??"",o=pve(a);if(o==="other")return f.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=$ve(o,{canShowInCanvas:s,source:a});return f.jsxs("span",{className:E("group/mdimg relative inline-block max-w-full"),children:[f.jsx("img",{src:e,alt:t,title:n,className:r}),l&&f.jsx("span",{"data-markdown-image":"",className:E("pointer-events-none absolute top-1 right-1 z-[2] opacity-0","transition-opacity duration-fast ease-out-quart","group-hover/mdimg:pointer-events-auto group-hover/mdimg:opacity-100","group-focus-within/mdimg:pointer-events-auto group-focus-within/mdimg:opacity-100","has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100"),children:f.jsx(vve,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||rO(eA(a))})}:void 0})})]})};function Uwt(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:a},exit:{mathFlow:i,mathFlowFence:r,mathFlowFenceMeta:n,mathFlowValue:s,mathText:o,mathTextData:s}};function e(l){const c={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[c]}},l)}function t(){this.buffer()}function n(){const l=this.resume(),c=this.stack[this.stack.length-1];c.type,c.meta=l}function r(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function i(l){const c=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c;const O=u.data.hChildren[0];O.type,O.tagName,O.children.push({type:"text",value:c}),this.data.mathFlowInside=void 0}function a(l){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},l),this.buffer()}function o(l){const c=this.resume(),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c,u.data.hChildren.push({type:"text",value:c})}function s(l){this.config.enter.data.call(this,l),this.config.exit.data.call(this,l)}}const Wwt={tokenize:Ywt,concrete:!0,name:"mathFlow"},vL={tokenize:Nwt,partial:!0};function Ywt(e,t,n){const r=this,i=r.events[r.events.length-1],a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let o=0;return s;function s(v){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(v)}function l(v){return v===36?(e.consume(v),o++,l):o<2?n(v):(e.exit("mathFlowFenceSequence"),Lt(e,c,"whitespace")(v))}function c(v){return v===null||gt(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||gt(v)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(v)):v===36?n(v):(e.consume(v),u)}function O(v){return e.exit("mathFlowFence"),r.interrupt?t(v):e.attempt(vL,d,g)(v)}function d(v){return e.attempt({tokenize:y,partial:!0},g,h)(v)}function h(v){return(a?Lt(e,p,"linePrefix",a+1):p)(v)}function p(v){return v===null?g(v):gt(v)?e.attempt(vL,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||gt(v)?(e.exit("mathFlowValue"),p(v)):(e.consume(v),m)}function g(v){return e.exit("mathFlow"),t(v)}function y(v,x,S){let b=0;return Lt(v,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function w(T){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),Q(T)}function Q(T){return T===36?(b++,v.consume(T),Q):b<o?S(T):(v.exit("mathFlowFenceSequence"),Lt(v,P,"whitespace")(T))}function P(T){return T===null||gt(T)?(v.exit("mathFlowFence"),x(T)):S(T)}}}function Nwt(e,t,n){const r=this;return i;function i(o){return o===null?t(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Gwt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:Zwt,previous:Iwt,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(m){return i.enter("mathText"),i.enter("mathTextSequence"),O(m)}function O(m){return m===36?(i.consume(m),s++,O):s<2&&!n?o(m):(i.exit("mathTextSequence"),d(m))}function d(m){return m===null?o(m):m===36?(c=i.enter("mathTextSequence"),l=0,p(m)):m===32?(i.enter("space"),i.consume(m),i.exit("space"),d):gt(m)?(i.enter("lineEnding"),i.consume(m),i.exit("lineEnding"),d):(i.enter("mathTextData"),h(m))}function h(m){return m===null||m===32||m===36||gt(m)?(i.exit("mathTextData"),d(m)):(i.consume(m),h)}function p(m){return m===36?(i.consume(m),l++,p):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(m)):(c.type="mathTextData",h(m))}}}function Zwt(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Iwt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function Dwt(e){return{flow:{36:Wwt},text:{36:Gwt()}}}const mh=36,bL=e=>e!==null&&e<-2,wL=e=>e===null||e===32||e<0,xL=e=>e!==null&&e>=48&&e<=57,bve=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:Vwt,previous:Mwt,name:"mathText"};function n(r,i,a){const o=this;let s=0,l=null,c,u;return O;function O(g){return r.enter("mathText"),r.enter("mathTextSequence"),d(g)}function d(g){return g===mh?(r.consume(g),s++,d):s<2&&!t||s===1&&(wL(g)||xL(g))?a(g):(r.exit("mathTextSequence"),h(g))}function h(g){return g===null?a(g):g===mh?(u=r.enter("mathTextSequence"),c=0,l=o.previous,m(g)):g===32?(r.enter("space"),r.consume(g),r.exit("space"),h):bL(g)?(r.enter("lineEnding"),r.consume(g),r.exit("lineEnding"),h):(r.enter("mathTextData"),p(g))}function p(g){return g===null||g===32||g===mh||bL(g)?(r.exit("mathTextData"),h(g)):(r.consume(g),p)}function m(g){return g===mh?(r.consume(g),c++,m):c===s?s===1&&(wL(l)||xL(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function Vwt(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Mwt(e){return e!==mh||this.events[this.events.length-1][1].type==="characterEscape"}const Lwt=Dwt().flow,Fwt=bve();function pk(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?Fwt:bve(e);n.push({flow:Lwt,text:{[mh]:i}}),r.push(Uwt())}const Bwt=({node:e,...t})=>f.jsx("div",{className:"lo-md-table-scroll",children:f.jsx("table",{...t})}),Hwt=/\$(?!\d)(.+?)\$/,Kwt=/\$\$([\s\S]+?)\$\$/,Jwt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,ext=/\\[a-zA-Z]+(\{[^}]*\})?/,SL=e=>Hwt.test(e)||Kwt.test(e)||Jwt.test(e)?!0:ext.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),txt=e=>{const t=fk(e);if(t.length===1&&t[0].kind==="text")return null;let n="",r=!1;for(const i of t){if(i.kind==="text"){n+=i.text;continue}r=!0,n+="x".repeat(i.text.length)}return r?n:null},nxt=e=>fk(e).filter(t=>t.kind!=="text").length,rxt=e=>{if(!SL(e))return!1;const t=txt(e);return t===null?!0:SL(t)||t.includes("$")?!1:nxt(e)<2},Nt="var(--color-ink)",Yl="var(--color-ink-muted)",Ms="var(--color-surface)",uu="var(--color-elevated)",Nl="var(--color-sunken)",Yi="var(--color-hairline)",Ou="var(--color-control)",If="var(--color-accent)",Ig="var(--color-accent-wash)",ixt="var(--color-accent-alt-wash)",axt="var(--color-on-accent)",oxt="var(--color-info)",wve="var(--color-info-wash)",sxt="var(--color-success)",xve="var(--color-success-wash)",lxt="var(--color-warning)",dj="var(--color-warning-wash)",cxt="var(--color-warning-border)",jT="var(--color-danger)",fj="var(--color-danger-wash)",QL=[Ig,ixt,wve,xve,dj,fj],du=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),uxt=()=>{const e={primaryColor:du("--color-accent"),secondaryColor:du("--color-success"),tertiaryColor:du("--color-info"),mainBkg:du("--color-elevated"),clusterBkg:du("--color-sunken"),clusterBorder:du("--color-hairline"),edgeLabelBackground:du("--color-surface"),quadrant1Fill:du("--color-accent-wash")};for(const[n,r]of Object.entries(e))r===""&&delete e[n];const t={darkMode:getComputedStyle(document.documentElement).colorScheme.includes("dark"),background:Ms,primaryTextColor:Nt,primaryBorderColor:Ou,secondaryTextColor:Nt,secondaryBorderColor:Yi,tertiaryTextColor:Nt,tertiaryBorderColor:Yi,lineColor:Yl,arrowheadColor:Yl,textColor:Nt,secondBkg:Nl,border1:Ou,border2:Yi,labelColor:Nt,nodeBkg:uu,nodeBorder:Ou,nodeTextColor:Nt,defaultLinkColor:Yl,titleColor:Nt,noteBkgColor:dj,noteBorderColor:cxt,noteTextColor:Nt,actorBkg:uu,actorBorder:Ou,actorTextColor:Nt,actorLineColor:Yi,signalColor:Yl,signalTextColor:Nt,labelBoxBkgColor:uu,labelBoxBorderColor:Yi,labelTextColor:Nt,loopTextColor:Nt,activationBkgColor:Ig,activationBorderColor:If,sequenceNumberColor:Ms,sectionBkgColor:Nl,sectionBkgColor2:Ms,altSectionBkgColor:Nl,excludeBkgColor:Nl,taskBkgColor:Ig,taskBorderColor:Ou,taskTextColor:Nt,taskTextLightColor:Nt,taskTextDarkColor:Nt,taskTextOutsideColor:Nt,taskTextClickableColor:If,activeTaskBkgColor:Ig,activeTaskBorderColor:If,gridColor:Yi,doneTaskBkgColor:Nl,doneTaskBorderColor:Yi,critBkgColor:fj,critBorderColor:jT,todayLineColor:If,transitionColor:Yl,transitionLabelColor:Nt,stateLabelColor:Nt,stateBkg:uu,labelBackgroundColor:Ms,compositeBackground:Nl,altBackground:Nl,compositeTitleBackground:uu,compositeBorder:Yi,innerEndBackground:Nt,specialStateColor:Nt,classText:Nt,attributeBackgroundColorOdd:Ms,attributeBackgroundColorEven:Nl,rowOdd:Ms,rowEven:Nl,errorBkgColor:fj,errorTextColor:jT,pieTitleTextColor:Nt,pieSectionTextColor:Nt,pieLegendTextColor:Nt,pieStrokeColor:Ms,pieOuterStrokeColor:Yi,requirementBackground:uu,requirementBorderColor:Ou,requirementTextColor:Nt,relationColor:Yl,relationLabelBackground:Ms,relationLabelColor:Nt,branchLabelColor:axt,commitLabelColor:Nt,commitLabelBackground:Ms,tagLabelColor:Nt,tagLabelBackground:Ig,tagLabelBorder:Ou,quadrant2Fill:wve,quadrant3Fill:xve,quadrant4Fill:dj,quadrant2TextFill:Nt,quadrant3TextFill:Nt,quadrant4TextFill:Nt,quadrantPointFill:If,archEdgeColor:Yl,archEdgeArrowColor:Yl,archGroupBorderColor:Yi,scaleLabelColor:Nt,packet:{startByteColor:Nt,endByteColor:Nt,labelColor:Nt,titleColor:Nt,blockStrokeColor:Ou,blockFillColor:uu},radar:{axisColor:Yl,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Yi,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:Ms,titleColor:Nt,xAxisTitleColor:Nt,xAxisLabelColor:Nt,xAxisTickColor:Yi,xAxisLineColor:Yi,yAxisTitleColor:Nt,yAxisLabelColor:Nt,yAxisTickColor:Yi,yAxisLineColor:Yi,plotColorPalette:[If,oxt,sxt,lxt,jT].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=uu,t[`surfacePeer${n}`]=Yi;for(let n=0;n<8;n++)t[`fillType${n}`]=QL[n%QL.length];return{...t,...e}};let CT=null,kL=null;const Oxt=async e=>{CT||(CT=ge(async()=>{const{default:n}=await import("./mermaid.core-BzKfajYZ.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([8,1,2]),import.meta.url).then(({default:n})=>n));const t=await CT;return kL!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:uxt()}),kL=e),t},PL=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>f.jsxs("div",{className:E("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[f.jsx(wt,{content:"Zoom in",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:f.jsx(_ae,{})})}),f.jsx(wt,{content:"Zoom out",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:f.jsx(Tae,{})})}),f.jsx(wt,{content:"Drag the diagram to pan",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:f.jsx(mRe,{})})}),f.jsx(wt,{content:"Reset view",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:f.jsx(BS,{})})}),f.jsx(wt,{content:"Save as SVG",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:a,children:f.jsx(my,{})})}),f.jsx(wt,{content:t?"Copied":"Copy mermaid text",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:o,children:f.jsx(Vp,{className:E(t&&"text-success")})})}),s]}),hj=({title:e,children:t})=>f.jsxs(pl,{variant:"danger",role:"alert",className:"my-4",children:[f.jsx(Kg,{children:e}),f.jsx(Jg,{children:t})]});class dxt extends $.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Mermaid Error Boundary caught an error:",t,n)}render(){return this.state.hasError?this.props.fallback||f.jsxs(hj,{title:"Mermaid diagram error",children:[this.state.error?.message||"An unexpected error occurred while rendering the diagram"," ","The error was contained within the diagram component."]}):this.props.children}}const fxt=$.memo(({chart:e,id:t})=>{const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[d,h]=$.useState({scale:1,x:0,y:0}),[p,m]=$.useState({scale:1,x:0,y:0}),[g,y]=$.useState(!1),[v,x]=$.useState({x:0,y:0}),[S,b]=$.useState("idle"),[w,Q]=$.useState("idle"),P=Cn(U=>U.themeName),T=$.useCallback(async()=>{try{if(s(!0),a(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const U=await Oxt(P),te=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:L}=await U.render(te,e);if(!L||typeof L!="string"||L.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(L)}catch(U){console.error("Mermaid rendering error:",U);const te=U instanceof Error?U.message:"Failed to render mermaid diagram";a(te),c("")}finally{s(!1)}},[e,t,P]);$.useEffect(()=>{T().catch(U=>{console.error("Error in renderDiagram effect:",U),a("Failed to initialize diagram rendering"),s(!1)})},[T]);const _=$.useCallback(()=>{try{if(!l||!r.current)return 1;const te=r.current.getBoundingClientRect(),L=document.createElement("div");L.innerHTML=l;const B=L.querySelector("svg");if(!B)return 1;const Oe=B.getBoundingClientRect?.()?.width||Number.parseFloat(B.getAttribute("width")||"0")||B.viewBox?.baseVal?.width||800,F=B.getBoundingClientRect?.()?.height||Number.parseFloat(B.getAttribute("height")||"0")||B.viewBox?.baseVal?.height||600,H=te.width*.9/Oe,ne=te.height*.9/F;return Math.min(H,ne,1)}catch(U){return console.error("Error calculating fullscreen scale:",U),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const U=_();m({scale:U,x:0,y:0})}catch(U){console.error("Error setting fullscreen transform:",U)}},100)},[u,l,_]);const R=$.useCallback((U=!1)=>{try{(U?m:h)(L=>({...L,scale:Math.min(L.scale*1.2,10)}))}catch(te){console.error("Error in zoom in:",te)}},[]),q=$.useCallback((U=!1)=>{try{(U?m:h)(L=>({...L,scale:Math.max(L.scale/1.2,.1)}))}catch(te){console.error("Error in zoom out:",te)}},[]),A=$.useCallback((U=!1)=>{try{const te=U?m:h;if(U){const L=_();te({scale:L,x:0,y:0})}else te({scale:1,x:0,y:0})}catch(te){console.error("Error in reset:",te)}},[_]),C=$.useCallback(()=>{if(l)try{const U=new Blob([l],{type:"image/svg+xml"}),te=URL.createObjectURL(U),L=document.createElement("a");L.href=te,L.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(te)}catch(U){console.error("Failed to save SVG:",U)}},[l]),N=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),b("copied"),setTimeout(()=>b("idle"),1200)}catch(U){console.error("Failed to copy Mermaid chart text:",U)}},[e]),I=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),Q("copied"),setTimeout(()=>Q("idle"),1200)}catch(U){console.error("Failed to copy Mermaid chart text:",U)}},[e]),W=$.useCallback(U=>{try{y(!0),x({x:U.clientX,y:U.clientY}),U.preventDefault()}catch(te){console.error("Error in mouse down:",te)}},[]),G=$.useCallback((U,te=!1)=>{try{if(!g)return;const L=U.clientX-v.x,B=U.clientY-v.y;(te?m:h)(F=>({...F,x:F.x+L,y:F.y+B})),x({x:U.clientX,y:U.clientY})}catch(L){console.error("Error in mouse move:",L)}},[g,v]),D=$.useCallback(()=>{try{y(!1)}catch(U){console.error("Error in mouse up:",U)}},[]),j=$.useCallback((U,te=!1)=>{try{U.preventDefault();const L=U.deltaY>0?.9:1.1;(te?m:h)(Oe=>({...Oe,scale:Math.min(Math.max(Oe.scale*L,.1),5)}))}catch(L){console.error("Error in wheel:",L)}},[]),V=$.useCallback(U=>{try{O(U)}catch(te){console.error("Error toggling fullscreen:",te)}},[]);if(i)return f.jsxs(hj,{title:"Mermaid diagram error",children:[i,f.jsx("span",{className:E("mt-2 block text-ink-muted"),children:"Chart"}),f.jsx("span",{className:E("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const J=(U=!1)=>{try{const te=U?r:n,L=U?p:d;return f.jsx("div",{ref:te,className:E("mermaid flex w-full items-center justify-center",U?"h-full min-h-full":"h-auto min-h-50",g?"cursor-grabbing":"cursor-grab"),onMouseDown:W,onMouseMove:B=>G(B,U),onMouseUp:D,onMouseLeave:D,onWheel:B=>j(B,U),children:o?f.jsx("div",{className:E("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?f.jsx("div",{className:E("flex h-full w-full items-center justify-center"),style:{transform:`translate(${L.x}px, ${L.y}px) scale(${L.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(te){return console.error("Error rendering diagram content:",te),f.jsx(hj,{title:"Rendering error",children:"Failed to render diagram content."})}};return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:E("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[J(!1),f.jsx(PL,{className:"top-2 right-2",copied:S==="copied",onZoomIn:()=>R(!1),onZoomOut:()=>q(!1),onReset:()=>A(!1),onSave:C,onCopy:N,children:f.jsx(wt,{content:"Fullscreen",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>V(!0),children:f.jsx(mae,{})})})})]}),f.jsx(N0,{open:u,onClose:()=>V(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:f.jsxs("div",{className:E("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[J(!0),f.jsx(PL,{className:"top-4 right-4",copied:w==="copied",onZoomIn:()=>R(!0),onZoomOut:()=>q(!0),onReset:()=>A(!0),onSave:C,onCopy:I,children:f.jsx(wt,{content:"Close fullscreen",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>V(!1),children:f.jsx(zi,{})})})})]})})]})}),hxt=$.memo(e=>f.jsx(dxt,{children:f.jsx(fxt,{...e})}));let Sve=!1,zT=null;const pxt=()=>(zT||(zT=ge(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(Sve=!0,e))),zT),mxt=/language-(\w+)/,gxt=GS,$xt=new RegExp(`^[^${Qc}\\d*+-]`),yxt=/\n$/,Qve=({href:e,children:t})=>{const n=Eye(e),r=ck();return!n||n.kind==="other"?f.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):f.jsx("a",{href:n.target,"data-lo-kind":n.kind,"data-lo-target":n.target,draggable:!1,target:n.kind==="url"?"_blank":void 0,rel:n.kind==="url"?"noopener noreferrer":void 0,onClick:n.kind==="file"?i=>wxt(i,r):void 0,children:t})},vxt=e=>Eye(e)?.kind==="file",bxt=Aye,wxt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(zye)??"file",i=n.getAttribute(bxt),a=Bvt({kind:r,hasHighlight:Obt(n),canOpenInCanvas:F9(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||rO(i)});return}rO(i)}},pj=(e,t)=>t==="href"&&vxt(e)?e:ece(e),S$={a:Qve,table:Bwt,img:Awt,code:({node:e,className:t,children:n,...r})=>mxt.exec(t??"")?.[1]==="mermaid"?f.jsx(hxt,{chart:String(n).replace(yxt,"")}):f.jsx("code",{className:t,...r,children:n})},xxt={...S$,a:wwt(Qve)},Sxt=[Ic],Qxt=[Ic,pk],kxt=[Ic,uk],Pxt=[Ic,pk,uk],_xt=[Ic,hk,Ok],Txt=[Ic,pk,hk,Ok],Xxt=[Ic,uk,hk,Ok],Rxt=[Ic,pk,uk,hk,Ok],Ext={"000":Sxt,"001":_xt,"010":kxt,"011":Xxt,100:Qxt,101:Txt,110:Pxt,111:Rxt},qxt=[],jxt=[LGe],kve=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),Pve=(e,t,n)=>{const r=$.useMemo(()=>rxt(e),[e]),[i,a]=$.useState(Sve),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return pxt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:Ext[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?jxt:qxt}},_ve=(e,t)=>{const[,n]=$.useState(0);$.useEffect(()=>{if(!t)return;const r=TDe(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=Kvt(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return Cye(r,window.api?.probeFiles,Xie).then(()=>{i&&r.some(s=>jye(s)!=="unknown")&&n(s=>s+1)}),()=>{i=!1,o()}},[e,t])},Q$=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1})=>{const a=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:o,rehypePlugins:s}=Pve(a,r,i),l=kve(t);return _ve(a,r),f.jsx("div",{className:E("lo-markdown",n),style:l,children:f.jsx(iq,{remarkPlugins:o,rehypePlugins:s,urlTransform:pj,components:i?xxt:S$,children:a})})});Q$.displayName="MarkdownRenderer";const _L={...S$,a:({children:e})=>f.jsx(f.Fragment,{children:e})},Tve=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:tL(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=Fye(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=Pve(n,t,!1);if(_ve(e,t),r!==null){const o=tL(r.before);return f.jsxs(f.Fragment,{children:[o.trim()!==""&&f.jsx(iq,{remarkPlugins:i,rehypePlugins:a,urlTransform:pj,components:t?S$:_L,children:o}),f.jsx(Cxt,{info:r.info,body:r.body})]})}return f.jsx(iq,{remarkPlugins:i,rehypePlugins:a,urlTransform:pj,components:t?S$:_L,children:n})});Tve.displayName="ParsedBlock";const Cxt=({info:e,body:t})=>{const n=e.split(gxt)[0];return f.jsx("pre",{children:f.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
820
+ `)&&(s={capture:Sx(e),buffer:n,caret:r})}return{...s,capture:ph(s.capture,s.buffer,s.caret,i)}}function c1t(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=sf(t);if(o===null||t.value==="")return{minted:!1,capture:t,buffer:n,caret:r,payload:null};const s=t.arm===null?o.start:t.arm.start,l=lve(i,t.value),c=l+dk,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Ta,buffer:u,caret:s+c.length,payload:{index:i,key:uve(a,e.draw),value:t.value,marker:l}}}const u1t=e=>Ro(e)&&e.value!=="";function O1t(e,t){const n=sf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,token:null};const r=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:Ta,buffer:t.slice(0,n.start)+t.slice(n.end),caret:n.start,token:{span:{start:r,end:n.start},text:t.slice(r,n.start)}}}function d1t(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function f1t(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=sf(e);return o===null?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:n.start<=o.start?{kind:"passthrough",capture:{...e,typingAt:o.start+r.length},buffer:i,caret:a,payload:null}:n.start>=o.end?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:{kind:"passthrough",capture:Sx(e),buffer:i,caret:a,payload:null}}function h1t(e){const{capture:t,buffer:n,caret:r,pasted:i}=e;if(t.arm===null)return null;if(t.typingAt!==null&&t.value!==""){if(i==="")return null;const u=J9(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=vn(i);if(!a)return i===""?null:f1t(t,n,e.selection,i);const o=t.arm,s=lve(e.index,a),l=s+dk,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Ta,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:uve(e.taken,e.draw),value:a,marker:s}}}const sve=e=>`${t1t(e)} chars`,lve=(e,t)=>`[Credential #${e}, ${sve(t)}]`;function p1t(e){dl.lastIndex=0;const t=dl.exec(e);return dl.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function m1t(e){dl.lastIndex=0;const t=dl.exec(e);if(dl.lastIndex=0,t===null||t[0]!==e)return null;const n=Number.parseInt(t[1],10);return{index:n,label:`#${n}`,chars:Number.parseInt(t[2],10)}}function Fy(e,t){if(p1t(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const RT=/\[credential ([A-Za-z_][A-Za-z0-9_]*) \((\d+) chars\) \u2014 available to bash and eval as \$([A-Za-z_][A-Za-z0-9_]*); its value cannot be read\]/y,ET=/\[credential NOT stored \u2014 [^\]\n]*\]/y,qT=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,g1t=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&uj.test(t[1])?t[1]:""};function $1t(e,t){if(e.charCodeAt(t)!==91)return null;RT.lastIndex=t;const n=RT.exec(e);if(RT.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};ET.lastIndex=t;const r=ET.exec(e);if(ET.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};qT.lastIndex=t;const i=qT.exec(e);return qT.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:g1t(i[0])}:null}function fk(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=$1t(e,r);if(i===null){r++;continue}r>n&&t.push({kind:"text",text:e.slice(n,r)}),t.push(i),r+=i.text.length,n=r}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}function sL(e,t){const n=[];for(const r of t){const i=Fy(e,r);i!==null&&n.push({at:i.start,payload:r})}return n.sort((r,i)=>r.at-i.at).map(r=>r.payload)}function y1t(e,t=""){return e==="unconfirmed"?t?`[credential unconfirmed — it may be held as $${t}, so check list_variables before assuming it is missing]`:"[credential unconfirmed — the session may hold it, so check list_variables before assuming it is missing]":e==="unreachable"?"[credential NOT stored — the session could not be reached; try again]":e==="rejected-key"?"[credential NOT stored — the store rejected its name]":"[credential NOT stored — its value did not survive; ask the operator to paste it again]"}const v1t=e=>`[credential ${e.key} (${sve(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function b1t(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=Fy(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of rve(e,r))i.push({span:o,payload:null});let a=e;for(const{span:o,payload:s}of i.sort((l,c)=>c.span.start-l.span.start)){const l=s===null?"lost":n.get(s.index),c=s===null||l!==void 0?y1t(l??"lost",s?.key):v1t(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const w1t=(e,t,n)=>`Removed ${e} (credential #${t}) from this message. Its value is gone — press ${n} to put it back, or paste it again after /credential to reuse it.`,x1t=e=>`Remove credential #${e}`,S1t=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,Q1t=(e,t,n)=>w1t(e,t,n),k1t="Undo",P1t=e=>`Credential #${e} removed`,_1t=e=>e.unredacted!==null?e.unredacted:e.armed?C1t:e.cleared!==null?Q1t(e.cleared.key,e.cleared.index,e.undoCap):null;function T1t(e){const{buffer:t,payload:n}=e,r=Fy(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===dk?r.end+1:r.end;return{cleared:!0,buffer:t.slice(0,r.start)+t.slice(i),caret:r.start,removed:t.slice(r.start,i)}}function X1t(e){const{buffer:t,cleared:n}=e;return n.removed===""||t!==n.buffer?null:{buffer:t.slice(0,n.caret)+n.removed+t.slice(n.caret),caret:n.caret+n.removed.length}}const lL=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function cL(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be stored (${[...e].sort().join(", ")}); the agent has been told so. Paste the value again after /credential to retry.`}const R1t="store unconfirmed",E1t="Credential store unconfirmed",q1t=e=>e===""?E1t:`${e} · ${R1t}`,cve="Paste the value again after /credential to store it again.",j1t=e=>`${e} ${cve}`;function uL(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be confirmed as stored (${[...e].sort().join(", ")}); the agent has been told to check before using it. ${cve}`}const C1t="armed — add a space, then type or paste the secret",z1t="masked as you type — Enter makes a pill, Esc twice discards",A1t="masked — Enter opens the credential picker; type or paste the secret into this span",U1t="Esc again discards it — still masked, Enter makes a pill",W1t="credential discarded — nothing was stored or sent",Y1t="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",N1t=e=>`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`;function G1t(e,t){const n=sf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const OL=(e,t)=>e&&e.over===t?e.chars:null,Z1t=e=>{const t=Math.floor(4294967296/e)*e,n=new Uint32Array(1);for(;;)if(globalThis.crypto.getRandomValues(n),n[0]<t)return n[0]%e},I1t=16,D1t=16;function uve(e=[],t=Z1t){const n=new Set(e);for(let r=0;r<I1t;r++){const i=aL+dL(8,t);if(!n.has(i))return i}return aL+dL(D1t,t)}const dL=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=iL[t(iL.length)];return n},V1t=8,M1t=256,L1t=/^[/@$#]/,F1t=/^\w+:\/\//,B1t=/^[A-Za-z]+$/,H1t=/^\d+$/,K1t=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],J1t=3,ewt=20,twt=/^[A-Za-z0-9_\-+/=.]+$/,nwt=new RegExp(`^[^${Qc}@]+@[^${Qc}@]+\\.[A-Za-z]{2,}$`),rwt=/^[\w.-]+(?:\/[\w.-]+)+$/,iwt=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,awt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,owt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,swt=/^[\w.-]+:\d{2,5}$/,lwt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,cwt=/^[a-z]+(?:_[a-z]+)+$/,uwt=/^[a-z]+(?:-[a-z]+)+$/,Owt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,dwt=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,fwt=/\d{4,}/,hwt=e=>{const t=e.trim();return t.length<V1t||t.length>M1t||ks.test(t)||L1t.test(t)||F1t.test(t)||Iae(t)!==null||nwt.test(t)||rwt.test(t)||iwt.test(t)||awt.test(t)||owt.test(t)||swt.test(t)||lwt.test(t)||cwt.test(t)||uwt.test(t)||Owt.test(t)||dwt.test(t)&&fwt.test(t)||B1t.test(t)||H1t.test(t)?!1:K1t.filter(r=>r.test(t)).length>=J1t?!0:t.length>=ewt&&twt.test(t)},Ove=E("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),dve=E("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),fve=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:o,style:s,small:l=!1})=>f.jsxs("span",{className:E("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?dve:Ove,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?f.jsx(Die,{"aria-hidden":"true",className:"size-3 shrink-0"}):f.jsx(FXe,{"aria-hidden":"true",className:"size-3 shrink-0"}),f.jsx("span",{className:"min-w-0 truncate",children:e}),t!==null&&f.jsx("span",{className:"shrink-0",children:`· ${t} chars`}),i&&f.jsx("button",{type:"button","aria-label":a,onClick:i,className:"pointer-events-auto -mr-1 flex shrink-0 cursor-pointer items-center rounded-xs p-0.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-offset-1! active:bg-sunken",children:f.jsx(zi,{"aria-hidden":"true",className:"size-3"})}),r&&f.jsx("span",{className:"sr-only",children:r})]}),x$="#lo-credential/",pwt=`${x$}unstored`,fL=`${x$}unconfirmed`,mwt=/^\d+$/,hve=e=>e.kind==="stored"?`${x$}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${fL}/${e.key}`:fL:pwt;function gwt(e){if(!e||!e.startsWith(x$))return null;const t=e.slice(x$.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return uj.test(a)?{kind:"unconfirmed",key:a}:null}const n=t.lastIndexOf("/");if(n===-1)return null;const r=t.slice(0,n),i=t.slice(n+1);return!uj.test(r)||!mwt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function hL(e,t){const n=gwt(e);if(n===null)return null;const r=fk(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return hve(i)!==e?null:n}const hk=()=>e=>{const t=n=>{if(!n.children)return;const r=[];let i=!1;for(const a of n.children){if(a.type!=="text"||typeof a.value!="string"){t(a),r.push(a);continue}const o=fk(a.value);if(o.length===1&&o[0].kind==="text"){r.push(a);continue}i=!0;for(const s of o){if(s.kind==="text"){r.push({type:"text",value:s.text});continue}r.push({type:"link",url:hve(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},$wt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?q1t(e.key):"Credential not stored",ywt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?j1t(t):t,vwt=({citation:e,title:t})=>f.jsx(fve,{tone:e.kind==="stored"?"live":"warning",label:$wt(e),chars:e.kind==="stored"?e.chars:null,title:ywt(e,t),className:"align-middle"}),bwt=(e,t)=>typeof t=="string"?hL(e,t):t==null?hL(e,""):null,wwt=e=>({href:t,title:n,children:r})=>{const i=bwt(t,r);if(i===null){const a=e;return f.jsx(a,{href:t,title:n,children:r})}return f.jsx(vwt,{citation:i,title:n})},pve=e=>oDe(e)?"artifact":e.startsWith("data:")?"data":e.startsWith("blob:")?"blob":e.startsWith("http://")||e.startsWith("https://")?"http":e.startsWith("file://")||e.startsWith("/")||e.startsWith("~")?"path":"other",mve=e=>{const t=pve(e);return t==="other"?"path":t},pL={id:"open-file",label:"Open file"},xwt={id:"show-in-canvas",label:"Show in canvas"},Swt={id:"save-as",label:"Save as…"},mL={id:"open-folder",label:"Open folder"},gL={id:"copy-file-path",label:"Copy file path"},dg={id:"copy-image",label:"Copy image"},Qwt={id:"copy-image-url",label:"Copy image URL"},kwt={id:"open-in-browser",label:"Open in browser"};function gve(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[xwt]:[],...a?[{id:"expand-image",label:"Expand image"}]:[]];switch(e){case"artifact":return[...o,...i?[pL,mL,gL]:[],Swt,...r==="video"||r==="audio"?[]:[dg]];case"path":return[...o,pL,mL,gL,...r==="video"||r==="audio"?[]:[dg]];case"data":return[...o,dg];case"blob":return[dg];case"http":return[...Pwt(n)?[dg]:[],Qwt,kwt];case"other":return[]}}const $ve=(e,t)=>gve(e,t).length>0;function Pwt(e){try{const t=new URL(e),n=t.hostname==="localhost"||t.hostname==="127.0.0.1";return t.protocol==="http:"&&n&&(t.port==="1111"||t.port==="8080")}catch{return!1}}const eA=e=>e.startsWith("file://")?e.slice(7):e;function _wt(e){const t=e.indexOf(",");if(t===-1)throw new Error("Malformed data URL");const n=e.slice(5,t),r=e.slice(t+1),i=n.split(";")[0]||"application/octet-stream";if(n.endsWith(";base64")){const s=atob(r),l=new Uint8Array(s.length);for(let c=0;c<s.length;c+=1)l[c]=s.charCodeAt(c);return new Blob([l],{type:i})}const a=decodeURIComponent(r),o=new Uint8Array(a.length);for(let s=0;s<a.length;s+=1)o[s]=a.charCodeAt(s);return new Blob([o],{type:i})}async function $L(e,t,n){if(e==="data")return _wt(t);if(e==="blob"){const o=Wse(n??t);if(o===null)throw new Error("These image bytes are not available in this window");return o}if(e==="http"){const o=await fetch(n??t);if(!o.ok)throw new Error(`The image server answered ${o.status}`);return o.blob()}const r=window.api?.readFileBytes;if(typeof r!="function")throw new Error("This window cannot read local files");const i=eA(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:g6(i)})}const Twt=e=>e.trim().toLowerCase()!=="image/png";async function Xwt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!Twt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await Rwt(t);if(n.naturalWidth===0||n.naturalHeight===0)throw new Error("This image could not be decoded for the clipboard");const r=document.createElement("canvas");r.width=n.naturalWidth,r.height=n.naturalHeight;const i=r.getContext("2d");if(i===null)throw new Error("This window cannot re-encode the image for the clipboard");i.drawImage(n,0,0);const a=await new Promise(o=>{r.toBlob(o,"image/png")});if(a===null)throw new Error("This image could not be re-encoded for the clipboard");return a}finally{URL.revokeObjectURL(t)}}function Rwt(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new Error("This image could not be decoded for the clipboard")),r.src=e})}const Ewt=6e4;function qwt(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),Ewt)}const L1=new Map;function jwt(e,t){const n=L1.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await Sc(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")return null;const a=y6(i.data,i.mimeType);return r.holders<=0?(xy(a),null):(Yse(t,a),a)}catch{return null}finally{L1.delete(t)}})(),L1.set(t,r),r.promise}class tA extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function yve(e,t){const n=v6(t),r=n?Wse(n):null;if(r)return r;const i=await Sc(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")throw i.status===404?new tA:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function Cwt(e){const t=L1.get(e);t&&(t.holders-=1)}function By(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?v6(e.attachment):null),[a,o]=$.useState(!1),s=t?.sessionId??null,l=t?.childId??null;$.useEffect(()=>{const u=e.attachment;if(n||!u||!s)return;let O=!0;const d=vw(u);if(d)return i(d),o(!1),()=>{O=!1,bw(u)};i(null),o(!1);let h=!0;return jwt({sessionId:s,childId:l},u).then(p=>{if(h=!1,!!O){if(!p){o(!0);return}i(vw(u))}}),()=>{O=!1,h&&Cwt(u),bw(u)}},[e.attachment,n,s,l]);const c=n??r;return c?{state:"ready",url:c}:e.attachment&&s&&!a?{state:"resolving"}:{state:"missing"}}function nA(e,t){return By(e,t)}const $tn=Object.freeze(Object.defineProperty({__proto__:null,AttachmentGoneError:tA,fetchAttachmentBlob:yve,useAttachmentSource:By,useAttachmentUrl:nA},Symbol.toStringTag,{value:"Module"})),zwt={"expand-image":f.jsx(mae,{"aria-hidden":"true"}),"open-file":f.jsx(gy,{"aria-hidden":"true"}),"show-in-canvas":f.jsx(pae,{"aria-hidden":"true"}),"save-as":f.jsx(my,{"aria-hidden":"true"}),"open-folder":f.jsx(Gh,{"aria-hidden":"true"}),"copy-file-path":f.jsx(NC,{"aria-hidden":"true"}),"copy-image":f.jsx(Vp,{"aria-hidden":"true"}),"copy-image-url":f.jsx(JXe,{"aria-hidden":"true"}),"open-in-browser":f.jsx(GC,{"aria-hidden":"true"})},yL=(e,t)=>t instanceof tA?`${e}: it is no longer in the session`:e,vve=({file:e,src:t,label:n,open:r,onOpenChange:i,onCloseAutoFocus:a,triggerTabIndex:o,resolvePath:s,missing:l,onShowInCanvas:c,mediaKind:u,onExpand:O,saveName:d,resolveBytes:h,tooltip:p="Image actions","aria-label":m})=>{const g=mve(e),y=gve(g,{canShowInCanvas:!!c,source:t??e,mediaKind:u,artifactPathActions:!!s,canExpand:!!O}).filter(Q=>(Q.id!=="save-as"||!!d)&&(!l||Q.id==="copy-file-path"));if(y.length===0)return null;const v=async(Q,P,T)=>{try{await navigator.clipboard.writeText(Q),wd(P)}catch(_){console.error(`${T}: `,_),Kr(T)}},x=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const Q=h?await h():await $L(g,e,t),P=await Xwt(Q);await navigator.clipboard.write([new ClipboardItem({[P.type]:P})]),wd("Image copied to clipboard")}catch(Q){console.error("Failed to copy image: ",Q),Kr(yL("Failed to copy image",Q))}},S=async()=>{try{const Q=h?await h():await $L(g,e,t);qwt(Q,d??"download")}catch(Q){console.error("Failed to save file: ",Q),Kr(yL("Failed to save file",Q))}},b=async Q=>{let P=eA(e);if(s&&["open-file","open-folder","copy-file-path"].includes(Q.id))try{P=await s()}catch{Kr(Y("ui.canvas.files.prepareError"));return}switch(Q.id){case"expand-image":O?.();return;case"open-file":rO(P);return;case"open-folder":B9(P);return;case"show-in-canvas":c?.();return;case"copy-file-path":v(P,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":x();return;case"save-as":S();return;case"copy-image-url":v(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":H9(t??e);return}},w=m??`Actions for ${n??"this image"}`;return f.jsxs(XC,{open:r,onOpenChange:i,children:[f.jsx(wt,{content:p,children:f.jsx(RC,{asChild:!0,children:f.jsx(Se,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":w,tabIndex:o,onClick:Q=>Q.stopPropagation(),children:f.jsx(kE,{"aria-hidden":"true"})})})}),f.jsxs(EC,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:Q=>Q.stopPropagation(),children:[s&&f.jsx("div",{role:"note",className:E("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:Y("ui.canvas.files.pathCopyNote")}),y.map(Q=>f.jsxs(rl,{onSelect:()=>b(Q),children:[zwt[Q.id],f.jsx("span",{children:Q.label})]},Q.id))]})]})},Awt=({src:e,alt:t,title:n,className:r})=>{const i=ck(),a=e??"",o=pve(a);if(o==="other")return f.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=$ve(o,{canShowInCanvas:s,source:a});return f.jsxs("span",{className:E("group/mdimg relative inline-block max-w-full"),children:[f.jsx("img",{src:e,alt:t,title:n,className:r}),l&&f.jsx("span",{"data-markdown-image":"",className:E("pointer-events-none absolute top-1 right-1 z-[2] opacity-0","transition-opacity duration-fast ease-out-quart","group-hover/mdimg:pointer-events-auto group-hover/mdimg:opacity-100","group-focus-within/mdimg:pointer-events-auto group-focus-within/mdimg:opacity-100","has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100"),children:f.jsx(vve,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||rO(eA(a))})}:void 0})})]})};function Uwt(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:a},exit:{mathFlow:i,mathFlowFence:r,mathFlowFenceMeta:n,mathFlowValue:s,mathText:o,mathTextData:s}};function e(l){const c={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[c]}},l)}function t(){this.buffer()}function n(){const l=this.resume(),c=this.stack[this.stack.length-1];c.type,c.meta=l}function r(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function i(l){const c=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c;const O=u.data.hChildren[0];O.type,O.tagName,O.children.push({type:"text",value:c}),this.data.mathFlowInside=void 0}function a(l){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},l),this.buffer()}function o(l){const c=this.resume(),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c,u.data.hChildren.push({type:"text",value:c})}function s(l){this.config.enter.data.call(this,l),this.config.exit.data.call(this,l)}}const Wwt={tokenize:Ywt,concrete:!0,name:"mathFlow"},vL={tokenize:Nwt,partial:!0};function Ywt(e,t,n){const r=this,i=r.events[r.events.length-1],a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let o=0;return s;function s(v){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(v)}function l(v){return v===36?(e.consume(v),o++,l):o<2?n(v):(e.exit("mathFlowFenceSequence"),Lt(e,c,"whitespace")(v))}function c(v){return v===null||gt(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||gt(v)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(v)):v===36?n(v):(e.consume(v),u)}function O(v){return e.exit("mathFlowFence"),r.interrupt?t(v):e.attempt(vL,d,g)(v)}function d(v){return e.attempt({tokenize:y,partial:!0},g,h)(v)}function h(v){return(a?Lt(e,p,"linePrefix",a+1):p)(v)}function p(v){return v===null?g(v):gt(v)?e.attempt(vL,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||gt(v)?(e.exit("mathFlowValue"),p(v)):(e.consume(v),m)}function g(v){return e.exit("mathFlow"),t(v)}function y(v,x,S){let b=0;return Lt(v,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function w(T){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),Q(T)}function Q(T){return T===36?(b++,v.consume(T),Q):b<o?S(T):(v.exit("mathFlowFenceSequence"),Lt(v,P,"whitespace")(T))}function P(T){return T===null||gt(T)?(v.exit("mathFlowFence"),x(T)):S(T)}}}function Nwt(e,t,n){const r=this;return i;function i(o){return o===null?t(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Gwt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:Zwt,previous:Iwt,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(m){return i.enter("mathText"),i.enter("mathTextSequence"),O(m)}function O(m){return m===36?(i.consume(m),s++,O):s<2&&!n?o(m):(i.exit("mathTextSequence"),d(m))}function d(m){return m===null?o(m):m===36?(c=i.enter("mathTextSequence"),l=0,p(m)):m===32?(i.enter("space"),i.consume(m),i.exit("space"),d):gt(m)?(i.enter("lineEnding"),i.consume(m),i.exit("lineEnding"),d):(i.enter("mathTextData"),h(m))}function h(m){return m===null||m===32||m===36||gt(m)?(i.exit("mathTextData"),d(m)):(i.consume(m),h)}function p(m){return m===36?(i.consume(m),l++,p):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(m)):(c.type="mathTextData",h(m))}}}function Zwt(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Iwt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function Dwt(e){return{flow:{36:Wwt},text:{36:Gwt()}}}const mh=36,bL=e=>e!==null&&e<-2,wL=e=>e===null||e===32||e<0,xL=e=>e!==null&&e>=48&&e<=57,bve=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:Vwt,previous:Mwt,name:"mathText"};function n(r,i,a){const o=this;let s=0,l=null,c,u;return O;function O(g){return r.enter("mathText"),r.enter("mathTextSequence"),d(g)}function d(g){return g===mh?(r.consume(g),s++,d):s<2&&!t||s===1&&(wL(g)||xL(g))?a(g):(r.exit("mathTextSequence"),h(g))}function h(g){return g===null?a(g):g===mh?(u=r.enter("mathTextSequence"),c=0,l=o.previous,m(g)):g===32?(r.enter("space"),r.consume(g),r.exit("space"),h):bL(g)?(r.enter("lineEnding"),r.consume(g),r.exit("lineEnding"),h):(r.enter("mathTextData"),p(g))}function p(g){return g===null||g===32||g===mh||bL(g)?(r.exit("mathTextData"),h(g)):(r.consume(g),p)}function m(g){return g===mh?(r.consume(g),c++,m):c===s?s===1&&(wL(l)||xL(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function Vwt(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Mwt(e){return e!==mh||this.events[this.events.length-1][1].type==="characterEscape"}const Lwt=Dwt().flow,Fwt=bve();function pk(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?Fwt:bve(e);n.push({flow:Lwt,text:{[mh]:i}}),r.push(Uwt())}const Bwt=({node:e,...t})=>f.jsx("div",{className:"lo-md-table-scroll",children:f.jsx("table",{...t})}),Hwt=/\$(?!\d)(.+?)\$/,Kwt=/\$\$([\s\S]+?)\$\$/,Jwt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,ext=/\\[a-zA-Z]+(\{[^}]*\})?/,SL=e=>Hwt.test(e)||Kwt.test(e)||Jwt.test(e)?!0:ext.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),txt=e=>{const t=fk(e);if(t.length===1&&t[0].kind==="text")return null;let n="",r=!1;for(const i of t){if(i.kind==="text"){n+=i.text;continue}r=!0,n+="x".repeat(i.text.length)}return r?n:null},nxt=e=>fk(e).filter(t=>t.kind!=="text").length,rxt=e=>{if(!SL(e))return!1;const t=txt(e);return t===null?!0:SL(t)||t.includes("$")?!1:nxt(e)<2},Nt="var(--color-ink)",Yl="var(--color-ink-muted)",Ms="var(--color-surface)",uu="var(--color-elevated)",Nl="var(--color-sunken)",Yi="var(--color-hairline)",Ou="var(--color-control)",If="var(--color-accent)",Ig="var(--color-accent-wash)",ixt="var(--color-accent-alt-wash)",axt="var(--color-on-accent)",oxt="var(--color-info)",wve="var(--color-info-wash)",sxt="var(--color-success)",xve="var(--color-success-wash)",lxt="var(--color-warning)",dj="var(--color-warning-wash)",cxt="var(--color-warning-border)",jT="var(--color-danger)",fj="var(--color-danger-wash)",QL=[Ig,ixt,wve,xve,dj,fj],du=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),uxt=()=>{const e={primaryColor:du("--color-accent"),secondaryColor:du("--color-success"),tertiaryColor:du("--color-info"),mainBkg:du("--color-elevated"),clusterBkg:du("--color-sunken"),clusterBorder:du("--color-hairline"),edgeLabelBackground:du("--color-surface"),quadrant1Fill:du("--color-accent-wash")};for(const[n,r]of Object.entries(e))r===""&&delete e[n];const t={darkMode:getComputedStyle(document.documentElement).colorScheme.includes("dark"),background:Ms,primaryTextColor:Nt,primaryBorderColor:Ou,secondaryTextColor:Nt,secondaryBorderColor:Yi,tertiaryTextColor:Nt,tertiaryBorderColor:Yi,lineColor:Yl,arrowheadColor:Yl,textColor:Nt,secondBkg:Nl,border1:Ou,border2:Yi,labelColor:Nt,nodeBkg:uu,nodeBorder:Ou,nodeTextColor:Nt,defaultLinkColor:Yl,titleColor:Nt,noteBkgColor:dj,noteBorderColor:cxt,noteTextColor:Nt,actorBkg:uu,actorBorder:Ou,actorTextColor:Nt,actorLineColor:Yi,signalColor:Yl,signalTextColor:Nt,labelBoxBkgColor:uu,labelBoxBorderColor:Yi,labelTextColor:Nt,loopTextColor:Nt,activationBkgColor:Ig,activationBorderColor:If,sequenceNumberColor:Ms,sectionBkgColor:Nl,sectionBkgColor2:Ms,altSectionBkgColor:Nl,excludeBkgColor:Nl,taskBkgColor:Ig,taskBorderColor:Ou,taskTextColor:Nt,taskTextLightColor:Nt,taskTextDarkColor:Nt,taskTextOutsideColor:Nt,taskTextClickableColor:If,activeTaskBkgColor:Ig,activeTaskBorderColor:If,gridColor:Yi,doneTaskBkgColor:Nl,doneTaskBorderColor:Yi,critBkgColor:fj,critBorderColor:jT,todayLineColor:If,transitionColor:Yl,transitionLabelColor:Nt,stateLabelColor:Nt,stateBkg:uu,labelBackgroundColor:Ms,compositeBackground:Nl,altBackground:Nl,compositeTitleBackground:uu,compositeBorder:Yi,innerEndBackground:Nt,specialStateColor:Nt,classText:Nt,attributeBackgroundColorOdd:Ms,attributeBackgroundColorEven:Nl,rowOdd:Ms,rowEven:Nl,errorBkgColor:fj,errorTextColor:jT,pieTitleTextColor:Nt,pieSectionTextColor:Nt,pieLegendTextColor:Nt,pieStrokeColor:Ms,pieOuterStrokeColor:Yi,requirementBackground:uu,requirementBorderColor:Ou,requirementTextColor:Nt,relationColor:Yl,relationLabelBackground:Ms,relationLabelColor:Nt,branchLabelColor:axt,commitLabelColor:Nt,commitLabelBackground:Ms,tagLabelColor:Nt,tagLabelBackground:Ig,tagLabelBorder:Ou,quadrant2Fill:wve,quadrant3Fill:xve,quadrant4Fill:dj,quadrant2TextFill:Nt,quadrant3TextFill:Nt,quadrant4TextFill:Nt,quadrantPointFill:If,archEdgeColor:Yl,archEdgeArrowColor:Yl,archGroupBorderColor:Yi,scaleLabelColor:Nt,packet:{startByteColor:Nt,endByteColor:Nt,labelColor:Nt,titleColor:Nt,blockStrokeColor:Ou,blockFillColor:uu},radar:{axisColor:Yl,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Yi,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:Ms,titleColor:Nt,xAxisTitleColor:Nt,xAxisLabelColor:Nt,xAxisTickColor:Yi,xAxisLineColor:Yi,yAxisTitleColor:Nt,yAxisLabelColor:Nt,yAxisTickColor:Yi,yAxisLineColor:Yi,plotColorPalette:[If,oxt,sxt,lxt,jT].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=uu,t[`surfacePeer${n}`]=Yi;for(let n=0;n<8;n++)t[`fillType${n}`]=QL[n%QL.length];return{...t,...e}};let CT=null,kL=null;const Oxt=async e=>{CT||(CT=ge(async()=>{const{default:n}=await import("./mermaid.core-COeGB8I0.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([8,1,2]),import.meta.url).then(({default:n})=>n));const t=await CT;return kL!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:uxt()}),kL=e),t},PL=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>f.jsxs("div",{className:E("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[f.jsx(wt,{content:"Zoom in",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:f.jsx(_ae,{})})}),f.jsx(wt,{content:"Zoom out",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:f.jsx(Tae,{})})}),f.jsx(wt,{content:"Drag the diagram to pan",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:f.jsx(mRe,{})})}),f.jsx(wt,{content:"Reset view",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:f.jsx(BS,{})})}),f.jsx(wt,{content:"Save as SVG",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:a,children:f.jsx(my,{})})}),f.jsx(wt,{content:t?"Copied":"Copy mermaid text",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:o,children:f.jsx(Vp,{className:E(t&&"text-success")})})}),s]}),hj=({title:e,children:t})=>f.jsxs(pl,{variant:"danger",role:"alert",className:"my-4",children:[f.jsx(Kg,{children:e}),f.jsx(Jg,{children:t})]});class dxt extends $.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Mermaid Error Boundary caught an error:",t,n)}render(){return this.state.hasError?this.props.fallback||f.jsxs(hj,{title:"Mermaid diagram error",children:[this.state.error?.message||"An unexpected error occurred while rendering the diagram"," ","The error was contained within the diagram component."]}):this.props.children}}const fxt=$.memo(({chart:e,id:t})=>{const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[d,h]=$.useState({scale:1,x:0,y:0}),[p,m]=$.useState({scale:1,x:0,y:0}),[g,y]=$.useState(!1),[v,x]=$.useState({x:0,y:0}),[S,b]=$.useState("idle"),[w,Q]=$.useState("idle"),P=Cn(U=>U.themeName),T=$.useCallback(async()=>{try{if(s(!0),a(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const U=await Oxt(P),te=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:L}=await U.render(te,e);if(!L||typeof L!="string"||L.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(L)}catch(U){console.error("Mermaid rendering error:",U);const te=U instanceof Error?U.message:"Failed to render mermaid diagram";a(te),c("")}finally{s(!1)}},[e,t,P]);$.useEffect(()=>{T().catch(U=>{console.error("Error in renderDiagram effect:",U),a("Failed to initialize diagram rendering"),s(!1)})},[T]);const _=$.useCallback(()=>{try{if(!l||!r.current)return 1;const te=r.current.getBoundingClientRect(),L=document.createElement("div");L.innerHTML=l;const B=L.querySelector("svg");if(!B)return 1;const Oe=B.getBoundingClientRect?.()?.width||Number.parseFloat(B.getAttribute("width")||"0")||B.viewBox?.baseVal?.width||800,F=B.getBoundingClientRect?.()?.height||Number.parseFloat(B.getAttribute("height")||"0")||B.viewBox?.baseVal?.height||600,H=te.width*.9/Oe,ne=te.height*.9/F;return Math.min(H,ne,1)}catch(U){return console.error("Error calculating fullscreen scale:",U),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const U=_();m({scale:U,x:0,y:0})}catch(U){console.error("Error setting fullscreen transform:",U)}},100)},[u,l,_]);const R=$.useCallback((U=!1)=>{try{(U?m:h)(L=>({...L,scale:Math.min(L.scale*1.2,10)}))}catch(te){console.error("Error in zoom in:",te)}},[]),q=$.useCallback((U=!1)=>{try{(U?m:h)(L=>({...L,scale:Math.max(L.scale/1.2,.1)}))}catch(te){console.error("Error in zoom out:",te)}},[]),A=$.useCallback((U=!1)=>{try{const te=U?m:h;if(U){const L=_();te({scale:L,x:0,y:0})}else te({scale:1,x:0,y:0})}catch(te){console.error("Error in reset:",te)}},[_]),C=$.useCallback(()=>{if(l)try{const U=new Blob([l],{type:"image/svg+xml"}),te=URL.createObjectURL(U),L=document.createElement("a");L.href=te,L.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(te)}catch(U){console.error("Failed to save SVG:",U)}},[l]),N=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),b("copied"),setTimeout(()=>b("idle"),1200)}catch(U){console.error("Failed to copy Mermaid chart text:",U)}},[e]),I=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),Q("copied"),setTimeout(()=>Q("idle"),1200)}catch(U){console.error("Failed to copy Mermaid chart text:",U)}},[e]),W=$.useCallback(U=>{try{y(!0),x({x:U.clientX,y:U.clientY}),U.preventDefault()}catch(te){console.error("Error in mouse down:",te)}},[]),G=$.useCallback((U,te=!1)=>{try{if(!g)return;const L=U.clientX-v.x,B=U.clientY-v.y;(te?m:h)(F=>({...F,x:F.x+L,y:F.y+B})),x({x:U.clientX,y:U.clientY})}catch(L){console.error("Error in mouse move:",L)}},[g,v]),D=$.useCallback(()=>{try{y(!1)}catch(U){console.error("Error in mouse up:",U)}},[]),j=$.useCallback((U,te=!1)=>{try{U.preventDefault();const L=U.deltaY>0?.9:1.1;(te?m:h)(Oe=>({...Oe,scale:Math.min(Math.max(Oe.scale*L,.1),5)}))}catch(L){console.error("Error in wheel:",L)}},[]),V=$.useCallback(U=>{try{O(U)}catch(te){console.error("Error toggling fullscreen:",te)}},[]);if(i)return f.jsxs(hj,{title:"Mermaid diagram error",children:[i,f.jsx("span",{className:E("mt-2 block text-ink-muted"),children:"Chart"}),f.jsx("span",{className:E("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const J=(U=!1)=>{try{const te=U?r:n,L=U?p:d;return f.jsx("div",{ref:te,className:E("mermaid flex w-full items-center justify-center",U?"h-full min-h-full":"h-auto min-h-50",g?"cursor-grabbing":"cursor-grab"),onMouseDown:W,onMouseMove:B=>G(B,U),onMouseUp:D,onMouseLeave:D,onWheel:B=>j(B,U),children:o?f.jsx("div",{className:E("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?f.jsx("div",{className:E("flex h-full w-full items-center justify-center"),style:{transform:`translate(${L.x}px, ${L.y}px) scale(${L.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(te){return console.error("Error rendering diagram content:",te),f.jsx(hj,{title:"Rendering error",children:"Failed to render diagram content."})}};return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:E("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[J(!1),f.jsx(PL,{className:"top-2 right-2",copied:S==="copied",onZoomIn:()=>R(!1),onZoomOut:()=>q(!1),onReset:()=>A(!1),onSave:C,onCopy:N,children:f.jsx(wt,{content:"Fullscreen",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>V(!0),children:f.jsx(mae,{})})})})]}),f.jsx(N0,{open:u,onClose:()=>V(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:f.jsxs("div",{className:E("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[J(!0),f.jsx(PL,{className:"top-4 right-4",copied:w==="copied",onZoomIn:()=>R(!0),onZoomOut:()=>q(!0),onReset:()=>A(!0),onSave:C,onCopy:I,children:f.jsx(wt,{content:"Close fullscreen",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>V(!1),children:f.jsx(zi,{})})})})]})})]})}),hxt=$.memo(e=>f.jsx(dxt,{children:f.jsx(fxt,{...e})}));let Sve=!1,zT=null;const pxt=()=>(zT||(zT=ge(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(Sve=!0,e))),zT),mxt=/language-(\w+)/,gxt=GS,$xt=new RegExp(`^[^${Qc}\\d*+-]`),yxt=/\n$/,Qve=({href:e,children:t})=>{const n=Eye(e),r=ck();return!n||n.kind==="other"?f.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):f.jsx("a",{href:n.target,"data-lo-kind":n.kind,"data-lo-target":n.target,draggable:!1,target:n.kind==="url"?"_blank":void 0,rel:n.kind==="url"?"noopener noreferrer":void 0,onClick:n.kind==="file"?i=>wxt(i,r):void 0,children:t})},vxt=e=>Eye(e)?.kind==="file",bxt=Aye,wxt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(zye)??"file",i=n.getAttribute(bxt),a=Bvt({kind:r,hasHighlight:Obt(n),canOpenInCanvas:F9(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||rO(i)});return}rO(i)}},pj=(e,t)=>t==="href"&&vxt(e)?e:ece(e),S$={a:Qve,table:Bwt,img:Awt,code:({node:e,className:t,children:n,...r})=>mxt.exec(t??"")?.[1]==="mermaid"?f.jsx(hxt,{chart:String(n).replace(yxt,"")}):f.jsx("code",{className:t,...r,children:n})},xxt={...S$,a:wwt(Qve)},Sxt=[Ic],Qxt=[Ic,pk],kxt=[Ic,uk],Pxt=[Ic,pk,uk],_xt=[Ic,hk,Ok],Txt=[Ic,pk,hk,Ok],Xxt=[Ic,uk,hk,Ok],Rxt=[Ic,pk,uk,hk,Ok],Ext={"000":Sxt,"001":_xt,"010":kxt,"011":Xxt,100:Qxt,101:Txt,110:Pxt,111:Rxt},qxt=[],jxt=[LGe],kve=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),Pve=(e,t,n)=>{const r=$.useMemo(()=>rxt(e),[e]),[i,a]=$.useState(Sve),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return pxt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:Ext[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?jxt:qxt}},_ve=(e,t)=>{const[,n]=$.useState(0);$.useEffect(()=>{if(!t)return;const r=TDe(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=Kvt(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return Cye(r,window.api?.probeFiles,Xie).then(()=>{i&&r.some(s=>jye(s)!=="unknown")&&n(s=>s+1)}),()=>{i=!1,o()}},[e,t])},Q$=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1})=>{const a=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:o,rehypePlugins:s}=Pve(a,r,i),l=kve(t);return _ve(a,r),f.jsx("div",{className:E("lo-markdown",n),style:l,children:f.jsx(iq,{remarkPlugins:o,rehypePlugins:s,urlTransform:pj,components:i?xxt:S$,children:a})})});Q$.displayName="MarkdownRenderer";const _L={...S$,a:({children:e})=>f.jsx(f.Fragment,{children:e})},Tve=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:tL(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=Fye(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=Pve(n,t,!1);if(_ve(e,t),r!==null){const o=tL(r.before);return f.jsxs(f.Fragment,{children:[o.trim()!==""&&f.jsx(iq,{remarkPlugins:i,rehypePlugins:a,urlTransform:pj,components:t?S$:_L,children:o}),f.jsx(Cxt,{info:r.info,body:r.body})]})}return f.jsx(iq,{remarkPlugins:i,rehypePlugins:a,urlTransform:pj,components:t?S$:_L,children:n})});Tve.displayName="ParsedBlock";const Cxt=({info:e,body:t})=>{const n=e.split(gxt)[0];return f.jsx("pre",{children:f.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
821
821
  `)?"":`
822
822
  `}`})})},Xve=({content:e,styleProps:t,className:n})=>{const r=$.useRef(null);r.current===null&&(r.current=pbt());const i=r.current;ybt(i,e);const{blockStart:a}=i,o=a+vbt(e.slice(a));let s=null,l=a;(i.kind==="other"||(i.kind==="list"||i.kind==="indented-code")&&$xt.test(e.slice(i.cursor)))&&i.fence===null&&i.blankRunStart>=a&&i.cursor<o&&e.slice(i.cursor,o).trim().length>0&&(s=e.slice(a,i.blankRunStart),l=i.cursor);const c=e.slice(l,o),u=i.blocks.map((d,h)=>({key:h,source:d,closed:!0}));s!==null&&u.push({key:i.blocks.length,source:s,closed:!0}),c!==""&&u.push({key:u.length,source:c,closed:!1});const O=kve(t);return f.jsx("div",{className:E("lo-markdown",n),style:O,children:u.map(d=>f.jsx(Tve,{source:d.source,closed:d.closed},d.key))})};Xve.displayName="StreamingMarkdown";const fo=({isUser:e,children:t,className:n})=>e?f.jsx("div",{className:E("flex w-full justify-end",n),children:t}):f.jsx("div",{className:E("group relative w-full",n),children:t}),rA=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},zxt=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()+1),Math.max(1,t.getTime()-e)};let iA=rA(Date.now()),Su=null;const F1=new Set,Rve=()=>{Su!==null&&clearTimeout(Su),Su=setTimeout(()=>{Su=null,iA=rA(Date.now());for(const e of F1)e();Rve()},zxt(Date.now())),Su.unref?.()},Axt=e=>(F1.add(e),iA=rA(Date.now()),Rve(),()=>{F1.delete(e),F1.size===0&&Su!==null&&(clearTimeout(Su),Su=null)}),TL=()=>iA,Uxt=()=>$.useSyncExternalStore(Axt,TL,TL),Wxt=e=>new Date(e+1e3),Yxt=()=>Wxt(Uxt()),ytn=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":eae(t,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},Nxt=(e,t=new Date)=>{if(e==null)return"";try{const n=e instanceof Date?e:new Date(e);if(Number.isNaN(n.getTime()))return"";const r=STe(n,{hour:"numeric",minute:"2-digit",hour12:!0});if(n.toDateString()===t.toDateString())return r;const i=new Date(t);if(i.setDate(t.getDate()-1),n.toDateString()===i.toDateString())return`Yesterday ${r}`;const a=eae(n,{month:"short",day:"numeric"});return n.getFullYear()===t.getFullYear()?`${a}, ${r}`:`${a}, ${n.getFullYear()}, ${r}`}catch(n){return console.error("Error formatting turn timestamp:",n),""}},Gxt=(e,t)=>{if(!e)return"";try{const n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?"":QTe(n,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",...t})}catch(n){return console.error("Error formatting calendar date-time:",n),""}},Zxt={turn:"Sent",answer:"Answered",tool:"Ran"},Qx=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=Yxt();if(Number.isNaN(r.getTime()))return null;const a=Gxt(r,{hour12:!0});return f.jsx(wt,{content:a,side:"bottom",delayDuration:1200,children:f.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":`${Zxt[t]} ${a}`,className:E("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:Nxt(r,i)})})},aA=({replies:e,onRemoveReply:t})=>f.jsxs("div",{className:"mb-2 flex flex-col gap-1.5 rounded-sm bg-sunken p-2",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-ink-dim",children:[f.jsx(gae,{size:12,"aria-hidden":"true"}),f.jsx("span",{className:"text-meta",children:"Replying to"})]}),e.map(n=>f.jsxs("div",{className:"flex items-center gap-2 border-hairline border-l-2 py-0.5 pl-2",children:[f.jsx("span",{className:"flex-1 truncate text-body-sm text-ink-muted",title:n.text,children:n.text}),t&&f.jsx(Se,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-ink-dim hover:bg-elevated hover:text-ink",onClick:()=>t(n.id),"aria-label":"Remove reply",children:f.jsx(zi,{"aria-hidden":"true"})})]},n.id))]}),Ixt=({children:e,className:t})=>f.jsx("span",{"aria-hidden":!0,className:E("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),Dxt={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},Vxt=({line:e})=>f.jsx("span",{className:E(Dxt[e.kind],"block"),children:e.text}),Mxt=({diff:e,className:t})=>{const n=HPe(e);return f.jsxs("div",{className:E("max-h-[740px] overflow-y-auto overflow-x-hidden rounded-md bg-sunken p-3 font-mono text-ink text-mono-sm whitespace-pre-wrap break-words",t),children:[n.lines.map((r,i)=>f.jsx(Vxt,{line:r},i)),n.hidden>0&&f.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:KPe(n.hidden)})]})},Lxt=(e,t=72)=>{let i=e.replace(/```[\s\S]*?```/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/\s+/g," ").trim();if(i.length>t){const a=i.slice(0,t),o=a.lastIndexOf(" ");i=`${a.slice(0,o>32?o:t).trimEnd()}…`}return i.replace(/[.!?…]+$/g,"").trimEnd()},XL=e=>e.startsWith("file://")?e.slice(7):e,Fxt={READ:{verb:"Read",runningVerb:"Reading",icon:WC},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:wae},EDIT:{verb:"Edited",runningVerb:"Editing",icon:_Re},CODE:{verb:"Ran code",runningVerb:"Running code",icon:Oae},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:DRe},DONE:{verb:"Finished",runningVerb:"Finishing",icon:qC},ASK:{verb:"Asked",runningVerb:"Asking",icon:MS},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:wXe}},Bxt={verb:"Worked on the request",runningVerb:"Working on the request",icon:Oae},Hxt=(e,t,n,r)=>{const i=e?Fxt[e]:Bxt;let a;if(t)a=XL(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=XL(s[0]):s.length>1&&(a=`${s.length} files`)}const o=!a&&r?Lxt(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:a,narration:o||void 0,icon:i.icon}},RL="min-h-5 py-0",Kxt=({icon:e,verb:t,object:n,narration:r,running:i,failed:a,wrap:o})=>f.jsxs("span",{className:E("flex min-w-0 gap-2",o?"items-start":"items-center"),"aria-busy":i||void 0,children:[f.jsx(Ixt,{className:E(a?"text-danger":"text-ink-dim",o&&Aoe),children:e}),f.jsxs("span",{className:E(o?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[f.jsxs("span",{...VP,className:E("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?f.jsxs("span",{...VP,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?f.jsxs("span",{...VP,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),EL=({action:e,filePath:t,files:n,narration:r,running:i=!1,failed:a=!1,defaultOpen:o=!1,details:s,className:l,verbOverride:c,object:u,glyph:O,wrap:d,dense:h=!1})=>{const p=Hxt(e,t,n,r),m=c??(i?p.runningVerb:p.verb),g=a?Nh:p.icon,y=a||!c||!O?f.jsx(g,{}):O,v=f.jsx(Kxt,{icon:y,verb:m,object:c?u:p.object,narration:c?r:p.narration,running:i,failed:a,wrap:d}),x=d?"firstLine":"center";return s?f.jsx(qi,{summary:v,chevron:"leading",summaryAlign:x,defaultOpen:o,className:l,rowClassName:h?RL:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):f.jsx(qi,{disabled:!0,summary:v,summaryAlign:x,className:l,rowClassName:h?RL:void 0})},Eve=8,Jxt="… deeper values not shown",eSt="(empty)";function tSt(e){return`… ${e} more line${e===1?"":"s"}`}const qL=.5;function nSt(e,t,n,r){if(!Number.isFinite(t)||t<=0)return 0;let i=0;for(const a of e){if(a.height<=0)continue;const o=Math.max(1,Math.round(a.height/t));for(let s=1;s<=o;s++)a.top+s*t>n+r&&i++}return i}function qve(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function oA(e){return typeof e=="object"&&e!==null}function jve(e,t,n,r){if(n>Eve){r.push({key:t,value:Jxt,depth:n});return}if(oA(e)){for(const[a,o]of Object.entries(e))jve(o,t?`${t}.${a}`:a,n+1,r);return}const i=qve(e);i!==null&&r.push({key:t,value:i,depth:n})}function Cve(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))jve(r,n,1,t);return t}const rSt=512;function iSt(e,t){if(t)return!0;if(!e)return!1;let n=rSt;const r=(i,a)=>{if(n--<=0||a>Eve)return!0;if(!oA(i))return qve(i)!==null;for(const o of Object.values(i))if(r(o,a+1))return!0;return!1};for(const i of Object.values(e))if(r(i,1))return!0;return!1}function aSt(e){if(!e)return null;const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;let n;try{n=JSON.parse(t)}catch{return null}if(!oA(n))return null;const r=Cve(n);return r.length>0?r:[{key:"",value:eSt,depth:1}]}const oSt=8,mj="max-h-[min(320px,40vh)]",zve=mj,sSt=({line:e})=>f.jsxs("div",{className:E("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*oSt},children:[e.key?f.jsxs("span",{className:E("text-ink-muted"),children:[e.key,": "]}):null,f.jsx("span",{className:E("text-ink-dim"),children:e.value})]}),jL=({lines:e,label:t})=>f.jsx("div",{className:E("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>f.jsx(sSt,{line:n},r))});function CL(e){const[t,n]=$.useState(0),[r,i]=$.useState(!1);return $.useLayoutEffect(()=>{const a=e.current;if(!a)return;const o=a.firstElementChild,s=()=>{const c=o??a,u=Number.parseFloat(getComputedStyle(c).lineHeight);if(!Number.isFinite(u)||u<=0){n(0),i(!1);return}const O=a.getBoundingClientRect(),d=c.getBoundingClientRect();i(d.height>O.height+qL);const h=c.children.length>0?Array.from(c.children):[c];n(nSt(h.map(p=>{const m=p.getBoundingClientRect();return{top:m.top,height:m.height}}),u,O.bottom,qL))};s(),a.addEventListener("scroll",s,{passive:!0});const l=new ResizeObserver(s);return l.observe(o??a),()=>{a.removeEventListener("scroll",s),l.disconnect()}}),{lines:t,overflowing:r}}const zL=({lines:e,overflowing:t})=>t?f.jsx("span",{className:E("mt-1 block text-ink-dim"),children:e>0?tSt(e):" "}):null,lSt=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{const a=Cve(e),o=aSt(t),s=$.useRef(null),l=$.useRef(null),c=CL(s),u=CL(l);return a.length===0&&!t&&!i?null:f.jsxs("div",{className:E("w-full rounded-md bg-sunken p-3 font-mono text-mono-sm"),children:[a.length>0&&f.jsxs("div",{"data-detail-section":"input",children:[f.jsx("div",{ref:s,className:E(mj,"overflow-auto"),children:f.jsx(jL,{lines:a,label:"input"})}),f.jsx(zL,{lines:c.lines,overflowing:c.overflowing})]}),i&&f.jsx("div",{className:E("whitespace-normal font-sans text-body-sm text-ink-muted",a.length>0&&"mt-3"),"data-detail-section":"note",children:i}),t&&f.jsxs("div",{className:E(a.length>0&&"mt-3"),"data-detail-section":"output",children:[f.jsx("span",{className:E("mb-1 block text-meta",n&&!r?"text-danger":"text-ink-dim"),children:r?"Interrupted":n?"Error":"Output"}),f.jsx("div",{ref:l,className:E(mj,"overflow-auto"),children:o?f.jsx(jL,{lines:o,label:"result-json"}):f.jsx("pre",{className:E("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),f.jsx(zL,{lines:u.lines,overflowing:u.overflowing})]})]})},cSt="mcp__",uSt={bash:HRe,read:FS,write:ZU,edit:ZU,glob:Gh,grep:$y,todo:tRe,wake:LS,list_variables:VU,read_variable:VU,browser:IU,console:ZC,project:mXe,project_delete:JRe,web_search:IU,web_fetch:my,task:ud,agent:ud,send:Qae,peer:MXe,sessions:RRe};function OSt(e){const t=e.trim().toLowerCase(),n=uSt[t];return n||(t.startsWith(cSt)?xae:s4e)}const dSt=YC,fSt=sRe,hSt=aRe,AL="min-h-5 py-0",UL={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},pSt=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?UL.plain:UL[JPe(t)],mSt=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",gSt=({added:e,removed:t})=>e<=0&&t<=0?null:f.jsxs("span",{className:E("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&f.jsxs("span",{className:E("text-success"),children:["+",e]}),t>0&&f.jsxs("span",{className:E("text-danger"),children:["-",t]})]}),AT={running:"",success:"succeeded",error:"failed",interrupted:"interrupted","not-run":"never ran",partial:"",receipt:""},$St=1e3;function ySt(e){const[t,n]=$.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return $.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,$St);return()=>window.clearInterval(i)},[e]),t}const vSt=({outcome:e,deliveryState:t=null,durationS:n,startedAt:r})=>{const i=e==="running",a=ySt(i?r??null:null),o=e==="error"||e==="not-run",s=e==="partial",l=t?t5e[t]:void 0,c=s?l??null:o?l??AT[e]:null,O=E("font-medium text-meta",s?"text-warning":"text-danger",s&&"hidden @[19rem]/toolrow:inline"),d=s&&t?r5e[t]??null:null,h=s&&t?n5e[t]:void 0,p=s?t==="mailbox"?fSt:t==="unconfirmed"?hSt:null:e==="interrupted"?dSt:null,m=p&&s?"text-warning":"text-ink-dim",g=i?r==null?"":Du(a??0):xC(n);return f.jsxs("span",{className:E("flex shrink-0 items-center gap-1.5"),children:[c?f.jsx("span",{className:O,title:h,"aria-hidden":d?!0:void 0,children:c}):null,f.jsxs("span",{className:E("flex shrink-0 [&_svg]:size-3.5",p&&"size-3.5",m),children:[p?f.jsx(p,{"aria-hidden":!0}):null,!o&&AT[e]?f.jsx("span",{className:E("sr-only"),children:AT[e]}):null,d?f.jsx("span",{className:E("sr-only"),children:d}):null]}),f.jsx("span",{className:E("hidden w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums @[19rem]/toolrow:inline"),children:g})]})},Gu=({toolName:e,op:t="",verbless:n=!1,summary:r,summaryFallback:i=null,summaryHold:a=!1,outcome:o,deliveryState:s=null,durationS:l,startedAt:c=null,added:u=0,removed:O=0,details:d,defaultOpen:h=!1,className:p,media:m})=>{const g=o==="running",y=o==="error",v=OSt(e),x=U0(e),{verb:S,object:b}=Rie(e,r,i,g,t,e5e(s)),w=f.jsxs("span",{className:E("flex min-w-0 flex-1 items-center gap-2"),children:[f.jsx("span",{"aria-hidden":!0,className:E("flex size-3.5 shrink-0 [&_svg]:size-3.5",pSt(o,e)),children:f.jsx(v,{})}),n?null:f.jsx("span",{"data-trace-verb":"",className:E("shrink-0 whitespace-nowrap text-body-sm",mSt(o)),title:x,children:S}),f.jsx("span",{className:E("min-w-0 flex-1 truncate font-mono text-ink-muted text-mono-sm"),title:a?void 0:b,children:a?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"text-ink-dim","data-label-hold":"true","aria-hidden":!0,children:"…"}),f.jsx("span",{className:E("sr-only"),children:"pending"})]}):b}),f.jsx(gSt,{added:u,removed:O}),f.jsx(vSt,{outcome:o,deliveryState:s,durationS:l,startedAt:c})]}),Q=g?{"data-glass-state":"running"}:void 0,P=g?"bg-elevated":y?"bg-danger-wash":"hover:bg-row-hover",T=d?f.jsx(qi,{summary:w,chevron:"leading",defaultOpen:h,className:E("@container/toolrow",p),triggerData:Q,rowClassName:AL,triggerClassName:E("-mx-2 rounded-sm px-2",P),children:d}):f.jsx(qi,{disabled:!0,summary:w,triggerData:Q,rowClassName:AL,className:E("@container/toolrow",(g||y)&&E("-mx-2 rounded-sm px-2",P),p)});return m?f.jsxs("div",{className:E("flex flex-col"),children:[T,m]}):T},bSt=3,wSt=2;function xSt(e){const t={incoming:0,job_result:0,wake:0,monitor_prompt:0};let n=!1,r=!1;for(const{record:o}of e){const s=i5e(o);s&&(t[s]+=1),o.kind==="custom"&&(o.receipt?.expectsReply===!0&&(n=!0),o.receipt?.steer===!0&&(r=!0))}const i=[],a=(o,s,l)=>{o>0&&i.push(`${o} ${o===1?s:l}`)};return a(t.incoming,"incoming message","incoming messages"),a(t.job_result,"job result","job results"),a(t.wake,"wake receipt","wake receipts"),a(t.monitor_prompt,"monitor prompt","monitor prompts"),a(e.length-t.incoming-t.job_result-t.wake-t.monitor_prompt,"other receipt","other receipts"),n&&i.push("Reply requested"),r&&i.push("Steered"),i}const Ave=e=>{const t=e.toLowerCase();return t==="read"||t==="grep"||t==="glob"||t==="ls"||t==="list"?"files":t==="search_the_web"||t==="web_search"||t==="search"?"web":t==="bash"||t==="exec"||t==="shell"||t==="run"?"commands":t==="edit"||t==="write"||t==="multiedit"?"edits":t==="task"||t==="delegate"?"delegated":t==="fetch"||t==="web_fetch"||t==="fetch_url"?"searches":null},Uve=e=>{const t=new Map;let n=0;for(const a of e){const o=Ave(a.name);o===null?n+=1:t.set(o,(t.get(o)??0)+1)}if(n>0||t.size>2){const a=Wve(Yve(e));return{units:a.length===0?[`${e.length} actions`]:a,prose:!1}}const r=["files","searches","web","commands","edits","delegated"],i=[];for(const a of r){const o=t.get(a)??0;o!==0&&(a==="files"&&i.push(`Explored ${o} file${o===1?"":"s"}`),a==="searches"&&i.push(`${o} search${o===1?"":"es"}`),a==="web"&&i.push(`Searched the web ${o} time${o===1?"":"s"}`),a==="commands"&&i.push(`Ran ${o} command${o===1?"":"s"}`),a==="edits"&&i.push(`Edited ${o} file${o===1?"":"s"}`),a==="delegated"&&i.push(`Delegated ${o} task${o===1?"":"s"}`))}return i.length===0?{units:[`${e.length} actions`],prose:!0}:{units:[i.length===1?i[0]:`${i[0]}, ${i[1].charAt(0).toLowerCase()}${i[1].slice(1)}`],prose:!0}},SSt=e=>Uve(e).units;function QSt(e){return SSt(e).join(" · ")}const UT={agent:{noun:"agent",plural:"agents"},team:{noun:"team",plural:"teams"},team_delete:{noun:"team deletion",plural:"team deletions"},hub:{noun:"subagent",plural:"subagents"},secret:{noun:"secret",plural:"secrets"},project:{noun:"project",plural:"projects"},project_delete:{noun:"project deletion",plural:"project deletions"},wake:{noun:"wake",plural:"wakes"},jobs:{noun:"job check",plural:"job checks"},console:{noun:"console",plural:"consoles"},network:{noun:"network call",plural:"network calls"},browser:{noun:"browser action",plural:"browser actions"},todo:{noun:"todo update",plural:"todo updates"},send:{noun:"message",plural:"messages"},ask:{noun:"question",plural:"questions"},wait:{noun:"wait",plural:"waits"},lsp:{noun:"code lookup",plural:"code lookups"},web_read:{noun:"page",plural:"pages"},list_variables:{noun:"variable lookup",plural:"variable lookups"},read_variable:{noun:"variable read",plural:"variable reads"},sessions:{noun:"session",plural:"sessions"}},WT=5,Wve=e=>{if(e.length<=WT)return e.map(r=>r.label);const t=e.slice(0,WT),n=e.slice(WT).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),`and ${n} other action${n===1?"":"s"}`]},Yve=e=>{const t=new Map,n=(s,l)=>{const c=t.get(s);c?c.count+=1:t.set(s,{kind:l,count:1})};for(const s of e){const l=s.name.toLowerCase();if(l==="bash"||l==="exec"||l==="shell"||l==="run"){n("kind:shell",{noun:"shell",plural:null});continue}if(l==="eval"){n("kind:python",{noun:"python",plural:null});continue}const c=Ave(s.name);if(c==="files")n("class:files",{noun:"file",plural:"files"});else if(c==="searches")n("class:searches",{noun:"search",plural:"searches"});else if(c==="web")n("class:web",{noun:"web search",plural:"web searches"});else if(c==="edits")n("class:edits",{noun:"edit",plural:"edits"});else if(c==="delegated")n("class:delegated",{noun:"task",plural:"tasks"});else if(l==="todo")(s.op??"").toLowerCase()==="view"?n("kind:todo:view",{noun:"todo read",plural:"todo reads"}):n("kind:todo",UT.todo);else if(l==="jobs")(s.op??"").toLowerCase()==="cancel"?n("kind:jobs:cancel",{noun:"job cancellation",plural:"job cancellations"}):n("kind:jobs",UT.jobs);else{const u=UT[l];if(u)n(`kind:${l}`,u);else{const O=U0(s.name);n(`name:${O}`,{noun:O,plural:null})}}}const r=["class:files","class:searches","class:web","kind:shell","kind:python","class:edits","class:delegated","kind:agent","kind:team","kind:hub"],i=[],a=(s,l)=>`${s} ${s===1||l.plural===null?l.noun:l.plural}`;for(const s of r){const l=t.get(s);l&&i.push({label:a(l.count,l.kind),count:l.count})}const o=[...t.entries()].filter(([s])=>!r.includes(s)).sort(([,s],[,l])=>l.count-s.count||s.kind.noun.localeCompare(l.kind.noun));for(const[,s]of o)i.push({label:a(s.count,s.kind),count:s.count});return i};function kSt(e){return e.running===!0?typeof e.startedAtMs!="number"?null:{startMs:e.startedAtMs,endMs:null}:typeof e.endedAtMs!="number"||typeof e.durationS!="number"?null:{startMs:e.endedAtMs-e.durationS*1e3,endMs:e.endedAtMs}}function PSt(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=kSt(i);a&&(t=t===null?a.startMs:Math.min(t,a.startMs),a.endMs!==null&&(n=n===null?a.endMs:Math.max(n,a.endMs)))}return t===null||n===null&&!r?null:{startedAtMs:t,endedAtMs:n,running:r}}function _St(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return Rie(n.name,n.summary??"",null,!0,n.op)}return null}function TSt(e,t){let n=0;for(let r=e.length-1;r>=0&&t(e[r]);r-=1)n+=1;return n}function XSt(e,t){const n=[];let r=[];const i=()=>{if(r.length===0)return;const a=r.filter(O=>t.isReceipt?.(O)),o=r.filter(O=>t.isFoldable(O)).map(O=>{const d={name:t.nameOf(O),failed:t.failedOf(O),durationS:t.durationOf?t.durationOf(O):null,startedAtMs:t.startedAtOf?t.startedAtOf(O):null,endedAtMs:t.endedAtOf?t.endedAtOf(O):null};return t.summaryOf&&(d.summary=t.summaryOf(O)),t.opOf&&(d.op=t.opOf(O)),t.runningOf&&(d.running=t.runningOf(O)),t.executingOf&&(d.executing=t.executingOf(O)),d}),s=a.length?t.receiptSummaryOf?.(a)??[]:[],l=s.length>0?s:a.length>0?[`${a.length} receipt${a.length===1?"":"s"}`]:[],c=t.isReceipt?TSt(r,t.isReceipt):0,u=t.liveTurn===!0&&t.latchedFoldIds!==void 0&&r.some(O=>t.latchedFoldIds?.has(O.record.id)===!0);if(o.length>=bSt||c>=wSt||u){const O=o.length===0?{units:[],prose:!1}:l.length>0?{units:Wve(Yve(o)),prose:!1}:Uve(o);n.push({kind:"run",id:r[0].record.id,gap:r[0].gap,rows:r,actions:o,summary:{units:[...O.units,...l],prose:O.prose},failedCount:o.filter(d=>d.failed).length,span:PSt(o),live:_St(o)})}else for(const O of r)n.push({kind:"row",row:O});r=[]};for(const a of e){if((a.gap==="turn"||a.gap==="first")&&i(),t.isFoldable(a)||t.isReceipt?.(a)){r.push(a);continue}i(),n.push({kind:"row",row:a})}return i(),n}function RSt(e,t,n){const r=new Set;for(const i of e)t.has(i)&&r.add(i);for(const i of n)if(i.kind==="run")for(const a of i.rows)r.add(a.record.id);return r}const WL=e=>{const t=[];for(const n of e)if(!(n.record.kind!=="tool"&&!(n.record.kind==="custom"&&n.record.customType==="hub_message")))for(const r of n.record.images??[])W0(r)&&t.push(r);return t},B1=5,ESt=(e,{uncapped:t=!1}={})=>t?{shown:Math.max(e,0),more:0}:e<B1?{shown:Math.max(e,0),more:0}:{shown:B1-1,more:e-(B1-1)},qSt=e=>{const t=B1-1;if(e<=0)return[];if(e<=t)return[e];const n=Array.from({length:Math.floor(e/t)},()=>t),r=e%t;return r===1?(n[n.length-1]=t-1,n.push(2)):r>1&&n.push(r),n},kx=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function Px(e){return e.record.kind==="tool"?e.record.durationS:null}function Nve(e){let t=null;for(const n of e){const r=Px(n);typeof r=="number"&&(t=(t??0)+r)}return t}function jSt(e,t){const n=new Map,r=t.opensRun??(l=>l.gap==="turn"||l.gap==="first");let i=0,a=0,o=null,s=null;for(const l of e){if(r(l)&&(i=0,a=0,o=null,s=null),t.isAction(l)){i+=1,t.failedOf(l)&&(a+=1,s??=l.record.id);const c=t.durationOf?t.durationOf(l):null;typeof c=="number"&&(o=(o??0)+c)}l.closesTurn&&n.set(l.record.id,{actions:i,failed:a,durationS:o,firstFailedId:s})}return n}const CSt="min-h-5 py-0",zSt=1e3;function ASt(e){const[t,n]=$.useState(()=>Date.now());return $.useEffect(()=>{if(!e)return;const r=()=>n(Date.now());r();const i=window.setInterval(r,zSt);return()=>window.clearInterval(i)},[e]),t}const USt=({summary:e,span:t,live:n,open:r,onOpenChange:i,className:a,condensedMedia:o,mediaCount:s=0,recordIds:l,children:c})=>{const u=ASt(t?.running===!0),O=t===null?null:Math.max(0,((t.running?u:t.endedAtMs??u)-t.startedAtMs)/1e3),d=O===null?"":xC(O),h=$.useRef(null),p=()=>{h.current?.querySelector("button[aria-expanded]")?.focus(),i(!0)};return f.jsxs("div",{ref:h,className:a,"data-fold-ids":l.join(" "),children:[f.jsx(qi,{animate:r||!o,open:r,onOpenChange:i,rowClassName:CSt,triggerClassName:E("-mx-2 rounded-sm px-2","hover:bg-row-hover"),summary:f.jsxs("span",{className:E("flex min-w-0 flex-1 items-center gap-2"),children:[n!==null&&!r&&f.jsxs(f.Fragment,{children:[f.jsxs("span",{"data-fold-live":"",className:E("min-w-0 shrink-[100000] truncate"),title:`${n.verb} ${n.object}`,children:[f.jsx("span",{className:E("text-accent"),children:n.verb})," ",f.jsx("span",{className:E("font-mono text-mono-sm text-ink-muted"),children:n.object})]}),f.jsx("span",{"aria-hidden":!0,className:E("text-ink-dim text-meta"),children:"·"})]}),f.jsx("span",{className:E("min-w-0 break-words text-body-sm text-ink-muted"),title:e.units.join(" · "),"data-fold-summary":"",children:e.units.map((m,g)=>f.jsxs($.Fragment,{children:[g>0&&f.jsx("span",{"aria-hidden":"true",children:" · "}),f.jsx("span",{className:E(e.prose?"whitespace-normal":"whitespace-nowrap"),children:m})]},m))}),kx(s)!==null&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":!0,className:E("text-ink-dim text-meta"),children:"·"}),f.jsx("span",{className:E("shrink-0 text-ink-muted text-meta"),children:kx(s)})]}),d!==""&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":!0,className:E("text-ink-dim text-meta"),children:"·"}),f.jsx("span",{"data-fold-span":"",className:E("shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:d})]})]}),children:f.jsx("div",{className:E("flex flex-col"),children:c})}),!r&&o&&o(p)]})},YL=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],WSt=80,YSt=1e3,Gve=({activity:e,phase:t,startedAt:n,clock:r,className:i})=>{const[a,o]=$.useState(0),[s,l]=$.useState(()=>n===void 0?0:Math.floor((Date.now()-n)/1e3)),[c,u]=$.useState(!1),O=r!==!1&&!c,d=o6("(prefers-reduced-motion: reduce)"),h=$.useRef(n??Date.now()),p=$.useRef(t),m=$.useRef(n);if(p.current!==t)p.current=t,m.current=n,h.current=n??Date.now(),c&&u(!1),l(0);else if(m.current!==n){const v=m.current!==void 0&&n===void 0;m.current=n,u(v),v||(h.current=n,l(Math.floor((Date.now()-n)/1e3)))}const g=$.useRef(r!==!1),y=$.useRef(t);return $.useEffect(()=>{const v=r!==!1,x=g.current,S=y.current===t;g.current=v,y.current=t,!x&&v&&S&&l(Math.floor((Date.now()-h.current)/1e3))},[r,t]),$.useEffect(()=>{const v=O?window.setInterval(()=>l(Math.floor((Date.now()-h.current)/1e3)),YSt):null;if(d)return o(0),()=>{v!==null&&window.clearInterval(v)};const x=window.setInterval(()=>o(S=>(S+1)%YL.length),WSt);return()=>{window.clearInterval(x),v!==null&&window.clearInterval(v)}},[d,O]),f.jsxs("div",{className:E("flex items-center gap-2",i),"data-lo-working-line":!0,"aria-live":"polite",children:[f.jsx("span",{"aria-hidden":!0,className:E("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:YL[a]}),f.jsx("span",{className:E("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),f.jsx("span",{"aria-hidden":!0,className:E("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:O?Du(s):""})]})},NSt="min-h-5 py-0",fu=()=>f.jsx("span",{"aria-hidden":!0,className:E("text-ink-dim text-meta"),children:"·"}),GSt=({recordIds:e,segmentIds:t,anchorRecordId:n,className:r,durationS:i,actionCount:a,partial:o=!1,title:s,stampTs:l,label:c=null,completed:u=!1,open:O,onOpenChange:d,children:h,condensedMedia:p,mediaCount:m=0,group:g=null,episode:y=null})=>{const v=o?`${a}+ actions`:a===1?"1 action":`${a} actions`,x=`At least ${a===1?"1 action":`${a} actions`} — earlier rows of this turn are not loaded`,S=y?.receipts??g?.count,b=S===void 0?null:`At least ${S} messages — earlier rows are not loaded`,w=$.useRef(null),Q=()=>{w.current?.querySelector("button[aria-expanded]")?.focus(),d(!0)};return c===null&&i===null&&a===0&&g===null&&y===null&&m===0?null:f.jsxs("div",{ref:w,className:E("border-b border-hairline pb-3",r),"data-turn-summary":"","data-run-ids":e.join(" "),"data-segment-ids":t?.join(" "),"data-segment-complete":u&&!y?.active?"true":void 0,"data-segment-active":y?.active?"true":void 0,"data-record-id":n,children:[f.jsx(qi,{open:O,onOpenChange:d,chevron:"trailing",rowClassName:NSt,triggerClassName:E("-ml-2 -mr-2 w-[calc(100%+1rem)] rounded-sm pl-2 pr-6","hover:bg-row-hover"),chevronClassName:E("-mr-6","text-ink-muted"),summary:f.jsxs("span",{className:E("flex min-w-0 flex-1 items-center gap-2"),title:s??void 0,children:[c!==null&&f.jsx("span",{className:E("shrink-0 text-body-sm text-ink-muted"),"data-segment-label":"",children:c}),u&&!y?.active&&f.jsx(f.Fragment,{children:f.jsx(qC,{"aria-hidden":!0,className:E("size-3.5 shrink-0 text-success")})}),y?.active?f.jsxs(f.Fragment,{children:[c!==null&&f.jsx(fu,{}),f.jsx("span",{className:"shrink-0 text-body-sm text-ink-muted",title:o?b??void 0:void 0,"aria-label":o?b??void 0:void 0,children:o?`${y.receipts}+`:y.receipts}),a>0&&f.jsxs(f.Fragment,{children:[f.jsx(fu,{}),f.jsx("span",{className:"shrink-0 text-body-sm text-ink-muted",title:o?x:void 0,children:v})]}),y.phaseLine!==null&&f.jsxs(f.Fragment,{children:[f.jsx(fu,{}),f.jsx(Gve,{activity:y.phaseLine.activity,phase:y.phaseLine.phase,startedAt:y.phaseLine.startedAt,clock:y.phaseLine.clock,className:"min-w-0"})]})]}):g!==null?f.jsxs(f.Fragment,{children:[c!==null&&f.jsx(fu,{}),f.jsx("span",{className:E("shrink-0 text-body-sm text-ink-muted"),title:o?b??void 0:void 0,"aria-label":o?b??void 0:void 0,children:o?`${y?.receipts??g.count}+`:`${y?.receipts??g.count}`}),g.spanS!==null&&f.jsxs(f.Fragment,{children:[f.jsx(fu,{}),f.jsx("span",{className:E("shrink-0 text-body-sm text-ink-muted"),children:Du(g.spanS)})]})]}):f.jsxs(f.Fragment,{children:[c!==null&&(i!==null||a>0)&&f.jsx(fu,{}),i!==null&&f.jsxs("span",{className:E("shrink-0 text-body-sm text-ink-muted"),children:["Took ",Du(i)]}),i!==null&&a>0&&f.jsx(fu,{}),a>0&&f.jsx("span",{className:E("shrink-0 text-body-sm text-ink-muted"),title:o?x:void 0,"aria-label":o?x:void 0,children:v})]}),kx(m)!==null&&f.jsxs(f.Fragment,{children:[f.jsx(fu,{}),f.jsx("span",{className:E("shrink-0 text-body-sm text-ink-muted"),children:kx(m)})]}),u&&!y?.active&&f.jsx("span",{className:E("sr-only"),children:"completed"}),l!==null&&f.jsx("span",{className:E("ml-auto"),children:f.jsx(Qx,{timestamp:l,scope:"answer"})})]}),children:f.jsx("div",{className:E("flex flex-col"),children:h})}),!O&&p&&f.jsx("div",{className:E("pb-2"),children:p(Q)})]})},Zve="lo-missing-session-notice",iO=({children:e,className:t,boundary:n="hairline",...r})=>f.jsx("div",{className:E("flex max-w-full items-center justify-center overflow-hidden","min-h-16 min-w-16 rounded-sm",n==="control"?["bg-media-surface","border border-transparent","transition-colors duration-fast ease-out-quart","group-hover/tile:border-control group-focus-visible/tile:border-control"]:["border border-hairline","bg-sunken"],t),...r,children:e}),ZSt="could not be displayed. It may have been moved, renamed, or deleted.",sA="could not be displayed. Its stored copy is not available to this reader.",Ive="could not be played. Its stored copy is not available to this reader.",Dve=Ive,zd=({name:e,detail:t=ZSt,className:n,compact:r=!1})=>r?f.jsx("div",{className:E("flex h-[78px] w-[117px] items-center justify-center rounded-sm border border-control bg-sunken",n),role:"img","aria-label":`${e} ${t}`,title:`${e} ${t}`,children:f.jsx(DU,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0})}):f.jsxs("div",{className:E("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),children:[f.jsx(DU,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),f.jsxs("span",{className:"min-w-0 text-body-sm text-ink-muted",children:[f.jsx("span",{className:"truncate font-mono text-ink text-mono-sm",children:e}),` ${t}`]})]}),_x=4,Vve=2,ISt=2,Mve=4,Lve=_x+Vve,DSt=.8,VSt=24,NL=.3,GL=1;function MSt(e){return!Number.isFinite(e)||e<=0?1:Math.max(1,Math.floor((e+Vve)/Lve))}function LSt(e,t){const n=Math.min(e,t-e);return Number.isFinite(n)?Math.max(0,Math.min(1,n/VSt)):0}function FSt(e,t){if(t<=0)return[];if(e.length===0)return new Array(t).fill(0);const n=new Array(t),r=e.length/t;for(let i=0;i<t;i+=1){const a=Math.floor(i*r),o=Math.max(a+1,Math.floor((i+1)*r));let s=0;for(let l=a;l<o&&l<e.length;l+=1){const c=e[l];Number.isFinite(c)&&c>s&&(s=c)}n[i]=Math.max(0,Math.min(1,s))}return n}function Fve(e,t,n){const r=MSt(t),i=e===null?null:FSt(e,r),a=[],o=Math.max(1,r-1);for(let s=0;s<r;s+=1){const l=s*Lve,c=l+_x/2,O=(i===null?0:i[s])*n*DSt,d=Math.max(Mve,Math.round(O)),h=NL+(GL-NL)*(s/o);a.push({x:l,width:_x,height:d,alpha:Math.min(GL,h)*LSt(c,t)})}return a}function S0(e){if(!Number.isFinite(e)||e<=0)return"0:00";const t=Math.floor(e),n=Math.floor(t/60),r=t%60;return`${n}:${r.toString().padStart(2,"0")}`}function BSt(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=0)return 0;const r=Math.max(0,Math.min(1,e/t));return!Number.isFinite(n)||n<=0?0:r*n}function HSt(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?0:Math.max(0,Math.min(1,e/t))}function ZL(e,t){return`${S0(e)} of ${S0(t)}`}const KSt=4,IL=1,JSt="flex min-h-11 min-w-11 shrink-0 items-center justify-center text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink disabled:pointer-events-none disabled:text-ink-disabled",Bve=({ownerId:e,src:t,label:n,peaks:r,durationHint:i=null,variant:a="full",className:o})=>{ut();const s=Ti(te=>te.ownerId===e),l=Ti(te=>te.ownerId===e?te.status:"idle"),c=Ti(te=>te.ownerId===e?te.duration:0),[u,O]=$.useState(!1),[d,h]=$.useState(!1);$.useEffect(()=>{(l==="loading"||l==="playing")&&h(!1)},[l]);const p=c>0?c:i??0,m=s&&l==="playing",g=s&&l==="loading",y=d||s&&l==="error",v=$.useRef(null),x=$.useRef(null),S=$.useRef(null),b=$.useRef(null),w=$.useRef(null),[Q,P]=$.useState({width:0,height:0,dpr:1});$.useEffect(()=>{const te=v.current;if(!te)return;const L=()=>{const Oe=te.getBoundingClientRect();P({width:Oe.width,height:Oe.height,dpr:window.devicePixelRatio||1})};L();const B=new ResizeObserver(L);return B.observe(te),()=>B.disconnect()},[]);const T=$.useCallback(te=>{if(!te||Q.width<=0)return;const L=te.getContext("2d");if(!L)return;te.width=Math.max(1,Math.round(Q.width*Q.dpr)),te.height=Math.max(1,Math.round(Q.height*Q.dpr)),L.setTransform(Q.dpr,0,0,Q.dpr,0,0),L.clearRect(0,0,Q.width,Q.height);const B=getComputedStyle(te).color,Oe=Fve(r,Q.width,Q.height);L.fillStyle=B;for(const F of Oe)L.globalAlpha=F.alpha,L.beginPath(),L.roundRect(F.x,(Q.height-F.height)/2,F.width,F.height,ISt),L.fill();L.globalAlpha=1},[Q.width,Q.height,Q.dpr,r]);$.useEffect(()=>{T(x.current),T(S.current)},[T]);const _=$.useRef(null),R=$.useCallback(te=>{const L=HSt(te,p),B=S.current;v.current?.style.setProperty("--sound-progress",`${L*100}%`),B&&(B.style.clipPath=`inset(0 ${(1-L)*100}% 0 0)`);const Oe=S0(te);w.current&&w.current.textContent!==Oe&&(w.current.textContent=Oe);const F=b.current;F&&(F.setAttribute("aria-valuenow",String(Math.floor(te))),F.setAttribute("aria-valuetext",ZL(te,p)))},[p]);$.useEffect(()=>{const te=m||u,L=()=>R(s?u5()?.currentTime??0:N.current);if(!te){L();return}let B=0;const Oe=()=>{const F=_.current??u5()?.currentTime??0;R(F),B=requestAnimationFrame(Oe)};return B=requestAnimationFrame(Oe),()=>cancelAnimationFrame(B)},[m,u,s,R]);const q=$.useCallback(async()=>(h(!1),Ti.getState().play(e,t,{onError:()=>h(!0)})),[e,t]),A=$.useCallback(te=>{const L=Ti.getState();if(m){L.seek(e,te),R(te);return}q().then(B=>{B!==!1&&(Ti.getState().seek(e,te),R(te))})},[e,m,q,R]),C=$.useCallback(async()=>{if(m){Ti.getState().pause(e);return}h(!1),await Ti.getState().toggle(e,t,{onError:()=>h(!0)})},[e,t,m]),N=$.useRef(0),I=$.useRef(null),W=$.useCallback(te=>{const L=v.current;if(!L)return 0;const B=L.getBoundingClientRect();return BSt(te-B.left,B.width,p)},[p]),G=te=>{if(g)return;te.currentTarget.setPointerCapture?.(te.pointerId),I.current={pointerId:te.pointerId,startX:te.clientX,moved:!1,pendingX:te.clientX,raf:0}},D=te=>{const L=I.current;!L||L.pointerId!==te.pointerId||(Math.abs(te.clientX-L.startX)>KSt&&(L.moved||O(!0),L.moved=!0),L.pendingX=te.clientX,L.moved&&L.raf===0&&(L.raf=requestAnimationFrame(()=>{const B=I.current;if(!B)return;B.raf=0;const Oe=W(B.pendingX);_.current=Oe,Ti.getState().scrub(e,Oe),R(Oe)})))},j=te=>{const L=I.current;if(!L||L.pointerId!==te.pointerId)return;L.raf!==0&&cancelAnimationFrame(L.raf),I.current=null,_.current=null,te.currentTarget.releasePointerCapture?.(te.pointerId);const B=W(te.clientX);if(L.moved){N.current=B,O(!1),Ti.getState().seek(e,B),R(B);return}A(B)},V=te=>{const L=u5(),B=s&&L?L.currentTime:0;if(te.key===" "||te.key==="Enter"){te.preventDefault(),C();return}let Oe=null;if(te.key==="ArrowLeft"?Oe=B-IL:te.key==="ArrowRight"?Oe=B+IL:te.key==="Home"?Oe=0:te.key==="End"&&(Oe=p),Oe===null)return;te.preventDefault();const F=Math.max(0,Math.min(p,Oe));A(F)},J=a==="compact",U=`${n} position`;return f.jsxs("div",{"data-sound-player":a,"data-sound-peaks":r?"stored":"flat","data-sound-status":y?"error":u?"scrubbing":s?l:"idle",className:E("flex w-full min-w-0 items-center gap-2",J?"gap-1.5":"gap-2",o),children:[f.jsx("button",{type:"button",className:JSt,disabled:g,onClick:()=>void C(),"aria-label":`${m?"Pause":"Play"} ${n}`,children:g?f.jsx(po,{size:"sm"}):m?f.jsx(uae,{size:22,"aria-hidden":"true"}):f.jsx(uXe,{size:22,"aria-hidden":"true"})}),f.jsx("div",{ref:b,role:"slider",tabIndex:0,"aria-label":U,"aria-valuemin":0,"aria-valuemax":Math.max(0,Math.round(p)),"aria-valuenow":0,"aria-valuetext":ZL(0,p),"data-sound-slider":"",className:E("group relative min-h-11 min-w-0 flex-1 cursor-pointer touch-none select-none","rounded-sm outline-offset-2 focus-visible:outline-2 focus-visible:outline-accent",y&&"cursor-default"),onPointerDown:G,onPointerMove:D,onPointerUp:j,onPointerCancel:j,onKeyDown:V,children:f.jsxs("div",{ref:v,className:"absolute inset-0",children:[f.jsx("canvas",{ref:x,className:"absolute inset-0 h-full w-full text-ink-dim"}),f.jsx("canvas",{ref:S,style:{clipPath:"inset(0 100% 0 0)"},className:"absolute inset-0 h-full w-full text-ink-muted"}),f.jsx("span",{"data-sound-thumb":"",className:E("pointer-events-none absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-ink-muted group-hover:bg-ink group-focus-visible:bg-accent",u&&"bg-accent"),style:{left:"var(--sound-progress, 0%)"}})]})}),f.jsx("span",{ref:w,"data-sound-time":"",className:E("min-w-10 shrink-0 text-center text-meta text-ink-muted tabular-nums"),children:S0(0)}),f.jsx("span",{className:E("min-w-10 shrink-0 text-center text-meta text-ink-dim tabular-nums"),children:S0(p)}),y?f.jsx("span",{"data-sound-error":"",className:E("shrink-0 text-meta text-ink-muted"),children:Y("ui.chat.canonical.sound.player_failed")}):null]})};function DL(e){const t=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.peaks)?e.peaks:null;if(!t||t.length===0)return null;const n=[];for(const r of t){if(typeof r!="number"||!Number.isFinite(r))return null;n.push(Math.max(0,Math.min(1,r)))}return n}const VL=new Map;async function eQt(e,t){try{const n=await Sc({op:"sessions.attachment.waveform",sessionId:e.sessionId,digest:t},null);if(n.kind==="json")return DL(n.body);if(n.kind==="bytes"){const r=new TextDecoder().decode(n.data);try{return DL(JSON.parse(r))}catch{return null}}return null}catch{return null}}function Hve(e,t){const n=t?.sessionId??null,r=t?.childId??null,[i,a]=$.useState(()=>e?tQt(e):null);return $.useEffect(()=>{if(!e||!n){a(null);return}let o=!0;return nQt({sessionId:n,childId:r},e).then(s=>{o&&a(s)}),()=>{o=!1}},[e,n,r]),i}function tQt(e){return gj.get(e)??null}const gj=new Map;function nQt(e,t){const n=VL.get(t);if(n)return n;const r=eQt(e,t).then(i=>(gj.set(t,i),i)).catch(()=>(gj.set(t,null),null));return VL.set(t,r),r}function Kve(e){return`sound:${e.attachment??e.id}`}const lA=({audio:e,scope:t,label:n,ownerId:r})=>{const i=By(e,t),a=Hve(e.attachment,t);return i.state==="missing"?f.jsx(zd,{name:n,detail:Dve}):i.state==="resolving"?f.jsx("div",{className:E("inline-block max-w-full self-start"),"aria-hidden":!0,children:f.jsx(iO,{"data-attachment-reserved":""})}):f.jsx("div",{className:E("w-full max-w-[560px] self-start"),children:f.jsx(Bve,{ownerId:r??Kve(e),src:i.url,label:n,peaks:a,durationHint:e.durationS??null})})},DO=1,Jve=4,ML=(e,t)=>Math.min(Jve,Math.max(DO,e+t)),fg=Object.freeze({x:0,y:0}),YT=(e,t)=>t<=0?0:Math.min(t-1,Math.max(0,Math.trunc(e))),NT=(e,t,n)=>t<=0?0:((e+n)%t+t)%t,rQt=(e,t)=>`Image ${e+1} of ${t}`,LL=(e,t,n)=>{const r=Math.max(0,n-1)/2,i=t.width*r||0,a=t.height*r||0;return{x:Math.min(i,Math.max(-i,e.x)),y:Math.min(a,Math.max(-a,e.y))}},iQt="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",aQt="max-h-[min(90vh,calc(100vh-208px))] max-w-[min(90vw,calc(100vw-104px))]",FL=e=>E(e,"flex min-h-16 min-w-64 items-center justify-center p-6"),oQt="opacity-85",Df="bg-surface/85 disabled:bg-surface/85",cA=({src:e,label:t,open:n,onOpenChange:r,restoreFocusTo:i,fallback:a,pending:o=!1,group:s,layerRef:l,mediaKind:c="image",mediaLabel:u="image",layerAttributes:O})=>{ut();const d=c==="video",h=(F,H)=>u==="asset"?`Asset ${F+1} of ${H}`:rQt(F,H),[p,m]=$.useState(null),g=e!==void 0&&p===e,[y,v]=$.useState(DO),[x,S]=$.useState(fg),b=$.useRef(e);$.useLayoutEffect(()=>{b.current!==e&&(b.current=e,v(DO),S(fg))},[e]);const[w,Q]=$.useState(!0),P=$.useRef(null);$.useEffect(()=>{if(!n)return;let F;const H=()=>{clearTimeout(F),F=setTimeout(()=>{const oe=P.current;if(oe&&(oe.matches(":hover")||oe.contains(document.activeElement))){H();return}Q(!1)},tse)},ne=()=>{Q(!0),H()};return Q(!0),H(),document.addEventListener("pointermove",ne,{passive:!0}),document.addEventListener("pointerdown",ne,{passive:!0}),document.addEventListener("keydown",ne),document.addEventListener("focusin",ne),()=>{clearTimeout(F),document.removeEventListener("pointermove",ne),document.removeEventListener("pointerdown",ne),document.removeEventListener("keydown",ne),document.removeEventListener("focusin",ne)}},[n]);const T=s?.onPrev,_=s?.onNext,R=s!==void 0&&s.count>1,q=R?aQt:iQt,A=$.useRef(null),C=l??A;$.useEffect(()=>{if(!n||!R)return;const F=H=>{H.defaultPrevented||H.metaKey||H.ctrlKey||H.altKey||(H.key==="ArrowLeft"?(H.preventDefault(),T?.()):H.key==="ArrowRight"&&(H.preventDefault(),_?.()))};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[n,R,T,_]),$C(n,"image-lightbox");const N=$.useRef(null),I=!d&&e!==void 0&&!g,W=y===DO&&x.x===fg.x&&x.y===fg.y,G=F=>{if(!I)return;v(F);const H=N.current;H&&S(ne=>LL(ne,{width:H.clientWidth,height:H.clientHeight},F))},D=()=>{I&&(v(DO),S(fg))},j=$.useRef(null),[V,J]=$.useState(!1),U=I&&y>DO,te=F=>{!U||F.button!==0||(F.currentTarget.setPointerCapture(F.pointerId),j.current={pointerId:F.pointerId,startX:F.clientX,startY:F.clientY,pan:x},J(!0))},L=F=>{const H=j.current,ne=N.current;!H||H.pointerId!==F.pointerId||!ne||S(LL({x:H.pan.x+(F.clientX-H.startX),y:H.pan.y+(F.clientY-H.startY)},{width:ne.clientWidth,height:ne.clientHeight},y))},B=F=>{j.current?.pointerId===F.pointerId&&(j.current=null,J(!1))},Oe=e!==void 0&&!g?f.jsx("div",{ref:N,"data-image-viewport":"",tabIndex:-1,className:E(q,"relative h-fit w-fit overflow-hidden leading-none outline-none",U&&(V?"cursor-grabbing":"cursor-grab"),U&&"touch-none"),onPointerDown:te,onPointerMove:L,onPointerUp:B,onPointerCancel:B,children:d?f.jsx("video",{src:e,controls:!0,autoPlay:!0,className:E(q,"block object-contain"),"data-lightbox-video":"",onError:()=>m(e),children:t}):f.jsx("img",{src:e,alt:t,draggable:!1,className:E(q,"block select-none object-contain"),style:W?void 0:{transform:`translate(${x.x}px, ${x.y}px) scale(${y})`},onError:()=>m(e)})}):e===void 0&&o?f.jsx("div",{className:FL(q),"aria-hidden":"true"}):f.jsx("div",{className:FL(q),children:a});return f.jsx(PC,{open:n,onOpenChange:r,children:f.jsxs(_C,{ref:C,tabIndex:-1,onOpenAutoFocus:F=>{F.preventDefault(),(N.current??C.current)?.focus()},showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:F=>{const H=i?.current;H&&(F.preventDefault(),H.focus())},className:E("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none outline-none",q,"gap-0 rounded-none border-0 border-transparent bg-transparent p-0 shadow-none"),...O,children:[f.jsx(TC,{className:"sr-only",children:t}),R&&s?f.jsx("div",{"aria-live":"polite",className:"sr-only",children:h(s.index,s.count)}):null,Oe,f.jsxs("div",{ref:P,"data-image-viewer-controls":"",className:E("pointer-events-none fixed inset-0 transition-opacity ease-out-quart",w?"opacity-100 duration-fast":`${oQt} duration-base`),children:[R&&s?.filmstrip?f.jsx("div",{className:"pointer-events-auto fixed inset-x-0 bottom-4 mx-auto w-fit max-w-[calc(100vw-256px)]",children:s.filmstrip}):null,R?f.jsxs(f.Fragment,{children:[f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":`Previous ${u}`,title:`Previous ${u}`,onClick:s?.onPrev,className:E("pointer-events-auto fixed top-0 bottom-0 left-4 my-auto",Df),"data-image-viewer-prev":"",children:f.jsx(K2e,{"aria-hidden":"true"})}),f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":`Next ${u}`,title:`Next ${u}`,onClick:s?.onNext,className:E("pointer-events-auto fixed top-0 right-4 bottom-0 my-auto",Df),"data-image-viewer-next":"",children:f.jsx(Iie,{"aria-hidden":"true"})})]}):null,!d&&f.jsxs("div",{className:"pointer-events-auto fixed right-4 bottom-4 flex items-center gap-1",children:[f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":Y("ui.common.viewer.zoom_out"),title:Y("ui.common.viewer.zoom_out"),disabled:!I||y===DO,onClick:()=>G(ML(y,-1)),className:Df,children:f.jsx(Tae,{"aria-hidden":"true"})}),f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":Y("ui.common.viewer.zoom_in"),title:Y("ui.common.viewer.zoom_in"),disabled:!I||y===Jve,onClick:()=>G(ML(y,1)),className:Df,children:f.jsx(_ae,{"aria-hidden":"true"})}),f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":Y("ui.common.viewer.reset_view"),title:Y("ui.common.viewer.reset_view"),disabled:!I||W,onClick:D,className:Df,children:f.jsx(BS,{"aria-hidden":"true"})})]}),f.jsx(G_e,{asChild:!0,children:f.jsx(Se,{variant:"ghost",size:"icon-sm",className:E("pointer-events-auto fixed top-4 right-4",Df),"aria-label":`Close ${u}`,title:`Close ${u}`,children:f.jsx(zi,{"aria-hidden":"true"})})})]})]})})};cA.displayName="ImageLightbox";const sQt={full:"max-h-[240px] max-w-full object-contain",thumbnail:["h-[76px] w-[115px] object-contain","motion-safe:transition-transform motion-safe:duration-fast motion-safe:ease-out-quart","motion-safe:group-hover/tile:scale-[1.04]"].join(" ")},lQt=/[/\\]/,BL=e=>{const t=e.split(lQt);return t[t.length-1]},ebe=$.memo(({file:e,src:t,conversationId:n,label:r,size:i="full",overlay:a,press:o})=>{const[s,l]=$.useState(!1),[c,u]=$.useState(!1),[O,d]=$.useState(!1),h=$.useRef(null),p=Cn(T=>T.setCanvasOpen),{setViewMode:m}=ed(),g=$.useCallback(async()=>{const T=BL(e),_=C=>{C&&console.error("Error processing file:",C);const N=e.startsWith("file://")?e.substring(7):e;window.api.openFile(N).catch(I=>{console.error("Error opening file:",I)})},{setFiles:R,setOpenTabs:q,setSelectedTab:A}=ed.getState();if(e.startsWith("data:"))if(sj(T)){const C=e,N={id:C,title:T,path:C,content:e,type:Ew(e)},W=ed.getState().conversations?.[n],G=W?.files??[],D=W?.openTabs??[],j=(()=>{const U=G.findIndex(te=>te.id===C);return U!==-1?[...G.slice(0,U),N,...G.slice(U+1)]:[...G,N]})();R(n,j);const J=D.some(U=>U.id===C)?D:[...D,{id:C,title:T}];q(n,J),A(n,C),p(!0),m(n,"documents")}else p(!0),m(n,"files");else{const C=e.startsWith("file://")?e.substring(7):e;try{const N=await window.api.readFile(C);if(N.success&&sj(T)){const I=C,W={id:I,title:T,path:C,content:N.data,type:Ew(e)},D=ed.getState().conversations?.[n],j=D?.files??[],V=D?.openTabs??[],J=(()=>{const L=j.findIndex(B=>B.id===I);return L!==-1?[...j.slice(0,L),W,...j.slice(L+1)]:[...j,W]})();R(n,J);const te=V.some(L=>L.id===I)?V:[...V,{id:I,title:T}];q(n,te),A(n,I),p(!0),m(n,"documents");return}p(!0),m(n,"files")}catch(N){const I=N instanceof Error?N.message:String(N??"Unknown error reading file");return _(I)}}},[e,p,m,n]),y=()=>{l(!0)},v=mve(e),S=(v==="path"||v==="data")&&n!=="",b=$ve(v,{canShowInCanvas:S,source:t}),w=v==="path",Q=r??BL(e);if(s)return f.jsx(zd,{name:Q,compact:i==="thumbnail"});const P=f.jsx(iO,{boundary:i==="thumbnail"?"control":"hairline",children:f.jsx("img",{className:E(sQt[i],c?"opacity-100":"opacity-0"),src:t,alt:Q,loading:"lazy",decoding:"async",onLoad:()=>u(!0),onError:y})});return f.jsxs("div",{className:"group relative inline-block",children:[f.jsx("button",{ref:h,type:"button",className:E("block max-w-full cursor-pointer",i==="thumbnail"&&"group/tile rounded-sm"),onClick:o?o.onPress:()=>d(!0),"aria-label":o?o.label:`Expand ${Q}`,title:o?o.title:`Click to expand ${Q}`,"aria-current":o?.current?"true":void 0,children:P}),b&&f.jsx("div",{className:"file-actions-menu pointer-events-none absolute top-1 right-1 z-[2] opacity-0 transition-opacity duration-fast ease-out-quart group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100",onClick:T=>{T.stopPropagation()},onKeyDown:T=>T.stopPropagation(),children:f.jsx(vve,{file:e,src:t,label:Q,onShowInCanvas:S?g:void 0})}),o?null:a?a({open:O,onOpenChange:d,restoreFocusTo:h}):f.jsx(cA,{src:t,label:Q,open:O,onOpenChange:d,restoreFocusTo:h,fallback:f.jsx(zd,{name:Q,detail:w?void 0:sA})})]})});ebe.displayName="ImageAttachment";const cQt=(e,t,n)=>e.name??(n===1?"Image":`Image ${t+1}`),uQt={id:"image-group:empty",data:null,attachment:null,mimeType:"image/png"},OQt=({cold:e,children:t})=>e?f.jsx("div",{className:"flex h-[79px] w-[117px] items-start leading-none",children:t}):t,dQt=({images:e,index:t,scope:n,open:r,onOpenChange:i,restoreFocusTo:a,labelFor:o=cQt})=>{const s=e.length,[l,c]=$.useState(()=>YT(t,s)),[u,O]=$.useState(r);u!==r&&(O(r),r&&c(YT(t,s)));const d=YT(l,s),h=e[d]??uQt,p=o(h,d,s),m=nA(h,n),g=$.useRef(null),y=$.useRef(null),[v,x]=$.useState(!1),S=$.useCallback(W=>{g.current=W,x(W!==null)},[]),b=W=>{const G=g.current?.querySelector(`button[aria-label="Show image ${W+1} of ${s}"]`);G?G.focus():y.current?.focus()},w=W=>{const G=NT(d,s,W),D=g.current?.contains(document.activeElement)??!1;c(G),D&&b(G)},Q=()=>w(-1),P=()=>w(1),T=JSON.stringify([n?.sessionId,n?.childId,e.map(W=>[W.id,W.attachment,W.mimeType])]),[_,R]=$.useState(()=>({identity:T,open:r,indices:new Set}));(_.identity!==T||_.open!==r)&&R({identity:T,open:r,indices:new Set});const q=$.useCallback(W=>{R(G=>{if(!r||G.identity!==T||!G.open||W.every(j=>G.indices.has(j)))return G;const D=new Set(G.indices);for(const j of W)D.add(j);return{...G,indices:D}})},[T,r]),A=NT(d,s,-1),C=NT(d,s,1);$.useEffect(()=>{r&&q([d,A,C])},[r,d,A,C,q]),$.useEffect(()=>{const W=g.current;if(!r||!v||!W||typeof IntersectionObserver>"u")return;let G=!0;const D=new IntersectionObserver(j=>{G&&q(j.filter(V=>V.isIntersecting).map(V=>Number(V.target.dataset.imageSlot)-1))},{root:W});for(const j of W.querySelectorAll("[data-image-slot]"))D.observe(j);return()=>{G=!1,D.disconnect()}},[r,v,q]);const N=(W,G)=>!!W.data||!W.attachment||G===d||G===A||G===C||_.identity===T&&_.open&&_.indices.has(G);$.useEffect(()=>{(g.current?.querySelector(`[data-image-slot="${d+1}"]`)??g.current)?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[v,d]);const I=s>1?f.jsx("ul",{role:"list",ref:S,"aria-label":`${s} images`,"data-image-filmstrip":"",className:"flex max-w-full items-center gap-2 overflow-x-auto px-2 py-1 leading-none",children:e.map((W,G)=>f.jsx("li",{"data-image-slot":G+1,className:E("flex shrink-0 scroll-mx-px rounded-sm leading-none",G===d&&"ring-1 ring-ink"),children:f.jsx(OQt,{cold:!!W.attachment&&!W.data,children:N(W,G)?f.jsx(am,{image:W,scope:n,size:"thumbnail",label:o(W,G,s),press:{onPress:()=>c(G),label:`Show image ${G+1} of ${s}`,title:`Show image ${G+1} of ${s}`,current:G===d}}):f.jsx("button",{type:"button","aria-label":`Show image ${G+1} of ${s}`,title:`Show image ${G+1} of ${s}`,className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:()=>{q([G]),c(G)},children:f.jsx(iO,{boundary:"control",className:"h-[78px] w-[117px]","data-attachment-reserved":"","data-attachment-deferred":""})})})},W.id))}):void 0;return f.jsx(cA,{src:m.state==="ready"?m.url:void 0,pending:m.state==="resolving",label:p,open:r,onOpenChange:i,restoreFocusTo:a,fallback:f.jsx(zd,{name:p,detail:sA}),layerRef:y,group:{index:d,count:s,onPrev:Q,onNext:P,filmstrip:I}})},am=({image:e,scope:t,label:n,size:r,group:i,press:a})=>{const o=nA(e,t);if(o.state==="resolving"){const l=f.jsx(iO,{boundary:r==="thumbnail"?"control":"hairline",className:r==="thumbnail"?"h-[78px] w-[117px]":void 0,"data-attachment-reserved":""});return a?f.jsx("button",{type:"button","aria-label":a.label,title:a.title,"aria-current":a.current||void 0,className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:a.onPress,children:l}):f.jsx("div",{className:E("inline-block max-w-full"),"aria-hidden":!0,children:l})}if(o.state==="missing")return f.jsx(zd,{name:n,compact:r==="thumbnail",detail:sA});const s=o.url;return f.jsx("div",{className:E("inline-block max-w-full"),children:f.jsx(ebe,{file:s,src:s,label:n,size:r,conversationId:t?.sessionId??"",press:a,overlay:i?l=>f.jsx(dQt,{images:i.images,index:i.index,labelFor:i.labelFor,scope:t,open:l.open,onOpenChange:l.onOpenChange,restoreFocusTo:l.restoreFocusTo}):void 0})})},fQt="Generating name…",hQt={rest:"scale-x-60 bg-ink-dim",preview:"scale-x-90 bg-ink-muted",active:"scale-x-100 bg-ink",unloaded:"scale-x-40 bg-ink-dim opacity-75"};function pQt(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function uA(e,t){return`Turn ${e} of ${t}`}const mQt=e=>e.charAt(0).toLowerCase()+e.slice(1);function gQt(e,t){const n=uA(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function $Qt(e){return e.kind==="completion"&&e.naming?.state==="pending"}function yQt(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function vQt(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const bQt={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function wQt(e){if(!Number.isFinite(e)||e<=0)return"";const t=new Date(e*1e3);if(Number.isNaN(t.getTime()))return"";const n=t.getHours(),r=t.getMinutes().toString().padStart(2,"0"),i=n%12===0?12:n%12,a=n<12?"AM":"PM";return`${i}:${r} ${a}`}function xQt(e,t){const n=mQt(uA(e.turn,t));if(e.kind==="user"){const i=wQt(e.ts);return i?`Jump to your message in ${n}, ${i}`:`Jump to your message in ${n}`}const r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`Jump to ${n}, ${r}`:`Jump to ${n}`}function SQt(e,t){const n=e.checkpoints.find(i=>i.id===t);return n?n.kind==="completion"?n.naming?.state??null:e.checkpoints.find(i=>i.kind==="completion"&&i.turn===n.turn)?.naming?.state??null:null}function GT(e,t){const n=[];for(const r of t)SQt(e,r)==="pending"&&n.push(r);return n}const QQt=120,HL=80,kQt="Turn checkpoints",PQt={complete:_l,error:Nh,interrupted:YC,open:oXe},_Qt={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},TQt=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?PQt[n]:null,i=yQt(e),a=e.naming?.state==="ready"?e.naming.name?.trim():"";return f.jsxs(f.Fragment,{children:[f.jsxs("p",{className:E("text-body-sm font-medium text-ink"),children:[uA(e.turn,t),a&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",children:" · "}),f.jsx("span",{className:E("font-normal text-ink-muted"),children:a})]})]}),$Qt(e)&&f.jsx("p",{className:E("text-ink-dim text-meta"),children:fQt}),i&&f.jsx("p",{className:E("line-clamp-2 break-words text-body-sm text-ink-muted"),children:i}),n&&r&&f.jsx("div",{className:E("flex items-center gap-1.5 text-ink-dim text-meta"),children:f.jsxs("span",{className:E("flex items-center gap-1",_Qt[n]),children:[f.jsx(r,{"aria-hidden":"true",className:E("size-3.5 shrink-0")}),bQt[n]]})})]})},XQt=$.memo(function({checkpoint:t,state:n,label:r,roving:i,registerTick:a,onPreview:o,onPreviewEnd:s,onFocusMark:l,onBlurMark:c,onActivate:u,onKeyMark:O,describedBy:d}){const h=p=>{p.pointerType!=="touch"&&o(t.id)};return f.jsx("button",{ref:p=>a(t.id,p),type:"button","data-checkpoint-id":t.id,"data-mark-state":n,"aria-label":r,"aria-describedby":d,tabIndex:i?0:-1,className:E("group pointer-events-auto block h-2.5 w-7"),onPointerMove:h,onPointerLeave:s,onFocus:()=>l(t.id),onBlur:c,onClick:()=>u(t.id),onKeyDown:p=>O(p,t.id),children:f.jsx("span",{"aria-hidden":"true",className:E("ml-auto mr-1.5 block h-0.5 w-5 origin-right rounded-full","transition-[transform,background-color] duration-fast ease-out-quart","motion-reduce:transition-none",hQt[n])})})}),RQt=({sessionId:e,checkpoints:t,onJump:n,onHover:r,building:i=!1,loadedIds:a,activeId:o=null})=>{const s=$.useId(),[l,c]=$.useState(null),[u,O]=$.useState(null),[d,h]=$.useState(null),p=$.useRef(t);p.current=t;const m=$.useRef(new Map),g=$.useRef(null),y=$.useRef(null),v=$.useRef(null),x=$.useCallback(()=>{y.current!==null&&(clearTimeout(y.current),y.current=null),v.current!==null&&(clearTimeout(v.current),v.current=null)},[]),S=$.useCallback((F,H)=>{x();const ne=()=>{O(F),h(p.current.find(oe=>oe.id===F)??null)};if(H<=0){ne();return}y.current=setTimeout(()=>{y.current=null,ne()},H)},[x]),b=$.useCallback(F=>{if(x(),F<=0){O(null);return}v.current=setTimeout(()=>{v.current=null,O(null)},F)},[x]),w=$.useRef(e);$.useEffect(()=>{w.current!==e&&(w.current=e,x(),V.current=null,c(null),O(null),h(null))},[e,x]);const Q=$.useRef(null);$.useLayoutEffect(()=>{const F=g.current;if(!(t.length===0||F===null)){if(o!==null&&P.current===e){Q.current=e;return}Q.current!==e&&(Q.current=e,F.scrollTop=F.scrollHeight)}},[o,t.length,e]);const P=$.useRef(null);$.useLayoutEffect(()=>{if(o===null)return;const F=g.current,H=m.current.get(o);if(F===null||H===void 0)return;P.current=e;const ne=F.getBoundingClientRect(),oe=H.getBoundingClientRect(),ie=oe.top-ne.top+F.scrollTop,we=ie+oe.height,ye=24;ie<F.scrollTop+ye?F.scrollTop=Math.max(0,ie-ye):we>F.scrollTop+F.clientHeight-ye&&(F.scrollTop=we-F.clientHeight+ye)},[o,e]),$.useEffect(()=>()=>x(),[x]);const T=$.useRef(r);$.useEffect(()=>{T.current=r});const _=$.useMemo(()=>vQt(t),[t]),R=$.useMemo(()=>new Map(t.map(F=>[F.id,xQt(F,_)])),[t,_]),q=u&&d?.id===u?d:null,A=u&&m.current.get(u)||null,C=$.useMemo(()=>({current:A}),[A]),N=q!==null&&A!==null;$.useEffect(()=>{T.current(N&&u?u:null)},[N,u]);const I=$.useCallback((F,H)=>{H?m.current.set(F,H):m.current.delete(F)},[]),[W,G]=$.useState(null),D=W&&t.some(F=>F.id===W)?W:t[0]?.id??null,j=$.useCallback(F=>{const H=Math.max(0,Math.min(t.length-1,F)),ne=t[H];ne&&(G(ne.id),m.current.get(ne.id)?.focus())},[t]),V=$.useRef(null),J=$.useCallback(F=>{V.current!==F&&(V.current=F,c(F),S(F,QQt))},[S]),U=$.useCallback(()=>{V.current=null,c(F=>F===null?F:null),b(HL)},[b]),te=$.useCallback(F=>{V.current=F,G(F),c(H=>H===F?H:F),S(F,0)},[S]),L=$.useCallback(()=>{V.current=null,c(F=>F===null?F:null),b(HL)},[b]),B=$.useCallback(F=>{b(0),V.current=null,c(null),n(F)},[b,n]),Oe=$.useCallback((F,H)=>{if(F.key==="Escape"){b(0);return}const ne=t.findIndex(oe=>oe.id===H);if(!(ne<0)){if(F.key==="ArrowDown"){F.preventDefault(),F.stopPropagation(),j(ne+1);return}if(F.key==="ArrowUp"){F.preventDefault(),F.stopPropagation(),j(ne-1);return}if(F.key==="Home"){F.preventDefault(),F.stopPropagation(),j(0);return}F.key==="End"&&(F.preventDefault(),F.stopPropagation(),j(t.length-1))}},[t,b,j]);return t.length===0&&!i?null:f.jsxs("div",{"data-lo-checkpoint-rail":"",role:"toolbar","aria-orientation":"vertical","aria-label":kQt,className:E("pointer-events-none absolute inset-y-0 right-3 z-10 hidden w-7 select-none","flex-col justify-center","@[900px]/chatcol:flex"),children:[f.jsxs("div",{"data-rail-frame":"",ref:g,className:E("max-h-[min(calc(100%-4rem),420px)] w-7 overflow-y-auto overscroll-contain","[&::-webkit-scrollbar]:hidden","[mask-image:linear-gradient(to_bottom,transparent_0,#000_24px,#000_calc(100%-24px),transparent_100%)]"),children:[i&&f.jsx("span",{"aria-hidden":"true","data-rail-building":"",className:E("ml-auto mr-1.5 block h-0.5 w-5 animate-pulse-visible rounded-full bg-ink-dim")}),f.jsx("div",{"data-rail-track":"",className:"py-6",children:t.map(F=>f.jsx(XQt,{checkpoint:F,state:pQt({id:F.id,previewId:l,activeId:o,loaded:a?a.has(F.id):!0}),label:R.get(F.id)??"",roving:F.id===D,registerTick:I,onPreview:J,onPreviewEnd:U,onFocusMark:te,onBlurMark:L,onActivate:B,onKeyMark:Oe,describedBy:N&&u===F.id?s:void 0},F.id))})]}),f.jsxs(Z_e,{open:N,onOpenChange:F=>{F||b(0)},children:[f.jsx(I_e,{virtualRef:C}),q&&f.jsx(D_e,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":q.kind==="user"?"Your message":gQt(q,_),onOpenAutoFocus:F=>F.preventDefault(),onCloseAutoFocus:F=>F.preventDefault(),onFocusOutside:F=>{const H=F.detail?.originalEvent?.target;H instanceof Element&&H.closest("[data-lo-checkpoint-rail]")&&F.preventDefault()},className:E("pointer-events-none max-h-[176px] w-[300px] max-w-[300px] overflow-hidden","flex flex-col gap-2"),children:q.kind==="user"?f.jsx("div",{"data-checkpoint-card-text":"",className:E("line-clamp-3 break-words whitespace-pre-wrap","text-body-sm text-ink"),children:q.text}):f.jsx(TQt,{checkpoint:q,turnCount:_})})]})]})},EQt=$.memo(RQt);function qQt(e,t){if(!t)return e;let n=!1;const r=[];for(const i of e){if(i.kind==="peer"||i.kind==="tool"&&i.toolName==="send"){n=!0;continue}r.push(i)}return n?r:e}const jQt=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function CQt(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function tbe(e,t){const n=[["[data-turn-summary]","data-run-ids"],["[data-fold-ids]","data-fold-ids"]];for(const[r,i]of n)for(const a of e.querySelectorAll(r)){const o=a.getAttribute("data-segment-ids");if(o!==null?!o.split(" ").includes(t):!jQt(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function zQt(e,t){return CQt(e,t)||tbe(e,t)!==null}const AQt=3;function UQt(e,t,n){const r=i=>{if(n.isCurrent&&!n.isCurrent()){n.onMissing();return}const a=e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`);if(a){const l=a.querySelector("button[aria-expanded]");l?.getAttribute("aria-expanded")==="false"&&l.click(),n.onRevealed(a);return}if(i>=AQt){n.onMissing();return}const s=tbe(e,t)?.querySelector("button[aria-expanded]");if(!s){n.onMissing();return}s.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const KL=(e,t,n)=>n===1?"Image":`Image ${t+1}`,JL=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{const{shown:a,more:o}=ESt(e.length,{uncapped:r}),s=qSt(a),l=s.length>1,c=new Set;for(let O=0,d=0;d<s.length;d+=1)c.add(O),O+=s[d];const u=e.slice(0,a).map((O,d)=>f.jsx("li",{className:E("flex leading-none",l&&c.has(d)&&"col-start-1"),children:f.jsx(am,{image:O,scope:t,size:"thumbnail",label:KL(O,d,e.length),group:{images:e,index:d,labelFor:KL}})},O.id));return f.jsxs("ul",{role:"list","aria-label":e.length===1?"1 image from this run":`${e.length} images from this run`,"data-fold-media":"",className:E("mt-2 gap-2",l?"grid grid-cols-[repeat(4,max-content)] items-start":"flex flex-wrap items-center",i==="content"?"ml-5":"ml-0"),children:[u,o>0&&f.jsx("li",{className:E("flex h-[78px] items-center leading-none"),children:f.jsx(Se,{variant:"outline",size:"sm",onClick:n,"aria-label":`+${o} more image${o===1?"":"s"}`,title:`+${o} more image${o===1?"":"s"}`,children:`+${o}`})},"fold-media-more")]})};function eF(e,t){if(t.length===0)return!1;const n=e.find(i=>i.ids[0]===t[0]);return n?n.open:e.find(i=>i.ids.some(a=>t.includes(a)))?.open??!1}function WQt(e,t,n,r){if(t.length===0)return[...e];const i=t[0],a=[];let o=!1;for(const s of e){if(!(s.ids[0]===i||s.ids.some(c=>t.includes(c)))){a.push(s);continue}o||(a.push({ids:[...t],open:n}),o=!0)}return o||a.push({ids:[...t],open:n}),a.filter(s=>s.ids.some(l=>r.has(l)))}const YQt=({video:e,scope:t,label:n})=>{const r=By(e,t),[i,a]=$.useState(!1);return r.state==="missing"||i?f.jsx(zd,{name:n,detail:Ive}):r.state==="resolving"?f.jsx("div",{className:E("inline-block max-w-full self-start"),"aria-hidden":!0,children:f.jsx(iO,{"data-attachment-reserved":""})}):f.jsx("div",{className:E("inline-block max-w-full self-start"),children:f.jsx(iO,{children:f.jsx("video",{controls:!0,preload:"metadata",src:r.url,"aria-label":n,className:E("max-h-[240px] max-w-full object-contain"),onError:()=>a(!0)})})})};function NQt({items:e,summary:t,scope:n}){return ut(),f.jsxs("div",{"data-sound-batch":"",className:E("flex w-full min-w-0 max-w-[560px] flex-col gap-4"),children:[f.jsx("p",{className:E("text-meta text-ink-muted break-words [overflow-wrap:anywhere]"),children:t}),f.jsx("ul",{className:"flex min-w-0 flex-col gap-4",children:e.map(r=>f.jsxs("li",{"data-sound-batch-item":"",className:E("min-w-0"),children:[f.jsxs("p",{className:E("text-body text-ink break-words [overflow-wrap:anywhere]"),children:[r.label,r.status!=="completed"?` · ${r.status==="unknown"?"Status unknown":r.status==="cancelled"?"Stopped":"Failed"}`:""]}),r.error?f.jsx("p",{className:E("text-body-sm text-ink break-words [overflow-wrap:anywhere]"),children:r.error}):r.audio?f.jsx(lA,{audio:r.audio,ownerId:`${Kve(r.audio)}:batch:${r.audio.id}:${r.id}`,scope:n,label:r.label}):f.jsx("p",{className:E("text-meta text-ink-muted"),children:Y("ui.chat.canonical.sound.batch_attachment_unavailable")}),f.jsx("p",{className:E("text-meta text-ink-dim"),children:r.costCaption??"Cost not yet known."})]},r.id))})]})}function vtn({sessionId:e,runningSound:t,available:n,onInterrupt:r,onRestoreFocus:i}){const[a,o]=$.useState(!1),s=$.useRef(null),l=$.useRef(e);$.useEffect(()=>{const h=l.current!==e;l.current=e,!(!h&&t)&&a&&(o(!1),i())},[e,t,a,i]);const c=$.useCallback(()=>{o(!1),i()},[i]),u=$.useCallback(()=>{if(!e||!n)return;const h=s.current?.querySelector("[data-sound-stop-confirmation] button");if(h){h.focus();return}if(t){o(!0);return}r()},[e,n,t,r]),O=$.useCallback(()=>{o(!1),i(),r()},[r,i]),d=$.useMemo(()=>a&&t?f.jsx(nbe,{onKeepWaiting:c,onRequestStop:O}):null,[a,t,c,O]);return{paneRef:s,stop:u,confirmation:d}}function nbe({onKeepWaiting:e,onRequestStop:t}){ut();const n=$.useRef(null),r=$.useId();return $.useEffect(()=>{n.current?.focus();const i=a=>{a.key!=="Escape"||a.isComposing||a.defaultPrevented||(a.preventDefault(),a.stopPropagation(),e())};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[e]),f.jsxs("fieldset",{"data-sound-stop-confirmation":"","aria-label":Y("ui.chat.canonical.sound.stop.confirm_label"),className:"flex flex-col items-start gap-2",children:[f.jsx("p",{className:"text-meta text-ink","aria-live":"polite",children:Y("ui.chat.canonical.sound.stop.question")}),f.jsx("p",{id:r,className:"text-body-sm text-ink-dim",children:Y("ui.chat.canonical.sound.stop.warning")}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx(Se,{ref:n,"aria-describedby":r,variant:"ghost",size:"sm",onClick:e,children:Y("ui.chat.canonical.sound.stop.keep_waiting")}),f.jsx(Se,{variant:"secondary",size:"sm",onClick:t,children:Y("ui.chat.canonical.sound.stop.request_stop")})]})]})}const GQt=1e3;function ZQt(e){const[t,n]=$.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return $.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,GQt);return()=>window.clearInterval(i)},[e]),t}function IQt(){return f.jsx("div",{"aria-hidden":!0,"data-imagegen-tile":"",className:E("relative aspect-[3/2] w-[240px] max-w-full overflow-hidden rounded-sm bg-sunken"),children:f.jsx("span",{className:E("absolute inset-0","animate-shimmer","bg-gradient-to-r from-transparent via-elevated to-transparent","bg-[length:200%_100%]","bg-[position:-200%_50%]","bg-no-repeat")})})}const tF=44,DQt=240,ZT=12,VQt=Array.from({length:240},(e,t)=>Math.min(1,.18+Math.abs(Math.sin(t/7)*Math.cos(t/17))*.72));function MQt({state:e}){const t=Fve(VQt,DQt-ZT*2,tF);return f.jsx("div",{"aria-hidden":!0,"data-sound-loading-tile":"","data-sound-loading":e,className:E("relative flex w-[240px] max-w-full items-center overflow-hidden rounded-sm bg-sunken"),style:{height:tF},children:f.jsx("div",{className:E("flex w-full items-center"),style:{paddingLeft:ZT,paddingRight:ZT},children:t.map((n,r)=>f.jsx("span",{"data-sound-loading-bar":"",className:E("shrink-0 rounded-[2px]",e==="running"?"animate-pulse-visible bg-ink-muted":e==="queued"?"bg-ink-disabled":e==="stopped"?"bg-ink-dim":"bg-ink-muted"),style:{width:_x,height:e==="failed"?Mve:n.height,marginRight:n===t.at(-1)?0:2,animationDelay:e==="running"?`${r%12*90}ms`:void 0}},n.x))})})}function LQt({view:e,elapsed:t}){let n,r=null,i=!1;switch(e.state){case"queued":n=e.composing?"Writing the request…":"Queued",r=e.queuePosition!==null?`${e.queuePosition} ahead`:e.argumentBytes>0?f1(e.argumentBytes):null;break;case"running":n=e.batchProgress?`Generating ${e.batchProgress.total} ${sh(e.material)}${e.batchProgress.total===1?"":"s"}…`:`Generating ${sh(e.material)}…`,r=t===null?null:Du(t);break;case"cancelling":n=e.generating?vE:TU;break;case"done":n=e.receipt==="already-finished"?"Already finished.":e.batch?`${IT(e.material)} batch`:`Generated ${sh(e.material)}`,r=e.receipt==="already-finished"||e.durationS===null?null:xC(e.durationS);break;case"failed":n=e.batch?`${IT(e.material)} batch failed.`:e.message??`The ${sh(e.material)} could not be generated.`,i=!0;break;case"cancelled":{const a=e.message??(e.generating?vE:TU);n=e.batch?`${IT(e.material??"sound-effect")} batch stopped.`:e.settlementCaption||e.settled?yTe(a):a;break}}return f.jsxs("p",{className:E("flex min-w-0 items-baseline gap-1.5 text-body-sm"),children:[f.jsx("span",{className:E("min-w-0",i?"text-ink":"text-ink-muted"),children:n}),r===null?null:f.jsxs("span",{className:E("shrink-0 text-meta text-ink-dim"),children:["· ",r]})]})}function FQt({line:e}){return f.jsx("p",{"data-imagegen-log":"",title:e,className:E("min-w-0 truncate font-mono text-mono-sm text-ink-dim"),children:e})}function IT(e){const t=sh(e);return t.charAt(0).toUpperCase()+t.slice(1)}function Vf({line:e,prominent:t=!1}){return f.jsx("p",{"data-imagegen-note":"",className:E("min-w-0 text-body-sm",t?"text-ink-muted":"text-ink-dim"),children:e})}function BQt(e,t){return e==="cancel"?"Stop":e==="restart"?t==="failed"?"Retry":"Restart":"Edit and restart"}const HQt=({view:e,scope:t,actions:n})=>{const[r,i]=$.useState(!1),a=$.useCallback(()=>i(!1),[]),o=$.useRef(null),s=$.useRef(!1);$.useLayoutEffect(()=>{s.current&&!r&&(o.current?.querySelector("[data-imagegen-controls] button")??o.current)?.focus(),s.current=r},[r]),$.useLayoutEffect(()=>{const S=o.current;return()=>{S?.contains(document.activeElement)&&S.closest("[data-chat-pane]")?.querySelector("textarea")?.focus()}},[]);const l=e.state==="running"&&(e.material==="voiceover"||e.material==="sound-effect");$.useEffect(()=>{l||i(!1)},[l]);const c=e.state==="running"||e.state==="cancelling"?e.startedAtMs:null,u=ZQt(c),O=bTe(e,n),d={cancel:n?.onCancel,restart:n?.onRestart,editRestart:n?.onEditRestart},h=e.state==="running"||e.state==="cancelling",p=h&&(e.state==="running"||e.generating),m="material"in e?e.material:void 0,g=m==="voiceover"||m==="sound-effect",y=g?e.state==="queued"?"queued":e.state==="cancelling"?e.generating?"stopped":null:p?"running":e.state==="failed"?"failed":e.state==="cancelled"?"stopped":null:null,v=g&&(e.state==="failed"?e.batch?.some(S=>S.status==="cancelled"):e.state==="cancelled"&&(e.batch?.some(S=>S.status==="cancelled")||e.message))?vE:null,x=h&&e.progress.logs.length>0?e.progress.logs[e.progress.logs.length-1]:null;return f.jsxs("div",{ref:o,tabIndex:-1,"data-imagegen-card":e.state,className:E("flex w-full flex-col gap-2"),children:[y?f.jsx(MQt,{state:y}):p?f.jsx(IQt,{}):null,e.state==="failed"&&(e.material==="voiceover"||e.material==="sound-effect")&&e.errorType?f.jsx("p",{className:E("text-meta text-ink-dim"),children:e.errorType}):null,f.jsx(LQt,{view:e,elapsed:u}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.costCaption?f.jsx(Vf,{line:e.costCaption,prominent:!!e.batch}):null,(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batchNote?f.jsx(Vf,{line:e.batchNote,prominent:!0}):null,e.state==="running"&&e.batchProgress?.note?f.jsx(Vf,{line:e.batchProgress.note}):null,e.state==="cancelled"&&e.settlementCaption?f.jsx(Vf,{line:e.settlementCaption}):null,v?f.jsx(Vf,{line:v}):null,l&&r?f.jsx(nbe,{onKeepWaiting:a,onRequestStop:()=>{i(!1),n?.onCancel?.()}}):null,e.state==="running"&&typeof e.note=="string"?f.jsx(Vf,{line:e.note}):null,p&&e.progress.fraction!==null?f.jsx(V_e,{"aria-label":"Image generation progress",className:E("max-w-[240px]"),value:Math.round(Math.min(1,Math.max(0,e.progress.fraction))*100)}):null,x===null?null:f.jsx(FQt,{line:x}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batch?f.jsx(NQt,{items:e.batch,summary:e.batchSummary??`${e.batch.length} items`,scope:t}):e.state==="done"&&e.images.length>0?f.jsx("div",{className:E("flex flex-col gap-2"),children:e.images.map((S,b)=>{const w=`Generated ${sh(S.kind==="audio"?e.material:S.kind??"image")}`,Q=e.images.length===1?w:`${w} ${b+1}`;return S.kind==="video"?f.jsx(YQt,{video:S,scope:t,label:Q},S.id):S.kind==="audio"?f.jsx(lA,{audio:S,scope:t,label:Q},S.id):f.jsx(am,{image:S,scope:t,label:Q},S.id)})}):null,O.length>0&&!(l&&r)?f.jsx("div",{"data-imagegen-controls":"",className:E("flex items-center gap-2"),children:O.map(S=>f.jsx(Se,{variant:"secondary",size:"sm",disabled:S.disabled,title:S.kind==="cancel"?e.state==="queued"||e.state==="cancelling"&&!e.generating?"Stops before the provider is called.":"Requests a stop; the provider may finish anyway.":void 0,onClick:S.kind==="cancel"&&l?()=>{const b=o.current?.closest("[data-chat-pane]")?.querySelector("[data-sound-stop-confirmation] button");if(b){b.focus();return}i(!0)}:d[S.kind],children:BQt(S.kind,e.state)},S.kind))}):null]})},om="data-lo-quote-toolkit";function $j(e,t){return e.kind!=="user"&&e.kind!=="assistant"||t.trim().length===0?!1:e.kind!=="assistant"?!0:!e.streaming}const nF=e=>(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[${om}]`)??null,KQt=e=>e.nodeType===Node.ELEMENT_NODE,JQt=e=>{const t=Array.from(e.childNodes),n=t.findIndex(r=>KQt(r)&&r.hasAttribute(om));return n===-1?t.length:n},ekt=(e,t)=>Math.abs(e.top-t.top)<.5&&Math.abs(e.left-t.left)<.5&&Math.abs(e.right-t.right)<.5&&Math.abs(e.bottom-t.bottom)<.5,tkt=e=>{const t=Array.from(document.querySelectorAll(`[${om}]`),n=>n.getBoundingClientRect());return Array.from(e.getClientRects()).filter(n=>!t.some(r=>ekt(r,n))).map(n=>({top:n.top,left:n.left,right:n.right,bottom:n.bottom}))};function Rh(e){if(!e)return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const n=t.getRangeAt(0);if(nF(n.startContainer)||nF(n.endContainer)||!e.contains(n.startContainer))return null;const r=n.cloneRange();e.contains(n.endContainer)||r.setEnd(e,JQt(e));const i=r.toString().trim();return i.length===0?null:{text:i,lines:tkt(n)}}const rF="[data-lo-canonical-transcript]",nkt="[data-lo-transcript-content]",iF=e=>({top:e.top,left:e.left,right:e.right,bottom:e.bottom}),rkt=()=>({top:0,left:0,right:window.innerWidth,bottom:window.innerHeight});function rbe(e){const{turnRef:t,visible:n,lines:r,measureKey:i,belowWhenOffFirstLine:a}=e,o=$.useRef(null),[s,l]=$.useState(null),c=$.useRef(r);c.current=r;const u=$.useCallback(()=>{const O=t.current,d=o.current;if(!O||!d){l(null);return}const h=c.current();if(!h||h.length===0){l(null);return}const p=A9e({lines:h,container:iF((O.closest(rF)??O).getBoundingClientRect()),viewport:rkt(),size:{width:d.offsetWidth,height:d.offsetHeight},row:iF(O.getBoundingClientRect()),belowWhenOffFirstLine:a}),m=O.getBoundingClientRect(),g=p?{top:p.top-m.top,left:p.left-m.left,placement:p.placement}:null;l(y=>y===g||y&&g&&y.top===g.top&&y.left===g.left&&y.placement===g.placement?y:g)},[t,a]);return $.useLayoutEffect(()=>{if(!n){l(null);return}u();let O=0;const d=()=>{O||(O=requestAnimationFrame(()=>{O=0,u()}))};document.addEventListener("scroll",d,!0),document.addEventListener("selectionchange",d),window.addEventListener("resize",d);const h=t.current?.closest(rF),p=h?.querySelector(nkt),m=new ResizeObserver(d);return h&&m.observe(h),p&&m.observe(p),()=>{O&&cancelAnimationFrame(O),document.removeEventListener("scroll",d,!0),document.removeEventListener("selectionchange",d),window.removeEventListener("resize",d),m.disconnect()}},[n,u,t,i]),{controlRef:o,placement:s}}function ibe(e){const[t,n]=$.useState(null);$.useEffect(()=>{const i=()=>n(Rh(e.current)?.text??null);return i(),document.addEventListener("selectionchange",i),()=>document.removeEventListener("selectionchange",i)},[e]);const r=$.useCallback(()=>n(null),[]);return{text:t,clear:r}}const ah="data-lo-link-toolbar",ikt=120,akt=2;function abe(e){const[t,n]=$.useState(null),[r,i]=$.useState(!1),a=$.useRef(null);a.current=t;const o=$.useRef(null),s=$.useRef(null),l=$.useCallback(()=>{const u=e.current;if(!u){o.current=null,n(h=>h===null?h:null),i(h=>h===!1?h:!1);return}const O=tbt(u);if(O){n(h=>h===O?h:O),i(h=>h===!0?h:!0);return}if(i(h=>h===!1?h:!1),Wye()){n(h=>h===null?h:null);return}const d=o.current&&u.contains(o.current)?o.current:null;n(h=>h===d?h:d)},[e]);$.useEffect(()=>{const u=e.current;if(!u)return;let O=0;const d=Q=>{O&&(clearTimeout(O),O=0),o.current=Q,l()},h=Q=>{if(O&&clearTimeout(O),!Q){O=0,o.current=null,l();return}o.current!==Q&&(s.current=null,O=setTimeout(()=>{O=0,o.current=Q,l()},ikt))},p=(Q,P)=>{const T=o.current;if(!T||!u.contains(T))return!1;const _=u.querySelector(`[${ah}]`),R=k6+akt;for(const q of[T,_]){if(!q)continue;const A=q.getBoundingClientRect();if(!(A.width<=0||A.height<=0)&&Q>=A.left-R&&Q<=A.right+R&&P>=A.top-R&&P<=A.bottom+R)return!0}return!1},m=Q=>{const P=Q.target;if(P?.closest(`[${om}]`))return;const T=P?.closest(ih)??null;!T&&p(Q.clientX,Q.clientY)||h(T)},g=Q=>{const P=Q.relatedTarget;P&&u.contains(P)||p(Q.clientX,Q.clientY)||d(null)},y=Q=>{const P=Q.target?.closest(ih);if(P){if(P===s.current){s.current=null;return}d(P)}},v=Q=>{const P=Q.relatedTarget;P&&u.contains(P)||d(null)},x=()=>Array.from(u.querySelectorAll(`[${ah}] button:not([disabled])`)),S=Q=>{const P=Q.target;if(!P)return!1;if(P.closest(`[${ah}]`)){const q=x(),A=q.indexOf(P);if(A===-1)return!1;if(Q.shiftKey&&A===0){const C=o.current;return C instanceof HTMLElement?(C.focus(),!0):!1}if(!Q.shiftKey&&A===q.length-1){const C=Array.from(u.querySelectorAll(ih)),N=o.current,I=N?C.indexOf(N)+1:-1,W=I>0?C[I]:void 0;return W?(W.focus(),!0):!1}return!1}if(Q.shiftKey)return!1;const _=P.closest(ih);if(!_||!u.contains(_))return!1;o.current!==_&&d(_);const[R]=x();return R?(R.focus(),!0):!1},b=Q=>{if(Q.key==="Tab"&&S(Q)){Q.preventDefault();return}if(!(Q.key==="ContextMenu"||Q.shiftKey&&Q.key==="F10"))return;const T=Q.target?.closest(ih);!T||!u.contains(T)||(Q.preventDefault(),d(T),requestAnimationFrame(()=>{u.querySelector(`[${ah}] button`)?.focus()}))},w=Q=>{const P=Q.target;P&&u.contains(P)||d(null)};return u.addEventListener("pointerover",m),u.addEventListener("pointerout",g),u.addEventListener("focusin",y),u.addEventListener("focusout",v),u.addEventListener("keydown",b),document.addEventListener("pointerdown",w,!0),document.addEventListener("selectionchange",l),l(),()=>{O&&clearTimeout(O),u.removeEventListener("pointerover",m),u.removeEventListener("pointerout",g),u.removeEventListener("focusin",y),u.removeEventListener("focusout",v),u.removeEventListener("keydown",b),document.removeEventListener("pointerdown",w,!0),document.removeEventListener("selectionchange",l)}},[e,l]);const c=$.useCallback(()=>{s.current=a.current,o.current=null,l()},[l]);return $.useEffect(()=>{if(!t)return;const u=O=>{if(O.key!=="Escape"||O.target?.closest(`[${ah}]`))return;const h=window.getSelection();h&&!h.isCollapsed&&h.removeAllRanges(),c()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t,c]),{subject:t,quoteAvailable:r,dismiss:c}}function obe(e,t,n){const r=Yn(i=>i.addReply);return $.useCallback(()=>{const a=Rh(t.current)?.text??(Wye()?null:n?.()??null);a&&(r(e,{id:Xa(),text:a}),window.getSelection()?.removeAllRanges(),n6())},[r,e,t,n])}const sbe=({conversationId:e,turnRef:t,subject:n,quoteAvailable:r,onDismiss:i})=>{const a=n.getAttribute(Aye)??"",o=n.getAttribute("data-lo-kind")??"file",s=ck(),l=$.useCallback(()=>(n.textContent??"").trim()||null,[n]),c=obe(e,t,l),{text:u}=ibe(t),{speak:O}=Lp(),d=aQ(e),h=u??l(),p=h===null?null:Lh(e,iQ(h).text);Ole(p);const m=sQ({key:p,getText:()=>Rh(t.current)?.text??l(),play:({text:N})=>O(Lh(e,N),oQ(d,N))}),[g,y]=$.useState(!1),[v,x]=$.useState(()=>M1(a)??null),{controlRef:S,placement:b}=rbe({turnRef:t,visible:!0,lines:()=>{const N=n.getClientRects();return Array.from(N,I=>({top:I.top,left:I.left,right:I.right,bottom:I.bottom}))},measureKey:n,belowWhenOffFirstLine:!0});$.useEffect(()=>{const N=M1(a);if(x(N??null),y(!1),N!==void 0)return;let I=!0;return Hvt(a,window.api?.probeFiles).then(()=>{I&&x(M1(a)??null)}),()=>{I=!1}},[a]);const w=o==="file"&&F9(s,a),Q=Gye({target:a,isDirectory:v?.exists===!0&&!v.isFile,probe:v,canOpenInCanvas:w}),P=ibt({kind:o,target:a,probe:v,quotable:r,canOpenInCanvas:w});if(!P||!a)return null;const T=async()=>{await Ly(a)&&y(!0)},_=async()=>{if(o==="url"){await KM(o,a);return}s&&Q&&await s.openInCanvas(a)||await KM(o,a)||x(null)},R=async()=>{await rO(a)||x(null)},q=async()=>{await B9(a)||x(null)},A={quote:f.jsx(Sae,{}),copy:g?f.jsx(_l,{}):f.jsx(Vp,{}),open:Q?f.jsx(SRe,{}):o==="url"?f.jsx(GC,{}):f.jsx(gy,{}),"open-default":f.jsx(I2e,{}),"open-folder":f.jsx(Gh,{})},C={quote:c,copy:()=>{T()},open:()=>{_()},"open-default":()=>{R()},"open-folder":()=>{q()}};return f.jsxs(P6,{[om]:"",[ah]:"",ref:S,label:P.label,className:E("absolute z-20",!b&&"invisible"),style:b?{top:b.top,left:b.left}:void 0,onKeyDown:N=>{if(N.key!=="Escape")return;window.getSelection()?.removeAllRanges();const I=n;N.preventDefault(),i(),I.focus?.()},children:[P.actions.map(N=>f.jsxs($.Fragment,{children:[f.jsx(wt,{content:N.id==="copy"&&g?"Copied":N.label,side:b?.placement==="below"?"bottom":"top",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":N.id==="copy"&&g?"Copied":N.label,className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:C[N.id],children:A[N.id]})}),N.id==="quote"&&f.jsx(lQ,{control:m,side:b?.placement==="below"?"bottom":"top"})]},N.id)),P.note&&f.jsx("span",{className:"max-w-56 truncate pl-1 text-ink-dim text-meta",title:P.noteTitle??P.note,children:P.note})]})};function okt({role:e="answer",forkable:t=!1}={}){const n=t?["fork"]:[];return e==="user"?["copy",...n]:e==="commentary"?["copy"]:e==="response"?["copy","speak",...n]:["copy","speak",...n]}function yj(e){return e.kind!=="user"&&e.kind!=="assistant"||e.kind==="assistant"&&e.streaming?null:e.id||null}const aF=96;function skt(e){const t=e.replace(/\s+/g," ").trim();return t.length<=aF?t:`${t.slice(0,aF-1).trimEnd()}…`}const lkt="Answer actions",ckt="Your message actions",ukt="pointer-events-none opacity-0 transition-opacity duration-fast ease-out-quart group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100";function oF(e){return e?"opacity-100":ukt}const lbe=2e3,Okt=1e4;function btn(e){const{request:t}=e;return t?e.now-t.requestedAt>Okt?"retire":e.presentable?e.claimed?"hold":"present":"yield":null}let sF=0,Yb=0;const dkt=ga(e=>({request:null,requestPanel:(t,n,r,i)=>{sF+=1,e({request:{destination:t,nonce:sF,requestedAt:Date.now(),invoker:n??null,...r?{sessionId:r}:{},...i?.id?{entryId:i.id}:{},...i?.id&&i.excerpt?{entryExcerpt:i.excerpt}:{},...r&&i?.subjectName?{subjectName:i.subjectName}:{}}})},consumePanel:t=>e(n=>n.request?.nonce===t?{request:null}:n),presenterClaimed:!1,claimPresenter:()=>{Yb+=1,e({presenterClaimed:!0});let t=!1;return()=>{t||(t=!0,Yb=Math.max(0,Yb-1),Yb===0&&e({presenterClaimed:!1}))}}})),fkt=(e,t)=>{let n=e;for(;n!==null;){if(n.matches(":hover"))return!0;if(n===t)break;n=n.parentElement}const r=e.ownerDocument.activeElement;return r!==null&&t.contains(r)},hkt=9e4,lF=new Set,pkt=2600,H1=$.memo(function({bodyText:t,kind:n="answer",agentId:r,speechId:i,revealId:a,revealAt:o,conversationId:s,entryId:l,overlay:c=!1,overlayClassName:u}){const[O,d]=$.useState(!1),[h,p]=$.useState(!1),m=$.useRef(null),g=$.useRef(null),y=$.useRef(null),v=$.useRef(null),{playSpeech:x}=Lp(),S=aQ(r??null),b=sQ({key:i?ule(i):null,getText:()=>t,play:({text:A})=>{i&&x(i,S,A)}}),w=dkt(A=>A.requestPanel),Q=!!(s&&l);ut();const P=okt({role:n,forkable:Q}),T=O||b.active;$.useEffect(()=>()=>{m.current!==null&&clearTimeout(m.current)},[]),$.useEffect(()=>{if(!a||o===void 0||lF.has(a)||(lF.add(a),Date.now()-o>hkt))return;const A=g.current;if(A===null)return;const C=A.closest(".group")??A;if(fkt(A,C))return;p(!0);const N=()=>{p(!1),C.removeEventListener("pointerenter",N),C.removeEventListener("focusin",N)};return C.addEventListener("pointerenter",N),C.addEventListener("focusin",N),()=>{C.removeEventListener("pointerenter",N),C.removeEventListener("focusin",N)}},[a,o]),$.useEffect(()=>{if(h)return v.current=setTimeout(()=>{v.current=null,p(!1)},pkt),()=>{v.current!==null&&clearTimeout(v.current)}},[h]);const _=async()=>{await Ly(t)&&(d(!0),m.current!==null&&clearTimeout(m.current),m.current=setTimeout(()=>{m.current=null,d(!1)},lbe))},R=()=>{!s||!l||w("session.fork",y.current,s,{id:l,excerpt:skt(t)})},q={copy:f.jsx(wt,{content:O?"Copied":"Copy",side:"bottom",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":O?"Copied":"Copy",className:E("text-ink-dim hover:bg-transparent hover:text-ink"),onClick:_,children:O?f.jsx(_l,{"aria-hidden":"true"}):f.jsx(Vp,{"aria-hidden":"true"})})}),speak:f.jsx(lQ,{control:b,side:"bottom",className:E("text-ink-dim hover:bg-transparent hover:text-ink")}),fork:f.jsx(wt,{content:"Fork from this message",side:"bottom",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Fork from this message",ref:y,className:E("text-ink-dim hover:bg-transparent hover:text-ink"),onClick:R,children:f.jsx(UXe,{"aria-hidden":"true"})})})};return f.jsx("div",{role:"toolbar","aria-label":n==="user"?ckt:n==="commentary"?Y("ui.chat.commentary_actions.label"):n==="response"?Y("ui.chat.response_actions.label"):lkt,ref:g,onAnimationEnd:A=>{A.target===A.currentTarget&&p(!1)},...h?{"data-lo-arrive":""}:{},...n==="user"?{"data-lo-user-actions":""}:n==="commentary"?{"data-lo-gutter-actions":""}:n==="response"?{"data-lo-response-actions":""}:{"data-lo-answer-actions":""},className:E(c?E("absolute z-10 flex h-8 items-center gap-1","-top-2 right-0",oF(T),u):E("flex h-8 shrink-0 items-center gap-1",oF(T))),children:P.map(A=>f.jsx($.Fragment,{children:q[A]},A))})}),mkt="@container/olderhistory mb-4 flex h-7 min-w-0 items-center gap-2",Nb="@min-[260px]/olderhistory:hidden",Gb="@max-[260px]/olderhistory:hidden",cbe="lo-older-history-hint",gkt=({state:e,transportDown:t=!1,onLoadOlder:n,onRetryHydration:r})=>{const i=e==="loading"?"Loading earlier messages":e==="failed"?t?"Earlier messages did not load":"Could not load earlier messages":e==="unproven"?"Earlier history not loaded":null,a=e==="loading";return f.jsxs("div",{className:mkt,children:[f.jsx("output",{className:"sr-only","aria-live":"polite",children:i}),e==="failed"&&t?f.jsxs("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:[f.jsx("span",{className:Nb,children:"Not loaded"}),f.jsx("span",{className:Gb,children:"Earlier messages did not load"})]}):e==="failed"?f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"min-w-0 truncate text-danger text-meta",title:"Could not load earlier messages",children:[f.jsx("span",{className:Nb,children:"Did not load"}),f.jsx("span",{className:Gb,children:"Could not load earlier messages"})]}),f.jsx(Se,{variant:"ghost",size:"sm",className:"shrink-0",onClick:n,children:"Try again"})]}):a?f.jsxs(Se,{variant:"ghost",size:"sm","aria-disabled":!0,onClick:o=>{o.preventDefault()},className:"text-ink-muted",children:[f.jsx(po,{size:"sm"}),"Loading earlier messages"]}):e==="idle"?f.jsx(Se,{variant:"ghost",size:"sm",onClick:n,children:"Load earlier messages"}):e==="windowed"?f.jsxs("span",{id:cbe,className:"min-w-0 truncate text-ink-dim text-meta",title:t?"Earlier history above":"Earlier history above — scroll up to load",children:[f.jsx("span",{className:Nb,children:t?"Earlier history above":"Scroll up for earlier"}),f.jsxs("span",{className:Gb,children:["Earlier history above",t?"":" — scroll up to load"]})]}):e==="unproven"?f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"min-w-0 truncate text-ink-dim text-meta",title:"Earlier history not loaded",children:[f.jsx("span",{className:Nb,children:"Earlier not loaded"}),f.jsx("span",{className:Gb,children:"Earlier history not loaded"})]}),!t&&r&&f.jsx(Se,{variant:"ghost",size:"sm",className:"shrink-0",onClick:r,children:"Try again"})]}):f.jsx("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:"Start of conversation"})]})},$kt="/settings?section=providers",cF="/settings?section=providers&provider=radient",ykt="/settings?section=radient",uF=/sign in to radient/i,vkt=[/insufficient credits/i,/credit balance is too low/i],bkt=[/rate limit or quota/i],wkt=[/insufficient credits/i,/\bHTTP 402\b/i];function ube(e){return(e??"").split("/")[0]?.trim().toLowerCase()==="radient"}function OA(e){return ube(e.provider)?e.category==="billing"?!0:(e.category==null||e.category==="unknown"||e.category==="rate-limit")&&wkt.some(n=>n.test(e.text)):!1}function xkt(e){if(!OA(e))return null;const t=/rate limit or quota( exceeded)?\s*/i;if(!t.test(e.headline))return{label:"billing",headline:e.headline};const n=e.headline.replace(t,"").trim(),r=/^\((HTTP \d{3})\):?\s*(.*)$/i.exec(n),i=(r?r[2]:n.replace(/^:\s*/,"")).trim(),a=r?` (${r[1]})`:"";return{label:"billing",headline:i?`Out of credits${a}: ${i}`:`Out of credits${a}: Radient refused the request`}}function Skt(e){return e==="auth"?"sign-in":e==="billing"?"billing":e==="rate-limit"?"quota":null}function OF(e){const t=ube(e.provider)||uF.test(e.text);let n=Skt(e.category);return OA(e)&&(n="billing"),n===null&&(e.category==null||e.category==="unknown")&&(uF.test(e.text)?n="sign-in":vkt.some(r=>r.test(e.text))?n="billing":bkt.some(r=>r.test(e.text))&&(n="quota")),n===null?null:n==="sign-in"&&t?{label:"Sign in to Radient",to:cF}:n==="billing"&&t?{label:"Open Radient account",to:ykt}:{label:"Open provider settings",to:t?cF:$kt}}const Obe=({conversationId:e,turnRef:t,allowQuote:n=!0})=>{ut();const{text:r,clear:i}=ibe(t),a=r!==null,o=obe(e,t);$.useEffect(()=>{const y=t.current;if(!y||!a)return;const v=y.closest("[data-record-id]")??y,x=[...v.querySelectorAll("[data-lo-gutter-actions], [data-lo-user-actions], [data-lo-answer-actions], [data-lo-response-actions]")];v.setAttribute("data-lo-selection-active","");for(const S of x)S.setAttribute("inert",""),S.setAttribute("aria-hidden","true");return()=>{v.removeAttribute("data-lo-selection-active");for(const S of x)S.removeAttribute("inert"),S.removeAttribute("aria-hidden")}},[a,t]);const[s,l]=$.useState(!1),c=$.useRef(null);$.useEffect(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);const u=$.useCallback(async()=>{const y=Rh(t.current)?.text??r;y&&await Ly(y)&&(l(!0),c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,l(!1)},lbe))},[r,t]),{controlRef:O,placement:d}=rbe({turnRef:t,visible:a,lines:()=>Rh(t.current)?.lines??null}),{speak:h}=Lp(),p=aQ(e),m=r===null?null:Lh(e,iQ(r).text);Ole(m);const g=sQ({key:m,getText:()=>Rh(t.current)?.text??null,play:({text:y})=>h(Lh(e,y),oQ(p,y))});return $.useEffect(()=>{if(!a)return;const y=v=>{v.key!=="Escape"||v.defaultPrevented||(window.getSelection()?.removeAllRanges(),i())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[a,i]),a?f.jsxs(P6,{[om]:"",ref:O,label:Y("ui.chat.transcript_copy.selection.toolbar"),className:E("absolute z-20",!d&&"invisible"),style:d?{top:d.top,left:d.left}:void 0,children:[n&&f.jsx(wt,{content:"Quote",side:d?.placement==="below"?"bottom":"top",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":"Quote",className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:o,children:f.jsx(Sae,{})})}),f.jsx(wt,{content:s?Y("ui.chat.transcript_copy.toast.copied_selection"):Y("ui.chat.transcript_copy.selection.copy"),side:d?.placement==="below"?"bottom":"top",children:f.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":s?Y("ui.chat.transcript_copy.toast.copied_selection"):Y("ui.chat.transcript_copy.selection.copy"),className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:()=>{u()},children:s?f.jsx(_l,{}):f.jsx(Vp,{})})}),f.jsx(lQ,{control:g,side:d?.placement==="below"?"bottom":"top"})]}):null},dbe={all:["radient-prices"],prices:()=>[...dbe.all,"prices"]},Qkt=()=>{const e=Rt({queryKey:dbe.prices(),queryFn:()=>c6({operation:"prices"}),staleTime:36e5,refetchOnWindowFocus:!1,refetchOnMount:!0,refetchInterval:!1,retry:3});return{prices:e.data,isLoading:e.isLoading,isFetching:e.isFetching,error:e.error,pricesQuery:e}},dF="https://console.radienthq.com/dashboard/verification",fF="https://console.radienthq.com/dashboard/billing",hF="Top up in Radient console";function kkt(e){return!e.email_verified&&e.signup_grant!=="claimed"}const wtn=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`$${e.toFixed(2)} in free credits`,vj=e=>Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`,Pkt=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`${vj(e)} in free credits`;function pF(e,t){if(!e)return t;try{const{protocol:n}=new URL(e);return n==="https:"||n==="http:"?e:t}catch{return t}}function _kt(e){window.api?.openExternal?window.api.openExternal(e):window.open(e,"_blank")}const Tkt=(e,t)=>e==="pending"?{sentence:`Verify your email to claim ${t}. Check your inbox for the link Radient sent.`,action:"Open verification page"}:e==="expired"?{sentence:`The link to claim ${t} has expired. Request a new one from the verification page.`,action:"Request a new link"}:{sentence:"No signup grant is attached to this account. Open the verification page to check the account.",action:"Open verification page"};function Xkt(e,t){if(e===void 0)return{state:"unknown",lines:["You're out of credits. If you haven't verified your email yet, verify it to claim free credits and start using Local Operator for free.","Otherwise, top up in the Radient console."],links:[{label:"Open verification page",url:dF},{label:hF,url:fF}]};if(kkt(e)){const i=pF(e.claim_url,dF),{action:a}=Tkt(e.signup_grant,"");return e.signup_grant==="none"?{state:"unverified",lines:["You haven't verified your email yet. Open the verification page to check whether free credits are waiting on your account."],links:[{label:a,url:i}]}:{state:"unverified",lines:[`You haven't verified your email yet. Verify to claim ${Pkt(e.grant_amount??t)} and start using Local Operator for free.`,e.signup_grant==="expired"?"The link you were sent has expired. Request a new one on the verification page.":"Check your inbox for the link Radient sent."],links:[{label:a,url:i}]}}const n=e.first_topup,r=["You're out of credits. Top up in the Radient console."];return n!==void 0&&n.bonus_received===!1&&Number.isFinite(n.bonus_amount)&&Number.isFinite(n.minimum_purchase)&&r.push(`Get an extra ${vj(n.bonus_amount)} free on your first top-up of ${vj(n.minimum_purchase)} or more.`),{state:"verified",lines:r,links:[{label:hF,url:pF(n?.topup_url,fF)}]}}const Rkt=5*1e3,Ekt=({action:e})=>{const{user:t,accountRead:n}=Voe({staleTime:Rkt,retryOnMount:!1}),r=ni(),{prices:i}=Qkt(),o=r.isPending||n==="checking"?null:Xkt(n==="ready"?t?.verification:void 0,i?.default_new_credits);return f.jsxs("div",{className:"mt-1 flex flex-col items-start gap-2 pl-6",children:[o?f.jsxs("div",{"data-radient-credits-state":o.state,className:"flex max-w-[60ch] items-start gap-3 rounded-sm border border-hairline bg-surface p-3",children:[f.jsx(py,{className:"mt-0.5 size-4 shrink-0 text-ink-muted","aria-hidden":"true"}),f.jsx("div",{className:"min-w-0 text-body-sm text-ink",children:o.lines.map(s=>f.jsx("p",{className:"[&:not(:first-child)]:mt-1",children:s},s))})]}):null,f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o?.links.map(s=>f.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>_kt(s.url),children:s.label},s.url)),f.jsx(Se,{variant:"ghost",size:"sm",asChild:!0,children:f.jsx(lae,{to:e.to,children:e.label})})]})]})},DT=(e,t,n="normal",r=0)=>{const a=e.scrollTop+t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-r;e.scrollTop=n==="reversed"?Math.min(0,a):Math.max(0,a)},K1=24,fbe=6,bj=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),mF=async e=>{for(let t=0;t<fbe;t+=1){if(e())return;await bj()}},hbe=e=>{let t=null;return()=>(t!==null||(t=e().finally(()=>{t=null})),t)},qkt=e=>{const t=hbe(e.loadOlder),n=()=>mF(()=>e.reachable()||e.rowDistance()!==null);return{loadOne:t,loadThrough:async i=>{const a=e.hasHeadroom??(()=>!0);let o=0;for(;;){if(e.reachable())return"landed";const s=e.rowDistance();if(s!==null){if(i.maxRows!==void 0&&s>i.maxRows)return"over-budget";if(!a()&&o<i.maxPages&&(o+=1,await t())){await n();continue}return e.mount(s),await mF(()=>e.reachable()),e.reachable()?"landed":"exhausted"}if(o>=i.maxPages||(o+=1,!await t()))return"exhausted";await n()}}}},Dg="data-jump-highlight",jkt=1400,Ckt=12,zkt=1200,Akt=fbe,Ukt=Akt+2,Wkt=2,Ykt=30,gF=1,hg=K1;let Mf=0;async function Nkt(e){const{isReachable:t,rowDistance:n,mount:r,loadOlder:i}=e,a=e.hasHeadroom??(()=>!0);return await qkt({reachable:t,rowDistance:n,mount:r,loadOlder:i,hasHeadroom:a}).loadThrough({maxPages:Ckt,maxRows:zkt})==="landed"}async function Gkt(e,t,n){if(!n()||!t.isConnected)return;Mf+=1;const r=Mf;DT(e,t,"reversed",hg);const i=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);let a=!1;const o=()=>{a=!0},s=l=>{i.has(l.key)&&(a=!0)};e.addEventListener("wheel",o,{passive:!0,once:!0}),e.addEventListener("pointerdown",o,{passive:!0,once:!0}),e.addEventListener("touchstart",o,{passive:!0,once:!0}),window.addEventListener("keydown",s);try{let l=0,c=!1;for(let u=0;u<Ukt&&(await bj(),!(!n()||!t.isConnected||a||r!==Mf));u+=1){const O=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-hg;if(Math.abs(O)<=gF){if(l+=1,l>=Wkt){c=!0;break}continue}l=0,DT(e,t,"reversed",hg)}if(c&&!a&&r===Mf){const u=e,O=t,d=()=>{a=!0};u.addEventListener("wheel",d,{passive:!0,once:!0}),u.addEventListener("pointerdown",d,{passive:!0,once:!0}),u.addEventListener("touchstart",d,{passive:!0,once:!0}),window.addEventListener("keydown",s),(async()=>{try{for(let h=0;h<Ykt;h+=1){if(await bj(),!n()||a||r!==Mf||!u.isConnected||!O.isConnected)return;const p=O.getBoundingClientRect().top-u.getBoundingClientRect().top-u.clientTop-hg;if(Math.abs(p)<=gF)continue;DT(u,O,"reversed",hg);const m=u.ownerDocument?.defaultView;m!=null&&u.dispatchEvent(new m.Event("scroll"))}}finally{u.removeEventListener("wheel",d),u.removeEventListener("pointerdown",d),u.removeEventListener("touchstart",d),window.removeEventListener("keydown",s)}})()}}finally{e.removeEventListener("wheel",o),e.removeEventListener("pointerdown",o),e.removeEventListener("touchstart",o),window.removeEventListener("keydown",s)}if(n()&&!a&&r===Mf){const l=e.ownerDocument?.defaultView;l!=null&&e.dispatchEvent(new l.Event("scroll"))}}function pbe(e,t,n,r=()=>!0){return r()?new Promise(i=>{UQt(e,n,{isCurrent:r,onRevealed:a=>{if(!r()){i("missing");return}$F(a),Gkt(t,a,r).then(()=>{r()&&a.isConnected&&!a.hasAttribute(Dg)&&$F(a),i(r()?"landed":"missing")})},onMissing:()=>{i("missing")}})}):Promise.resolve("missing")}const VT=new WeakMap;function $F(e){const t=VT.get(e);t!==void 0&&window.clearTimeout(t);const n=e.hasAttribute(Dg);e.removeAttribute(Dg),n&&e.offsetHeight,e.setAttribute(Dg,""),VT.set(e,window.setTimeout(()=>{VT.delete(e),e.removeAttribute(Dg)},jkt))}const ju=120,Zb=400,Zkt=.5,Ikt=320,Dkt=900,Ib=64,mk=2,MT=24,LT=3,Vkt=4,k$=12,wj=k$,Mkt=120,Lkt=.35,yF=12,Fkt=8,Bkt=k$,Hkt=.5,vF=()=>({armed:!1,deliberate:!1,retained:!1,busy:!1,continuation:!1,clampLatched:!1,actFetchSpent:!1,travelledSinceLatch:!1,actTravelled:!1,pressDemand:!1,pageWidenOwed:!1,turnedAround:!1,lastInputAt:Number.NEGATIVE_INFINITY,failures:0,chainFetch:0,chainWiden:0,chainInvisible:0,actAsks:0,revealsThisAct:0}),mbe=e=>Math.min(Dkt,Math.max(Ikt,Math.round(e*Zkt))),Kkt=(e,t)=>{if(t.direction==="down")return{...e,armed:!1,deliberate:!1,retained:!1,actFetchSpent:t.at-e.lastInputAt>=Zb?!1:e.actFetchSpent,actAsks:t.at-e.lastInputAt>=Zb?0:e.actAsks,revealsThisAct:t.at-e.lastInputAt>=Zb?0:e.revealsThisAct,continuation:!1,clampLatched:!1,travelledSinceLatch:!1,actTravelled:e.actTravelled||t.travelledPx>=Ib,pageWidenOwed:!1,turnedAround:e.busy,chainFetch:0,chainWiden:0,chainInvisible:0,lastInputAt:t.at};const n=t.at-e.lastInputAt>=Zb,r={...e,actFetchSpent:n?!1:e.actFetchSpent,actAsks:n?0:e.actAsks,revealsThisAct:n?0:e.revealsThisAct,travelledSinceLatch:n?!1:e.travelledSinceLatch,actTravelled:n?t.travelledPx>=Ib:e.actTravelled||t.travelledPx>=Ib,continuation:!1,turnedAround:!1,chainFetch:0,chainInvisible:0,chainWiden:0,lastInputAt:t.at};return t.deliberate?{...r,clampLatched:!1,failures:0,deliberate:!0,actFetchSpent:!1,actAsks:0,revealsThisAct:0,actTravelled:!1,pressDemand:!1,...e.busy?{retained:!0}:{armed:!0}}:t.atHardTop&&t.continuous&&e.clampLatched&&!n?t.travelledPx>=Ib&&!e.travelledSinceLatch?{...r,armed:!0,pressDemand:!1,clampLatched:!1,travelledSinceLatch:!0}:!e.armed&&e.clampLatched&&!e.actTravelled?{...e,armed:!0,pressDemand:!0,lastInputAt:t.at}:{...e,lastInputAt:t.at}:e.busy?{...r,retained:!0,pressDemand:!1}:{...r,armed:!0,pressDemand:!1}},pg=(e,t,n)=>({action:t,state:{...e,armed:!1,deliberate:!1,busy:!0,continuation:!1,clampLatched:e.clampLatched||e.armed&&n.distanceFromTopPx<=mk,pageWidenOwed:e.pageWidenOwed&&t!=="widen",actFetchSpent:t==="fetch"?!0:e.actFetchSpent,chainWiden:t==="widen"?e.chainWiden+1:e.chainWiden,chainFetch:t==="fetch"?e.chainFetch+1:e.chainFetch,actAsks:t==="fetch"?e.actAsks+1:e.actAsks,revealsThisAct:e.revealsThisAct+1,chainInvisible:e.chainInvisible}}),Jkt=(e,t,n)=>e.busy||e.pageWidenOwed?!0:!e.armed||!gbe(t).inZone?!1:t.distanceFromTopPx<=mk?!e.pressDemand||!e.clampLatched||e.actTravelled||e.actAsks>=wj?!1:n-e.lastInputAt>=ju:!0;function gbe(e,t=mbe(e.clientHeight)){return{inZone:e.distanceFromTopPx<=t}}const ePt=(e,t,n)=>{if(e.busy)return{action:"none",state:e};const r=t.hiddenRows>0?"widen":t.hasMore?"fetch":"none";if(r==="none")return{action:"none",state:e.armed||e.continuation?{...e,armed:!1,deliberate:!1,continuation:!1}:e};if(t.followingTail&&t.scrollable)return e.armed?{action:"none",state:{...e,armed:!1}}:{action:"none",state:e};const i=mbe(t.clientHeight),{inZone:a}=gbe(t,i),o=n-e.lastInputAt>=ju||t.distanceFromTopPx<=mk,s=e.revealsThisAct<Bkt;if(e.pageWidenOwed&&r==="widen"&&e.chainWiden<yF&&s)return o?pg({...e,pageWidenOwed:!1,continuation:!1,armed:!1,retained:!1,deliberate:!1},r,t):{action:"none",state:e};if(e.armed){if(e.deliberate)return pg(e,r,t);if(r==="fetch"&&e.failures>=LT)return{action:"none",state:{...e,armed:!1}};if(!o)return{action:"none",state:e};if(!a)return{action:"none",state:{...e,armed:!1}};if(r==="fetch"&&e.actFetchSpent){const l=n-e.lastInputAt>=ju;return l&&e.clampLatched&&!e.actTravelled&&e.pressDemand&&e.actAsks<wj?pg(e,r,t):l?{action:"none",state:{...e,armed:!1}}:{action:"none",state:e}}return pg(e,r,t)}if(e.continuation){const l=e.actAsks<wj,c=l&&e.chainInvisible>0&&e.chainInvisible<k$;return t.scrollable&&!(e.pageWidenOwed&&r==="widen")&&!c?{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}:s&&(r==="widen"?e.chainWiden<yF:(c||l&&e.chainFetch<Vkt)&&e.failures<LT)?pg({...e,pageWidenOwed:!1,continuation:!1},r,t):{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}}return{action:"none",state:e}},bF=(e,{network:t=!0,hiddenRowsAfter:n=0,paintedDelta:r=null,growthPx:i=null,clientHeight:a=0,newRecords:o=null}={})=>{const s=r!==null&&r<Fkt,l=r===null&&t&&i!==null&&i<Math.max(Mkt,Lkt*a),c=s||t&&o===0||l;return{...e,busy:!1,failures:t?0:e.failures,armed:e.retained,pressDemand:e.retained&&e.pressDemand,deliberate:e.retained?e.deliberate:!1,retained:!1,turnedAround:!1,pageWidenOwed:t&&n>0,actFetchSpent:c?!1:e.actFetchSpent,chainInvisible:c?Math.min(e.chainInvisible+1,k$):0,continuation:t&&n>0||c&&e.chainInvisible+1<k$||!e.retained&&!e.turnedAround}},tPt=e=>({...e,busy:!1,pressDemand:!1,failures:e.failures+1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),nPt=e=>({...e,busy:!1,pressDemand:!1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),rPt=(e,t,n,r)=>n===r?$be(e,t):null,$be=(e,t)=>{if(!e||!t||e.id!==t.id||e.extent===t.extent)return 0;const n=t.viewportOffset-e.viewportOffset;return Math.abs(n)<Hkt?0:n};function ybe({path:e}){switch(m6(e)){case"image":return f.jsx(PXe,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"spreadsheet":return f.jsx(XXe,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"markdown":case"text":case"document":return f.jsx(FS,{"aria-hidden":"true",className:"size-3.5 shrink-0"});default:return f.jsx(gy,{"aria-hidden":"true",className:"size-3.5 shrink-0"})}}function iPt(e,t){try{return F9(e,t)}catch{return!1}}function dA(e,t,n){const r=$.useCallback(async o=>{try{const[s]=await window.api.probeFiles([e],t??void 0);if(!s?.resolved.startsWith("/"))throw new Error("File path has no session working directory");await o(s.resolved)}catch{Kr(Y("ui.chat.highlights.file_resolution_failed"))}},[e,t]),i=iPt(n??null,e),a=$.useCallback(()=>{r(async o=>{i&&n&&await n.openInCanvas(o)||await rO(o)})},[r,i,n]);return{canOpenInCanvas:i,press:a,withTarget:r}}const vbe=$.memo(function({actionPath:t,label:n,cwd:r,pane:i,overlay:a=!1}){ut();const{canOpenInCanvas:o,withTarget:s}=dA(t,r,i),[l,c]=$.useState(!1),u=`Actions for ${n||"this file"}`;return f.jsxs(XC,{children:[f.jsx(wt,{content:"File actions",children:f.jsx(RC,{asChild:!0,children:a?f.jsx(Se,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":u,children:f.jsx(kE,{"aria-hidden":"true"})}):f.jsx("button",{type:"button",className:"flex size-6 shrink-0 items-center justify-center text-ink-dim opacity-0 group-hover:opacity-100 focus-visible:opacity-100","aria-label":u,children:f.jsx(kE,{"aria-hidden":"true",className:"size-3.5"})})})}),f.jsxs(EC,{align:"end",className:"min-w-45",children:[o&&f.jsxs(rl,{onSelect:()=>{s(O=>i?.openInCanvas(O))},children:[f.jsx(pae,{"aria-hidden":"true"}),f.jsx("span",{children:Y("ui.chat.canonical.supplement.file_actions.open_in_canvas")})]}),f.jsxs(rl,{onSelect:()=>{s(rO)},children:[f.jsx(gy,{"aria-hidden":"true"}),f.jsx("span",{children:Y("ui.chat.canonical.supplement.file_actions.open_in_default_app")})]}),f.jsxs(rl,{onSelect:()=>{s(B9)},children:[f.jsx(Gh,{"aria-hidden":"true"}),f.jsx("span",{children:Y("ui.chat.canonical.supplement.file_actions.reveal_in_finder")})]}),f.jsxs(rl,{onSelect:()=>{navigator.clipboard.writeText(t).then(()=>c(!0)).catch(()=>Kr("Failed to copy file path"))},children:[f.jsx(NC,{"aria-hidden":"true"}),f.jsx("span",{children:l?"Copied":"Copy file path"})]})]})]})}),aPt="lo-supplement",oPt="s";function sPt(e,t){return`${aPt}://${oPt}/${e}/${t}`}const lPt="[supplement] frame torn down after a second load (hostile navigation or a blocked attempt)";function cPt(e){let t=e.parentElement;for(;t;){const n=window.getComputedStyle(t);if((n.overflowY==="auto"||n.overflowY==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function uPt({component:e,sessionId:t,documentHtml:n,documentFailed:r=!1,onRetry:i,onHeightChange:a,className:o}){ut();const s=a5e(e),[l,c]=$.useState(s),[u,O]=$.useState(!1),[d,h]=$.useState(!0),p=$.useRef(null),m=$.useRef(null),g=$.useRef(""),y=$.useRef(!1),v=$.useRef(""),x=$.useRef(()=>{}),S=$.useRef(0),b=$.useRef(s),w=$.useRef(null),Q=$.useRef(()=>{}),P=$.useRef(a),T=$.useRef(()=>{}),_=$.useCallback(R=>{y.current||(y.current=!0,v.current=R,O(!0))},[]);return $.useEffect(()=>{if(n===null)return;const R=m.current;if(!R)return;g.current=o5e();const q=window.api?.desktop?.armSupplementFrame,A=t!==null&&fE(e.attachment);let C;if(q===void 0)C=s5e(n);else if(A)C=sPt(t,e.attachment);else{_("no-address");return}let N=!1,I=!1,W=null,G=null,D=null;const j={resize:null,error:!1},V=window.setTimeout(()=>{N||_("no-ready")},dU),J=ne=>{R.contentWindow?.postMessage(ne,"*")},U=()=>{y.current||G===null&&(J({lo:"supplement-host",t:"ping"}),G=window.setTimeout(()=>{G=null,_("no-pong")},dU))};x.current=()=>{I||y.current||(I=!0,U(),W=window.setInterval(U,l5e))};const te=ne=>{const oe=p.current;if(oe){const ie=cPt(oe);if(ie&&oe.getBoundingClientRect().top<ie.getBoundingClientRect().top){w.current=ne,P.current?.(ne);return}}w.current=null,P.current?.(ne),ne!==b.current&&(b.current=ne,c(ne))},L=()=>{D===null&&(D=window.requestAnimationFrame(()=>{D=null;const{resize:ne,error:oe}=j;if(j.resize=null,j.error=!1,oe){_("frame-error");return}ne!==null&&te(ne)}))},B=ne=>{if(y.current||ne.source!==R.contentWindow||ne.origin!=="null")return;const oe=O5e(ne.data,g.current);if(oe){if(oe.t==="ready"){N||(N=!0,window.clearTimeout(V));return}if(oe.t==="pong"){G!==null&&(window.clearTimeout(G),G=null);return}if(oe.t==="resize"){j.resize=d5e(oe.h),h(!1),L();return}j.error=!0,L()}},Oe=()=>{const ne=w.current;ne!==null&&te(ne)};window.addEventListener("message",B),window.addEventListener("scroll",Oe,!0);let F=!1;return(async()=>{if(q)try{await q(C)}catch{}F||(R.src=C)})(),()=>{F=!0,window.clearTimeout(V),W!==null&&window.clearInterval(W),G!==null&&window.clearTimeout(G),D!==null&&window.cancelAnimationFrame(D),window.removeEventListener("message",B),window.removeEventListener("scroll",Oe,!0),x.current=()=>{}}},[n,_,t,e.attachment]),P.current=a,T.current=R=>{y.current||S.current!==1||m.current?.contentWindow?.postMessage({lo:"supplement-host",t:"theme",mode:R.mode,vars:R.vars,nonce:g.current},"*")},$.useEffect(()=>c5e(R=>T.current(R)),[]),Q.current=()=>{const R=S.current+1;if(S.current=R,R>1){console.debug(lPt),_("second-load");return}T.current(u5e()),x.current()},u||r?f.jsxs("div",{className:"text-ink-dim text-meta","data-supplement-frame-fallback":r?"document":v.current,children:[Y("ui.chat.canonical.supplement.frame.failed"),i&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",className:"px-1 text-ink-dim",children:"·"}),f.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-frame-retry":"",onClick:()=>i(),children:Y("ui.common.actions.retry")})]})]}):f.jsxs("div",{className:o,"data-supplement-frame-box":"",children:[f.jsxs("div",{ref:p,"data-supplement-frame":"",className:"relative overflow-hidden",style:{height:l,width:"100%"},children:[n!==null&&f.jsx("iframe",{ref:m,title:e.title,sandbox:"allow-scripts",onLoad:()=>Q.current(),className:"block h-full w-full border-0"}),d&&f.jsxs(f.Fragment,{children:[f.jsx("output",{className:"sr-only",children:Y("ui.chat.canonical.supplement.frame.loading")}),f.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 animate-shimmer bg-elevated/40 bg-gradient-to-r from-transparent via-elevated/60 to-transparent bg-[length:200%_100%] bg-[position:-200%_50%] bg-no-repeat"})]})]}),f.jsx("span",{className:"block truncate text-ink-muted text-meta",title:Y("ui.chat.canonical.supplement.frame.source",{name:e.source}),"data-supplement-source":"",children:Y("ui.chat.canonical.supplement.frame.source",{name:lw(e.source)})})]})}function OPt(e="200px"){const[t,n]=$.useState(()=>typeof IntersectionObserver>"u"),[r,i]=$.useState(null),a=$.useCallback(o=>i(o),[]);return $.useEffect(()=>{if(r===null||t||typeof IntersectionObserver>"u")return;const o=new IntersectionObserver(s=>{s.some(l=>l.isIntersecting)&&(n(!0),o.disconnect())},{rootMargin:e});return o.observe(r),()=>o.disconnect()},[r,e,t]),[a,t]}const dPt=150,xj=16*1024*1024,vs=new Map,Eh=[];let Vg=0,bbe=0,wbe=0,Sj=0;const xtn=()=>({entries:vs.size,queued:Eh.length,active:Vg,reads:bbe,decodes:wbe,peakActive:Sj}),fPt=e=>e.artifact?`finder:${e.artifact.sessionId}:${e.artifact.childId??"self"}:${e.artifact.digest}`:`finder:${e.path}:${e.lastAgentModified??0}:${e.sizeBytes??0}`;async function hPt(e){if(e.artifact)return yve({sessionId:e.artifact.sessionId,childId:e.artifact.childId??null},e.artifact.digest);const t=await window.api.readFileBytes(e.path,xj);if(!t.success)throw new Error(t.error??"Could not be read");return new Blob([t.data],{type:g6(e.path)})}function xbe(){for(const[e,t]of vs){if(vs.size<=dPt)return;t.listeners.size||t.started||(t.state.url&&xy(t.state.url),vs.delete(e))}}function wF(e,t){e.state=t;for(const n of e.listeners)n(t)}function Sbe(){for(;Vg<4&&Eh.length;){const e=Eh.shift();if(!e||!e.listeners.size){e&&vs.delete(e.key);continue}e.started=!0,Vg++,bbe++,Sj=Math.max(Sj,Vg),(async()=>{try{if((e.document.sizeBytes??0)>xj)throw new Error("Too large to preview");const t=await hPt(e.document);if(t.size>xj)throw new Error("Too large to preview");const n=e.document.artifact?.width,r=e.document.artifact?.height,i=n&&r?Math.min(1,640/Math.max(n,r)):null,a=i&&n&&r?{resizeWidth:Math.max(1,Math.round(n*i)),resizeHeight:Math.max(1,Math.round(r*i)),resizeQuality:"high"}:{resizeWidth:640,resizeQuality:"high"};let o,s=null;if(t.type==="image/svg+xml"||e.document.path.toLowerCase().endsWith(".svg")){s=URL.createObjectURL(t);const l=new Image;l.src=s;try{await l.decode()}catch(u){throw URL.revokeObjectURL(s),u}const c=Math.min(1,640/Math.max(l.naturalWidth,l.naturalHeight));l.width=Math.max(1,Math.round(l.naturalWidth*c)),l.height=Math.max(1,Math.round(l.naturalHeight*c)),o=l}else o=await createImageBitmap(t,a);wbe++;try{const l=Math.min(1,640/Math.max(o.width,o.height)),c=new OffscreenCanvas(Math.max(1,Math.round(o.width*l)),Math.max(1,Math.round(o.height*l))),u=c.getContext("2d");if(!u)throw new Error("Can't preview this image");u.drawImage(o,0,0,c.width,c.height);const O=await c.convertToBlob({type:"image/png"});wF(e,{state:"ready",url:y6(await O.arrayBuffer(),"image/png")})}finally{"close"in o&&o.close(),s&&URL.revokeObjectURL(s)}}catch(t){wF(e,{state:"unavailable",reason:t instanceof Error?t.message:"Could not be read"})}finally{e.started=!1,Vg--,xbe(),Sbe()}})()}}function pPt(e,t){const n=fPt(e),[r,i]=$.useState({state:"loading"});return $.useEffect(()=>{if(!t)return;let a=vs.get(n);a?.state.state==="unavailable"&&!a.listeners.size&&(vs.delete(n),a=void 0),a?(vs.delete(n),vs.set(n,a)):(a={key:n,document:e,state:{state:"loading"},listeners:new Set,started:!1},vs.set(n,a),Eh.push(a)),a.listeners.add(i),i(a.state),Sbe();const o=a;return()=>{if(o.listeners.delete(i),!o.started&&o.state.state==="loading"&&!o.listeners.size){const s=Eh.indexOf(o);s>=0&&Eh.splice(s,1),vs.delete(n)}xbe()}},[n,t,e]),r}const mPt="pointer-events-none absolute top-1 right-1 flex opacity-0 transition-opacity duration-fast ease-out-quart group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100",gPt=$.memo(function({file:t,cwd:n,pane:r}){const{name:i,path:a}=Eie(t),o=i||a||t.path,[s,l]=OPt(),[c,u]=$.useState(null),[O,d]=$.useState(!1);$.useEffect(()=>{let x=!1;const S=window.api?.probeFiles;if(typeof S!="function"){u(null),d(!0);return}return u(null),d(!1),(async()=>{try{const[b]=await S([t.path],n??void 0),w=b?.resolved??"";x||u(w.startsWith("/")?w:null)}catch{x||u(null)}finally{x||d(!0)}})(),()=>{x=!0}},[t.path,n]);const h=$.useMemo(()=>({id:`supplement:${t.path}`,title:o,path:c??t.path,content:"",type:"image",sizeBytes:t.sizeBytes,lastAgentModified:t.mtime?t.mtime*1e3:void 0}),[t.path,o,t.sizeBytes,t.mtime,c]),p=pPt(h,l&&c!==null),{press:m}=dA(t.path,n,r),g=p.state==="ready"&&typeof p.url=="string",v=!(!O||c!==null&&p.state==="loading")&&(c===null||p.state==="unavailable");return f.jsx("li",{className:"flex leading-none","data-supplement-image-tile":"",children:f.jsxs("div",{className:"group relative",ref:s,children:[f.jsx("button",{type:"button",className:"group/tile block cursor-pointer rounded-sm","aria-label":`Open ${o}`,title:t.path,onClick:()=>void m(),children:g?f.jsx(iO,{boundary:"control",className:"h-[78px] w-[117px]",children:f.jsx("img",{alt:"",className:"h-[76px] w-[115px] object-contain",src:p.url})}):v?f.jsx("span",{className:"flex h-[78px] w-[117px] items-center justify-center rounded-sm border border-control bg-sunken text-ink-dim","data-supplement-image-fallback":"",children:f.jsx(ybe,{path:t.path})}):f.jsx(iO,{boundary:"control",className:"h-[78px] w-[117px]"})}),f.jsx("div",{className:mPt,children:f.jsx(vbe,{overlay:!0,actionPath:t.path,label:o,cwd:n,pane:r})})]})})}),$Pt=({files:e,cwd:t,pane:n,className:r})=>f.jsx("ul",{role:"list","aria-label":e.length===1?"1 image from this run":`${e.length} images from this run`,"data-supplement-images":"",className:E("grid grid-cols-[repeat(4,max-content)] gap-2",r),children:e.map(i=>f.jsx(gPt,{file:i,cwd:t,pane:n},i.path))}),yPt=2*1024*1024,gh=new Map,FT=new Map,vPt=64,xF={html:null,failed:!1};async function bPt(e,t){const n=`${e}:${t}`,r=FT.get(n);if(r)return r;const i=(async()=>{try{const a=await Sc({op:"sessions.supplementDocument",sessionId:e,digest:t},null);if(a.kind!=="json")return null;const o=a.body,s=o&&typeof o.html=="string"?o.html:null;if(s===null||s.length>yPt)return null;for(gh.set(n,s);gh.size>vPt;){const l=gh.keys().next().value;if(l===void 0)break;gh.delete(l)}return s}catch{return null}finally{FT.delete(n)}})();return FT.set(n,i),i}function wPt(e,t,n){const[r,i]=$.useState(()=>{if(!e||!fE(t))return xF;const a=gh.get(`${e}:${t}`);return a!==void 0?{html:a,failed:!1}:xF});return $.useEffect(()=>{if(!n||!e||!fE(t))return;const a=gh.get(`${e}:${t}`);if(a!==void 0){i({html:a,failed:!1});return}let o=!1;return bPt(e,t).then(s=>{o||i(s!==null?{html:s,failed:!1}:{html:null,failed:!0})}),()=>{o=!0}},[n,e,t]),r}const SF=$.memo(function({actionPath:t,cwd:n,label:r,suffix:i,size:a,pane:o}){const{press:s}=dA(t,n,o);return f.jsxs("div",{className:"group flex w-full items-center gap-2 text-meta",children:[f.jsx(ybe,{path:t}),f.jsxs("button",{type:"button",className:"min-w-0 flex-1 truncate text-left text-ink hover:text-ink-dim","data-supplement-file":"",title:t,onClick:()=>{s()},children:[lw(r),i&&i!==r&&f.jsx("span",{className:"ml-2 text-ink-muted",children:lw(i)})]}),a&&f.jsx("span",{className:"shrink-0 text-ink-dim",children:a}),f.jsx(vbe,{actionPath:t,label:r,cwd:n,pane:o})]})}),xPt=$.memo(function({sound:t,sessionId:n}){const r=$.useMemo(()=>n?{sessionId:n,childId:null}:null,[n]),i=By({data:null,attachment:t.attachment,mimeType:t.mime},r),a=Hve(t.attachment,r),o=t.title||"Generated sound";return f.jsxs("div",{"data-supplement-sound":"",className:"flex min-w-0 flex-col gap-0.5",children:[t.title&&f.jsx("span",{"data-supplement-sound-title":"",title:t.title,className:"truncate text-meta text-ink-muted",children:lw(t.title)}),i.state==="missing"?f.jsx(zd,{name:o,detail:Dve}):i.state==="resolving"?f.jsx("div",{"data-supplement-sound-placeholder":"",className:"h-11","aria-hidden":!0}):f.jsx(Bve,{variant:"compact",ownerId:`sound:${t.attachment}`,src:i.url,label:o,peaks:a,durationHint:t.durationS})]})}),QF=$.memo(function({component:t,sessionId:n,onRetry:r,onHeight:i}){const a=$.useRef(null),[o,s]=$.useState(!1);$.useEffect(()=>{const u=a.current;if(u===null)return;if(typeof IntersectionObserver>"u"){s(!0);return}const O=new IntersectionObserver(d=>{for(const h of d)h.isIntersecting&&s(!0)},{rootMargin:"200px 0px"});return O.observe(u),()=>O.disconnect()},[]);const l=wPt(n,t.attachment,o),c=$.useCallback(u=>{i?.(t.attachment,u)},[i,t.attachment]);return f.jsx("div",{ref:a,"data-supplement-slot":"",children:f.jsx(uPt,{component:t,sessionId:n,documentHtml:l.html,documentFailed:l.failed,onRetry:r,onHeightChange:i?c:void 0})})}),SPt=$.memo(function({record:t,sessionId:n,cwd:r,condensed:i=!1}){ut();const a=ck(),[o,s]=$.useState(!1),[l,c]=$.useState(!1),[u,O]=$.useState(!1),d=JSON.stringify([n,t.anchor,t.job]),[h,p]=$.useState({identity:d,open:!0}),m=h.identity===d&&h.open;h.identity!==d&&(p({identity:d,open:!0}),O(!1));const[g,y]=$.useState(!1),[v,x]=$.useState(""),[S,b]=$.useState(!1),[w,Q]=$.useState(()=>new Map),[P,T]=$.useState(0),_=f5e(t,t.live),R=h5e(t.cause),q=t.files,A=t.filesMore,C=t.components,N=t.sounds??[],I=q.length+A,W=async ie=>{if(n){b(!0);try{await je({...ie,sessionId:n,job:t.job,anchor:t.anchor})}catch(we){Kr(ZS("Highlights could not be updated.",we))}finally{b(!1)}}},G=()=>{W({op:"supplements.cancel"})},D=()=>{W({op:"supplements.restart"})},j=()=>{const ie=v.trim();ie&&(y(!1),x(""),W({op:"supplements.steer",text:ie}))},V=$.useCallback((ie,we)=>{Q(ye=>{if(ye.get(ie)===we)return ye;const Re=new Map(ye);return Re.set(ie,we),Re})},[]),J=_5e(typeof window>"u"?900:window.innerHeight),{visible:U}=p5e(C,J,w);$.useEffect(()=>{T(ie=>Math.max(ie,U.length))},[U.length]);const te=Math.min(C.length,Math.max(P,U.length)),L=C.slice(0,te),B=C.slice(te),Oe=()=>_==="preparing"||_==="files_preparing"||_==="cancelled_retry"||_==="files_cancelled_retry"||_==="failed_retry"||_==="files_failed_retry"?f.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-meta","data-supplement-line":"",children:[(_==="preparing"||_==="files_preparing")&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",className:"relative inline-block size-3 overflow-hidden rounded-full bg-sunken",children:f.jsx("span",{className:"absolute inset-0 animate-shimmer bg-gradient-to-r from-transparent via-elevated to-transparent bg-[length:200%_100%] bg-[position:-200%_50%] bg-no-repeat"})}),f.jsx("span",{className:"text-ink-muted",children:w5e})]}),(_==="cancelled_retry"||_==="files_cancelled_retry")&&f.jsx("span",{className:"text-ink-muted",children:x5e}),(_==="failed_retry"||_==="files_failed_retry")&&f.jsxs("span",{className:"text-ink-muted",children:[S5e,R?` — ${R}`:""]}),(_==="preparing"||_==="files_preparing")&&n&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"·"}),!g&&f.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-adjust":"",onClick:()=>y(!0),children:Q5e}),f.jsx("button",{type:"button",className:"text-ink-dim disabled:text-ink-dim/60","data-supplement-cancel":"",disabled:S||t.state==="cancelling",onClick:G,children:k5e})]}),(_==="cancelled_retry"||_==="files_cancelled_retry"||_==="failed_retry"||_==="files_failed_retry")&&n&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"·"}),f.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-retry":"",onClick:D,children:P5e})]})]}):null,F=g?f.jsxs("div",{className:"flex items-center gap-2 text-meta","data-supplement-adjust-form":"",children:[f.jsx("input",{autoFocus:!0,className:"min-w-0 flex-1 rounded-sm border border-control bg-canvas px-1.5 py-0.5 text-ink text-meta",maxLength:m5e,placeholder:Y("ui.chat.canonical.supplement.adjust_placeholder"),value:v,onChange:ie=>x(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&j(),ie.key==="Escape"&&(y(!1),x(""))}}),f.jsx("button",{type:"button",className:"text-ink-dim disabled:text-ink-dim/60",disabled:S||!v.trim(),onClick:j,children:Y("ui.chat.canonical.supplement.send")})]}):null;if(_==="nothing")return null;let H=null;if(q.length>0||A>0){const ie=[],we=[];for(const Re of q)m6(Re.path)==="image"?ie.push(Re):we.push(Re);const ye=I<=2&&C.length===0&&A===0;H=f.jsxs("div",{className:"flex flex-col gap-1","data-supplement-files-summary":ye?"":void 0,"data-supplement-files":ye?void 0:"",children:[ie.length>0&&f.jsx($Pt,{files:ie,cwd:r,pane:a,className:we.length>0||A>0?"mb-1":void 0}),we.map(Re=>{const{name:ze,path:Ge,size:qe}=Eie(Re);return f.jsx(SF,{actionPath:Re.path,cwd:r,label:ze||Ge,suffix:Ge,size:qe,pane:a},`${Re.path}:${Re.name}`)}),A>0&&f.jsx(qi,{chevronClassName:"text-ink-dim",open:o,onOpenChange:s,rowClassName:"min-h-0 py-0",summary:f.jsx("span",{"data-supplement-more":"",children:o?"Show fewer":g5e(A)}),children:t.more.slice(0,20).map(Re=>f.jsx(SF,{actionPath:Re,cwd:r,label:Re,suffix:"",size:"",pane:a},Re))})]})}const ne=N.length>0?f.jsx("div",{"data-supplement-sounds":"",className:N.length>1?"grid grid-cols-[repeat(auto-fit,minmax(15rem,1fr))] gap-1":"flex flex-col gap-1",children:N.map(ie=>f.jsx(xPt,{sound:ie,sessionId:n},ie.attachment))}):null,oe=f.jsxs("div",{className:"flex flex-col gap-2","data-supplement-components":"",children:[L.map(ie=>f.jsx(QF,{component:ie,sessionId:n,onRetry:n?D:void 0,onHeight:V},ie.attachment)),B.length>0&&f.jsx(qi,{chevronClassName:"text-ink-dim",open:u,onOpenChange:O,rowClassName:"min-h-0 py-0",summary:f.jsx("span",{"data-supplement-show-all":"",children:u?"Show fewer":$5e(B.length)}),children:B.map(ie=>f.jsx(QF,{component:ie,sessionId:n,onRetry:n?D:void 0,onHeight:V},ie.attachment))})]});return f.jsxs("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,"data-supplement-condensed":i?"":void 0,children:[H,ne,Oe(),!i&&t.detail?.includes("prepared:unsupported")&&f.jsx("p",{className:"text-meta text-ink-muted","data-supplement-refusal":"",children:Y("ui.chat.canonical.supplement.preview_unavailable")}),!i&&(_==="failed_retry"||_==="files_failed_retry")&&f.jsxs("div",{className:"flex flex-col gap-1 text-meta text-ink-muted","data-supplement-diagnostic":"",children:[f.jsx("p",{children:y5e(t)}),((t.attempts?.length??0)>0||(t.detail?.length??0)>0)&&f.jsx(qi,{open:l,onOpenChange:c,rowClassName:"min-h-6 py-0",chevronClassName:"text-ink-dim",summary:"Details",children:f.jsxs("div",{className:"max-h-[min(320px,40vh)] overflow-auto break-words font-mono text-ink-dim",children:[t.model&&f.jsx("p",{children:Y("ui.chat.canonical.supplement.details.model",{name:t.model})}),f.jsx("p",{children:Y("ui.chat.canonical.supplement.details.attempts",{count:t.attempts?.length??0})}),t.detail?.map(ie=>f.jsx("p",{children:v5e(ie)},ie))]})})]}),(_==="preparing"||_==="files_preparing")&&F,_==="block"&&C.length>0&&(i?f.jsx(qi,{open:m,onOpenChange:ie=>{ie||O(!1),p({identity:d,open:ie})},chevronClassName:"text-ink-dim",rowClassName:"min-h-0 py-0",summary:f.jsx("span",{"data-supplement-graphics-reveal":"",children:b5e(C.length,m,L.length)}),children:f.jsx("div",{className:"-ml-5 w-[calc(100%+1.25rem)]",children:oe})}):oe)]})});function QPt(e){return e.shiftKey||e.altKey||!(e.metaKey||e.ctrlKey)?!1:e.key.toLowerCase()==="f"}const kPt=e=>e?"⌘F":"Ctrl+F";function PPt(e){switch(e){case"ready":case"building":case"unsupported":case"error":return e;default:return"error"}}function _Pt(e,t,n){return n<=0?-1:(((e<0||e>=n?t>0?-1:0:e)+t)%n+n)%n}function TPt(e,t){return t>=0&&t<e.length?e[t]:null}function XPt(e,t){const n=[];let r=0;for(const[i,a]of t){const o=Math.max(r,Math.min(e.length,i)),s=Math.max(o,Math.min(e.length,a));s<=o||(o>r&&n.push({text:e.slice(r,o),matched:!1}),n.push({text:e.slice(o,s),matched:!0}),r=s)}return r<e.length&&n.push({text:e.slice(r),matched:!1}),n}const RPt={user:"You",agent:"Agent"},EPt="related match",kF="Search this conversation",qPt="Search results",jPt="Close search";function CPt(e){const t=e.filter(r=>r.tier==="exact").length,n=e.length-t;return n===0?e.length===1?"1 match":`${e.length} matches`:t===0?n===1?"1 related match":`${n} related matches`:`${t} exact · ${n} related`}const zPt="No messages match this search.",APt="Still indexing this conversation.",UPt="Results appear as the index catches up.",WPt="Newer messages may be missing while the index catches up.",YPt="This conversation lives on another device, so it cannot be searched here.",NPt="This conversation could not be searched.",GPt="Try again",ZPt="Check again",IPt="Could not reach that message. It is further back than the loaded history — scroll up in the transcript to load more.",DPt="Updating — the list below is the previous search's.",VPt="Going to that message…";function MPt(e){return e===1?"(the first match shown)":`(first ${e} shown)`}function LPt(e){return e.state==="building"}async function FPt(e,t){if(e===null)return"not-mounted";const n=e.querySelector("[data-lo-transcript-content]")??e;return await pbe(n,e,t)==="landed"?"revealed":"not-mounted"}async function BPt(e){const t=e.query.trim().slice(0,qie);if(t.length===0)return{query:"",state:"ready",partial:!1,hits:[],truncated:!1};const n=Math.min(Math.max(e.limit??T5e,1),X5e);return je({op:"sessions.find",sessionId:e.sessionId,q:t,limit:n})}const HPt=200,KPt=1500;function JPt({sessionId:e,enabled:t}){const[n,r]=$.useState(""),[i,a]=$.useState("idle"),[o,s]=$.useState([]),[l,c]=$.useState(!1),[u,O]=$.useState(!1),[d,h]=$.useState(-1),p=$.useRef(0),m=$.useRef(0),g=$.useRef(0),y=$.useRef(""),v=$.useRef(null),x=$.useRef(null),S=$.useRef(new Set),b=$.useRef(e);b.current=e;const w=$.useCallback(()=>{x.current!==null&&(clearTimeout(x.current),x.current=null)},[]),Q=$.useCallback((C,N)=>{S.current.has(C)||(S.current.add(C),console.warn(C,N))},[]),P=$.useCallback(()=>{p.current+=1,w(),v.current=null,g.current=0,a("idle"),s(C=>C.length===0?C:[]),c(!1),O(!1),h(-1)},[w]),T=$.useRef(()=>{}),_=$.useCallback((C,N)=>{const I=PPt(N.state);a(I);const W=I==="ready"||I==="building",G=W?N.hits:[];if(g.current=G.length,s(G),c(W&&N.truncated),O(I==="building"&&N.partial),h(G.length>0?0:-1),I==="building"&&LPt(N)){if(v.current!==C){v.current=C;const D=p.current;x.current=setTimeout(()=>{x.current=null,p.current===D&&T.current(C,"follow-up")},KPt)}}else w()},[w]),R=$.useCallback((C,N)=>{const I=b.current;if(!I)return;const W=p.current,G=++m.current;N==="fresh"&&(w(),v.current=null,a("loading")),BPt({sessionId:I,query:C}).then(D=>{G!==m.current||p.current!==W||_(C,D)}).catch(D=>{G!==m.current||p.current!==W||(Q("thread search could not be answered:",D),w(),v.current=null,g.current=0,s([]),c(!1),O(!1),h(-1),a("error"))})},[_,w,Q]);T.current=R,$.useEffect(()=>{const C=`${t?"1":"0"}:${e??""}`;if(y.current!==C&&(y.current=C,S.current=new Set,P(),r(G=>G===""?G:""),!t||!e))return;if(!t||!e){P();return}const N=n.trim();if(N.length===0){P();return}const I=p.current,W=setTimeout(()=>{p.current===I&&T.current(N,"fresh")},HPt);return()=>clearTimeout(W)},[n,t,e,P]),$.useEffect(()=>()=>w(),[w]);const q=$.useCallback(C=>{h(N=>_Pt(N,C,g.current))},[]),A=$.useCallback(()=>{const C=n.trim();!t||!e||C.length===0||T.current(C,"fresh")},[t,e,n]);return{query:n,setQuery:r,state:i,hits:o,truncated:l,partial:u,cursor:d,moveCursor:q,activeHit:TPt(o,d),refresh:A}}const e5t=E("bg-accent-wash","before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent"),t5t="bg-accent-wash font-medium text-ink underline decoration-accent decoration-2 underline-offset-2",n5t=()=>navigator.platform.toUpperCase().indexOf("MAC")>=0,r5t=({hit:e,active:t,optionId:n,onNavigate:r})=>{const i=XPt(e.snippet,e.ranges);return f.jsxs("li",{id:n,role:"option","aria-selected":t,onMouseDown:a=>a.preventDefault(),onClick:()=>r(e),className:E("relative flex cursor-pointer flex-col gap-0.5 px-3 py-2",t?e5t:"hover:bg-accent-wash"),children:[f.jsxs("span",{className:"flex items-center gap-1.5 text-ink-muted text-meta",children:[f.jsx("span",{children:RPt[e.role]}),e.tier==="soft"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{className:"text-ink-dim",children:EPt})]})]}),f.jsx("span",{className:"line-clamp-2 text-body-sm text-ink",children:i.map((a,o)=>a.matched?f.jsx("mark",{className:t5t,children:a.text},o):f.jsx("span",{children:a.text},o))})]})},i5t=({query:e,onQueryChange:t,state:n,hits:r,cursor:i,truncated:a,partial:o,onMoveCursor:s,onNavigate:l,onRetry:c,onClose:u,isMac:O,jumping:d=!1})=>{const h=$.useId(),p=`${h}-list`,m=$.useCallback(b=>`${h}-opt-${b}`,[h]),g=$.useRef(null),y=i>=0&&i<r.length?r[i]:null,v=r.length>0,x=n==="error"||n==="building";$.useEffect(()=>{g.current?.focus(),g.current?.select()},[]),$.useEffect(()=>{i<0||document.getElementById(m(i))?.scrollIntoView({block:"nearest"})},[i,m]);const S=b=>{if(b.key==="ArrowDown"){b.preventDefault(),s(1);return}if(b.key==="ArrowUp"){b.preventDefault(),s(-1);return}if(b.key==="Enter"){b.preventDefault(),y!==null?l(y):x&&c();return}};return f.jsxs("div",{"data-lo-thread-search":"",role:"presentation",onKeyDown:b=>{b.defaultPrevented||b.key==="Escape"&&(b.preventDefault(),u())},className:"pointer-events-auto w-[26rem] max-w-full rounded-md border border-hairline bg-elevated text-body-sm text-ink shadow-overlay",children:[f.jsx("div",{className:"p-2",children:f.jsxs("div",{className:E("flex items-center gap-2 rounded-sm border border-control bg-surface px-2","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[f.jsx($y,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-ink-dim"}),f.jsx("input",{ref:g,type:"text",value:e,onChange:b=>t(b.target.value),onKeyDown:S,maxLength:qie,placeholder:kF,"aria-label":kF,role:"combobox","aria-expanded":v,"aria-controls":v?p:void 0,"aria-activedescendant":y!==null?m(i):void 0,"aria-autocomplete":"list",autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 border-0 bg-transparent text-body-sm text-ink outline-none placeholder:text-ink-dim"}),f.jsx(Se,{type:"button",variant:"ghost",size:"icon-sm","aria-label":jPt,onClick:u,children:f.jsx(zi,{"aria-hidden":"true"})})]})}),f.jsxs("div",{className:"flex items-start gap-2 px-3 pb-2",children:[f.jsxs("p",{className:"min-w-0 flex-1 text-ink-muted text-meta",children:[n==="loading"&&(v?DPt:"Searching…"),n==="ready"&&(r.length>0?CPt(r):zPt),n==="building"&&(o?WPt:APt),n==="unsupported"&&YPt,n==="error"&&NPt,n==="ready"&&a&&v&&f.jsxs("span",{className:"text-ink-dim",children:[" ",MPt(r.length)]}),n==="building"&&!o&&f.jsxs("span",{className:"text-ink-dim",children:[" ",UPt]})]}),x&&f.jsx(Se,{type:"button",variant:"ghost",size:"sm",onClick:c,className:"shrink-0",children:n==="building"?ZPt:GPt})]}),v&&f.jsx("ul",{id:p,role:"listbox","aria-label":qPt,"aria-busy":n==="loading",className:E("max-h-80 overflow-y-auto border-t border-hairline py-1",n==="loading"&&"opacity-60"),children:r.map((b,w)=>f.jsx(r5t,{hit:b,active:w===i,optionId:m(w),onNavigate:l},b.id))}),d&&f.jsx("output",{className:"block border-t border-hairline px-3 py-1.5 text-ink-muted text-meta",children:VPt}),f.jsxs("div",{className:"flex items-center gap-3 border-t border-hairline px-3 py-1.5",children:[f.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[f.jsx(JO,{shortcut:"↑"}),f.jsx(JO,{shortcut:"↓"}),f.jsx("span",{children:"browse"})]}),f.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[f.jsx(JO,{shortcut:"↵"}),f.jsx("span",{children:"jump"})]}),f.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[f.jsx(JO,{shortcut:"esc"}),f.jsx("span",{children:"close"})]}),f.jsx("span",{className:"ml-auto text-ink-dim text-meta",children:kPt(O)})]})]})},a5t=({sessionId:e,containerRef:t,onReveal:n})=>{const[r,i]=$.useState(!1),[a,o]=$.useState(!1),s=$.useRef(null),l=$.useRef(null),c=JPt({sessionId:e,enabled:r}),u=$.useCallback(()=>{const h=document.activeElement;l.current=h instanceof HTMLElement?h:null,i(!0)},[]),O=$.useCallback(()=>{i(!1);const h=l.current;l.current=null,h?.isConnected&&h.focus()},[]);$.useEffect(()=>{const h=p=>{if(p.defaultPrevented||!QPt(p))return;const m=p.target;if(!(!(s.current!==null&&m!==null&&s.current.contains(m))&&(A0(p.target)||Yae(p.target)===null))){if(p.preventDefault(),r){const y=s.current?.querySelector("input");y?.focus(),y?.select();return}u()}};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[r,u]);const d=$.useCallback(async h=>{o(!0);try{if(n){await n(h.id);return}await FPt(t.current,h.id)}finally{o(!1)}},[t,n]);return r?f.jsx("div",{ref:s,className:"pointer-events-none absolute top-3 right-6 z-20 max-w-[calc(100%-1.5rem)]",children:f.jsx(i5t,{query:c.query,onQueryChange:c.setQuery,state:c.state,hits:c.hits,cursor:c.cursor,truncated:c.truncated,partial:c.partial,onMoveCursor:c.moveCursor,onNavigate:d,onRetry:c.refresh,onClose:O,isMac:n5t(),jumping:a})}):null},o5t=/\s+$/;function s5t(e){return e.kind==="user"||e.kind==="assistant"}function Qbe(e){return e.kind!=="user"&&e.kind!=="assistant"?"":jie(e.text)?.text??e.text}const l5t=Jle().use(Ile).use(Ic);function fA(e){switch(e.type){case"text":case"inlineCode":case"html":return e.value??"";case"image":return e.alt??"";case"break":return`
823
823
  `;default:return(e.children??[]).map(fA).join("")}}function c5t(e){return(e.children??[]).map(t=>(t.children??[]).map(n=>fA(n)).join(" | ")).join(`
@@ -945,4 +945,4 @@ ${m}`,J=A.current;A.current=V,!(J===null||J===V)&&(gLt(J.split(`
945
945
  }`,Pke=()=>f.jsxs("div",{className:"flex h-6 items-center gap-0.5 [&>span]:animate-[waveform-bar_1.2s_infinite_ease-in-out]","aria-hidden":"true",children:[f.jsx("style",{children:EHt}),f.jsx("span",{className:"size-[3px] rounded-[1px] bg-accent"}),f.jsx("span",{className:"h-2 size-[3px] rounded-[1px] bg-accent",style:{animationDelay:"0.2s"}}),f.jsx("span",{className:"size-[3px] rounded-[1px] bg-accent",style:{animationDelay:"0.4s"}}),f.jsx("span",{className:"h-3 size-[3px] rounded-[1px] bg-accent",style:{animationDelay:"0.6s"}}),f.jsx("span",{className:"size-[3px] rounded-[1px] bg-accent",style:{animationDelay:"0.8s"}})]});Pke.displayName="WaveformAnimation";const qHt=120;function jHt({text:e,cwd:t,enabled:n=!1}){const r=$.useMemo(()=>n?iFt(e):[],[e,n]),i=$.useRef(new Map),a=$.useRef(t),[o,s]=$.useState(new Map),l=ni(),c=Qr(l.data,"projects",1),u=$.useRef(new Set),O=$.useMemo(()=>{const g=new Set;for(const y of r)if(y.path&&g.add(y.path),g.size>=Xie)break;return[...g]},[r]),d=O.join(`
946
946
  `),h=$.useMemo(()=>{const g=new Set;for(const y of O){const v=Ire(y);v&&g.add(v.toLowerCase())}return[...g]},[O]),p=()=>{const g=new Map(i.current);if(u.current.size===0)return g;for(const y of O){const v=Ire(y);v&&u.current.has(v.toLowerCase())&&g.set(y,{exists:!0,outside:!1})}return g};$.useEffect(()=>{const g=window.api;if(a.current!==t&&(a.current=t,i.current.clear(),s(p())),!n||O.length===0){s(b=>b.size>0?new Map:b);return}if(typeof g?.probeFiles!="function"&&h.length===0){s(b=>b.size>0?p():b);return}const y=O.filter(b=>!i.current.has(b)),v=c?h.filter(b=>!u.current.has(b)):[];if(y.length===0&&v.length===0){s(p());return}let x=!1;const S=setTimeout(()=>{const b=y.length>0&&typeof g?.probeFiles=="function"?g.probeFiles(y,t).then(Q=>{if(!x)for(const P of Q)P.exists&&i.current.set(P.input,{exists:!0,outside:P.outsideWorkspace===!0})}).catch(()=>{}):Promise.resolve(),w=v.length>0?je({op:"projects.list"}).then(Q=>{if(!x)for(const P of Q.projects){const T=P.name.toLowerCase();v.includes(T)&&u.current.add(T)}}).catch(()=>{}):Promise.resolve();Promise.allSettled([b,w]).then(()=>{x||s(p())})},qHt);return()=>{x=!0,clearTimeout(S)}},[d,t,c]);const m=$.useMemo(()=>HLt(r,o),[r,o]);return{spans:r,resolved:m}}const oie=""+new URL("brand-mark-Bv0Hu-Cz.png",import.meta.url).href,CHt={ink:"bg-ink","ink-muted":"bg-ink-muted"},zHt={maskImage:`linear-gradient(#000, #000), url(${oie})`,WebkitMaskImage:`linear-gradient(#000, #000), url(${oie})`,maskSize:"100% 100%, auto 50%",WebkitMaskSize:"100% 100%, auto 50%",maskRepeat:"no-repeat",WebkitMaskRepeat:"no-repeat",maskPosition:"center",WebkitMaskPosition:"center",maskComposite:"exclude",WebkitMaskComposite:"xor"},AHt=({className:e,tone:t="ink",label:n})=>f.jsx("span",{role:n?"img":void 0,"aria-label":n,"aria-hidden":n?void 0:!0,"data-brand-mark":"",className:E("inline-block shrink-0 rounded-full",CHt[t],e),style:zHt}),UHt=new Set(eve),OE=navigator.platform.toUpperCase().indexOf("MAC")>=0,sie="composer-credential-notice",lie="composer-secret-closure-notice",WHt="Answer the secret request in the asks panel — this box is paused until it is answered, and your draft is kept.",cie="composer-secret-ask-notice",YHt="composer-secret-ask-refusal",NHt="composer-secret-confirm",uie="composer-secret-confirm-message",Oie="composer-mention-outside-notice",die="composer-host-blocked-reason",fie="composer-delivery-remedies-hint",GHt={canUseRadientSpeech:!1,speechBlock:"could-not-check"},ZHt=1500;function _ke(e,t){return new Promise((n,r)=>{const i=setTimeout(()=>r(new Error("credential store timed out")),t);e.then(a=>{clearTimeout(i),n(a)},a=>{clearTimeout(i),r(a)})})}const IHt=$_e("sessions.credential"),hie=5e3;async function pie(e,t,n){try{const r=await _ke(je({op:"sessions.credential",sessionId:e,action:"store",key:t.key,value:t.value}),n);return r?.data?.ok===!1?{kind:"fate",fate:r.data.reason==="empty-key"?"rejected-key":"lost"}:{kind:"stored"}}catch(r){const i=r instanceof Nn?r.status:null;return i!==null&&i>=400&&i<500?{kind:"fate",fate:"lost"}:null}}async function DHt(e,t,n){try{const r=await _ke(je({op:"sessions.credential",sessionId:e,action:"list"}),n),i=r?.data;return i?.ok===!1||!Array.isArray(i?.credentials)?null:K9(r).includes(t)}catch{return null}}async function VHt(e,t){const n=await pie(e,t,IHt);if(n?.kind==="stored")return n;const r=n===null;let i=n;if(i===null&&(i=await pie(e,t,hie)),i?.kind==="stored")return i;const a=await DHt(e,t.key,hie);return a===!0?{kind:"stored"}:a===!1&&i!==null&&!r?i:null}const mie=[],gie=[],MHt=e=>new Promise(t=>{const n=new FileReader;n.onload=r=>t(typeof r.target?.result=="string"?r.target.result:null),n.onerror=()=>t(null),n.readAsDataURL(e)}),LHt=()=>document.querySelector('[aria-label="Answer options"] button:not([disabled])'),FHt=()=>document.querySelector(hoe),BHt='[aria-label="Remove reply"]';let gC=!1;const Lnn=()=>GEe(FHt(),document.activeElement,gC),HHt=E("mx-auto flex w-full flex-col bg-elevated","box-border transition-colors duration-fast ease-out-quart"),KHt=E("has-[textarea:focus-visible]:outline-solid has-[textarea:focus-visible]:outline-2","has-[textarea:focus-visible]:outline-accent has-[textarea:focus-visible]:outline-offset-2"),JHt=$.forwardRef(({onSendMessage:e,isLoading:t,awaitingReply:n=!1,awaitingAnswer:r=!1,deliveryRemediesReachable:i=!1,deviceHold:a,hostNotice:o,secretAnswer:s=!1,secretAsk:l=null,asideSessionId:c,asideStreaming:u=!1,asideAdoptQueue:O=!1,conversationId:d,messages:h,currentJobId:p,onCancelJob:m,onComposerInput:g,isFarFromBottom:y=!1,hasNewActivity:v=!1,scrollToBottom:x=()=>{},canonicalStop:S,canonicalStopAvailable:b=!1,interruptNotice:w,sendError:Q,stopConfirmation:P,initialSuggestions:T,noProvider:_=!1,noModel:R=!1,agentData:q,cwd:A,cwdWritePath:C,cwdReadOnlyReason:N,cwdPending:I,cwdPendingAccepted:W,isSmallView:G=!1,askExpanded:D,onAskToggle:j,askOutcomes:V,ownGutter:J=!1,isHydrating:U=!1,transcriptless:te=!1,autoFocus:L=!0,unavailable:B=!1,mentionsEnabled:Oe=!1,mentionsUnsupported:F=!1,sessionStatus:H,onSlashCommand:ne,onSlashNote:oe,paneHasSession:ie,runDetails:we,recordingProbe:ye=GHt,onCredentialsStored:Re,onDictationStateChange:ze,placeholderOverride:Ge},qe)=>{ut();const Ve=A??(C?.kind==="move"?void 0:q?.current_working_directory),lt=ur(M=>c?M.attached[c]??null:null),Ot=$.useRef(null);$.useEffect(()=>{if(O||!u||Ot.current===null)return;Ot.current=null;const M=ur.getState(),de=c??"";M.attached[de]?.notice===tY(OE)&&M.setAsideNotice(de,null)},[u,c,O]);const dt=Yn(M=>M.removeReply),fe=Yn(M=>M.addAttachment),$e=Yn(M=>M.removeAttachment),ke=Yn($.useCallback(M=>d?M.inputByConversation[d]?.replies??mie:mie,[d])),ce=Yn($.useCallback(M=>d?M.inputByConversation[d]?.attachments??gie:gie,[d])),me=$.useRef(Re);$.useEffect(()=>{me.current=Re});const[ve,Je]=$.useState(!1),[ct,bt]=$.useState(!1),[Dt,rn]=$.useState(null),[Ze,jt]=$.useState(!1),[St,an]=$.useState(!1);$.useEffect(()=>{if(!St)return;const M=window.setTimeout(()=>an(!1),5e3);return()=>window.clearTimeout(M)},[St]);const on=$.useRef(null),pr=$.useRef([]),[De,pt]=$.useState(""),Vt=$.useRef(0);$.useEffect(()=>{const M=Q?.message;Vt.current=M?Date.now():0},[Q?.message]);const{canUseRadientSpeech:Ai,speechBlock:Qt}=ye,Xn=Ai,mr=Zoe("recording",Qt),_r=!te&&h.length===0&&!U,na=_r,tr=$.useMemo(()=>{const M=H?.frontend?.effective_model??H?.frontend?.selected_model??null;return M?{provider:M.provider,model_id:M.model_id}:null},[H]),Tr=$.useRef(null),Ga=$.useMemo(()=>!T||T.length===0?[]:na?(Tr.current===null&&(Tr.current=zMt(T)),Tr.current):[],[T,na]),[yt,Rn]=$.useState(null),[gr,$r]=$.useState(null),[Gr,ra]=$.useState(null),[Zr,nr]=$.useState(null),[hf,pf]=$.useState(null),[Za,OP]=$.useState(Ta),ii=$.useRef(Ta),ts=$.useCallback(M=>{ii.current=M,OP(M),Ro(M)||nr(null)},[]),Bc=$.useCallback((M,de)=>Zr!==null&&Zr.buffer===M&&Zr.value===de.value,[Zr]),Ui=$.useRef(new Map),jl=$.useRef(1),[vO,mf]=$.useState(null),bO=$.useRef(null),Ir=$.useCallback(M=>{bO.current=M,mf(M)},[]),[$m,ov]=$.useState(null),sv=$.useRef(null),Cl=$.useCallback(M=>{sv.current=M,ov(M)},[]),gf=$.useCallback(M=>OL(bO.current,M)??0,[]),$f=$.useRef(null),qs=$.useRef(null),ns=$.useRef(null),ym=$.useRef(null),Hc=$.useRef(null),yf=$.useRef(!1),[lv,cv]=$.useState(0),dP=$.useRef([]),vf=$.useRef(void 0),yr=H&&!H.draft?d:void 0,Kc=$.useCallback(async(M,de=yr)=>{const _e=[...Ui.current.values()],Le=sL(M,_e);if(Le.length===0&&rve(M,_e).length===0)return{text:M,stored:[],refused:[],unconfirmed:[]};const Ht=new Map,tn=[],dn=await Promise.all(Le.map(async oi=>({payload:oi,attempt:de?await VHt(de,oi):{kind:"fate",fate:"unreachable"}})));for(const{payload:oi,attempt:Pi}of dn){if(Pi===null){Ht.set(oi.index,"unconfirmed");continue}if(Pi.kind==="stored"){tn.push(oi.key);continue}Ht.set(oi.index,Pi.fate)}tn.length>0&&de&&await me.current?.(de);const or=oi=>[...Ht.entries()].filter(([,Pi])=>oi(Pi)).map(([Pi])=>_e.find(Ys=>Ys.index===Pi)?.key??`#${Pi}`);return{text:b1t(M,_e,Ht),stored:tn,refused:or(oi=>oi!=="unconfirmed"),unconfirmed:or(oi=>oi==="unconfirmed")}},[yr]),vm=H?.draft===!0&&H?.draftResolved===!1,bf=$.useCallback(()=>{yf.current=!0,cv(M=>M+1),Ir(null),Hc.current=null},[Ir]),wf=$.useRef(!1),js=$.useRef(!1),xf=$.useCallback(()=>js.current?wf.current?"mixed":"dictated":"typed",[]),uv=$.useRef([]),{client:bm,provided:wm}=go(),fP=$.useMemo(()=>async(M,de)=>{if(vm)return H?.onOpenDraftPicker?.("session.model"),!1;if(ve||Ze)return!1;let _e;const Le=yr?await Kc(M):{text:M,stored:[],refused:[],unconfirmed:[]};Le.stored.length>0&&wd(lL(Le.stored)),Le.refused.length>0&&jm(cL(Le.refused)),Le.unconfirmed.length>0&&jm(uL(Le.unconfirmed));const Ht=uv.current,tn=wU(M,Ht);let dn=null;if(tn&&wm){const as=await kBt(bm,A??"",tn.name);as!==null&&y_e(as)?dn=as:oe?.(as!==null?`skill \`${tn.name}\` has an empty body — sending your message as written`:`could not load skill \`${tn.name}\` — sending your message as written`)}const or=as=>{if(tn!==null&&dn!==null){const QP=wU(as,Ht),nPe=QP&&QP.name===tn.name?QP.request:tn.request;return PP(P_e({...tn,request:nPe},dn),ke)}return PP(as,ke)},oi=yr?void 0:async as=>(_e=await Kc(M,as),or(_e.text)),Pi=or(Le.text),Ys=await e(Pi,ce.map(as=>as.path),de,M,oi,xf());return Ys!==!1&&(wf.current=!1,js.current=!1),Ys!==!1&&_e&&(_e.stored.length>0&&wd(lL(_e.stored)),_e.refused.length>0&&jm(cL(_e.refused)),_e.unconfirmed.length>0&&jm(uL(_e.unconfirmed))),Ys===!1?Ys:d6(Ys)?(Moe(Ys,bf),Ys):(bf(),Ys)},[e,ce,ke,bf,Kc,yr,vm,H?.onOpenDraftPicker,xf,ve,Ze,bm,wm,A,oe]),xm=Wr(M=>h6e(M.drafts,d)),{inputValue:xe,setInputValue:Un,handleKeyDown:wO,handleSubmit:Sf,textareaRef:Bt,sendInFlight:Sm,appendTranscriptText:rs}=M7e({conversationId:d,onSubmit:fP,scrollToBottom:x,draftHeld:Ro(Za),transcriptless:te,draftUnredacted:gf});$.useEffect(()=>{xe===""&&!Sm&&!xm&&(wf.current=!1,js.current=!1)},[xe,Sm,xm]);const Qm=OL(vO,xe),[On,ai]=$.useState(0),[Qf,km]=$.useState(!1),Ov=ABt(d),Cs=ie??!1,Ke=SHt({inputValue:xe,selectionStart:On,sessionId:Ov,paneHasSession:Cs,activeProfile:{team:H?.frontend?.active_team,agent:H?.frontend?.active_agent},activeModel:Tx(H?.frontend?.effective_model??H?.frontend?.selected_model),activeSpec:H?.frontend?.effective_model??H?.frontend?.selected_model,cwd:A}),dv=na&&!(Ke.open&&Ke.phase==="argument"),$i=QBt({text:xe,caret:On,cwd:A,attached:Cs,commandNames:Ke.commandNames,argumentWords:Ke.argumentWords,enabled:!Ro(Za)});$.useEffect(()=>{uv.current=$i.vocabulary.map(M=>M.name)},[$i.vocabulary]);const ya=CFt({text:xe,caret:On,cwd:A,enabled:Oe,unsupported:F}),zs=jHt({text:xe,cwd:A,enabled:Oe}),zl=$.useMemo(()=>[...zs.resolved.values()].filter(M=>M.outside).length,[zs.resolved]),vr=$.useRef(null),Jc=$.useRef(null),va=$.useRef(null);$.useLayoutEffect(()=>{d!==void 0&&va.current!==d&&xe&&(va.current=d,vr.current=xe.length,ai(xe.length))},[xe,d]);const Pm=$.useRef(xe);$.useLayoutEffect(()=>{Pm.current=xe;const M=Bt.current,de=vr.current;!M||de===null||(vr.current=null,M.setSelectionRange(de,de))},[xe,Bt,Ir]);const kf=$.useCallback(()=>[...dP.current,...[...Ui.current.values()].map(M=>M.key)],[]),eu=$.useCallback((M,de)=>{d&&(Ro(M)||Yn.getState().setCurrentInput(d,de,gf(de)))},[d,gf]),Wi=$.useCallback(M=>{const de=M.payload??null;de&&(Ui.current.set(de.index,de),jl.current=Math.max(jl.current,de.index+1)),M.buffer!==Pm.current&&(vr.current=M.caret,ai(M.caret)),$f.current=M.buffer,ns.current!==null&&!M.buffer.includes(ns.current.trim())&&(ns.current=null),qs.current!==null&&!M.buffer.includes(qs.current.text.trim())&&(qs.current=null),ts(M.capture),Un(M.buffer),eu(M.capture,M.buffer)},[eu,ts,Un]);$.useLayoutEffect(()=>{$f.current!==xe&&($f.current=xe,o1t(ii.current)&&(ts(Ta),Ir(null)))},[xe,ts,Ir]),$.useEffect(()=>{ii.current=Ta,ts(Ta),Ui.current.clear(),jl.current=1,yf.current=!1,qs.current=null,ns.current=null,Hc.current=null,Ir(null),nr(null),pf(null)},[d,ts,Ir]);const _m=Yn(M=>d?M.getUnredactedChars(d):0),xO=Yn(M=>d?M.getCurrentInput(d):"");$.useEffect(()=>{_m<=0||!xO||xe!==xO||bO.current?.over!==xO&&Ir({chars:_m,over:xO})},[_m,xO,xe,Ir]),$.useLayoutEffect(()=>{const M=bO.current;M&&M.over!==xe&&Ir(null)},[xe,Ir]),$.useLayoutEffect(()=>{const M=sv.current;M&&M.over!==xe&&Cl(null)},[xe,Cl]),$.useEffect(()=>{yf.current&&(sL(xe,Ui.current.values()).length>0||(Ui.current.clear(),jl.current=1,yf.current=!1))},[xe,lv]),$.useEffect(()=>{Za.arm===null||!yr||vf.current!==yr&&(vf.current=yr,je({op:"sessions.credential",sessionId:yr,action:"list"}).then(M=>{dP.current=K9(M)}).catch(()=>{}))},[Za.arm,yr]);const Tm=$.useCallback(()=>{const M=ii.current;if(!Ro(M))return!1;const de=c1t({capture:M,buffer:xe,caret:Bt.current?.selectionEnd??xe.length,index:jl.current,taken:kf()});return de.minted?(Wi(de),Ir(null),!0):!1},[Wi,xe,kf,Ir]),se=$.useCallback(M=>{const de=ii.current;if(!Ro(de))return!1;const _e=M.currentTarget,Le={start:_e.selectionStart??xe.length,end:_e.selectionEnd??xe.length};if(M.key==="Enter"&&!M.shiftKey&&!M.nativeEvent.isComposing)return Tm();if(M.key==="Escape"){if(u1t(de)&&!Bc(xe,de))return nr({buffer:xe,value:de.value}),!0;const tn=de.value!=="",dn=O1t(de,xe);return dn.cancelled?(qs.current=dn.token,Ir(null),tn&&pf(dn.buffer),Wi(dn),!0):!1}return M.key==="Enter"?(Wi(oL(de,xe,Le,`
947
947
  `)),!0):M.key==="Tab"?!0:Array.from(M.key).length===1&&!M.ctrlKey&&!M.metaKey&&!M.altKey&&!M.nativeEvent.isComposing?(Wi(oL(de,xe,Le,M.key)),!0):!1},[xe,Wi,Tm,Ir,Bc]),le=$.useCallback((M,de,_e="typed")=>$Ht({gesture:_e,draft:M,caret:de,commandNames:Ke.commandNames,promptCommands:Ke.promptCommands,armedOnlyCommands:Ke.armedOnlyCommands,valueArgumentCommands:Ke.valueArgumentCommands,argumentCommands:Ke.argumentCommands,argumentShapes:Ke.argumentShapes,prefixingCommands:Ke.prefixingCommands,commandLockedWords:UHt,unmaskedRunWord:ft(M)?ym.current?.word:void 0,nameListCommands:Ke.nameListCommands,enabled:Ke.available&&!!ne}),[Ke.commandNames,Ke.promptCommands,Ke.armedOnlyCommands,Ke.valueArgumentCommands,Ke.argumentCommands,Ke.argumentShapes,Ke.prefixingCommands,Ke.nameListCommands,Ke.available,ne]),We=$.useCallback((M,de,_e)=>{vr.current=de,Un(M),ai(de),oe?.(_e)},[oe,Un]),Me=$.useCallback(M=>{const de=qs.current;if(de!==null&&de.text.trim().length>0&&M.includes(de.text.trim()))return de.text.trim();const _e=ns.current;return _e!==null&&_e.trim().length>0&&M.includes(_e.trim())?_e.trim():null},[]),rt=$.useCallback(M=>d1t(M,qs.current)?"send":Me(M)===null?"typed":"pick",[Me]),ft=$.useCallback(M=>{const de=ym.current;return de!==null&&n1t(M,de.run)},[]),Wn=$.useCallback((M,de)=>{const _e=rt(M);if(_e==="send")return{kind:"send"};const Le=_e==="pick"?le(M,de,"pick"):le(M,de);if(_e!=="pick"||Le.kind!=="send")return Le;const Ht=Me(M);if(Ht===null)return Le;const tn=M.indexOf(Ht);return tn<0?Le:le(M,tn+Ht.length,"pick")},[rt,le,Me]),sn=$.useMemo(()=>{if(Qf)return[];const M=YFt({draft:xe,commandNames:Ke.commandNames,nameListCommands:Ke.nameListCommands,nameChoices:Ke.nameChoices,picking:Ke.open&&Ke.matches.length>0});if(M.length===0)return M;const de=le(xe,On,"typed");return NFt(M,xe,{sendsAsWritten:de.kind==="send"})},[xe,On,Qf,le,Ke.commandNames,Ke.nameListCommands,Ke.nameChoices,Ke.open,Ke.matches.length]),br=$.useMemo(()=>Qf?[]:dBt({draft:xe,vocabulary:$i.vocabulary,settled:$i.settled,picking:$i.open}),[xe,Qf,$i.vocabulary,$i.settled,$i.open]),Mt=$.useMemo(()=>[...sn,...br],[sn,br]),Xr=Oke(Mt),Dr=$.useCallback(async(M,de,_e)=>{const Le=ne;if(!Le)return;if(M.kind==="whole"||M.kind==="splice"){const tn=Ke.commands.find(or=>or.name===M.command.name||or.aliases.includes(M.command.name)),dn=vn(M.command.args??"");if(tn?.destination==="session.model"&&dn){const or=i1e(Ke.argumentList.rows,dn);if(or){Nu.getState().openConnect({providerId:or});return}}if(tn?.destination==="session.tags"){if(!vn(M.command.args??"")){const or=M.kind==="splice"?M.start:0,oi=M.kind==="splice"?M.end:de.length,Pi=sc(de,or,oi,`/${tn.name} `);vr.current=Pi.caret,Un(Pi.text),ai(Pi.caret)}Ke.reopen();return}}if(M.kind==="list-open"){if(Ke.open&&Ke.matches.length>0)return;oe?.(`Type a name after /${M.command.name}, or choose one from the list.`);return}if(M.kind==="unrecognised"){await Le(M.command),vr.current=_e,Un(de),ai(_e);return}if(M.kind==="reassemble"){We(M.text,M.caret,KBt(M.text.trim(),Cs));return}if(await Le(M.command)==="consumed"){const tn=M.kind==="whole"?"":M.text,dn=M.kind==="whole"?0:M.caret;if(vr.current=dn,Un(tn),ai(dn),M.locked===!0){const or=G1t(de,ii.current),Pi=!(M.kind==="whole"?or:or.slice(M.start,M.end)).includes(Jye);Hc.current=Pi?{text:or,caret:_e,plain:fp(M.command.args).length}:null,oe?.(JBt(M.command.name,{dialog:Cs&&Ke.commandNames.has(M.command.name),undo:Pi},OE))}return}vr.current=_e,Un(de),ai(_e)},[ne,oe,Un,Ke.commandNames,Ke.open,Ke.matches.length,Ke.commands,Ke.argumentList.rows,Ke.reopen,We,Cs]),xn=!!(t&&p),Vr=!!s,et=B||xn||Vr||!!o?.blocksInput,[Bn,As]=$.useState(null),[Rr,Pf]=$.useState(null),[Ia,W8]=$.useState(!1),Y8=$.useRef(null),fv=$.useRef(null),N8=$.useRef(xe);$.useEffect(()=>{N8.current=xe},[xe]),$.useEffect(()=>{As(null),Pf(null)},[d]),$.useEffect(()=>{Bn!==null&&Y8.current?.focus()},[Bn]),$.useEffect(()=>{if(!Ia)return;const M=document.activeElement;M!==null&&M!==document.body&&!fv.current?.contains(M)||fv.current?.focus()},[Ia]),$.useEffect(()=>{if(Bn===null||l!==null&&l.key===Bn.key)return;As(null),Pf(l===null?Y("ui.chat.composer.secret_fill_gone"):Y("ui.chat.composer.secret_fill_changed"));const M=document.activeElement;M!==null&&M!==document.body&&M!==Bt.current&&!fv.current?.contains(M)||Bt.current?.focus()},[l,Bn,Bt]),$.useEffect(()=>{Pf(null)},[xe]),$.useEffect(()=>{Bn!==null&&xe.trim()!==Bn.value&&As(null)},[xe,Bn]);const hv=$.useCallback(M=>!l||!hwt(M)?!1:(As({value:M.trim(),key:l.key}),!0),[l]),pv=$.useCallback(()=>{As(null),Pf(null),Bt.current?.focus()},[Bt]),G8=$.useCallback(M=>{switch(M){case"locked":return Y("ui.chat.composer.secret_fill_locked");case"stale":return Y("ui.chat.composer.secret_fill_changed");case"multi":return Y("ui.chat.composer.secret_fill_multi");case"refused":return Y("ui.chat.composer.secret_fill_refused");case"unavailable":return Y("ui.chat.composer.secret_fill_unavailable")}},[]),Xke=$.useCallback(async()=>{if(Bn===null||l===null||Ia)return;if(!l.fillable){As(null),Pf(Y("ui.chat.composer.secret_fill_multi")),l.onOpen({focus:!1}),Bt.current?.focus();return}W8(!0);let M;try{M=await l.onFill(Bn.value,Bn.key)}catch{M="unavailable"}finally{W8(!1)}if(As(null),M==="sent"){N8.current.trim()===Bn.value&&Un(""),Bt.current?.focus();return}Pf(G8(M)),M!=="unavailable"&&l.onOpen({focus:!1}),Bt.current?.focus()},[l,Bn,Ia,G8,Un,Bt]),Rke=$.useCallback(()=>{As(null),Sf(),Bt.current?.focus()},[Sf,Bt]),Xm=_||R,mv=$.useCallback(()=>{an(!0)},[]),hP=$.useCallback(async M=>{const de=Tx(M.model);if(!(et||!k1e(M)||M.id!=="model-default"||!de)){Ke.close();try{await Q1e(de,(_e,Le)=>je({op:"settings.edit",key:_e,value:Le})),Un(""),oe?.(`Default for new sessions: ${de.provider}/${de.model_id}`)}catch(_e){oe?.(`The default was not saved: ${_e instanceof Error?_e.message:"the backend refused it"}`)}}},[et,Ke.close,Un,oe]),pP=$.useCallback(async(M,de)=>{if(M.kind==="action"){de.run&&await hP(M.row);return}if(et)return;if(M.kind==="argument"&&Ke.inline?.source==="session-tags"&&de.run){await Ke.actOnTagRow(M.row);return}const _e=RHt(xe,On,M,Ke.commandNames,Ke.argumentWords,Ke.inline?.nameThenMessage??!1);if(!_e)return;if(Ke.close(),de.run&&M.kind==="argument"&&!Cs&&ne){const dn=xMt(Ke.inline?.source);if(dn){const or=Y0(xe,On,Ke.commandNames),oi=or?vn(sc(xe,or.start,or.end,"").text):"";Wr.getState().restageDraft({kind:dn,name:M.row.value},oi);return}}hh.lastIndex=0;const Le=hh.exec(_e.text);if(ns.current=Le?Le[0].trim():null,M.kind==="command"&&de.run&&mC(M,Ke.armedOnlyCommands)){const dn=yHt({draft:_e.text,caret:_e.caret,commandNames:Ke.commandNames,armedOnlyCommands:Ke.armedOnlyCommands});if(dn.kind==="armed"){We(dn.text,dn.caret,HBt(dn.text.trim(),M.command.destination,IQe(M.command.destination)?Cs:!0));return}}if(Wi({capture:ph(ii.current,_e.text,_e.caret,"completion"),buffer:_e.text,caret:_e.caret}),!(de.run&&(M.kind==="command"?vke(M.command.destination,Ke.effectiveEntry(M.command.destination)):Ke.inline?.runs??!1)&&!!ne))return;const tn=le(_e.text,_e.caret,"pick");tn.kind!=="send"&&await Dr(tn,xe,On)},[xe,On,Ke,Wi,ne,le,Dr,We,Cs,et,hP]),Z8=$.useCallback(M=>{const de=UBt(xe,On,M,Ke.commandNames);de&&(vr.current=de.caret,Un(de.text),ai(de.caret))},[xe,On,Ke.commandNames,Un]),I8=$.useCallback(M=>{if(et)return;const de=oke(xe,On);if(!de)return;const _e=oFt(M),Le=xe.slice(de.end,de.end+1),Ht=de.start>0&&(Le===" "||Le===`
948
- `)?1:0,tn=sc(xe,de.start,de.end+Ht,_e),dn=_e.endsWith('"')?tn.caret-1:tn.caret;vr.current=dn,Un(tn.text),ai(dn),ya.remember(M.path),ya.close()},[xe,On,ya,Un,et]),mP=$.useCallback(M=>{if(et||!$i.token)return;const de=oBt(xe,$i.token,M.name);$i.close(),vr.current=de.caret,Un(de.text),ai(de.caret)},[xe,$i,Un,et]),Eke=$.useCallback(M=>{const de=Hc.current;return de===null||!(M.metaKey||M.ctrlKey)||M.altKey||M.shiftKey||M.key.toLowerCase()!=="z"?!1:(Hc.current=null,vr.current=de.caret,de.plain>0&&Ir({chars:de.plain,over:de.text}),Un(de.text),ai(de.caret),!0)},[Ir,Un]),qke=$.useCallback(M=>{if(et)return;if(se(M)){M.preventDefault();return}if(M.key==="Escape"&&Bn!==null){if(M.preventDefault(),Ia)return;pv();return}if(Cke(M)){M.preventDefault();return}if(Eke(M)){M.preventDefault();return}if(zFt(M,ya,I8)){M.preventDefault();return}if(XHt(M,Ke,pP,Z8)){M.preventDefault();return}if(_Bt(M,$i,mP)){M.preventDefault();return}if(lt!==null&&M.key==="Escape"){M.preventDefault(),GE(c??"");return}if(lt!==null&&ZCe(M)){const Le=lt.turns.at(-1),Ht=Le?ur.getState().streams[Le.asideId]:void 0;if(!Le||lt.queued!==void 0||!cse(Ht,u,O))return;M.preventDefault();const tn=c??"",dn=Date.now(),or=DCe(Ot.current,Le.asideId,dn);if(or==="arm"){Ot.current={turnId:Le.asideId,at:dn},ur.getState().setAsideNotice(tn,tY(OE));return}if(or==="ignore")return;Ot.current=null,sse(tn).catch(()=>{});return}if(M.key==="Backspace"||M.key==="Delete"){const Le=BLt(On,M.key==="Backspace"?"back":"forward",zs.spans,zs.resolved);if(Le&&!M.nativeEvent.isComposing){const Ht=sc(xe,Le.start,Le.end,"");vr.current=Ht.caret,ai(Ht.caret),Un(Ht.text),M.preventDefault();return}}const de=Bt.current,_e=LHt();if(_e&&NEe(M,{value:xe,selectionStart:de?.selectionStart??null,selectionEnd:de?.selectionEnd??null})){_e.focus(),M.preventDefault();return}if(Xm&&M.key==="Enter"&&!M.shiftKey&&!M.nativeEvent.isComposing){M.preventDefault(),mv();return}if(M.key==="Enter"&&!M.shiftKey&&!M.nativeEvent.isComposing){const Le=Wn(xe,On);if(Le.kind!=="send"){M.preventDefault(),Dr(Le,xe,On);return}if(hv(xe)){M.preventDefault();return}}wO(M)},[Ke,pP,Z8,$i,mP,hv,wO,se,Bn,pv,Wn,Dr,xe,On,et,lt,c,u,O]),D8=$.useRef(null),Us=$.useCallback(M=>{gC=!1,Bt.current?.focus({preventScroll:M?.preventScroll===!0})},[Bt]),jke=$.useCallback(()=>{Iae(xe)!==null&&Un("")},[xe,Un]);$.useImperativeHandle(qe,()=>({focusInput:Us,openWorkingDirectoryMenu:()=>{D8.current?.openMenu()},submitNow:()=>{hv(xe)||Sf()},consumeApprovalAnswerDraft:jke}));const V8=$.useCallback(()=>Bt.current,[Bt]);$.useEffect(()=>u3e(Us,V8),[Us,V8]);const Ws=$.useRef(null),M8=$.useRef(xe);$.useLayoutEffect(()=>{M8.current=xe},[xe]);const L8=$.useCallback(M=>{Ws.current===M&&(Ws.current=null,Ui.current.delete(M.index))},[]),gv=$.useCallback(M=>{if(Ws.current!==M)return!1;const de=X1t({buffer:M8.current,cleared:M.cleared});return de?(Ui.current.set(M.index,M.payload),Ws.current===M&&(Ws.current=null),M.toastId!==null&&e0(M.toastId),Wi({capture:ph(ii.current,de.buffer,de.caret,"arrival"),buffer:de.buffer,caret:de.caret}),Cl(null),!0):!1},[Wi,Cl]);$.useLayoutEffect(()=>{const M=Ws.current;M!==null&&M.cleared.buffer!==xe&&(M.toastId!==null&&e0(M.toastId),L8(M))},[xe,L8]);const Cke=$.useCallback(M=>{const de=Ws.current;return de===null||!(M.metaKey||M.ctrlKey)||M.altKey||M.shiftKey||M.key.toLowerCase()!=="z"?!1:(gv(de),!0)},[gv]),F8=$.useCallback(M=>{gv(M)&&Us()},[Us,gv]),zke=$.useCallback(M=>{if(et)return;const de=Ui.current.get(M);if(!de)return;const _e=T1t({buffer:xe,payload:de});if(!_e.cleared)return;const Le=Ws.current;Le&&(Ws.current=null,Ui.current.delete(Le.index),Le.toastId!==null&&e0(Le.toastId));const Ht={index:M,payload:de,cleared:_e,toastId:null};Ws.current=Ht,Wi({capture:ph(ii.current,_e.buffer,_e.caret,"arrival"),buffer:_e.buffer,caret:_e.caret}),Cl({key:de.key,index:M,over:_e.buffer}),Ht.toastId=jm(P1t(M),{action:{label:k1t,onClick:()=>F8(Ht)}}),Us()},[Wi,Us,et,xe,Cl,F8]),Ake=nMt(!!S?.active),B8=b&&!S?.active&&(Ake.held||ve)&&!(t&&p),Uke=!!S?.active||B8,Wke=et||ve||Ze||xe.trim().length>0;$.useEffect(()=>{const M=Bt.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[xe,Bt,ve,Ze]);const H8=$.useRef(!1);$.useEffect(()=>{const M=ve||Ze,de=H8.current&&!M;if(H8.current=M,!L&&!de||et||M)return;const _e=document.activeElement;!(_e&&(_e.tagName==="INPUT"||_e.tagName==="TEXTAREA"))&&!_&&Bt.current?.focus({preventScroll:!0})},[L,et,ve,Ze,Bt,_]),$.useEffect(()=>{window.electron.ipcRenderer.invoke("get-platform-info").then(M=>{pt(M.platform)}).catch(M=>{console.error("Failed to get platform info:",M)})},[]);const is=$.useRef(null),Yke=250,K8=$.useRef(ze);$.useEffect(()=>{K8.current=ze}),$.useEffect(()=>(Cre("message-input",ve||ct),()=>Cre("message-input",!1)),[ve,ct]),$.useEffect(()=>{K8.current?.(ve)},[ve]);const tu=$.useCallback(M=>{bt(!1);const de=on.current;if(!de)return;const _e=is.current?.startedAt??null,Le=_e===null?Number.POSITIVE_INFINITY:performance.now()-_e;if(is.current=null,de.state==="inactive"){Je(!1);return}(M==="abort"||Le<Yke)&&(de.onstop=()=>{if(de.stream)for(const Ht of de.stream.getTracks())Ht.stop();rn(null),pr.current=[]}),de.stop(),Je(!1)},[]);$.useEffect(()=>()=>{const M=is.current!==null;is.current=null;const de=on.current;if(de&&de.state!=="inactive"){tu("abort");return}M&&bt(!1)},[tu]);const gP=$.useCallback((M="release")=>{const de=is.current;if(de){if(de.startedAt===null){is.current=null,bt(!1);return}tu(M)}},[tu]),J8=$.useCallback(async()=>{if(!(et||!Xn)&&!is.current)if(navigator?.mediaDevices?.getUserMedia){const M={startedAt:null};is.current=M,bt(!0);try{const de=await navigator.mediaDevices.getUserMedia({audio:!0});if(is.current!==M){for(const _e of de.getTracks())_e.stop();return}on.current=new MediaRecorder(de),pr.current=[],on.current.ondataavailable=_e=>{pr.current.push(_e.data)},on.current.onstop=()=>{const _e=new Blob(pr.current,{type:"audio/webm"});rn(_e);for(const Le of de.getTracks())Le.stop()},on.current.start(),M.startedAt=performance.now(),bt(!1),Je(!0),rn(null)}catch(de){if(is.current!==M)return;is.current=null,bt(!1),console.error("Error accessing microphone:",de),Kr("Error accessing microphone. Please ensure microphone permissions are granted.")}}else console.error("This runtime exposes no MediaRecorder"),Kr("Dictation is not available on this device.")},[Xn,et]),$P=$.useCallback(()=>{ve&&tu("release")},[ve,tu]),yP=$.useCallback(()=>{ve&&tu("abort")},[ve,tu]);$.useEffect(()=>{if(!ve&&!ct)return;const M=de=>{if(ve){de.key==="Enter"?(de.preventDefault(),$P()):de.key==="Escape"&&(de.preventDefault(),yP());return}de.key==="Escape"&&(de.preventDefault(),gP("abort"),bt(!1))};return window.addEventListener("keydown",M),()=>{window.removeEventListener("keydown",M)}},[ve,ct,$P,yP,gP]);const eU=$.useCallback(async()=>{if(Dt)try{jt(!0);const M=await Aae.createTranscription(Vd.baseUrl,{file:new File([Dt],"recording.webm",{type:"audio/webm"})});if(M.result?.text){const de=M.result?.text||"";js.current=!0,rs(de)}else Uu(mEe);rn(null)}catch(M){console.error("Error transcribing audio:",M),Kr(M4e(M))}finally{jt(!1)}},[Dt,rs]);$.useEffect(()=>{Dt&&eU()},[Dt,eU]);const tU=$.useRef(!0);$.useEffect(()=>{if(typeof IntersectionObserver>"u")return;const M=Bt.current;if(M===null)return;const de=new IntersectionObserver(_e=>{const Le=_e[_e.length-1];Le!==void 0&&(tU.current=Le.isIntersecting)});return de.observe(M),()=>de.disconnect()},[Bt]),EMt("message-input",DQe.MESSAGE_INPUT,{start:J8,stop:gP},()=>!!(!et&&!ve&&!Ze&&Xn&&tU.current));const Nke=M=>{if(M.preventDefault(),et||_)return;if(R){mv();return}if(!xe.trim()&&ce.length===0||Tm())return;const de=Wn(xe,On);if(de.kind!=="send"){Dr(de,xe,On);return}hv(xe)||Sf()},vP=$.useCallback(M=>{et&&M.preventDefault()},[et]),Gke=$.useCallback(M=>{!et&&!Xm||(M.preventDefault(),Xm&&!et&&mv())},[et,Xm,mv]),Zke=M=>{d&&$e(d,M)},Ike=async()=>{const M=await window.electron.ipcRenderer.invoke("show-open-dialog",{properties:["openFile","multiSelections"]});if(!M.canceled&&M.filePaths.length>0&&d)for(const de of M.filePaths)fe(d,{id:Xa(),path:xU(de)})},Dke=M=>{if(et)return;const de=M.clipboardData?.getData("text/plain")??"";if(de&&ii.current.arm!==null){const Le=M.currentTarget,Ht=h1t({capture:ii.current,buffer:xe,caret:Le.selectionEnd??xe.length,selection:{start:Le.selectionStart??xe.length,end:Le.selectionEnd??xe.length},pasted:de,index:jl.current,taken:kf()});if(Ht){M.preventDefault(),Wi(Ht),Ir(null);return}}de&&(ym.current=r1t(de));const _e=M.clipboardData?.items;if(_e){for(let Le=0;Le<_e.length;Le++)if(_e[Le].type.indexOf("image")!==-1||_e[Le].kind==="file"){const Ht=_e[Le].getAsFile();if(Ht){const tn=new FileReader;tn.onload=dn=>{dn.target?.result&&d&&fe(d,{id:Xa(),path:dn.target.result})},tn.readAsDataURL(Ht)}}}},Vke=M=>{et||M.dataTransfer?.types.includes("Files")&&(M.preventDefault(),M.stopPropagation(),M.dataTransfer.dropEffect="copy",bP(!0))},Mke=M=>{M.currentTarget.contains(M.relatedTarget)||bP(!1)},Lke=M=>{if(bP(!1),et)return;const de=M.dataTransfer?.files;!de||de.length===0||(M.preventDefault(),M.stopPropagation(),d&&Fke(d,Array.from(de)))},Fke=async(M,de)=>{for(const _e of de){const Le=window.api?.getPathForFile?window.api.getPathForFile(_e):"";if(Le){fe(M,{id:Xa(),path:xU(Le)});continue}const Ht=await MHt(_e);Ht&&fe(M,{id:Xa(),path:Ht})}},[nU,bP]=$.useState(!1),Bke=M=>{et||(xe||g?.(),vr.current=M.length,Un(M),ai(M.length),Bt.current?.focus())},wP=Ro(Za)?Za.value!==""?Bc(xe,Za)?U1t:z1t:yr?A1t:Y1t:hf!==null&&hf===xe?W1t:_1t({unredacted:Qm!==null?N1t(Qm):null,armed:Za.arm!==null&&ave(xe,xe.length)!==null,cleared:$m===null?null:{key:$m.key,index:$m.index},undoCap:Ske(De==="darwin")}),Hke=$.useMemo(()=>De==="darwin"?"Cmd+Shift+S":"Ctrl+Shift+S",[De]),xP=$.useRef(null),Kke=M=>{d&&(xP.current=ke.findIndex(de=>de.id===M),dt(d,M))};$.useEffect(()=>{const M=xP.current;if(M===null)return;xP.current=null;const de=document.querySelectorAll(BHt),_e=de[Math.min(M,de.length-1)];_e?_e.focus():Us()},[ke,Us]);const yo=$.useMemo(()=>{const de=PP(xe,ke)!==""||ce.length>0,_e=_||Q?.message&&ale.test(Q.message)?[{label:"Connect a provider",onClick:()=>Nu.getState().openConnect()}]:[];return{message:Q?.message,muted:Q?.muted===!0,polite:Q?.polite===!0,actions:[...Q?.actions??[],..._e],retry:Q?.retry===!0,clear:Q?.muted!==!0&&(Q?.onClear!==void 0||de)}},[Q,xe,ke,ce,_]),_f=iTt(),rU=E("block text-body-sm",G?"px-2 pb-1":"px-4 pb-2",Qm!==null?"text-warning":"text-ink-muted"),SP=E("flex flex-wrap items-center gap-2 text-body-sm text-ink-muted",G?"px-2 pb-1":"px-4 pb-2"),iU=Vr&&xe.length>0,Jke=f.jsx("output",{className:E(lr,"block pb-2",_f.issue.kind==="hidden"&&"hidden"),children:f.jsx(rBt,{issue:_f.issue,onSignIn:_f.start,onCancel:_f.cancel,onDismiss:_f.dismiss,isSmallView:G,onFocusComposer:()=>Bt.current?.focus()})}),Rm=v_e(H),ePe=Rm&&!b_e(Rm,w_e(_f.issue))?f.jsx("output",{className:E(lr,"block pb-2"),children:f.jsx(SMt,{access:Rm,isSmallView:G,onSwitchModel:H?.onCommand?()=>H.onCommand?.({name:"model",args:""}):void 0,onConnect:()=>Nu.getState().openConnect({providerId:Rm.provider})})}):null,aU=ct||!ve&&!Ze&&!(t&&p),tPe=f.jsxs("form",{onSubmit:Nke,"data-chat-region":"composer","aria-label":Wae.composer,tabIndex:-1,className:"w-full",children:[f.jsx(_U,{fallback:null,children:f.jsx(JVt,{frontend:H?.frontend,askFrontend:H?.asks,runDetails:we,isSmallView:G,askExpanded:D,onAskToggle:j,askOutcomes:V,onNote:oe,onFocusComposer:()=>Bt.current?.focus()},d)}),!x_e(Rm)&&Jke,ePe,a,o?.blocksInput&&o.placeholder&&!o.statedByNode&&xe.trim().length>0?f.jsx("p",{id:die,className:"mb-2 text-meta text-ink-muted",children:o.placeholder}):null,o?.node,yo.message!==void 0&&f.jsxs("div",{role:yo.polite?"status":"alert","data-composer-notice":!0,"data-composer-queued":Q?.message===k_e.queuedSend?!0:void 0,className:E(lr,"flex flex-wrap items-center gap-x-3 gap-y-1 text-body-sm",G?"px-2 pb-1":"px-4 pb-2"),children:[f.jsxs("p",{className:E("flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",yo.muted?"text-ink-muted":"text-danger"),children:[!yo.muted&&f.jsx("span",{className:"flex shrink-0 items-center pt-0.5",children:f.jsx(Nh,{size:14,"aria-hidden":"true"})}),f.jsx("span",{className:E("min-w-0 break-words",!yo.muted&&"font-medium"),children:yo.message})]}),(yo.retry||yo.clear||yo.actions.length>0)&&f.jsxs(f.Fragment,{children:[yo.actions.map(M=>f.jsx(Se,{type:"button",variant:"link",size:"sm",className:E("min-h-6 cursor-pointer text-body-sm underline"),onClick:M.onClick,children:M.label},M.label)),yo.retry&&Q?.onRetry&&f.jsx(Se,{type:"button",variant:"link",size:"sm",className:E("min-h-6 cursor-pointer font-semibold text-body-sm underline"),onClick:()=>Q.onRetry?.(),children:S_e}),yo.clear&&Q?.onClear&&f.jsx(Se,{type:"button",variant:"link",size:"sm","aria-label":Y("ui.chat.composer.clear_message"),className:E("min-h-6 cursor-pointer text-ink-dim text-body-sm underline"),onClick:()=>Q.onClear?.(),children:Q_e})]})]}),w&&f.jsx("output",{className:E(lr,"block text-body-sm text-ink-muted",G?"px-2 pb-1":"px-4 pb-2"),children:w}),c&&lt!==null&&f.jsx(zLt,{sessionId:c,sessionStreaming:u,adoptQueueSupported:O,isSmallView:G,onReturnFocus:()=>Bt.current?.focus()}),P?f.jsx("div",{className:E(lr,G?"px-2 pb-2":"px-4 pb-2"),children:P}):null,f.jsxs("div",{className:E(lr,"relative w-full"),children:[f.jsx(kHt,{state:Ke,onPick:pP,onActionPick:hP}),f.jsx(UFt,{state:ya,onPick:I8}),f.jsx(PBt,{state:$i,onPick:mP}),!te&&!Ke.open&&!ya.open&&!$i.open&&f.jsx(_2t,{visible:y,onClick:x,hasNewActivity:v}),f.jsx("output",{id:sie,className:E(lr,wP?rU:"hidden"),children:wP}),iU&&f.jsx("output",{id:lie,className:E(lr,rU),children:WHt}),l&&Bn===null&&f.jsxs("output",{id:cie,className:E(SP,lr),children:[f.jsx("span",{className:"min-w-0",children:Y("ui.chat.composer.secret_ask_notice")}),f.jsx(Se,{type:"button",size:"sm",variant:"secondary","data-lo-ask-item-toggle":"",onClick:()=>l.onOpen(),children:Y("ui.chat.composer.secret_ask_open")})]}),Rr!==null&&Bn===null&&f.jsx("output",{id:YHt,className:E(SP,lr),children:f.jsx("span",{className:"min-w-0",children:Rr})}),Bn!==null&&f.jsxs("fieldset",{ref:fv,tabIndex:-1,id:NHt,"aria-labelledby":uie,"aria-busy":Ia,onKeyDown:M=>{M.key==="Escape"&&(M.preventDefault(),!Ia&&pv())},className:E("m-0 min-w-0 border-0 p-0",SP,lr),children:[f.jsxs("span",{id:uie,className:"min-w-0",children:[Ia?Y("ui.chat.composer.secret_confirm_sending"):Y("ui.chat.composer.secret_confirm_message"),f.jsx("span",{className:E("whitespace-nowrap",Ia&&"invisible"),"aria-hidden":Ia||void 0,children:` ${Y("ui.chat.composer.secret_confirm_chars",{count:Bn.value.length})}`})]}),f.jsx(Se,{ref:Y8,type:"button",size:"sm",disabled:Ia,onClick:Xke,children:l?.fillable?Y("ui.chat.composer.secret_confirm_put"):Y("ui.chat.composer.secret_confirm_put_multi")}),f.jsx(Se,{type:"button",size:"sm",variant:"secondary",disabled:Ia,onClick:Rke,children:Y("ui.chat.composer.secret_confirm_send")}),f.jsx(Se,{type:"button",size:"sm",variant:"ghost",disabled:Ia,onClick:pv,children:Y("ui.chat.composer.secret_confirm_cancel")})]}),zl>0&&f.jsx("span",{id:Oie,className:"sr-only",children:zl===1?"1 reference points outside this session's working directory; the agent will ask you to approve it before reading.":`${zl} references point outside this session's working directory; the agent will ask you to approve them before reading.`}),i&&f.jsx("span",{id:fie,className:"sr-only",children:Y("ui.chat.composer.delivery_remedies_hint")}),f.jsxs("div",{"data-glass-region":"composer",className:E(HHt,nU?void 0:KHt,G?"gap-2 rounded-md p-2":"gap-3 rounded-frame p-4",lr,nU&&"outline-dashed outline-2 outline-accent outline-offset-2"),"data-lo-composer-measure":"","data-tour-tag":"chat-input-textarea",children:[(ke.length>0||ce.length>0)&&f.jsxs("div",{className:"max-h-[240px] shrink-0 overflow-y-auto",children:[ke.length>0&&f.jsx(aA,{replies:ke,onRemoveReply:Kke}),ce.length>0&&f.jsx(N6e,{attachments:ce.map(M=>M.path),onRemoveAttachment:M=>Zke(ce[M].id),disabled:et||ve||Ze})]}),f.jsxs("div",{className:"relative isolate w-full",children:[f.jsx(FMt,{text:xe,payloads:Ui.current,capture:Za,held:Bc(xe,Za),fieldRef:Bt,mirrorRef:Jc,isSmallView:G}),f.jsx(fFt,{text:xe,spans:zs.spans,resolved:zs.resolved,fieldRef:Bt,isSmallView:G}),f.jsx(DFt,{draft:xe,runs:Mt,textareaRef:Bt,fieldClassName:jS(G),refused:et,children:f.jsx("textarea",{ref:Bt,"data-region-entry":!0,className:E(jS(G),"block",G?"max-h-24":"max-h-28","resize-none overflow-y-auto bg-transparent",Xr?"text-transparent caret-ink":"text-ink","outline-none placeholder:text-ink-dim",o?.blocksInput?"read-only:text-ink-muted read-only:placeholder:text-ink-muted disabled:text-ink-disabled disabled:placeholder:text-ink-disabled":"read-only:text-ink-disabled read-only:placeholder:text-ink-disabled disabled:text-ink-disabled disabled:placeholder:text-ink-disabled"),placeholder:ve?Os.recording:N7e({unavailable:B,secretAnswer:Vr,inputDisabled:et,awaitingAnswer:r,asideAttached:lt!==null,sendingUnsettled:xm||Sm,awaitingReply:n,stopping:S?.stopping===!0,noProvider:_,idle:Ge,hostLine:o?.placeholder??null}),value:xe,onCompositionStart:()=>km(!0),onCompositionEnd:()=>km(!1),onChange:M=>{wf.current=!0;const de=M.target.value,_e=M.target.selectionStart??de.length;Hc.current=null;const Le=l1t(ii.current,xe,de,_e,"typing");Le.buffer!==de?(vr.current=Le.caret,ai(Le.caret)):ai(_e),Le.capture!==ii.current&&ts(Le.capture),!xe&&Le.buffer&&g?.(),$f.current=Le.buffer,eu(Le.capture,Le.buffer),Un(Le.buffer),Date.now()-Vt.current>=ZHt&&Q?.onDismiss?.()},onSelect:M=>{const de=M.target,_e=vr.current;if(_e!==null){de.selectionStart===_e&&(vr.current=null);return}ai(de.selectionStart),ts(ph(ii.current,xe,de.selectionStart,"caret"))},onKeyDown:qke,onPointerDown:()=>{gC=!0},onPaste:Dke,rows:1,readOnly:et,"aria-disabled":et||void 0,"aria-label":Y("ui.chat.composer.message"),role:"combobox","aria-describedby":[o?o.id:null,o?.blocksInput&&o.placeholder&&!o.statedByNode&&xe.trim().length>0?die:null,wP?sie:null,iU?lie:null,l&&Bn===null?cie:null,zl>0?Oie:null,B?Zve:null,i?fie:null].filter(Boolean).join(" ")||void 0,"aria-expanded":Ke.open||ya.open,"aria-controls":Ke.open?Ke.listId:ya.open?ya.listId:void 0,"aria-activedescendant":(Ke.open?Ke.activeDescendantId:ya.activeDescendantId)??void 0})}),f.jsx(VMt,{small:G,text:xe,payloads:Ui.current,capture:Za,mirrorRef:Jc,fieldRef:Bt,onClear:et?null:zke,onControlUnmounted:Us})]}),ve&&f.jsx(Gse,{isRecording:ve}),Ze&&f.jsxs("div",{"data-transcribing-indicator":"",className:"mt-1 flex items-center gap-2 px-2 [min-height:1.5rem]",children:[f.jsx("span",{className:"font-medium text-body-sm text-ink-muted",children:Y("ui.chat.composer.processing_audio")}),f.jsx(Pke,{})]}),f.jsxs("div",{className:"flex min-w-0 flex-nowrap items-center gap-x-2",children:[H&&f.jsx(_U,{fallback:null,children:f.jsx(j9e,{frontend:H.frontend,onCommand:H.onCommand,effortEntities:H.effortEntities,draft:H.draft,onOpenDraftPicker:H.onOpenDraftPicker,draftResolution:H.draftResolution,held:H.held,contextHeld:H.contextHeld,readingsDropped:H.readingsDropped,pendingModel:H.pendingModel,costChannels:H.costChannels,controlsThirdBox:Uke})}),f.jsxs("div",{className:"contents",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1 shrink-0",children:[f.jsx(wt,{content:Y("ui.chat.composer.attach_file"),children:f.jsx("span",{children:f.jsx(Se,{variant:"ghost",size:G?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:vP,onClick:Ike,"aria-label":Y("ui.chat.composer.attach_file"),"data-tour-tag":"chat-input-attach-file-button",disabled:et||ve||Ze,children:f.jsx(kRe,{"aria-hidden":"true"})})})}),Ve!==void 0&&f.jsx(KFt,{ref:D8,currentWorkingDirectory:Ve,writePath:C,pending:I,pendingAccepted:W,readOnlyReason:C?void 0:N??GQe})]}),f.jsxs("div",{"data-lo-composer-controls":!0,className:"ms-auto flex order-3 items-center gap-1",children:[ct&&aU&&f.jsx("output",{"data-preparing-indicator":"",className:"shrink-0 font-medium text-body-sm text-ink-muted",children:G?Y("ui.chat.composer.starting"):Y("ui.chat.composer.starting_recording")}),aU&&f.jsx(wt,{content:ct?Y("ui.chat.composer.starting_recording"):Xn?Y("ui.chat.composer.start_recording_hint",{shortcut:Hke,pushToTalk:dC().label}):mr,children:f.jsx("span",{children:f.jsx(Se,{variant:"ghost",size:G?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:vP,onClick:J8,"aria-label":Y("ui.chat.composer.start_recording"),"aria-busy":ct||void 0,disabled:et||!Xn,children:ct?f.jsx(po,{size:"sm"}):f.jsx(fRe,{"aria-hidden":"true"})})})}),ve&&f.jsxs(f.Fragment,{children:[f.jsx(wt,{content:Y("ui.chat.composer.confirm_recording_hint"),children:f.jsx("span",{children:f.jsx(Se,{variant:"ghost",size:G?"icon-sm":"icon",className:"text-success hover:bg-success-wash hover:text-success",onClick:$P,"aria-label":Y("ui.chat.composer.confirm_recording"),children:f.jsx(_l,{"aria-hidden":"true"})})})}),f.jsx(wt,{content:Y("ui.chat.composer.cancel_recording_hint"),children:f.jsx("span",{children:f.jsx(Se,{variant:"ghost",size:G?"icon-sm":"icon",className:"text-danger hover:bg-danger-wash hover:text-danger",onClick:yP,"aria-label":Y("ui.chat.composer.cancel_recording"),children:f.jsx(zi,{"aria-hidden":"true"})})})})]}),B8&&f.jsx("span",{"aria-hidden":"true","data-interrupt-slot":"",className:E("pointer-events-none invisible flex items-center"),children:f.jsx(Se,{variant:"danger",size:G?"icon-sm":"icon",type:"button",tabIndex:-1,children:f.jsx(p1,{"aria-hidden":"true"})})}),S?.active&&f.jsx(wt,{content:Y("ui.chat.composer.stop_work_hint"),children:f.jsx("span",{children:f.jsx(Se,{variant:"danger",size:G?"icon-sm":"icon",type:"button",onClick:S.onStop,"aria-label":Y("ui.chat.composer.stop"),"aria-keyshortcuts":"Escape","data-stopping":S.stopping===!0?"true":void 0,"aria-busy":S.stopping===!0?!0:void 0,className:E("data-[stopping]:border-danger data-[stopping]:text-ink data-[stopping]:bg-[color-mix(in_oklab,var(--color-danger-wash)_80%,var(--color-danger))]"),children:f.jsx(p1,{"aria-hidden":"true"})})})}),t&&p?f.jsx(wt,{content:Y("ui.chat.composer.stop_agent"),children:f.jsx("span",{children:f.jsx(Se,{variant:"danger",size:G?"icon-sm":"icon",type:"button",onClick:()=>m?.(p),"aria-label":Y("ui.chat.composer.stop_agent"),children:f.jsx(p1,{"aria-hidden":"true"})})})}):!ve&&!Ze&&f.jsx(wt,{content:lt!==null&&!r?Y("ui.chat.composer.ask_aside"):Y("ui.chat.composer.send_message"),children:f.jsx("span",{children:f.jsx(Se,{variant:"primary",size:G?"icon-sm":"icon",type:"submit",onPointerDown:Gke,disabled:et||Xm||!xe.trim()&&ce.length===0,className:"rounded-full disabled:bg-surface","aria-label":lt!==null&&!r?Y("ui.chat.composer.ask_aside"):Y("ui.chat.composer.send_message"),children:f.jsx(Qae,{"aria-hidden":"true"})})})})]})]})]})]})]}),_&&!na?f.jsx("div",{className:E("mt-2",lr),children:f.jsx(QLt,{})}):null,(_||R)&&St?f.jsx("div",{className:E("mt-2",lr),children:f.jsx("output",{className:"block text-body-sm text-ink-muted",children:R?"Choose a model for this conversation before sending.":"Connect a provider to send."})}):null]});return f.jsxs("div",{className:E($se,"flex w-full flex-col items-center",_r?"grow":"shrink-0",J?void 0:y6e,G?"pb-1 pt-0.5":"pb-4 pt-2"),"data-lo-composer-band":!0,ref:Rn,onDragOver:Vke,onDragLeave:Mke,onDrop:Lke,children:[f.jsx("div",{"data-lo-composer-splash":"",className:E("flex w-full flex-col items-center justify-center",_r?"grow":null),children:f.jsx("div",{ref:$r,className:E(dv?"flex w-full flex-col items-center gap-6 py-4":"hidden"),children:dv?f.jsxs(f.Fragment,{children:[f.jsx("span",{"data-lo-empty-mark":"",className:"contents",children:f.jsx(AHt,{className:"size-8",tone:"ink-muted"})}),_?null:f.jsx("h2",{className:"text-center text-ink text-title",children:Y("ui.chat.composer.welcome")}),_?f.jsx("div",{className:E("w-full",lr),children:f.jsx(SLt,{})}):f.jsxs("div",{className:E("flex flex-col gap-3",lr),children:[f.jsx(eBt,{band:yt,splash:gr,foot:Gr,suggestions:Ga,disabled:Wke,onRefusedPress:vP,onSelect:Bke,focusComposer:()=>Bt.current?.focus()}),f.jsx(IMt,{suspended:xe.trim().length>0,mentionsEnabled:Oe})]})]}):null})}),na?f.jsx("div",{className:E("mb-2 mt-2",lr),children:f.jsx(xLt,{selection:tr})}):null,f.jsx("div",{ref:ra,"data-lo-composer-foot":"",className:"w-full",children:tPe})]})}),eKt=$.memo(JHt);eKt.displayName="MessageInput";const Tke=1024,ow=1024*1024,U8=.85,tKt=new Set(["image/png","image/jpeg","image/webp"]),nKt=[{maxEdge:Tke,quality:.8},{maxEdge:768,quality:.7},{maxEdge:512,quality:.6}];function rKt(e){const t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function iKt(e){const t=Uint8Array.fromBase64;if(typeof t=="function")return t.call(Uint8Array,e);const n=atob(e),r=new Uint8Array(n.length);for(let i=0;i<n.length;i+=1)r[i]=n.charCodeAt(i);return r}function aKt(e){const t=e.toBase64;if(typeof t=="function")return t.call(e);let n="";const r=32768;for(let i=0;i<e.length;i+=r)n+=String.fromCharCode(...e.subarray(i,i+r));return btoa(n)}async function oKt(e,t,n,r,i){const a=Math.max(e.width,e.height),o=a>r?r/a:1,s=Math.max(1,Math.round(e.width*o)),l=Math.max(1,Math.round(e.height*o)),c=new OffscreenCanvas(s,l),u=c.getContext("2d");if(!u)return null;u.drawImage(e,0,0,s,l);const O=[],d=await c.convertToBlob({type:"image/png"}),h=new Uint8Array(await d.arrayBuffer());if(h.byteLength<=ow&&O.push({bytes:h,mime_type:"image/png"}),h.byteLength>ow||i<U8){const g=new OffscreenCanvas(s,l),y=g.getContext("2d");if(!y)return null;y.fillStyle="#ffffff",y.fillRect(0,0,s,l),y.drawImage(e,0,0,s,l);const v=await g.convertToBlob({type:"image/jpeg",quality:i}),x=new Uint8Array(await v.arrayBuffer());O.push({bytes:x,mime_type:"image/jpeg"}),h.byteLength>ow&&x.byteLength>h.byteLength&&O.push({bytes:h,mime_type:"image/png"})}let p=null,m=Number.POSITIVE_INFINITY;for(const g of O)g.bytes.byteLength<m&&(p=g,m=g.bytes.byteLength);return p?m>=n?t:{data_b64:aKt(p.bytes),mime_type:p.mime_type}:null}async function sKt(e){if(!tKt.has(e.mime_type)||typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")return null;try{return await createImageBitmap(new Blob([iKt(e.data_b64)],{type:e.mime_type}))}catch{return null}}async function lKt(e,t,n,r){const i=rKt(e.data_b64);try{return Math.max(t.width,t.height)<=n&&i<=ow&&r>=U8?e:await oKt(t,e,i,n,r)??e}catch{return e}}async function cKt(e,t,n){if(!e.length)return e;const r=await Promise.all(e.map(i=>sKt(i)));try{return await uKt(e,r,t,n)}finally{for(const i of r)i?.close()}}async function uKt(e,t,n,r){const i=(c,u)=>Promise.all(e.map((O,d)=>{const h=t[d];return h?lKt(O,h,c,u):Promise.resolve(O)})),a=await i(Tke,U8);if(r(a)<=n)return a;let o=e,s=r(e);const l=c=>{const u=r(c);return u<s&&(o=c,s=u),u};l(a);for(const c of nKt){const u=await i(c.maxEdge,c.quality);if(l(u)<=n)return u}return o}const OKt=/^data:(image\/(png|jpeg|gif|webp));base64,(.+)$/,dKt=/^file:\/\//,fKt={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"};async function Fnn(e,t){const n=[],r=[];for(const a of e){const o=OKt.exec(a);if(o){n.push({data_b64:o[3],mime_type:o[1]});continue}const s=a.split(".").pop()?.toLowerCase()??"",l=fKt[s];if(!l||!window.api?.readFile)continue;const c=await window.api.readFile(a.replace(dKt,""),"base64");c.success?n.push({data_b64:c.data,mime_type:l}):r.push(a)}const i=Math.max(0,n.length-mE);return{images:await cKt(n.slice(0,mE),YS,a=>zE(t,a)),unreadable:r,overflow:i}}function Bnn(e){if(e.length===0)return null;const t=e.map(bQ);return t.length===1?`${t[0]} could not be read (it may have been moved or deleted), so this message was not sent. Attach it again, or remove it from the draft.`:`${t.join(", ")} could not be read (they may have been moved or deleted), so this message was not sent. Attach them again, or remove them from the draft.`}function Hnn(e){if(e<=0)return null;const t=mE,n=t+e;return e===1?`This draft carries ${n} images and one message carries up to ${t}, so this message was not sent. Remove the extra image, or send it in a second message.`:`This draft carries ${n} images and one message carries up to ${t}, so this message was not sent. Remove ${e} of them, or send them in a second message.`}function Knn(e){const t=e.trim();if(t.startsWith("="))return null;const n=t.toLowerCase();return n==="pause"||n==="resume"||n==="status"?n:null}function Jnn(e){const t=e.trim();return t.startsWith("=")?t.slice(1).trimStart():t}function ern(e,t){return e==="pause"?{text:"Aida is paused. She will not check in until you resume her.",kind:"success"}:e==="resume"?{text:"Aida is resumed. She will check in on her usual schedule.",kind:"success"}:{kind:"info",text:t.paused?"Aida is paused.":"Aida is active."}}function hKt(e){return Qs(e,"Aida's controls could not reach the backend.")}const trn="The chief of staff is switched off on this install.",pKt="aida_no_provider",mKt="aida_disabled";function nrn(e,t){const n=e instanceof Nn?e.code:void 0;return n===mKt?null:n===pKt?{kind:"info",text:`${t} will say hello once an AI account is connected. Connect one from the chat to start.`}:{kind:"error",text:`${t}'s conversation could not be opened, so you are in a new chat instead. ${hKt(e)}`}}function rrn(e,t){if(e.held===!0)return`${t} is already open in another window, so she will say hello there.`;const n=e.greeting_state==="delivered"||e.greeting_state==="skipped"||e.greeting_state==null&&e.greeted===!0;return e.paused&&!n?`${t} is paused, so she will say hello when you resume her: type /aida resume.`:null}function irn(e){const t=e?.greeting_state;return t==null||t==="owed"}function gKt(e){return e.eventKey===e.storeKey&&!e.focused}let $ie=!1;function arn(){if($ie)return;$ie=!0;const e=Yn.persist?.getOptions?.()?.name??"conversation-input-store",t=n=>{gKt({eventKey:n.key,storeKey:e,focused:document.hasFocus()})&&Yn.persist?.rehydrate?.()?.catch?.(()=>{})};window.addEventListener("storage",t)}export{jtn as $,EQ as A,zy as B,Kd as C,Pr as D,nt as E,hr as F,Cr as G,Io as H,Uz as I,ea as J,An as K,$n as L,Dn as M,vz as N,Ko as O,jKt as P,wKt as Q,CKt as R,N0 as S,Kr as T,CA as U,LA as V,Fl as W,kr as X,Cze as Y,Z0 as Z,qtn as _,Kn as a,y6e as a$,h1e as a0,c6 as a1,UE as a2,vy as a3,Vd as a4,h7e as a5,trn as a6,Fnn as a7,Bnn as a8,Hnn as a9,qa as aA,Mjt as aB,FA as aC,Dwe as aD,ev as aE,Lwe as aF,Xnn as aG,VCt as aH,fee as aI,dee as aJ,dxe as aK,c8 as aL,Ck as aM,j7t as aN,q7t as aO,wp as aP,E7t as aQ,R7t as aR,Hx as aS,nv as aT,s8 as aU,a8 as aV,od as aW,Bx as aX,T7e as aY,Xx as aZ,lr as a_,YJt as aa,fDe as ab,ed as ac,Gp as ad,JO as ae,eKt as af,YEe as ag,wJt as ah,kKt as ai,_Kt as aj,arn as ak,FJt as al,MJt as am,PKt as an,k7e as ao,xE as ap,wd as aq,JRe as ar,my as as,ytn as at,Js as au,lh as av,qi as aw,yae as ax,ZC as ay,kE as az,Es as b,ybe as b$,$se as b0,p1 as b1,aen as b2,EKt as b3,QTe as b4,ien as b5,f6 as b6,gCe as b7,ise as b8,nen as b9,NC as bA,gy as bB,FS as bC,Pae as bD,$ae as bE,hae as bF,rRe as bG,OPt as bH,Bve as bI,Utn as bJ,YT as bK,cA as bL,NT as bM,GC as bN,Tae as bO,_ae as bP,mae as bQ,pae as bR,tae as bS,xKt as bT,Uu as bU,SKt as bV,e0 as bW,TEe as bX,Dvt as bY,m6 as bZ,iO as b_,ren as ba,ud as bb,$y as bc,ge as bd,K2e as be,y7e as bf,jm as bg,R4e as bh,VP as bi,Fbe as bj,IU as bk,iq as bl,Bwt as bm,Ic as bn,eae as bo,STe as bp,bKt as bq,VU as br,Oae as bs,AKt as bt,MC as bu,WJt as bv,xEe as bw,DL as bx,Gh as by,wae as bz,D1e as c,j7e as c$,R6e as c0,zd as c1,ebe as c2,g6 as c3,$Ce as c4,eXe as c5,M2e as c6,_Gt as c7,SO as c8,EJt as c9,Wnn as cA,RBt as cB,w1e as cC,xae as cD,H9 as cE,$Mt as cF,rO as cG,Ioe as cH,VJt as cI,Qkt as cJ,Tkt as cK,wtn as cL,pF as cM,dF as cN,_kt as cO,SZt as cP,xi as cQ,Gl as cR,DJt as cS,LTt as cT,VO as cU,L_t as cV,MRe as cW,c4e as cX,TKt as cY,Ann as cZ,_7e as c_,u7e as ca,lc as cb,PGt as cc,Kk as cd,Jk as ce,BUt as cf,Bk as cg,Voe as ch,QKt as ci,Wje as cj,jae as ck,R7e as cl,Bbe as cm,HXt as cn,$1e as co,Gxt as cp,Vp as cq,Rtn as cr,QTt as cs,O1e as ct,Etn as cu,E2t as cv,Cj as cw,TBt as cx,Unn as cy,tc as cz,xnn as d,_E as d$,X_t as d0,uXe as d1,Atn as d2,vd as d3,ewe as d4,jx as d5,Vx as d6,wee as d7,a7t as d8,Y$ as d9,Ftn as dA,Ntn as dB,Btn as dC,Mtn as dD,Dtn as dE,rae as dF,nae as dG,NJt as dH,GJt as dI,j4e as dJ,ZJt as dK,IJt as dL,wEe as dM,P7e as dN,Vje as dO,LJt as dP,LP as dQ,AZe as dR,IZe as dS,eWe as dT,F0 as dU,CZe as dV,kue as dW,wje as dX,xje as dY,ua as dZ,O3e as d_,K4t as da,J4t as db,H4t as dc,B4t as dd,F4t as de,L4t as df,M4t as dg,kk as dh,R4t as di,X4t as dj,V4t as dk,D4t as dl,W4e as dm,En as dn,LS as dp,Htn as dq,Jtn as dr,Ltn as ds,Vtn as dt,cC as du,Gtn as dv,Ztn as dw,Itn as dx,Ktn as dy,enn as dz,Pnn as e,AHt as e$,Q$ as e0,n6 as e1,yJt as e2,Ytn as e3,Wtn as e4,Jqe as e5,dJt as e6,uJt as e7,OJt as e8,gJt as e9,fJt as eA,G2e as eB,BKt as eC,toe as eD,nJt as eE,DT as eF,vJt as eG,wRe as eH,sqe as eI,eJt as eJ,hJt as eK,lJt as eL,Lqe as eM,mJt as eN,Eqe as eO,cJt as eP,B2t as eQ,TE as eR,Wqe as eS,tnn as eT,_Qe as eU,nnn as eV,Stn as eW,e2t as eX,F2e as eY,hoe as eZ,f3e as e_,$Jt as ea,Xqe as eb,tJt as ec,JKt as ed,rJt as ee,FKt as ef,MT as eg,iJt as eh,jj as ei,R2t as ej,_2t as ek,aJt as el,pw as em,Dqe as en,sJt as eo,z2t as ep,iXe as eq,MS as er,lae as es,wA as et,aB as eu,Rg as ev,HKt as ew,noe as ex,YRe as ey,pJt as ez,Snn as f,Wo as f$,fae as f0,a4e as f1,sze as f2,uze as f3,dze as f4,fen as f5,hen as f6,pen as f7,Qze as f8,ven as f9,fz as fA,Gue as fB,Wue as fC,Aue as fD,Uue as fE,Cen as fF,r6 as fG,yoe as fH,Q3e as fI,By as fJ,Hve as fK,Wa as fL,pn as fM,uO as fN,vt as fO,Ue as fP,st as fQ,Ben as fR,pi as fS,sZ as fT,em as fU,io as fV,ic as fW,nOe as fX,Ft as fY,kn as fZ,Qd as f_,gen as fa,yze as fb,Zse as fc,ben as fd,YXe as fe,wze as ff,men as fg,Xze as fh,wen as fi,$en as fj,cze as fk,_n as fl,yen as fm,cae as fn,QEe as fo,SJt as fp,XE as fq,M2t as fr,E_t as fs,mz as ft,zen as fu,Ren as fv,aDe as fw,Xen as fx,hz as fy,Nue as fz,Tnn as g,Ew as g$,Ol as g0,Nen as g1,Sde as g2,DLe as g3,Ku as g4,ILe as g5,zn as g6,qt as g7,Hd as g8,ji as g9,atn as gA,RQ as gB,Ven as gC,Rye as gD,L9 as gE,Cre as gF,Aae as gG,TW as gH,mEe as gI,M4e as gJ,EMt as gK,DQe as gL,N6e as gM,Gse as gN,Pke as gO,kRe as gP,Zoe as gQ,dC as gR,fRe as gS,Qae as gT,gtn as gU,sAe as gV,I4e as gW,D4e as gX,vve as gY,yve as gZ,Een as g_,Or as ga,bi as gb,yc as gc,ab as gd,Iw as ge,TQ as gf,Fen as gg,Dc as gh,ctn as gi,ntn as gj,yBe as gk,Hen as gl,Ken as gm,Ien as gn,rtn as go,Gen as gp,Zen as gq,ttn as gr,itn as gs,otn as gt,ltn as gu,utn as gv,Men as gw,Len as gx,Den as gy,kQ as gz,UH as h,Xbe as h$,cQ as h0,xle as h1,S5 as h2,RYe as h3,XYe as h4,wle as h5,Sen as h6,Kle as h7,ta as h8,lO as h9,Inn as hA,Gnn as hB,EBt as hC,Ynn as hD,Nnn as hE,r7e as hF,o6 as hG,k0 as hH,Vnn as hI,$h as hJ,bnn as hK,qh as hL,wnn as hM,zBt as hN,nXe as hO,_Jt as hP,dkt as hQ,rse as hR,sje as hS,TJt as hT,J2t as hU,GKt as hV,Dnn as hW,XEe as hX,Mnn as hY,m5t as hZ,g5t as h_,ky as ha,ken as hb,QAe as hc,DYe as hd,iIe as he,Qw as hf,N6 as hg,q6 as hh,eq as hi,Hle as hj,AAe as hk,vAe as hl,jAe as hm,IN as hn,Jle as ho,Ile as hp,HWe as hq,JXe as hr,Sae as hs,bQ as ht,zue as hu,oDe as hv,dDe as hw,Znn as hx,cE as hy,mke as hz,Qnn as i,ZEe as i$,J1 as i0,WKt as i1,UXe as i2,NKt as i3,CBt as i4,YKt as i5,UKt as i6,ZKt as i7,UEe as i8,hPt as i9,xJt as iA,gze as iB,znn as iC,den as iD,$6e as iE,QW as iF,Goe as iG,Cje as iH,CJt as iI,C5t as iJ,qbe as iK,rMt as iL,GQe as iM,Rnn as iN,gm as iO,Knn as iP,ern as iQ,hKt as iR,Jnn as iS,IQe as iT,oen as iU,cen as iV,sen as iW,len as iX,UJt as iY,T1e as iZ,Okt as i_,y6 as ia,xy as ib,B9 as ic,pPt as id,qen as ie,Nxt as ig,jen as ih,dae as ii,KFt as ij,lRt as ik,C1e as il,n5 as im,Zp as io,q7e as ip,_tn as iq,Ttn as ir,Xtn as is,kae as it,PEe as iu,uen as iv,JS as iw,QJt as ix,x3e as iy,kJt as iz,_nn as j,dnn as j$,p6e as j0,m6e as j1,Oen as j2,KKt as j3,oJt as j4,H2t as j5,Enn as j6,Lnn as j7,vtn as j8,jnn as j9,Qtn as jA,Ptn as jB,c1e as jC,Cc as jD,ktn as jE,Q7e as jF,o1e as jG,snn as jH,$nn as jI,ynn as jJ,lnn as jK,vnn as jL,BS as jM,rTt as jN,BMt as jO,fnn as jP,hnn as jQ,OTt as jR,ann as jS,OXt as jT,inn as jU,onn as jV,lXt as jW,unn as jX,mnn as jY,pnn as jZ,$k as j_,PJt as ja,iqe as jb,aqe as jc,oqe as jd,LKt as je,MKt as jf,J3e as jg,K3e as jh,Eoe as ji,VKt as jj,Iae as jk,IKt as jl,DKt as jm,Cnn as jn,btn as jo,qnn as jp,nw as jq,SRe as jr,Nu as js,RJt as jt,yje as ju,XJt as jv,d7e as jw,iTt as jx,a1e as jy,gnn as jz,A$ as k,Onn as k0,cnn as k1,VC as k2,FQe as k3,S1e as k4,AE as k5,irn as k6,rrn as k7,nrn as k8,DTt as k9,Ym as kA,JJt as kB,zKt as kC,m1 as kD,een as kE,RKt as kF,Ten as kG,$tn as kH,m1e as ka,p1e as kb,pCe as kc,GF as kd,Ctn as ke,ztn as kf,k_t as kg,ten as kh,Mje as ki,Lje as kj,qJt as kk,n7e as kl,zJt as km,jJt as kn,bJt as ko,L7e as kp,AJt as kq,Ti as kr,Lp as ks,xen as kt,rnn as ku,xtn as kv,qTt as kw,KJt as kx,BJt as ky,HJt as kz,Fx as l,knn as m,B1e as n,I4t as o,pp as p,nl as q,dd as r,qx as s,Qk as t,wn as u,k as v,jA as w,gn as x,ir as y,un as z};
948
+ `)?1:0,tn=sc(xe,de.start,de.end+Ht,_e),dn=_e.endsWith('"')?tn.caret-1:tn.caret;vr.current=dn,Un(tn.text),ai(dn),ya.remember(M.path),ya.close()},[xe,On,ya,Un,et]),mP=$.useCallback(M=>{if(et||!$i.token)return;const de=oBt(xe,$i.token,M.name);$i.close(),vr.current=de.caret,Un(de.text),ai(de.caret)},[xe,$i,Un,et]),Eke=$.useCallback(M=>{const de=Hc.current;return de===null||!(M.metaKey||M.ctrlKey)||M.altKey||M.shiftKey||M.key.toLowerCase()!=="z"?!1:(Hc.current=null,vr.current=de.caret,de.plain>0&&Ir({chars:de.plain,over:de.text}),Un(de.text),ai(de.caret),!0)},[Ir,Un]),qke=$.useCallback(M=>{if(et)return;if(se(M)){M.preventDefault();return}if(M.key==="Escape"&&Bn!==null){if(M.preventDefault(),Ia)return;pv();return}if(Cke(M)){M.preventDefault();return}if(Eke(M)){M.preventDefault();return}if(zFt(M,ya,I8)){M.preventDefault();return}if(XHt(M,Ke,pP,Z8)){M.preventDefault();return}if(_Bt(M,$i,mP)){M.preventDefault();return}if(lt!==null&&M.key==="Escape"){M.preventDefault(),GE(c??"");return}if(lt!==null&&ZCe(M)){const Le=lt.turns.at(-1),Ht=Le?ur.getState().streams[Le.asideId]:void 0;if(!Le||lt.queued!==void 0||!cse(Ht,u,O))return;M.preventDefault();const tn=c??"",dn=Date.now(),or=DCe(Ot.current,Le.asideId,dn);if(or==="arm"){Ot.current={turnId:Le.asideId,at:dn},ur.getState().setAsideNotice(tn,tY(OE));return}if(or==="ignore")return;Ot.current=null,sse(tn).catch(()=>{});return}if(M.key==="Backspace"||M.key==="Delete"){const Le=BLt(On,M.key==="Backspace"?"back":"forward",zs.spans,zs.resolved);if(Le&&!M.nativeEvent.isComposing){const Ht=sc(xe,Le.start,Le.end,"");vr.current=Ht.caret,ai(Ht.caret),Un(Ht.text),M.preventDefault();return}}const de=Bt.current,_e=LHt();if(_e&&NEe(M,{value:xe,selectionStart:de?.selectionStart??null,selectionEnd:de?.selectionEnd??null})){_e.focus(),M.preventDefault();return}if(Xm&&M.key==="Enter"&&!M.shiftKey&&!M.nativeEvent.isComposing){M.preventDefault(),mv();return}if(M.key==="Enter"&&!M.shiftKey&&!M.nativeEvent.isComposing){const Le=Wn(xe,On);if(Le.kind!=="send"){M.preventDefault(),Dr(Le,xe,On);return}if(hv(xe)){M.preventDefault();return}}wO(M)},[Ke,pP,Z8,$i,mP,hv,wO,se,Bn,pv,Wn,Dr,xe,On,et,lt,c,u,O]),D8=$.useRef(null),Us=$.useCallback(M=>{gC=!1,Bt.current?.focus({preventScroll:M?.preventScroll===!0})},[Bt]),jke=$.useCallback(()=>{Iae(xe)!==null&&Un("")},[xe,Un]);$.useImperativeHandle(qe,()=>({focusInput:Us,openWorkingDirectoryMenu:()=>{D8.current?.openMenu()},submitNow:()=>{hv(xe)||Sf()},consumeApprovalAnswerDraft:jke}));const V8=$.useCallback(()=>Bt.current,[Bt]);$.useEffect(()=>u3e(Us,V8),[Us,V8]);const Ws=$.useRef(null),M8=$.useRef(xe);$.useLayoutEffect(()=>{M8.current=xe},[xe]);const L8=$.useCallback(M=>{Ws.current===M&&(Ws.current=null,Ui.current.delete(M.index))},[]),gv=$.useCallback(M=>{if(Ws.current!==M)return!1;const de=X1t({buffer:M8.current,cleared:M.cleared});return de?(Ui.current.set(M.index,M.payload),Ws.current===M&&(Ws.current=null),M.toastId!==null&&e0(M.toastId),Wi({capture:ph(ii.current,de.buffer,de.caret,"arrival"),buffer:de.buffer,caret:de.caret}),Cl(null),!0):!1},[Wi,Cl]);$.useLayoutEffect(()=>{const M=Ws.current;M!==null&&M.cleared.buffer!==xe&&(M.toastId!==null&&e0(M.toastId),L8(M))},[xe,L8]);const Cke=$.useCallback(M=>{const de=Ws.current;return de===null||!(M.metaKey||M.ctrlKey)||M.altKey||M.shiftKey||M.key.toLowerCase()!=="z"?!1:(gv(de),!0)},[gv]),F8=$.useCallback(M=>{gv(M)&&Us()},[Us,gv]),zke=$.useCallback(M=>{if(et)return;const de=Ui.current.get(M);if(!de)return;const _e=T1t({buffer:xe,payload:de});if(!_e.cleared)return;const Le=Ws.current;Le&&(Ws.current=null,Ui.current.delete(Le.index),Le.toastId!==null&&e0(Le.toastId));const Ht={index:M,payload:de,cleared:_e,toastId:null};Ws.current=Ht,Wi({capture:ph(ii.current,_e.buffer,_e.caret,"arrival"),buffer:_e.buffer,caret:_e.caret}),Cl({key:de.key,index:M,over:_e.buffer}),Ht.toastId=jm(P1t(M),{action:{label:k1t,onClick:()=>F8(Ht)}}),Us()},[Wi,Us,et,xe,Cl,F8]),Ake=nMt(!!S?.active),B8=b&&!S?.active&&(Ake.held||ve)&&!(t&&p),Uke=!!S?.active||B8,Wke=et||ve||Ze||xe.trim().length>0;$.useEffect(()=>{const M=Bt.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[xe,Bt,ve,Ze]);const H8=$.useRef(!1);$.useEffect(()=>{const M=ve||Ze,de=H8.current&&!M;if(H8.current=M,!L&&!de||et||M)return;const _e=document.activeElement;!(_e&&(_e.tagName==="INPUT"||_e.tagName==="TEXTAREA"))&&!_&&Bt.current?.focus({preventScroll:!0})},[L,et,ve,Ze,Bt,_]),$.useEffect(()=>{window.electron.ipcRenderer.invoke("get-platform-info").then(M=>{pt(M.platform)}).catch(M=>{console.error("Failed to get platform info:",M)})},[]);const is=$.useRef(null),Yke=250,K8=$.useRef(ze);$.useEffect(()=>{K8.current=ze}),$.useEffect(()=>(Cre("message-input",ve||ct),()=>Cre("message-input",!1)),[ve,ct]),$.useEffect(()=>{K8.current?.(ve)},[ve]);const tu=$.useCallback(M=>{bt(!1);const de=on.current;if(!de)return;const _e=is.current?.startedAt??null,Le=_e===null?Number.POSITIVE_INFINITY:performance.now()-_e;if(is.current=null,de.state==="inactive"){Je(!1);return}(M==="abort"||Le<Yke)&&(de.onstop=()=>{if(de.stream)for(const Ht of de.stream.getTracks())Ht.stop();rn(null),pr.current=[]}),de.stop(),Je(!1)},[]);$.useEffect(()=>()=>{const M=is.current!==null;is.current=null;const de=on.current;if(de&&de.state!=="inactive"){tu("abort");return}M&&bt(!1)},[tu]);const gP=$.useCallback((M="release")=>{const de=is.current;if(de){if(de.startedAt===null){is.current=null,bt(!1);return}tu(M)}},[tu]),J8=$.useCallback(async()=>{if(!(et||!Xn)&&!is.current)if(navigator?.mediaDevices?.getUserMedia){const M={startedAt:null};is.current=M,bt(!0);try{const de=await navigator.mediaDevices.getUserMedia({audio:!0});if(is.current!==M){for(const _e of de.getTracks())_e.stop();return}on.current=new MediaRecorder(de),pr.current=[],on.current.ondataavailable=_e=>{pr.current.push(_e.data)},on.current.onstop=()=>{const _e=new Blob(pr.current,{type:"audio/webm"});rn(_e);for(const Le of de.getTracks())Le.stop()},on.current.start(),M.startedAt=performance.now(),bt(!1),Je(!0),rn(null)}catch(de){if(is.current!==M)return;is.current=null,bt(!1),console.error("Error accessing microphone:",de),Kr("Error accessing microphone. Please ensure microphone permissions are granted.")}}else console.error("This runtime exposes no MediaRecorder"),Kr("Dictation is not available on this device.")},[Xn,et]),$P=$.useCallback(()=>{ve&&tu("release")},[ve,tu]),yP=$.useCallback(()=>{ve&&tu("abort")},[ve,tu]);$.useEffect(()=>{if(!ve&&!ct)return;const M=de=>{if(ve){de.key==="Enter"?(de.preventDefault(),$P()):de.key==="Escape"&&(de.preventDefault(),yP());return}de.key==="Escape"&&(de.preventDefault(),gP("abort"),bt(!1))};return window.addEventListener("keydown",M),()=>{window.removeEventListener("keydown",M)}},[ve,ct,$P,yP,gP]);const eU=$.useCallback(async()=>{if(Dt)try{jt(!0);const M=await Aae.createTranscription(Vd.baseUrl,{file:new File([Dt],"recording.webm",{type:"audio/webm"})});if(M.result?.text){const de=M.result?.text||"";js.current=!0,rs(de)}else Uu(mEe);rn(null)}catch(M){console.error("Error transcribing audio:",M),Kr(M4e(M))}finally{jt(!1)}},[Dt,rs]);$.useEffect(()=>{Dt&&eU()},[Dt,eU]);const tU=$.useRef(!0);$.useEffect(()=>{if(typeof IntersectionObserver>"u")return;const M=Bt.current;if(M===null)return;const de=new IntersectionObserver(_e=>{const Le=_e[_e.length-1];Le!==void 0&&(tU.current=Le.isIntersecting)});return de.observe(M),()=>de.disconnect()},[Bt]),EMt("message-input",DQe.MESSAGE_INPUT,{start:J8,stop:gP},()=>!!(!et&&!ve&&!Ze&&Xn&&tU.current));const Nke=M=>{if(M.preventDefault(),et||_)return;if(R){mv();return}if(!xe.trim()&&ce.length===0||Tm())return;const de=Wn(xe,On);if(de.kind!=="send"){Dr(de,xe,On);return}hv(xe)||Sf()},vP=$.useCallback(M=>{et&&M.preventDefault()},[et]),Gke=$.useCallback(M=>{!et&&!Xm||(M.preventDefault(),Xm&&!et&&mv())},[et,Xm,mv]),Zke=M=>{d&&$e(d,M)},Ike=async()=>{const M=await window.electron.ipcRenderer.invoke("show-open-dialog",{properties:["openFile","multiSelections"]});if(!M.canceled&&M.filePaths.length>0&&d)for(const de of M.filePaths)fe(d,{id:Xa(),path:xU(de)})},Dke=M=>{if(et)return;const de=M.clipboardData?.getData("text/plain")??"";if(de&&ii.current.arm!==null){const Le=M.currentTarget,Ht=h1t({capture:ii.current,buffer:xe,caret:Le.selectionEnd??xe.length,selection:{start:Le.selectionStart??xe.length,end:Le.selectionEnd??xe.length},pasted:de,index:jl.current,taken:kf()});if(Ht){M.preventDefault(),Wi(Ht),Ir(null);return}}de&&(ym.current=r1t(de));const _e=M.clipboardData?.items;if(_e){for(let Le=0;Le<_e.length;Le++)if(_e[Le].type.indexOf("image")!==-1||_e[Le].kind==="file"){const Ht=_e[Le].getAsFile();if(Ht){const tn=new FileReader;tn.onload=dn=>{dn.target?.result&&d&&fe(d,{id:Xa(),path:dn.target.result})},tn.readAsDataURL(Ht)}}}},Vke=M=>{et||M.dataTransfer?.types.includes("Files")&&(M.preventDefault(),M.stopPropagation(),M.dataTransfer.dropEffect="copy",bP(!0))},Mke=M=>{M.currentTarget.contains(M.relatedTarget)||bP(!1)},Lke=M=>{if(bP(!1),et)return;const de=M.dataTransfer?.files;!de||de.length===0||(M.preventDefault(),M.stopPropagation(),d&&Fke(d,Array.from(de)))},Fke=async(M,de)=>{for(const _e of de){const Le=window.api?.getPathForFile?window.api.getPathForFile(_e):"";if(Le){fe(M,{id:Xa(),path:xU(Le)});continue}const Ht=await MHt(_e);Ht&&fe(M,{id:Xa(),path:Ht})}},[nU,bP]=$.useState(!1),Bke=M=>{et||(xe||g?.(),vr.current=M.length,Un(M),ai(M.length),Bt.current?.focus())},wP=Ro(Za)?Za.value!==""?Bc(xe,Za)?U1t:z1t:yr?A1t:Y1t:hf!==null&&hf===xe?W1t:_1t({unredacted:Qm!==null?N1t(Qm):null,armed:Za.arm!==null&&ave(xe,xe.length)!==null,cleared:$m===null?null:{key:$m.key,index:$m.index},undoCap:Ske(De==="darwin")}),Hke=$.useMemo(()=>De==="darwin"?"Cmd+Shift+S":"Ctrl+Shift+S",[De]),xP=$.useRef(null),Kke=M=>{d&&(xP.current=ke.findIndex(de=>de.id===M),dt(d,M))};$.useEffect(()=>{const M=xP.current;if(M===null)return;xP.current=null;const de=document.querySelectorAll(BHt),_e=de[Math.min(M,de.length-1)];_e?_e.focus():Us()},[ke,Us]);const yo=$.useMemo(()=>{const de=PP(xe,ke)!==""||ce.length>0,_e=_||Q?.message&&ale.test(Q.message)?[{label:"Connect a provider",onClick:()=>Nu.getState().openConnect()}]:[];return{message:Q?.message,muted:Q?.muted===!0,polite:Q?.polite===!0,actions:[...Q?.actions??[],..._e],retry:Q?.retry===!0,clear:Q?.muted!==!0&&(Q?.onClear!==void 0||de)}},[Q,xe,ke,ce,_]),_f=iTt(),rU=E("block text-body-sm",G?"px-2 pb-1":"px-4 pb-2",Qm!==null?"text-warning":"text-ink-muted"),SP=E("flex flex-wrap items-center gap-2 text-body-sm text-ink-muted",G?"px-2 pb-1":"px-4 pb-2"),iU=Vr&&xe.length>0,Jke=f.jsx("output",{className:E(lr,"block pb-2",_f.issue.kind==="hidden"&&"hidden"),children:f.jsx(rBt,{issue:_f.issue,onSignIn:_f.start,onCancel:_f.cancel,onDismiss:_f.dismiss,isSmallView:G,onFocusComposer:()=>Bt.current?.focus()})}),Rm=v_e(H),ePe=Rm&&!b_e(Rm,w_e(_f.issue))?f.jsx("output",{className:E(lr,"block pb-2"),children:f.jsx(SMt,{access:Rm,isSmallView:G,onSwitchModel:H?.onCommand?()=>H.onCommand?.({name:"model",args:""}):void 0,onConnect:()=>Nu.getState().openConnect({providerId:Rm.provider})})}):null,aU=ct||!ve&&!Ze&&!(t&&p),tPe=f.jsxs("form",{onSubmit:Nke,"data-chat-region":"composer","aria-label":Wae.composer,tabIndex:-1,className:"w-full",children:[f.jsx(_U,{fallback:null,children:f.jsx(JVt,{frontend:H?.frontend,askFrontend:H?.asks,runDetails:we,isSmallView:G,askExpanded:D,onAskToggle:j,askOutcomes:V,onNote:oe,onFocusComposer:()=>Bt.current?.focus()},d)}),!x_e(Rm)&&Jke,ePe,a,o?.blocksInput&&o.placeholder&&!o.statedByNode&&xe.trim().length>0?f.jsx("p",{id:die,className:"mb-2 text-meta text-ink-muted",children:o.placeholder}):null,o?.node,yo.message!==void 0&&f.jsxs("div",{role:yo.polite?"status":"alert","data-composer-notice":!0,"data-composer-queued":Q?.message===k_e.queuedSend?!0:void 0,className:E(lr,"flex flex-wrap items-center gap-x-3 gap-y-1 text-body-sm",G?"px-2 pb-1":"px-4 pb-2"),children:[f.jsxs("p",{className:E("flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",yo.muted?"text-ink-muted":"text-danger"),children:[!yo.muted&&f.jsx("span",{className:"flex shrink-0 items-center pt-0.5",children:f.jsx(Nh,{size:14,"aria-hidden":"true"})}),f.jsx("span",{className:E("min-w-0 break-words",!yo.muted&&"font-medium"),children:yo.message})]}),(yo.retry||yo.clear||yo.actions.length>0)&&f.jsxs(f.Fragment,{children:[yo.actions.map(M=>f.jsx(Se,{type:"button",variant:"link",size:"sm",className:E("min-h-6 cursor-pointer text-body-sm underline"),onClick:M.onClick,children:M.label},M.label)),yo.retry&&Q?.onRetry&&f.jsx(Se,{type:"button",variant:"link",size:"sm",className:E("min-h-6 cursor-pointer font-semibold text-body-sm underline"),onClick:()=>Q.onRetry?.(),children:S_e}),yo.clear&&Q?.onClear&&f.jsx(Se,{type:"button",variant:"link",size:"sm","aria-label":Y("ui.chat.composer.clear_message"),className:E("min-h-6 cursor-pointer text-ink-dim text-body-sm underline"),onClick:()=>Q.onClear?.(),children:Q_e})]})]}),w&&f.jsx("output",{className:E(lr,"block text-body-sm text-ink-muted",G?"px-2 pb-1":"px-4 pb-2"),children:w}),c&&lt!==null&&f.jsx(zLt,{sessionId:c,sessionStreaming:u,adoptQueueSupported:O,isSmallView:G,onReturnFocus:()=>Bt.current?.focus()}),P?f.jsx("div",{className:E(lr,G?"px-2 pb-2":"px-4 pb-2"),children:P}):null,f.jsxs("div",{className:E(lr,"relative w-full"),children:[f.jsx(kHt,{state:Ke,onPick:pP,onActionPick:hP}),f.jsx(UFt,{state:ya,onPick:I8}),f.jsx(PBt,{state:$i,onPick:mP}),!te&&!Ke.open&&!ya.open&&!$i.open&&f.jsx(_2t,{visible:y,onClick:x,hasNewActivity:v}),f.jsx("output",{id:sie,className:E(lr,wP?rU:"hidden"),children:wP}),iU&&f.jsx("output",{id:lie,className:E(lr,rU),children:WHt}),l&&Bn===null&&f.jsxs("output",{id:cie,className:E(SP,lr),children:[f.jsx("span",{className:"min-w-0",children:Y("ui.chat.composer.secret_ask_notice")}),f.jsx(Se,{type:"button",size:"sm",variant:"secondary","data-lo-ask-item-toggle":"",onClick:()=>l.onOpen(),children:Y("ui.chat.composer.secret_ask_open")})]}),Rr!==null&&Bn===null&&f.jsx("output",{id:YHt,className:E(SP,lr),children:f.jsx("span",{className:"min-w-0",children:Rr})}),Bn!==null&&f.jsxs("fieldset",{ref:fv,tabIndex:-1,id:NHt,"aria-labelledby":uie,"aria-busy":Ia,onKeyDown:M=>{M.key==="Escape"&&(M.preventDefault(),!Ia&&pv())},className:E("m-0 min-w-0 border-0 p-0",SP,lr),children:[f.jsxs("span",{id:uie,className:"min-w-0",children:[Ia?Y("ui.chat.composer.secret_confirm_sending"):Y("ui.chat.composer.secret_confirm_message"),f.jsx("span",{className:E("whitespace-nowrap",Ia&&"invisible"),"aria-hidden":Ia||void 0,children:` ${Y("ui.chat.composer.secret_confirm_chars",{count:Bn.value.length})}`})]}),f.jsx(Se,{ref:Y8,type:"button",size:"sm",disabled:Ia,onClick:Xke,children:l?.fillable?Y("ui.chat.composer.secret_confirm_put"):Y("ui.chat.composer.secret_confirm_put_multi")}),f.jsx(Se,{type:"button",size:"sm",variant:"secondary",disabled:Ia,onClick:Rke,children:Y("ui.chat.composer.secret_confirm_send")}),f.jsx(Se,{type:"button",size:"sm",variant:"ghost",disabled:Ia,onClick:pv,children:Y("ui.chat.composer.secret_confirm_cancel")})]}),zl>0&&f.jsx("span",{id:Oie,className:"sr-only",children:zl===1?"1 reference points outside this session's working directory; the agent will ask you to approve it before reading.":`${zl} references point outside this session's working directory; the agent will ask you to approve them before reading.`}),i&&f.jsx("span",{id:fie,className:"sr-only",children:Y("ui.chat.composer.delivery_remedies_hint")}),f.jsxs("div",{"data-glass-region":"composer",className:E(HHt,nU?void 0:KHt,G?"gap-2 rounded-md p-2":"gap-3 rounded-frame p-4",lr,nU&&"outline-dashed outline-2 outline-accent outline-offset-2"),"data-lo-composer-measure":"","data-tour-tag":"chat-input-textarea",children:[(ke.length>0||ce.length>0)&&f.jsxs("div",{className:"max-h-[240px] shrink-0 overflow-y-auto",children:[ke.length>0&&f.jsx(aA,{replies:ke,onRemoveReply:Kke}),ce.length>0&&f.jsx(N6e,{attachments:ce.map(M=>M.path),onRemoveAttachment:M=>Zke(ce[M].id),disabled:et||ve||Ze})]}),f.jsxs("div",{className:"relative isolate w-full",children:[f.jsx(FMt,{text:xe,payloads:Ui.current,capture:Za,held:Bc(xe,Za),fieldRef:Bt,mirrorRef:Jc,isSmallView:G}),f.jsx(fFt,{text:xe,spans:zs.spans,resolved:zs.resolved,fieldRef:Bt,isSmallView:G}),f.jsx(DFt,{draft:xe,runs:Mt,textareaRef:Bt,fieldClassName:jS(G),refused:et,children:f.jsx("textarea",{ref:Bt,"data-region-entry":!0,className:E(jS(G),"block",G?"max-h-24":"max-h-28","resize-none overflow-y-auto bg-transparent",Xr?"text-transparent caret-ink":"text-ink","outline-none placeholder:text-ink-dim",o?.blocksInput?"read-only:text-ink-muted read-only:placeholder:text-ink-muted disabled:text-ink-disabled disabled:placeholder:text-ink-disabled":"read-only:text-ink-disabled read-only:placeholder:text-ink-disabled disabled:text-ink-disabled disabled:placeholder:text-ink-disabled"),placeholder:ve?Os.recording:N7e({unavailable:B,secretAnswer:Vr,inputDisabled:et,awaitingAnswer:r,asideAttached:lt!==null,sendingUnsettled:xm||Sm,awaitingReply:n,stopping:S?.stopping===!0,noProvider:_,idle:Ge,hostLine:o?.placeholder??null}),value:xe,onCompositionStart:()=>km(!0),onCompositionEnd:()=>km(!1),onChange:M=>{wf.current=!0;const de=M.target.value,_e=M.target.selectionStart??de.length;Hc.current=null;const Le=l1t(ii.current,xe,de,_e,"typing");Le.buffer!==de?(vr.current=Le.caret,ai(Le.caret)):ai(_e),Le.capture!==ii.current&&ts(Le.capture),!xe&&Le.buffer&&g?.(),$f.current=Le.buffer,eu(Le.capture,Le.buffer),Un(Le.buffer),Date.now()-Vt.current>=ZHt&&Q?.onDismiss?.()},onSelect:M=>{const de=M.target,_e=vr.current;if(_e!==null){de.selectionStart===_e&&(vr.current=null);return}ai(de.selectionStart),ts(ph(ii.current,xe,de.selectionStart,"caret"))},onKeyDown:qke,onPointerDown:()=>{gC=!0},onPaste:Dke,rows:1,readOnly:et,"aria-disabled":et||void 0,"aria-label":Y("ui.chat.composer.message"),role:"combobox","aria-describedby":[o?o.id:null,o?.blocksInput&&o.placeholder&&!o.statedByNode&&xe.trim().length>0?die:null,wP?sie:null,iU?lie:null,l&&Bn===null?cie:null,zl>0?Oie:null,B?Zve:null,i?fie:null].filter(Boolean).join(" ")||void 0,"aria-expanded":Ke.open||ya.open,"aria-controls":Ke.open?Ke.listId:ya.open?ya.listId:void 0,"aria-activedescendant":(Ke.open?Ke.activeDescendantId:ya.activeDescendantId)??void 0})}),f.jsx(VMt,{small:G,text:xe,payloads:Ui.current,capture:Za,mirrorRef:Jc,fieldRef:Bt,onClear:et?null:zke,onControlUnmounted:Us})]}),ve&&f.jsx(Gse,{isRecording:ve}),Ze&&f.jsxs("div",{"data-transcribing-indicator":"",className:"mt-1 flex items-center gap-2 px-2 [min-height:1.5rem]",children:[f.jsx("span",{className:"font-medium text-body-sm text-ink-muted",children:Y("ui.chat.composer.processing_audio")}),f.jsx(Pke,{})]}),f.jsxs("div",{className:"flex min-w-0 flex-nowrap items-center gap-x-2",children:[H&&f.jsx(_U,{fallback:null,children:f.jsx(j9e,{frontend:H.frontend,onCommand:H.onCommand,effortEntities:H.effortEntities,draft:H.draft,onOpenDraftPicker:H.onOpenDraftPicker,draftResolution:H.draftResolution,held:H.held,contextHeld:H.contextHeld,readingsDropped:H.readingsDropped,pendingModel:H.pendingModel,costChannels:H.costChannels,controlsThirdBox:Uke})}),f.jsxs("div",{className:"contents",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1 shrink-0",children:[f.jsx(wt,{content:Y("ui.chat.composer.attach_file"),children:f.jsx("span",{children:f.jsx(Se,{variant:"ghost",size:G?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:vP,onClick:Ike,"aria-label":Y("ui.chat.composer.attach_file"),"data-tour-tag":"chat-input-attach-file-button",disabled:et||ve||Ze,children:f.jsx(kRe,{"aria-hidden":"true"})})})}),Ve!==void 0&&f.jsx(KFt,{ref:D8,currentWorkingDirectory:Ve,writePath:C,pending:I,pendingAccepted:W,readOnlyReason:C?void 0:N??GQe})]}),f.jsxs("div",{"data-lo-composer-controls":!0,className:"ms-auto flex order-3 items-center gap-1",children:[ct&&aU&&f.jsx("output",{"data-preparing-indicator":"",className:"shrink-0 font-medium text-body-sm text-ink-muted",children:G?Y("ui.chat.composer.starting"):Y("ui.chat.composer.starting_recording")}),aU&&f.jsx(wt,{content:ct?Y("ui.chat.composer.starting_recording"):Xn?Y("ui.chat.composer.start_recording_hint",{shortcut:Hke,pushToTalk:dC().label}):mr,children:f.jsx("span",{children:f.jsx(Se,{variant:"ghost",size:G?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:vP,onClick:J8,"aria-label":Y("ui.chat.composer.start_recording"),"aria-busy":ct||void 0,disabled:et||!Xn,children:ct?f.jsx(po,{size:"sm"}):f.jsx(fRe,{"aria-hidden":"true"})})})}),ve&&f.jsxs(f.Fragment,{children:[f.jsx(wt,{content:Y("ui.chat.composer.confirm_recording_hint"),children:f.jsx("span",{children:f.jsx(Se,{variant:"ghost",size:G?"icon-sm":"icon",className:"text-success hover:bg-success-wash hover:text-success",onClick:$P,"aria-label":Y("ui.chat.composer.confirm_recording"),children:f.jsx(_l,{"aria-hidden":"true"})})})}),f.jsx(wt,{content:Y("ui.chat.composer.cancel_recording_hint"),children:f.jsx("span",{children:f.jsx(Se,{variant:"ghost",size:G?"icon-sm":"icon",className:"text-danger hover:bg-danger-wash hover:text-danger",onClick:yP,"aria-label":Y("ui.chat.composer.cancel_recording"),children:f.jsx(zi,{"aria-hidden":"true"})})})})]}),B8&&f.jsx("span",{"aria-hidden":"true","data-interrupt-slot":"",className:E("pointer-events-none invisible flex items-center"),children:f.jsx(Se,{variant:"danger",size:G?"icon-sm":"icon",type:"button",tabIndex:-1,children:f.jsx(p1,{"aria-hidden":"true"})})}),S?.active&&f.jsx(wt,{content:Y("ui.chat.composer.stop_work_hint"),children:f.jsx("span",{children:f.jsx(Se,{variant:"danger",size:G?"icon-sm":"icon",type:"button",onClick:S.onStop,"aria-label":Y("ui.chat.composer.stop"),"aria-keyshortcuts":"Escape","data-stopping":S.stopping===!0?"true":void 0,"aria-busy":S.stopping===!0?!0:void 0,className:E("data-[stopping]:border-danger data-[stopping]:text-ink data-[stopping]:bg-[color-mix(in_oklab,var(--color-danger-wash)_80%,var(--color-danger))]"),children:f.jsx(p1,{"aria-hidden":"true"})})})}),t&&p?f.jsx(wt,{content:Y("ui.chat.composer.stop_agent"),children:f.jsx("span",{children:f.jsx(Se,{variant:"danger",size:G?"icon-sm":"icon",type:"button",onClick:()=>m?.(p),"aria-label":Y("ui.chat.composer.stop_agent"),children:f.jsx(p1,{"aria-hidden":"true"})})})}):!ve&&!Ze&&f.jsx(wt,{content:lt!==null&&!r?Y("ui.chat.composer.ask_aside"):Y("ui.chat.composer.send_message"),children:f.jsx("span",{children:f.jsx(Se,{variant:"primary",size:G?"icon-sm":"icon",type:"submit",onPointerDown:Gke,disabled:et||Xm||!xe.trim()&&ce.length===0,className:"rounded-full disabled:bg-surface","aria-label":lt!==null&&!r?Y("ui.chat.composer.ask_aside"):Y("ui.chat.composer.send_message"),children:f.jsx(Qae,{"aria-hidden":"true"})})})})]})]})]})]})]}),_&&!na?f.jsx("div",{className:E("mt-2",lr),children:f.jsx(QLt,{})}):null,(_||R)&&St?f.jsx("div",{className:E("mt-2",lr),children:f.jsx("output",{className:"block text-body-sm text-ink-muted",children:R?"Choose a model for this conversation before sending.":"Connect a provider to send."})}):null]});return f.jsxs("div",{className:E($se,"flex w-full flex-col items-center",_r?"grow":"shrink-0",J?void 0:y6e,G?"pb-1 pt-0.5":"pb-4 pt-2"),"data-lo-composer-band":!0,ref:Rn,onDragOver:Vke,onDragLeave:Mke,onDrop:Lke,children:[f.jsx("div",{"data-lo-composer-splash":"",className:E("flex w-full flex-col items-center justify-center",_r?"grow":null),children:f.jsx("div",{ref:$r,className:E(dv?"flex w-full flex-col items-center gap-6 py-4":"hidden"),children:dv?f.jsxs(f.Fragment,{children:[f.jsx("span",{"data-lo-empty-mark":"",className:"contents",children:f.jsx(AHt,{className:"size-8",tone:"ink-muted"})}),_?null:f.jsx("h2",{className:"text-center text-ink text-title",children:Y("ui.chat.composer.welcome")}),_?f.jsx("div",{className:E("w-full",lr),children:f.jsx(SLt,{})}):f.jsxs("div",{className:E("flex flex-col gap-3",lr),children:[f.jsx(eBt,{band:yt,splash:gr,foot:Gr,suggestions:Ga,disabled:Wke,onRefusedPress:vP,onSelect:Bke,focusComposer:()=>Bt.current?.focus()}),f.jsx(IMt,{suspended:xe.trim().length>0,mentionsEnabled:Oe})]})]}):null})}),na?f.jsx("div",{className:E("mb-2 mt-2",lr),children:f.jsx(xLt,{selection:tr})}):null,f.jsx("div",{ref:ra,"data-lo-composer-foot":"",className:"w-full",children:tPe})]})}),eKt=$.memo(JHt);eKt.displayName="MessageInput";const Tke=1024,ow=1024*1024,U8=.85,tKt=new Set(["image/png","image/jpeg","image/webp"]),nKt=[{maxEdge:Tke,quality:.8},{maxEdge:768,quality:.7},{maxEdge:512,quality:.6}];function rKt(e){const t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function iKt(e){const t=Uint8Array.fromBase64;if(typeof t=="function")return t.call(Uint8Array,e);const n=atob(e),r=new Uint8Array(n.length);for(let i=0;i<n.length;i+=1)r[i]=n.charCodeAt(i);return r}function aKt(e){const t=e.toBase64;if(typeof t=="function")return t.call(e);let n="";const r=32768;for(let i=0;i<e.length;i+=r)n+=String.fromCharCode(...e.subarray(i,i+r));return btoa(n)}async function oKt(e,t,n,r,i){const a=Math.max(e.width,e.height),o=a>r?r/a:1,s=Math.max(1,Math.round(e.width*o)),l=Math.max(1,Math.round(e.height*o)),c=new OffscreenCanvas(s,l),u=c.getContext("2d");if(!u)return null;u.drawImage(e,0,0,s,l);const O=[],d=await c.convertToBlob({type:"image/png"}),h=new Uint8Array(await d.arrayBuffer());if(h.byteLength<=ow&&O.push({bytes:h,mime_type:"image/png"}),h.byteLength>ow||i<U8){const g=new OffscreenCanvas(s,l),y=g.getContext("2d");if(!y)return null;y.fillStyle="#ffffff",y.fillRect(0,0,s,l),y.drawImage(e,0,0,s,l);const v=await g.convertToBlob({type:"image/jpeg",quality:i}),x=new Uint8Array(await v.arrayBuffer());O.push({bytes:x,mime_type:"image/jpeg"}),h.byteLength>ow&&x.byteLength>h.byteLength&&O.push({bytes:h,mime_type:"image/png"})}let p=null,m=Number.POSITIVE_INFINITY;for(const g of O)g.bytes.byteLength<m&&(p=g,m=g.bytes.byteLength);return p?m>=n?t:{data_b64:aKt(p.bytes),mime_type:p.mime_type}:null}async function sKt(e){if(!tKt.has(e.mime_type)||typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")return null;try{return await createImageBitmap(new Blob([iKt(e.data_b64)],{type:e.mime_type}))}catch{return null}}async function lKt(e,t,n,r){const i=rKt(e.data_b64);try{return Math.max(t.width,t.height)<=n&&i<=ow&&r>=U8?e:await oKt(t,e,i,n,r)??e}catch{return e}}async function cKt(e,t,n){if(!e.length)return e;const r=await Promise.all(e.map(i=>sKt(i)));try{return await uKt(e,r,t,n)}finally{for(const i of r)i?.close()}}async function uKt(e,t,n,r){const i=(c,u)=>Promise.all(e.map((O,d)=>{const h=t[d];return h?lKt(O,h,c,u):Promise.resolve(O)})),a=await i(Tke,U8);if(r(a)<=n)return a;let o=e,s=r(e);const l=c=>{const u=r(c);return u<s&&(o=c,s=u),u};l(a);for(const c of nKt){const u=await i(c.maxEdge,c.quality);if(l(u)<=n)return u}return o}const OKt=/^data:(image\/(png|jpeg|gif|webp));base64,(.+)$/,dKt=/^file:\/\//,fKt={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"};async function Fnn(e,t){const n=[],r=[];for(const a of e){const o=OKt.exec(a);if(o){n.push({data_b64:o[3],mime_type:o[1]});continue}const s=a.split(".").pop()?.toLowerCase()??"",l=fKt[s];if(!l||!window.api?.readFile)continue;const c=await window.api.readFile(a.replace(dKt,""),"base64");c.success?n.push({data_b64:c.data,mime_type:l}):r.push(a)}const i=Math.max(0,n.length-mE);return{images:await cKt(n.slice(0,mE),YS,a=>zE(t,a)),unreadable:r,overflow:i}}function Bnn(e){if(e.length===0)return null;const t=e.map(bQ);return t.length===1?`${t[0]} could not be read (it may have been moved or deleted), so this message was not sent. Attach it again, or remove it from the draft.`:`${t.join(", ")} could not be read (they may have been moved or deleted), so this message was not sent. Attach them again, or remove them from the draft.`}function Hnn(e){if(e<=0)return null;const t=mE,n=t+e;return e===1?`This draft carries ${n} images and one message carries up to ${t}, so this message was not sent. Remove the extra image, or send it in a second message.`:`This draft carries ${n} images and one message carries up to ${t}, so this message was not sent. Remove ${e} of them, or send them in a second message.`}function Knn(e){const t=e.trim();if(t.startsWith("="))return null;const n=t.toLowerCase();return n==="pause"||n==="resume"||n==="status"?n:null}function Jnn(e){const t=e.trim();return t.startsWith("=")?t.slice(1).trimStart():t}function ern(e,t){return e==="pause"?{text:"Aida is paused. She will not check in until you resume her.",kind:"success"}:e==="resume"?{text:"Aida is resumed. She will check in on her usual schedule.",kind:"success"}:{kind:"info",text:t.paused?"Aida is paused.":"Aida is active."}}function hKt(e){return Qs(e,"Aida's controls could not reach the backend.")}const trn="The chief of staff is switched off on this install.",pKt="aida_no_provider",mKt="aida_disabled";function nrn(e,t){const n=e instanceof Nn?e.code:void 0;return n===mKt?null:n===pKt?{kind:"info",text:`${t} will say hello once an AI account is connected. Connect one from the chat to start.`}:{kind:"error",text:`${t}'s conversation could not be opened, so you are in a new chat instead. ${hKt(e)}`}}function rrn(e,t){if(e.held===!0)return`${t} is already open in another window, so she will say hello there.`;const n=e.greeting_state==="delivered"||e.greeting_state==="skipped"||e.greeting_state==null&&e.greeted===!0;return e.paused&&!n?`${t} is paused, so she will say hello when you resume her: type /aida resume.`:null}function irn(e){const t=e?.greeting_state;return t==null||t==="owed"}function gKt(e){return e.eventKey===e.storeKey&&!e.focused}let $ie=!1;function arn(){if($ie)return;$ie=!0;const e=Yn.persist?.getOptions?.()?.name??"conversation-input-store",t=n=>{gKt({eventKey:n.key,storeKey:e,focused:document.hasFocus()})&&Yn.persist?.rehydrate?.()?.catch?.(()=>{})};window.addEventListener("storage",t)}export{jtn as $,EQ as A,zy as B,Kd as C,Pr as D,nt as E,hr as F,Cr as G,Io as H,Uz as I,ea as J,An as K,$n as L,Dn as M,vz as N,Ko as O,jKt as P,wKt as Q,CKt as R,N0 as S,Kr as T,CA as U,LA as V,Fl as W,kr as X,Cze as Y,Z0 as Z,qtn as _,Kn as a,y6e as a$,h1e as a0,c6 as a1,UE as a2,vy as a3,Vd as a4,h7e as a5,trn as a6,Fnn as a7,Bnn as a8,Hnn as a9,qa as aA,Mjt as aB,FA as aC,Dwe as aD,ev as aE,Lwe as aF,Xnn as aG,VCt as aH,fee as aI,dee as aJ,dxe as aK,c8 as aL,Ck as aM,j7t as aN,q7t as aO,wp as aP,E7t as aQ,R7t as aR,Hx as aS,nv as aT,s8 as aU,a8 as aV,od as aW,Bx as aX,T7e as aY,Xx as aZ,lr as a_,YJt as aa,fDe as ab,ed as ac,Gp as ad,JO as ae,eKt as af,YEe as ag,wJt as ah,kKt as ai,_Kt as aj,arn as ak,FJt as al,MJt as am,PKt as an,k7e as ao,xE as ap,wd as aq,JRe as ar,my as as,ytn as at,Js as au,lh as av,qi as aw,yae as ax,ZC as ay,kE as az,Es as b,ybe as b$,$se as b0,p1 as b1,aen as b2,EKt as b3,QTe as b4,ien as b5,f6 as b6,gCe as b7,ise as b8,nen as b9,NC as bA,gy as bB,FS as bC,Pae as bD,$ae as bE,hae as bF,rRe as bG,OPt as bH,Bve as bI,Utn as bJ,YT as bK,cA as bL,NT as bM,GC as bN,Tae as bO,_ae as bP,mae as bQ,pae as bR,tae as bS,xKt as bT,Uu as bU,SKt as bV,e0 as bW,TEe as bX,Dvt as bY,m6 as bZ,iO as b_,ren as ba,ud as bb,$y as bc,ge as bd,iq as be,Bwt as bf,Ic as bg,eae as bh,STe as bi,bKt as bj,K2e as bk,y7e as bl,jm as bm,R4e as bn,VP as bo,Fbe as bp,IU as bq,VU as br,Oae as bs,AKt as bt,MC as bu,WJt as bv,xEe as bw,DL as bx,Gh as by,wae as bz,D1e as c,j7e as c$,R6e as c0,zd as c1,ebe as c2,g6 as c3,$Ce as c4,eXe as c5,M2e as c6,_Gt as c7,SO as c8,EJt as c9,Wnn as cA,RBt as cB,w1e as cC,xae as cD,H9 as cE,$Mt as cF,rO as cG,Ioe as cH,VJt as cI,Qkt as cJ,Tkt as cK,wtn as cL,pF as cM,dF as cN,_kt as cO,SZt as cP,xi as cQ,Gl as cR,DJt as cS,LTt as cT,VO as cU,L_t as cV,MRe as cW,c4e as cX,TKt as cY,Ann as cZ,_7e as c_,u7e as ca,lc as cb,PGt as cc,Kk as cd,Jk as ce,BUt as cf,Bk as cg,Voe as ch,QKt as ci,Wje as cj,jae as ck,R7e as cl,Bbe as cm,HXt as cn,$1e as co,Gxt as cp,Vp as cq,Rtn as cr,QTt as cs,O1e as ct,Etn as cu,E2t as cv,Cj as cw,TBt as cx,Unn as cy,tc as cz,xnn as d,_E as d$,X_t as d0,uXe as d1,Atn as d2,vd as d3,ewe as d4,jx as d5,Vx as d6,wee as d7,a7t as d8,Y$ as d9,Ftn as dA,Ntn as dB,Btn as dC,Mtn as dD,Dtn as dE,rae as dF,nae as dG,NJt as dH,GJt as dI,j4e as dJ,ZJt as dK,IJt as dL,wEe as dM,P7e as dN,Vje as dO,LJt as dP,LP as dQ,AZe as dR,IZe as dS,eWe as dT,F0 as dU,CZe as dV,kue as dW,wje as dX,xje as dY,ua as dZ,O3e as d_,K4t as da,J4t as db,H4t as dc,B4t as dd,F4t as de,L4t as df,M4t as dg,kk as dh,R4t as di,X4t as dj,V4t as dk,D4t as dl,W4e as dm,En as dn,LS as dp,Htn as dq,Jtn as dr,Ltn as ds,Vtn as dt,cC as du,Gtn as dv,Ztn as dw,Itn as dx,Ktn as dy,enn as dz,Pnn as e,AHt as e$,Q$ as e0,n6 as e1,yJt as e2,Ytn as e3,Wtn as e4,Jqe as e5,dJt as e6,uJt as e7,OJt as e8,gJt as e9,fJt as eA,G2e as eB,BKt as eC,toe as eD,nJt as eE,DT as eF,vJt as eG,wRe as eH,sqe as eI,eJt as eJ,hJt as eK,lJt as eL,Lqe as eM,mJt as eN,Eqe as eO,cJt as eP,B2t as eQ,TE as eR,Wqe as eS,tnn as eT,_Qe as eU,nnn as eV,Stn as eW,e2t as eX,F2e as eY,hoe as eZ,f3e as e_,$Jt as ea,Xqe as eb,tJt as ec,JKt as ed,rJt as ee,FKt as ef,MT as eg,iJt as eh,jj as ei,R2t as ej,_2t as ek,aJt as el,pw as em,Dqe as en,sJt as eo,z2t as ep,iXe as eq,MS as er,lae as es,wA as et,aB as eu,Rg as ev,HKt as ew,noe as ex,YRe as ey,pJt as ez,Snn as f,Wo as f$,fae as f0,a4e as f1,sze as f2,uze as f3,dze as f4,fen as f5,hen as f6,pen as f7,Qze as f8,ven as f9,fz as fA,Gue as fB,Wue as fC,Aue as fD,Uue as fE,Cen as fF,r6 as fG,yoe as fH,Q3e as fI,By as fJ,Hve as fK,Wa as fL,pn as fM,uO as fN,vt as fO,Ue as fP,st as fQ,Ben as fR,pi as fS,sZ as fT,em as fU,io as fV,ic as fW,nOe as fX,Ft as fY,kn as fZ,Qd as f_,gen as fa,yze as fb,Zse as fc,ben as fd,YXe as fe,wze as ff,men as fg,Xze as fh,wen as fi,$en as fj,cze as fk,_n as fl,yen as fm,cae as fn,QEe as fo,SJt as fp,XE as fq,M2t as fr,E_t as fs,mz as ft,zen as fu,Ren as fv,aDe as fw,Xen as fx,hz as fy,Nue as fz,Tnn as g,Ew as g$,Ol as g0,Nen as g1,Sde as g2,DLe as g3,Ku as g4,ILe as g5,zn as g6,qt as g7,Hd as g8,ji as g9,atn as gA,RQ as gB,Ven as gC,Rye as gD,L9 as gE,Cre as gF,Aae as gG,TW as gH,mEe as gI,M4e as gJ,EMt as gK,DQe as gL,N6e as gM,Gse as gN,Pke as gO,kRe as gP,Zoe as gQ,dC as gR,fRe as gS,Qae as gT,gtn as gU,sAe as gV,I4e as gW,D4e as gX,vve as gY,yve as gZ,Een as g_,Or as ga,bi as gb,yc as gc,ab as gd,Iw as ge,TQ as gf,Fen as gg,Dc as gh,ctn as gi,ntn as gj,yBe as gk,Hen as gl,Ken as gm,Ien as gn,rtn as go,Gen as gp,Zen as gq,ttn as gr,itn as gs,otn as gt,ltn as gu,utn as gv,Men as gw,Len as gx,Den as gy,kQ as gz,UH as h,Xbe as h$,cQ as h0,xle as h1,S5 as h2,RYe as h3,XYe as h4,wle as h5,Sen as h6,Kle as h7,ta as h8,lO as h9,Inn as hA,Gnn as hB,EBt as hC,Ynn as hD,Nnn as hE,r7e as hF,o6 as hG,k0 as hH,Vnn as hI,$h as hJ,bnn as hK,qh as hL,wnn as hM,zBt as hN,nXe as hO,_Jt as hP,dkt as hQ,rse as hR,sje as hS,TJt as hT,J2t as hU,GKt as hV,Dnn as hW,XEe as hX,Mnn as hY,m5t as hZ,g5t as h_,ky as ha,ken as hb,QAe as hc,DYe as hd,iIe as he,Qw as hf,N6 as hg,q6 as hh,eq as hi,Hle as hj,AAe as hk,vAe as hl,jAe as hm,IN as hn,Jle as ho,Ile as hp,HWe as hq,JXe as hr,Sae as hs,bQ as ht,zue as hu,oDe as hv,dDe as hw,Znn as hx,cE as hy,mke as hz,Qnn as i,ZEe as i$,J1 as i0,WKt as i1,UXe as i2,NKt as i3,CBt as i4,YKt as i5,UKt as i6,ZKt as i7,UEe as i8,hPt as i9,xJt as iA,gze as iB,znn as iC,den as iD,$6e as iE,QW as iF,Goe as iG,Cje as iH,CJt as iI,C5t as iJ,qbe as iK,rMt as iL,GQe as iM,Rnn as iN,gm as iO,Knn as iP,ern as iQ,hKt as iR,Jnn as iS,IQe as iT,oen as iU,cen as iV,sen as iW,len as iX,UJt as iY,T1e as iZ,Okt as i_,y6 as ia,xy as ib,B9 as ic,pPt as id,qen as ie,Nxt as ig,jen as ih,dae as ii,KFt as ij,lRt as ik,C1e as il,n5 as im,Zp as io,q7e as ip,_tn as iq,Ttn as ir,Xtn as is,kae as it,PEe as iu,uen as iv,JS as iw,QJt as ix,x3e as iy,kJt as iz,_nn as j,dnn as j$,p6e as j0,m6e as j1,Oen as j2,KKt as j3,oJt as j4,H2t as j5,Enn as j6,Lnn as j7,vtn as j8,jnn as j9,Qtn as jA,Ptn as jB,c1e as jC,Cc as jD,ktn as jE,Q7e as jF,o1e as jG,snn as jH,$nn as jI,ynn as jJ,lnn as jK,vnn as jL,BS as jM,rTt as jN,BMt as jO,fnn as jP,hnn as jQ,OTt as jR,ann as jS,OXt as jT,inn as jU,onn as jV,lXt as jW,unn as jX,mnn as jY,pnn as jZ,$k as j_,PJt as ja,iqe as jb,aqe as jc,oqe as jd,LKt as je,MKt as jf,J3e as jg,K3e as jh,Eoe as ji,VKt as jj,Iae as jk,IKt as jl,DKt as jm,Cnn as jn,btn as jo,qnn as jp,nw as jq,SRe as jr,Nu as js,RJt as jt,yje as ju,XJt as jv,d7e as jw,iTt as jx,a1e as jy,gnn as jz,A$ as k,Onn as k0,cnn as k1,VC as k2,FQe as k3,S1e as k4,AE as k5,irn as k6,rrn as k7,nrn as k8,DTt as k9,Ym as kA,JJt as kB,zKt as kC,m1 as kD,een as kE,RKt as kF,Ten as kG,$tn as kH,m1e as ka,p1e as kb,pCe as kc,GF as kd,Ctn as ke,ztn as kf,k_t as kg,ten as kh,Mje as ki,Lje as kj,qJt as kk,n7e as kl,zJt as km,jJt as kn,bJt as ko,L7e as kp,AJt as kq,Ti as kr,Lp as ks,xen as kt,rnn as ku,xtn as kv,qTt as kw,KJt as kx,BJt as ky,HJt as kz,Fx as l,knn as m,B1e as n,I4t as o,pp as p,nl as q,dd as r,qx as s,Qk as t,wn as u,k as v,jA as w,gn as x,ir as y,un as z};